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

use strict;

package Raritan::RPC::datapush::SensorLogPushMessage;

use Raritan::RPC::datapush::Sensor;
use Raritan::RPC::datapush::LogRow;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'sensors'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'sensors'}}; $i0++) {
        $encoded->{'sensors'}->[$i0] = Raritan::RPC::datapush::Sensor::encode($in->{'sensors'}->[$i0]);
    }
    $encoded->{'rows'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'rows'}}; $i0++) {
        $encoded->{'rows'}->[$i0] = Raritan::RPC::datapush::LogRow::encode($in->{'rows'}->[$i0]);
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'sensors'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'sensors'}}; $i0++) {
        $decoded->{'sensors'}->[$i0] = Raritan::RPC::datapush::Sensor::decode($agent, $in->{'sensors'}->[$i0]);
    }
    $decoded->{'rows'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'rows'}}; $i0++) {
        $decoded->{'rows'}->[$i0] = Raritan::RPC::datapush::LogRow::decode($agent, $in->{'rows'}->[$i0]);
    }
    return $decoded;
}

1;
