Check if canceled by a Preset. Wait for three PCS fast loop cycles. Set target OK for GetTrajectory. If asynchronous, unlock mutex. If synchronous, update flags. Return error if PCS reports failure, or offset was canceled by a Preset, or there are any accumulated pseudo-monocular errors..
Tell AOS about the offset. Do not wait for the AOS.
This will start the AO stage moving.
Perform secondary active optics offload calculation if step 5 requires it. Return error if PSF reports failure.
This will apply any held WFS correction.
This will block if there is another PSF command in progress.
Set up mount balancing if binocular. Issue PSF adjustPointing with PCS mount altitude demand angle. Wait for three PCS fast loop cycles. Get optics tip/tilts from PCS and send them to the PSF but do not move the optics at this time.
Start collimating the primary and/or secondary mirrors if step 5 requires it.
Use same altitude angle as step 13.
This will include any secondary offload and the PCS tip/tilts.
Note that if the collimation is skipped than mount balancing is also.
Wait for telescope (elevation, azimuth, and rotators) to get there. Return error if wait times out or is aborted.
The wait time out is set in iif.conf (default 400 seconds) and can be aborted from the IIF GUI.
Wait for GCS probe move to finish. Convert errors to warnings so if probe cannot reach position the offset will not fail, and set flag so resume will not be done.
Wait for AOS stage move to finish. Convert errors to warnings for FLAO so if the stage cannot reach position the offset will not fail. ARGOS will return a warning in this case. Set flag to inhibit resume if not success. Return error if AOS reports failure.
Wait for collimations to finish. Return error if PSF reports failure.
Check the current elevation angle and collimate again if necessary. Return error if PSF reports failure.
If the difference between the current elevation angle and the one used in step 13 is more than 0.1 degree collimate again.
Tell PCS to start accepting demands from the TCS and start sending pointing corrections to the PSF.
Delay Always do 'mount' delay, which is a parameter in iif.conf, settable on the IIFGUI, and is normally zero. For 'optics' offsets the default is 6 seconds for large (greater than 5 arc-seconds) offsets, zero for less. Both the delay and size threshold are settable on the IIFGUI. Any mount delay will be included in the optics delay.
Resume guiding if no error from GCS probe move. Otherwise leave guiding paused.
Resume AO if no error (FLAO), or warning (ARGOS) from AOS stage move. Otherwise leave AO paused.
Return error if GCS or AOS reports failure. Return success.
Set up guiding:
If AO is in use and AO offset succeeded, disable GCS guide and WFS updates.
If AO is in use and AO offset failed, but GCS didn't, enable GCS guide if simplemode is GUIDE or higher and WFS updates if simplemode is ACTIVE.
If AO is in use and AO offset failed and GCS offset failed, telescope is open loop tracking.
If AO is not in use but guiding/active optics is and GCS offset succeeded, enable GCS guide and WFS updates.
If AO is not in use but guiding/active optics is and GCS offset failed, telescope is open loop tracking.
Unlock synchronizing mutex and clean up wait flags.
If command error or warning, make events from CommandReturn results.