Chronos Plugins 5.11.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
MockPlugin.AcquisitionService.MockSimpleAcquisitionService Class Reference

An example acquisition service using a fixed list of parameters. More...

Inheritance diagram for MockPlugin.AcquisitionService.MockSimpleAcquisitionService:
Collaboration diagram for MockPlugin.AcquisitionService.MockSimpleAcquisitionService:

Public Member Functions

void ValidateCommand (MockCommandAndParameters cmdAndPars)
void RunCommand (MockCommandAndParameters cmdAndPars)
void Validate (SimpleParameters parameters)
void RunAcquisition (SimpleParameters parameters)
string ShowConfigDialog (IntPtr owner, string oldConfig)
 Show a configuration dialog for your acquisition service.
void BeginSequence (string pathToChronosSampleList)
 A new Chronos sequence has started. You can use the path to the list file to construct your own sequence name.
void EndSequence ()
 The Chronos sequence has ended. Good moment, for example, to export sample information to a list for further processing.
Public Member Functions inherited from AxelSemrau.Chronos.Plugin.IAcquisitionService< TParam >
void Validate (TParam parameters)
 Check the given parameters and throw an exception if they are invalid.
void RunAcquisition (TParam parameters)
 Send the acquisition parameters to the CDS.
Public Member Functions inherited from AxelSemrau.Chronos.Plugin.ICommandUsingAcquisitionService< TCommandAndParameters >
void ValidateCommand (TCommandAndParameters cmdAndPars)
 Please check if it is likely that you can actually execute the parameters.
void RunCommand (TCommandAndParameters cmdAndPars)
 Perform the actual command action.

Properties

string Name [get]
 Name that is visible to the user in the list of acquisition services. Do not localize.
static bool ImmediatelyAvailable [get, set]
 Allows us to bypass the delayed availability for test purposes.
bool IsAvailable [get]
 See above - we pretend the service becomes available only after some time.
bool? Abort [set]
 Will be set to true if you should abort the current acquisition. Will be set to false when everything is back to normal.
string Configuration [get, set]
 XML Fragment containing the services configuration, if any.
TimeSpan RetryInterval [get]
 If you are sure the service will not be available, return TimeSpan.Zero. Else return a reasonable interval for retrying, depending on how costly the operation is.

Events

EventHandler< TraceWriteEventArgsTraceWrite
Action< string > WriteToRunlog
Events inherited from AxelSemrau.Chronos.Plugin.ITraceLogger
EventHandler< TraceWriteEventArgsTraceWrite
 Chronos will subscribe to this event and log the text provided in the event args.
Events inherited from AxelSemrau.Chronos.Plugin.IHaveRunlogOutput
Action< string > WriteToRunlog
 Use this event to send output to the Run Control / Runlog page and, if applicable, to the runlog file.

Private Member Functions

void TraceLog (string txt)
string ConfigFromXml (string value)
string ConfigToXml (string configParam)

Private Attributes

readonly Stopwatch mAvailabilityTimer = Stopwatch.StartNew()
 We use this timer to pretend the service will only become available after a certain amount of time.
string mConfigParam = "Foobar"
 Some fake configuration parameter.

Static Private Attributes

const string RootEl = "MockServiceConfigRootElement"

Detailed Description

An example acquisition service using a fixed list of parameters.

For a more complex example, see MockDynamicParAcquisitionService.

Definition at line 55 of file MockSimpleAcquisitionService.cs.

Member Function Documentation

◆ BeginSequence()

void MockPlugin.AcquisitionService.MockSimpleAcquisitionService.BeginSequence ( string pathToChronosSampleList)

A new Chronos sequence has started. You can use the path to the list file to construct your own sequence name.

Parameters
pathToChronosSampleList

Implements AxelSemrau.Chronos.Plugin.ISequenceAwareAcquisitionService.

Definition at line 191 of file MockSimpleAcquisitionService.cs.

192 {
193 TraceLog($"Sequence ${pathToChronosSampleList} was started.");
194 }

References TraceLog().

◆ ConfigFromXml()

string MockPlugin.AcquisitionService.MockSimpleAcquisitionService.ConfigFromXml ( string value)
private

