/* SPDX-License-Identifier: BSD-3-Clause */
/*
 * Copyright 2009 Raritan Inc. All rights reserved.
 */

#ifndef __PDUMODEL_INLET_IDL__
#define __PDUMODEL_INLET_IDL__

#include <EDevice.idl>
#include <Nameplate.idl>
#include <NumericSensor.idl>
#include <StateSensor.idl>
#include <Pole.idl>
#include <ResidualCurrentStateSensor.idl>

/**
 * PDU Model
 */
module pdumodel {

    /** %Inlet interface */
    interface Inlet_3_0_3 extends EDevice_1_0_1 {

        /** %Inlet metadata */
        structure MetaData {
            string label;                       ///< %Inlet label
            string plugType;                    ///< Plug type
            Nameplate_2_0_0 namePlate;          ///< %Nameplate information
            Rating_2_0_0 rating;                ///< Numerical usage ratings
            boolean hasWaveformSupport;         ///< Whether waveform reading is supported on this inlet
            boolean isDC;                       ///< Current type, \c true for DC, \c false for AC
        };

        /** %Inlet sensors */
        structure Sensors {
            sensors.NumericSensor_4_0_8 voltage;             ///< RMS voltage sensor (may be a VoltageMonitoringSensor)
            sensors.NumericSensor_4_0_8 current;             ///< RMS current sensor
            sensors.NumericSensor_4_0_8 peakCurrent;         ///< Peak current sensor
            sensors.NumericSensor_4_0_8 residualCurrent;     ///< Residual current sensor
            sensors.NumericSensor_4_0_8 residualACCurrent;   ///< AC Residual current sensor
                                                             ///< (AC portion of residual operating current)
            sensors.NumericSensor_4_0_8 residualDCCurrent;   ///< DC Residual current sensor
                                                             ///< (DC portion of residual operating current)
            sensors.NumericSensor_4_0_8 activePower;         ///< Active power sensor
            sensors.NumericSensor_4_0_8 reactivePower;       ///< Reactive power sensor
            sensors.NumericSensor_4_0_8 apparentPower;     ///< Apparent power sensor
            sensors.NumericSensor_4_0_8 powerFactor;         ///< Power factor sensor
            sensors.NumericSensor_4_0_8 displacementPowerFactor; ///< Displacement power factor sensor
            sensors.NumericSensor_4_0_8 activeEnergy;        ///< Active energy sensor
            sensors.NumericSensor_4_0_8 apparentEnergy;    ///< Apparent energy sensor
            sensors.NumericSensor_4_0_8 unbalancedCurrent; ///< Current unbalance sensor
            sensors.NumericSensor_4_0_8 unbalancedLineLineCurrent; ///< Line-Line current unbalance sensor
            sensors.NumericSensor_4_0_8 unbalancedVoltage; ///< Voltage unbalance sensor
            sensors.NumericSensor_4_0_8 unbalancedLineLineVoltage; ///< Line-Line voltage unbalance sensor
            sensors.NumericSensor_4_0_8 lineFrequency;     ///< Line AC frequency sensor
            sensors.NumericSensor_4_0_8 phaseAngle;        ///< Phase angle sensor
            sensors.NumericSensor_4_0_8 crestFactor;        ///< Crest factor sensor
            sensors.NumericSensor_4_0_8 voltageThd;         ///< Voltage total harmonic distortion sensor
            sensors.NumericSensor_4_0_8 currentThd;         ///< Current total harmonic distortion sensor
            sensors.StateSensor_4_0_7 powerQuality;        ///< Power quality sensor
            sensors.StateSensor_4_0_7 surgeProtectorStatus;  ///< Surge protector status sensor
            ResidualCurrentStateSensor_2_0_7 residualCurrentStatus; ///< Residual current monitor state sensor
        };

        /** %Inlet settings */
        structure Settings {
            string name;                        ///< User-defined name
        };

        /** Event: Inlet settings have been changed */
        valueobject SettingsChangedEvent extends event.UserEvent {
            Settings oldSettings;               ///< Settings before change
            Settings newSettings;               ///< Settings after change
        };

        /** Event: Inlet has been enabled or disabled */
        valueobject EnableStateChangedEvent extends event.UserEvent {
            boolean enabled;                    ///< New enable state
        };

        /**
         * Retrieve the inlet metadata.
         *
         * @return %Inlet metadata
         */
        MetaData getMetaData();

        /**
         * Get the inlet sensors.
         *
         * @return %Inlet sensors
         */
        Sensors getSensors();

        /**
         * Get the list of inlet poles.
         *
         * @return List of inlet poles
         */
        vector<Pole_11_0_0> getPoles();

        /**
         * Get the list of inlet line pairs.
         *
         * @return List of inlet line pairs
         */
        vector<MeteredLinePair_4_0_0> getLinePairs();

        /**
         * Retrieve the inlet settings.
         *
         * @return %Inlet settings
         */
        Settings getSettings();

        /**
         * Change the inlet settings.
         *
         * @param settings  New inlet settings
         *
         * @return 0 if OK
         * @return 1 if any parameters are invalid
         */
        int setSettings(in Settings settings);

        /**
         * Enable/disable PDU operation for this inlet.
         *
         * When PDU operation is disabled the sensors for this inlet and all
         * children will no longer be updated, and outlet switching is no
         * longer allowed. This can be useful for multi-inlet units if one
         * inlet is temporarily expected to be powered down.
         *
         * @param enabled  \c true to enable PDU operation
         */
        void setEnabled(in boolean enabled);

        /**
         * Test whether PDU operation is enabled for this inlet.
         *
         * @return \c true if PDU operation is enabled
         */
        boolean isEnabled();
    };

}

#endif
