# $Header: https://oberon.oapd.inaf.it/shins/trunk/shins/src/iif/Interface/Ltcs/Iif/ServiceWorker.basda 3896 2022-04-13 13:24:17Z depa $

include LbtoIIFInterface.h
include LbtoIIFInterface2.h
sliceinc LbtoIIFInterface.ice
slicemap Ltcs::IifStar lbto::position2
slicemap Ltcs::IifStarcat lbto::SeqPos2

#include Ltcs/Iif/IifSide.h
include Ltcs/Iif/IifStarcat.h

namespace Ltcs

exception IIFServiceException : Basda::ServiceException
exception RotatorPolynomialException : Ltcs::IIFServiceException

include Nice/Time.h
include Basda/Vino/FitsCard.h
sliceinc Basda/Vino/FitsCardVar.ice
slicemap Basda::VinoFitsCardBox Basda::SeqVinoFitsCardVar

interface Iif
completion CMD

    # Methods [v] return the value of the corresponding property.
    # No communication to the device will be done.
    # It is a wrapper for read() or write() of the local client side property tree VAR.
    function[v] std::string SERVICE_NAME readServiceName()
    function[v] double POSITION readPosition()    

    # getInt and getString are not yet implemented
    # function[o] int RET getInt(const std::string & ddnam, const std::string & lognam)
    # function[o] std::string RET getString(const std::string & ddnam, const std::string & lognam)
    function[o] double RET getDouble(const std::string & ddnam, const std::string & lognam)
    function[o] bool isReachable()
    function[o] bool isIifReachable()
    function[o] std::string RA getRA()
    function[o] std::string DEC getDEC()
    function[o] double PA getParallacticAngle()
    function[o] std::string UTC getUTC()
    function[o] std::string LST getLST()
    function[o] double HA getHourAngle()
