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

use strict;

package Raritan::RPC::pdumodel::VoltageMonitoringSensor_1_0_1::Event;

use Raritan::RPC::pdumodel::Waveform;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'type'} = 1 * $in->{'type'};
    $encoded->{'timestamp'} = 1 * $in->{'timestamp'};
    $encoded->{'duration'} = 1 * $in->{'duration'};
    $encoded->{'voltage'} = 1 * $in->{'voltage'};
    $encoded->{'waveform'} = Raritan::RPC::pdumodel::Waveform::encode($in->{'waveform'});
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'type'} = ($in->{'type'} < 3 ? $in->{'type'} : 2);
    $decoded->{'timestamp'} = $in->{'timestamp'};
    $decoded->{'duration'} = $in->{'duration'};
    $decoded->{'voltage'} = $in->{'voltage'};
    $decoded->{'waveform'} = Raritan::RPC::pdumodel::Waveform::decode($agent, $in->{'waveform'});
    return $decoded;
}

1;
