/* 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_2 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_7 voltage;             ///< RMS voltage sensor (may be a VoltageMonitoringSensor)
            sensors.NumericSensor_4_0_7 current;             ///< RMS current sensor
            sensors.NumericSensor_4_0_7 peakCurrent;         ///< Peak current sensor
            sensors.NumericSensor_4_0_7 residualCurrent;     ///< Residual current sensor
            sensors.NumericSensor_4_0_7 residualACCurrent;   ///< AC Residual current sensor
                                                             ///< (AC portion of residual operating current)
            sensors.NumericSensor_4_0_7 residualDCCurrent;   ///< DC Residual current sensor
                                                             ///< (DC portion of residual operating current)
            sensors.NumericSensor_4_0_7 activePower;         ///< Active power sensor
            sensors.NumericSensor_4_0_7 reactivePower;       ///< Reactive power sensor
            sensors.NumericSensor_4_0_7 apparentPower;     ///< Apparent power sensor
            sensors.NumericSensor_4_0_7 powerFactor;         ///< Power factor sensor
            sensors.NumericSensor_4_0_7 displacementPowerFactor; ///< Displacement power factor sensor
            sensors.NumericSensor_4_0_7 activeEnergy;        ///< Active energy sensor
            sensors.NumericSensor_4_0_7 apparentEnergy;    ///< Apparent energy sensor
            sensors.NumericSensor_4_0_7 unbalancedCurrent; ///< Current unbalance sensor
            sensors.NumericSensor_4_0_7 unbalancedLineLineCurrent; ///< Line-Line current unbalance sensor
            sensors.NumericSensor_4_0_7 unbalancedVoltage; ///< Voltage unbalance sensor
            sensors.NumericSensor_4_0_7 unbalancedLineLineVoltage; ///< Line-Line voltage unbalance sensor
            sensors.NumericSensor_4_0_7 lineFrequency;     ///< Line AC frequency sensor
            sensors.NumericSensor_4_0_7 phaseAngle;        ///< Phase angle sensor
            sensors.NumericSensor_4_0_7 crestFactor;        ///< Crest factor sensor
            sensors.NumericSensor_4_0_7 voltageThd;         ///< Voltage total harmonic distortion sensor
            sensors.NumericSensor_4_0_7 currentThd;         ///< Current total harmonic distortion sensor
            sensors.StateSensor_4_0_6 powerQuality;        ///< Power quality sensor
            sensors.StateSensor_4_0_6 surgeProtectorStatus;  ///< Surge protector status sensor
            ResidualCurrentStateSensor_2_0_6 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_10_0_0> getPoles();

        /**
         * Get the list of inlet line pairs.
         *
         * @return List of inlet line pairs
         */
        vector<MeteredLinePair_3_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
