Cambio Namespace progetto NEXT
This commit is contained in:
Generated
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
partial class AdapterForm
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public partial class AdapterForm : Form
|
||||
{
|
||||
|
||||
+19
-17
@@ -3,21 +3,23 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public enum StartMode
|
||||
{
|
||||
/// <summary>
|
||||
/// modalità standard (standalone, multi IOB)
|
||||
/// </summary>
|
||||
STD = 0,
|
||||
/// <summary>
|
||||
/// Modalità managed (da IOB-MAN)
|
||||
/// </summary>
|
||||
MAN = 1,
|
||||
/// <summary>
|
||||
/// Modalità update (per aggiornare IOB-WIN) senza IOB
|
||||
/// </summary>
|
||||
UPD = 2
|
||||
}
|
||||
}
|
||||
public enum StartMode
|
||||
{
|
||||
/// <summary>
|
||||
/// modalità standard (standalone, multi IOB)
|
||||
/// </summary>
|
||||
STD = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Modalità managed (da IOB-MAN)
|
||||
/// </summary>
|
||||
MAN = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Modalità update (per aggiornare IOB-WIN) senza IOB
|
||||
/// </summary>
|
||||
UPD = 2
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// This Configuration class is basically just a set of
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobFanuc : IobGeneric
|
||||
{
|
||||
|
||||
+36
-32
@@ -12,7 +12,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Generica classe per implementare IOB basato su scambio FILE
|
||||
@@ -58,6 +58,39 @@ namespace IOB_WIN
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Processo stati unknown...
|
||||
/// </summary>
|
||||
/// <param name="cKey"></param>
|
||||
private void processUnknStatus(string cKey)
|
||||
{
|
||||
// cerco se avevo già una key nella dictionary...
|
||||
if (freqUnknStatus.ContainsKey(cKey))
|
||||
{
|
||||
freqUnknStatus[cKey]++;
|
||||
// se è 1 ogni 100 (%100, resto ==1) --> loggo...
|
||||
if (freqUnknStatus[cKey] % 100 == 1)
|
||||
{
|
||||
lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey} | freq: {freqUnknStatus[cKey]}");
|
||||
// accodo come invio di tipo FLOG...
|
||||
string sVal = string.Format("[UnknStatus] {0}, freq: {1}", cKey, freqUnknStatus);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog("UnknStatus", sVal));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// creo chiave con freq = 1
|
||||
freqUnknStatus.Add(cKey, 1);
|
||||
// log iniziale
|
||||
lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -114,36 +147,7 @@ namespace IOB_WIN
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Metodi specifici (da verificare/completare in implementazione)
|
||||
|
||||
/// <summary>
|
||||
/// Processo stati unknown...
|
||||
/// </summary>
|
||||
/// <param name="cKey"></param>
|
||||
private void processUnknStatus(string cKey)
|
||||
{
|
||||
// cerco se avevo già una key nella dictionary...
|
||||
if (freqUnknStatus.ContainsKey(cKey))
|
||||
{
|
||||
freqUnknStatus[cKey]++;
|
||||
// se è 1 ogni 100 (%100, resto ==1) --> loggo...
|
||||
if (freqUnknStatus[cKey] % 100 == 1)
|
||||
{
|
||||
lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey} | freq: {freqUnknStatus[cKey]}");
|
||||
// accodo come invio di tipo FLOG...
|
||||
string sVal = string.Format("[UnknStatus] {0}, freq: {1}", cKey, freqUnknStatus);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog("UnknStatus", sVal));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// creo chiave con freq = 1
|
||||
freqUnknStatus.Add(cKey, 1);
|
||||
// log iniziale
|
||||
lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey}");
|
||||
}
|
||||
}
|
||||
#region Public Methods
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
@@ -352,6 +356,6 @@ namespace IOB_WIN
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Metodi specifici (da verificare/completare in implementazione)
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobFileEurom63 : IobFile
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobGeneric
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobKawasaki : IobGeneric
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ using System.Windows.Forms;
|
||||
using MTConnectDevices = MTConnect.MTConnectDevices;
|
||||
using MTConnectStreams = MTConnect.MTConnectStreams;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobMTC : IobGeneric
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using CVCncLib;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobOSAI : IobGeneric
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobOmron : IobGeneric
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobSiemens : IobGeneric, IDisposable
|
||||
{
|
||||
|
||||
+197
-191
@@ -4,211 +4,217 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Controllo Siemens specifico x impianti Aprochim /MacDermid
|
||||
/// </summary>
|
||||
public class IobSiemensAprochim : IobSiemens
|
||||
{
|
||||
/* --------------------------------------------------------------------------------
|
||||
* Controlli SIEMENS Aprochim (impianti filtrazione in Jetco, gruppo macDermid)
|
||||
* - basasto su SIEMENS
|
||||
* - S7 vers 1500
|
||||
*
|
||||
* STRUTTURA MEMORIA DB60:
|
||||
* - parametri processo
|
||||
* - DB60.DBD6: pressione camera filtrante (salvataggio del MAX ogni minuto) | var testVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(0).Take(4).ToArray());
|
||||
* - DB60.DBD10: pressione linea utenze (salvataggio del MAX ogni minuto)
|
||||
* - DB60.DBD14: temperatura acqua pulita (salvataggio del MAX ogni minuto)
|
||||
*
|
||||
* - BIT di stato
|
||||
* - DB60.DBX3.0: AUSILIARI INSERITI = NO EMERGENZA
|
||||
* - DB60.DBX3.1: Filtro (macchina) in LAVORAZIONE
|
||||
* - DB60.DBX3.2: Selettore in AUTOMATICO (sennò GIALLO)
|
||||
* - DB60.DBX3.3: WARNING MIN LIV VASCA (arancio)
|
||||
* - DB60.DBX3.4: WARNING MIN LIV CELLULOSA (blu)
|
||||
* - DB60.DBX3.5: LAMPADA ROSSA (allarmi almeno 1 attivo)
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
/// <summary>
|
||||
/// Classe base con i metodi x Siemens
|
||||
/// Controllo Siemens specifico x impianti Aprochim /MacDermid
|
||||
/// </summary>
|
||||
/// <param name="caller"></param>
|
||||
/// <param name="adpConf"></param>
|
||||
public IobSiemensAprochim(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
|
||||
public class IobSiemensAprochim : IobSiemens
|
||||
{
|
||||
lgInfo("NEW IOB SIEMENS versione APROCHIM");
|
||||
// imposto i parametri speciali x calcolo...
|
||||
var chiaviTSVC = findOptPar("TSVC");
|
||||
if (chiaviTSVC.Count > 0)
|
||||
{
|
||||
lgInfo($"Trovate {chiaviTSVC.Count} chiavi TSVC");
|
||||
string[] codVal;
|
||||
VCData currConf;
|
||||
int periodo = 0;
|
||||
VC_func funz = VC_func.POINT;
|
||||
// accodo nella conf...
|
||||
foreach (var item in chiaviTSVC)
|
||||
/* --------------------------------------------------------------------------------
|
||||
* Controlli SIEMENS Aprochim (impianti filtrazione in Jetco, gruppo macDermid)
|
||||
* - basasto su SIEMENS
|
||||
* - S7 vers 1500
|
||||
*
|
||||
* STRUTTURA MEMORIA DB60:
|
||||
* - parametri processo
|
||||
* - DB60.DBD6: pressione camera filtrante (salvataggio del MAX ogni minuto) | var testVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(0).Take(4).ToArray());
|
||||
* - DB60.DBD10: pressione linea utenze (salvataggio del MAX ogni minuto)
|
||||
* - DB60.DBD14: temperatura acqua pulita (salvataggio del MAX ogni minuto)
|
||||
*
|
||||
* - BIT di stato
|
||||
* - DB60.DBX3.0: AUSILIARI INSERITI = NO EMERGENZA
|
||||
* - DB60.DBX3.1: Filtro (macchina) in LAVORAZIONE
|
||||
* - DB60.DBX3.2: Selettore in AUTOMATICO (sennò GIALLO)
|
||||
* - DB60.DBX3.3: WARNING MIN LIV VASCA (arancio)
|
||||
* - DB60.DBX3.4: WARNING MIN LIV CELLULOSA (blu)
|
||||
* - DB60.DBX3.5: LAMPADA ROSSA (allarmi almeno 1 attivo)
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Classe base con i metodi x Siemens
|
||||
/// </summary>
|
||||
/// <param name="caller"></param>
|
||||
/// <param name="adpConf"></param>
|
||||
public IobSiemensAprochim(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
|
||||
{
|
||||
codVal = item.Value.Split(':');
|
||||
Enum.TryParse(codVal[0], out funz);
|
||||
int.TryParse(codVal[1], out periodo);
|
||||
currConf = new VCData()
|
||||
{
|
||||
Funzione = funz,
|
||||
Period = periodo,
|
||||
DTStart = DateTime.Now.AddHours(-1),
|
||||
dataArray = new List<double>()
|
||||
};
|
||||
TSVC_Data.Add(item.Key.Replace("TSVC_", ""), currConf);
|
||||
lgInfo("NEW IOB SIEMENS versione APROCHIM");
|
||||
// imposto i parametri speciali x calcolo...
|
||||
var chiaviTSVC = findOptPar("TSVC");
|
||||
if (chiaviTSVC.Count > 0)
|
||||
{
|
||||
lgInfo($"Trovate {chiaviTSVC.Count} chiavi TSVC");
|
||||
string[] codVal;
|
||||
VCData currConf;
|
||||
int periodo = 0;
|
||||
VC_func funz = VC_func.POINT;
|
||||
// accodo nella conf...
|
||||
foreach (var item in chiaviTSVC)
|
||||
{
|
||||
codVal = item.Value.Split(':');
|
||||
Enum.TryParse(codVal[0], out funz);
|
||||
int.TryParse(codVal[1], out periodo);
|
||||
currConf = new VCData()
|
||||
{
|
||||
Funzione = funz,
|
||||
Period = periodo,
|
||||
DTStart = DateTime.Now.AddHours(-1),
|
||||
dataArray = new List<double>()
|
||||
};
|
||||
TSVC_Data.Add(item.Key.Replace("TSVC_", ""), currConf);
|
||||
}
|
||||
// documento...
|
||||
foreach (var item in TSVC_Data)
|
||||
{
|
||||
lgInfo($"TSVC: {item.Key} | periodo: {item.Value.Period} | funz: {item.Value.Funzione}");
|
||||
// salvo i valori PREC...
|
||||
LastTSVC.Add(item.Key, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
// documento...
|
||||
foreach (var item in TSVC_Data)
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// </summary>
|
||||
protected override void decodeToBaseBitmap()
|
||||
{
|
||||
lgInfo($"TSVC: {item.Key} | periodo: {item.Value.Period} | funz: {item.Value.Funzione}");
|
||||
// salvo i valori PREC...
|
||||
LastTSVC.Add(item.Key, 0);
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* bitmap MAPO STANDARD
|
||||
* B0: POWER_ON
|
||||
* B1: RUN
|
||||
* B2: pzCount
|
||||
* B3: allarme
|
||||
* B4: manuale
|
||||
* B5: emergenza
|
||||
*
|
||||
*
|
||||
* - BIT di stato
|
||||
* - DB60.DBX3.0: AUSILIARI INSERITI = NO EMERGENZA
|
||||
* - DB60.DBX3.1: Filtro (macchina) in LAVORAZIONE
|
||||
* - DB60.DBX3.2: Selettore in AUTOMATICO (sennò GIALLO)
|
||||
* - DB60.DBX3.3: WARNING MIN LIV VASCA (arancio)
|
||||
* - DB60.DBX3.4: WARNING MIN LIV CELLULOSA (blu)
|
||||
* - DB60.DBX3.5: LAMPADA ROSSA (allarmi almeno 1 attivo)
|
||||
----------------------------------------------------- */
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* bitmap MAPO FILTRO Aprochim
|
||||
* B0: POWER_ON
|
||||
* B1: RUN
|
||||
* B2: AUTOMATICO
|
||||
* B3: WARN_MIN_VASCA
|
||||
* B4: WARN_MIN_CELL
|
||||
* B5: ALARM
|
||||
* B6: EMERGENZA
|
||||
----------------------------------------------------- */
|
||||
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
B_input = currPLC.IsConnected ? 1 : 0;
|
||||
|
||||
// recupero byte segnali...
|
||||
int byteSignals = RawInput[3];
|
||||
// aggiungo "in coda" primo bit emergenza...essendo un bit negato (NON emergenza) lo cambio di segno
|
||||
if ((byteSignals & (1 << 0)) == 0)
|
||||
{
|
||||
byteSignals += (1 << 6);
|
||||
}
|
||||
// cancello primo bit (faccio uno shift a dx e poi a sx di 1...)
|
||||
byteSignals = ((byteSignals >> 1) << 1);
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[3]} --> B_input: {B_input}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Metodi specifici (da verificare/completare in implementazione)
|
||||
#endregion Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid)
|
||||
/// </summary>
|
||||
public override void processOverride()
|
||||
{
|
||||
}
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dati dinamici in formato dictionary
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Dictionary<string, string> getDynData()
|
||||
{
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
try
|
||||
{
|
||||
/* ----------------------------------------------------------
|
||||
* DB60.DBD6: pressione camera filtrante (salvataggio del MAX ogni minuto) | var testVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(0).Take(4).ToArray());
|
||||
* DB60.DBD10: pressione linea utenze (salvataggio del MAX ogni minuto)
|
||||
* DB60.DBD14: temperatura acqua pulita (salvataggio del MAX ogni minuto)
|
||||
* */
|
||||
double pressCamFilt = S7.Net.Types.Double.FromByteArray(RawInput.Skip(6).Take(4).ToArray());
|
||||
double pressLinUt = S7.Net.Types.Double.FromByteArray(RawInput.Skip(10).Take(4).ToArray());
|
||||
double tempH2O = S7.Net.Types.Double.FromByteArray(RawInput.Skip(14).Take(4).ToArray());
|
||||
|
||||
if (utils.CRB("enableTSVC"))
|
||||
/// <summary>
|
||||
/// Recupero dati dinamici in formato dictionary
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Dictionary<string, string> getDynData()
|
||||
{
|
||||
// salvo in stack le VC rilevate
|
||||
bool scad01 = stackVal_TSVC("pressCamFilt", pressCamFilt);
|
||||
bool scad02 = stackVal_TSVC("pressLinUt", pressLinUt);
|
||||
bool scad03 = stackVal_TSVC("tempH2O", tempH2O);
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
try
|
||||
{
|
||||
/* ----------------------------------------------------------
|
||||
* DB60.DBD6: pressione camera filtrante (salvataggio del MAX ogni minuto) | var testVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(0).Take(4).ToArray());
|
||||
* DB60.DBD10: pressione linea utenze (salvataggio del MAX ogni minuto)
|
||||
* DB60.DBD14: temperatura acqua pulita (salvataggio del MAX ogni minuto)
|
||||
* */
|
||||
double pressCamFilt = S7.Net.Types.Double.FromByteArray(RawInput.Skip(6).Take(4).ToArray());
|
||||
double pressLinUt = S7.Net.Types.Double.FromByteArray(RawInput.Skip(10).Take(4).ToArray());
|
||||
double tempH2O = S7.Net.Types.Double.FromByteArray(RawInput.Skip(14).Take(4).ToArray());
|
||||
|
||||
// verifico SE devo riportare dati VC
|
||||
if (scad01 || scad02 || scad03)
|
||||
{
|
||||
pressCamFilt = getVal_TSVC("pressCamFilt", scad01);
|
||||
pressLinUt = getVal_TSVC("pressLinUt", scad02);
|
||||
tempH2O = getVal_TSVC("tempH2O", scad03);
|
||||
outVal.Add("DYNDATA", $"pressCamFilt {pressCamFilt:N6} | pressLinUt {pressLinUt:N6} | tempH2O {tempH2O:N3}");
|
||||
outVal.Add("pressCamFilt", $"{pressCamFilt:N6}");
|
||||
outVal.Add("pressLinUt", $"{pressLinUt:N6}");
|
||||
outVal.Add("tempH2O", $"{tempH2O:N3}");
|
||||
// salvo!
|
||||
LastTSVC["pressCamFilt"] = pressCamFilt;
|
||||
LastTSVC["pressLinUt"] = pressLinUt;
|
||||
LastTSVC["tempH2O"] = tempH2O;
|
||||
}
|
||||
else
|
||||
{
|
||||
outVal.Add("DYNDATA", $"pressCamFilt {LastTSVC["pressCamFilt"]:N6} | pressLinUt {LastTSVC["pressLinUt"]:N6} | tempH2O {LastTSVC["tempH2O"]:N3}");
|
||||
}
|
||||
if (utils.CRB("enableTSVC"))
|
||||
{
|
||||
// salvo in stack le VC rilevate
|
||||
bool scad01 = stackVal_TSVC("pressCamFilt", pressCamFilt);
|
||||
bool scad02 = stackVal_TSVC("pressLinUt", pressLinUt);
|
||||
bool scad03 = stackVal_TSVC("tempH2O", tempH2O);
|
||||
|
||||
// verifico SE devo riportare dati VC
|
||||
if (scad01 || scad02 || scad03)
|
||||
{
|
||||
pressCamFilt = getVal_TSVC("pressCamFilt", scad01);
|
||||
pressLinUt = getVal_TSVC("pressLinUt", scad02);
|
||||
tempH2O = getVal_TSVC("tempH2O", scad03);
|
||||
outVal.Add("DYNDATA", $"pressCamFilt {pressCamFilt:N6} | pressLinUt {pressLinUt:N6} | tempH2O {tempH2O:N3}");
|
||||
outVal.Add("pressCamFilt", $"{pressCamFilt:N6}");
|
||||
outVal.Add("pressLinUt", $"{pressLinUt:N6}");
|
||||
outVal.Add("tempH2O", $"{tempH2O:N3}");
|
||||
// salvo!
|
||||
LastTSVC["pressCamFilt"] = pressCamFilt;
|
||||
LastTSVC["pressLinUt"] = pressLinUt;
|
||||
LastTSVC["tempH2O"] = tempH2O;
|
||||
}
|
||||
else
|
||||
{
|
||||
outVal.Add("DYNDATA", $"pressCamFilt {LastTSVC["pressCamFilt"]:N6} | pressLinUt {LastTSVC["pressLinUt"]:N6} | tempH2O {LastTSVC["tempH2O"]:N3}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
outVal.Add("pressCamFilt", $"{pressCamFilt:N6}");
|
||||
outVal.Add("pressLinUt", $"{pressLinUt:N6}");
|
||||
outVal.Add("tempH2O", $"{tempH2O:N3}");
|
||||
outVal.Add("DYNDATA", $"pressCamFilt {pressCamFilt:N3} | pressLinUt {pressLinUt:N3} | tempH2O {tempH2O:N3}");
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Errore in getDynData x Siemens Aprochim");
|
||||
}
|
||||
return outVal;
|
||||
}
|
||||
else
|
||||
|
||||
/// <summary>
|
||||
/// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid)
|
||||
/// </summary>
|
||||
public override void processOverride()
|
||||
{
|
||||
outVal.Add("pressCamFilt", $"{pressCamFilt:N6}");
|
||||
outVal.Add("pressLinUt", $"{pressLinUt:N6}");
|
||||
outVal.Add("tempH2O", $"{tempH2O:N3}");
|
||||
outVal.Add("DYNDATA", $"pressCamFilt {pressCamFilt:N3} | pressLinUt {pressLinUt:N3} | tempH2O {tempH2O:N3}");
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Errore in getDynData x Siemens Aprochim");
|
||||
}
|
||||
return outVal;
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// </summary>
|
||||
protected override void decodeToBaseBitmap()
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* bitmap MAPO STANDARD
|
||||
* B0: POWER_ON
|
||||
* B1: RUN
|
||||
* B2: pzCount
|
||||
* B3: allarme
|
||||
* B4: manuale
|
||||
* B5: emergenza
|
||||
*
|
||||
*
|
||||
* - BIT di stato
|
||||
* - DB60.DBX3.0: AUSILIARI INSERITI = NO EMERGENZA
|
||||
* - DB60.DBX3.1: Filtro (macchina) in LAVORAZIONE
|
||||
* - DB60.DBX3.2: Selettore in AUTOMATICO (sennò GIALLO)
|
||||
* - DB60.DBX3.3: WARNING MIN LIV VASCA (arancio)
|
||||
* - DB60.DBX3.4: WARNING MIN LIV CELLULOSA (blu)
|
||||
* - DB60.DBX3.5: LAMPADA ROSSA (allarmi almeno 1 attivo)
|
||||
----------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* bitmap MAPO FILTRO Aprochim
|
||||
* B0: POWER_ON
|
||||
* B1: RUN
|
||||
* B2: AUTOMATICO
|
||||
* B3: WARN_MIN_VASCA
|
||||
* B4: WARN_MIN_CELL
|
||||
* B5: ALARM
|
||||
* B6: EMERGENZA
|
||||
----------------------------------------------------- */
|
||||
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
B_input = currPLC.IsConnected ? 1 : 0;
|
||||
|
||||
// recupero byte segnali...
|
||||
int byteSignals = RawInput[3];
|
||||
// aggiungo "in coda" primo bit emergenza...essendo un bit negato (NON emergenza) lo cambio di segno
|
||||
if ((byteSignals & (1 << 0)) == 0)
|
||||
{
|
||||
byteSignals += (1 << 6);
|
||||
}
|
||||
// cancello primo bit (faccio uno shift a dx e poi a sx di 1...)
|
||||
byteSignals = ((byteSignals >> 1) << 1);
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[3]} --> B_input: {B_input}"));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
+274
-249
@@ -2,93 +2,180 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Controllo Siemens specifico x impianti SAET
|
||||
/// </summary>
|
||||
public class IobSiemensAt2001 : IobSiemens
|
||||
{
|
||||
/* --------------------------------------------------------------------------------
|
||||
* Controlli VIPA/SIEMENS (Interclays) di @2001
|
||||
* - VIPA, COMPATIBILE SIEMENS
|
||||
* - S7 vers 300
|
||||
*
|
||||
*
|
||||
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
protected DateTime lastPLCWatchDog;
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Classe base con i metodi x Siemens
|
||||
/// Controllo Siemens specifico x impianti SAET
|
||||
/// </summary>
|
||||
/// <param name="caller"></param>
|
||||
/// <param name="adpConf"></param>
|
||||
public IobSiemensAt2001(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
|
||||
public class IobSiemensAt2001 : IobSiemens
|
||||
{
|
||||
lgInfo("NEW IOB SIEMENS versione VIPA AT2001");
|
||||
lastPLCWatchDog = DateTime.Now.AddMinutes(-1);
|
||||
}
|
||||
/* --------------------------------------------------------------------------------
|
||||
* Controlli VIPA/SIEMENS (Interclays) di @2001
|
||||
* - VIPA, COMPATIBILE SIEMENS
|
||||
* - S7 vers 300
|
||||
*
|
||||
*
|
||||
|
||||
#region Metodi specifici (da verificare/completare in implementazione)
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
/// <summary>
|
||||
/// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid)
|
||||
/// </summary>
|
||||
public override void processOverride()
|
||||
{
|
||||
}
|
||||
#region Protected Fields
|
||||
|
||||
public override void processWhatchDog()
|
||||
{
|
||||
//NON SERVE!!!!
|
||||
}
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
|
||||
/// <summary>
|
||||
/// Processo i task richiesti e li elimino dalla coda 1:1
|
||||
/// </summary>
|
||||
/// <param name="task2exe"></param>
|
||||
public override Dictionary<string, string> executeTasks(Dictionary<string, string> task2exe)
|
||||
{
|
||||
// Verificare il protocollo: dovrebeb togliere SOLO i task eseguiti...
|
||||
Dictionary<string, string> taskDone = new Dictionary<string, string>();
|
||||
bool taskOk = false;
|
||||
string taskVal = "";
|
||||
// inizio VUOTO
|
||||
byte[] MemBlock = new byte[1];
|
||||
string memAddrWrite = "";
|
||||
if (task2exe != null)
|
||||
{
|
||||
// cerco task specifici: se ho startSetup --> imposto bit DBB701.DBB0.4
|
||||
foreach (var item in task2exe)
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Classe base con i metodi x Siemens
|
||||
/// </summary>
|
||||
/// <param name="caller"></param>
|
||||
/// <param name="adpConf"></param>
|
||||
public IobSiemensAt2001(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
|
||||
{
|
||||
taskOk = false;
|
||||
taskVal = "";
|
||||
memAddrWrite = "";
|
||||
// converto richiesta in enum...
|
||||
taskType tName = taskType.nihil;
|
||||
Enum.TryParse(item.Key, out tName);
|
||||
// controllo sulla KEY
|
||||
switch (tName)
|
||||
{
|
||||
case taskType.nihil:
|
||||
case taskType.fixStopSetup:
|
||||
case taskType.forceSetPzCount:
|
||||
case taskType.stopSetup:
|
||||
taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC";
|
||||
break;
|
||||
case taskType.forceResetPzCount:
|
||||
case taskType.startSetup:
|
||||
// alzo il bit x registrare richiesta reset contapezzi... POI quando ha eseguito abbassa il PLC il bit a zero...
|
||||
MemBlock[0] = 1;
|
||||
memAddrWrite = "DB1001.DBB88";
|
||||
break;
|
||||
case taskType.setArt:
|
||||
case taskType.setComm:
|
||||
case taskType.setProg:
|
||||
lgInfo("NEW IOB SIEMENS versione VIPA AT2001");
|
||||
lastPLCWatchDog = DateTime.Now.AddMinutes(-1);
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// </summary>
|
||||
protected override void decodeToBaseBitmap()
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* bitmap MAPO STANDARD
|
||||
* B0: POWER_ON
|
||||
* B1: RUN
|
||||
* B2: pzCount
|
||||
* B3: allarme
|
||||
* B4: manuale
|
||||
* B5: avvio/spegnimento
|
||||
* B6: emergenza
|
||||
*
|
||||
*
|
||||
* - BYTE di stato
|
||||
* - +0.0 AutoStatus BYTE B#16#0 Valore 0=Fermo/1->3=Avviamento/4=Avviato/5=Pausa/6->8spegnimento/9->10 allarme
|
||||
* - +1.0 Dosatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +2.0 V_Dosatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +3.0 Nas_Lancio BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +4.0 Cilindro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +5.0 Bruciatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +6.0 Aspiratore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +7.0 Nas_Raccolta BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +8.0 Nas_Brandeg BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +9.0 Coclea_Filtro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +10.0 Ciclico_Filtro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
----------------------------------------------------- */
|
||||
|
||||
// recupero byte segnali...
|
||||
int byteSignals = RawInput[0];
|
||||
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
B_input = currPLC.IsConnected ? 1 : 0;
|
||||
|
||||
// avviamento --> manuale
|
||||
switch (byteSignals)
|
||||
{
|
||||
case 0:
|
||||
B_input = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
B_input += (1 << 5);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
B_input += (1 << 1);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
B_input += (1 << 4);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
B_input += (1 << 5);
|
||||
break;
|
||||
|
||||
case 9:
|
||||
B_input += (1 << 3);
|
||||
break;
|
||||
|
||||
case 10:
|
||||
B_input += (1 << 6);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}"));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Processo i task richiesti e li elimino dalla coda 1:1
|
||||
/// </summary>
|
||||
/// <param name="task2exe"></param>
|
||||
public override Dictionary<string, string> executeTasks(Dictionary<string, string> task2exe)
|
||||
{
|
||||
// Verificare il protocollo: dovrebeb togliere SOLO i task eseguiti...
|
||||
Dictionary<string, string> taskDone = new Dictionary<string, string>();
|
||||
bool taskOk = false;
|
||||
string taskVal = "";
|
||||
// inizio VUOTO
|
||||
byte[] MemBlock = new byte[1];
|
||||
string memAddrWrite = "";
|
||||
if (task2exe != null)
|
||||
{
|
||||
// cerco task specifici: se ho startSetup --> imposto bit DBB701.DBB0.4
|
||||
foreach (var item in task2exe)
|
||||
{
|
||||
taskOk = false;
|
||||
taskVal = "";
|
||||
memAddrWrite = "";
|
||||
// converto richiesta in enum...
|
||||
taskType tName = taskType.nihil;
|
||||
Enum.TryParse(item.Key, out tName);
|
||||
// controllo sulla KEY
|
||||
switch (tName)
|
||||
{
|
||||
case taskType.nihil:
|
||||
case taskType.fixStopSetup:
|
||||
case taskType.forceSetPzCount:
|
||||
case taskType.stopSetup:
|
||||
taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC";
|
||||
break;
|
||||
|
||||
case taskType.forceResetPzCount:
|
||||
case taskType.startSetup:
|
||||
// alzo il bit x registrare richiesta reset contapezzi... POI quando ha eseguito abbassa il PLC il bit a zero...
|
||||
MemBlock[0] = 1;
|
||||
memAddrWrite = "DB1001.DBB88";
|
||||
break;
|
||||
|
||||
case taskType.setArt:
|
||||
case taskType.setComm:
|
||||
case taskType.setProg:
|
||||
#if false
|
||||
// imposto i valori...
|
||||
if (currProdData.ContainsKey(item.Key))
|
||||
@@ -99,36 +186,41 @@ namespace IOB_WIN
|
||||
{
|
||||
currProdData.Add(item.Key, item.Value);
|
||||
}
|
||||
taskVal = item.Value;
|
||||
taskVal = item.Value;
|
||||
#endif
|
||||
saveProdData(item);
|
||||
int byteSize = 0;
|
||||
// recupero dati da memMap... altrimenti NULLA
|
||||
if (memMap.mMapWrite.ContainsKey(item.Key))
|
||||
{
|
||||
dataConf currMem = memMap.mMapWrite[item.Key];
|
||||
byteSize = currMem.size;
|
||||
memAddrWrite = currMem.memAddr;
|
||||
MemBlock = new byte[byteSize];
|
||||
switch (currMem.tipoMem)
|
||||
{
|
||||
case plcDataType.Boolean:
|
||||
break;
|
||||
case plcDataType.Int:
|
||||
saveIntOnMemBlock(ref MemBlock, item.Key, 0);
|
||||
break;
|
||||
case plcDataType.DInt:
|
||||
saveDIntOnMemBlock(ref MemBlock, item.Key, 0);
|
||||
break;
|
||||
case plcDataType.Real:
|
||||
saveRealOnMemBlock(ref MemBlock, item.Key, 0);
|
||||
break;
|
||||
case plcDataType.String:
|
||||
saveStringOnMemBlock(ref MemBlock, item.Key, 0, byteSize);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
saveProdData(item);
|
||||
int byteSize = 0;
|
||||
// recupero dati da memMap... altrimenti NULLA
|
||||
if (memMap.mMapWrite.ContainsKey(item.Key))
|
||||
{
|
||||
dataConf currMem = memMap.mMapWrite[item.Key];
|
||||
byteSize = currMem.size;
|
||||
memAddrWrite = currMem.memAddr;
|
||||
MemBlock = new byte[byteSize];
|
||||
switch (currMem.tipoMem)
|
||||
{
|
||||
case plcDataType.Boolean:
|
||||
break;
|
||||
|
||||
case plcDataType.Int:
|
||||
saveIntOnMemBlock(ref MemBlock, item.Key, 0);
|
||||
break;
|
||||
|
||||
case plcDataType.DInt:
|
||||
saveDIntOnMemBlock(ref MemBlock, item.Key, 0);
|
||||
break;
|
||||
|
||||
case plcDataType.Real:
|
||||
saveRealOnMemBlock(ref MemBlock, item.Key, 0);
|
||||
break;
|
||||
|
||||
case plcDataType.String:
|
||||
saveStringOnMemBlock(ref MemBlock, item.Key, 0, byteSize);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#if false
|
||||
if (currMem.tipoMem == plcDataType.String)
|
||||
{
|
||||
@@ -145,62 +237,65 @@ namespace IOB_WIN
|
||||
short valDInt = 0;
|
||||
short.TryParse(item.Value, out valDInt);
|
||||
MemBlock = S7.Net.Types.Int.ToByteArray(valDInt);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
taskVal = item.Value;
|
||||
break;
|
||||
case taskType.setParameter:
|
||||
// richiedo da URL i parametri WRITE da popolare
|
||||
lgInfo("Chiamata processMemWriteRequests");
|
||||
taskVal = processMemWriteRequests();
|
||||
// se restituiscce "" faccio altra prova...
|
||||
if (!string.IsNullOrEmpty(taskVal))
|
||||
{
|
||||
taskOk = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// i parametri me li aspetto come stringa composta paramName|paramvalue
|
||||
if (item.Value.Contains("|"))
|
||||
{
|
||||
string[] paramsJob = item.Value.Split('|');
|
||||
taskVal = $"REQUEST SET PARAMETERS: {paramsJob[0]} --> {paramsJob[1]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {item.Value} doesnt contain pipe for splitting key/value";
|
||||
}
|
||||
}
|
||||
// alzo il bit x registrare RICHEISTA modifica (secondo BIT)... POI quando ha eseguito abbassa il PLC il bit a zero...
|
||||
MemBlock[0] = 2;
|
||||
memAddrWrite = "DB1001.DBB88";
|
||||
break;
|
||||
case taskType.sendWatchDogMes2Plc:
|
||||
//// compogo in byte... primo bit è setup/run, ultimo è watchdog
|
||||
//int valore = inSetup ? 1 : 0;
|
||||
int valore = counterMes2Plc;
|
||||
MemBlock[68] = (byte)valore;
|
||||
taskVal = $"VALUE DB1001.68 --> {counterMes2Plc}";
|
||||
break;
|
||||
default:
|
||||
taskVal = "SKIPPED | NO EXEC";
|
||||
break;
|
||||
}
|
||||
}
|
||||
taskVal = item.Value;
|
||||
break;
|
||||
|
||||
// aggiungo task!
|
||||
taskDone.Add(item.Key, taskVal);
|
||||
if (!string.IsNullOrEmpty(memAddrWrite))
|
||||
{
|
||||
// scrivo comunque!
|
||||
taskOk = S7WriteBB(ref MemBlock, memAddrWrite);
|
||||
}
|
||||
if (!taskOk)
|
||||
{
|
||||
lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
case taskType.setParameter:
|
||||
// richiedo da URL i parametri WRITE da popolare
|
||||
lgInfo("Chiamata processMemWriteRequests");
|
||||
taskVal = processMemWriteRequests();
|
||||
// se restituiscce "" faccio altra prova...
|
||||
if (!string.IsNullOrEmpty(taskVal))
|
||||
{
|
||||
taskOk = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// i parametri me li aspetto come stringa composta paramName|paramvalue
|
||||
if (item.Value.Contains("|"))
|
||||
{
|
||||
string[] paramsJob = item.Value.Split('|');
|
||||
taskVal = $"REQUEST SET PARAMETERS: {paramsJob[0]} --> {paramsJob[1]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {item.Value} doesnt contain pipe for splitting key/value";
|
||||
}
|
||||
}
|
||||
// alzo il bit x registrare RICHEISTA modifica (secondo BIT)... POI quando ha eseguito abbassa il PLC il bit a zero...
|
||||
MemBlock[0] = 2;
|
||||
memAddrWrite = "DB1001.DBB88";
|
||||
break;
|
||||
|
||||
case taskType.sendWatchDogMes2Plc:
|
||||
//// compogo in byte... primo bit è setup/run, ultimo è watchdog
|
||||
//int valore = inSetup ? 1 : 0;
|
||||
int valore = counterMes2Plc;
|
||||
MemBlock[68] = (byte)valore;
|
||||
taskVal = $"VALUE DB1001.68 --> {counterMes2Plc}";
|
||||
break;
|
||||
|
||||
default:
|
||||
taskVal = "SKIPPED | NO EXEC";
|
||||
break;
|
||||
}
|
||||
|
||||
// aggiungo task!
|
||||
taskDone.Add(item.Key, taskVal);
|
||||
if (!string.IsNullOrEmpty(memAddrWrite))
|
||||
{
|
||||
// scrivo comunque!
|
||||
taskOk = S7WriteBB(ref MemBlock, memAddrWrite);
|
||||
}
|
||||
if (!taskOk)
|
||||
{
|
||||
lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if false
|
||||
// controllo SE HO da scrivere articolo/commessa/programma
|
||||
@@ -208,9 +303,6 @@ namespace IOB_WIN
|
||||
saveStringOnMemBlock(ref MemBlock, "setComm", 22, 20, true);
|
||||
saveStringOnMemBlock(ref MemBlock, "setProg", 44, 20, true);
|
||||
|
||||
|
||||
|
||||
|
||||
// !!!FIXME!!! rendere parametrico
|
||||
// SE HO un valore ART scrivo...
|
||||
if (currProdData.ContainsKey("setArt"))
|
||||
@@ -238,91 +330,24 @@ namespace IOB_WIN
|
||||
// fare un controllo x forzare update...
|
||||
|
||||
// scrivo comunque!
|
||||
taskOk = S7WriteBB(ref MemBlock);
|
||||
taskOk = S7WriteBB(ref MemBlock);
|
||||
#endif
|
||||
|
||||
return taskDone;
|
||||
return taskDone;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid)
|
||||
/// </summary>
|
||||
public override void processOverride()
|
||||
{
|
||||
}
|
||||
|
||||
public override void processWhatchDog()
|
||||
{
|
||||
//NON SERVE!!!!
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// </summary>
|
||||
protected override void decodeToBaseBitmap()
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* bitmap MAPO STANDARD
|
||||
* B0: POWER_ON
|
||||
* B1: RUN
|
||||
* B2: pzCount
|
||||
* B3: allarme
|
||||
* B4: manuale
|
||||
* B5: avvio/spegnimento
|
||||
* B6: emergenza
|
||||
*
|
||||
*
|
||||
* - BYTE di stato
|
||||
* - +0.0 AutoStatus BYTE B#16#0 Valore 0=Fermo/1->3=Avviamento/4=Avviato/5=Pausa/6->8spegnimento/9->10 allarme
|
||||
* - +1.0 Dosatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +2.0 V_Dosatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +3.0 Nas_Lancio BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +4.0 Cilindro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +5.0 Bruciatore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +6.0 Aspiratore BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +7.0 Nas_Raccolta BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +8.0 Nas_Brandeg BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +9.0 Coclea_Filtro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
* - +10.0 Ciclico_Filtro BYTE B#16#0 Stato (bit0=in avviamento/1=marcia sx/2=marcia dx/3=in allarme/4=by-pass on)
|
||||
----------------------------------------------------- */
|
||||
|
||||
|
||||
// recupero byte segnali...
|
||||
int byteSignals = RawInput[0];
|
||||
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
B_input = currPLC.IsConnected ? 1 : 0;
|
||||
|
||||
// avviamento --> manuale
|
||||
switch (byteSignals)
|
||||
{
|
||||
case 0:
|
||||
B_input = 1;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
B_input += (1 << 5);
|
||||
break;
|
||||
case 4:
|
||||
B_input += (1 << 1);
|
||||
break;
|
||||
case 5:
|
||||
B_input += (1 << 4);
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
B_input += (1 << 5);
|
||||
break;
|
||||
case 9:
|
||||
B_input += (1 << 3);
|
||||
break;
|
||||
case 10:
|
||||
B_input += (1 << 6);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}"));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Controllo Siemens specifico x impianti COMUR
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobSiemensFape : IobSiemens
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Controllo Siemens specifico x impianti Ingenia (Automazione Valvital)
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Controllo Siemens specifico x impianti Lasco (Pressa bilancere Valvital)
|
||||
|
||||
@@ -2,235 +2,253 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Controllo Siemens specifico x impianti Pressoil+Cei (Pressa idraulica Valvital)
|
||||
/// </summary>
|
||||
public class IobSiemensPressoilCei : IobSiemens
|
||||
{
|
||||
/* --------------------------------------------------------------------------------
|
||||
* Controlli SIEMENS CEI PRESSOIL (impianti ad induzione in VALVITAL)
|
||||
* - basasto su SIEMENS
|
||||
* - S7 vers 1500
|
||||
*
|
||||
* STRUTTURA MEMORIA DB64 READ e DB67 WRITE, vedere file conf json
|
||||
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
protected DateTime lastPLCWatchDog;
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Classe base con i metodi x Siemens
|
||||
/// Controllo Siemens specifico x impianti Pressoil+Cei (Pressa idraulica Valvital)
|
||||
/// </summary>
|
||||
/// <param name="caller"></param>
|
||||
/// <param name="adpConf"></param>
|
||||
public IobSiemensPressoilCei(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
|
||||
public class IobSiemensPressoilCei : IobSiemens
|
||||
{
|
||||
lgInfo("NEW IOB SIEMENS versione PRESSOIL - CEI");
|
||||
}
|
||||
/* --------------------------------------------------------------------------------
|
||||
* Controlli SIEMENS CEI PRESSOIL (impianti ad induzione in VALVITAL)
|
||||
* - basasto su SIEMENS
|
||||
* - S7 vers 1500
|
||||
*
|
||||
* STRUTTURA MEMORIA DB64 READ e DB67 WRITE, vedere file conf json
|
||||
|
||||
#region Metodi specifici (da verificare/completare in implementazione)
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
/// <summary>
|
||||
/// Processo i task richiesti e li elimino dalla coda 1:1
|
||||
/// </summary>
|
||||
/// <param name="task2exe"></param>
|
||||
public override Dictionary<string, string> executeTasks(Dictionary<string, string> task2exe)
|
||||
{
|
||||
// Verificare il protocollo: dovrebeb togliere SOLO i task eseguiti...
|
||||
Dictionary<string, string> taskDone = new Dictionary<string, string>();
|
||||
bool taskOk = false;
|
||||
string taskVal = "";
|
||||
// inizio con 1 byte di default
|
||||
byte[] MemBlock = new byte[1];
|
||||
string memAddrWrite = "";
|
||||
if (task2exe != null)
|
||||
{
|
||||
// cerco task specifici
|
||||
foreach (var item in task2exe)
|
||||
#region Protected Fields
|
||||
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Classe base con i metodi x Siemens
|
||||
/// </summary>
|
||||
/// <param name="caller"></param>
|
||||
/// <param name="adpConf"></param>
|
||||
public IobSiemensPressoilCei(AdapterForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
|
||||
{
|
||||
taskOk = false;
|
||||
taskVal = "";
|
||||
// converto richiesta in enum...
|
||||
taskType tName = taskType.nihil;
|
||||
Enum.TryParse(item.Key, out tName);
|
||||
// controllo sulla KEY
|
||||
switch (tName)
|
||||
{
|
||||
case taskType.nihil:
|
||||
case taskType.fixStopSetup:
|
||||
case taskType.forceResetPzCount:
|
||||
case taskType.forceSetPzCount:
|
||||
case taskType.setProg:
|
||||
taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC";
|
||||
break;
|
||||
case taskType.setArt:
|
||||
case taskType.setComm:
|
||||
case taskType.setPzComm:
|
||||
saveProdData(item);
|
||||
int byteSize = 0;
|
||||
// recupero dati da memMap... altrimenti NULLA
|
||||
if (memMap.mMapWrite.ContainsKey(item.Key))
|
||||
{
|
||||
dataConf currMem = memMap.mMapWrite[item.Key];
|
||||
byteSize = currMem.size;
|
||||
memAddrWrite = currMem.memAddr;
|
||||
MemBlock = new byte[byteSize];
|
||||
if (currMem.tipoMem == plcDataType.String)
|
||||
{
|
||||
saveStringOnMemBlock(ref MemBlock, item.Key, 0, byteSize);
|
||||
}
|
||||
else if (currMem.tipoMem == plcDataType.Int)
|
||||
{
|
||||
short valDInt = 0;
|
||||
short.TryParse(item.Value, out valDInt);
|
||||
MemBlock = S7.Net.Types.Int.ToByteArray(valDInt);
|
||||
}
|
||||
else if (currMem.tipoMem == plcDataType.DInt)
|
||||
{
|
||||
int valDInt = 0;
|
||||
int.TryParse(item.Value, out valDInt);
|
||||
MemBlock = S7.Net.Types.DInt.ToByteArray(valDInt);
|
||||
}
|
||||
else if (currMem.tipoMem == plcDataType.Word)
|
||||
{
|
||||
ushort valDInt = 0;
|
||||
ushort.TryParse(item.Value, out valDInt);
|
||||
MemBlock = S7.Net.Types.Word.ToByteArray(valDInt);
|
||||
}
|
||||
else if (currMem.tipoMem == plcDataType.DWord)
|
||||
{
|
||||
uint valDInt = 0;
|
||||
uint.TryParse(item.Value, out valDInt);
|
||||
MemBlock = S7.Net.Types.DWord.ToByteArray(valDInt);
|
||||
}
|
||||
}
|
||||
taskVal = item.Value;
|
||||
break;
|
||||
case taskType.sendWatchDogMes2Plc:
|
||||
// processo scrittura BIT su DB67.DBX0.0
|
||||
MemBlock = new byte[1];
|
||||
memAddrWrite = "DB67.DBB0";
|
||||
// compogo in byte... primo bit è setup/run, ultimo è watchdog
|
||||
int valore = inSetup ? 1 : 0;
|
||||
valore += (byte)(counterMes2Plc << 7);
|
||||
MemBlock[0] = (byte)valore;
|
||||
taskVal = $"VALUE DB67.0 --> {valore} | counter interno {counterMes2Plc}";
|
||||
break;
|
||||
case taskType.setParameter:
|
||||
// richiedo da URL i parametri WRITE da popolare
|
||||
lgInfo("Chiamata processMemWriteRequests");
|
||||
taskVal = processMemWriteRequests();
|
||||
// se restituiscce "" faccio altra prova...
|
||||
if (string.IsNullOrEmpty(taskVal))
|
||||
{
|
||||
// i parametri me li aspetto come stringa composta paramName|paramvalue
|
||||
if (item.Value.Contains("|"))
|
||||
{
|
||||
string[] paramsJob = item.Value.Split('|');
|
||||
taskVal = $"REQUEST SET PARAMETERS: {paramsJob[0]} --> {paramsJob[1]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {item.Value} doesnt contain pipe for splitting key/value";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case taskType.startSetup:
|
||||
// salvo che SONO IN SETUP!
|
||||
inSetup = true;
|
||||
break;
|
||||
case taskType.stopSetup:
|
||||
// salvo che SONO FUORI DAL SETUP!
|
||||
inSetup = false;
|
||||
break;
|
||||
default:
|
||||
taskVal = "SKIPPED | NO EXEC";
|
||||
break;
|
||||
}
|
||||
// aggiungo task!
|
||||
taskDone.Add(item.Key, taskVal);
|
||||
// scrivo comunque!
|
||||
taskOk = S7WriteBB(ref MemBlock, memAddrWrite);
|
||||
if (!taskOk)
|
||||
{
|
||||
lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}");
|
||||
}
|
||||
lgInfo("NEW IOB SIEMENS versione PRESSOIL - CEI");
|
||||
}
|
||||
}
|
||||
return taskDone;
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// </summary>
|
||||
protected override void decodeToBaseBitmap()
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* bitmap MAPO STANDARD
|
||||
* B0: POWER_ON
|
||||
* B1: RUN
|
||||
* B2: pzCount
|
||||
* B3: allarme
|
||||
* B4: manuale
|
||||
* B5: emergenza
|
||||
*
|
||||
*
|
||||
* - BIT di stato
|
||||
* - DBX0.0 - Life bit
|
||||
* - DBX0.1 – Macchina lavora
|
||||
* - DBX0.2 – Macchina in ciclo
|
||||
* - DBX0.3 – Macchina in manuale
|
||||
* - DBX0.4 – Macchina in allarme
|
||||
* - DBX0.5 – Macchina in emergenza
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[0];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
// RUN se lavora ed in ciclo
|
||||
if ((mainData & (1 << 1)) != 0 && (mainData & (1 << 2)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
// manuale
|
||||
if ((mainData & (1 << 3)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
// allarme
|
||||
if ((mainData & (1 << 4)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
// emergenza
|
||||
if ((mainData & (1 << 5)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 5);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Processo i task richiesti e li elimino dalla coda 1:1
|
||||
/// </summary>
|
||||
/// <param name="task2exe"></param>
|
||||
public override Dictionary<string, string> executeTasks(Dictionary<string, string> task2exe)
|
||||
{
|
||||
// Verificare il protocollo: dovrebeb togliere SOLO i task eseguiti...
|
||||
Dictionary<string, string> taskDone = new Dictionary<string, string>();
|
||||
bool taskOk = false;
|
||||
string taskVal = "";
|
||||
// inizio con 1 byte di default
|
||||
byte[] MemBlock = new byte[1];
|
||||
string memAddrWrite = "";
|
||||
if (task2exe != null)
|
||||
{
|
||||
// cerco task specifici
|
||||
foreach (var item in task2exe)
|
||||
{
|
||||
taskOk = false;
|
||||
taskVal = "";
|
||||
// converto richiesta in enum...
|
||||
taskType tName = taskType.nihil;
|
||||
Enum.TryParse(item.Key, out tName);
|
||||
// controllo sulla KEY
|
||||
switch (tName)
|
||||
{
|
||||
case taskType.nihil:
|
||||
case taskType.fixStopSetup:
|
||||
case taskType.forceResetPzCount:
|
||||
case taskType.forceSetPzCount:
|
||||
case taskType.setProg:
|
||||
taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC";
|
||||
break;
|
||||
|
||||
case taskType.setArt:
|
||||
case taskType.setComm:
|
||||
case taskType.setPzComm:
|
||||
saveProdData(item);
|
||||
int byteSize = 0;
|
||||
// recupero dati da memMap... altrimenti NULLA
|
||||
if (memMap.mMapWrite.ContainsKey(item.Key))
|
||||
{
|
||||
dataConf currMem = memMap.mMapWrite[item.Key];
|
||||
byteSize = currMem.size;
|
||||
memAddrWrite = currMem.memAddr;
|
||||
MemBlock = new byte[byteSize];
|
||||
if (currMem.tipoMem == plcDataType.String)
|
||||
{
|
||||
saveStringOnMemBlock(ref MemBlock, item.Key, 0, byteSize);
|
||||
}
|
||||
else if (currMem.tipoMem == plcDataType.Int)
|
||||
{
|
||||
short valDInt = 0;
|
||||
short.TryParse(item.Value, out valDInt);
|
||||
MemBlock = S7.Net.Types.Int.ToByteArray(valDInt);
|
||||
}
|
||||
else if (currMem.tipoMem == plcDataType.DInt)
|
||||
{
|
||||
int valDInt = 0;
|
||||
int.TryParse(item.Value, out valDInt);
|
||||
MemBlock = S7.Net.Types.DInt.ToByteArray(valDInt);
|
||||
}
|
||||
else if (currMem.tipoMem == plcDataType.Word)
|
||||
{
|
||||
ushort valDInt = 0;
|
||||
ushort.TryParse(item.Value, out valDInt);
|
||||
MemBlock = S7.Net.Types.Word.ToByteArray(valDInt);
|
||||
}
|
||||
else if (currMem.tipoMem == plcDataType.DWord)
|
||||
{
|
||||
uint valDInt = 0;
|
||||
uint.TryParse(item.Value, out valDInt);
|
||||
MemBlock = S7.Net.Types.DWord.ToByteArray(valDInt);
|
||||
}
|
||||
}
|
||||
taskVal = item.Value;
|
||||
break;
|
||||
|
||||
case taskType.sendWatchDogMes2Plc:
|
||||
// processo scrittura BIT su DB67.DBX0.0
|
||||
MemBlock = new byte[1];
|
||||
memAddrWrite = "DB67.DBB0";
|
||||
// compogo in byte... primo bit è setup/run, ultimo è watchdog
|
||||
int valore = inSetup ? 1 : 0;
|
||||
valore += (byte)(counterMes2Plc << 7);
|
||||
MemBlock[0] = (byte)valore;
|
||||
taskVal = $"VALUE DB67.0 --> {valore} | counter interno {counterMes2Plc}";
|
||||
break;
|
||||
|
||||
case taskType.setParameter:
|
||||
// richiedo da URL i parametri WRITE da popolare
|
||||
lgInfo("Chiamata processMemWriteRequests");
|
||||
taskVal = processMemWriteRequests();
|
||||
// se restituiscce "" faccio altra prova...
|
||||
if (string.IsNullOrEmpty(taskVal))
|
||||
{
|
||||
// i parametri me li aspetto come stringa composta paramName|paramvalue
|
||||
if (item.Value.Contains("|"))
|
||||
{
|
||||
string[] paramsJob = item.Value.Split('|');
|
||||
taskVal = $"REQUEST SET PARAMETERS: {paramsJob[0]} --> {paramsJob[1]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {item.Value} doesnt contain pipe for splitting key/value";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case taskType.startSetup:
|
||||
// salvo che SONO IN SETUP!
|
||||
inSetup = true;
|
||||
break;
|
||||
|
||||
case taskType.stopSetup:
|
||||
// salvo che SONO FUORI DAL SETUP!
|
||||
inSetup = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
taskVal = "SKIPPED | NO EXEC";
|
||||
break;
|
||||
}
|
||||
// aggiungo task!
|
||||
taskDone.Add(item.Key, taskVal);
|
||||
// scrivo comunque!
|
||||
taskOk = S7WriteBB(ref MemBlock, memAddrWrite);
|
||||
if (!taskOk)
|
||||
{
|
||||
lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
return taskDone;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// </summary>
|
||||
protected override void decodeToBaseBitmap()
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* bitmap MAPO STANDARD
|
||||
* B0: POWER_ON
|
||||
* B1: RUN
|
||||
* B2: pzCount
|
||||
* B3: allarme
|
||||
* B4: manuale
|
||||
* B5: emergenza
|
||||
*
|
||||
*
|
||||
* - BIT di stato
|
||||
* - DBX0.0 - Life bit
|
||||
* - DBX0.1 – Macchina lavora
|
||||
* - DBX0.2 – Macchina in ciclo
|
||||
* - DBX0.3 – Macchina in manuale
|
||||
* - DBX0.4 – Macchina in allarme
|
||||
* - DBX0.5 – Macchina in emergenza
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[0];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
// RUN se lavora ed in ciclo
|
||||
if ((mainData & (1 << 1)) != 0 && (mainData & (1 << 2)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
// manuale
|
||||
if ((mainData & (1 << 3)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
// allarme
|
||||
if ((mainData & (1 << 4)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
// emergenza
|
||||
if ((mainData & (1 << 5)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 5);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Controllo Siemens specifico x impianti SAET
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Controllo Siemens specifico x impianti Simec
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobSiemensTorri : IobSiemens
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using MapoSDK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobSimula : IobGeneric
|
||||
{
|
||||
|
||||
+142
-120
@@ -12,47 +12,57 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Generica classe per implementare WebPageScraping (scaricamento web pages anche js-based x recupero informazioni)
|
||||
/// </summary>
|
||||
public class IobWPS : IobGeneric, IDisposable
|
||||
{
|
||||
/* --------------------------------------------------------------------------------
|
||||
/* --------------------------------------------------------------------------------
|
||||
* Controlli dotati di GENERICA pagina WEB in cui cercare e recuperare informazioni
|
||||
*
|
||||
*
|
||||
* - il file di conf deve contenere l'URL di base
|
||||
* - il file di conf deve contenere COSA cercare (es il "contenitore" del dato da estrarre)
|
||||
*
|
||||
*
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
/// <summary>
|
||||
/// Vettore della frequenza di ogni status trovato... invio ogni 100 rilevazioni (modulo 100, resto == 1)
|
||||
/// </summary>
|
||||
protected Dictionary<string, int> freqUnknStatus = new Dictionary<string, int>();
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Pagina web da scaricare
|
||||
/// </summary>
|
||||
protected string baseUri = "http://127.0.0.1";
|
||||
|
||||
/// <summary>
|
||||
/// Array di configurazione degli oggetti da cercare x decodifica e recupero info
|
||||
/// </summary>
|
||||
protected Dictionary<string, string> dataLocatorLUT;
|
||||
|
||||
/// <summary>
|
||||
/// Driver per gestione chiamate crawling/scraping
|
||||
/// </summary>
|
||||
protected IWebDriver driver;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetti decodificati da pagina
|
||||
/// </summary>
|
||||
protected MonitoredItemsConf monitoredItems;
|
||||
/// <summary>
|
||||
/// Elementi da recuperare nella apgina web
|
||||
/// </summary>
|
||||
protected IWebElement element;
|
||||
|
||||
/// <summary>
|
||||
/// Vettore della frequenza di ogni status trovato... invio ogni 100 rilevazioni (modulo 100, resto == 1)
|
||||
/// </summary>
|
||||
protected Dictionary<string, int> freqUnknStatus = new Dictionary<string, int>();
|
||||
|
||||
/// <summary>
|
||||
/// Oggetti decodificati da pagina
|
||||
/// </summary>
|
||||
protected MonitoredItemsConf monitoredItems;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Estende l'init della classe base...
|
||||
/// </summary>
|
||||
@@ -63,6 +73,40 @@ namespace IOB_WIN
|
||||
lgInfo("INIT IobWPS");
|
||||
//reloadAdapterConf();
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Processo stati unknown...
|
||||
/// </summary>
|
||||
/// <param name="cKey"></param>
|
||||
private void processUnknStatus(string cKey)
|
||||
{
|
||||
// cerco se avevo già una key nella dictionary...
|
||||
if (freqUnknStatus.ContainsKey(cKey))
|
||||
{
|
||||
freqUnknStatus[cKey]++;
|
||||
// se è 1 ogni 100 (%100, resto ==1) --> loggo...
|
||||
if (freqUnknStatus[cKey] % 100 == 1)
|
||||
{
|
||||
lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey} | freq: {freqUnknStatus[cKey]}");
|
||||
// accodo come invio di tipo FLOG...
|
||||
string sVal = string.Format("[UnknStatus] {0}, freq: {1}", cKey, freqUnknStatus);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog("UnknStatus", sVal));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// creo chiave con freq = 1
|
||||
freqUnknStatus.Add(cKey, 1);
|
||||
// log iniziale
|
||||
lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ricarica conf adapter...
|
||||
/// </summary>
|
||||
@@ -105,66 +149,6 @@ namespace IOB_WIN
|
||||
raiseRefresh(currDispData);
|
||||
}
|
||||
|
||||
#region Metodi specifici (da verificare/completare in implementazione)
|
||||
|
||||
public override void startAdapter(bool resetQueue)
|
||||
{
|
||||
// in primis RICARICO conf specifica...
|
||||
reloadAdapterConf();
|
||||
// continuo con start...
|
||||
base.startAdapter(resetQueue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override x chiusura driver...
|
||||
/// </summary>
|
||||
/// <param name="tryRestart"></param>
|
||||
/// <param name="forceDequeue"></param>
|
||||
public override void stopAdapter(bool tryRestart, bool forceDequeue)
|
||||
{
|
||||
try
|
||||
{
|
||||
// in primis chiudo driver...
|
||||
if (driver != null)
|
||||
{
|
||||
driver.Quit();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Eccezione in tryDisconnect");
|
||||
}
|
||||
// continuo
|
||||
base.stopAdapter(tryRestart, forceDequeue);
|
||||
}
|
||||
/// <summary>
|
||||
/// Connessione
|
||||
/// </summary>
|
||||
public override void tryConnect()
|
||||
{
|
||||
// controllo ping --> segno connected...
|
||||
connectionOk = (testPingMachine == IPStatus.Success);
|
||||
if (connectionOk)
|
||||
{
|
||||
try
|
||||
{
|
||||
//var t = TaskEx.Run(() => startDriver());
|
||||
//t.Wait();
|
||||
// modalità sincrona
|
||||
startDriver();
|
||||
lgInfo("Completato start driver");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Eccezione in tryConnect");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// aspetto prima di riprovare...
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Avvio del WebDriver
|
||||
/// </summary>
|
||||
@@ -198,31 +182,15 @@ namespace IOB_WIN
|
||||
// imposto pagina di acquisizione
|
||||
driver.Navigate().GoToUrl(baseUri);
|
||||
}
|
||||
/// <summary>
|
||||
/// Disconnessione
|
||||
/// </summary>
|
||||
public override void tryDisconnect()
|
||||
{
|
||||
connectionOk = false;
|
||||
try
|
||||
{
|
||||
// in primis chiudo driver...
|
||||
if (driver != null)
|
||||
//if (driver != null && driver.WindowHandles.Count > 0)
|
||||
{
|
||||
driver.Quit();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Eccezione in tryDisconnect");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid)
|
||||
/// </summary>
|
||||
public override void processOverride()
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
driver.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -274,6 +242,13 @@ namespace IOB_WIN
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid)
|
||||
/// </summary>
|
||||
public override void processOverride()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua lettura semafori principale
|
||||
/// <paramref name="currDispData">Parametri da aggiornare x display in form</paramref>
|
||||
@@ -328,41 +303,88 @@ namespace IOB_WIN
|
||||
currDispData.semIn = Semaforo.SR;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Processo stati unknown...
|
||||
/// </summary>
|
||||
/// <param name="cKey"></param>
|
||||
private void processUnknStatus(string cKey)
|
||||
|
||||
public override void startAdapter(bool resetQueue)
|
||||
{
|
||||
// cerco se avevo già una key nella dictionary...
|
||||
if (freqUnknStatus.ContainsKey(cKey))
|
||||
// in primis RICARICO conf specifica...
|
||||
reloadAdapterConf();
|
||||
// continuo con start...
|
||||
base.startAdapter(resetQueue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override x chiusura driver...
|
||||
/// </summary>
|
||||
/// <param name="tryRestart"></param>
|
||||
/// <param name="forceDequeue"></param>
|
||||
public override void stopAdapter(bool tryRestart, bool forceDequeue)
|
||||
{
|
||||
try
|
||||
{
|
||||
freqUnknStatus[cKey]++;
|
||||
// se è 1 ogni 100 (%100, resto ==1) --> loggo...
|
||||
if (freqUnknStatus[cKey] % 100 == 1)
|
||||
// in primis chiudo driver...
|
||||
if (driver != null)
|
||||
{
|
||||
lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey} | freq: {freqUnknStatus[cKey]}");
|
||||
// accodo come invio di tipo FLOG...
|
||||
string sVal = string.Format("[UnknStatus] {0}, freq: {1}", cKey, freqUnknStatus);
|
||||
// chiamo accodamento...
|
||||
accodaFLog(sVal, qEncodeFLog("UnknStatus", sVal));
|
||||
driver.Quit();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Eccezione in tryDisconnect");
|
||||
}
|
||||
// continuo
|
||||
base.stopAdapter(tryRestart, forceDequeue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connessione
|
||||
/// </summary>
|
||||
public override void tryConnect()
|
||||
{
|
||||
// controllo ping --> segno connected...
|
||||
connectionOk = (testPingMachine == IPStatus.Success);
|
||||
if (connectionOk)
|
||||
{
|
||||
try
|
||||
{
|
||||
//var t = TaskEx.Run(() => startDriver());
|
||||
//t.Wait();
|
||||
// modalità sincrona
|
||||
startDriver();
|
||||
lgInfo("Completato start driver");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Eccezione in tryConnect");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// creo chiave con freq = 1
|
||||
freqUnknStatus.Add(cKey, 1);
|
||||
// log iniziale
|
||||
lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey}");
|
||||
// aspetto prima di riprovare...
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
/// <summary>
|
||||
/// Disconnessione
|
||||
/// </summary>
|
||||
public override void tryDisconnect()
|
||||
{
|
||||
driver.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
connectionOk = false;
|
||||
try
|
||||
{
|
||||
// in primis chiudo driver...
|
||||
if (driver != null)
|
||||
//if (driver != null && driver.WindowHandles.Count > 0)
|
||||
{
|
||||
driver.Quit();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Eccezione in tryDisconnect");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ using System.Net.NetworkInformation;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
|
||||
+36
-31
@@ -3,39 +3,44 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class Objects
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe di estensione x oggetti DataItems con struttura e valori
|
||||
/// </summary>
|
||||
public class MtcDataItemExt : MTConnect.MTConnectDevices.DataItem
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Valore (in sec) del periodo di downsampling (0 --> NON usato)
|
||||
/// </summary>
|
||||
public int samplePeriod { get; set; } = 60;
|
||||
|
||||
/// <summary>
|
||||
/// Classe di estensione x oggetti DataItems con struttura e valori
|
||||
/// </summary>
|
||||
public class MtcDataItemExt : MTConnect.MTConnectDevices.DataItem
|
||||
{
|
||||
/// <summary>
|
||||
/// UUID univoco dell'oggetto --> flusso
|
||||
/// </summary>
|
||||
public string uid { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Valore Registrato in formato stringa
|
||||
/// </summary>
|
||||
public string value { get; set; } = "";
|
||||
/// <summary>
|
||||
/// Timestamp data-ora evento registrato
|
||||
/// </summary>
|
||||
public DateTime valueTimestamp { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// Valore soglia DeadBand (0 --> non usata)
|
||||
/// </summary>
|
||||
public double thresholdDeadBand { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// Valore (in sec) del periodo di downsampling (0 --> NON usato)
|
||||
/// </summary>
|
||||
public int samplePeriod { get; set; } = 60;
|
||||
}
|
||||
/// <summary>
|
||||
/// Valore soglia DeadBand (0 --> non usata)
|
||||
/// </summary>
|
||||
public double thresholdDeadBand { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// UUID univoco dell'oggetto --> flusso
|
||||
/// </summary>
|
||||
public string uid { get; set; } = "";
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Valore Registrato in formato stringa
|
||||
/// </summary>
|
||||
public string value { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Timestamp data-ora evento registrato
|
||||
/// </summary>
|
||||
public DateTime valueTimestamp { get; set; } = DateTime.Now;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class Objects
|
||||
{
|
||||
}
|
||||
}
|
||||
+23
-19
@@ -1,25 +1,29 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Punto di ingresso principale dell'applicazione.
|
||||
/// <paramref name="args">Parametri di avvio</paramref>
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
internal static class Program
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
try
|
||||
{
|
||||
Application.Run(new MainForm(args));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Punto di ingresso principale dell'applicazione.
|
||||
/// <paramref name="args">Parametri di avvio</paramref>
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
try
|
||||
{
|
||||
Application.Run(new MainForm(args));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace IOB_WIN.Properties {
|
||||
namespace IOB_WIN_NEXT.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace IOB_WIN.Properties {
|
||||
namespace IOB_WIN_NEXT.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
|
||||
Generated
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
partial class TestForm
|
||||
{
|
||||
|
||||
@@ -8,13 +8,17 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public partial class TestForm : Form
|
||||
{
|
||||
public TestForm()
|
||||
public partial class TestForm : Form
|
||||
{
|
||||
InitializeComponent();
|
||||
#region Public Constructors
|
||||
|
||||
public TestForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+112
-68
@@ -5,87 +5,34 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Definizione area memoria SIEMENS
|
||||
/// </summary>
|
||||
public class memAreaSiemens
|
||||
{
|
||||
/// <summary>
|
||||
/// Indice DB
|
||||
/// </summary>
|
||||
public int DbNum = 0;
|
||||
/// <summary>
|
||||
/// Tipo Memoria (DBD, DBW...)
|
||||
/// </summary>
|
||||
public string tipoMem = "";
|
||||
/// <summary>
|
||||
/// Indice partenza memoria (es DBD0 --> 0)
|
||||
/// </summary>
|
||||
public int indiceMem = 0;
|
||||
/// <summary>
|
||||
/// Inizializza da un formato stringa
|
||||
/// </summary>
|
||||
/// <param name="strFormat"></param>
|
||||
public memAreaSiemens(string strFormat)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(strFormat))
|
||||
{
|
||||
string[] memComp = strFormat.Split('.');
|
||||
int.TryParse(memComp[0].Replace("DB", ""), out DbNum);
|
||||
//tipoMem = memComp[1].Substring(2, 1);
|
||||
tipoMem = "";
|
||||
for (int i = 0; i < memComp[1].Length; i++)
|
||||
{
|
||||
if(char.IsLetter(memComp[1][i]))
|
||||
{
|
||||
tipoMem += memComp[1][i];
|
||||
}
|
||||
}
|
||||
// rimuovo DB iniziale..
|
||||
tipoMem = tipoMem.Replace("DB", "");
|
||||
// ciclo x trovare SOLO stringa
|
||||
int.TryParse(memComp[1].Replace("DB", "").Replace(tipoMem, ""), out indiceMem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Definizione area memoria FANUC
|
||||
/// </summary>
|
||||
public class memAreaFanuc
|
||||
{
|
||||
/// <summary>
|
||||
/// Nome area memoria
|
||||
/// </summary>
|
||||
public string areaName;
|
||||
/// <summary>
|
||||
/// Indice inizio array
|
||||
/// </summary>
|
||||
public int startIdx;
|
||||
/// <summary>
|
||||
/// Dimensione array memoria
|
||||
/// </summary>
|
||||
public int arraySize;
|
||||
}
|
||||
/// <summary>
|
||||
/// Definizione indirizzo memoria FANUC
|
||||
/// </summary>
|
||||
public class memAddressFanuc
|
||||
{
|
||||
/// <summary>
|
||||
/// Tipo memoria
|
||||
/// </summary>
|
||||
public FANUC.MemType mType;
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Posizione memoria
|
||||
/// </summary>
|
||||
public int mPos;
|
||||
|
||||
/// <summary>
|
||||
/// Tipo memoria
|
||||
/// </summary>
|
||||
public FANUC.MemType mType;
|
||||
|
||||
/// <summary>
|
||||
/// Tipo valore
|
||||
/// </summary>
|
||||
public string vType;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Inizializza da un formato stringa
|
||||
/// </summary>
|
||||
@@ -100,48 +47,63 @@ namespace IOB_WIN
|
||||
case "A":
|
||||
mType = FANUC.MemType.A;
|
||||
break;
|
||||
|
||||
case "C":
|
||||
mType = FANUC.MemType.C;
|
||||
break;
|
||||
|
||||
case "CM":
|
||||
mType = FANUC.MemType.CM;
|
||||
break;
|
||||
|
||||
case "D":
|
||||
mType = FANUC.MemType.D;
|
||||
break;
|
||||
|
||||
case "E":
|
||||
mType = FANUC.MemType.E;
|
||||
break;
|
||||
|
||||
case "F":
|
||||
mType = FANUC.MemType.F;
|
||||
break;
|
||||
|
||||
case "G":
|
||||
mType = FANUC.MemType.G;
|
||||
break;
|
||||
|
||||
case "K":
|
||||
mType = FANUC.MemType.K;
|
||||
break;
|
||||
|
||||
case "M":
|
||||
mType = FANUC.MemType.M;
|
||||
break;
|
||||
|
||||
case "N":
|
||||
mType = FANUC.MemType.N;
|
||||
break;
|
||||
|
||||
case "R":
|
||||
mType = FANUC.MemType.R;
|
||||
break;
|
||||
|
||||
case "T":
|
||||
mType = FANUC.MemType.T;
|
||||
break;
|
||||
|
||||
case "X":
|
||||
mType = FANUC.MemType.X;
|
||||
break;
|
||||
|
||||
case "Y":
|
||||
mType = FANUC.MemType.Y;
|
||||
break;
|
||||
|
||||
case "Z":
|
||||
mType = FANUC.MemType.Z;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -149,5 +111,87 @@ namespace IOB_WIN
|
||||
vType = memComp[2];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Definizione area memoria FANUC
|
||||
/// </summary>
|
||||
public class memAreaFanuc
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Nome area memoria
|
||||
/// </summary>
|
||||
public string areaName;
|
||||
|
||||
/// <summary>
|
||||
/// Dimensione array memoria
|
||||
/// </summary>
|
||||
public int arraySize;
|
||||
|
||||
/// <summary>
|
||||
/// Indice inizio array
|
||||
/// </summary>
|
||||
public int startIdx;
|
||||
|
||||
#endregion Public Fields
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Definizione area memoria SIEMENS
|
||||
/// </summary>
|
||||
public class memAreaSiemens
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Indice DB
|
||||
/// </summary>
|
||||
public int DbNum = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Indice partenza memoria (es DBD0 --> 0)
|
||||
/// </summary>
|
||||
public int indiceMem = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tipo Memoria (DBD, DBW...)
|
||||
/// </summary>
|
||||
public string tipoMem = "";
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Inizializza da un formato stringa
|
||||
/// </summary>
|
||||
/// <param name="strFormat"></param>
|
||||
public memAreaSiemens(string strFormat)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(strFormat))
|
||||
{
|
||||
string[] memComp = strFormat.Split('.');
|
||||
int.TryParse(memComp[0].Replace("DB", ""), out DbNum);
|
||||
//tipoMem = memComp[1].Substring(2, 1);
|
||||
tipoMem = "";
|
||||
for (int i = 0; i < memComp[1].Length; i++)
|
||||
{
|
||||
if (char.IsLetter(memComp[1][i]))
|
||||
{
|
||||
tipoMem += memComp[1][i];
|
||||
}
|
||||
}
|
||||
// rimuovo DB iniziale..
|
||||
tipoMem = tipoMem.Replace("DB", "");
|
||||
// ciclo x trovare SOLO stringa
|
||||
int.TryParse(memComp[1].Replace("DB", "").Replace(tipoMem, ""), out indiceMem);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,60 @@
|
||||
using S7.Net;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementazione classe connessione SIEMENS con S7.net,
|
||||
/// comprensiva dei parametri delle aree di memoria
|
||||
/// </summary>
|
||||
public class connParamS7
|
||||
{
|
||||
/// <summary>
|
||||
/// Indirizzo IP del PLC
|
||||
/// Implementazione classe connessione SIEMENS con S7.net,
|
||||
/// comprensiva dei parametri delle aree di memoria
|
||||
/// </summary>
|
||||
public string ipAdrr = "";
|
||||
/// <summary>
|
||||
/// Tipo CPU Siemens
|
||||
/// </summary>
|
||||
public CpuType tipoCpu = CpuType.S7300;
|
||||
/// <summary>
|
||||
/// Slot comunicazione
|
||||
/// </summary>
|
||||
public short slot = 0;
|
||||
/// <summary>
|
||||
/// Rack comunicazione
|
||||
/// </summary>
|
||||
public short rack = 0;
|
||||
/// <summary>
|
||||
/// Timeout ping
|
||||
/// </summary>
|
||||
public int pingMsTimeout = 250;
|
||||
/// <summary>
|
||||
/// Base area x lettura
|
||||
/// </summary>
|
||||
public string memAddrRead = "";
|
||||
/// <summary>
|
||||
/// Base area x scrittura
|
||||
/// </summary>
|
||||
public string memAddrWrite = "";
|
||||
/// <summary>
|
||||
/// Size memoria lettura
|
||||
/// </summary>
|
||||
public int memSizeRead = 0;
|
||||
/// <summary>
|
||||
/// Size memoria scrittura
|
||||
/// </summary>
|
||||
public int memSizeWrite = 0;
|
||||
}
|
||||
}
|
||||
public class connParamS7
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Indirizzo IP del PLC
|
||||
/// </summary>
|
||||
public string ipAdrr = "";
|
||||
|
||||
/// <summary>
|
||||
/// Base area x lettura
|
||||
/// </summary>
|
||||
public string memAddrRead = "";
|
||||
|
||||
/// <summary>
|
||||
/// Base area x scrittura
|
||||
/// </summary>
|
||||
public string memAddrWrite = "";
|
||||
|
||||
/// <summary>
|
||||
/// Size memoria lettura
|
||||
/// </summary>
|
||||
public int memSizeRead = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Size memoria scrittura
|
||||
/// </summary>
|
||||
public int memSizeWrite = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Timeout ping
|
||||
/// </summary>
|
||||
public int pingMsTimeout = 250;
|
||||
|
||||
/// <summary>
|
||||
/// Rack comunicazione
|
||||
/// </summary>
|
||||
public short rack = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Slot comunicazione
|
||||
/// </summary>
|
||||
public short slot = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Tipo CPU Siemens
|
||||
/// </summary>
|
||||
public CpuType tipoCpu = CpuType.S7300;
|
||||
|
||||
#endregion Public Fields
|
||||
}
|
||||
}
|
||||
+130
-112
@@ -2,118 +2,136 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class utils : IOB_UT.baseUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// folder archiviazione dati configurazione (DATA\CONF)
|
||||
/// </summary>
|
||||
public static string resxDir
|
||||
public class utils : IOB_UT.baseUtils
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("resxPath"));
|
||||
}
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// folder archiviazione dati configurazione (DATA\CONF)
|
||||
/// </summary>
|
||||
public static string confDir
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataConfPath"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// folder archiviazione dati storici giornalieri (DATA\DAT)
|
||||
/// </summary>
|
||||
public static string dataDatDir
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataDatPath"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// folder archiviazione dati (DATA)
|
||||
/// </summary>
|
||||
public static string dataDir
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataPath"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File icona default
|
||||
/// </summary>
|
||||
public static string defIconFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\SteamWare.ico", utils.resxDir);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File persistenza generale
|
||||
/// </summary>
|
||||
public static string defPersLayerFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("defaultPersLayerFile"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// file persistenza generale
|
||||
/// </summary>
|
||||
public static string histPersLayerFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File configurazione default x MAIN
|
||||
/// </summary>
|
||||
public static string mainConfFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", utils.confDir, utils.CRS("mainConfFile"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// folder archiviazione dati configurazione (DATA\CONF)
|
||||
/// </summary>
|
||||
public static string resxDir
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("resxPath"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File SimData x simulazione deterministica
|
||||
/// </summary>
|
||||
public static string simDataFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("simDataFile"));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// file persistenza generale data attuale ANTICIPATA di xx giorni
|
||||
/// </summary>
|
||||
/// <param name="numDD">num DD di anticipo</param>
|
||||
/// <returns></returns>
|
||||
public static string prevPersLayerFile(int numDD)
|
||||
{
|
||||
return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now.AddDays(-numDD));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converte un array di caratteri in una stringa valida (ovvero SOLO numeri/lettere)
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public static string purgedChar2String(char[] input)
|
||||
{
|
||||
string answ = new string(input.Where(c => char.IsLetter(c) || char.IsDigit(c)).ToArray());
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
/// <summary>
|
||||
/// folder archiviazione dati configurazione (DATA\CONF)
|
||||
/// </summary>
|
||||
public static string confDir
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataConfPath"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// folder archiviazione dati storici giornalieri (DATA\DAT)
|
||||
/// </summary>
|
||||
public static string dataDatDir
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataDatPath"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// folder archiviazione dati (DATA)
|
||||
/// </summary>
|
||||
public static string dataDir
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataPath"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// File configurazione default x MAIN
|
||||
/// </summary>
|
||||
public static string mainConfFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", utils.confDir, utils.CRS("mainConfFile"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// File SimData x simulazione deterministica
|
||||
/// </summary>
|
||||
public static string simDataFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("simDataFile"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// File persistenza generale
|
||||
/// </summary>
|
||||
public static string defPersLayerFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("defaultPersLayerFile"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// file persistenza generale
|
||||
/// </summary>
|
||||
public static string histPersLayerFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// file persistenza generale data attuale ANTICIPATA di xx giorni
|
||||
/// </summary>
|
||||
/// <param name="numDD">num DD di anticipo</param>
|
||||
/// <returns></returns>
|
||||
public static string prevPersLayerFile(int numDD)
|
||||
{
|
||||
return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now.AddDays(-numDD));
|
||||
}
|
||||
/// <summary>
|
||||
/// File icona default
|
||||
/// </summary>
|
||||
public static string defIconFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\SteamWare.ico", utils.resxDir);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Converte un array di caratteri in una stringa valida (ovvero SOLO numeri/lettere)
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public static string purgedChar2String(char[] input)
|
||||
{
|
||||
string answ = new string(input.Where(c => char.IsLetter(c) || char.IsDigit(c)).ToArray());
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user