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

use strict;

package Raritan::RPC::peripheral::GatewaySensorManager::NumericSensorClass;

use constant typeId => "peripheral.GatewaySensorManager.NumericSensorClass:1.0.0";
use Raritan::RPC::peripheral::GatewaySensorManager::SensorClass;
use Raritan::RPC::sensors::NumericSensor_4_0_6::MetaData;
use Raritan::RPC::sensors::NumericSensor_4_0_6::Thresholds;

sub encode {
    my ($in) = @_;
    my $encoded = Raritan::RPC::peripheral::GatewaySensorManager::SensorClass::encode($in);
    $encoded->{'metadata'} = Raritan::RPC::sensors::NumericSensor_4_0_6::MetaData::encode($in->{'metadata'});
    $encoded->{'defaultThresholds'} = Raritan::RPC::sensors::NumericSensor_4_0_6::Thresholds::encode($in->{'defaultThresholds'});
    $encoded->{'preferCommonThresholds'} = ($in->{'preferCommonThresholds'}) ? JSON::true : JSON::false;
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = Raritan::RPC::peripheral::GatewaySensorManager::SensorClass::decode($agent, $in);
    $decoded->{'metadata'} = Raritan::RPC::sensors::NumericSensor_4_0_6::MetaData::decode($agent, $in->{'metadata'});
    $decoded->{'defaultThresholds'} = Raritan::RPC::sensors::NumericSensor_4_0_6::Thresholds::decode($agent, $in->{'defaultThresholds'});
    $decoded->{'preferCommonThresholds'} = ($in->{'preferCommonThresholds'}) ? 1 : 0;
    return $decoded;
}

Raritan::RPC::Registry::registerCodecClass('peripheral.GatewaySensorManager.NumericSensorClass', 1, 0, 0, 'Raritan::RPC::peripheral::GatewaySensorManager::NumericSensorClass');
1;
