Chronos Plugins 5.4.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.Runtime.CompilerServices;
4using System.Windows;
5using System.Windows.Forms;
6using System.Windows.Threading;
10
12{
17 public interface IGuiHelper
18 {
22 System.Threading.Tasks.TaskScheduler GuiThreadScheduler { get; }
26 System.Threading.Tasks.TaskFactory GuiTaskFactory { get; }
33 void OwnMyWindow(IntPtr handle);
37 IWin32Window MainWindow { get; }
38
46 bool MainWindowEnabled { get; set; }
47
51 Dispatcher GuiDispatcher { get; }
52 }
53
58 public interface IDebugHelper
59 {
65 void TraceWrite(string text, params object[] arguments);
71 void TraceWriteExceptionInfo(string contextHint, Exception ex);
72 }
73
77 public static class Helpers
78 {
87 public static Version ApiVersion { get; } = new Version(1,3,0);
88
92 public static IGuiHelper Gui { get; internal set; }
93
97 public static IDebugHelper Debug { get; internal set; }
98
102 public static IConfigInfo Config { get; internal set; }
103
107 public static IEnumerable<IDeviceInfo> Devices { get; internal set; }
108
112 public static IUtilityFactories UtilityFactories { get; internal set; }
113
120 public static IStorageInspector Storage { get; internal set; }
121
125 public static IConsumables Consumables { get; internal set; }
126
130 public static ILicenseChecker LicenseChecker { get; internal set; }
138 public static ResourceDictionary WpfResources { get; } = new ChronosResources();
144 public static IEnumerable<IAcquisitionServiceBase> AcquisitionServices { get; internal set; }
148 public static ILoadPathExtender LoadPathExtender { get; internal set; }
149 }
150
158 public interface ILicenseChecker
159 {
165 ILicenseInfo GetLicenseInfo(string licenseCode);
169 string ComputerId { get; }
170 }
171
175 public interface ILicenseInfo
176 {
180 string Serial { get; }
184 int ProductId { get; }
188 DateTime IssueDate { get; }
192 bool IsValid { get; }
198 bool ActivationMatches(string activationCode);
199 }
200
204 public interface IStorageInspector
205 {
211 IMethodInfo Method(string path);
212 }
213
217 public interface IConfigInfo
218 {
225 string PathToMethods { get; }
232 string PathToSampleLists { get; }
240 IReadOnlyList<ITrayInfo> Trays { get; }
241 }
242
246 public interface IDeviceInfo
247 {
256 }
257
261 public interface IUtilityFactories
262 {
271 System.IO.Ports.SerialPort CreateSafeSerialPort();
277 T CreateViewModel<T>() where T: class;
283 T CreateView<T>() where T: FrameworkElement;
289 }
290
291}
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.
Information regarding the currently active configuration. These classes reflect configuration informa...
Definition: ITrayInfo.cs:4
For centralized access to all consumables.
Definition: IConsumables.cs:12
To be implemented by the "device driver" part of a Chronos plugin.
Helper functions for GUI related tasks.
Definition: Helpers.cs:18
bool MainWindowEnabled
Allows you to temporarily disable all user interaction with the Chronos main window.
Definition: Helpers.cs:46
System.Threading.Tasks.TaskScheduler GuiThreadScheduler
Use this scheduler to do actions on the thread that owns the main GUI.
Definition: Helpers.cs:22
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:51
System.Threading.Tasks.TaskFactory GuiTaskFactory
For your convenience, a default task factory for tasks running on the GUI thread.
Definition: Helpers.cs:26
IWin32Window MainWindow
If you need to set the owner window yourself or want to show message boxes.
Definition: Helpers.cs:37
Utility functions for debugging purposes.
Definition: Helpers.cs:59
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:78
static IGuiHelper Gui
Utility functions for window handling.
Definition: Helpers.cs:92
static IEnumerable< IAcquisitionServiceBase > AcquisitionServices
Available acquisition service instances.
Definition: Helpers.cs:144
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:87
static IConfigInfo Config
Information about general program configuration, standard folders and similar.
Definition: Helpers.cs:102
static IEnumerable< IDeviceInfo > Devices
Definition: Helpers.cs:107
static ResourceDictionary WpfResources
Resources for WPF controls that should make it easier to keep a common look and feel.
Definition: Helpers.cs:138
static ILoadPathExtender LoadPathExtender
Helps dealing with assemblies in different locations.
Definition: Helpers.cs:148
static IStorageInspector Storage
Inspect stored data like methods...
Definition: Helpers.cs:120
static IUtilityFactories UtilityFactories
Helper class factories, see the members for details.
Definition: Helpers.cs:112
static IConsumables Consumables
Access to consumables managers, if they are present.
Definition: Helpers.cs:125
static IDebugHelper Debug
Utility functions for debugging.
Definition: Helpers.cs:97
static ILicenseChecker LicenseChecker
Helps optional Chronos components understand their environment.
Definition: Helpers.cs:130
Information about license validity and type.
Definition: Helpers.cs:159
string ComputerId
Unique identifier for this computer.
Definition: Helpers.cs:169
ILicenseInfo GetLicenseInfo(string licenseCode)
Give information regarding some Chronos style license code.
Details about a Chronos style license.
Definition: Helpers.cs:176
string Serial
The license code for which the information is provided.
Definition: Helpers.cs:180
bool IsValid
Check if the license code is formally correct. Does not check any date restrictions.
Definition: Helpers.cs:192
int ProductId
Axel Semrau internal product numbers.
Definition: Helpers.cs:184
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:188
IMethodInfo Method(string path)
Get information about a method.
Get information about the currently active configuration.
Definition: Helpers.cs:218
string PathToInstrumentConfig
Full path to the folder where the active Chronos instrument configuration is stored.
Definition: Helpers.cs:236
IReadOnlyList< ITrayInfo > Trays
Some general information about the configured trays and other accessible objects.
Definition: Helpers.cs:240
string PathToMethods
Full path to the standard method folder chosen by the user. Can be null or empty.
Definition: Helpers.cs:225
string PathToSampleLists
Full path to the standard sample list folder chosen by the user. Can be null or empty.
Definition: Helpers.cs:232
Gives access to information about a device and its connection state, if known.
Definition: Helpers.cs:247
Helper factories for utility classes implemented within Chronos.
Definition: Helpers.cs:262
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.