|
Chronos Plugins 5.11.0
This documentation covers the plugin interfaces definitions and an example implementation.
|
A chronos plugin implementation for a fake device. We pretend we are controlling a mixture of coffee machine and waiter robot. More...
Public Member Functions | |
| MockDevice (IGuiHelper guiHelper) | |
| void | Dispose () |
| void | BrewFrappuccino (BrewFrappuccino.CompositionData composition) |
| Pretend we are doing some operation on a complex parameter set. | |
| void | SomeDummyMethod () |
| Just for testing if methods of this device can be called from some other point in our code. | |
| void | Connect () |
| Inform the user of our connect attempt / success. Instead of establishing a real connection, show some message box. | |
| void | Disconnect () |
| Pretend we are closing the connection. Actual operation substituted by a message box. | |
| void | ShowTheMessage (string messageText) |
| Let our device set a status message and display some message box instead of doing real work. | |
| void | TriggerAbort (string reason, bool softStop) |
| This will trigger the AbortSchedule-Event 5 seconds after it was called from a task. | |
| void | CheckForAbort () |
| Task | ApplyParametersAsync (bool waitUntilSetpointIsReached, CancellationToken canToken) |
| Set the given parameters on the device. | |
| void | WaitIfPaused () |
| void | BeginInteraction () |
| Will be called if interaction is started, gives you a chance to unlock a terminal, for example. | |
| void | EndInteraction () |
| Will be called if you can lock the terminal again. | |
| void | RaiseError (string errorDescription, ErrorType errType, bool resolved) |
| "Retry" here means that we don't retry some action, but that we raise the error again. | |
Static Public Attributes | |
| const string | DeviceTypeName = "ACME Coffee Maker" |
Properties | |
| string | DisplayedTypeName [get] |
| Visible to the user on the instruments page of the settings editor. | |
| string | DeviceTypeDescription [get] |
| Device class specification referred to by some messages. | |
| string | Name [get, set] |
| User-selected name for the device instance. | |
| string | Connection = "COM17" [get, set] |
| Connection as set in the Chronos instrument settings. | |
| bool | IsConnected [get, set] |
| Helper for our toolbox. | |
| CoffeMakerParams | Parameters = new CoffeMakerParams() [get, set] |
| Your parameter set. | |
| bool | Aborted [get, set] |
| If set, abort execution as soon as possible. You can throw an OperationCanceledException. Will be set to false after termination of the run. | |
| bool | Paused [get, set] |
| If paused, wait until paused is reset before executing the next command. | |
| IEnumerable< string > | LogPaths [get] |
| Provide full paths to each of your log files here. | |
| Func< StopRunArgs, Task > | StopRun [get, set] |
| Callback function returning a task that completes once the schedule queue was stopped. | |
| IScheduleEvents | ScheduleEvents [set] |
| Hook up immediately or save this for later use. | |
Events | |
| Action< ConnectionState > | ConnectionStateChanged |
| Action< string > | SetStatusMessage |
| Action< string > | DebugOutput |
| PropertyChangedEventHandler | PropertyChanged |
| Action< string > | AbortSchedule |
| EventHandler< InteractiveErrorHandlingEventArgs > | HandleError |
| Events inherited from AxelSemrau.Chronos.Plugin.IDevice | |
| Action< ConnectionState > | ConnectionStateChanged |
| Raise this event when your connection state has changed. | |
| Events inherited from AxelSemrau.Chronos.Plugin.IProvideStatusMessages | |
| Action< string > | SetStatusMessage |
| Raise this event to set your current status while doing something on the device. Messages passed to this event will be shown in the "Autosampler status" line. | |
| Events inherited from AxelSemrau.Chronos.Plugin.IHaveDebugOutput | |
| Action< string > | DebugOutput |
| Messages passed to this event will be logged (including a timestamp) to the user configured debug logfile. | |
| Events inherited from AxelSemrau.Chronos.Plugin.IAbortSchedules | |
| Action< string > | AbortSchedule |
| If you raise this event, the schedule will be aborted. | |
| Events inherited from AxelSemrau.Chronos.Plugin.IHaveInteractiveErrorHandling | |
| EventHandler< InteractiveErrorHandlingEventArgs > | HandleError |
| Raise this event if you want the user to decide how to continue, if this is desired in the settings. | |
Private Member Functions | |
| void | OnIsConnectedChanged () |
| For thread-safe update of the toolbox's GUI elements representing the connection state. | |
| void | ScheduleStateChangedHandler (object sender, ScheduleStateEventArgs e) |
Private Attributes | |
| bool | mIsConnected |
| readonly ManualResetEventSlim | mPauseEnded = new ManualResetEventSlim(true) |
| Using an event here instead of a simple bool helps us avoid polling while checking for the events. | |
| readonly ManualResetEventSlim | mAborted = new ManualResetEventSlim(false) |
| IScheduleEvents | mScheduleEvents |
| readonly IGuiHelper | mGuiHelper |
A chronos plugin implementation for a fake device. We pretend we are controlling a mixture of coffee machine and waiter robot.
Just an example implementation that doesn't do any real work.
Definition at line 38 of file MockDevice.cs.
| MockPlugin.Device.MockDevice.MockDevice | ( | IGuiHelper | guiHelper | ) |
Definition at line 63 of file MockDevice.cs.
References mGuiHelper.
| Task MockPlugin.Device.MockDevice.ApplyParametersAsync | ( | bool | waitUntilSetpointIsReached, |
| CancellationToken | cancelToken ) |
Set the given parameters on the device.
| waitUntilSetpointIsReached | Parameter setting is done in two turns: The first call will ask you to set all controls to the new setpoints, the second call will ask you to wait until they are actually reached. Return as soon as possible from the first call, and to not return from the second call before you are definitely ready. |
| cancelToken | If requested, abort waiting for the desired temperature. |
Implements AxelSemrau.Chronos.Plugin.IHaveMachineParameters< ParamType >.
Definition at line 268 of file MockDevice.cs.
References SetStatusMessage.
| void MockPlugin.Device.MockDevice.BeginInteraction | ( | ) |
Will be called if interaction is started, gives you a chance to unlock a terminal, for example.
Implements AxelSemrau.Chronos.Plugin.IHaveInteractiveErrorHandling.
Definition at line 356 of file MockDevice.cs.
References DebugOutput.
| void MockPlugin.Device.MockDevice.BrewFrappuccino | ( | BrewFrappuccino.CompositionData | composition | ) |
Pretend we are doing some operation on a complex parameter set.
| composition |
Definition at line 97 of file MockDevice.cs.
References BrewFrappuccino(), ShowTheMessage(), and WaitIfPaused().
Referenced by BrewFrappuccino().
| void MockPlugin.Device.MockDevice.CheckForAbort | ( | ) |
Definition at line 254 of file MockDevice.cs.
References mAborted.
Referenced by WaitIfPaused().
| void MockPlugin.Device.MockDevice.Connect | ( | ) |
Inform the user of our connect attempt / success. Instead of establishing a real connection, show some message box.
Implements AxelSemrau.Chronos.Plugin.IDevice.
Definition at line 115 of file MockDevice.cs.
References ConnectionStateChanged, mGuiHelper, mIsConnected, and OnIsConnectedChanged().
| void MockPlugin.Device.MockDevice.Disconnect | ( | ) |
Pretend we are closing the connection. Actual operation substituted by a message box.
Implements AxelSemrau.Chronos.Plugin.IDevice.
Definition at line 127 of file MockDevice.cs.
References ConnectionStateChanged, mGuiHelper, mIsConnected, and OnIsConnectedChanged().
| void MockPlugin.Device.MockDevice.Dispose | ( | ) |
Definition at line 71 of file MockDevice.cs.
References DebugOutput.
| void MockPlugin.Device.MockDevice.EndInteraction | ( | ) |
Will be called if you can lock the terminal again.
Implements AxelSemrau.Chronos.Plugin.IHaveInteractiveErrorHandling.
Definition at line 361 of file MockDevice.cs.
References DebugOutput.
|
private |
For thread-safe update of the toolbox's GUI elements representing the connection state.
Definition at line 208 of file MockDevice.cs.
References IsConnected, mGuiHelper, and PropertyChanged.
Referenced by Connect(), and Disconnect().
| void MockPlugin.Device.MockDevice.RaiseError | ( | string | errorDescription, |
| ErrorType | errType, | ||
| bool | resolved ) |
"Retry" here means that we don't retry some action, but that we raise the error again.
| errorDescription | |
| errType | |
| resolved |
Definition at line 372 of file MockDevice.cs.
References HandleError.
|
private |
Definition at line 350 of file MockDevice.cs.
References DebugOutput.
| void MockPlugin.Device.MockDevice.ShowTheMessage | ( | string | messageText | ) |
Let our device set a status message and display some message box instead of doing real work.
| messageText |
Definition at line 159 of file MockDevice.cs.
References DebugOutput, mGuiHelper, SetStatusMessage, and WaitIfPaused().
Referenced by BrewFrappuccino().
| void MockPlugin.Device.MockDevice.SomeDummyMethod | ( | ) |
Just for testing if methods of this device can be called from some other point in our code.
Definition at line 107 of file MockDevice.cs.
References DebugOutput.
| void MockPlugin.Device.MockDevice.TriggerAbort | ( | string | reason, |
| bool | softStop ) |
This will trigger the AbortSchedule-Event 5 seconds after it was called from a task.
| reason | |
| softStop |
For a real device, this would be something like a leak, a failed pump or heater or anything else that makes it impossible to operate the device properly.
Definition at line 232 of file MockDevice.cs.
References AbortSchedule, and StopRun.
| void MockPlugin.Device.MockDevice.WaitIfPaused | ( | ) |
Definition at line 281 of file MockDevice.cs.
References CheckForAbort(), and mPauseEnded.
Referenced by BrewFrappuccino(), and ShowTheMessage().
|
static |
Definition at line 54 of file MockDevice.cs.
|
private |
Definition at line 294 of file MockDevice.cs.
Referenced by CheckForAbort().
|
private |
Definition at line 331 of file MockDevice.cs.
Referenced by Connect(), Disconnect(), MockDevice(), OnIsConnectedChanged(), and ShowTheMessage().
|
private |
Definition at line 57 of file MockDevice.cs.
Referenced by Connect(), and Disconnect().
|
private |
Using an event here instead of a simple bool helps us avoid polling while checking for the events.
Definition at line 292 of file MockDevice.cs.
Referenced by WaitIfPaused().
|
private |
Definition at line 330 of file MockDevice.cs.
|
getset |
If set, abort execution as soon as possible. You can throw an OperationCanceledException. Will be set to false after termination of the run.
Implements AxelSemrau.Chronos.Plugin.ICanInterrupt.
Definition at line 296 of file MockDevice.cs.
|
getset |
Connection as set in the Chronos instrument settings.
If this gets a bit more complicated, you can also use a UITypeEditor here.
Implements AxelSemrau.Chronos.Plugin.INeedAConnection.
Definition at line 149 of file MockDevice.cs.
|
get |
Device class specification referred to by some messages.
Implements AxelSemrau.Chronos.Plugin.IDevice.
Definition at line 85 of file MockDevice.cs.
|
get |
Visible to the user on the instruments page of the settings editor.
Implements AxelSemrau.Chronos.Plugin.IDevice.
Definition at line 80 of file MockDevice.cs.
|
getset |
Helper for our toolbox.
Definition at line 173 of file MockDevice.cs.
Referenced by OnIsConnectedChanged().
|
get |
Provide full paths to each of your log files here.
Implements AxelSemrau.Chronos.Plugin.IProvideDiagnosticLogs.
Definition at line 323 of file MockDevice.cs.
|
getset |
User-selected name for the device instance.
Please return what you are given. Note: Before Chronos 5.1.8, this was set to "Uninitialized Device" for temporary device instances. With later versions, the name should only be set for a "real" instance.
Implements AxelSemrau.Chronos.Plugin.IDevice.
Definition at line 87 of file MockDevice.cs.
|
getset |
Your parameter set.
Before sequence start, this will be set to the desired values. Wait until ApplyParameters is called to actually transmit these values to the device.
Implements AxelSemrau.Chronos.Plugin.IHaveMachineParameters< ParamType >.
Definition at line 266 of file MockDevice.cs.
|
getset |
If paused, wait until paused is reset before executing the next command.
Implements AxelSemrau.Chronos.Plugin.ICanInterrupt.
Definition at line 305 of file MockDevice.cs.
|
set |
Hook up immediately or save this for later use.
Implements AxelSemrau.Chronos.Plugin.IScheduleStateAware.
Definition at line 333 of file MockDevice.cs.
|
getset |
Callback function returning a task that completes once the schedule queue was stopped.
Implements AxelSemrau.Chronos.Plugin.IStopRuns.
Definition at line 326 of file MockDevice.cs.
Referenced by TriggerAbort().
| Action<string> MockPlugin.Device.MockDevice.AbortSchedule |
Definition at line 252 of file MockDevice.cs.
Referenced by TriggerAbort().
| Action<ConnectionState> MockPlugin.Device.MockDevice.ConnectionStateChanged |
Definition at line 136 of file MockDevice.cs.
Referenced by Connect(), and Disconnect().
| Action<string> MockPlugin.Device.MockDevice.DebugOutput |
Definition at line 199 of file MockDevice.cs.
Referenced by BeginInteraction(), Dispose(), EndInteraction(), ScheduleStateChangedHandler(), ShowTheMessage(), and SomeDummyMethod().
| EventHandler<InteractiveErrorHandlingEventArgs> MockPlugin.Device.MockDevice.HandleError |
Definition at line 385 of file MockDevice.cs.
Referenced by RaiseError().
| PropertyChangedEventHandler MockPlugin.Device.MockDevice.PropertyChanged |
Definition at line 217 of file MockDevice.cs.
Referenced by OnIsConnectedChanged().
| Action<string> MockPlugin.Device.MockDevice.SetStatusMessage |
Definition at line 193 of file MockDevice.cs.
Referenced by ApplyParametersAsync(), and ShowTheMessage().