2using System.Collections.Generic;
3using System.Threading.Tasks;
21 private DateTime timepoint = DateTime.MaxValue;
49 this.Current = DateTime.Now;
50 this.Next = DateTime.MaxValue;
60 this.Current = DateTime.Now;
61 this.Next =
Next.ToLocalTime();
71 this.Current = DateTime.Now;
83 this.Current = DateTime.Now;
84 this.Next =
Next.ToLocalTime();
97 this.Next =
Next.ToLocalTime();
127 this.timepoint = TP.
Next;
128 this.recurrence = Event.HasNewState ? Duration.Zero : TP.
Duration;
130 if (this.timepoint <= DateTime.Now)
133 if (this.timepoint == DateTime.MaxValue)
139 this.timepoint = pendingEvents.Add(this.timepoint, this.EventElapsed, Handler);
141 this.AddIntervalToProfiler(TP, Arguments.
Profiler);
154 this.timepoint = Handler.
Timepoint.ToLocalTime();
157 if (this.timepoint <= DateTime.Now)
158 await this.EventElapsed(Handler);
159 else if (this.timepoint < DateTime.MaxValue)
160 this.timepoint = pendingEvents.Add(this.timepoint, this.EventElapsed, Handler);
171 Label = TP.Duration.ToString();
174 TimeSpan TS = TP.Next - TP.Current;
175 double d = TS.TotalDays;
177 Label = d.ToString(
"F2") +
" days";
182 Label = d.ToString(
"F2") +
" h";
187 Label = d.ToString(
"F2") +
" min";
192 Label = d.ToString(
"F2") +
" s";
195 d = TS.TotalMilliseconds;
196 Label = d.ToString(
"F2") +
" ms";
213 this.timepoint = pendingEvents.Add(Handler.
Timepoint,
this.EventElapsed, Handler);
223 if (this.timepoint != DateTime.MaxValue)
225 pendingEvents.Remove(this.timepoint);
226 this.timepoint = DateTime.MaxValue;
230 return Task.CompletedTask;
233 private Task EventElapsed(
object State)
244 StateMachineProcessor.CacheRecord Record =
null;
253 if (Recurring && !(Record is
null))
257 Handler.Timepoint += Recurrence;
259 while (Handler.
Timepoint <= DateTime.Now);
261 this.recurrence = Recurrence;
262 this.timepoint = pendingEvents.Add(Handler.
Timepoint,
this.EventElapsed, Handler);
271 catch (KeyNotFoundException)
279 if (!(Record.Profiler is
null))
281 int NoteNr = Record.Profiler.AddNote(ex);
282 Record.Profiler?.Exception(ex,
"Note" + NoteNr);
290 internal static void ClearPendingEvents()
292 pendingEvents.Clear();
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static async Task Update(object Object)
Updates an object in the database.
static async Task Delete(object Object)
Deletes an object in the database.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
Class that keeps track of events and timing.
void Interval(DateTime From, DateTime To, string Label)
Records an interval in the main thread.
Class that can be used to schedule events in time. It uses a timer to execute tasks at the appointed ...
Event handler for timepoint events.
Duration Recurrence
Recurrence
DateTime Timepoint
Timepoint.
Contains information required for evaluating script in a state-machine.
Profiler Profiler
State-Machine profiler.
Represents an event definition.
Abstract base class for State-Machine event nodes.
abstract string Label
UML Label for event.
Contains information about when a timed event elapses.
EventTimepoint()
No next timepoint
EventTimepoint(Duration Duration)
Contains information about when a timed event elapses.
EventTimepoint(DateTime Next, Duration Duration)
Contains information about when a timed event elapses.
Duration Duration
Duration of recurring events.
EventTimepoint(DateTime Next)
Contains information about when a timed event elapses.
DateTime Current
Current timepoint
EventTimepoint(DateTime Current, DateTime Next, Duration Duration)
Contains information about when a timed event elapses.
DateTime Next
Next timepoint
Abstract base class for timed State-Machine event nodes.
abstract Task< EventTimepoint > GetEventTimepoint(EvaluationArguments Arguments)
Gets the timepoint for when the event elapses.
override async Task< bool > Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
Registers the event
TimedEventNode()
Abstract base class for timed State-Machine event nodes.
async Task EventElapsed(TimepointEventHandler Handler)
Method called when event elapses.
async Task ReregisterOnStart(TimepointEventHandler Handler)
Re-registers the event on module start.
override Task Unregister(int EventIndex, EvaluationArguments Arguments)
Registers the event
void Register(TimepointEventHandler Handler)
Registers an existing event handler.
Action executed when entering a state.
Represents an action definition.
Represents a duration value, as defined by the xsd:duration data type: http://www....
static readonly Duration Zero
Zero value