Chronos Plugins 5.4.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
DeviceInterfaces.cs
Go to the documentation of this file.
1using System;
2using System.Runtime.InteropServices;
3using System.Collections.Generic;
4using System.Threading;
5using System.Threading.Tasks;
6using Ctc.Palplus.Integration.Driver;
7using Ctc.Palplus.Integration.Driver.Entities;
8
10{
15 public enum ConnectionState
16 {
21
26
31
36
40 Failed
41 }
42
54 [Guid("831BEA86-1D89-4761-A481-0F20443F7579")]
55 public interface IDevice
56 {
61 {
62 get;
63 }
64
69 {
70 get;
71 }
72
80 string Name
81 {
82 get;
83 set;
84 }
85
89 void Connect();
90
94 void Disconnect();
95
99 event Action<ConnectionState> ConnectionStateChanged;
100 }
101
105 public static class DeviceExtensions
106 {
112 public static string LongID(this IDevice dev) => $"{dev.DeviceTypeDescription} \"{dev.Name}\"";
113 }
114
118 public class TrayGeometry
119 {
123 public int Rows { get; protected set; }
127 public int Cols { get; protected set; }
128
132 public bool IndexingDirectionX { get; protected set; }
133
137 public (Quantity x, Quantity y, Quantity z) Size { get; protected set; }
138
142 public (Quantity x, Quantity y, Quantity z) FirstSampleOffset { get; protected set; }
143
150 public (Quantity x, Quantity y, Quantity z) AlternateSampleOffset { get; protected set; }
151
155 public Quantity CavityDiameter { get; protected set; }
156
160 public Quantity TotalRowLengthY { get; protected set; }
164 public Quantity TotalColLengthX { get; protected set; }
165
166
172 public TrayGeometry(int rows, int cols)
173 {
174 Rows = rows;
175 Cols = cols;
176 IndexingDirectionX = true;
177 }
178
182 protected TrayGeometry()
183 {
184 }
185 }
186
190 public interface IProvideTrayGeometry : IDevice
191 {
197 TrayGeometry GetGeometry(string trayName);
198 }
199
200
204 [Guid("F1226971-CCEB-4AD0-9BF6-22D44AED58E9")]
205 public interface INeedAConnection : IDevice
206 {
211 {
212 get;
213 set;
214 }
215 }
223 [Guid("8589E2C5-32DD-43EF-9EEB-186530592E27")]
225 {
230 }
231
235 [Guid("7512BE09-4CCD-4FDF-A7CB-2A21630B7A47")]
237 {
242 event Action<string> SetStatusMessage;
243 }
244
248 [Guid("E8F8A431-3BFB-481C-9007-A0B5DB229DEC")]
249 public interface IHaveDebugOutput : IDevice
250 {
255 event Action<string> DebugOutput;
256 }
257
264 [Guid("EB9F2BC9-5C34-4485-8A68-A5890E6F80C6")]
265 public interface IAbortSchedules : IDevice
266 {
270 event Action<string> AbortSchedule;
271 }
272
283 [Guid("A88FFB64-3605-4FBB-A1BA-951A10686775")]
284 public interface IMultipartDevice : IDevice
285 {
289 IReadOnlyCollection<IDevice> Parts { get; }
290 }
291
299 public enum ErrorType
300 {
304 Other,
313 }
314
322 public class InteractiveErrorHandlingEventArgs : EventArgs
323 {
327 public bool RetryLastAction { get; set; } = false;
328
332 public string Error { get; set; }
333
337 public ErrorType ErrorType { get; set; }
338 }
339
343 [Guid("EC088A8E-BE61-49CA-84E2-D06DF0167AF6")]
345 {
354
358 event EventHandler<InteractiveErrorHandlingEventArgs> HandleError;
359 }
360
361
365 [Guid("EDDB22B2-82DB-488B-997D-E8369F860AD7")]
366 public interface ICanInterrupt : IDevice
367 {
372 bool Aborted { get; set; }
376 bool Paused { get; set; }
377 }
378
393 [Guid("E990933A-5282-4A43-B64E-7EEFECBE9BF8")]
394 public interface IHaveMachineParameters<ParamType> : IDevice where ParamType : class, new()
395 {
403 ParamType Parameters { set; get; }
404
414 Task ApplyParametersAsync(bool waitUntilSetpointIsReached, CancellationToken cancelToken);
415 }
416
428 [Guid("4915BAD4-53C7-4453-97E8-ECC7C2E52E62")]
429 public interface IDirectDeviceAccess
430 {
435 IEnumerable<IDevice> ConfiguredDevices { set; }
436 }
437
441 [Guid("4D78A78F-776F-4D0D-ACC0-4A1829429A76")]
442 public interface IPal3Options
443 {
447 bool ResetBeforeSequence { get; set; }
452 bool AlwaysResetAfterSequence { get; set; }
453 }
454
460 [Guid("AFF1F948-EBB3-484D-9EDC-0DD2CA2FDBAA")]
461 public interface IPal3Access
462 {
470 IPalPlusConfigurationService ConfigService { get; }
471 }
472
479 public interface IJobAwareDevice : IDevice
480 {
485 void JobFinished(int jobNo);
486 }
487
491 public interface IBarcodeReader : IDevice
492 {
497 string ReadBarcode();
498 }
499
507 public interface IPluginDeviceAdapter : IDevice, IPluginAdapter<IDevice>
508 {
509
510 }
511
512}
Classes and interfaces that are meant for plugins. The classes and interfaces below this namespace ar...
ConnectionState
If your connectivity state changes, you should tell the user about it.
@ Disconnecting
We are trying to disconnect from the device.
@ Connected
The connection has been established.
@ Failed
There was an error while trying to connect, the device is not usable.
@ Connecting
We are just trying to establish a connection.
@ Disconnected
The device is not connected.
ErrorType
Lets a device implementing IHaveInteractiveErrorHandling specify which kind of error occurred.
@ BarcodeNotRead
Device was unable to read a barcode.
@ Other
Any kind of error that does not fit into the predefined categories.
@ MissingVial
A card/vial/whatever is containing the sample was not found in the expected place.
To be implemented by the "device driver" part of a Chronos plugin.
void Connect()
You may have connected to the device before this, but make sure you are connected after this.
void Disconnect()
You may disconnect now.
string DeviceTypeDescription
Text which is displayed to make clear which kind of device a named sampler is.
Action< ConnectionState > ConnectionStateChanged
Raise this event when your connection state has changed.
string Name
User-selected name for the device instance.
string DisplayedTypeName
Text which is displayed in the instruments settings "Autosampler Type" column and in many other place...
Hopefully useful extensions for IDevice.
static string LongID(this IDevice dev)
Identify the device in a user friendly way, including the type.
Basic description of a simple rectangle tray geometry.
Quantity Quantity Quantity z AlternateSampleOffset
bool IndexingDirectionX
When increasing the index from position 1 on, are we moving in sampler axis X direction?
Quantity TotalColLengthX
Total length of a column in X direction. Please keep the IndexingOrientationX in mind when making cal...
TrayGeometry()
For derived classes that may have to do some extra work for finding out the dimensions.
Quantity CavityDiameter
Diameter of the cavities.
int Cols
Number of columns on the tray.
TrayGeometry(int rows, int cols)
Construct a tray with the given number of columns and rows.
Quantity Quantity Quantity z Size
int Rows
Number of rows on the tray.
Quantity TotalRowLengthY
Total length of a row in Y direction. Please keep the IndexingOrientationX in mind when making calcul...
Quantity Quantity Quantity z FirstSampleOffset
Allow to ask the sampler for the geometry of a tray.
TrayGeometry GetGeometry(string trayName)
Return the geometry for the named tray (if known)
For devices that need some kind of user configured connection string to address the hardware.
string Connection
Name of a serial port, IP address, hostname....
Implement this if your device wants to expose its connection state to other plugins.
Implement this interface if you want to keep the user up-to-date about what your device is doing.
Action< string > SetStatusMessage
Raise this event to set your current status while doing something on the device. Messages passed to t...
Implement this interface if you wish to provide debug log output.
Action< string > DebugOutput
Messages passed to this event will be logged (including a timestamp) to the user configured debug log...
Implement this interface if you need to abort schedules on some error condition.
Action< string > AbortSchedule
If you raise this event, the schedule will be aborted.
Implement this interface if your device consists of multiple parts which can be used in parallel - li...
IReadOnlyCollection< IDevice > Parts
Collection of all available parts.
Everything needed for showing the error dialog / reacting on input.
string Error
A description of the problem that is shown to the user.
bool RetryLastAction
Will be set by the error dialog if "ask user" was configured and the user picked the "Retry" option.
For devices that allow interactive error handling (like retrying the last action)
EventHandler< InteractiveErrorHandlingEventArgs > HandleError
Raise this event if you want the user to decide how to continue, if this is desired in the settings.
void BeginInteraction()
Will be called if interaction is started, gives you a chance to unlock a terminal,...
void EndInteraction()
Will be called if you can lock the terminal again.
For devices that support pausing/aborting independent of a task.
bool Paused
If paused, wait until paused is reset before executing the next command.
bool Aborted
If set, abort execution as soon as possible. You can throw an OperationCanceledException....
Parameters that are constant for the duration of a schedule.
Task ApplyParametersAsync(bool waitUntilSetpointIsReached, CancellationToken cancelToken)
Set the given parameters on the device.
Implement this interface if you need direct access to the list of configured devices.
IEnumerable< IDevice > ConfiguredDevices
List of IDevice for all configured devices in Chronos.
Makes some aspects of the PAL3 behavior configurable.
bool ResetBeforeSequence
Resetting the sampler before a sequence starts is optional.
bool AlwaysResetAfterSequence
Set this to false if the sampler should be only reset after errors occurred or the schedule run was a...
Provides access to some options and configuration information for the PAL3 samplers even out of the s...
IPal3Options Options
Configure the runtime behavior.
IPalPlusConfigurationService ConfigService
The service which provides information about the device configuration, like trays and modules.
Implement this if your device needs to know when a specific job of the running scheduler has finished...
void JobFinished(int jobNo)
Will be called as soon as a job is finished.
Implement this interface if your device is a barcode reader that can be used with the ReadBarcode tas...
string ReadBarcode()
Return the read barcode here.
Generic way to access a plugin object that was wrapped by Chronos.