Update SIM

- generazione dati x stato
- dati x contatori
This commit is contained in:
Samuele Locatelli
2022-06-24 11:55:12 +02:00
parent 72fb70093d
commit 424fc11fc1
8 changed files with 188 additions and 119 deletions
+26 -26
View File
@@ -74,11 +74,11 @@ LogSimulator.Add(Constants.MAINT_STATS_M_QUEUE, 0);
LogSimulator.Add(Constants.TOOLS_M_QUEUE, 0);
// avvio tutti i thread...
Thread threadStatus = new Thread(simStatus);
Thread threadStatus = new Thread(simMPStatus);
Thread threadCount = new Thread(simCountersRaw);
Thread threadAlarms = new Thread(simAlarms);
Thread threadParams = new Thread(simParameters);
Thread threadProd = new Thread(simProd);
Thread threadMachStat = new Thread(simMachStat);
Thread threadMaint = new Thread(simMaint);
Thread threadTools = new Thread(simTools);
Thread threadEvHistory = new Thread(simEvents);
@@ -88,7 +88,7 @@ threadStatus.Start();
threadAlarms.Start();
threadParams.Start();
threadProd.Start();
threadMachStat.Start();
threadCount.Start();
threadMaint.Start();
threadTools.Start();
threadEvHistory.Start();
@@ -346,13 +346,13 @@ void simParameters()
}
}
void simStatus()
void simMPStatus()
{
int minPeriod = 1000;
int maxPeriod = 5000;
// controllo se devo fare (se ho valori da simulare...)
if (currSimGen.currSimStatus.Count > 0)
if (currSimGen.currSimMachStat.Count > 0)
{
do
{
@@ -367,6 +367,27 @@ void simStatus()
}
}
void simCountersRaw()
{
int minPeriod = 1000;
int maxPeriod = 5000;
// controllo se devo fare (se ho valori da simulare...)
if (currSimGen.currSimMachStat.Count > 0)
{
do
{
// recupero uno stato simulato
var newStatus = currSimGen.getCountersRaw();
string rawData = JsonConvert.SerializeObject(newStatus);
saveAndSendMessage(Constants.COUNT_CURR_KEY, Constants.COUNT_RAW_QUEUE, rawData);
// attesa random
Thread.Sleep(rand.Next(minPeriod, maxPeriod));
} while (true);
}
}
void simProd()
{
int minPeriod = 3000;
@@ -388,27 +409,6 @@ void simProd()
}
}
void simMachStat()
{
int minPeriod = 5000;
int maxPeriod = 15000;
// controllo se devo fare (se ho valori da simulare...)
if (currSimGen.currSimMachStat.Count > 0)
{
do
{
// recupero uno stato simulato
var newVal = currSimGen.getProdStats();
string rawData = JsonConvert.SerializeObject(newVal);
saveAndSendMessage(Constants.MACH_STATS_CURR_KEY, Constants.MACH_STATS_M_QUEUE, rawData);
// attesa random
Thread.Sleep(rand.Next(minPeriod, maxPeriod));
} while (true);
}
}
void simMaint()
{