/** =====================================================================	
*
*  File Name : $Id: OCSCorbaDrama.idl,v 1.13 2013/11/28 17:36:37 whtsm Exp $
*
*  Description
*  -----------
*
*  This is an IDL interface which will be used to provide an interface to the 
*  OCSCorbaDramaInterface through which CORBA clients will be able to access 
*  legacy DRAMA applications
*
*  =====================================================================
*
*   @Author : Craige Bevil 
*             Control Software Group
*             Isaac Newton Group of Telescopes
*
*  =====================================================================
*
*     Modification Log
*
*     Vers         Date        Author       Reason
*     ----         ----        ------       ------
*      1           15-Apr-03   C.Bevil      First Release
*
*     Commissioning Notes
*     -------------------
*
*     None
*     
*  =====================================================================
*
*     @Version   : $Id: OCSCorbaDrama.idl,v 1.13 2013/11/28 17:36:37 whtsm Exp $
*
*     @Author    : $Author: whtsm $
*
*     Header     : $Header: /opt/INGsrc/src/CVS/softproj/IDL/src/iOCSCORBADRAMABridge/OCSCorbaDrama.idl,v 1.13 2013/11/28 17:36:37 whtsm Exp $
*
*     Log        : $Log: OCSCorbaDrama.idl,v $
*     Log        : Revision 1.13  2013/11/28 17:36:37  whtsm
*     Log        : FJG Added support for TCS commands probe and dither. Probe for AUTOGSS, dither as requested for TCS at INT & WHT. Also added support to cancel
*     Log        : goto (gotoTarget) for PAUCAM.
*     Log        :
*     Log        : Revision 1.12  2012/03/28 13:27:43  whtsm
*     Log        : Added methods addSource and  gotoTarget for TCS commands ADD and GOTO
*     Log        :
*     Log        : Revision 1.11  2011/04/05 11:02:44  rab
*     Log        : Added setTelescopeFocusAbsolute method to set the absolute focus postion in mm.
*     Log        :
*     Log        : Revision 1.10  2010/12/07 10:36:33  rab
*     Log        : Added the setGuidingSkips method to the TCS interface to allow setting of the number of autoguider packets to be skipped.
*     Log        :
*     Log        : Revision 1.9  2008/11/25 16:02:23  cb
*     Log        : Added a new method to the TCS interface to allow the elevation limit
*     Log        : status to be modified depending on whether the laser is switched on or
*     Log        : not.
*     Log        :
*     Log        : Revision 1.8  2008/02/15 15:13:09  cb
*     Log        : Added the tweak command
*     Log        :
*     Log        : Revision 1.7  2006/08/30 10:29:47  cb
*     Log        : Added the focal station
*     Log        :
*     Log        : Revision 1.6  2005/02/24 14:17:41  cb
*     Log        : Added new methods to the TCS interface to support the new version of
*     Log        : AF2 control software which Richard is working on at the moment. It
*     Log        : includes methods such as gocat, rotator and offset,
*     Log        :
*     Log        : Revision 1.5  2004/06/03 15:47:14  cb
*     Log        : Updated the performIntegration method to increase the number of
*     Log        : arguments and to change the integration time so that we enter reals
*     Log        :
*     Log        : Revision 1.4  2004/05/30 15:09:01  cb
*     Log        : Included a method in the camera server interface such that a remote
*     Log        : task can exercise a remote integration on the camera server.
*     Log        :
*     Log        : Revision 1.3  2003/12/09 12:43:11  cb
*     Log        : Modified so that we do not use oneways when closing the application down
*     Log        :
*     Log        : Revision 1.2  2003/12/09 08:36:09  cb
*     Log        : Added more status information to that returned so some of the
*     Log        : information which is returned from the TCS is in a form ready to use.
*     Log        :
*     Log        : Revision 1.1  2003/08/19 11:50:24  cb
*     Log        : *** empty log message ***
*     Log        :
*     Log        : Revision 1.2  2003/04/16 12:06:17  cb
*     Log        : Added support for setting the focus of the telescope from the TCS
*     Log        :
*
* =====================================================================*/


module OCSCorbaDrama {

  interface TCSInterface 
  {

    // Used for setting the state of the autoguider

    enum AutoguiderState {ON,OFF,SUSPEND,RESUME,CENTRE};

    // Types of offset that can be applied 
    
