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

use strict;

package Raritan::RPC::peripheral::PackageInfo_2_0_1;

use Raritan::RPC::peripheral::PackageInfo_2_0_1::FirmwareInfo;
use Raritan::RPC::peripheral::PackageInfo_2_0_1::HardwareInfo;
use Raritan::RPC::peripheral::PosElement;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'state'} = 1 * $in->{'state'};
    $encoded->{'position'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'position'}}; $i0++) {
        $encoded->{'position'}->[$i0] = Raritan::RPC::peripheral::PosElement::encode($in->{'position'}->[$i0]);
    }
    $encoded->{'hwInfo'} = Raritan::RPC::peripheral::PackageInfo_2_0_1::HardwareInfo::encode($in->{'hwInfo'});
    $encoded->{'fwInfo'} = Raritan::RPC::peripheral::PackageInfo_2_0_1::FirmwareInfo::encode($in->{'fwInfo'});
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'state'} = $in->{'state'};
    $decoded->{'position'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'position'}}; $i0++) {
        $decoded->{'position'}->[$i0] = Raritan::RPC::peripheral::PosElement::decode($agent, $in->{'position'}->[$i0]);
    }
    $decoded->{'hwInfo'} = Raritan::RPC::peripheral::PackageInfo_2_0_1::HardwareInfo::decode($agent, $in->{'hwInfo'});
    $decoded->{'fwInfo'} = Raritan::RPC::peripheral::PackageInfo_2_0_1::FirmwareInfo::decode($agent, $in->{'fwInfo'});
    return $decoded;
}

1;
