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

use strict;

package Raritan::RPC::sensors::NumericSensor_4_0_3::Reading;

use Raritan::RPC::sensors::NumericSensor_4_0_3::Reading::Status;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'timestamp'} = 1 * $in->{'timestamp'};
    $encoded->{'available'} = ($in->{'available'}) ? JSON::true : JSON::false;
    $encoded->{'status'} = Raritan::RPC::sensors::NumericSensor_4_0_3::Reading::Status::encode($in->{'status'});
    $encoded->{'valid'} = ($in->{'valid'}) ? JSON::true : JSON::false;
    $encoded->{'value'} = 1 * $in->{'value'};
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'timestamp'} = $in->{'timestamp'};
    $decoded->{'available'} = ($in->{'available'}) ? 1 : 0;
    $decoded->{'status'} = Raritan::RPC::sensors::NumericSensor_4_0_3::Reading::Status::decode($agent, $in->{'status'});
    $decoded->{'valid'} = ($in->{'valid'}) ? 1 : 0;
    $decoded->{'value'} = $in->{'value'};
    return $decoded;
}

1;
