# 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_4::TransferLogEntry;

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

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_4::WaveformSample::encode($in->{'waveform'}->[$i0]);
    }
    $encoded->{'statistics'} = Raritan::RPC::pdumodel::TransferSwitch_4_0_4::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_4::WaveformSample::decode($agent, $in->{'waveform'}->[$i0]);
    }
    $decoded->{'statistics'} = Raritan::RPC::pdumodel::TransferSwitch_4_0_4::Statistics::decode($agent, $in->{'statistics'});
    $decoded->{'switchFault'} = $in->{'switchFault'};
    return $decoded;
}

1;
