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
+16 -16
View File
@@ -3,7 +3,7 @@
"Order": 0,
"ExtCode": "ns=1;s=5_1_TOOL 1 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 01",
"Title": "SPINDLE 1 TOOL 01",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -15,7 +15,7 @@
"Order": 1,
"ExtCode": "ns=1;s=5_2_TOOL 2 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 02",
"Title": "SPINDLE 1 TOOL 02",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -27,7 +27,7 @@
"Order": 2,
"ExtCode": "ns=1;s=5_3_TOOL 3 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 03",
"Title": "SPINDLE 1 TOOL 03",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -39,7 +39,7 @@
"Order": 3,
"ExtCode": "ns=1;s=5_4_TOOL 4 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 04",
"Title": "SPINDLE 1 TOOL 04",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -51,7 +51,7 @@
"Order": 4,
"ExtCode": "ns=1;s=5_5_TOOL 11 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 05",
"Title": "SPINDLE 2 TOOL 01",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -63,7 +63,7 @@
"Order": 5,
"ExtCode": "ns=1;s=5_6_TOOL 12 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 06",
"Title": "SPINDLE 2 TOOL 02",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -75,7 +75,7 @@
"Order": 6,
"ExtCode": "ns=1;s=5_7_TOOL 13 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 07",
"Title": "SPINDLE 2 TOOL 03",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -87,7 +87,7 @@
"Order": 7,
"ExtCode": "ns=1;s=5_8_TOOL 14 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 08",
"Title": "SPINDLE 2 TOOL 04",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -99,7 +99,7 @@
"Order": 8,
"ExtCode": "ns=1;s=5_9_TOOL 21 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 09",
"Title": "SPINDLE 3 TOOL 01",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -111,7 +111,7 @@
"Order": 9,
"ExtCode": "ns=1;s=5_10_TOOL 22 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 10",
"Title": "SPINDLE 3 TOOL 2",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -123,7 +123,7 @@
"Order": 10,
"ExtCode": "ns=1;s=5_11_TOOL 23 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 11",
"Title": "SPINDLE 3 TOOL 3",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -135,7 +135,7 @@
"Order": 11,
"ExtCode": "ns=1;s=5_12_TOOL 24 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 12",
"Title": "SPINDLE 3 TOOL 4",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -147,7 +147,7 @@
"Order": 12,
"ExtCode": "ns=1;s=5_13_TOOL 31 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 13",
"Title": "SPINDLE 4 TOOL 1",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -159,7 +159,7 @@
"Order": 13,
"ExtCode": "ns=1;s=5_14_TOOL 32 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 14",
"Title": "SPINDLE 4 TOOL 2",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -171,7 +171,7 @@
"Order": 14,
"ExtCode": "ns=1;s=5_15_TOOL 33 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 15",
"Title": "SPINDLE 4 TOOL 3",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
@@ -183,7 +183,7 @@
"Order": 15,
"ExtCode": "ns=1;s=5_16_TOOL 34 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 16",
"Title": "SPINDLE 4 TOOL 4",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
+32 -32
View File
@@ -3,192 +3,192 @@
"Order": 0,
"ExtCode": "ns=1;s=5_1_TOOL 1 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 01",
"Title": "SPINDLE 1 TOOL 01",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 1,
"ExtCode": "ns=1;s=5_2_TOOL 2 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 02",
"Title": "SPINDLE 1 TOOL 02",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 2,
"ExtCode": "ns=1;s=5_3_TOOL 3 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 03",
"Title": "SPINDLE 1 TOOL 03",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 3,
"ExtCode": "ns=1;s=5_4_TOOL 4 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 04",
"Title": "SPINDLE 1 TOOL 04",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 4,
"ExtCode": "ns=1;s=5_5_TOOL 11 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 05",
"Title": "SPINDLE 2 TOOL 01",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 5,
"ExtCode": "ns=1;s=5_6_TOOL 12 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 06",
"Title": "SPINDLE 2 TOOL 02",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 6,
"ExtCode": "ns=1;s=5_7_TOOL 13 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 07",
"Title": "SPINDLE 2 TOOL 03",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 7,
"ExtCode": "ns=1;s=5_8_TOOL 14 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 08",
"Title": "SPINDLE 2 TOOL 04",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 8,
"ExtCode": "ns=1;s=5_9_TOOL 21 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 09",
"Title": "SPINDLE 3 TOOL 01",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 9,
"ExtCode": "ns=1;s=5_10_TOOL 22 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 10",
"Title": "SPINDLE 3 TOOL 2",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 10,
"ExtCode": "ns=1;s=5_11_TOOL 23 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 11",
"Title": "SPINDLE 3 TOOL 3",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 11,
"ExtCode": "ns=1;s=5_12_TOOL 24 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 12",
"Title": "SPINDLE 3 TOOL 4",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 12,
"ExtCode": "ns=1;s=5_13_TOOL 31 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 13",
"Title": "SPINDLE 4 TOOL 1",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 13,
"ExtCode": "ns=1;s=5_14_TOOL 32 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 14",
"Title": "SPINDLE 4 TOOL 2",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 14,
"ExtCode": "ns=1;s=5_15_TOOL 33 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 15",
"Title": "SPINDLE 4 TOOL 3",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
},
{
"Order": 15,
"ExtCode": "ns=1;s=5_16_TOOL 34 CURRENT LIFE PC",
"Type": "TOOL",
"Title": "TOOL 16",
"Title": "SPINDLE 4 TOOL 4",
"Value": "0",
"ValueNum": 0,
"MinVal": -9999,
"MaxVal": 9999,
"DisplFormat": "N2",
"DisplFormat": "N1",
"IsNumeric": true
}
]
+3 -3
View File
@@ -63,15 +63,15 @@
<None Update="conf\SimActLog.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="conf\SimCountersRaw.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="conf\SimMachStat.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="conf\SimEvHist.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="conf\SimStatus.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="conf\SimTools.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+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()
{
+98 -16
View File
@@ -13,12 +13,12 @@ namespace MachineSim
public List<SimDisplayDataDTO> currSimActLog = new List<SimDisplayDataDTO>();
public List<SimDisplayDataDTO> currSimEvHist = new List<SimDisplayDataDTO>();
public List<SimDisplayDataDTO> currSimMachStat = new List<SimDisplayDataDTO>();
public List<SimDisplayDataDTO> currSimMaint = new List<SimDisplayDataDTO>();
public List<SimDisplayDataDTO> currSimPar = new List<SimDisplayDataDTO>();
public List<SimDisplayDataDTO> currSimProd = new List<SimDisplayDataDTO>();
public List<SimDisplayDataDTO> currSimStatus = new List<SimDisplayDataDTO>();
public List<SimDisplayDataDTO> currSimTools = new List<SimDisplayDataDTO>();
public List<string> currCountersRaw = new List<string>();
public List<string> currSimMachStat = new List<string>();
#endregion Public Fields
@@ -183,6 +183,7 @@ namespace MachineSim
return currMachDto;
}
#if false
public List<DisplayDataDTO> getProdStats()
{
List<DisplayDataDTO> answ = new List<DisplayDataDTO>();
@@ -207,7 +208,8 @@ namespace MachineSim
}
return answ;
}
}
#endif
/// <summary>
/// Restituisce elenco info stato Macchina simulato come lista da adapter
@@ -216,9 +218,6 @@ namespace MachineSim
public Dictionary<string, string> getStatus()
{
Dictionary<string, string> answ = new Dictionary<string, string>();
int maxRun = 7;
int maxExe = 7;
// simulo stato macchina ad 1 nel 99.5% (0 nel 0.5% dei casi
if (rand.Next(0, 1000) < 995)
{
@@ -248,6 +247,72 @@ namespace MachineSim
answ.Add("PROCESS STATUS", "3");
answ.Add("PROCESS MODE", "7");
}
// aggiunta part program che cambia ogni minuto...
answ.Add("RECIPE NAME", $"{DateTime.Now:yyMMdd-HHmm}.prg");
return answ;
}
/// <summary>
/// Restituisce elenco info dati x contatori come lista da adapter
/// </summary>
/// <returns></returns>
public Dictionary<string, string> getCountersRaw()
{
Dictionary<string, string> answ = new Dictionary<string, string>();
// simulo stato macchina ad 1 nel 99.5% (0 nel 0.5% dei casi
if (rand.Next(0, 1000) < 995)
{
answ.Add("MACHINE STATUS", "1");
}
else
{
answ.Add("MACHINE STATUS", "1");
}
// simulo stato processo in ciclo 90% dei casi, resto HOLD
if (rand.Next(0, 1000) < 900)
{
answ.Add("PROCESS STATUS", "2");
// simulo modo auto 90% dei casi
if (rand.Next(0, 1000) < 900)
{
answ.Add("PROCESS MODE", "2");
// aggiungo spindle load che sono attivi 50% del tempo ogni coppia, random
if (rand.Next(0, 1000) < 500)
{
answ.Add("SPINDLE 1 LOAD", $"{rand.Next(5, 80)}");
answ.Add("SPINDLE 2 LOAD", $"{rand.Next(5, 80)}");
answ.Add("SPINDLE 3 LOAD", $"{rand.Next(5, 80)}");
answ.Add("SPINDLE 4 LOAD", $"{rand.Next(5, 80)}");
}
else
{
answ.Add("SPINDLE 1 LOAD", "0");
answ.Add("SPINDLE 2 LOAD", "0");
answ.Add("SPINDLE 3 LOAD", "0");
answ.Add("SPINDLE 4 LOAD", "0");
}
}
else
{
answ.Add("PROCESS MODE", "1");
answ.Add("SPINDLE 1 LOAD", "0");
answ.Add("SPINDLE 2 LOAD", "0");
answ.Add("SPINDLE 3 LOAD", "0");
answ.Add("SPINDLE 4 LOAD", "0");
}
}
else
{
answ.Add("PROCESS STATUS", "3");
answ.Add("PROCESS MODE", "7");
answ.Add("SPINDLE 1 LOAD", "0");
answ.Add("SPINDLE 2 LOAD", "0");
answ.Add("SPINDLE 3 LOAD", "0");
answ.Add("SPINDLE 4 LOAD", "0");
}
return answ;
}
@@ -354,7 +419,7 @@ namespace MachineSim
#region Private Methods
private void setupConf(string paramFileName, ref List<SimDisplayDataDTO> localObj)
private void setupConfDTO(string paramFileName, ref List<SimDisplayDataDTO> localObj)
{
string fullPath = Path.Combine(basePath, paramFileName);
if (File.Exists(fullPath))
@@ -371,24 +436,41 @@ namespace MachineSim
}
}
private void setupConfList(string paramFileName, ref List<string> localObj)
{
string fullPath = Path.Combine(basePath, paramFileName);
if (File.Exists(fullPath))
{
var rawData = File.ReadAllText(fullPath);
if (!string.IsNullOrEmpty(rawData))
{
var deserObj = JsonConvert.DeserializeObject<List<String>>(rawData);
if (deserObj != null)
{
localObj = deserObj;
}
}
}
}
private void setupConfig()
{
// setup conf Parametri
setupConf("SimParams.json", ref currSimPar);
// setup conf MachStat
setupConf("SimMachStat.json", ref currSimMachStat);
setupConfDTO("SimParams.json", ref currSimPar);
// setup conf Maintenance
setupConf("SimMaint.json", ref currSimMaint);
setupConfDTO("SimMaint.json", ref currSimMaint);
// setup conf Tools
setupConf("SimTools.json", ref currSimTools);
setupConfDTO("SimTools.json", ref currSimTools);
// setup conf Event History
setupConf("SimEvHist.json", ref currSimEvHist);
setupConfDTO("SimEvHist.json", ref currSimEvHist);
// setup conf Activity Log
setupConf("SimActLog.json", ref currSimActLog);
setupConfDTO("SimActLog.json", ref currSimActLog);
// setup conf Prod
setupConf("SimProd.json", ref currSimProd);
setupConfDTO("SimProd.json", ref currSimProd);
// setup conf MachStat
setupConfList("SimMachStat.json", ref currSimMachStat);
// setup conf Prod
setupConf("SimStatus.json", ref currSimStatus);
setupConfList("SimStatus.json", ref currCountersRaw);
}
#endregion Private Methods
+9
View File
@@ -0,0 +1,9 @@
[
"MACHINE STATUS",
"PROCESS STATUS",
"PROCESS MODE",
"SPINDLE 1 LOAD",
"SPINDLE 2 LOAD",
"SPINDLE 3 LOAD",
"SPINDLE 4 LOAD"
]
+4 -12
View File
@@ -1,14 +1,6 @@
[
{
"Order": 0,
"Type": "OEE-75-90",
"Title": "OEE",
"Value": "0.5",
"ValueNum": 0.5,
"MinVal": 0.4,
"MaxVal": 1,
"SimMean": 0.2,
"SimStd": 0.2,
"DisplFormat": "P1"
}
"MACHINE STATUS",
"PROCESS STATUS",
"PROCESS MODE",
"RECIPE NAME"
]
-14
View File
@@ -1,14 +0,0 @@
[
{
"Order": 0,
"Type": "POS",
"Title": "Z POS",
"Value": "-500",
"ValueNum": -500,
"MinVal": -3000,
"MaxVal": 0,
"SimMean": 50,
"SimStd": 5,
"DisplFormat": "N2"
}
]