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

use strict;

package Raritan::RPC::pdumodel::Pdu_6_4_4::Settings;


sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'name'} = "$in->{'name'}";
    $encoded->{'startupState'} = 1 * $in->{'startupState'};
    $encoded->{'cycleDelay'} = 1 * $in->{'cycleDelay'};
    $encoded->{'inRushGuardDelay'} = 1 * $in->{'inRushGuardDelay'};
    $encoded->{'outletPowerStateSequence'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'outletPowerStateSequence'}}; $i0++) {
        $encoded->{'outletPowerStateSequence'}->[$i0] = 1 * $in->{'outletPowerStateSequence'}->[$i0];
    }
    $encoded->{'powerOnDelay'} = 1 * $in->{'powerOnDelay'};
    $encoded->{'latchingRelays'} = ($in->{'latchingRelays'}) ? JSON::true : JSON::false;
    $encoded->{'energyPulseEnabled'} = ($in->{'energyPulseEnabled'}) ? JSON::true : JSON::false;
    $encoded->{'energyPulsesPerKWh'} = 1 * $in->{'energyPulsesPerKWh'};
    $encoded->{'demandUpdateInterval'} = 1 * $in->{'demandUpdateInterval'};
    $encoded->{'demandAveragingIntervals'} = 1 * $in->{'demandAveragingIntervals'};
    $encoded->{'suspendTripCauseOutlets'} = ($in->{'suspendTripCauseOutlets'}) ? JSON::true : JSON::false;
    $encoded->{'inhibitRelayControl'} = ($in->{'inhibitRelayControl'}) ? JSON::true : JSON::false;
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'name'} = $in->{'name'};
    $decoded->{'startupState'} = $in->{'startupState'};
    $decoded->{'cycleDelay'} = $in->{'cycleDelay'};
    $decoded->{'inRushGuardDelay'} = $in->{'inRushGuardDelay'};
    $decoded->{'outletPowerStateSequence'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'outletPowerStateSequence'}}; $i0++) {
        $decoded->{'outletPowerStateSequence'}->[$i0] = $in->{'outletPowerStateSequence'}->[$i0];
    }
    $decoded->{'powerOnDelay'} = $in->{'powerOnDelay'};
    $decoded->{'latchingRelays'} = ($in->{'latchingRelays'}) ? 1 : 0;
    $decoded->{'energyPulseEnabled'} = ($in->{'energyPulseEnabled'}) ? 1 : 0;
    $decoded->{'energyPulsesPerKWh'} = $in->{'energyPulsesPerKWh'};
    $decoded->{'demandUpdateInterval'} = $in->{'demandUpdateInterval'};
    $decoded->{'demandAveragingIntervals'} = $in->{'demandAveragingIntervals'};
    $decoded->{'suspendTripCauseOutlets'} = ($in->{'suspendTripCauseOutlets'}) ? 1 : 0;
    $decoded->{'inhibitRelayControl'} = ($in->{'inhibitRelayControl'}) ? 1 : 0;
    return $decoded;
}

1;
