Reorg simula...
This commit is contained in:
+174
-162
@@ -86,6 +86,8 @@ namespace IOB_WIN
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Ora spegniemnto (standard)
|
||||
/// </summary>
|
||||
@@ -96,6 +98,10 @@ namespace IOB_WIN
|
||||
/// </summary>
|
||||
public int tOn = 6;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// estende l'init della classe base...
|
||||
/// </summary>
|
||||
@@ -145,167 +151,9 @@ namespace IOB_WIN
|
||||
lgInfo($"Impostazione iniziale contatori: contapezzi macchina contapezziPLC: {contapezziPLC} | contapezziIOB: {contapezziIOB}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua reset del contapezzi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool resetcontapezziPLC()
|
||||
{
|
||||
bool answ = false;
|
||||
// ...SE abilitato da conf IOB
|
||||
if (cIobConf.optPar.Count > 0 && getOptPar("ENABLE_PZ_RESET") == "TRUE")
|
||||
{
|
||||
// fingo di aver fatto...
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endregion Public Constructors
|
||||
|
||||
public override void tryConnect()
|
||||
{
|
||||
base.tryConnect();
|
||||
connectionOk = true;
|
||||
}
|
||||
|
||||
public override void tryDisconnect()
|
||||
{
|
||||
base.tryDisconnect();
|
||||
connectionOk = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setup aprametri di simulazione per BIT indicato
|
||||
/// </summary>
|
||||
/// <param name="keyName"></param>
|
||||
private simPar setupSimPar(string keyName)
|
||||
{
|
||||
simPar answ = new simPar();
|
||||
if (cIobConf.optPar.Count > 0)
|
||||
{
|
||||
if (cIobConf.optPar.ContainsKey(keyName))
|
||||
{
|
||||
string fullVal = getOptPar(keyName);
|
||||
if (!string.IsNullOrEmpty(fullVal) && fullVal.IndexOf("|") > 0)
|
||||
{
|
||||
string[] param = fullVal.Split('|');
|
||||
int.TryParse(param[0], out answ.wait);
|
||||
int.TryParse(param[1], out answ.duration);
|
||||
// aggiongo noise, +/- 40%...
|
||||
Random rnd = new Random();
|
||||
int noise = rnd.Next(1, answ.wait * 40 / 100);
|
||||
answ.wait += noise - (answ.wait * 20 / 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#region Metodi specifici (da verificare/completare in implementazione)
|
||||
|
||||
/// <summary>
|
||||
/// Recupera e processa allarmi CNC...
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> getCncAlarms()
|
||||
{
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dati dinamici...
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> getDynData()
|
||||
{
|
||||
// valore non presente in vers default... se gestito fare override
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
// verificare periodo SIM parametri... se passato li invio altrimenti NO... FIX a 20 sec
|
||||
if (lastSimData.AddSeconds(waitSimPar) < DateTime.Now)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
// controllo conf memorie json (se ci sono...)
|
||||
try
|
||||
{
|
||||
if (memMap.mMapWrite.Count > 0)
|
||||
{
|
||||
foreach (var item in memMap.mMapWrite)
|
||||
{
|
||||
outVal.Add(item.Key, item.Value.value);
|
||||
}
|
||||
}
|
||||
if (memMap.mMapRead.Count > 0)
|
||||
{
|
||||
foreach (var item in memMap.mMapRead)
|
||||
{
|
||||
// uso factor come valore MAX ammesso
|
||||
int randVal = rnd.Next(item.Value.minVal, item.Value.maxVal);
|
||||
outVal.Add(item.Key, randVal.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
lastSimData = DateTime.Now;
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero programma in lavorazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string getPrgName()
|
||||
{
|
||||
// valore non presente in vers default... se gestito fare override
|
||||
string prgName = string.Format("DEMO_{0:00}", DateTime.Now.Minute);
|
||||
return prgName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero info sistema generiche
|
||||
/// <returns></returns>
|
||||
public override Dictionary<string, string> getSysInfo()
|
||||
{
|
||||
// valore non presente in vers default... se gestito fare override
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
outVal.Add("MACHINE", "IOB_SIM");
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processo contatori eventi...
|
||||
/// </summary>
|
||||
public override void processVHF()
|
||||
{
|
||||
if (lastEvCheck.AddMilliseconds(periodoMSec) < DateTime.Now)
|
||||
{
|
||||
// decremento contatore ultimo evento
|
||||
bit2.wait--;
|
||||
bit3.wait--;
|
||||
bit4.wait--;
|
||||
bit5.wait--;
|
||||
lastEvCheck = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua lettura semafori principale
|
||||
/// <paramref name="currDispData">Parametri da aggiornare x display in form</paramref>
|
||||
/// </summary>
|
||||
public override void readSemafori(ref newDisplayData currDispData)
|
||||
{
|
||||
base.readSemafori(ref currDispData);
|
||||
// decodifica e gestione
|
||||
decodeToBaseBitmap();
|
||||
decodeOtherData();
|
||||
reportRawInput(ref currDispData);
|
||||
}
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Decodifica il resto dell'area x i dati accessori (allarmi, ...)
|
||||
@@ -601,7 +449,34 @@ namespace IOB_WIN
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// provo a chaimare split ODL
|
||||
/// Setup aprametri di simulazione per BIT indicato
|
||||
/// </summary>
|
||||
/// <param name="keyName"></param>
|
||||
private simPar setupSimPar(string keyName)
|
||||
{
|
||||
simPar answ = new simPar();
|
||||
if (cIobConf.optPar.Count > 0)
|
||||
{
|
||||
if (cIobConf.optPar.ContainsKey(keyName))
|
||||
{
|
||||
string fullVal = getOptPar(keyName);
|
||||
if (!string.IsNullOrEmpty(fullVal) && fullVal.IndexOf("|") > 0)
|
||||
{
|
||||
string[] param = fullVal.Split('|');
|
||||
int.TryParse(param[0], out answ.wait);
|
||||
int.TryParse(param[1], out answ.duration);
|
||||
// aggiongo noise, +/- 40%...
|
||||
Random rnd = new Random();
|
||||
int noise = rnd.Next(1, answ.wait * 40 / 100);
|
||||
answ.wait += noise - (answ.wait * 20 / 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// provo a chiamare split ODL
|
||||
/// </summary>
|
||||
private void trySplitOdl()
|
||||
{
|
||||
@@ -619,7 +494,144 @@ namespace IOB_WIN
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Metodi specifici (da verificare/completare in implementazione)
|
||||
#endregion Private Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupera e processa allarmi CNC...
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> getCncAlarms()
|
||||
{
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dati dinamici...
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> getDynData()
|
||||
{
|
||||
// valore non presente in vers default... se gestito fare override
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
// verificare periodo SIM parametri... se passato li invio altrimenti NO... FIX a 20 sec
|
||||
if (lastSimData.AddSeconds(waitSimPar) < DateTime.Now)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
// controllo conf memorie json (se ci sono...)
|
||||
try
|
||||
{
|
||||
if (memMap.mMapWrite.Count > 0)
|
||||
{
|
||||
foreach (var item in memMap.mMapWrite)
|
||||
{
|
||||
outVal.Add(item.Key, item.Value.value);
|
||||
}
|
||||
}
|
||||
if (memMap.mMapRead.Count > 0)
|
||||
{
|
||||
foreach (var item in memMap.mMapRead)
|
||||
{
|
||||
// uso factor come valore MAX ammesso
|
||||
int randVal = rnd.Next(item.Value.minVal, item.Value.maxVal);
|
||||
outVal.Add(item.Key, randVal.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
lastSimData = DateTime.Now;
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero programma in lavorazione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string getPrgName()
|
||||
{
|
||||
// valore non presente in vers default... se gestito fare override
|
||||
string prgName = string.Format("DEMO_{0:00}", DateTime.Now.Minute);
|
||||
return prgName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero info sistema generiche
|
||||
/// <returns></returns>
|
||||
public override Dictionary<string, string> getSysInfo()
|
||||
{
|
||||
// valore non presente in vers default... se gestito fare override
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
outVal.Add("MACHINE", "IOB_SIM");
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processo contatori eventi...
|
||||
/// </summary>
|
||||
public override void processVHF()
|
||||
{
|
||||
if (lastEvCheck.AddMilliseconds(periodoMSec) < DateTime.Now)
|
||||
{
|
||||
// decremento contatore ultimo evento
|
||||
bit2.wait--;
|
||||
bit3.wait--;
|
||||
bit4.wait--;
|
||||
bit5.wait--;
|
||||
lastEvCheck = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua lettura semafori principale
|
||||
/// <paramref name="currDispData">Parametri da aggiornare x display in form</paramref>
|
||||
/// </summary>
|
||||
public override void readSemafori(ref newDisplayData currDispData)
|
||||
{
|
||||
base.readSemafori(ref currDispData);
|
||||
// decodifica e gestione
|
||||
decodeToBaseBitmap();
|
||||
decodeOtherData();
|
||||
reportRawInput(ref currDispData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua reset del contapezzi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool resetcontapezziPLC()
|
||||
{
|
||||
bool answ = false;
|
||||
// ...SE abilitato da conf IOB
|
||||
if (cIobConf.optPar.Count > 0 && getOptPar("ENABLE_PZ_RESET") == "TRUE")
|
||||
{
|
||||
// fingo di aver fatto...
|
||||
answ = true;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public override void tryConnect()
|
||||
{
|
||||
base.tryConnect();
|
||||
connectionOk = true;
|
||||
}
|
||||
|
||||
public override void tryDisconnect()
|
||||
{
|
||||
base.tryDisconnect();
|
||||
connectionOk = false;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user