Definition at line 167 of file MockSimpleAcquisitionService.cs.

168 {
169 if (!string.IsNullOrEmpty(value))
170 {
171 var el = XElement.Parse(value);
172 if (el.Name == RootEl)
173 {
174 return el.Value;
175 }
176 }
177 return mConfigParam;
178 }

References mConfigParam, and RootEl.

Referenced by ShowConfigDialog().

◆ ConfigToXml()

string MockPlugin.AcquisitionService.MockSimpleAcquisitionService.ConfigToXml ( string configParam)
private

Definition at line 181 of file MockSimpleAcquisitionService.cs.

182 {
183 var el = new XElement(RootEl) {Value = configParam};
184 return el.ToString();
185 }

References RootEl.

Referenced by ShowConfigDialog().

◆ EndSequence()

void MockPlugin.AcquisitionService.MockSimpleAcquisitionService.EndSequence ( )

The Chronos sequence has ended. Good moment, for example, to export sample information to a list for further processing.

Implements AxelSemrau.Chronos.Plugin.ISequenceAwareAcquisitionService.

Definition at line 196 of file MockSimpleAcquisitionService.cs.

197 {
198 TraceLog("Sequence has ended.");
199 }

References TraceLog().

◆ RunAcquisition()

void MockPlugin.AcquisitionService.MockSimpleAcquisitionService.RunAcquisition ( SimpleParameters parameters)

Definition at line 115 of file MockSimpleAcquisitionService.cs.

116 {
117 TraceLog($"Running acquisition with parameters: {parameters}");
118 }

References TraceLog().

◆ RunCommand()

void MockPlugin.AcquisitionService.MockSimpleAcquisitionService.RunCommand ( MockCommandAndParameters cmdAndPars)

Definition at line 101 of file MockSimpleAcquisitionService.cs.

102 {
103 WriteToRunlog?.Invoke($"Running command '{cmdAndPars.SomeFakeCommand}' for instrument {cmdAndPars.InstrumentNumber}");
104 }

References WriteToRunlog.

◆ ShowConfigDialog()

string MockPlugin.AcquisitionService.MockSimpleAcquisitionService.ShowConfigDialog ( IntPtr owner,
string oldConfig )

Show a configuration dialog for your acquisition service.

Parameters
ownerUse this as your window's owner
oldConfigShow the dialog based on this configuration, not some internal state of your service.
Returns
The new or old configuration, depending on the user's choices and how the dialog was terminated.

Implements AxelSemrau.Chronos.Plugin.IHaveConfigurator.

Definition at line 142 of file MockSimpleAcquisitionService.cs.

143 {
144
145 var dlg = new ConfigDialog()
146 {
147 ParamText = ConfigFromXml(oldConfig)
148 };
149 var dummy = new System.Windows.Interop.WindowInteropHelper(dlg) { Owner = owner };
150 if (dlg.ShowDialog() ?? false)
151 {
152 return ConfigToXml(dlg.ParamText);
153 }
154 return oldConfig;
155 }

References ConfigFromXml(), and ConfigToXml().

◆ TraceLog()

void MockPlugin.AcquisitionService.MockSimpleAcquisitionService.TraceLog ( string txt)
private

Definition at line 122 of file MockSimpleAcquisitionService.cs.

123 {
124 TraceWrite?.Invoke(this, new TraceWriteEventArgs(txt));
125 }

References TraceWrite.

Referenced by BeginSequence(), EndSequence(), RunAcquisition(), and Validate().

◆ Validate()

void MockPlugin.AcquisitionService.MockSimpleAcquisitionService.Validate ( SimpleParameters parameters)

Definition at line 110 of file MockSimpleAcquisitionService.cs.

111 {
112 TraceLog($"Validating simple parameters: {parameters}");
113 }

References TraceLog().

◆ ValidateCommand()

void MockPlugin.AcquisitionService.MockSimpleAcquisitionService.ValidateCommand ( MockCommandAndParameters cmdAndPars)

Definition at line 96 of file MockSimpleAcquisitionService.cs.

97 {
98 WriteToRunlog?.Invoke($"Validating command '{cmdAndPars.SomeFakeCommand}' for instrument {cmdAndPars.InstrumentNumber}");
99 }

