Chronos Plugins 5.4.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
MockUseMultipleDevicesTask.cs
Go to the documentation of this file.
1using System;
2using System.Diagnostics.CodeAnalysis;
3using System.Linq;
6
7// ReSharper disable UnusedMember.Global
8
9namespace MockPlugin.Tasks
10{
14 [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global")]
15 [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
17 {
19
20 #region Implementation of ITask
21
22 public void PreValidate()
23 {
24
25 }
26
27 public void PostValidate()
28 {
29
30 }
31
35 public void Execute()
36 {
37 if (mDevice1 is IPAL3Services pal && pal.Simulating)
38 {
39 WriteToRunlog?.Invoke("Running simulation for validation");
40 }
41 else
42 {
43 WriteToRunlog?.Invoke($"Running {GetTaskAction()}");
44 foreach (var dev in new[] {SecondCoffeeMakerOrPal3, ThirdAnyDevice}.OfType<MockDevice>())
45 {
46 dev.SomeDummyMethod();
47 }
48 }
49 }
50
51 public string GetTaskAction()
52 {
53 return $"Task for devices {NameOrNotSet(mDevice1)}, {NameOrNotSet(SecondCoffeeMakerOrPal3)}, {NameOrNotSet(ThirdAnyDevice)}";
54 }
55
56 private string NameOrNotSet(IDevice dev)
57 {
58 return dev?.Name ?? "(not set)";
59 }
60
61 [DevicesLimited(typeof(IPAL3Services)) /* Accept only PAL3 as "Autosampler" */]
62 public void SetDevice(IDevice yourDevice)
63 {
64 mDevice1 = yourDevice;
65 }
66
67 #endregion
68 // Accept PAL3 or CoffeeMaker
69 [DevicesLimited(typeof(MockDevice), typeof(IPAL3Services))]
70 public IDevice SecondCoffeeMakerOrPal3 { get; set; }
71
72 public IDevice ThirdAnyDevice { get; set; }
73
74 #region Implementation of IHaveRunlogOutput
75
76 public event Action<string> WriteToRunlog;
77
78 #endregion
79 }
80}
Classes and interfaces that are meant for plugins. The classes and interfaces below this namespace ar...
A fake device. This namespace contains the fake device driver and auxiliary classes for settings,...
Example task implementations. Since there are lots of things that can be done from a task,...
To be implemented by the "device driver" part of a Chronos plugin.
string Name
User-selected name for the device instance.
Implement this interface if you have messages for our run log.
An object implementing this interface is provided by Chronos and passed to the PAL3task just before e...
bool Simulating
Gets a value indicating whether this IPAL3Services is simulating.
To be implemented if the task needs to access a device ("Autosampler" property in Chronos)
A chronos plugin implementation for a fake device. We pretend we are controlling a mixture of coffee ...
Definition: MockDevice.cs:53
For some special cases it can be necessary to have a single task communicate with two different devic...
string GetTaskAction()
Description of the tasks's action (for hints/time table)
void PostValidate()
Called after the schedule construction is completed.
void SetDevice(IDevice yourDevice)
Will be called by chronos when building the schedule.
void Execute()
Showing how to use our device(s) from the task.
void PreValidate()
Called before the schedule construction is completed.