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

use strict;

package Raritan::RPC::peripheral::GatewaySensorManager::ConfigurationPackage;

use Raritan::RPC::peripheral::GatewaySensorManager::ValueEncoding;
use Raritan::RPC::peripheral::GatewaySensorManager::SensorClass;
use Raritan::RPC::peripheral::GatewaySensorManager::RemoteDevice;
use Raritan::RPC::peripheral::GatewaySensorManager::Sensor;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'disabled'} = ($in->{'disabled'}) ? JSON::true : JSON::false;
    $encoded->{'name'} = "$in->{'name'}";
    $encoded->{'classes'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'classes'}}; $i0++) {
        $encoded->{'classes'}->[$i0] = Raritan::RPC::ValObjCodec::encode($in->{'classes'}->[$i0]);
    }
    $encoded->{'devices'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'devices'}}; $i0++) {
        $encoded->{'devices'}->[$i0] = Raritan::RPC::ValObjCodec::encode($in->{'devices'}->[$i0]);
    }
    $encoded->{'encodings'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'encodings'}}; $i0++) {
        $encoded->{'encodings'}->[$i0] = Raritan::RPC::ValObjCodec::encode($in->{'encodings'}->[$i0]);
    }
    $encoded->{'sensors'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'sensors'}}; $i0++) {
        $encoded->{'sensors'}->[$i0] = Raritan::RPC::ValObjCodec::encode($in->{'sensors'}->[$i0]);
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'disabled'} = ($in->{'disabled'}) ? 1 : 0;
    $decoded->{'name'} = $in->{'name'};
    $decoded->{'classes'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'classes'}}; $i0++) {
        $decoded->{'classes'}->[$i0] = Raritan::RPC::ValObjCodec::decode($agent, $in->{'classes'}->[$i0], 'peripheral.GatewaySensorManager.SensorClass');
    }
    $decoded->{'devices'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'devices'}}; $i0++) {
        $decoded->{'devices'}->[$i0] = Raritan::RPC::ValObjCodec::decode($agent, $in->{'devices'}->[$i0], 'peripheral.GatewaySensorManager.RemoteDevice');
    }
    $decoded->{'encodings'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'encodings'}}; $i0++) {
        $decoded->{'encodings'}->[$i0] = Raritan::RPC::ValObjCodec::decode($agent, $in->{'encodings'}->[$i0], 'peripheral.GatewaySensorManager.ValueEncoding');
    }
    $decoded->{'sensors'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'sensors'}}; $i0++) {
        $decoded->{'sensors'}->[$i0] = Raritan::RPC::ValObjCodec::decode($agent, $in->{'sensors'}->[$i0], 'peripheral.GatewaySensorManager.Sensor');
    }
    return $decoded;
}

1;
