# $Header: https://oberon.oapd.inaf.it/shins/trunk/shins/src/track_ctrl/drot/Interface/Sharknir/Drot/SharknirDrotServiceWorker.basda 2976 2020-05-14 15:38:34Z depa $

# https://svn.mpia.de/gulli/TwiceAsNice/branch/unstable/ln/laos-drot/src/Interface/Laos/Drot/LaosDrotServiceWorker.basda 15070 2018-01-26 22:16:34Z mathar $

include Nice/Time.h
include LbtoIIFInterface.h
include LbtoIIFInterface2.h
include Ltcs/Iif/IifSide.h
include Ltcs/Iif/IifStar.h
# include Ltcs/Iif/IifStarcat.h

#sliceinc ../../../lbto/LbtoIIFInterface.ice
sliceinc LbtoIIFInterface.ice
# slicemap Ltcs::IifStarcat lbto::SeqPos2


namespace Sharknir

exception ServiceException : Basda::ServiceException
exception DrotServiceException : Sharknir::ServiceException
exception DrotWrongProfileException : Sharknir::DrotServiceException
exception DrotOutOfRangeException : Sharknir::DrotServiceException
exception DrotUnitNotKnownException : Sharknir::DrotServiceException
exception DrotHomeException : Sharknir::DrotServiceException
exception DrotMotionException : Sharknir::DrotServiceException
exception DrotLimitSwitchException : Sharknir::DrotServiceException
exception DrotPythonException : Sharknir::DrotServiceException
exception DrotPolynomialToShortException : Sharknir::DrotServiceException
exception DrotCommandExecutionFailedException : Sharknir::DrotServiceException

# Two properties that store derotator starting positions for recovery by GEIRS.
# See also config/lircs/drot/lircs.moe.drot-svc.cfg which may also
# create these (but without adding the setter and getter member functions..)
property PangStrtAng VAR.PANG_STRT_ANG : double=-9999
property MotStrtAng VAR.MOT_STRT_ANG : double=-9999

# The recent estimate of the end of the trajectory, RJM 2017-04-05
# It seems to be impossible to initialize with something recognized by the parser here....
# property TrajFinDate VAR.TRAJ_FIN_DATE : Nice::Date=1970-00-00 +00:00:00.0
# property TrajFinDate VAR.TRAJ_FIN_DATE : Nice::Date=1970-00-00
property TrajFinDate VAR.TRAJ_FIN_DATE : Nice::Date

interface Drot
completion CMD
    # These method ([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()
    function[v] double POSITION.DEVICE_ENCODER readDeviceEncoderPosition()
    function[v] double POSITION.ABSOLUTE_ENCODER readAbsoluteEncoderPosition()
    function[v] double POSITION.INCREMENTAL_ENCODER readIncrementalEncoderPosition()

    # These methods ([o]) communication with the device and return current value.
    # The communication is purely synchronous.
    function[o] bool isReachable()
    function[o] double getPosition(std::string UNIT = "STEPS")
    function[o] void setPosition(double POSITION, std::string UNIT = "STEPS")
    function[o] double getDeviceEncoderPosition(std::string UNIT = "STEPS")
    function[o] double getAbsoluteEncoderPosition()
    function[o] double getIncrementalEncoderPosition()
    function[o] double convertPosition(double POSITION, bool ABSOLUTE, std::string UNIT_FROM, std::string UNIT_TO)
    function[o] double getVelocity()
    function[o] bool ATHOME isAtHome()
    function[o] bool LIMIT isAtLimit()
    function[o] bool MOVING isMoving()
    function[o] double getNamedPosition( int NAMED_POSITION )
    function[o] std::string getRA()
    function[o] void changeDerotationWithAbsoluteOffset(const Nice::Date & START_DATE, double POSITION, std::string UNIT = "DEGREE")
    function[o] void changeDerotationWithRelativeOffset(const Nice::Date & START_DATE, double POSITION, std::string UNIT = "DEGREE")
    # function[o] Nice::SeqPoint getKFPCoordinates(const lbto::SeqPos2 backupCat)
    # function[o] Nice::SeqPoint getKFPCoordinates(const Lics::Starcat backupCat)
    function[o] Nice::SeqPoint getKFPCoordinates()
    function[o] lbto::SeqPos2 getPresetStars()
    function[o] std::string getSHARKNIRstation()
    function[o] double getParallacticAngle()
    function[o] bool isSlewing()
    function[o] void setDerotationParameters1(int numPolynomials, double samplingRate, double frequency)
    function[o] void setDerotationParameters2(int polynomialOrder, int faultTolerance, int samplesPerSegment)
    function[o] void setDerotationParameters3(double debug1, double debug2, double debug3)
    function[o] void setDerotationParameters4(double debug4, double debug5, double debug6)
    function[o] std::string getMode()

    # These 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] int sharkDerotatorBacklashProcedure()
    function[i] void moveRelative( double POSITION, std::string UNIT = "DEGREE")
    function[i] void moveAbsolute( double POSITION, std::string UNIT = "DEGREE")
    function[i] void moveToHome()
    function[i] void moveToLimit(double LIMIT)
    function[i] void moveToNamedPosition( int NAMED_POSITION )
    function[i] void startDerotation( const Nice::Date & START_DATE, double POSITION, std::string UNIT = "DEGREE")
    function[i] int OsStartDerotation( const Nice::Date & START_DATE, double POSITION, int CORRECTION, bool AUTOPOS)
    function[i] Nice::SeqDouble OsGetDerotationProfile(const Nice::Date & start_date, int number_of_polynomials, float time_interval);
    function[i] int OsWaitDerotation(int SECONDS)
    # function[i] int OsExtimateDerotation( const Nice::Date & START_DATE, double POSITION, std::string UNIT, bool AUTOPOS)
    function[i] int OsStartDerotationTest(double startPosDegree, double endPosDegree, double speedDegreeSec)
    function[i] void startDerotationHere( const Nice::Date & START_DATE)
    # function[i] void startSinusCurveHere( const Nice::Date & START_DATE )
