Chronos Plugins 5.11.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
Helpers.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Windows;
5using System.Windows.Forms;
6using System.Windows.Threading;
11
13{
18 public interface IGuiHelper
19 {
23 System.Threading.Tasks.TaskScheduler GuiThreadScheduler { get; }
27 System.Threading.Tasks.TaskFactory GuiTaskFactory { get; }
34 void OwnMyWindow(IntPtr handle);
38 IWin32Window MainWindow { get; }
39
47 bool MainWindowEnabled { get; set; }
48
52 Dispatcher GuiDispatcher { get; }
53 }
54
59 public interface IDebugHelper
60 {
66 void TraceWrite(string text, params object[] arguments);
72 void TraceWriteExceptionInfo(string contextHint, Exception ex);
73 }
74
78 public static class Helpers
79 {
88 public static Version ApiVersion { get; } = new(1,5,0);
89
93 public static IGuiHelper Gui { get; internal set; }
94
98 public static IDebugHelper Debug { get; internal set; }
99
103 public static IConfigInfo Config { get; internal set; }
104
108 public static IEnumerable<IDeviceInfo> Devices { get; internal set; }
109
113 public static IUtilityFactories UtilityFactories { get; internal set; }
114
121 public static IStorageInspector Storage { get; internal set; }
122
126 public static IConsumables Consumables { get; internal set; }
127
131 public static ILicenseChecker LicenseChecker { get; internal set; }
139 public static ResourceDictionary WpfResources { get; } = new ChronosResources();
145 public static IEnumerable<IAcquisitionServiceBase> AcquisitionServices { get; internal set; }
149 public static ILoadPathExtender LoadPathExtender { get; internal set; }
153 public static ISecurity Security { get; internal set; }
154 }
155
163 public interface ILicenseChecker
164 {
170 ILicenseInfo GetLicenseInfo(string licenseCode);
174 string ComputerId { get; }
175 }
176
180 public interface IDeviceInfoProvider : IEnumerable<IDeviceInfo>
181 {
182
183 }
184
188 public interface ILicenseInfo
189 {
193 string Serial { get; }
197 int ProductId { get; }
201 DateTime IssueDate { get; }
205 bool IsValid { get; }
211 bool ActivationMatches(string activationCode);
212 }
213
217 public interface IStorageInspector
218 {
224 IMethodInfo Method(string path);
225
231 IMethodInfo Method(Stream method);
232 }
233
237 public interface IConfigInfo
238 {
245 string PathToMethods { get; }
252 string PathToSampleLists { get; }
260 IReadOnlyList<ITrayInfo> Trays { get; }
261 }
262
266 public interface IDeviceInfo
267 {
276 }
277
281 public interface IUtilityFactories
282 {
291 System.IO.Ports.SerialPort CreateSafeSerialPort();
297 T CreateViewModel<T>() where T: class;
303 T CreateView<T>() where T: FrameworkElement;
309 }
310
311}
Classes and interfaces that are meant for plugins. The classes and interfaces below this namespace ar...
Information regarding the currently active configuration. These classes reflect configuration informa...
Definition ITrayInfo.cs:4
Foundation of a consumable management system. Not yet really utilized in Chronos itself,...
Infrastructure for security related things. Currently providing easy access to the Windows Credential...
Useful things for those who use Windows Presentation Foundation for their plugins.
For centralized access to all consumables.
To be implemented by the "device driver" part of a Chronos plugin.
Helper functions for GUI related tasks.
Definition Helpers.cs:19
bool MainWindowEnabled
Allows you to temporarily disable all user interaction with the Chronos main window.
Definition Helpers.cs:47
System.Threading.Tasks.TaskScheduler GuiThreadScheduler
Use this scheduler to do actions on the thread that owns the main GUI.
Definition Helpers.cs:23
void OwnMyWindow(IntPtr handle)
Make the window with the given handle owned by the Chronos main window. This prevents it from droppin...
Dispatcher GuiDispatcher
The dispatcher that is used for WPF operations on the main GUI thread.
Definition Helpers.cs:52
System.Threading.Tasks.TaskFactory GuiTaskFactory
For your convenience, a default task factory for tasks running on the GUI thread.
Definition Helpers.cs:27
IWin32Window MainWindow
If you need to set the owner window yourself or want to show message boxes.
Definition Helpers.cs:38
Utility functions for debugging purposes.
Definition Helpers.cs:60
void TraceWriteExceptionInfo(string contextHint, Exception ex)
Logs exception details to the trace log, including a stack trace and, if applicable,...
void TraceWrite(string text, params object[] arguments)
Write something to the Chronos trace log.
Static instance for access to utility functions and resources.
Definition Helpers.cs:79
static IGuiHelper Gui
Utility functions for window handling.
Definition Helpers.cs:93
static IEnumerable< IAcquisitionServiceBase > AcquisitionServices
Available acquisition service instances.
Definition Helpers.cs:145
static Version ApiVersion
From Chronos 5.2 on: A plugin API version you can check if you want to give understandable error mess...
Definition Helpers.cs:88
static IConfigInfo Config
Information about general program configuration, standard folders and similar.
Definition Helpers.cs:103
static IEnumerable< IDeviceInfo > Devices
Definition Helpers.cs:108
static ResourceDictionary WpfResources
Resources for WPF controls that should make it easier to keep a common look and feel.
Definition Helpers.cs:139
static ILoadPathExtender LoadPathExtender
Helps to deal with assemblies in different locations.
Definition Helpers.cs:149
static ISecurity Security
Gives access to security related functions.
Definition Helpers.cs:153
static IStorageInspector Storage
Inspect stored data like methods...
Definition Helpers.cs:121
static IUtilityFactories UtilityFactories
Helper class factories, see the members for details.
Definition Helpers.cs:113
static IConsumables Consumables
Access to consumables managers, if they are present.
Definition Helpers.cs:126
static IDebugHelper Debug
Utility functions for debugging.
Definition Helpers.cs:98
static ILicenseChecker LicenseChecker
Helps optional Chronos components understand their environment.
Definition Helpers.cs:131
Information about license validity and type.
Definition Helpers.cs:164
string ComputerId
Unique identifier for this computer.
Definition Helpers.cs:174
ILicenseInfo GetLicenseInfo(string licenseCode)
Give information regarding some Chronos style license code.
Providing an opportunity for future extension. Made available via dependency injection.
Definition Helpers.cs:181
Details about a Chronos style license.
Definition Helpers.cs:189
string Serial
The license code for which the information is provided.
Definition Helpers.cs:193
bool IsValid
Check if the license code is formally correct. Does not check any date restrictions.
Definition Helpers.cs:205
int ProductId
Axel Semrau internal product numbers.
Definition Helpers.cs:197
bool ActivationMatches(string activationCode)
Checks if the given activation code matches the license and the current machine.
DateTime IssueDate
Official license issue date.
Definition Helpers.cs:201
IMethodInfo Method(string path)
Get information about a method.
IMethodInfo Method(Stream method)
Get information about a method.
Get information about the currently active configuration.
Definition Helpers.cs:238
string PathToInstrumentConfig
Full path to the folder where the active Chronos instrument configuration is stored.
Definition Helpers.cs:256
IReadOnlyList< ITrayInfo > Trays
Some general information about the configured trays and other accessible objects.
Definition Helpers.cs:260
string PathToMethods
Full path to the standard method folder chosen by the user. Can be null or empty.
Definition Helpers.cs:245
string PathToSampleLists
Full path to the standard sample list folder chosen by the user. Can be null or empty.
Definition Helpers.cs:252
Gives access to information about a device and its connection state, if known.
Definition Helpers.cs:267
ConnectionState ConnectionState
The connection state, if known (.
Definition Helpers.cs:275
Helper factories for utility classes implemented within Chronos.
Definition Helpers.cs:282
IInspectJob CreateDummyJobInspector()
Needed by the CTC Task SDK.
System.IO.Ports.SerialPort CreateSafeSerialPort()
Returns a modified serial port class instance that avoids some problems of the original component.
T CreateViewModel< T >()
Create a working instance for one of the abstract classes in WPF/ViewModels.
Allows loading assemblies from specific paths.
Allows to get information about other tasks within our task's job and about other jobs.
Information about the method that was used to create this job.