diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-01 19:26:32 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-01 19:26:32 +0200 |
| commit | 68ec47fb04c19139f8e39343689201a9f089ad8c (patch) | |
| tree | e23dd24478a97faa373a2a58ae4d865882447f4d /Software/Visual_Studio/Tango.Integration | |
| parent | 45a7a7319bbae1a2ab5cfc93d7a2507cccd8770e (diff) | |
| download | Tango-68ec47fb04c19139f8e39343689201a9f089ad8c.tar.gz Tango-68ec47fb04c19139f8e39343689201a9f089ad8c.zip | |
Implemented machine events emulation via FSE.
Added support for event 5099.
Updated event rev to 28.
Added 3 & 4 dancer types for X4.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration')
| -rw-r--r-- | Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs | 7 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs | 30 |
2 files changed, 36 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs index 232446cb6..e7d3cd0e8 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/IMachineOperator.cs @@ -550,5 +550,12 @@ namespace Tango.Integration.Operation /// </summary> /// <returns></returns> Task AttemptThreadJogging(); + + /// <summary> + /// Emulates a hardware event that will last for the specified timeout. + /// </summary> + /// <param name="ev">Type of the event.</param> + /// <param name="timeout">The timeout.</param> + void PushEmulatedEvent(Event ev, TimeSpan timeout); } } diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 93320c646..bce386bfe 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -85,6 +85,7 @@ namespace Tango.Integration.Operation private DateTime? _jobUploadingStartDate; private DateTime? _jobHeatingStartDate; private DateTime? _jobActualStartDate; + private List<Event> _emulatedEvents; public static String EmbeddedLogsFolder { get; private set; } public static String EmbeddedLogsTag { get; private set; } @@ -124,6 +125,7 @@ namespace Tango.Integration.Operation /// </summary> public MachineOperator() : base() { + _emulatedEvents = new List<Event>(); ComponentName = $"Machine Operator {_component_counter++}"; DeviceInformation = new DeviceInformation(); MachineEventsStateProvider = new DefaultMachineEventsStateProvider(); @@ -957,7 +959,17 @@ namespace Tango.Integration.Operation { if (MachineEventsStateProvider != null) { - MachineEventsStateProvider.ApplyEvents(response.Events); + var events = response.Events; + + foreach (var emulated in _emulatedEvents) + { + if (!events.Any(x => x.Type == emulated.Type)) + { + events.Add(emulated); + } + } + + MachineEventsStateProvider.ApplyEvents(events); } EventsNotification?.Invoke(this, response); @@ -1373,6 +1385,7 @@ namespace Tango.Integration.Operation if (MachineEventsStateProvider != null) { LogManager.Log("Resetting active events..."); + _emulatedEvents.Clear(); MachineEventsStateProvider.Reset(); } } @@ -4154,6 +4167,21 @@ namespace Tango.Integration.Operation }, new TransportRequestConfig() { ShouldLog = true, Timeout = TimeSpan.FromSeconds(20) }); } + /// <summary> + /// Emulates a hardware event that will last for the specified timeout. + /// </summary> + /// <param name="ev">Type of the event.</param> + /// <param name="timeout">The timeout.</param> + public async void PushEmulatedEvent(Event ev, TimeSpan timeout) + { + if (!_emulatedEvents.Exists(x => x.Type == ev.Type)) + { + _emulatedEvents.Add(ev); + await Task.Delay(timeout); + _emulatedEvents.Remove(ev); + } + } + #endregion } } |
