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

use strict;

package Raritan::RPC::peripheral::DeviceManager_3_0_1::DeviceTypeInfo;

use Raritan::RPC::sensors::NumericSensor_4_0_2::Range;
use Raritan::RPC::sensors::Sensor_4_0_2::TypeSpec;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'type'} = Raritan::RPC::sensors::Sensor_4_0_2::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_2::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_2::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_2::Range::decode($agent, $in->{'defaultRange'});
    $decoded->{'defaultDecDigits'} = $in->{'defaultDecDigits'};
    return $decoded;
}

1;
