Chronos Plugins 5.9.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< SimpleParameters >
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.IHaveConfigurator
- Public Member Functions inherited from AxelSemrau.Chronos.Plugin.ISequenceAwareAcquisitionService
- Public Member Functions inherited from AxelSemrau.Chronos.Plugin.ICommandUsingAcquisitionService< MockCommandAndParameters >
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.
 
- Properties inherited from AxelSemrau.Chronos.Plugin.IConfigurableAcquisitionService
- Properties inherited from AxelSemrau.Chronos.Plugin.IAcquisitionServiceBase
- Properties inherited from AxelSemrau.Chronos.Plugin.IPerseveringAcquisitionService

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 MockPlugin.AcquisitionService.MockSimpleAcquisitionService.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 MockPlugin.AcquisitionService.MockSimpleAcquisitionService.mConfigParam, and MockPlugin.AcquisitionService.MockSimpleAcquisitionService.RootEl.

Referenced by MockPlugin.AcquisitionService.MockSimpleAcquisitionService.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 MockPlugin.AcquisitionService.MockSimpleAcquisitionService.RootEl.

Referenced by MockPlugin.AcquisitionService.MockSimpleAcquisitionService.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 MockPlugin.AcquisitionService.MockSimpleAcquisitionService.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 MockPlugin.AcquisitionService.MockSimpleAcquisitionService.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 MockPlugin.AcquisitionService.MockSimpleAcquisitionService.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 MockPlugin.AcquisitionService.MockSimpleAcquisitionService.ConfigFromXml(), and MockPlugin.AcquisitionService.MockSimpleAcquisitionService.ConfigToXml().

◆ TraceLog()

◆ 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 MockPlugin.AcquisitionService.MockSimpleAcquisitionService.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 MockPlugin.AcquisitionService.MockSimpleAcquisitionService.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 MockPlugin.AcquisitionService.MockSimpleAcquisitionService.ConfigFromXml().

◆ RootEl

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

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 {
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 }
static bool ImmediatelyAvailable
Allows us to bypass the delayed availability for test purposes.
readonly Stopwatch mAvailabilityTimer
We use this timer to pretend the service will only become available after a certain amount of time.

◆ 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

◆ WriteToRunlog

Action<string> MockPlugin.AcquisitionService.MockSimpleAcquisitionService.WriteToRunlog

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