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

use strict;

package Raritan::RPC::pdumodel::TransferSwitch_4_0_2::TransferLogEntry;

use Raritan::RPC::pdumodel::TransferSwitch_4_0_2::WaveformSample;
use Raritan::RPC::pdumodel::TransferSwitch_4_0_2::Statistics;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'timestamp'} = 1 * $in->{'timestamp'};
    $encoded->{'oldInlet'} = 1 * $in->{'oldInlet'};
    $encoded->{'newInlet'} = 1 * $in->{'newInlet'};
    $encoded->{'reason'} = 1 * $in->{'reason'};
    $encoded->{'waveform'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'waveform'}}; $i0++) {
        $encoded->{'waveform'}->[$i0] = Raritan::RPC::pdumodel::TransferSwitch_4_0_2::WaveformSample::encode($in->{'waveform'}->[$i0]);
    }
    $encoded->{'statistics'} = Raritan::RPC::pdumodel::TransferSwitch_4_0_2::Statistics::encode($in->{'statistics'});
    $encoded->{'switchFault'} = 1 * $in->{'switchFault'};
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'timestamp'} = $in->{'timestamp'};
    $decoded->{'oldInlet'} = $in->{'oldInlet'};
    $decoded->{'newInlet'} = $in->{'newInlet'};
    $decoded->{'reason'} = $in->{'reason'};
    $decoded->{'waveform'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'waveform'}}; $i0++) {
        $decoded->{'waveform'}->[$i0] = Raritan::RPC::pdumodel::TransferSwitch_4_0_2::WaveformSample::decode($agent, $in->{'waveform'}->[$i0]);
    }
    $decoded->{'statistics'} = Raritan::RPC::pdumodel::TransferSwitch_4_0_2::Statistics::decode($agent, $in->{'statistics'});
    $decoded->{'switchFault'} = $in->{'switchFault'};
    return $decoded;
}

1;
