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

use strict;

package Raritan::RPC::pdumodel::Pdu_6_0_0::MetaData;

use Raritan::RPC::pdumodel::Nameplate_2_0_0;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'nameplate'} = Raritan::RPC::pdumodel::Nameplate_2_0_0::encode($in->{'nameplate'});
    $encoded->{'ctrlBoardSerial'} = "$in->{'ctrlBoardSerial'}";
    $encoded->{'hwRevision'} = "$in->{'hwRevision'}";
    $encoded->{'fwRevision'} = "$in->{'fwRevision'}";
    $encoded->{'macAddress'} = "$in->{'macAddress'}";
    $encoded->{'hasSwitchableOutlets'} = ($in->{'hasSwitchableOutlets'}) ? JSON::true : JSON::false;
    $encoded->{'hasMeteredOutlets'} = ($in->{'hasMeteredOutlets'}) ? JSON::true : JSON::false;
    $encoded->{'hasLatchingOutletRelays'} = ($in->{'hasLatchingOutletRelays'}) ? JSON::true : JSON::false;
    $encoded->{'isInlineMeter'} = ($in->{'isInlineMeter'}) ? JSON::true : JSON::false;
    $encoded->{'isEnergyPulseSupported'} = ($in->{'isEnergyPulseSupported'}) ? JSON::true : JSON::false;
    $encoded->{'hasDCInlets'} = ($in->{'hasDCInlets'}) ? JSON::true : JSON::false;
    $encoded->{'pduOrientation'} = 1 * $in->{'pduOrientation'};
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'nameplate'} = Raritan::RPC::pdumodel::Nameplate_2_0_0::decode($agent, $in->{'nameplate'});
    $decoded->{'ctrlBoardSerial'} = $in->{'ctrlBoardSerial'};
    $decoded->{'hwRevision'} = $in->{'hwRevision'};
    $decoded->{'fwRevision'} = $in->{'fwRevision'};
    $decoded->{'macAddress'} = $in->{'macAddress'};
    $decoded->{'hasSwitchableOutlets'} = ($in->{'hasSwitchableOutlets'}) ? 1 : 0;
    $decoded->{'hasMeteredOutlets'} = ($in->{'hasMeteredOutlets'}) ? 1 : 0;
    $decoded->{'hasLatchingOutletRelays'} = ($in->{'hasLatchingOutletRelays'}) ? 1 : 0;
    $decoded->{'isInlineMeter'} = ($in->{'isInlineMeter'}) ? 1 : 0;
    $decoded->{'isEnergyPulseSupported'} = ($in->{'isEnergyPulseSupported'}) ? 1 : 0;
    $decoded->{'hasDCInlets'} = ($in->{'hasDCInlets'}) ? 1 : 0;
    $decoded->{'pduOrientation'} = $in->{'pduOrientation'};
    return $decoded;
}

1;
