# 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;

use Raritan::RPC::peripheral::PackageInfo::FirmwareInfo;
use Raritan::RPC::peripheral::PackageInfo::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::HardwareInfo::encode($in->{'hwInfo'});
    $encoded->{'fwInfo'} = Raritan::RPC::peripheral::PackageInfo::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::HardwareInfo::decode($agent, $in->{'hwInfo'});
    $decoded->{'fwInfo'} = Raritan::RPC::peripheral::PackageInfo::FirmwareInfo::decode($agent, $in->{'fwInfo'});
    return $decoded;
}

1;
