/* ******************************************************************************************* */
/* IRA Istituto di Radioastronomia                                                                                                  */
/*                                                                                                                                                         */
/* This code is under GNU General Public Licence (GPL).                                                             */
/*                                                                                                                                                         */
/* Who                                                 When                  What                                                           */
/* Andrea Orlati(aorlati@ira.inaf.it)  22/01/2008      Creation                                                    */
/* Andrea Orlati(a.orlati@ira.inaf.it) 19/02/2008     Added the Boolean enum interface        */ 
/* Andrea Orlati(a.orlati@ira.inaf.it) 24/11/2009     Added the CommandInterpreter Interface   */
/* Andrea Orlati, Marco Buttu          30/03/2010     Added the Subsystem Interface   */
/* Marco Bartolini                     24/05/2012     Added the LogLevel enum interface   */
/* Andrea Orlati(a.orlati@ira.inaf.it)   08/04/2013    MNG_SKYDIP added to TScanTypes, expanded the definition of TScanAxis*/

#ifndef _MANAGMENTDEFINITIONS_IDL_

#define _MANAGMENTDEFINITIONS_IDL_

#include <baci.idl>
#include <enumpropMACRO.idl>
#include <ManagementErrors.idl>

#pragma prefix "alma"

/** 
 * @mainpage IDL Interface documentation of the managment subsystem
 * @date 08/04/2013
 * @version 0.51.0
 * @author <a href=mailto:a.orlati@ira.inaf.it>Andrea Orlati</a>, 
 * @remarks Last compiled under ACS 8.2.0
*/

/**
 * @todo add a description of the module here
 */
module Management  {
	
	/**
	 * This is the interface defines how a command line interpreter looks like. 
	 * Any component, able to interpret and executes human readable commands, must have implemented this interface.
	 * @author <a href=mailto:a.orlati@ira.inaf.it>Andrea Orlati</a>,
 	 * Istituto di Radioastronomia, Italia
 	 * <br> 
 	*/
	interface CommandInterpreter  {
		/**
		 * This method can be used to execute a command or to setup a configuration The commands and configurations are given as strings.
		 * @attention the implmentation of this method must take care of logging the errors deriving from the execution of the command.
		 * @throw CORBA::SystemException 
		 * @param command this string contains the instruction to be executed, the command and the syntax may vary from implementation to implementation
		 * @param answer this string contains the answer of the system to the incoming command. It must frred by the caller
		 * @return  the result of the command, true after a succesful command invokation. false otherwise.
		 */
		//string  command(in string command) raises (ManagementErrors::CommandLineErrorEx);
		boolean command (in string command,out string answer);
	};	
	
	/**
	 * This enlists all the possible subscan that the system is able to perform. Both involving the main drives (Antenna) or the minor servo or whatever
	 */ 
	enum TScanTypes {
		MNG_SIDEREAL,          /*!< perform a sidereal tracking of a source  */     
		MNG_SUN,               /*!< tracks the sun  */     
		MNG_MOON,              /*!< tracks the moon  */     
		MNG_SATELLITE,         /*!< tracks an artificial sattelite  */     
		MNG_SOLARSYTEMBODY,    /*!< tracks a body of the solar system */
		MNG_OTF,			   /*!< perform a On the Fly Scan */
		MNG_OTFC,              /*!< this is a wrapper of the otf, it allows the system to compute the center of the on-the-fly */  
		MNG_PEAKER,             /*!< perform a peaker measurement, involving the subreflector or minor servo systems */
		MNG_SKYDIP,			 /*!< perform a skydip scan */
		MNG_NONE               /*!< no action */
	};
	
	/**
	 * This enlists all signal values during a subScan
	 */
	enum TSubScanSignal {
		MNG_SIGNAL_SIGNAL,      /*!< The subscan signal is on source  */
		MNG_SIGNAL_REFERENCE,   /*!< The subscan signal is off source  */
		MNG_SIGNAL_NONE         /*!< The subscan signal is undetermined, during OTF for example  */
	};

	/**
	 * Enlist all the supported coordinate frames
	 * @note this is derived one-one to the corresponding structure in Antenna module. This definition is present in order to avoid circular inclusion between
	 * this module and Antenna module.
	*/
	enum TCoordinateFrame {
		MNG_EQUATORIAL,      /*!< equatorial frame  */     
		MNG_HORIZONTAL,       /*!< horizontal frame  */     
		MNG_GALACTIC              /*!< galactic frame  */      
	};

