aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Emulations
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2020-01-15 14:39:41 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2020-01-15 14:39:41 +0200
commit7b5a8bd0e4dbe8f1955a06c720380760ccb67ebd (patch)
treee9212b540608df6aaf4bb5280229675b828b6751 /Software/Visual_Studio/Tango.Emulations
parent4e739ecb88185867e2c9ca05fda661eb8e0c6f10 (diff)
downloadTango-7b5a8bd0e4dbe8f1955a06c720380760ccb67ebd.tar.gz
Tango-7b5a8bd0e4dbe8f1955a06c720380760ccb67ebd.zip
Working on diagnostics synchronization..
Diffstat (limited to 'Software/Visual_Studio/Tango.Emulations')
-rw-r--r--Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs19
1 files changed, 16 insertions, 3 deletions
diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
index 7537e4676..8ac03b23f 100644
--- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
+++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs
@@ -52,6 +52,7 @@ namespace Tango.Emulations.Emulators
}
private const int MAX_CHUNK_LENGTH = 4000;
+ private const int DIAGNOSTICS_INTERVAL = 300;
private static Random _rnd = new Random();
private StartDiagnosticsRequest _diagnosticsRequest;
private bool _cancelJob;
@@ -80,6 +81,7 @@ namespace Tango.Emulations.Emulators
private bool _abortPowerDown;
private bool _isThreadLoadingStarted;
private String _threadLoadingToken;
+ private DateTime _connectionTime;
#region Properties
@@ -460,8 +462,12 @@ namespace Tango.Emulations.Emulators
var cancelToken = CreateCancelToken();
+ Stopwatch watch = new Stopwatch();
+
Task.Factory.StartNew(() =>
{
+ watch.Start();
+
while (_diagnostics_enabled && Transporter.State == TransportComponentState.Connected && !cancelToken.Canceled)
{
StartDiagnosticsResponse res = new StartDiagnosticsResponse();
@@ -535,13 +541,16 @@ namespace Tango.Emulations.Emulators
res.ComponentsStates.AddRange(_componentsStates);
res.HeatersStates.AddRange(_heater_states);
res.ValvesStates.AddRange(_valveStates);
+ res.ElapsedMilli = (uint)watch.ElapsedMilliseconds;
+
+ watch.Restart();
if (!EmulateCorruption)
{
Transporter.SendResponse<StartDiagnosticsResponse>(res, request.Container.Token);
}
- Thread.Sleep(300);
+ Thread.Sleep(DIAGNOSTICS_INTERVAL);
}
});
@@ -1040,11 +1049,15 @@ namespace Tango.Emulations.Emulators
Name = "Machine Emulator",
FPGA1Version = "1.1",
FPGA2Version = "2.2",
- FPGA3Version = "3.3"
+ FPGA3Version = "3.3",
+ DiagnosticsInterval = (uint)DIAGNOSTICS_INTERVAL,
},
IsAfterReset = _isAfterReset,
}, request.Container.Token, null, request.Message.Password == "1234" ? ErrorCode.None : ErrorCode.UnauthorizedConnection);
+
+ _connectionTime = DateTime.Now;
+
_isAfterReset = false;
}
}
@@ -1456,7 +1469,7 @@ namespace Tango.Emulations.Emulators
{
await Transporter.SendResponse<StartThreadLoadingResponse>(new StartThreadLoadingResponse() { State = ThreadLoadingState.ReadyForLoading }, _threadLoadingToken);
}
-
+
public async void FinalizeThreadLoading()
{
await Transporter.SendResponse<StartThreadLoadingResponse>(new StartThreadLoadingResponse() { State = ThreadLoadingState.Finalizing }, _threadLoadingToken);