    enum OffsetMode {ARC,TIME};

    // Types of rotation movement 
    
    enum RotatorMode {SKY,MOUNT,FLOATING,VERTICAL,VFLOAT};
    
    // Types of slow offsets which can be used 

    enum SlowoffsetModes {ABS,ADD};

    exception UnableToPerformTCSAction {
      string Reason;
    };

    exception UnableToCancelTCSAction {
      string Reason;
    };

    exception UnableToGetTCSData {
      string Reason;
    };

    exception UnableToSetTelescopeFocus {
      string Reason;
    };
    
    /* Structured type describing the telescope's current tracking */
    
    struct TCSData {
      double mjd;		       /* Modified Julian date (days).		      */
      double ra;		       /* RA being tracked (radians).		      */
      double dec;		       /* Dec. being tracked (radians).		      */
      double equinox;		       /* Equinox of position (years).		      */
      string coordType;		       /* Coord. system ('B', 'J' or 'A').	      */
      double alt;		       /* Altitude of Telescope (radians).	      */
      double altErr;		       /* Error in declination or altitude (radians). */
      double az;		       /* Azimuth of telescope (radians).	      */
      double azErr;		       /* Error in hour angle or azimuth (radians).   */
      double rot;		       /* Position angle of rotator (rad).	      */
      double roterr;		       /* Error in rotator position.		      */
      double parallactic;	       /* Parallactic angle (radians).		      */
      double focus;		       /* Telescope focus (mm).			      */
      double azDome;		       /* Azimuth of dome aperture (rad).	      */
      double airMass;		       /* Air mass (dimensionless).		      */
      double xApNom;		       /* Nominal Aperture X			      */
      double yApNom;		       /* Nominal Aperture Y			      */
      double xApOff;		       /* Aperture offset in x (rad).		      */
      double yApOff;		       /* Aperture offset in y (rad).		      */
      double raOff;		       /* Positional offset in RA (rad).	      */
      double decOff;		       /* Positional offset in Dec. (rad).	      */
      double skyPa;		       /* Rotator sky-position-angle (rad).	      */
      string rotMode;		       /* Code for rotator mode.		      */
      double guideX;		       /* Guiding point in x (A/G pixels).	      */
      double guideY;		       /* Guiding point in y (A/G pixels).	      */
      string guiMode;		       /* Guiding mode.				      */
      double telTemp;		       /* Telescope temperature			      */
      long vignette;		       /* True when beam is vignetted.		      */
      string last;		       /* Local Apparent Sidereal Time    	      */
      string telstat;		       /* Tracking/moving status		      */
      string RAHHMMSS;		       /* RA in HHMMSS				      */
      string DECDDMMSS;		       /* Declination in DDMMSS			      */
      string RotModeDecoded;	       /* This is the rotation status decoded	      */
      string SourceName;	       /* This is the name of the current source      */
      string SourceRA;		       /* Requested RA in radians        	      */
      string SourceDEC;		       /* Requested DEC in radians            	      */
      double SourceDiffRA;	       /* This differantial RA in radians/day	      */
      double SourceDiffDec;	       /* This differantial DEC in radians/day	      */
      string SourceEquinox;	       /* Equinox of position (years)		      */
      string SourceProperRa;	       /* Proper motion, RA (radians/year).	      */
      string SourceProperDec;	       /* Proper motion, RA (radians/year).	      */
      string SourceEpoch;	       /* This is the epoch			      */
      string SourceParallax;	       /* Annual parallax (arcsec).		      */
      string SourceRadVel;	       /* Radial velocity (km/s).		      */
      string SourceCoordType;	       /* Coord. system ('B', 'J' or 'A').	      */
      string SourceRAHHMMSS;           /* This is the RA in HHMMSS                    */
      string SourceDECDDMMSS;          /* Declination in DDMMSS                       */
      string FocalStation;             /* The selected focal station of the telescope */
    };
  
    struct TCSTarget {
      string name;                      /* Target name (up to 20 chars)                */
      double ra;                        /* Right Ascension (Radians)                   */
      double dec;                       /* Declination (Radians)                       */
      char   coordType;                 /* Coordinate system ('B','J' or 'A')          */
      double equinox;                   /* equinox of the coordinate system            */

    }; 
  
    // Fetch information relating to the TCS 

