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

use strict;

package Raritan::RPC::peripheral::GatewaySensorManager_2_0_0::RemoteModbusDevice;

use constant typeId => "peripheral.GatewaySensorManager_2_0_0.RemoteModbusDevice:1.0.0";
use Raritan::RPC::peripheral::GatewaySensorManager_2_0_0::RemoteDevice;

sub encode {
    my ($in) = @_;
    my $encoded = Raritan::RPC::peripheral::GatewaySensorManager_2_0_0::RemoteDevice::encode($in);
    $encoded->{'detectionIdentifiers'} = [];
    foreach my $key0 (keys %{$in->{'detectionIdentifiers'}}) {
        my $value0 = $in->{'detectionIdentifiers'}->{$key0};
        my $elem0 = {};
        $elem0->{'key'} = 1 * $key0;
        $elem0->{'value'} = "$value0";
        push(@{$encoded->{'detectionIdentifiers'}}, $elem0);
    }
    $encoded->{'unitId'} = 1 * $in->{'unitId'};
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = Raritan::RPC::peripheral::GatewaySensorManager_2_0_0::RemoteDevice::decode($agent, $in);
    $decoded->{'detectionIdentifiers'} = {};
    for (my $i0 = 0; $i0 <= $#{$in->{'detectionIdentifiers'}}; $i0++) {
        my $key0 = $in->{'detectionIdentifiers'}->[$i0]->{'key'};
        my $value0 = $in->{'detectionIdentifiers'}->[$i0]->{'value'};
        $decoded->{'detectionIdentifiers'}->{$key0} = $value0;
    }
    $decoded->{'unitId'} = $in->{'unitId'};
    return $decoded;
}

Raritan::RPC::Registry::registerCodecClass('peripheral.GatewaySensorManager_2_0_0.RemoteModbusDevice', 1, 0, 0, 'Raritan::RPC::peripheral::GatewaySensorManager_2_0_0::RemoteModbusDevice');
1;
