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

use strict;

package Raritan::RPC::peripheral::Address_5_0_0;

use Raritan::RPC::peripheral::PosElement_2_0_0;
use Raritan::RPC::sensors::Sensor_4_0_4::TypeSpec;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'position'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'position'}}; $i0++) {
        $encoded->{'position'}->[$i0] = Raritan::RPC::peripheral::PosElement_2_0_0::encode($in->{'position'}->[$i0]);
    }
    $encoded->{'type'} = Raritan::RPC::sensors::Sensor_4_0_4::TypeSpec::encode($in->{'type'});
    $encoded->{'isActuator'} = ($in->{'isActuator'}) ? JSON::true : JSON::false;
    $encoded->{'channel'} = 1 * $in->{'channel'};
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'position'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'position'}}; $i0++) {
        $decoded->{'position'}->[$i0] = Raritan::RPC::peripheral::PosElement_2_0_0::decode($agent, $in->{'position'}->[$i0]);
    }
    $decoded->{'type'} = Raritan::RPC::sensors::Sensor_4_0_4::TypeSpec::decode($agent, $in->{'type'});
    $decoded->{'isActuator'} = ($in->{'isActuator'}) ? 1 : 0;
    $decoded->{'channel'} = $in->{'channel'};
    return $decoded;
}

1;