    TCSData getTCSStatusData () raises (UnableToGetTCSData);
    
    // Will be used to set the telescope focus
    
    boolean setTelescopeFocus (in double DemandedFocusPositionMM) raises (UnableToSetTelescopeFocus);

    // Will be used to set the absolute telescope focus
    
    boolean setTelescopeFocusAbsolute (in double DemandedFocusPositionMM) raises (UnableToSetTelescopeFocus);

    // Will be used to set the guiding state in the TCS
    
    boolean setGuidingStatus (in AutoguiderState GuideState, in double X, in double Y,in double EWGain, in double NSGain) raises (UnableToPerformTCSAction);
    
    // Will be used to set the number of autoguider packets skips in the TCS

    boolean setGuidingSkips (in unsigned long Skips) raises (UnableToPerformTCSAction);
    
    // Will be used to perform a slow offset
    
    boolean slowOffset (in double X, in double Y, in double SlewRate,in SlowoffsetModes SlowOffsetMode) raises (UnableToPerformTCSAction);

    // Will be used to perform a rotation of the derotator, angle is
    // specified in degrees
    
    boolean rotator (in RotatorMode RotationType,in double MountAngleDegrees) raises (UnableToPerformTCSAction);

    // Will be used to go to a specific item in the catalogue
    
    boolean gocat (in string Source) raises (UnableToPerformTCSAction);

    // Go to the target object specfied 
    
    boolean gotoTarget (in TCSTarget Target) raises (UnableToPerformTCSAction);

    // To offset the telescope from the reference position so that the
    // image moves to a given position on the detector. 
    
    boolean offset (in OffsetMode Mode, in double DeltaRARadians, in double DeltaDecRadians) raises (UnableToPerformTCSAction);

    // This command will be used to enable and disable the laser
    // elevation limit
    
    boolean laserLimitState (in boolean Enabled) raises (UnableToPerformTCSAction);
    
    // This command is used to position a field precisely on an
    // instrument. It can be used whether or not the telescope is
    // being autoguided and is useful for long-slit spectroscopy,
    // especially when two objects are to be placed on the slit
    // simultaneously. It is not advisable to use displacements of
    // more than 1 arcsec or rotations of more than 0.1Â° when
    // autoguiding, since the guide star may be lost. Larger offsets
    // can be split into successive smaller ones, or autoguiding may
    // be suspended whilst the CCD window is moved. The TCS focal
    // plane (aperture) coordinate system is used, with position angle
    // measured anticlockwise.4

    boolean tweak (in double xOffset, in double yOffset, in double rotation) raises (UnableToPerformTCSAction);

    // This command is used to add the current source block entry to the
    // TCS catalog 

    boolean addSource () raises (UnableToPerformTCSAction);

    // This command is used to cancel a GotoTarget (move of telescope)

    boolean cancelGotoTarget () raises (UnableToCancelTCSAction);

    // This command is use to dither the telescope 

    boolean dither (in double raOffset, in double decOffset) raises (UnableToPerformTCSAction);

    // This command is used to send autoguider probe position to TCs (for AUTOGSS) 
    
    boolean probe (in double radial_x, in double radial_y) raises (UnableToPerformTCSAction);

  };
 
  interface UDASInterface {

    exception UnableToPerformMerit {
      string Reason;
    };

    exception UnableToMoveShutter {
      string Reason;
    };

    exception UnableToPerformIntegration {
      string Reason;
    };

    enum IntegrationType {SCRATCH,RUN,FLASH,ARC,GLANCE,BIAS,DARK};
    
    typedef double MeritResult[4];

    MeritResult merit (in string DramaServer, 
		       in string Node, 
		       in double IntTime,
		       in long x1,
		       in long y1, 
		       in long x2,
		       in long y2,
		       in long Offset,
		       in long ColumnsToIgnore,
		       in long RowsToIgnore) raises (UnableToPerformMerit);

    MeritResult test (in string DramaServer);

    // Open the shutter

    void openShutter(in string DramaServer, in string Node) raises (UnableToMoveShutter);

    // Close the shutter 

    void closeShutter(in string DramaServer, in string Node) raises (UnableToMoveShutter);
    
    // Perform an integration on the specified camera 
    
    void performIntegration(in IntegrationType Type, in double Duration, in string Camera,in string Title,in string FileName) raises (UnableToPerformIntegration);
  };
};
