# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2022 Raritan Inc. All rights reserved.
#
# This file was generated by IdlC from Outlet.idl.

use strict;

package Raritan::RPC::pdumodel::Outlet_1_5_7::State;

use Raritan::RPC::pdumodel::Outlet_1_5_7::LedState;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'available'} = ($in->{'available'}) ? JSON::true : JSON::false;
    $encoded->{'powerState'} = 1 * $in->{'powerState'};
    $encoded->{'switchOnInProgress'} = ($in->{'switchOnInProgress'}) ? JSON::true : JSON::false;
    $encoded->{'cycleInProgress'} = ($in->{'cycleInProgress'}) ? JSON::true : JSON::false;
    $encoded->{'ledState'} = Raritan::RPC::pdumodel::Outlet_1_5_7::LedState::encode($in->{'ledState'});
    $encoded->{'lastPowerStateChange'} = 1 * $in->{'lastPowerStateChange'};
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'available'} = ($in->{'available'}) ? 1 : 0;
    $decoded->{'powerState'} = $in->{'powerState'};
    $decoded->{'switchOnInProgress'} = ($in->{'switchOnInProgress'}) ? 1 : 0;
    $decoded->{'cycleInProgress'} = ($in->{'cycleInProgress'}) ? 1 : 0;
    $decoded->{'ledState'} = Raritan::RPC::pdumodel::Outlet_1_5_7::LedState::decode($agent, $in->{'ledState'});
    $decoded->{'lastPowerStateChange'} = $in->{'lastPowerStateChange'};
    return $decoded;
}

1;