References WriteToRunlog.

Member Data Documentation

◆ mAvailabilityTimer

readonly Stopwatch MockPlugin.AcquisitionService.MockSimpleAcquisitionService.mAvailabilityTimer = Stopwatch.StartNew()
private

We use this timer to pretend the service will only become available after a certain amount of time.

Definition at line 71 of file MockSimpleAcquisitionService.cs.

◆ mConfigParam

string MockPlugin.AcquisitionService.MockSimpleAcquisitionService.mConfigParam = "Foobar"
private

Some fake configuration parameter.

Definition at line 138 of file MockSimpleAcquisitionService.cs.

Referenced by ConfigFromXml().

◆ RootEl

const string MockPlugin.AcquisitionService.MockSimpleAcquisitionService.RootEl = "MockServiceConfigRootElement"
staticprivate

Definition at line 131 of file MockSimpleAcquisitionService.cs.

Referenced by ConfigFromXml(), and ConfigToXml().

Property Documentation

◆ Abort

bool? MockPlugin.AcquisitionService.MockSimpleAcquisitionService.Abort
set

Will be set to true if you should abort the current acquisition. Will be set to false when everything is back to normal.

Implements AxelSemrau.Chronos.Plugin.IAcquisitionServiceBase.

Definition at line 95 of file MockSimpleAcquisitionService.cs.

95{ set => TraceLog($"Abort flag {(value ? "set" : "reset")}"); }

◆ Configuration

string MockPlugin.AcquisitionService.MockSimpleAcquisitionService.Configuration
getset

XML Fragment containing the services configuration, if any.

If you have none, just return null.

Implements AxelSemrau.Chronos.Plugin.IConfigurableAcquisitionService.

Definition at line 161 of file MockSimpleAcquisitionService.cs.

162 {
163 get => ConfigToXml(mConfigParam);
164 set => mConfigParam = ConfigFromXml(value);
165 }

◆ ImmediatelyAvailable

bool MockPlugin.AcquisitionService.MockSimpleAcquisitionService.ImmediatelyAvailable
staticgetset

Allows us to bypass the delayed availability for test purposes.

Definition at line 76 of file MockSimpleAcquisitionService.cs.

76{ get; set; }

◆ IsAvailable

bool MockPlugin.AcquisitionService.MockSimpleAcquisitionService.IsAvailable
get

See above - we pretend the service becomes available only after some time.

Implements AxelSemrau.Chronos.Plugin.IAcquisitionServiceBase.

Definition at line 81 of file MockSimpleAcquisitionService.cs.

82 {
83 get
84 {
85 if (ImmediatelyAvailable || mAvailabilityTimer.Elapsed > TimeSpan.FromMinutes(2))
86 {
87 mAvailabilityTimer.Stop();
88 return true;
89 }
90
91 return false;
92 }
93 }

◆ Name

string MockPlugin.AcquisitionService.MockSimpleAcquisitionService.Name
get

Name that is visible to the user in the list of acquisition services. Do not localize.

Implements AxelSemrau.Chronos.Plugin.IAcquisitionServiceBase.

Definition at line 66 of file MockSimpleAcquisitionService.cs.

◆ RetryInterval

TimeSpan MockPlugin.AcquisitionService.MockSimpleAcquisitionService.RetryInterval
get

If you are sure the service will not be available, return TimeSpan.Zero. Else return a reasonable interval for retrying, depending on how costly the operation is.

Implements AxelSemrau.Chronos.Plugin.IPerseveringAcquisitionService.

Definition at line 207 of file MockSimpleAcquisitionService.cs.

Event Documentation

◆ TraceWrite

EventHandler<TraceWriteEventArgs> MockPlugin.AcquisitionService.MockSimpleAcquisitionService.TraceWrite

Definition at line 129 of file MockSimpleAcquisitionService.cs.

Referenced by TraceLog().

◆ WriteToRunlog

Action<string> MockPlugin.AcquisitionService.MockSimpleAcquisitionService.WriteToRunlog

Definition at line 203 of file MockSimpleAcquisitionService.cs.

Referenced by RunCommand(), and ValidateCommand().


The documentation for this class was generated from the following file: