6,433 bytes added,
11:07, 28 January 2014 {{Filter Wheel Driver Software}}
==Introduction==
The filter wheel driver software provides an interface to the Programmable Logic Controller (PLC) which controls one or more filter wheels. The software comprises a back-end, which communicates directly with the PLC over a serial link, and the front-end with which the user interacts. There are in fact a number of front-end interfaces available to control and query the filter wheels.
The software is modular, and may be used on its own (to control filter wheels not part of a larger system), or as part of interconnected systems (e.g. the Sutherland High-speed Optical Camera (SHOC) instrument, which includes filter wheels, a global positioning system (GPS) receiver used for timing information, and a charge-coupled device (CCD) camera.)
A basic command line interface is provided to control the filter wheel, but most users will find it preferable to use the provided web interface. There is also a diagnostic interface, which may be used by technicians for the purposes of trouble-shooting.
The filter wheel software also provides a means for scripting the filter wheel behaviour. This is useful for users whose observation requirements are for a predefined set of steps to be taken, possibly repeatedly. The scripting interface should be particularly useful when the filter wheel is used in conjunction with other instruments, and a particular work-flow needs to be followed.
==General Usage==
When the filter wheel controller is first switched on, at the start of
the night's viewing, it will need to be initialized. This action
rotates the wheel until the reference position passes a sensor, and
from then on the wheel's position is known. After this the user merely
needs to specify the required position, and the PLC controller takes
care of rotating the wheel as required.
To check that the wheel is operating as required, the user may check that:
* The initialization status is true.
* The wheel centred status is true.
* When the wheel is at position 1, the ''at_reference'' status is true.
These are indicated by green lights in the web interface, or status
bits displayed in the command-line interface (CLI).
Occasionally (e.g. after a power outage) the PLC may become confused, and
a software reset may be required. Both the CLI and web interface allow
this.
==Command Line Interface==
As mentioned, the command line interface CLI is the most basic means
of interacting with the filter wheel controller.
To start the interface, double-click the <code>filterwheel_cli</code> icon (in
Windows) or in a bash shell, type <code>filterwheel_cli.py</code> (Linux).
For help using the CLI, invoke it with the ''-h'' option. This presents
the user with a list of command line options, and explanations as to
their use. For example, it may be necessary to specify the serial port
for the PLC connection; this may be done with the <code>--serial <port></code>
command (e.g. <code>--serial /dev/ttyUSB2</code>).
Once the interface has started, the user may view the status, or
control a particular wheel.
Entering ''S'' or ''s'' displays the status of the PLC. This lists, for
each wheel (''A'' and ''B''):
* whether the wheel has been initialized
* whether it is currently centred
* whether it is currently at the reference position
* whether it is moving
* the current position,
* the id of the wheel (in binary notation).
Other options take the form <code><wheel> <option></code>. For example:
* <code>A I</code> - initialize wheel A
* <code>A R</code> - reset wheel A
* <code>B 5</code> - move wheel ''B'' to slot position ''5''. The slot positions range from 1 to 8.
Entering ''q'' or ''Q'' exits the program.
==Web Interface==
The web interface is the primary interface for interaction with the
filter wheel. The filter wheel control software and web server are
started as a service (Windows) or daemon (Linux), and the user should
not need to start these. The web server provides a web interface for
interaction with the filter wheels.
The status of the each wheel is displayed at the top, below the
wheel's name and binary-format ID.
The current position of the wheel is displayed below this. The slot
number, and if available, filter name and color are also displayed.
Below this, the next required position may be entered. There are then
buttons to move to the required position, or to initialize the wheel.
An "advanced" link allows the user to see which filters are installed
in each slot (if known), and also allows the user to reset the PLC.
Note: the filter name and colour are obtained from a configuration
file. This file includes a time for which this information is valid,
for each wheel. If there is no information valid for a wheel for the
current time, the name and colour are not displayed. This ensures that
out-of-date or incorrect information is not displayed.
==Diagnostic Interface==
The diagnostic interface is similar to the command line interface, but
provides greater details on the data strings sent to and received from
the PLC. There is also the ability to set various bits in the PLC, to
control features not required for day-to-day operation.
==Qt GUI Interface==
Not yet done
==Scripting==
A scripting interface has been developed, and enables filter wheel
operations to be controlled from a script.
The operations are available for each wheel and include status checks and filter wheel control.
Status:
* Is the wheel initialized?
* Is the wheel centred?
* Is wheel at the reference position?
* Is the wheel moving?
* What is the current position?
Control:
* Initialize the wheel.
* Move to a specified position.
So to initialize wheel B, then check that it's at the reference
position, move it to position 4 and then check that it is centred, one
might write a bash script as follows:
<code>
#!/bin/bash
wheel=B
port=/dev/ttyUSB0
newpos=4
./fwc --serial $port -w $wheel -a Z
sleep 4
atref=`./fwc --serial $port -w $wheel -a r`
echo "atref = $atref"
if [ $atref -lt "1" ]
then
echo "Filter wheel $wheel is not at reference position after initialization"
exit -1
fi
echo "Moving wheel to $newpos"
./fwc --serial $port -w $wheel -a $newpos
sleep 4
if [ `./fwc --serial $port -w $wheel -a c` -ne 1 ]
then
echo "Filter wheel $wheel is not centred after move"
exit 1
fi
echo "Success. Wheel initialized and centred at position $newpos."
</code>