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

use strict;

package Raritan::RPC::peripheral::SensorHub_2_0_0::DeviceInfo;

use Raritan::RPC::peripheral::PosElement_3_0_0;
use Raritan::RPC::peripheral::SensorHub_2_0_0::HubPortInfo;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'serial'} = "$in->{'serial'}";
    $encoded->{'model'} = "$in->{'model'}";
    $encoded->{'upstreamType'} = 1 * $in->{'upstreamType'};
    $encoded->{'position'} = Raritan::RPC::peripheral::PosElement_3_0_0::encode($in->{'position'});
    $encoded->{'protocolVersion'} = 1 * $in->{'protocolVersion'};
    $encoded->{'bootVersion'} = 1 * $in->{'bootVersion'};
    $encoded->{'appVersion'} = 1 * $in->{'appVersion'};
    $encoded->{'hubPortInfos'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'hubPortInfos'}}; $i0++) {
        $encoded->{'hubPortInfos'}->[$i0] = Raritan::RPC::peripheral::SensorHub_2_0_0::HubPortInfo::encode($in->{'hubPortInfos'}->[$i0]);
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'serial'} = $in->{'serial'};
    $decoded->{'model'} = $in->{'model'};
    $decoded->{'upstreamType'} = $in->{'upstreamType'};
    $decoded->{'position'} = Raritan::RPC::peripheral::PosElement_3_0_0::decode($agent, $in->{'position'});
    $decoded->{'protocolVersion'} = $in->{'protocolVersion'};
    $decoded->{'bootVersion'} = $in->{'bootVersion'};
    $decoded->{'appVersion'} = $in->{'appVersion'};
    $decoded->{'hubPortInfos'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'hubPortInfos'}}; $i0++) {
        $decoded->{'hubPortInfos'}->[$i0] = Raritan::RPC::peripheral::SensorHub_2_0_0::HubPortInfo::decode($agent, $in->{'hubPortInfos'}->[$i0]);
    }
    return $decoded;
}

1;
