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

use strict;

package Raritan::RPC::pdumodel::Pdu_5_0_1::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->{'activeEnergy'} = Raritan::RPC::ObjectCodec::encode($in->{'activeEnergy'});
    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->{'activeEnergy'} = Raritan::RPC::ObjectCodec::decode($agent, $in->{'activeEnergy'}, 'sensors.NumericSensor');
    return $decoded;
}

1;