	/** All the possible status that a subsystem can have, are enlisted in this macro */
	enum TSystemStatus {
		MNG_OK,               /*!< the subsystem is Ok, no errors condition found  */     
		MNG_WARNING,   /*!< the subsystem has an abnormal condition that should not affect the observation, but should be invisigated */
		MNG_FAILURE      /*!< the subsystem failed, the observation will not be succesful */
	} ;
	
	ACS_ENUM(TSystemStatus);
	
	/**
	 * The definition of boolean type for an ACS property 
	*/
	enum TBoolean {   
		MNG_TRUE,
		MNG_FALSE
	};
	
	ACS_ENUM(TBoolean);
	
    /**
     * Log level definitions for ACS custom logging utilization
    */
	enum LogLevel{
		C_TRACE,
		C_DEBUG,
		C_INFO,
		C_NOTICE,
		C_WARNING,
		C_ERROR,
		C_CRITICAL,
		C_ALERT,
		C_EMERGENCY
	};

    ACS_ENUM(LogLevel);

	/**
	 * This enumerates all the possible axis along with the control system is able to perform scans, the axis may involve the primary servo system (Antenna) or the secondary servo system (ServoMinor).
	 */ 
	enum TScanAxis {
		MNG_NO_AXIS,  /*!< No scan along any axis is currently performed */
		MNG_HOR_LON,   /*!< Scan along the horizontal longitude (azimuth) */
		MNG_HOR_LAT,   /*!< Scan along the horizontal latitude (elevation) */
		MNG_EQ_LON,     /*!< Scan along the equatorial longitude (right ascension) */
		MNG_EQ_LAT,      /*!< Scan along the equatorial latitude (declination) */
		MNG_GAL_LON,     /*!< Scan along the galactic longitude */
		MNG_GAL_LAT,     /*!< Scan along the galactic latitude ) */
		MNG_SUBR_Z,      /*!< Scan along the Z (focus) of the subreflector */
		MNG_SUBR_X,      /*!< Scan along the X of the subreflector */
		MNG_SUBR_Y,      /*!< Scan along the Y of the subreflector */
		MNG_SUBR_ROTY, /*!< rotation along the Y of the subreflector */
		MNG_SUBR_ROTX, /*!< rotation  along the X of the subreflector */
		MNG_PFP_Z,       /*!< Scan along the Z (focus) of the primary focus */
		MNG_PFP_Y,        /*!< Scan along the Y of the primary focus */
		MNG_BEAMPARK, /*!< Scan consists of a fixed horizontal position */
		MNG_TRACK,   /*!< Scan consists of a normal, combined  movement */
		MNG_GCIRCLE /*!< scan is a great circle */
	};
	
	ACS_ENUM(TScanAxis);
	
	/**
	 * This defines the basic interface that all the subystem bosses must inherits from. It contains the minimun services ad attributes needed by a 
	 * supervisor to drive the subsystem
 	 * @author <a href=mailto:a.orlati@ira.inaf.it>Andrea Orlati</a>,
 	 * Istituto di Radioastronomia, Italia
 	 * <br>
 	 * @author <a href=mailto:mbuttu@oa-cagliari.inaf.it>Marco Buttu</a>,
 	 * Osservatorio di Cagliari, Italia
 	 * <br> 
	 */
	interface Subsystem {
		/**
		 * This attribute reports the general status of the subsystem
		 */
		readonly attribute Management::ROTSystemStatus status;
		
		/**
		 * It allows the caller to ask the boss for a specific configuration.
		 * @param config this string stores the code for the required configuration
		 * @throw ManagementErrors::ConfigurationErrorEx
		 * @throw CORBA::SystemException
		 */
		void setup(in string config) raises (ManagementErrors::ConfigurationErrorEx);
		
		/**
		 * It allows to shutdown or park or stow the subsystem, any boss should take all the action required to
		 * put its subsystem in a survival position.
		 * @throw ManagementErrors::ParkingErrorEx
		 * @throw CORBA::SystemException
		 */
		void park() raises (ManagementErrors::ParkingErrorEx);
	};
	
	/**
	 * This structure contains some information derived from the subscan parameters
	*/
	struct TSubScanConfiguration  {
		TSubScanSignal signal;			/* this indicates the signal of the current subscan */
	};

};

#endif

