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

use strict;

package Raritan::RPC::pdumodel::Pdu_6_0_0::Sensors;


sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'powerSupplyStatus'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'powerSupplyStatus'}}; $i0++) {
        $encoded->{'powerSupplyStatus'}->[$i0] = Raritan::RPC::ObjectCodec::encode($in->{'powerSupplyStatus'}->[$i0]);
    }
    $encoded->{'activePower'} = Raritan::RPC::ObjectCodec::encode($in->{'activePower'});
    $encoded->{'apparentPower'} = Raritan::RPC::ObjectCodec::encode($in->{'apparentPower'});
    $encoded->{'activeEnergy'} = Raritan::RPC::ObjectCodec::encode($in->{'activeEnergy'});
    $encoded->{'apparentEnergy'} = Raritan::RPC::ObjectCodec::encode($in->{'apparentEnergy'});
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'powerSupplyStatus'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'powerSupplyStatus'}}; $i0++) {
        $decoded->{'powerSupplyStatus'}->[$i0] = Raritan::RPC::ObjectCodec::decode($agent, $in->{'powerSupplyStatus'}->[$i0], 'sensors.StateSensor');
    }
    $decoded->{'activePower'} = Raritan::RPC::ObjectCodec::decode($agent, $in->{'activePower'}, 'sensors.NumericSensor');
    $decoded->{'apparentPower'} = Raritan::RPC::ObjectCodec::decode($agent, $in->{'apparentPower'}, 'sensors.NumericSensor');
    $decoded->{'activeEnergy'} = Raritan::RPC::ObjectCodec::decode($agent, $in->{'activeEnergy'}, 'sensors.NumericSensor');
    $decoded->{'apparentEnergy'} = Raritan::RPC::ObjectCodec::decode($agent, $in->{'apparentEnergy'}, 'sensors.NumericSensor');
    return $decoded;
}

1;
