# sinqmotor ## Overview This library offers base classes for EPICS motor drivers (`sinqAxis` and `sinqController`) of PSI SINQ. These classes are extensions of the classes `asynMotorAxis` and `asynMotorController` from the `asynMotor` framework (https://github.com/epics-modules/motor/tree/master/motorApp/MotorSrc) and bundle some common functionalities. ## Features sinqMotor offers a variety of additional methods for children classes to standardize certain patterns (e.g. writing messages to the IOC shell and the motor message PV). For a detailed description, please see the respective function documentation in the .h-files. All of these functions can be overwritten manually if e.g. a completely different implementation of `poll` is required. Some functions are marked as virtual, because they are called from other functions of sinqMotor and therefore need runtime polymorphism. Functions without that marker are not called anywhere in sinqMotor. ### sinqController - `stringifyAsynStatus`: Convert the enum `asynStatus` into a human-readable string. - `errMsgCouldNotParseResponse`: Write a standardized message if parsing a device response failed. - `paramLibAccessFailed`: Write a standardized message if accessing the parameter library failed. ### sinqAxis - `atFirstPoll`: This function is executed once before the first poll. If it returns anything but `asynSuccess`, it retries. - `setWatchdogEnabled`: Enables / disables the watchdog. This function is also available in the IOC shell. - `checkMovTimeoutWatchdog`: Manages a watchdog mechanism for movement operations. This watchdog compares the actual time spent in a movement operation with an expected time, which is calculated based on the distance of the current and the target position. - `poll`: This is a wrapper around `doPoll` which performs some bookkeeping tasks before and after calling `doPoll`: Before calling `doPoll`: - Try to execute `atFirstPoll` once during the lifetime of the IOC (and retry, if that failed) After calling `doPoll`: - Reset `motorStatusProblem_`, `motorStatusCommsError_` and `motorMessageText_` if `doPoll` returned `asynSuccess` - Run `callParamCallbacks` - Return the status of `doPoll` - `doPoll`: This is an empty function which should be overwritten by concrete driver implementations. - `move`: This function sets the absolute target position in the parameter library and then calls `doMove`. - `doMove`: This is an empty function which should be overwritten by concrete driver implementations. - `home`: This function sets the absolute target position in the parameter library and then calls `doHome`. The target position is assumed to be the high limit, if the distance of the current position to it is larger than that to the low limit, and the low limit otherwise. - `doHome`: This is an empty function which should be overwritten by concrete driver implementations. - `setOffsetMovTimeout`: Set a linear offset for the expected movement time. This function is also available in the IOC shell. - `setScaleMovTimeout`: Set a scaling factor for the expected movement time. This function is also available in the IOC shell. ## Versioning The versioning is done via git tags. Git tags are recognized by the PSI build system: If you tag a version as 1.0, it will be built into the directory /ioc/modules/sinqMotor/1.0. The tag is directly coupled to a commit so that it is always clear which source code was used to build which binary. All existing tags can be listed with `git tag` in the sinqMotor directory. Detailed information (author, data, commit number, commit message) regarding a specific tag can be shown with `git show X.X`, where X.X is the name of your version. To create a new tag, use `git tag X.X`. If the tag `X.X` is already used by another commit, git will show a corresponding error. ## How to build it The makefile in the top directory includes all necessary steps for compiling a shared library together with the header files into `/ioc/modules` (using the PSI EPICS build system).Therefore it is sufficient to run `make install -f Makefile` from the terminal. To use the library when writing a concrete motor driver, include it in the makefile of your application /library the same way as other libraries such as e.g. `asynMotor` by adding `REQUIRED+=sinqMotor` to your Makefile.