Rotator - Device-Specific Responders
This module contains the Rotator device-specific responder classes for the Alpaca
REST endpoints which represent ASCOM interface members.
You would need to create a module like this for the device you
wish to handle in your driver (e.g., Focuser). The interface to each of
these responder classes is identical, as
described in
The Falcon Web Framework but with the Alpaca Device Number as an additional
parameter to the on_get() and on_put() methods.
The ASCOM standard interface members (properties and methods) are implemented
as separate responder classes here. Incoming Alpaca requests are mapped to
the responders. Thus, your device’s low-level control code would be called
from within the on_get() and/or on_put() responder functions. Here
are the bare interfaces (error handling omitted for clarity).
See the Developer Roadmap for details on how the responders work in this
template/sample.
Note
The
devnoparameter carries the Alpaca device number. This is used only if your Alpaca device supports more than one ASCOM device (e.g. two or more Rotators).The
PropertyResponseandMethodResponseclasses take a second attribute for returning an Alpaca exception. If omitted, it defaults to Success (no exception).
The maxdev = 1 Constant
This constant is passed as a parameter to all PreProcessRequest() decorators.
It is used to range check the device number in requests. It should be 1 unless
your Alpaca device supports more than one ASCOM device of this type (e.g. two
or more rotators).
Property (GET) Endpoint Responder
This returns a Value in the JSON response (response.text):
@before(PreProcessRequest(maxdev))
class IsMoving:
def on_get(self, req: Request, resp: Response, devnum: int):
value = #whatever your device says
resp.text = PropertyResponse(value, req).json
Method (PUT) Endpoint Responder
Initiates an action. Normally returns no value. Parameters for the method
are carried in the PUT request body, and are encoded as HTTP “form fields”.
These are retrieved as a Python dictionary via the Falcon req.get_media()
function.
@before(PreProcessRequest(maxdev))
class MoveAbsolute:
def on_put(self, req: Request, resp: Response, devnum: int):
formdata = req.get_media()
newpos = float(formdata['Position']) # Position parameter
# Whatever it takes to START the action
resp.text = MethodResponse(req).json
API Responder Documentation
Each class is a responder for that specific member (property or method) of the ASCOM IRotator specification.
Note
Calls to on_get() and on_put() have the same arguments as described
above and in
The Falcon Web Framework plus the Alpaca DeviceNumber as the last
argument.
Attention
The CommandXxx() methods are deprecated. These are left over from
the distant past. If you want to implement unique non-standard
commands for your device, use the Action() and SupportedActions
members. In this sample all of these are marked as not implemented.
- class rotator.RotatorMetadata
Metadata describing the Rotator Device. Edit for your device
- class rotator.action
Invoke the specified device-specific custom action
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Action
- class rotator.canreverse
True if the rotator supports the
ReversemethodSeehttps://ascom-standards.org/newdocs/rotator.html#Rotator.CanReverse
Always True for IRotatorV3 (InterfaceVersion >= 3).
- class rotator.connect
Connect to the device asynchronously
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Connect
- class rotator.connected
Retrieves or sets the connected state of the device
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Connected
Notes
There is a setting
sync_write_connectedin config.toml that determines whether connecting by writingConnected = Truebehaves synchronously or acts asynchronously. Conform requires this to be synchronous per IRotatorV3 (PLatform 6).
- class rotator.connecting
True while the device is undertaking an asynchronous connect or disconnect operation.
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Connecting
- class rotator.description
Description of the device such as manufacturer and model number. Any ASCII characters may be used.
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Description
- class rotator.devicestate
List of StateValue objects representing the operational properties of this device.
See https://ascom-standards.org/newdocs/rotator.html#Rotator.DeviceState
- class rotator.disconnect
Disconnect from the device asynchronously.
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Disconnect
NOTE: In this sample, Disconnect is instantaneous
- class rotator.driverinfo
Descriptive and version information about the ASCOM driver
See https://ascom-standards.org/newdocs/rotator.html#Rotator.DriverInfo
- class rotator.driverversion
String containing only the major and minor version of the driver.
See https://ascom-standards.org/newdocs/rotator.html#Rotator.DriverVersion
- class rotator.halt
Immediately stop any rotator motion
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Halt
- class rotator.interfaceversion
ASCOM Device interface definition version that this device supports. Should return 4 for this interface version IRotatorV4.
See https://ascom-standards.org/newdocs/rotator.html#Rotator.InterfaceVersion
- class rotator.ismoving
True if the rotator is currently moving to a new angle
See https://ascom-standards.org/newdocs/rotator.html#Rotator.IsMoving
- class rotator.mechanicalposition
The raw mechanical position of the rotator in degrees.
See https://ascom-standards.org/newdocs/rotator.html#Rotator.MechanicalPosition
- class rotator.move
Start rotation relative to the current position (degrees)
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Move
- class rotator.moveabsolute
Start rotation to the given
Position(degrees)See https://ascom-standards.org/newdocs/rotator.html#Rotator.MoveAbsolute
- class rotator.movemechanical
Start rotation to the given new mechanical position (degrees)
See https://ascom-standards.org/newdocs/rotator.html#Rotator.MoveMechanical
- class rotator.name
The short name of the driver, for display purposes.
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Name
- class rotator.position
Current instantaneous Rotator position, allowing for any sync offset, in degrees.
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Position
- class rotator.reverse
The direction of rotation CCW or CW
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Reverse
- class rotator.stepsize
Minimum rotation step size (deg)
See https://ascom-standards.org/newdocs/rotator.html#Rotator.StepSize
- class rotator.supportedactions
Returns the list of custom action names, to be used with
Action(), supported by this driver.See https://ascom-standards.org/newdocs/rotator.html#Rotator.SupportedActions
- class rotator.sync
Syncs the rotator to the specified position angle (degrees) without moving it.
See https://ascom-standards.org/newdocs/rotator.html#Rotator.Sync
- class rotator.targetposition
The destination angle for
Move()andMoveAbsolute()See https://ascom-standards.org/newdocs/rotator.html#Rotator.TargetPosition