Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
EvaluationArguments.cs
1using System.Collections.Generic;
4using Waher.Script;
8
10{
15 {
16 private readonly SortedDictionary<string, object> updatedVariables = new SortedDictionary<string, object>();
17
31 {
32 this.Variables = Variables;
33 this.Machine = Machine;
34 this.Token = Token;
35 this.CurrentState = CurrentState;
36 this.StateUpdated = false;
37 this.VariablesUpdated = false;
38 this.AuthorizationsUpdated = false;
39 this.Legal = Legal;
40 this.EDaler = EDaler;
41 this.Profiler = Profiler;
42 }
43
47 public Variables Variables { get; }
48
52 public StateMachine Machine { get; }
53
57 public Token Token { get; }
58
62 public CurrentState CurrentState { get; }
63
67 public bool StateUpdated
68 {
69 get;
70 internal set;
71 }
72
76 public bool VariablesUpdated
77 {
78 get;
79 private set;
80 }
81
86 {
87 get;
88 internal set;
89 }
90
94 public LegalComponent Legal { get; }
95
99 public EDalerComponent EDaler { get; }
100
104 public Profiler Profiler { get; }
105
110 public void SetState(string StateId)
111 {
112 this.CurrentState.State = StateId;
113 this.StateUpdated = true;
114
115 if (string.IsNullOrEmpty(StateId))
116 this.Profiler?.Idle();
117 else
118 this.Profiler?.NewState(StateId);
119 }
120
126 public void UpdateVariable(string Name, object Value)
127 {
128 lock (this.updatedVariables)
129 {
130 this.updatedVariables[Name] = Value;
131 this.VariablesUpdated = true;
132 }
133
134 this.Variables[Name] = Value;
135 this.CurrentState.SetVariable(Name, Value);
136 }
137
143 {
144 if (this.CurrentState.AddSource(Source))
145 this.AuthorizationsUpdated = true;
146 }
147
153 {
154 if (this.CurrentState.RemoveSource(Source))
155 this.AuthorizationsUpdated = true;
156 }
157
162 public KeyValuePair<string, object>[] PopUpdatedVariables()
163 {
164 KeyValuePair<string, object>[] Result;
165
166 lock (this.updatedVariables)
167 {
168 Result = new KeyValuePair<string, object>[this.updatedVariables.Count];
169 this.updatedVariables.CopyTo(Result, 0);
170
171 this.updatedVariables.Clear();
172 this.VariablesUpdated = false;
173 }
174
175 return Result;
176 }
177
182 {
183 lock (this.updatedVariables)
184 {
185 this.updatedVariables.Clear();
186 this.VariablesUpdated = false;
187 }
188 }
189 }
190}
Represents a case-insensitive string.
Class that keeps track of events and timing.
Definition: Profiler.cs:67
void Idle()
Main Thread goes idle.
Definition: Profiler.cs:264
void NewState(string State)
Main Thread changes state.
Definition: Profiler.cs:247
Collection of variables.
Definition: Variables.cs:25
Manages eDaler on accounts connected to the broker.
Class representing the current state of a state machine.
Definition: CurrentState.cs:20
void SetVariable(string Name, object Value)
Sets a variable
Definition: CurrentState.cs:98
bool AddSource(CaseInsensitiveString Name)
Adds a source
bool RemoveSource(CaseInsensitiveString Name)
Removes a source
Contains information required for evaluating script in a state-machine.
StateMachine Machine
Reference to state-machine definition.
EvaluationArguments(Variables Variables, StateMachine Machine, Token Token, CurrentState CurrentState, LegalComponent Legal, EDalerComponent EDaler, Profiler Profiler)
Contains information required for evaluating script in a state-machine.
void AddSource(CaseInsensitiveString Source)
Adds an authorization.
bool AuthorizationsUpdated
If authorizations in the state machine have been updated.
KeyValuePair< string, object >[] PopUpdatedVariables()
Gets an array of updated variables since last call.
void UpdateVariable(string Name, object Value)
Updates a variable.
void RemoveSource(CaseInsensitiveString Source)
Removes an authorization.
bool StateUpdated
If the state machine has changed state during processing.
bool VariablesUpdated
If variables in the state machine have been updated.
Class representing a state machine.
Definition: StateMachine.cs:37