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

#ifndef __PDUMODEL_OUTLETGROUP_IDL__
#define __PDUMODEL_OUTLETGROUP_IDL__

#include <AccumulatingNumericSensor.idl>
#include <Outlet.idl>

module pdumodel {

    /** Outlet group interface */
    interface OutletGroup_1_1_9 {
        constant int ERR_INVALID_ARGUMENT = 1;

        /** Outlet group sensors */
        structure Sensors {
            sensors.NumericSensor_4_0_8 activePower;                ///< Active power sensor
            sensors.NumericSensor_4_0_8 apparentPower;              ///< Apparent power sensor
            sensors.AccumulatingNumericSensor_2_0_8 activeEnergy;   ///< Active energy sensor
            sensors.AccumulatingNumericSensor_2_0_8 apparentEnergy; ///< Apparent energy sensor
        };

        /** Outlet group settings */
        structure Settings {
            string name;                   ///< User-defined name
            vector<Outlet_3_0_3> members;  ///< List of member outlets
        };

        /** Outlet group metadata */
        structure MetaData {
            int groupId;                ///< (ID) Value under which OutletGroupManager references this group,
                                        ///< unique only for a given point in time
            int uniqueId;               ///< (Random) ID value uniquely identifying this group,
                                        ///< even after group deletions and creations of new groups
        };

        /** Event: Group sensors have changed */
        valueobject SensorsChangedEvent extends idl.Event {
            Sensors oldSensors;                         ///< Sensors before change
            Sensors newSensors;                         ///< Sensors after change
        };

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

        /** Event: Group switch operation has been invoked */
        valueobject PowerControlEvent extends event.UserEvent {
            Outlet_3_0_3.PowerState state;             ///< Target power state, only valid if not cycling
            boolean cycle;                             ///< Whether a power cycle operation was invoked
        };

        /**
         * Retrieve the outlet group sensors.
         *
         * @return outlet group sensors
         */
        Sensors getSensors();

        /**
         * Retrieve the outlet group metadata.
         *
         * @return outlet group metadata
         */
        MetaData getMetaData();

        /**
         * Retrieve the outlet group settings.
         *
         * @return outlet group settings
         */
        Settings getSettings();

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

        /**
         * Switch all member outlets.
         *
         * @param pstate  New power state for all outlets
         *
         * @return 0 if OK
         */
        int setAllOutletPowerStates(in Outlet_3_0_3.PowerState pstate);

        /**
         * Power-cycle all member outlets.
         *
         * @return 0 if OK
         */
        int cycleAllOutletPowerStates();
    };
}

#endif
