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

use strict;

package Raritan::RPC::sensors::Logger_2_2_7::LogRow;

use Raritan::RPC::sensors::Logger_2_2_7::Record;
use Raritan::RPC::sensors::Logger_2_2_7::Record;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'sensorSetTimestamp'} = 1 * $in->{'sensorSetTimestamp'};
    $encoded->{'timestamp'} = 1 * $in->{'timestamp'};
    $encoded->{'sensorRecords'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'sensorRecords'}}; $i0++) {
        $encoded->{'sensorRecords'}->[$i0] = Raritan::RPC::sensors::Logger_2_2_7::Record::encode($in->{'sensorRecords'}->[$i0]);
    }
    $encoded->{'peripheralDeviceRecords'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'peripheralDeviceRecords'}}; $i0++) {
        $encoded->{'peripheralDeviceRecords'}->[$i0] = Raritan::RPC::sensors::Logger_2_2_7::Record::encode($in->{'peripheralDeviceRecords'}->[$i0]);
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'sensorSetTimestamp'} = $in->{'sensorSetTimestamp'};
    $decoded->{'timestamp'} = $in->{'timestamp'};
    $decoded->{'sensorRecords'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'sensorRecords'}}; $i0++) {
        $decoded->{'sensorRecords'}->[$i0] = Raritan::RPC::sensors::Logger_2_2_7::Record::decode($agent, $in->{'sensorRecords'}->[$i0]);
    }
    $decoded->{'peripheralDeviceRecords'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'peripheralDeviceRecords'}}; $i0++) {
        $decoded->{'peripheralDeviceRecords'}->[$i0] = Raritan::RPC::sensors::Logger_2_2_7::Record::decode($agent, $in->{'peripheralDeviceRecords'}->[$i0]);
    }
    return $decoded;
}

1;
