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

use strict;

package Raritan::RPC::peripheral::GatewaySensorManager::RemoteModbusDevice;

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

sub encode {
    my ($in) = @_;
    my $encoded = Raritan::RPC::peripheral::GatewaySensorManager::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::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.RemoteModbusDevice', 1, 0, 0, 'Raritan::RPC::peripheral::GatewaySensorManager::RemoteModbusDevice');
1;
