|
Chronos Plugins
5.2.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...
Inheritance diagram for MockPlugin.Device.MockDevice:
Collaboration diagram for MockPlugin.Device.MockDevice:Public Member Functions | |
| MockDevice () | |
| void | Dispose () |
| void | BrewFrappuccino (BrewFrappuccino.CompositionData composition) |
| Pretend we are doing some operation on a complex parameter set. More... | |
| void | SomeDummyMethod () |
| Just for testing if methods of this device can be called from some other point in our code. More... | |
| void | Connect () |
| Inform the user of our connect attempt / success. Instead of establishing a real connection, show some message box. More... | |
| void | Disconnect () |
| Pretend we are closing the connection. Actual operation substituted by a message box. More... | |
| void | ShowTheMessage (string messageText) |
| Let our device set a status message and display some message box instead of doing real work. More... | |
| void | TriggerAbort (string reason, bool softStop) |
| This will trigger the AbortSchedule-Event 5 seconds after it was called from a task. More... | |
| void | CheckForAbort () |
| Task | ApplyParametersAsync (bool waitUntilSetpointIsReached, CancellationToken canToken) |
| void | WaitIfPaused () |
Public Member Functions inherited from AxelSemrau.Chronos.Plugin.IHaveMachineParameters< CoffeMakerParams > | |
| Task | ApplyParametersAsync (bool waitUntilSetpointIsReached, CancellationToken cancelToken) |
| Set the given parameters on the device. More... | |
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. More... | |
| string | DeviceTypeDescription [get] |
| Device class specification referred to by some messages. More... | |
| string | Name [get, set] |
| string | Connection = "COM17" [get, set] |
| Connection as set in the Chronos instrument settings. More... | |
| bool | IsConnected [get, set] |
| Helper for our toolbox. More... | |
| CoffeMakerParams | Parameters = new CoffeMakerParams() [get, set] |
| bool | Aborted [get, set] |
| bool | Paused [get, set] |
| IEnumerable< string > | LogPaths [get] |
| Func< StopRunArgs, Task > | StopRun [get, set] |
| IScheduleEvents | ScheduleEvents [set] |
Properties inherited from AxelSemrau.Chronos.Plugin.IDevice | |
| string | DisplayedTypeName [get] |
| Text which is displayed in the instruments settings "Autosampler Type" column and in many other places. More... | |
| string | DeviceTypeDescription [get] |
| Text which is displayed to make clear which kind of device a named sampler is. More... | |
| string | Name [get, set] |
| User-selected name for the device instance. More... | |
Properties inherited from AxelSemrau.Chronos.Plugin.INeedAConnection | |
| string | Connection [get, set] |
| Name of a serial port, IP address, hostname.... More... | |
Properties inherited from AxelSemrau.Chronos.Plugin.ICanInterrupt | |
| bool | Aborted [get, set] |
| If set, abort execution as soon as possible. You can throw an OperationCanceledException. Well be set to false after termination of the run. More... | |
| bool | Paused [get, set] |
| If paused, wait until paused is reset before executing the next command. More... | |
Properties inherited from AxelSemrau.Chronos.Plugin.IHaveMachineParameters< CoffeMakerParams > | |
| ParamType | Parameters [get, set] |
| Your parameter set. More... | |
Properties inherited from AxelSemrau.Chronos.Plugin.IProvideDiagnosticLogs | |
| IEnumerable< string > | LogPaths [get] |
| Provide full paths to each of your log files here. More... | |
Properties inherited from AxelSemrau.Chronos.Plugin.IStopRuns | |
| Func< StopRunArgs, Task > | StopRun [set] |
| Callback function returning a task that completes once the schedule queue was stopped. More... | |
Properties inherited from AxelSemrau.Chronos.Plugin.IScheduleStateAware | |
| IScheduleEvents | ScheduleEvents [set] |
| Hook up immediately or save this for later use. More... | |
Events | |
| Action< ConnectionState > | ConnectionStateChanged |
| Action< string > | SetStatusMessage |
| Action< string > | DebugOutput |
| PropertyChangedEventHandler | PropertyChanged |
| Action< string > | AbortSchedule |
Events inherited from AxelSemrau.Chronos.Plugin.IDevice | |
| Action< ConnectionState > | ConnectionStateChanged |
| Raise this event when your connection state has changed. More... | |
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. More... | |
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. More... | |
Events inherited from AxelSemrau.Chronos.Plugin.IAbortSchedules | |
| Action< string > | AbortSchedule |
| If you raise this event, the schedule will be aborted. More... | |
Private Member Functions | |
| void | OnIsConnectedChanged () |
| For thread-safe update of the toolbox's GUI elements representing the connection state. More... | |
| 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. More... | |
| readonly ManualResetEventSlim | mAborted = new ManualResetEventSlim(false) |
| IScheduleEvents | mScheduleEvents |
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 37 of file MockDevice.cs.
| MockPlugin.Device.MockDevice.MockDevice | ( | ) |
Definition at line 61 of file MockDevice.cs.
| Task MockPlugin.Device.MockDevice.ApplyParametersAsync | ( | bool | waitUntilSetpointIsReached, |
| CancellationToken | canToken | ||
| ) |
Definition at line 265 of file MockDevice.cs.
References MockPlugin.Device.MockDevice.SetStatusMessage.
| void MockPlugin.Device.MockDevice.BrewFrappuccino | ( | BrewFrappuccino.CompositionData | composition | ) |
Pretend we are doing some operation on a complex parameter set.
| composition |
Definition at line 94 of file MockDevice.cs.
References MockPlugin.Device.MockDevice.ShowTheMessage(), and MockPlugin.Device.MockDevice.WaitIfPaused().
Referenced by MockPlugin.Tasks.BrewFrappuccino.Execute().
| void MockPlugin.Device.MockDevice.CheckForAbort | ( | ) |
Definition at line 251 of file MockDevice.cs.
References MockPlugin.Device.MockDevice.mAborted.
Referenced by MockPlugin.Device.MockDevice.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 112 of file MockDevice.cs.
References MockPlugin.Device.MockDevice.ConnectionStateChanged, AxelSemrau.Chronos.Plugin.Helpers.Gui, AxelSemrau.Chronos.Plugin.IGuiHelper.MainWindow, MockPlugin.Device.MockDevice.mIsConnected, and MockPlugin.Device.MockDevice.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 124 of file MockDevice.cs.
References MockPlugin.Device.MockDevice.ConnectionStateChanged, AxelSemrau.Chronos.Plugin.Helpers.Gui, AxelSemrau.Chronos.Plugin.IGuiHelper.MainWindow, MockPlugin.Device.MockDevice.mIsConnected, and MockPlugin.Device.MockDevice.OnIsConnectedChanged().
| void MockPlugin.Device.MockDevice.Dispose | ( | ) |
|
private |
For thread-safe update of the toolbox's GUI elements representing the connection state.
Definition at line 205 of file MockDevice.cs.
References AxelSemrau.Chronos.Plugin.Helpers.Gui, AxelSemrau.Chronos.Plugin.IGuiHelper.GuiTaskFactory, MockPlugin.Device.MockDevice.IsConnected, and MockPlugin.Device.MockDevice.PropertyChanged.
Referenced by MockPlugin.Device.MockDevice.Connect(), and MockPlugin.Device.MockDevice.Disconnect().
|
private |
Definition at line 346 of file MockDevice.cs.
References MockPlugin.Device.MockDevice.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 156 of file MockDevice.cs.
References MockPlugin.Device.MockDevice.DebugOutput, AxelSemrau.Chronos.Plugin.Helpers.Gui, AxelSemrau.Chronos.Plugin.IGuiHelper.MainWindow, MockPlugin.Device.MockDevice.SetStatusMessage, and MockPlugin.Device.MockDevice.WaitIfPaused().
Referenced by MockPlugin.Device.MockDevice.BrewFrappuccino(), MockPlugin.Device.MockDeviceToolbox.btnShowMessage_Click(), and MockPlugin.Tasks.BrewCoffee.Execute().
| 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 104 of file MockDevice.cs.
References MockPlugin.Device.MockDevice.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 229 of file MockDevice.cs.
References MockPlugin.Device.MockDevice.AbortSchedule, and MockPlugin.Device.MockDevice.StopRun.
Referenced by MockPlugin.Tasks.PretendCoffeeMachineIsBroken.Execute().
| void MockPlugin.Device.MockDevice.WaitIfPaused | ( | ) |
Definition at line 278 of file MockDevice.cs.
References MockPlugin.Device.MockDevice.CheckForAbort(), MockPlugin.Device.MockDevice.mAborted, and MockPlugin.Device.MockDevice.mPauseEnded.
Referenced by MockPlugin.Device.MockDevice.BrewFrappuccino(), and MockPlugin.Device.MockDevice.ShowTheMessage().
|
static |
Definition at line 52 of file MockDevice.cs.
|
private |
Definition at line 291 of file MockDevice.cs.
Referenced by MockPlugin.Device.MockDevice.CheckForAbort(), and MockPlugin.Device.MockDevice.WaitIfPaused().
|
private |
Definition at line 55 of file MockDevice.cs.
Referenced by MockPlugin.Device.MockDevice.Connect(), and MockPlugin.Device.MockDevice.Disconnect().
|
private |
Using an event here instead of a simple bool helps us avoid polling while checking for the events.
Definition at line 289 of file MockDevice.cs.
Referenced by MockPlugin.Device.MockDevice.WaitIfPaused().
|
private |
Definition at line 327 of file MockDevice.cs.
|
getset |
Definition at line 293 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.
Definition at line 146 of file MockDevice.cs.
|
get |
Device class specification referred to by some messages.
Definition at line 82 of file MockDevice.cs.
|
get |
Visible to the user on the instruments page of the settings editor.
Definition at line 77 of file MockDevice.cs.
|
getset |
Helper for our toolbox.
Definition at line 170 of file MockDevice.cs.
Referenced by MockPlugin.Device.MockDevice.OnIsConnectedChanged().
|
get |
Definition at line 320 of file MockDevice.cs.
|
getset |
Definition at line 84 of file MockDevice.cs.
Referenced by MockPlugin.Tasks.BrewCoffee.RegisterCoffeeConsumption(), MockPlugin.Tasks.BrewFrappuccino.RegisterConsumption(), and MockPlugin.Misc.StatusViewControl.timer1_Tick().
|
getset |
Definition at line 263 of file MockDevice.cs.
|
getset |
Definition at line 302 of file MockDevice.cs.
|
set |
Definition at line 329 of file MockDevice.cs.
|
getset |
Definition at line 323 of file MockDevice.cs.
Referenced by MockPlugin.Device.MockDevice.TriggerAbort().
| Action<string> MockPlugin.Device.MockDevice.AbortSchedule |
Definition at line 249 of file MockDevice.cs.
Referenced by MockPlugin.Device.MockDevice.TriggerAbort().
| Action<ConnectionState> MockPlugin.Device.MockDevice.ConnectionStateChanged |
Definition at line 133 of file MockDevice.cs.
Referenced by MockPlugin.Device.MockDevice.Connect(), and MockPlugin.Device.MockDevice.Disconnect().
| Action<string> MockPlugin.Device.MockDevice.DebugOutput |
Definition at line 196 of file MockDevice.cs.
Referenced by MockPlugin.Device.MockDevice.Dispose(), MockPlugin.Device.MockDevice.ScheduleStateChangedHandler(), MockPlugin.Device.MockDevice.ShowTheMessage(), and MockPlugin.Device.MockDevice.SomeDummyMethod().
| PropertyChangedEventHandler MockPlugin.Device.MockDevice.PropertyChanged |
Definition at line 214 of file MockDevice.cs.
Referenced by MockPlugin.Device.MockDevice.OnIsConnectedChanged().
| Action<string> MockPlugin.Device.MockDevice.SetStatusMessage |
Definition at line 190 of file MockDevice.cs.
Referenced by MockPlugin.Device.MockDevice.ApplyParametersAsync(), and MockPlugin.Device.MockDevice.ShowTheMessage().