# 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_3_0_0::ValueEncoding;

use constant typeId => "peripheral.GatewaySensorManager_3_0_0.ValueEncoding:1.0.0";
use Raritan::RPC::peripheral::GatewaySensorManager_3_0_0::InterpretationRule;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'encodingId'} = "$in->{'encodingId'}";
    $encoded->{'type'} = 1 * $in->{'type'};
    $encoded->{'invertState'} = ($in->{'invertState'}) ? JSON::true : JSON::false;
    $encoded->{'interpretationRules'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'interpretationRules'}}; $i0++) {
        $encoded->{'interpretationRules'}->[$i0] = Raritan::RPC::ValObjCodec::encode($in->{'interpretationRules'}->[$i0]);
    }
    $encoded->{'minAccessInterval'} = 1 * $in->{'minAccessInterval'};
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'encodingId'} = $in->{'encodingId'};
    $decoded->{'type'} = $in->{'type'};
    $decoded->{'invertState'} = ($in->{'invertState'}) ? 1 : 0;
    $decoded->{'interpretationRules'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'interpretationRules'}}; $i0++) {
        $decoded->{'interpretationRules'}->[$i0] = Raritan::RPC::ValObjCodec::decode($agent, $in->{'interpretationRules'}->[$i0], 'peripheral.GatewaySensorManager_3_0_0.InterpretationRule');
    }
    $decoded->{'minAccessInterval'} = $in->{'minAccessInterval'};
    return $decoded;
}

Raritan::RPC::Registry::registerCodecClass('peripheral.GatewaySensorManager_3_0_0.ValueEncoding', 1, 0, 0, 'Raritan::RPC::peripheral::GatewaySensorManager_3_0_0::ValueEncoding');
1;