#    function[o] std::string HAHMS getHourAngleHms()
    function[o] double ALT getAlt()
    function[o] double AZ getAz()
    function[o] double Epoch getEpoch()
    function[o] double RA getRAradians()
    function[o] double DEC getDECradians()
    function[o] std::string setOffsetGuiding(double offx, double offy, const std::string & _coordSys, const std::string & _side)
    function[o] std::string setOffsetPointing(double offx, double offy, const std::string & _coordSys, const std::string & _move_type, const std::string & _side)
    function[o] Nice::SeqSeqDouble getRotatorPolynomials(double _starttime, int _count, double _interval, int _order, const std::string & _side )
    function[o] Nice::SeqPoint getKFPCoordinates(const std::string & _side )
    function[o] lbto::SeqPos2 getPresetStars()
    function[o] std::string getLINCstation()
    function[o] bool isSlewing()
    function[o] Basda::VinoFitsCardBox getFits(const double & _pixscal = 0.0)

    # Methods [i] are in-order commands. 
    # They use the service worker thread and can not be called concurrently.
    # The process of these procedures takes a long time.
    # While a task is running the other types of functions [v] & [i] 
    # can still be used from client side.
    function[i] std::string setPresetTelescope(int _raH, int _raMin, double _raSec, int _decDeg, int _decMin, double _decSec)
    # function[i] std::string setPresetTelescopeStar(const lbto::position2 & star)
    function[i] std::string setPresetTelescopeCat(const lbto::SeqPos2 & stars)
    function[i] lbto::result iifSyncPresetTelescope(double leftRotAngle, const std::string & leftRotMode, const std::string & leftTelescopeMode, double rightRotAngle, const std::string & rightRotMode, const std::string & rightTelescopeMode)
    function[i] lbto::result iifSyncOffsetPointing (double leftOffX,  double leftOffY,  const std::string & leftCoordSys,  const std::string & leftMoveType, double rightOffX, double rightOffY, const std::string & rightCoordSys, const std::string & rightMoveType)

    # copy-through methods of the IIF follow; for convenience of SHARK only

    function[i] lbto::result iifAcquireRefAO(bool repointFlag, const std::string & side) 
    function[i] lbto::result iifAuthorize() 
    function[i] lbto::result iifAuthorize2(const std::string & side)
    function[i] lbto::result iifBinocularControl(const std::string & flag) 
    function[i] lbto::result iifCheckRefAO(const std::string & side) 
    function[i] lbto::result iifClearHotspot() 
    function[i] lbto::result iifClearNonSidereal(bool override) 
    function[i] lbto::result iifClearOffset() 
    function[i] lbto::result iifClearReference() 
    function[i] lbto::result iifClearStars() 
    function[i] lbto::result iifCorrectModesAO(const lbto::SeqModes & modes, const std::string & side ) 
    # function[i] lbto::result iifGetKFPCoordinates(const lbto::SeqPos & list, const std::string & side) 
    function[i] lbto::result iifGetKFPCoordinates2( const lbto::SeqPos2 & list, const std::string & side) 
    function[i] lbto::result iifGetParameter(const lbto::SeqDD & _dd) 
    function[i] lbto::result iifGetRotatorPolynomials( double start, int count, double interval, int order, const std::string & side ) 
    function[i] lbto::result iifGetRotatorTrajectory( double seconds, double interval, double start, const std::string & side) 
    function[i] lbto::result iifLogEvent(const std::string & event, const std::string & description) 
    function[i] lbto::result iifMaximizeWrapTime(bool azflag, bool rotflag, const std::string & side) 
    function[i] lbto::result iifModifyAO(int NModes, double Freq, int Nbins, double TTmod, const std::string & F1spec, const std::string & F2spec, const std::string & side) 
    function[i] lbto::result iifMove(double x, double y, double z, double rx, double ry, double rz, int dflag, const std::string & movetype, const std::string & ope, int time, const std::string & side) 
    function[i] lbto::result iifMoveFocus(double absPos, const std::string & ope, const std::string & side ) 
    function[i] lbto::result iifMoveXY(double xmov, double ymov, const std::string & ope, const std::string & side) 
    function[i] lbto::result iifMoveXYZ(double xmov, double ymov, double zmov, const std::string & side ) 
    function[i] lbto::result iifOffsetGuiding(double angle, double offx, double offy, const std::string & _coordsys, const std::string & side) 
    # function[i] lbto::result iifOffsetPointing(double _rotangle, double _offx, double _offy, const std::string & _coordsys, const std::string & _ope, const std::string & _np, const std::string & _movetype, const std::string & _side) 
    function[i] lbto::result iifOffsetPointing2(double _rotangle, double _offx, double _offy, const std::string & _coordsys, const std::string & _movetype, const std::string & _side) 
    function[i] lbto::result iifOffsetXYAO(double DeltaX, double DeltaY, const std::string & side ) 
    function[i] lbto::result iifOffsetZAO(double DeltaZ, const std::string & side) 
    function[i] lbto::result iifPauseAO(const std::string & side) 
    function[i] lbto::result iifPauseGuiding(const std::string & side) 
    function[i] lbto::result iifPresetAO(const std::string & AOMode, const std::string & side) 
    function[i] lbto::result iifPresetFlatAO(const std::string & flat, const std::string & side ) 
    function[i] lbto::result iifPresetTelescope(double rotangle, const std::string & rotmode, const std::string & mode, const std::string & side) 
    function[i] lbto::result iifRefineAO(const std::string & method, const std::string & side) 
    function[i] void iifRemove() 
    function[i] lbto::result iifResumeAO(const std::string & side) 
    function[i] lbto::result iifResumeGuiding(const std::string & side) 
    function[i] lbto::result iifRotateCommon(double z, double angle, double direction, const std::string & side) 
    function[i] lbto::result iifRotatePrimary(double distance, double angle, double direction, const std::string & side) 
    function[i] lbto::result iifRotateZ(double angle, const std::string & movetype, const std::string & side ) 
    function[i] lbto::result iifRotHold(const std::string & side ) 
    function[i] lbto::result iifRotReady(bool enable, const std::string & side) 
    function[i] lbto::result iifRotServicePosition(double angle, const std::string & side ) 
    function[i] lbto::result iifRotTrack(const std::string & side) 
    function[i] lbto::result iifRunAO(const std::string & repointFlag, const std::string & side) 
    function[i] lbto::result iifSendWavefront(const lbto::SeqWF & wfs, const std::string & OPE, const std::string & side) 
    function[i] lbto::result iifSetAGWFilter(int filterNumber, const std::string & side) 
    function[i] lbto::result iifSetGuidingBinning(int factor, const std::string & side) 
    function[i] lbto::result iifSetGuidingHotspot( double coord1, double coord2, const std::string & movetype, const std::string & side) 
    function[i] lbto::result iifSetHotspot(double _offx, double _offy) 
    function[i] lbto::result iifSetNonSidereal( const lbto::nonsidereal & target, bool override) 
    # function[i] lbto::result iifSetOffset(double _offx, double _offy, const std::string & _coordsys) 
    function[i] lbto::result iifSetOffset2(double coord1, double coord2, const std::string & system, const std::string & movetype) 
    function[i] lbto::result iifSetParameter(const lbto::SeqDD & list) 
    # function[i] lbto::result iifSetPMTerm(const std::string & _name, double value, const std::string & side ) 
    function[i] lbto::result iifSetPMTerm2(const std::string & _name, double value, const std::string & movetype, const std::string & side) 
    # function[i] lbto::result iifSetReference(const lbto::SeqPos & list) 
    function[i] lbto::result iifSetReference2(const lbto::SeqPos2 & list) 
    # function[i] lbto::result iifSetStars(const lbto::SeqPos & _stars) 
    function[i] lbto::result iifSetStars2(const lbto::SeqPos2 & list) 
    function[i] lbto::result iifSetTarget(double coord1, double coord2, const std::string & coordsys, double epoch, float wl) 
    function[i] lbto::result iifStandby(int level, const std::string & side) 
    function[i] lbto::result iifStartAO(const std::string & side) 
    function[i] lbto::result iifStepFocus(double relPos, const std::string & ope, const std::string & side) 
    function[i] lbto::result iifStopAO(const std::string & reason, const std::string & side) 
    function[i] lbto::result iifTipTilt(double xrot, double yrot, const std::string & ope, const std::string & side) 
    function[i] lbto::result iifUpdateNonSiderealTarget( double RArate, double DECrate) 
    function[i] lbto::result iifUpdatePointingReference(const std::string & offset_coord, const std::string & side) 
    function[i] lbto::result iifUpdateTargetWavelength(float wavelength, const std::string & side) 
    function[i] lbto::result iifSetReference22(const lbto::SeqPos2 & list, const std::string & side)
    function[i] lbto::result iifSetStars22(const lbto::SeqPos2 & list, const std::string & side)
