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

use strict;

package Raritan::RPC::peripheral::DeviceManager_5_0_1::DeviceTypeInfo;

use Raritan::RPC::sensors::Sensor_4_0_5::TypeSpec;
use Raritan::RPC::sensors::NumericSensor_4_0_5::Range;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'type'} = Raritan::RPC::sensors::Sensor_4_0_5::TypeSpec::encode($in->{'type'});
    $encoded->{'isActuator'} = ($in->{'isActuator'}) ? JSON::true : JSON::false;
    $encoded->{'identifier'} = "$in->{'identifier'}";
    $encoded->{'name'} = "$in->{'name'}";
    $encoded->{'defaultRange'} = Raritan::RPC::sensors::NumericSensor_4_0_5::Range::encode($in->{'defaultRange'});
    $encoded->{'defaultDecDigits'} = 1 * $in->{'defaultDecDigits'};
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'type'} = Raritan::RPC::sensors::Sensor_4_0_5::TypeSpec::decode($agent, $in->{'type'});
    $decoded->{'isActuator'} = ($in->{'isActuator'}) ? 1 : 0;
    $decoded->{'identifier'} = $in->{'identifier'};
    $decoded->{'name'} = $in->{'name'};
    $decoded->{'defaultRange'} = Raritan::RPC::sensors::NumericSensor_4_0_5::Range::decode($agent, $in->{'defaultRange'});
    $decoded->{'defaultDecDigits'} = $in->{'defaultDecDigits'};
    return $decoded;
}

1;
