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

use strict;

package Raritan::RPC::peripheral::DeviceManager_5_0_3::DeviceTypeInfo;

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

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_6::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_6::Range::decode($agent, $in->{'defaultRange'});
    $decoded->{'defaultDecDigits'} = $in->{'defaultDecDigits'};
    return $decoded;
}

1;
