Merge branch 'FeatureOpcUaBaglietto' of https://gitlab.steamware.net/steamware/Mapo-IOB-WIN into FeatureOpcUaBaglietto
This commit is contained in:
+1
-1
@@ -93,7 +93,7 @@ variables:
|
||||
$Target = "Releases\" + $CI_COMMIT_BRANCH + "\" + $env:APP_NAME + ".zip"
|
||||
cd "$env:APP_NAME\bin\"
|
||||
$Source = "*"
|
||||
7zip a -tzip $Target $Source -xr!DATA
|
||||
7zip a -tzip $Target $Source -xr!DATA\CONF
|
||||
echo "called ZIP $Source --> $Target"
|
||||
|
||||
# helper creazione hash files
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace IOB_UT_NEXT
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -253,9 +252,6 @@ namespace IOB_UT_NEXT
|
||||
|
||||
#region Private Methods
|
||||
|
||||
|
||||
// INI filename
|
||||
|
||||
/// <summary>
|
||||
/// GetPrivateProfileInt: import windows dll functions
|
||||
/// </summary>
|
||||
|
||||
@@ -55,6 +55,11 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
public DateTime lastUpdate { get; set; } = DateTime.Now.AddDays(-1);
|
||||
|
||||
/// <summary>
|
||||
/// Valore minimo da considerare come delta secondi x indicare variazione sui dati temporali
|
||||
/// </summary>
|
||||
public int minDeltaSec { get; set; } = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Status del SINGOLO IOB
|
||||
/// </summary>
|
||||
@@ -105,11 +110,6 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
public Dictionary<string, string> setupParams { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Valore minimo da considerare come delta secondi x indicare variazione sui dati temporali
|
||||
/// </summary>
|
||||
public int minDeltaSec { get; set; } = 5;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -65,8 +65,6 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
public class BaseRawTransf
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Data-Ora riferimento (x ordinamento fifo)
|
||||
/// </summary>
|
||||
@@ -104,9 +102,7 @@ namespace IOB_UT_NEXT
|
||||
this.mesContent = mesContent;
|
||||
this.mesType = mesType;
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
@@ -813,7 +809,7 @@ namespace IOB_UT_NEXT
|
||||
public int Period { get; set; } = 60;
|
||||
|
||||
/// <summary>
|
||||
/// UM parametro, impiegato anche x conversione (es epoch --> datetime)
|
||||
/// UM parametro, impiegato anche x conversione (es epoch --> datetime)
|
||||
/// </summary>
|
||||
public string UM { get; set; } = "";
|
||||
|
||||
|
||||
@@ -26,7 +26,9 @@ namespace IOB_UT_NEXT
|
||||
/// <param name="codServer">IP/nome server</param>
|
||||
/// <param name="codIob">Cod IOB</param>
|
||||
/// <param name="tipoIob">Tipo di IOB</param>
|
||||
/// <param name="minDeltaS">Minima differenza in secondi x considerare variazione dati DataOra</param>
|
||||
/// <param name="minDeltaS">
|
||||
/// Minima differenza in secondi x considerare variazione dati DataOra
|
||||
/// </param>
|
||||
public RedisIobCache(string codServer, string codIob, string tipoIob, int minDeltaS)
|
||||
{
|
||||
// init dati di base...
|
||||
@@ -1105,16 +1107,16 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
protected string currIobType = "ND";
|
||||
|
||||
/// <summary>
|
||||
/// Hash REDIS x dati IOB
|
||||
/// </summary>
|
||||
protected string redIobKey = "";
|
||||
|
||||
/// <summary>
|
||||
/// Nome del channel REDIS x dati IOB
|
||||
/// </summary>
|
||||
protected string redIobChannel = "IobChannel";
|
||||
|
||||
/// <summary>
|
||||
/// Hash REDIS x dati IOB
|
||||
/// </summary>
|
||||
protected string redIobKey = "";
|
||||
|
||||
/// <summary>
|
||||
/// Hash REDIS x dati server
|
||||
/// </summary>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_UT_NEXT
|
||||
{
|
||||
public class TimeUtils
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
public static DateTime epochConvert(double epoch)
|
||||
{
|
||||
DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, 0); //from start epoch time
|
||||
DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, 0); //from start epoch time
|
||||
date = date.AddSeconds(epoch);
|
||||
return date;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-3
@@ -234,6 +234,11 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
public List<string> fluxLogVeto { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Indica se il controllo di ping sia OK (x controllo prima della connessione)
|
||||
/// </summary>
|
||||
public bool forcePingOk { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Array degli elementi di traduzione item
|
||||
/// </summary>
|
||||
@@ -280,10 +285,14 @@ namespace IOB_UT_NEXT
|
||||
public bool pingAsPowerOn { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Indica se il controllo di ping sia OK (x controllo prima della connessione)
|
||||
/// Indica se venga richiesta invio del run mode
|
||||
/// </summary>
|
||||
public bool forcePingOk { get; set; } = false;
|
||||
|
||||
public bool runModeSend { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Indica se venga richiesta traduzione del run mode
|
||||
/// </summary>
|
||||
public bool runModeTrad { get; set; } = false;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
@@ -41,15 +41,15 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
public static bool MPIO_Online = false;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Oggetto connessione REDIS
|
||||
/// </summary>
|
||||
public static RedisIobCache redisMan = new RedisIobCache();
|
||||
public static RedisIobCache redisMan = new RedisIobCache();
|
||||
#endif
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
|
||||
+149
-146
@@ -13,15 +13,6 @@ namespace IOB_UT_NEXT
|
||||
/// </summary>
|
||||
public class fileMover
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// path di lavoro dei metodi leggi/scrivi
|
||||
/// </summary>
|
||||
protected string _workPath;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +33,7 @@ namespace IOB_UT_NEXT
|
||||
/// inizializza il metodo alla cartella indicata
|
||||
/// </summary>
|
||||
/// <param name="_path"></param>
|
||||
/// <param name="_log">non serve +... x retrocompatibilità...</param>
|
||||
/// <param name="_log">non serve +... x retrocompatibilit�...</param>
|
||||
public fileMover(string _path, string _log)
|
||||
{
|
||||
setDirs(_path);
|
||||
@@ -59,111 +50,6 @@ namespace IOB_UT_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// cerca di caricare la directoryInfo o da httpcontext-application re-position o direttamente come workpath
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private DirectoryInfo getDirectoryInfo()
|
||||
{
|
||||
DirectoryInfo _di;
|
||||
_di = new DirectoryInfo(_workPath);
|
||||
return _di;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera oggetto DirInfo da path
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
private DirectoryInfo getDirectoryInfo(string path)
|
||||
{
|
||||
DirectoryInfo _di = new DirectoryInfo(path);
|
||||
return _di;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente come workpath + nomefile
|
||||
/// </summary>
|
||||
/// <param name="_fullPath">path completo file</param>
|
||||
/// <returns></returns>
|
||||
private FileInfo getFileInfoByName(string _fullPath)
|
||||
{
|
||||
FileInfo _fi;
|
||||
_fi = new FileInfo(_fullPath);
|
||||
return _fi;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente come workpath + nomefile
|
||||
/// </summary>
|
||||
/// <param name="_path">cartella file</param>
|
||||
/// <param name="_nomeFile">nome file</param>
|
||||
/// <returns></returns>
|
||||
private FileInfo getFileInfoByName(string _path, string _nomeFile)
|
||||
{
|
||||
FileInfo _fi;
|
||||
_fi = new FileInfo(_path + "\\" + _nomeFile);
|
||||
return _fi;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// setta le directory
|
||||
/// </summary>
|
||||
/// <param name="_path"></param>
|
||||
private void setDirs(string _path)
|
||||
{
|
||||
_workPath = _path;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// converte un byte[] in una string
|
||||
/// </summary>
|
||||
/// <param name="_array"></param>
|
||||
/// <returns></returns>
|
||||
protected string byteToStr(byte[] _array)
|
||||
{
|
||||
System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding();
|
||||
return encod.GetString(_array);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// converte una string in un byte[]
|
||||
/// </summary>
|
||||
/// <param name="_val"></param>
|
||||
/// <returns></returns>
|
||||
protected byte[] strToByte(string _val)
|
||||
{
|
||||
System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding();
|
||||
return encod.GetBytes(_val);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// verifica esistenza directory ed eventualmente crea restituendo nome completo di "/" finale
|
||||
/// </summary>
|
||||
/// <param name="_path"></param>
|
||||
/// <returns></returns>
|
||||
protected string verDir(string _path)
|
||||
{
|
||||
DirectoryInfo di = getDirectoryInfo(_path);
|
||||
if (!di.Exists)
|
||||
{
|
||||
di.Create();
|
||||
}
|
||||
if (!_path.EndsWith("/") && !_path.EndsWith(@"\"))
|
||||
{
|
||||
_path += "/";
|
||||
}
|
||||
return _path;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -253,16 +139,15 @@ namespace IOB_UT_NEXT
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Legge i dati da uno stream fino a quando arriva alla fine.
|
||||
/// I dati sono restituiti come un byte[] array. un eccezione IOException è
|
||||
/// sollevata se una delle chiamate IO sottostanti fallisce.
|
||||
/// Legge i dati da uno stream fino a quando arriva alla fine. I dati sono restituiti come
|
||||
/// un byte[] array. Un eccezione IOException viene sollevata se una delle chiamate IO
|
||||
/// sottostanti fallisce.
|
||||
/// </summary>
|
||||
/// <param name="stream">Lo stream da cui leggere</param>
|
||||
/// <param name="initialLength">Lunghezza buffer iniziale (-1 = default 32k)</param>
|
||||
public static byte[] ReadFully(Stream stream, int initialLength)
|
||||
{
|
||||
// If we've been passed an unhelpful initial length, just
|
||||
// use 32K.
|
||||
// If we've been passed an unhelpful initial length, just use 32K.
|
||||
if (initialLength < 1)
|
||||
{
|
||||
initialLength = 32768;
|
||||
@@ -276,8 +161,7 @@ namespace IOB_UT_NEXT
|
||||
{
|
||||
read += chunk;
|
||||
|
||||
// If we've reached the end of our buffer, check to see if there's
|
||||
// any more information
|
||||
// If we've reached the end of our buffer, check to see if there's any more information
|
||||
if (read == buffer.Length)
|
||||
{
|
||||
int nextByte = stream.ReadByte();
|
||||
@@ -288,8 +172,7 @@ namespace IOB_UT_NEXT
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// Nope. Resize the buffer, put in the byte we've just
|
||||
// read, and continue
|
||||
// Nope. Resize the buffer, put in the byte we've just read, and continue
|
||||
byte[] newBuffer = new byte[buffer.Length * 2];
|
||||
Array.Copy(buffer, newBuffer, buffer.Length);
|
||||
newBuffer[read] = (byte)nextByte;
|
||||
@@ -513,6 +396,25 @@ namespace IOB_UT_NEXT
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina i file + vecchi di maxNumDays giorni
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void deleteOlderThan(int maxNumDays)
|
||||
{
|
||||
DirectoryInfo _di = checkDir();
|
||||
FileInfo[] _fis = _di.GetFiles();
|
||||
DateTime dateLimit = DateTime.Now.AddDays(-maxNumDays);
|
||||
try
|
||||
{
|
||||
_fis.Where(x => x.LastWriteTime < dateLimit).ToList().ForEach(x => x.Delete());
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Logging.Instance.Error($"Eccezione in deleteOlderThan{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// elimina il file + vecchio
|
||||
/// </summary>
|
||||
@@ -541,24 +443,6 @@ namespace IOB_UT_NEXT
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
/// <summary>
|
||||
/// Elimina i file + vecchi di maxNumDays giorni
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void deleteOlderThan(int maxNumDays)
|
||||
{
|
||||
DirectoryInfo _di = checkDir();
|
||||
FileInfo[] _fis = _di.GetFiles();
|
||||
DateTime dateLimit = DateTime.Now.AddDays(-maxNumDays);
|
||||
try
|
||||
{
|
||||
_fis.Where(x => x.LastWriteTime <dateLimit).ToList().ForEach(x => x.Delete());
|
||||
}
|
||||
catch(Exception exc)
|
||||
{
|
||||
Logging.Instance.Error($"Eccezione in deleteOlderThan{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// elenco dei files come array di oggetti FileInfo
|
||||
@@ -582,7 +466,7 @@ namespace IOB_UT_NEXT
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// elimina la directory di lavoro se è dir virtuale mappata
|
||||
/// elimina la directory di lavoro se � dir virtuale mappata
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool eliminaDir()
|
||||
@@ -852,7 +736,7 @@ namespace IOB_UT_NEXT
|
||||
/// imposta la dir di lavoro
|
||||
/// </summary>
|
||||
/// <param name="_path"></param>
|
||||
/// <param name="_log">non serve +... x retrocompatibilità...</param>
|
||||
/// <param name="_log">non serve +... x retrocompatibilit�...</param>
|
||||
public void setDirectory(string _path, string _log)
|
||||
{
|
||||
setDirs(_path);
|
||||
@@ -911,7 +795,8 @@ namespace IOB_UT_NEXT
|
||||
{
|
||||
s.SetLevel(5);
|
||||
byte[] buffer = new byte[4096];
|
||||
// effettuo una ricerca dei files corrispondenti al criterio regexp, e per ognuno effettuo inserimento in zipfile...
|
||||
// effettuo una ricerca dei files corrispondenti al criterio regexp, e per
|
||||
// ognuno effettuo inserimento in zipfile...
|
||||
FileInfo[] filesTrovati = elencoFiles_FI(regExp);
|
||||
ZipEntry entry;
|
||||
foreach (FileInfo _fi in filesTrovati)
|
||||
@@ -923,7 +808,8 @@ namespace IOB_UT_NEXT
|
||||
s.PutNextEntry(entry);
|
||||
using (FileStream fs = File.OpenRead(_fi.FullName))
|
||||
{
|
||||
// Using a fixed size buffer here makes no noticeable difference for output but keeps a lid on memory usage.
|
||||
// Using a fixed size buffer here makes no noticeable difference for
|
||||
// output but keeps a lid on memory usage.
|
||||
int sourceBytes;
|
||||
do
|
||||
{
|
||||
@@ -1026,5 +912,122 @@ namespace IOB_UT_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// path di lavoro dei metodi leggi/scrivi
|
||||
/// </summary>
|
||||
protected string _workPath;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// converte un byte[] in una string
|
||||
/// </summary>
|
||||
/// <param name="_array"></param>
|
||||
/// <returns></returns>
|
||||
protected string byteToStr(byte[] _array)
|
||||
{
|
||||
System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding();
|
||||
return encod.GetString(_array);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// converte una string in un byte[]
|
||||
/// </summary>
|
||||
/// <param name="_val"></param>
|
||||
/// <returns></returns>
|
||||
protected byte[] strToByte(string _val)
|
||||
{
|
||||
System.Text.ASCIIEncoding encod = new System.Text.ASCIIEncoding();
|
||||
return encod.GetBytes(_val);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// verifica esistenza directory ed eventualmente crea restituendo nome completo di "/" finale
|
||||
/// </summary>
|
||||
/// <param name="_path"></param>
|
||||
/// <returns></returns>
|
||||
protected string verDir(string _path)
|
||||
{
|
||||
DirectoryInfo di = getDirectoryInfo(_path);
|
||||
if (!di.Exists)
|
||||
{
|
||||
di.Create();
|
||||
}
|
||||
if (!_path.EndsWith("/") && !_path.EndsWith(@"\"))
|
||||
{
|
||||
_path += "/";
|
||||
}
|
||||
return _path;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// cerca di caricare la directoryInfo o da httpcontext-application re-position o
|
||||
/// direttamente come workpath
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private DirectoryInfo getDirectoryInfo()
|
||||
{
|
||||
DirectoryInfo _di;
|
||||
_di = new DirectoryInfo(_workPath);
|
||||
return _di;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera oggetto DirInfo da path
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
private DirectoryInfo getDirectoryInfo(string path)
|
||||
{
|
||||
DirectoryInfo _di = new DirectoryInfo(path);
|
||||
return _di;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente
|
||||
/// come workpath + nomefile
|
||||
/// </summary>
|
||||
/// <param name="_fullPath">path completo file</param>
|
||||
/// <returns></returns>
|
||||
private FileInfo getFileInfoByName(string _fullPath)
|
||||
{
|
||||
FileInfo _fi;
|
||||
_fi = new FileInfo(_fullPath);
|
||||
return _fi;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// cerca di caricare il fileinfo o da httpcontext-application re-position o direttamente
|
||||
/// come workpath + nomefile
|
||||
/// </summary>
|
||||
/// <param name="_path">cartella file</param>
|
||||
/// <param name="_nomeFile">nome file</param>
|
||||
/// <returns></returns>
|
||||
private FileInfo getFileInfoByName(string _path, string _nomeFile)
|
||||
{
|
||||
FileInfo _fi;
|
||||
_fi = new FileInfo(_path + "\\" + _nomeFile);
|
||||
return _fi;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// setta le directory
|
||||
/// </summary>
|
||||
/// <param name="_path"></param>
|
||||
private void setDirs(string _path)
|
||||
{
|
||||
_workPath = _path;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
+530
-530
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
@@ -15,7 +11,7 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
#region Public Methods
|
||||
|
||||
static public void UIThread(this Control control, Action code)
|
||||
public static void UIThread(this Control control, Action code)
|
||||
{
|
||||
if (control.InvokeRequired)
|
||||
{
|
||||
@@ -25,7 +21,7 @@ namespace IOB_WIN_NEXT
|
||||
code.Invoke();
|
||||
}
|
||||
|
||||
static public void UIThreadInvoke(this Control control, Action code)
|
||||
public static void UIThreadInvoke(this Control control, Action code)
|
||||
{
|
||||
if (control.InvokeRequired)
|
||||
{
|
||||
|
||||
@@ -58,6 +58,7 @@ ENABLE_DYN_DATA=FALSE
|
||||
FORCE_DYN_DATA=TRUE
|
||||
ENABLE_DATA_FILTER=TRUE
|
||||
ENABLE_CLI_RESTART=TRUE
|
||||
MAX_TRY_PING=3
|
||||
|
||||
|
||||
;NO_PING=FALSE
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
"keyPartReq": "",
|
||||
"keyPartId": "",
|
||||
"keyProgName": "",
|
||||
"keyRunMode": "",
|
||||
"keyRunMode": "PLC/DB231/Attivita",
|
||||
"pingAsPowerOn": true,
|
||||
"forcePingOk": false,
|
||||
"translRunMode": true,
|
||||
"condWork": [
|
||||
{
|
||||
"keyName": "PLC/DB13/Gen/Marcia_AUX",
|
||||
@@ -42,11 +43,26 @@
|
||||
},
|
||||
"condError": {
|
||||
"checkMode": "OR",
|
||||
"negateValue": true,
|
||||
"checkList": [
|
||||
{
|
||||
"keyName": "PLC/DB13/Gen/ComProfibusMessage",
|
||||
"targetValue": "0"
|
||||
"targetValue": "1"
|
||||
},
|
||||
{
|
||||
"keyName": "PLC/DB13/Gen/ComProfibusMessage",
|
||||
"targetValue": "3"
|
||||
},
|
||||
{
|
||||
"keyName": "PLC/DB13/Gen/Hydraulic_Unit",
|
||||
"targetValue": "3"
|
||||
},
|
||||
{
|
||||
"keyName": "PLC/DB13/Gen/Marcia_AUX",
|
||||
"targetValue": "1"
|
||||
},
|
||||
{
|
||||
"keyName": "PLC/DB13/Gen/Wheel_Fault",
|
||||
"targetValue": "3"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -56,7 +72,8 @@
|
||||
},
|
||||
"condWarmUpCoolDown": {
|
||||
"checkMode": "OR",
|
||||
"checkList": []
|
||||
"checkList": [],
|
||||
"negateValue": true
|
||||
},
|
||||
"condWarning": {
|
||||
"checkMode": "AND",
|
||||
@@ -71,7 +88,16 @@
|
||||
],
|
||||
"itemTranslation": {
|
||||
"fdovrd": "PATH FEED OVERRIDE",
|
||||
"rovrd": "PATH RAPID OVERRIDE"
|
||||
"rovrd": "PATH RAPID OVERRIDE",
|
||||
"RunMode_1": "Avvio Registrazione Ricetta",
|
||||
"RunMode_2": "Inizio Comando Traslazione",
|
||||
"RunMode_3": "Termine Comando Traslazione",
|
||||
"RunMode_4": "Inizio Comando Sterzatura",
|
||||
"RunMode_5": "Termine Comando Sterzatura",
|
||||
"RunMode_6": "Inizio Comando Movimento Carrelli",
|
||||
"RunMode_7": "Termine Comando Movimento Carrelli",
|
||||
"RunMode_8": "Inizio Comando Sollevamento",
|
||||
"RunMode_9": "Termine Comando Sollevamento"
|
||||
},
|
||||
"paramsEndThresh": {
|
||||
"InvDDone": 50
|
||||
|
||||
@@ -58,6 +58,7 @@ ENABLE_DYN_DATA=FALSE
|
||||
FORCE_DYN_DATA=TRUE
|
||||
ENABLE_DATA_FILTER=TRUE
|
||||
ENABLE_CLI_RESTART=TRUE
|
||||
MAX_TRY_PING=3
|
||||
|
||||
; conf parametri memoria READ/WRITE
|
||||
OPC_PARAM_CONF=FINASSI_OMP_01.json
|
||||
|
||||
@@ -40,7 +40,7 @@ CLI_INST=SteamWareSim
|
||||
;STARTLIST=GIACO_NWSE
|
||||
;STARTLIST=SIM_DP_01
|
||||
;STARTLIST=FINASSI_HELPI_01
|
||||
STARTLIST=FINASSI_OMP_01
|
||||
;STARTLIST=BAGLIETTO_CIMOLAI_01
|
||||
;STARTLIST=FINASSI_OMP_01
|
||||
STARTLIST=BAGLIETTO_CIMOLAI_01
|
||||
|
||||
MAXCNC=10
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public enum StartMode
|
||||
{
|
||||
|
||||
@@ -427,7 +427,7 @@
|
||||
<None Include="DATA\CONF\GT594.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="DATA\CONF\IobOpcUaClient.Config.xml">
|
||||
<None Include="DATA\IobOpcUaClient.Config.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Include="ExtLib\krcc.dll">
|
||||
|
||||
+23
-30
@@ -1,30 +1,10 @@
|
||||
using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobBeckhoff : IobGeneric
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected TcAdsClient AdsCli;
|
||||
|
||||
/// <summary>
|
||||
/// Veto controllo status x log...
|
||||
/// </summary>
|
||||
protected DateTime vetoCheckStatus = DateTime.Now;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
public List<string> dataVal = new List<string>();
|
||||
@@ -54,15 +34,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void AdsCli_ValueChanged(TcAdsClient sender, string key, string value)
|
||||
{
|
||||
lg.Info($"Monitored Value changed | sender: {sender} | key: {key} | value: {value}");
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -125,6 +96,8 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Override connessione
|
||||
/// </summary>
|
||||
public override void tryConnect()
|
||||
@@ -168,5 +141,25 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected TcAdsClient AdsCli;
|
||||
|
||||
/// <summary>
|
||||
/// Veto controllo status x log...
|
||||
/// </summary>
|
||||
protected DateTime vetoCheckStatus = DateTime.Now;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void AdsCli_ValueChanged(TcAdsClient sender, string key, string value)
|
||||
{
|
||||
lg.Info($"Monitored Value changed | sender: {sender} | key: {key} | value: {value}");
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -2,34 +2,14 @@
|
||||
using MapoSDK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobBeckhoffCpa : IobBeckhoff
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private string counterVar = "VarADS.BuoniLancio";
|
||||
private string setArtVar = "VarADS.NomeDisegnoRichiesto";
|
||||
private string setCommVar = "VarADS.NomeLancioRichiesto";
|
||||
private string setParamsVar = "VarADS.bCambioArticolo";
|
||||
private string setPzReqVar = "VarADS.nQuantitaRichiesta";
|
||||
private string statusVar = "VarADS.StatoMacchina";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int currStatus = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Estende l'init della classe base
|
||||
/// <param name="caller"></param>
|
||||
@@ -48,15 +28,12 @@ namespace IOB_WIN_NEXT
|
||||
counterVar = getOptPar("CPA_PZCOUNT");
|
||||
}
|
||||
|
||||
|
||||
if (getOptPar("ADD_VARS").ToLower() == "true")
|
||||
{
|
||||
// fixme conf var gestite ad eventi da json
|
||||
dataVal.Add(statusVar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (getOptPar("EARLY_CONNECT").ToLower() == "true")
|
||||
{
|
||||
tryConnect();
|
||||
@@ -69,22 +46,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void AdsCli_CountChanged(TcAdsClient sender, int newCount)
|
||||
{
|
||||
contapezziPLC = newCount;
|
||||
lg.Info($"Nuova lettura contapezzi | contapezziPLC: {contapezziPLC} | contapezziIOB: {contapezziIOB}");
|
||||
}
|
||||
|
||||
protected void AdsCli_StatusChanged(TcAdsClient sender, int newStatus)
|
||||
{
|
||||
currStatus = newStatus;
|
||||
lg.Info($"Status changed: {newStatus}");
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -304,6 +265,39 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int currStatus = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void AdsCli_CountChanged(TcAdsClient sender, int newCount)
|
||||
{
|
||||
contapezziPLC = newCount;
|
||||
lg.Info($"Nuova lettura contapezzi | contapezziPLC: {contapezziPLC} | contapezziIOB: {contapezziIOB}");
|
||||
}
|
||||
|
||||
protected void AdsCli_StatusChanged(TcAdsClient sender, int newStatus)
|
||||
{
|
||||
currStatus = newStatus;
|
||||
lg.Info($"Status changed: {newStatus}");
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private string counterVar = "VarADS.BuoniLancio";
|
||||
private string setArtVar = "VarADS.NomeDisegnoRichiesto";
|
||||
private string setCommVar = "VarADS.NomeLancioRichiesto";
|
||||
private string setParamsVar = "VarADS.bCambioArticolo";
|
||||
private string setPzReqVar = "VarADS.nQuantitaRichiesta";
|
||||
private string statusVar = "VarADS.StatoMacchina";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#if false
|
||||
public enum EnuStates //Stato Macchina
|
||||
{
|
||||
|
||||
@@ -5,10 +5,8 @@ using System.Collections.Generic;
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// This Configuration class is basically just a set of
|
||||
/// properties with a couple of static methods to manage
|
||||
/// the serialization to and deserialization from a
|
||||
/// simple XML file.
|
||||
/// This Configuration class is basically just a set of properties with a couple of static
|
||||
/// methods to manage the serialization to and deserialization from a simple XML file.
|
||||
///
|
||||
/// ref: http://www.cambiaresearch.com/articles/33/how-can-i-easily-manage-an-xml-configuration-file-in-dotnet
|
||||
/// </summary>
|
||||
@@ -63,6 +61,11 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
public int MAX_COUNTER_BLINK { get; set; } = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Minimo delta in sec x considerare variazioni info
|
||||
/// </summary>
|
||||
public int minDeltaSec { get; set; } = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Modello della macchina
|
||||
/// </summary>
|
||||
@@ -86,7 +89,7 @@ namespace IOB_WIN_NEXT
|
||||
/// <summary>
|
||||
/// Dati di conf del server MoonPro cui comunicare
|
||||
/// </summary>
|
||||
public serverMapo serverData { get; set; } = new serverMapo("127.0.0.1", "/", "/IOB/input/", "/IOB/flog/", "/IOB/ulog/", "/IOB", "/IOB/enabled/", "/sendReboot.aspx?idxMacchina=", "/IOB/getCurrOdlStart/","SteamWare","/IOB/forceSplitOdlFull", "/IOB/getIdlePeriod", "/IOB/rawTransfJson");
|
||||
public serverMapo serverData { get; set; } = new serverMapo("127.0.0.1", "/", "/IOB/input/", "/IOB/flog/", "/IOB/ulog/", "/IOB", "/IOB/enabled/", "/sendReboot.aspx?idxMacchina=", "/IOB/getCurrOdlStart/", "SteamWare", "/IOB/forceSplitOdlFull", "/IOB/getIdlePeriod", "/IOB/rawTransfJson");
|
||||
|
||||
/// <summary>
|
||||
/// Slot (Siemens S7)
|
||||
@@ -123,11 +126,6 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
public string versIOB { get; set; } = "0";
|
||||
|
||||
/// <summary>
|
||||
/// Minimo delta in sec x considerare variazioni info
|
||||
/// </summary>
|
||||
public int minDeltaSec { get; set; } = 2;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
@@ -241,30 +239,33 @@ namespace IOB_WIN_NEXT
|
||||
public string CMDFLOG { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// comando base x LOG di FLUSSO generico - salvataggio parametri extra sistema MAPO in modalità JSON payload come lista
|
||||
/// comando base x LOG di FLUSSO generico - salvataggio parametri extra sistema MAPO in
|
||||
/// modalità JSON payload come lista
|
||||
/// </summary>
|
||||
public string CMDFLOG_JSON { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// comando base x Raw Transf LOG - salvataggio valori generici in modalità JSON payload
|
||||
/// come lista
|
||||
/// </summary>
|
||||
public string CMDRAWTRANSF_JSON { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// comando base x comando reboot
|
||||
/// </summary>
|
||||
public string CMDREBO { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// comando base x USER LOG - salvataggio parametri extra sistema MAPO
|
||||
/// </summary>
|
||||
public string CMDULOG { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// comando base x Raw Transf LOG - salvataggio valori generici in modalità JSON payload come lista
|
||||
/// </summary>
|
||||
public string CMDRAWTRANSF_JSON { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// comando base x USER LOG - salvataggio parametri extra sistema MAPO in modalità JSON payload come lista
|
||||
/// comando base x USER LOG - salvataggio parametri extra sistema MAPO in modalità JSON
|
||||
/// payload come lista
|
||||
/// </summary>
|
||||
public string CMDULOG_JSON { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// comando base x comando reboot
|
||||
/// </summary>
|
||||
public string CMDREBO { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Indirizzo IP server
|
||||
/// </summary>
|
||||
|
||||
+970
-961
File diff suppressed because it is too large
Load Diff
+109
-115
@@ -1,16 +1,9 @@
|
||||
using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Chrome;
|
||||
using OpenQA.Selenium.Firefox;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
@@ -24,25 +17,6 @@ namespace IOB_WIN_NEXT
|
||||
*
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Cartella di base per interscambio
|
||||
/// </summary>
|
||||
protected string BaseDir = @"C:\Steamware";
|
||||
|
||||
/// <summary>
|
||||
/// Array di configurazione degli oggetti da cercare x decodifica e recupero info
|
||||
/// </summary>
|
||||
protected Dictionary<string, string> dataLocatorLUT;
|
||||
|
||||
/// <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>();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -58,95 +32,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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>
|
||||
/// Pulizia preliminare folder comunicazione
|
||||
/// </summary>
|
||||
internal virtual void cleanupFolder()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ricarica conf adapter...
|
||||
/// </summary>
|
||||
internal virtual void reloadAdapterConf()
|
||||
{
|
||||
#if false
|
||||
// init obj display
|
||||
newDisplayData currDispData = new newDisplayData();
|
||||
lgInfo("BEGIN reloadAdapterConf");
|
||||
// inizializzo LUT decodifica
|
||||
string jsonConf = getOptPar("LUT_CONF");
|
||||
if (!string.IsNullOrEmpty(jsonConf))
|
||||
{
|
||||
string jsonFullPath = $"{Application.StartupPath}/DATA/CONF/{jsonConf}";
|
||||
lgInfo($"Apertura file {jsonFullPath}");
|
||||
StreamReader reader = new StreamReader(jsonFullPath);
|
||||
string jsonData = reader.ReadToEnd();
|
||||
if (!string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
try
|
||||
{
|
||||
monitoredItems = JsonConvert.DeserializeObject<MonitoredItemsConf>(jsonData);
|
||||
// salvo baseUri
|
||||
baseDir = monitoredItems.SrvData.baseUri;
|
||||
lgInfo($"baseUri = {baseDir}");
|
||||
// imposto a zero la bitmap x riavvio!
|
||||
B_input = 0;
|
||||
// FORZO invio dati...
|
||||
accodaSigIN(ref currDispData);
|
||||
// loggo!
|
||||
lgInfo($"init input bitmap to zero: {B_input}");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Eccezione in decodifica conf json");
|
||||
}
|
||||
}
|
||||
reader.Dispose();
|
||||
}
|
||||
lgInfo("DONE reloadAdapterConf");
|
||||
raiseRefresh(currDispData);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void Dispose()
|
||||
@@ -358,5 +243,114 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Internal Methods
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia preliminare folder comunicazione
|
||||
/// </summary>
|
||||
internal virtual void cleanupFolder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ricarica conf adapter...
|
||||
/// </summary>
|
||||
internal virtual void reloadAdapterConf()
|
||||
{
|
||||
#if false
|
||||
// init obj display
|
||||
newDisplayData currDispData = new newDisplayData();
|
||||
lgInfo("BEGIN reloadAdapterConf");
|
||||
// inizializzo LUT decodifica
|
||||
string jsonConf = getOptPar("LUT_CONF");
|
||||
if (!string.IsNullOrEmpty(jsonConf))
|
||||
{
|
||||
string jsonFullPath = $"{Application.StartupPath}/DATA/CONF/{jsonConf}";
|
||||
lgInfo($"Apertura file {jsonFullPath}");
|
||||
StreamReader reader = new StreamReader(jsonFullPath);
|
||||
string jsonData = reader.ReadToEnd();
|
||||
if (!string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
try
|
||||
{
|
||||
monitoredItems = JsonConvert.DeserializeObject<MonitoredItemsConf>(jsonData);
|
||||
// salvo baseUri
|
||||
baseDir = monitoredItems.SrvData.baseUri;
|
||||
lgInfo($"baseUri = {baseDir}");
|
||||
// imposto a zero la bitmap x riavvio!
|
||||
B_input = 0;
|
||||
// FORZO invio dati...
|
||||
accodaSigIN(ref currDispData);
|
||||
// loggo!
|
||||
lgInfo($"init input bitmap to zero: {B_input}");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Eccezione in decodifica conf json");
|
||||
}
|
||||
}
|
||||
reader.Dispose();
|
||||
}
|
||||
lgInfo("DONE reloadAdapterConf");
|
||||
raiseRefresh(currDispData);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion Internal Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Cartella di base per interscambio
|
||||
/// </summary>
|
||||
protected string BaseDir = @"C:\Steamware";
|
||||
|
||||
/// <summary>
|
||||
/// Array di configurazione degli oggetti da cercare x decodifica e recupero info
|
||||
/// </summary>
|
||||
protected Dictionary<string, string> dataLocatorLUT;
|
||||
|
||||
/// <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>();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#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
|
||||
}
|
||||
}
|
||||
+493
-492
File diff suppressed because it is too large
Load Diff
+50
-44
@@ -2980,6 +2980,36 @@ namespace IOB_WIN_NEXT
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua salvataggio in LUT del valore ricevuto (valori string)
|
||||
/// - non serve calcolo medie o altro
|
||||
/// - accoda in out val e basta
|
||||
/// </summary>
|
||||
/// <param name="outVal">Array eventi da popolare</param>
|
||||
/// <param name="valore">valore da salvare</param>
|
||||
/// <param name="chiave">ID/chiave di riferimento</param>
|
||||
/// <returns></returns>
|
||||
public virtual void saveAlarmString(ref Dictionary<string, string> outVal, string valore, string chiave)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
//check obj preliminare
|
||||
if (outVal == null)
|
||||
{
|
||||
outVal = new Dictionary<string, string>();
|
||||
}
|
||||
// default invio: blindato a 120 sec (rivedere da conf?)
|
||||
int vetoSendAlarms = 120;
|
||||
// verifico se sia scaduto OVVERO variato rispetto a prima oppure oltre tempo
|
||||
bool scaduto = !LastTSSSend.ContainsKey(chiave) || (LastTSSSend[chiave].AddSeconds(vetoSendAlarms) < adesso);
|
||||
bool cambiato = !LastTSS.ContainsKey(chiave) || !LastTSS[chiave].Equals(valore);
|
||||
if (scaduto || cambiato)
|
||||
{
|
||||
outVal.Add(chiave, valore);
|
||||
LastTSS[chiave] = valore;
|
||||
LastTSSSend[chiave] = adesso;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// metodo dummy x salvataggio aree memoria conf x CN
|
||||
/// </summary>
|
||||
@@ -3031,36 +3061,6 @@ namespace IOB_WIN_NEXT
|
||||
LastTSVC[chiave] = valore;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua salvataggio in LUT del valore ricevuto (valori string)
|
||||
/// - non serve calcolo medie o altro
|
||||
/// - accoda in out val e basta
|
||||
/// </summary>
|
||||
/// <param name="outVal">Array eventi da popolare</param>
|
||||
/// <param name="valore">valore da salvare</param>
|
||||
/// <param name="chiave">ID/chiave di riferimento</param>
|
||||
/// <returns></returns>
|
||||
public virtual void saveAlarmString(ref Dictionary<string, string> outVal, string valore, string chiave)
|
||||
{
|
||||
DateTime adesso = DateTime.Now;
|
||||
//check obj preliminare
|
||||
if (outVal == null)
|
||||
{
|
||||
outVal = new Dictionary<string, string>();
|
||||
}
|
||||
// default invio: blindato a 120 sec (rivedere da conf?)
|
||||
int vetoSendAlarms = 120;
|
||||
// verifico se sia scaduto OVVERO variato rispetto a prima oppure oltre tempo
|
||||
bool scaduto = !LastTSSSend.ContainsKey(chiave) || (LastTSSSend[chiave].AddSeconds(vetoSendAlarms) < adesso);
|
||||
bool cambiato = !LastTSS.ContainsKey(chiave) || !LastTSS[chiave].Equals(valore);
|
||||
if (scaduto || cambiato)
|
||||
{
|
||||
outVal.Add(chiave, valore);
|
||||
LastTSS[chiave] = valore;
|
||||
LastTSSSend[chiave] = adesso;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua salvataggio in LUT del valore ricevuto (valori string)
|
||||
/// - non serve calcolo medie o altro
|
||||
@@ -3826,6 +3826,21 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
protected int demFactDynData = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Boolean x indicare contapezzi disabilitato forzatamente da IOB
|
||||
/// </summary>
|
||||
protected bool disablePzCounteByIob = false;
|
||||
|
||||
/// <summary>
|
||||
/// Boolean x indicare contapezzi abilitato a livello di conf apoplicazione
|
||||
/// </summary>
|
||||
protected bool enablePzCountByApp = true;
|
||||
|
||||
/// <summary>
|
||||
/// Boolean x indicare contapezzi abilitato forzatamente da IOB
|
||||
/// </summary>
|
||||
protected bool enablePzCountByIob = true;
|
||||
|
||||
/// <summary>
|
||||
/// Array dei contatori x segnali blinking
|
||||
/// </summary>
|
||||
@@ -3896,6 +3911,11 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
protected int maxSendErrors = utils.CRI("maxSendErrors");
|
||||
|
||||
/// <summary>
|
||||
/// Numero massimo di tentativi x test ping preliminare
|
||||
/// </summary>
|
||||
protected int maxTryPing = 1;
|
||||
|
||||
/// <summary>
|
||||
/// indica se serva refresh parametri e quindi PLC...
|
||||
/// </summary>
|
||||
@@ -3942,20 +3962,6 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
protected int watchDogPeriod = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Boolean x indicare contapezzi abilitato a livello di conf apoplicazione
|
||||
/// </summary>
|
||||
protected bool enablePzCountByApp = true;
|
||||
|
||||
/// <summary>
|
||||
/// Boolean x indicare contapezzi abilitato forzatamente da IOB
|
||||
/// </summary>
|
||||
protected bool enablePzCountByIob = true;
|
||||
/// <summary>
|
||||
/// Boolean x indicare contapezzi disabilitato forzatamente da IOB
|
||||
/// </summary>
|
||||
protected bool disablePzCounteByIob = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
@@ -38,7 +38,6 @@ namespace IOB_WIN_NEXT
|
||||
string SyncStatePwd = getOptPar("SyncStatePwd");
|
||||
string SyncStateCTout = getOptPar("SyncStateCTout");
|
||||
|
||||
|
||||
string connSyncState = $"data source={SyncStateDb};initial catalog=MoonPro_ISF;persist security info=True;user id={SyncStateUser};password={SyncStatePwd};MultipleActiveResultSets=True;App=IOB-WIN-NEXT";
|
||||
|
||||
// gestione command timeout da https://erikej.github.io/sqlclient/2020/10/26/sqlclient-commandtimeout-preview.html
|
||||
@@ -47,7 +46,6 @@ namespace IOB_WIN_NEXT
|
||||
connSyncState = $"{connSyncState};Command Timeout={SyncStateCTout}";
|
||||
}
|
||||
|
||||
|
||||
// eccezione: NON TROVA EntityFramework 6.0.0 o successivo... why?!?
|
||||
dbProxy = new DbProxy(connSyncState);
|
||||
|
||||
|
||||
+110
-110
@@ -90,7 +90,6 @@ namespace IOB_WIN_NEXT
|
||||
taskVal = executeSetSupplier(cmdArgs);
|
||||
break;
|
||||
|
||||
|
||||
case taskType.setParameter:
|
||||
// richiedo da URL i parametri WRITE da popolare
|
||||
lgInfo("Chiamata setParameter --> processMemWriteRequests");
|
||||
@@ -129,114 +128,6 @@ namespace IOB_WIN_NEXT
|
||||
return taskDone;
|
||||
}
|
||||
|
||||
private string executeSetSupplier(string cmdArgs)
|
||||
{
|
||||
string taskVal;
|
||||
// loggo i parametri ricevuti da popolare
|
||||
lgInfo($"Chiamata setSupplier --> params payload: {cmdArgs}");
|
||||
// recupero batch corrente x preselezionare i dati guid layout/varietà...
|
||||
var currBatch = IcoelSizer.GetCurrentBatch();
|
||||
// recupero GUID x variety e layout di default
|
||||
var varGuid = currBatch[1].VarietyId;
|
||||
var layGuid = currBatch[1].LayoutId;
|
||||
// predispongo grower di default
|
||||
GrowerInfo GrowerData = new GrowerInfo();
|
||||
// le info sono una stringa separata da valore | di GrowerCode|GrowerName|varietyGuid|LayoutGuid;
|
||||
string[] reqParams = cmdArgs.Split('|');
|
||||
// se ho dati sistemo grower...
|
||||
if (reqParams.Length >= 2)
|
||||
{
|
||||
//GrowerData.GrowerCode = reqParams[0];
|
||||
//GrowerData.GrowerName = reqParams[1];
|
||||
// sistemo commenti
|
||||
var comments = new List<string>();
|
||||
comments.Add($"sent {DateTime.Now: yyyy.MM.dd HH:mm:ss}");
|
||||
comments.Add("Qty: no set");
|
||||
comments.Add("------------");
|
||||
//GrowerData.Comments = comments;
|
||||
|
||||
GrowerData = new GrowerInfo()
|
||||
{
|
||||
GrowerCode = reqParams[0],
|
||||
GrowerName = reqParams[1],
|
||||
Comments = comments
|
||||
};
|
||||
lgInfo($"Set grower data | GrowerCode: {GrowerData.GrowerCode} | GrowerName: {GrowerData.GrowerName}");
|
||||
}
|
||||
if (reqParams.Length >= 3)
|
||||
{
|
||||
Guid.TryParse(reqParams[2], out varGuid);
|
||||
lgInfo($"Set Variety data | VarGUID: {varGuid}");
|
||||
}
|
||||
if (reqParams.Length >= 4)
|
||||
{
|
||||
Guid.TryParse(reqParams[3], out layGuid);
|
||||
lgInfo($"Set Layout data | LayGUID: {layGuid}");
|
||||
}
|
||||
|
||||
// invio richiesta!!!
|
||||
IcoelSizer.EnqueueBatch(GrowerData, varGuid, layGuid);
|
||||
lgInfo($"Request sent!");
|
||||
|
||||
|
||||
|
||||
taskVal = $"REQUEST SET SUPPLIER | EnqueueBatch | GrowCode: {GrowerData.GrowerCode} | GrowName: {GrowerData.GrowerName} | Var: {varGuid} | Lay: {layGuid} ";
|
||||
// se restituiscce "" faccio altra prova...
|
||||
if (string.IsNullOrEmpty(taskVal))
|
||||
{
|
||||
// i parametri me li aspetto come stringa composta paramName|paramvalue
|
||||
if (cmdArgs.Contains("|"))
|
||||
{
|
||||
string[] paramsJob = cmdArgs.Split('|');
|
||||
taskVal = $"REQUEST SET PARAMETERS: {paramsJob[0]} --> {paramsJob[1]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {cmdArgs} doesnt contain pipe for splitting key/value";
|
||||
}
|
||||
}
|
||||
|
||||
return taskVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Metodo da overridare x scrivere DAVVERO i parametri sul PLC
|
||||
/// </summary>
|
||||
/// <param name="updatedPar"></param>
|
||||
protected override void plcWriteParams(ref List<objItem> updatedPar)
|
||||
{
|
||||
foreach (var item in updatedPar)
|
||||
{
|
||||
// cerco se sia setSupplier
|
||||
if (item.uid == "setSupplier")
|
||||
{
|
||||
string reqVal = !string.IsNullOrEmpty(item.reqValue) ? item.reqValue : item.value;
|
||||
// chiamo
|
||||
var taskVal = executeSetSupplier(reqVal);
|
||||
bool fatto = taskVal.StartsWith("REQUEST");
|
||||
// se fatto --> aggiorno!
|
||||
if (fatto)
|
||||
{
|
||||
//item.value = item.reqValue;
|
||||
item.reqValue = "";
|
||||
item.lastRead = DateTime.Now;
|
||||
item.UM = "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario parametri correnti
|
||||
/// </summary>
|
||||
protected Dictionary<string, double> perfParamDict { get; set; } = new Dictionary<string, double>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario dati Batch correnti
|
||||
/// </summary>
|
||||
protected Dictionary<string, string> batchDataDict { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dati dinamici...
|
||||
/// </summary>
|
||||
@@ -342,7 +233,7 @@ namespace IOB_WIN_NEXT
|
||||
if (currBatchList[1].EndTime == DateTime.MinValue || currBatchList[1].EndTime == DateTime.MinValue)
|
||||
{
|
||||
B_input = 3;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// accodo NON emergenza
|
||||
@@ -435,6 +326,11 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario dati Batch correnti
|
||||
/// </summary>
|
||||
protected Dictionary<string, string> batchDataDict { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// elenco dei BAtch correntemente caricati x testing variazione
|
||||
/// </summary>
|
||||
@@ -442,10 +338,42 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
protected Connector IcoelSizer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario parametri correnti
|
||||
/// </summary>
|
||||
protected Dictionary<string, double> perfParamDict { get; set; } = new Dictionary<string, double>();
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Metodo da overridare x scrivere DAVVERO i parametri sul PLC
|
||||
/// </summary>
|
||||
/// <param name="updatedPar"></param>
|
||||
protected override void plcWriteParams(ref List<objItem> updatedPar)
|
||||
{
|
||||
foreach (var item in updatedPar)
|
||||
{
|
||||
// cerco se sia setSupplier
|
||||
if (item.uid == "setSupplier")
|
||||
{
|
||||
string reqVal = !string.IsNullOrEmpty(item.reqValue) ? item.reqValue : item.value;
|
||||
// chiamo
|
||||
var taskVal = executeSetSupplier(reqVal);
|
||||
bool fatto = taskVal.StartsWith("REQUEST");
|
||||
// se fatto --> aggiorno!
|
||||
if (fatto)
|
||||
{
|
||||
//item.value = item.reqValue;
|
||||
item.reqValue = "";
|
||||
item.lastRead = DateTime.Now;
|
||||
item.UM = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// recupera le variety ed i rispettivi layout e li invia al sistema MP/IO
|
||||
/// </summary>
|
||||
@@ -465,5 +393,77 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string executeSetSupplier(string cmdArgs)
|
||||
{
|
||||
string taskVal;
|
||||
// loggo i parametri ricevuti da popolare
|
||||
lgInfo($"Chiamata setSupplier --> params payload: {cmdArgs}");
|
||||
// recupero batch corrente x preselezionare i dati guid layout/varietà...
|
||||
var currBatch = IcoelSizer.GetCurrentBatch();
|
||||
// recupero GUID x variety e layout di default
|
||||
var varGuid = currBatch[1].VarietyId;
|
||||
var layGuid = currBatch[1].LayoutId;
|
||||
// predispongo grower di default
|
||||
GrowerInfo GrowerData = new GrowerInfo();
|
||||
// le info sono una stringa separata da valore | di GrowerCode|GrowerName|varietyGuid|LayoutGuid;
|
||||
string[] reqParams = cmdArgs.Split('|');
|
||||
// se ho dati sistemo grower...
|
||||
if (reqParams.Length >= 2)
|
||||
{
|
||||
//GrowerData.GrowerCode = reqParams[0];
|
||||
//GrowerData.GrowerName = reqParams[1];
|
||||
// sistemo commenti
|
||||
var comments = new List<string>();
|
||||
comments.Add($"sent {DateTime.Now: yyyy.MM.dd HH:mm:ss}");
|
||||
comments.Add("Qty: no set");
|
||||
comments.Add("------------");
|
||||
//GrowerData.Comments = comments;
|
||||
|
||||
GrowerData = new GrowerInfo()
|
||||
{
|
||||
GrowerCode = reqParams[0],
|
||||
GrowerName = reqParams[1],
|
||||
Comments = comments
|
||||
};
|
||||
lgInfo($"Set grower data | GrowerCode: {GrowerData.GrowerCode} | GrowerName: {GrowerData.GrowerName}");
|
||||
}
|
||||
if (reqParams.Length >= 3)
|
||||
{
|
||||
Guid.TryParse(reqParams[2], out varGuid);
|
||||
lgInfo($"Set Variety data | VarGUID: {varGuid}");
|
||||
}
|
||||
if (reqParams.Length >= 4)
|
||||
{
|
||||
Guid.TryParse(reqParams[3], out layGuid);
|
||||
lgInfo($"Set Layout data | LayGUID: {layGuid}");
|
||||
}
|
||||
|
||||
// invio richiesta!!!
|
||||
IcoelSizer.EnqueueBatch(GrowerData, varGuid, layGuid);
|
||||
lgInfo($"Request sent!");
|
||||
|
||||
taskVal = $"REQUEST SET SUPPLIER | EnqueueBatch | GrowCode: {GrowerData.GrowerCode} | GrowName: {GrowerData.GrowerName} | Var: {varGuid} | Lay: {layGuid} ";
|
||||
// se restituiscce "" faccio altra prova...
|
||||
if (string.IsNullOrEmpty(taskVal))
|
||||
{
|
||||
// i parametri me li aspetto come stringa composta paramName|paramvalue
|
||||
if (cmdArgs.Contains("|"))
|
||||
{
|
||||
string[] paramsJob = cmdArgs.Split('|');
|
||||
taskVal = $"REQUEST SET PARAMETERS: {paramsJob[0]} --> {paramsJob[1]}";
|
||||
}
|
||||
else
|
||||
{
|
||||
taskVal = $"WRONG REQUEST FOR SET PARAMETERS: {cmdArgs} doesnt contain pipe for splitting key/value";
|
||||
}
|
||||
}
|
||||
|
||||
return taskVal;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
+632
-633
File diff suppressed because it is too large
Load Diff
+635
-632
File diff suppressed because it is too large
Load Diff
@@ -801,7 +801,6 @@ namespace IOB_WIN_NEXT
|
||||
fatto = writeInputReg(currMem.index, CurrVal, parametri.holdRegBaseAddr);
|
||||
break;
|
||||
|
||||
|
||||
case plcDataType.IntLH:
|
||||
valInt = getScaledInt(currMem, true);
|
||||
if (byteSize == 1)
|
||||
@@ -1155,8 +1154,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#region Private Methods
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// converte valore in tipo desiderato
|
||||
/// </summary>
|
||||
@@ -1241,7 +1238,6 @@ namespace IOB_WIN_NEXT
|
||||
valore = ModbusClient.ConvertRegistersToInt(listInt);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
return valore;
|
||||
}
|
||||
@@ -1258,6 +1254,7 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
return valDouble;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua scalatura valore secondo fattore
|
||||
/// Read --> * (moltiplico)
|
||||
|
||||
@@ -1,19 +1,11 @@
|
||||
using EasyModbus;
|
||||
using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/* --------------------------------------------------------------------------------
|
||||
* Controlli ModBusTCP Hunitronix Cedax
|
||||
* - protocollo ModBus TCP
|
||||
* - protocollo ModBus TCP
|
||||
* - specifico comportamento impianti Unitronix Cedax
|
||||
* - nessuna gestione allarmi
|
||||
*
|
||||
@@ -54,42 +46,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void testBlockRead(int baseAddr, int numByte)
|
||||
{
|
||||
int baseHold = 40001;
|
||||
int[] readTestFull = new int[2];
|
||||
lgTrace($"-------------------- Inizio test lettura {baseAddr} --------------------");
|
||||
try
|
||||
{
|
||||
stopwatch.Restart();
|
||||
readTestFull = currPLC.ReadHoldingRegisters(baseAddr - baseHold, numByte);
|
||||
stopwatch.Stop();
|
||||
lgTrace($"Stats lettura | {readTestFull.Length} val | {stopwatch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
for (int i = 0; i < readTestFull.Length / 2; i++)
|
||||
{
|
||||
int[] thisSet = new int[2];
|
||||
Array.Copy(readTestFull, i * 2, thisSet, 0, 2);
|
||||
lgTrace($"{baseAddr + i * 2:000} | HoldingRegisters: {thisSet[0]} / {thisSet[1]} | Val Real: {ModbusClient.ConvertRegistersToFloat(thisSet):N6}");
|
||||
}
|
||||
lgTrace("-------------------- Completato test lettura {baseAddr} --------------------");
|
||||
}
|
||||
|
||||
private void testRead()
|
||||
{
|
||||
foreach (var item in memSetR)
|
||||
{
|
||||
testBlockRead(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -140,5 +96,41 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void testBlockRead(int baseAddr, int numByte)
|
||||
{
|
||||
int baseHold = 40001;
|
||||
int[] readTestFull = new int[2];
|
||||
lgTrace($"-------------------- Inizio test lettura {baseAddr} --------------------");
|
||||
try
|
||||
{
|
||||
stopwatch.Restart();
|
||||
readTestFull = currPLC.ReadHoldingRegisters(baseAddr - baseHold, numByte);
|
||||
stopwatch.Stop();
|
||||
lgTrace($"Stats lettura | {readTestFull.Length} val | {stopwatch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
for (int i = 0; i < readTestFull.Length / 2; i++)
|
||||
{
|
||||
int[] thisSet = new int[2];
|
||||
Array.Copy(readTestFull, i * 2, thisSet, 0, 2);
|
||||
lgTrace($"{baseAddr + i * 2:000} | HoldingRegisters: {thisSet[0]} / {thisSet[1]} | Val Real: {ModbusClient.ConvertRegistersToFloat(thisSet):N6}");
|
||||
}
|
||||
lgTrace("-------------------- Completato test lettura {baseAddr} --------------------");
|
||||
}
|
||||
|
||||
private void testRead()
|
||||
{
|
||||
foreach (var item in memSetR)
|
||||
{
|
||||
testBlockRead(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,11 @@
|
||||
using EasyModbus;
|
||||
using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/* --------------------------------------------------------------------------------
|
||||
* Controlli ModBusTCP Centerfrigo
|
||||
* - protocollo ModBus TCP
|
||||
* - protocollo ModBus TCP
|
||||
* - specifico comportamento impianti Centerfrigo
|
||||
* - gestione allarmi
|
||||
* - gestione stati salvati come dynData
|
||||
@@ -23,7 +15,7 @@ namespace IOB_WIN_NEXT
|
||||
* lettura: xxx byte,
|
||||
* scrittura yyy byte
|
||||
* G:\Drive condivisi\30_Clienti\Giacovelli - WIL\CenterFrigo
|
||||
*
|
||||
*
|
||||
* ATTENZIONE! leggere al max 44 byte alla volta
|
||||
*
|
||||
* -------------------------------------------------------------------------------- */
|
||||
@@ -57,42 +49,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void testBlockRead(int baseAddr, int numByte)
|
||||
{
|
||||
int baseHold = 40001;
|
||||
int[] readTestFull = new int[2];
|
||||
lgTrace($"-------------------- Inizio test lettura {baseAddr} --------------------");
|
||||
try
|
||||
{
|
||||
stopwatch.Restart();
|
||||
readTestFull = currPLC.ReadHoldingRegisters(baseAddr - baseHold, numByte);
|
||||
stopwatch.Stop();
|
||||
lgTrace($"Stats lettura | {readTestFull.Length} val | {stopwatch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
for (int i = 0; i < readTestFull.Length / 2; i++)
|
||||
{
|
||||
int[] thisSet = new int[2];
|
||||
Array.Copy(readTestFull, i * 2, thisSet, 0, 2);
|
||||
lgTrace($"{baseAddr + i * 2:000} | HoldingRegisters: {thisSet[0]} / {thisSet[1]} | Val Real: {ModbusClient.ConvertRegistersToFloat(thisSet):N6}");
|
||||
}
|
||||
lgTrace("-------------------- Completato test lettura {baseAddr} --------------------");
|
||||
}
|
||||
|
||||
private void testRead()
|
||||
{
|
||||
foreach (var item in memSetR)
|
||||
{
|
||||
testBlockRead(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -143,5 +99,41 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void testBlockRead(int baseAddr, int numByte)
|
||||
{
|
||||
int baseHold = 40001;
|
||||
int[] readTestFull = new int[2];
|
||||
lgTrace($"-------------------- Inizio test lettura {baseAddr} --------------------");
|
||||
try
|
||||
{
|
||||
stopwatch.Restart();
|
||||
readTestFull = currPLC.ReadHoldingRegisters(baseAddr - baseHold, numByte);
|
||||
stopwatch.Stop();
|
||||
lgTrace($"Stats lettura | {readTestFull.Length} val | {stopwatch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
for (int i = 0; i < readTestFull.Length / 2; i++)
|
||||
{
|
||||
int[] thisSet = new int[2];
|
||||
Array.Copy(readTestFull, i * 2, thisSet, 0, 2);
|
||||
lgTrace($"{baseAddr + i * 2:000} | HoldingRegisters: {thisSet[0]} / {thisSet[1]} | Val Real: {ModbusClient.ConvertRegistersToFloat(thisSet):N6}");
|
||||
}
|
||||
lgTrace("-------------------- Completato test lettura {baseAddr} --------------------");
|
||||
}
|
||||
|
||||
private void testRead()
|
||||
{
|
||||
foreach (var item in memSetR)
|
||||
{
|
||||
testBlockRead(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,5 @@
|
||||
using EasyModbus;
|
||||
using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
@@ -51,49 +43,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void testBlockRead(int baseAddr, int numByte)
|
||||
{
|
||||
int baseHold = 40001;
|
||||
int[] readTestFull = new int[2];
|
||||
lgTrace($"-------------------- Inizio test lettura {baseAddr} --------------------");
|
||||
try
|
||||
{
|
||||
stopwatch.Restart();
|
||||
readTestFull = currPLC.ReadHoldingRegisters(baseAddr - baseHold, numByte);
|
||||
stopwatch.Stop();
|
||||
lgTrace($"Stats lettura | {readTestFull.Length} val | {stopwatch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
for (int i = 0; i < readTestFull.Length / 2; i++)
|
||||
{
|
||||
int[] thisSet = new int[2];
|
||||
Array.Copy(readTestFull, i * 2, thisSet, 0, 2);
|
||||
lgTrace($"{baseAddr + i * 2:000} | HoldingRegisters: {thisSet[0]} / {thisSet[1]} | Val Real: {ModbusClient.ConvertRegistersToFloat(thisSet):N6}");
|
||||
}
|
||||
lgTrace("-------------------- Completato test lettura {baseAddr} --------------------");
|
||||
}
|
||||
|
||||
private void testRead()
|
||||
{
|
||||
//Ip-Address and Port of Modbus-TCP-Server
|
||||
//currPLC = new ModbusClient(cIobConf.cncIpAddr, 502);
|
||||
////Connect to Server
|
||||
//currPLC.Connect();
|
||||
//modbusClient.WriteMultipleCoils(4, new bool[] { true, true, true, true, true, true, true, true, true, true }); //Write Coils starting with Address 5
|
||||
//bool[] readCoils = modbusClient.ReadCoils(9, 10); //Read 10 Coils from Server, starting with address 10
|
||||
//int[] readHoldingRegisters = currPLC.ReadHoldingRegisters(0, 34); //Read 10 Holding Registers from Server, starting with Address 1
|
||||
foreach (var item in memSetR)
|
||||
{
|
||||
testBlockRead(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -138,5 +87,48 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void testBlockRead(int baseAddr, int numByte)
|
||||
{
|
||||
int baseHold = 40001;
|
||||
int[] readTestFull = new int[2];
|
||||
lgTrace($"-------------------- Inizio test lettura {baseAddr} --------------------");
|
||||
try
|
||||
{
|
||||
stopwatch.Restart();
|
||||
readTestFull = currPLC.ReadHoldingRegisters(baseAddr - baseHold, numByte);
|
||||
stopwatch.Stop();
|
||||
lgTrace($"Stats lettura | {readTestFull.Length} val | {stopwatch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
for (int i = 0; i < readTestFull.Length / 2; i++)
|
||||
{
|
||||
int[] thisSet = new int[2];
|
||||
Array.Copy(readTestFull, i * 2, thisSet, 0, 2);
|
||||
lgTrace($"{baseAddr + i * 2:000} | HoldingRegisters: {thisSet[0]} / {thisSet[1]} | Val Real: {ModbusClient.ConvertRegistersToFloat(thisSet):N6}");
|
||||
}
|
||||
lgTrace("-------------------- Completato test lettura {baseAddr} --------------------");
|
||||
}
|
||||
|
||||
private void testRead()
|
||||
{
|
||||
//Ip-Address and Port of Modbus-TCP-Server
|
||||
//currPLC = new ModbusClient(cIobConf.cncIpAddr, 502);
|
||||
////Connect to Server
|
||||
//currPLC.Connect();
|
||||
//modbusClient.WriteMultipleCoils(4, new bool[] { true, true, true, true, true, true, true, true, true, true }); //Write Coils starting with Address 5
|
||||
//bool[] readCoils = modbusClient.ReadCoils(9, 10); //Read 10 Coils from Server, starting with address 10
|
||||
//int[] readHoldingRegisters = currPLC.ReadHoldingRegisters(0, 34); //Read 10 Holding Registers from Server, starting with Address 1
|
||||
foreach (var item in memSetR)
|
||||
{
|
||||
testBlockRead(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,13 @@
|
||||
using EasyModbus;
|
||||
using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/* --------------------------------------------------------------------------------
|
||||
* Controlli ModBusTCP Helpi
|
||||
* - protocollo ModBus TCP
|
||||
* - protocollo ModBus TCP
|
||||
* - specifico comportamento impianti confezionatrici Helpi
|
||||
*
|
||||
*
|
||||
* NRicetta UINT 16bit 41060 W
|
||||
* ApplicaRicetta UINT 16bit 41061 R/W
|
||||
* IDOrdine STRING [30] 41062 W
|
||||
@@ -28,7 +20,7 @@ namespace IOB_WIN_NEXT
|
||||
* EpochStop UDINT 32bit 41104 R
|
||||
* PPM REAL 32bit 41106 R
|
||||
* StatusLavoro UINT 16bit 41108 R
|
||||
*
|
||||
*
|
||||
* StatusLavoro indica lo stato della macchina:
|
||||
* 0. macchina completamente ferma
|
||||
* 1. macchina in riscaldamento
|
||||
@@ -44,7 +36,6 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Classe base con i metodi x ModBusTCP
|
||||
/// </summary>
|
||||
@@ -74,41 +65,53 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Methods
|
||||
#region Protected Properties
|
||||
|
||||
private void testBlockRead(int baseAddr, int numByte)
|
||||
/// <summary>
|
||||
/// Restituisce status di emergenza, hard coded dall'area di allarmi
|
||||
/// </summary>
|
||||
protected bool EStop
|
||||
{
|
||||
int baseHold = 41060;
|
||||
int[] readTestFull = new int[50];
|
||||
lgTrace($"-------------------- Inizio test lettura {baseAddr} --------------------");
|
||||
try
|
||||
get
|
||||
{
|
||||
stopwatch.Restart();
|
||||
readTestFull = currPLC.ReadHoldingRegisters(baseAddr - baseHold, numByte);
|
||||
stopwatch.Stop();
|
||||
lgTrace($"Stats lettura | {readTestFull.Length} val | {stopwatch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
for (int i = 0; i < readTestFull.Length / 2; i++)
|
||||
{
|
||||
int[] thisSet = new int[2];
|
||||
Array.Copy(readTestFull, i * 2, thisSet, 0, 2);
|
||||
lgTrace($"{baseAddr + i * 2:000} | HoldingRegisters: {thisSet[0]} / {thisSet[1]} | Val Real: {ModbusClient.ConvertRegistersToFloat(thisSet):N6}");
|
||||
}
|
||||
lgTrace("-------------------- Completato test lettura {baseAddr} --------------------");
|
||||
}
|
||||
|
||||
private void testRead()
|
||||
{
|
||||
foreach (var item in memSetR)
|
||||
{
|
||||
testBlockRead(item.Key, item.Value);
|
||||
bool answ = false;
|
||||
int currStatus = 0;
|
||||
// hard coded
|
||||
int statusReg = 41094;
|
||||
// deve avere allarmi (è un allarme EStop)
|
||||
if (hasAlarms)
|
||||
{
|
||||
int[] listInt = new int[2];
|
||||
listInt = HoldingRegisterLUT[statusReg];
|
||||
currStatus = ModbusClient.ConvertRegistersToInt(listInt);
|
||||
// hard coded il 5° bit
|
||||
answ = ((currStatus & (1 << 4)) > 0);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
/// <summary>
|
||||
/// Restituisce status di lavorazione, hard coded dall'area di memoria 41108
|
||||
/// </summary>
|
||||
protected int StatusLavoro
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = 0;
|
||||
// hard coded
|
||||
int statusReg = 41108;
|
||||
if (HoldingRegisterLUT.ContainsKey(statusReg))
|
||||
{
|
||||
int[] listInt = new int[2];
|
||||
listInt = HoldingRegisterLUT[statusReg];
|
||||
answ = ModbusClient.ConvertRegistersToInt(listInt);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
@@ -160,13 +163,16 @@ namespace IOB_WIN_NEXT
|
||||
case 0:
|
||||
default:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
byteSignals += (1 << 6);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 3:
|
||||
byteSignals += (1 << 4);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
byteSignals += (1 << 1);
|
||||
break;
|
||||
@@ -177,51 +183,42 @@ namespace IOB_WIN_NEXT
|
||||
B_input = byteSignals;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce status di lavorazione, hard coded dall'area di memoria 41108
|
||||
/// </summary>
|
||||
protected int StatusLavoro
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = 0;
|
||||
// hard coded
|
||||
int statusReg = 41108;
|
||||
if (HoldingRegisterLUT.ContainsKey(statusReg))
|
||||
{
|
||||
int[] listInt = new int[2];
|
||||
listInt = HoldingRegisterLUT[statusReg];
|
||||
answ = ModbusClient.ConvertRegistersToInt(listInt);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce status di emergenza, hard coded dall'area di allarmi
|
||||
/// </summary>
|
||||
protected bool EStop
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
int currStatus = 0;
|
||||
// hard coded
|
||||
int statusReg = 41094;
|
||||
// deve avere allarmi (è un allarme EStop)
|
||||
if (hasAlarms)
|
||||
{
|
||||
int[] listInt = new int[2];
|
||||
listInt = HoldingRegisterLUT[statusReg];
|
||||
currStatus = ModbusClient.ConvertRegistersToInt(listInt);
|
||||
// hard coded il 5° bit
|
||||
answ = ((currStatus & (1 << 4)) > 0);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void testBlockRead(int baseAddr, int numByte)
|
||||
{
|
||||
int baseHold = 41060;
|
||||
int[] readTestFull = new int[50];
|
||||
lgTrace($"-------------------- Inizio test lettura {baseAddr} --------------------");
|
||||
try
|
||||
{
|
||||
stopwatch.Restart();
|
||||
readTestFull = currPLC.ReadHoldingRegisters(baseAddr - baseHold, numByte);
|
||||
stopwatch.Stop();
|
||||
lgTrace($"Stats lettura | {readTestFull.Length} val | {stopwatch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
for (int i = 0; i < readTestFull.Length / 2; i++)
|
||||
{
|
||||
int[] thisSet = new int[2];
|
||||
Array.Copy(readTestFull, i * 2, thisSet, 0, 2);
|
||||
lgTrace($"{baseAddr + i * 2:000} | HoldingRegisters: {thisSet[0]} / {thisSet[1]} | Val Real: {ModbusClient.ConvertRegistersToFloat(thisSet):N6}");
|
||||
}
|
||||
lgTrace("-------------------- Completato test lettura {baseAddr} --------------------");
|
||||
}
|
||||
|
||||
private void testRead()
|
||||
{
|
||||
foreach (var item in memSetR)
|
||||
{
|
||||
testBlockRead(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
+231
-226
@@ -1,39 +1,16 @@
|
||||
using CndexLinkDotNet;
|
||||
using EgwProxy.OsaiCncLib;
|
||||
using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using EgwProxy.OsaiCncLib;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobOSAI : IobGeneric
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// LookUpTable di decodifica da CNC a segnali tipo bitmap MAPO
|
||||
/// </summary>
|
||||
private Dictionary<string, string> signLUT = new Dictionary<string, string>();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Struttura dati principale in continuo update...
|
||||
/// </summary>
|
||||
protected Cndex.GETINFO1DATA oData;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto MAIN x connessione OSAI
|
||||
/// </summary>
|
||||
protected ComCNOsai OSAI_ref;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
@@ -145,7 +122,8 @@ namespace IOB_WIN_NEXT
|
||||
lgInfo("OSAI: inizio gestione contapezzi");
|
||||
try
|
||||
{
|
||||
// verifico quale modalità sia richiesta: STD (6711) oppure BIT (Custom, con indicazione area)
|
||||
// verifico quale modalità sia richiesta: STD (6711) oppure BIT (Custom, con
|
||||
// indicazione area)
|
||||
if (cIobConf.optPar.Count > 0 && !string.IsNullOrEmpty(getOptPar("PZCOUNT_MODE")))
|
||||
{
|
||||
if (getOptPar("PZCOUNT_MODE").StartsWith("OVAR"))
|
||||
@@ -180,204 +158,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// </summary>
|
||||
private void decodeToBitmap()
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
// SE SI E' CONNESSO al CNC allora è 1=powerON...
|
||||
if (OSAI_ref.Connected)
|
||||
{
|
||||
B_input += 1 << 0;
|
||||
}
|
||||
|
||||
// decodifico impiegando dictionary... cercando il TIPO di memoria & co...
|
||||
string bKey = "";
|
||||
string bVal = "";
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
bKey = string.Format("BIT{0}", i);
|
||||
// cerco se ci sia in LUT
|
||||
if (signLUT.ContainsKey(bKey))
|
||||
{
|
||||
// recupero nome variabile...
|
||||
bVal = signLUT[bKey];
|
||||
// se l'area è PZCOUNT... processo PUNTUALMENTE il CONTAPEZZI...
|
||||
if (bVal.StartsWith("PZCOUNT"))
|
||||
{
|
||||
// procedo SOLO SE è enabled IOB
|
||||
if (IobOnline)
|
||||
{
|
||||
try
|
||||
{
|
||||
currODL = utils.callUrl(urlGetCurrODL);
|
||||
// solo SE HO un ODL...
|
||||
if (string.IsNullOrEmpty(currODL) || currODL == "0")
|
||||
{
|
||||
if (periodicLog)
|
||||
{
|
||||
lgInfo(string.Format("Osai | Lettura ODL andata a vuoto: currODL: {0}", currODL));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgInfo(string.Format("Osai | Lettura ODL, currODL: {0} --> currIdxODL prec: {1}", currODL, currIdxODL));
|
||||
// provo a salvare nuovo ODL
|
||||
int.TryParse(currODL, out currIdxODL);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
if (DateTime.Now.Subtract(lastWarnODL).TotalSeconds > 15)
|
||||
{
|
||||
lgError(exc, "Errore in fase di chiamata URL x ODL corrente | URL chiamato: {0}", urlGetCurrODL);
|
||||
lastWarnODL = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// imposto currODL a vuoto!
|
||||
currODL = "";
|
||||
if (periodicLog)
|
||||
{
|
||||
lgInfo($"OSAI | Lettura ODL non effettuata: IobOnline: {IobOnline} | currODL impostato a vuoto");
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(currODL) && currODL != "0")
|
||||
{
|
||||
// controllo se è passato intervallo minimo tra 2 controlli/elaborazioni x distanziare invio e ridurre letture
|
||||
if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay))
|
||||
{
|
||||
// se sono differenti MOSTRO...
|
||||
if (contapezziPLC != contapezziIOB)
|
||||
{
|
||||
// registro contapezzi
|
||||
lgInfo($"Differenza Contapezzi: contapezziPLC: {contapezziPLC} | contapezziIOB {contapezziIOB}");
|
||||
}
|
||||
// verifico se variato contapezzi in area STD PAR6711... e se passato ritardo minimo...
|
||||
if (contapezziPLC > contapezziIOB)
|
||||
{
|
||||
// salvo nuovo contapezzi (incremento di 1...) + richiesta refresh conteggio
|
||||
contapezziIOB++;
|
||||
needRefreshPzCount = true;
|
||||
// salvo in semaforo!
|
||||
B_input += 1 << 2;
|
||||
// registro contapezzi
|
||||
lgInfo($"contapezziPLC OSAI: {contapezziPLC} | contapezziIOB {contapezziIOB}");
|
||||
}
|
||||
|
||||
// invio a server contapezzi (aggiornato)
|
||||
string retVal = utils.callUrl(urlSetPzCount + contapezziIOB.ToString());
|
||||
// verifica se tutto OK
|
||||
if (retVal != contapezziIOB.ToString())
|
||||
{
|
||||
// errore salvataggio contapezzi
|
||||
lgInfo($"Errore salvataggio Contapezzi OSAI: contapezziPLC {contapezziPLC} | contapezziIOB {contapezziIOB} | risposta: {retVal}");
|
||||
// rileggo il counter pezzi da server
|
||||
pzCntReload(true);
|
||||
}
|
||||
// resetto timer...
|
||||
lastPzCountSend = DateTime.Now;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay))
|
||||
{
|
||||
lgInfo($"Attenzione: mancanza ODL non procedo con gestione contapezzi. contapezziPLC OSAI: {contapezziPLC} | contapezziIOB {contapezziIOB}");
|
||||
// resetto timer...
|
||||
lastPzCountSend = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
// controllo le condizioni x costruire il bit1 RUN!
|
||||
if (oData.mode_select == 2 && oData.status == 2)
|
||||
{
|
||||
B_input += 1 << 1;
|
||||
}
|
||||
// errore su bit3
|
||||
if (oData.mode_select == 6)
|
||||
{
|
||||
B_input += 1 << 3;
|
||||
}
|
||||
// auto su bit4
|
||||
if (oData.mode_select != 2)
|
||||
{
|
||||
B_input += 1 << 4;
|
||||
}
|
||||
// emergenza su bit5
|
||||
if (oData.mode_select == 9)
|
||||
{
|
||||
B_input += 1 << 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format("Trasformazione B_input: {0}", B_input));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Decodifica del MODE selezionato
|
||||
/// </summary>
|
||||
/// <param name="mode"></param>
|
||||
/// <returns></returns>
|
||||
protected static CNC_MODE decodeModeOsai(int mode)
|
||||
{
|
||||
CNC_MODE answ = CNC_MODE.ND;
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
answ = CNC_MODE.MDI;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
answ = CNC_MODE.AUTO;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
answ = CNC_MODE.SEMI;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
answ = CNC_MODE.JOG_MAN;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
answ = CNC_MODE.JOG_INC;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
answ = CNC_MODE.PROFILE;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
answ = CNC_MODE.HOME;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
answ = CNC_MODE.HANDLE_INC;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -481,7 +261,8 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
try
|
||||
{
|
||||
// verifico quale modalità sia richiesta: STD (6711) oppure BIT (Custom, con indicazione area)
|
||||
// verifico quale modalità sia richiesta: STD (6711) oppure BIT (Custom, con
|
||||
// indicazione area)
|
||||
if (cIobConf.optPar.Count > 0 && !string.IsNullOrEmpty(getOptPar("PZCOUNT_MODE")))
|
||||
{
|
||||
string memAddr = getOptPar("PZCOUNT_MODE");
|
||||
@@ -588,8 +369,8 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua lettura semafori principale
|
||||
/// <paramref name="currDispData">Parametri da aggiornare x display in form</paramref>
|
||||
/// Effettua lettura semafori principale <paramref name="currDispData">Parametri da
|
||||
/// aggiornare x display in form</paramref>
|
||||
/// </summary>
|
||||
public override void readSemafori(ref newDisplayData currDispData)
|
||||
{
|
||||
@@ -758,5 +539,229 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Struttura dati principale in continuo update...
|
||||
/// </summary>
|
||||
protected Cndex.GETINFO1DATA oData;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto MAIN x connessione OSAI
|
||||
/// </summary>
|
||||
protected ComCNOsai OSAI_ref;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Decodifica del MODE selezionato
|
||||
/// </summary>
|
||||
/// <param name="mode"></param>
|
||||
/// <returns></returns>
|
||||
protected static CNC_MODE decodeModeOsai(int mode)
|
||||
{
|
||||
CNC_MODE answ = CNC_MODE.ND;
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
answ = CNC_MODE.MDI;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
answ = CNC_MODE.AUTO;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
answ = CNC_MODE.SEMI;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
answ = CNC_MODE.JOG_MAN;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
answ = CNC_MODE.JOG_INC;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
answ = CNC_MODE.PROFILE;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
answ = CNC_MODE.HOME;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
answ = CNC_MODE.HANDLE_INC;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// LookUpTable di decodifica da CNC a segnali tipo bitmap MAPO
|
||||
/// </summary>
|
||||
private Dictionary<string, string> signLUT = new Dictionary<string, string>();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// </summary>
|
||||
private void decodeToBitmap()
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
// SE SI E' CONNESSO al CNC allora è 1=powerON...
|
||||
if (OSAI_ref.Connected)
|
||||
{
|
||||
B_input += 1 << 0;
|
||||
}
|
||||
|
||||
// decodifico impiegando dictionary... cercando il TIPO di memoria & co...
|
||||
string bKey = "";
|
||||
string bVal = "";
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
bKey = string.Format("BIT{0}", i);
|
||||
// cerco se ci sia in LUT
|
||||
if (signLUT.ContainsKey(bKey))
|
||||
{
|
||||
// recupero nome variabile...
|
||||
bVal = signLUT[bKey];
|
||||
// se l'area è PZCOUNT... processo PUNTUALMENTE il CONTAPEZZI...
|
||||
if (bVal.StartsWith("PZCOUNT"))
|
||||
{
|
||||
// procedo SOLO SE è enabled IOB
|
||||
if (IobOnline)
|
||||
{
|
||||
try
|
||||
{
|
||||
currODL = utils.callUrl(urlGetCurrODL);
|
||||
// solo SE HO un ODL...
|
||||
if (string.IsNullOrEmpty(currODL) || currODL == "0")
|
||||
{
|
||||
if (periodicLog)
|
||||
{
|
||||
lgInfo(string.Format("Osai | Lettura ODL andata a vuoto: currODL: {0}", currODL));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgInfo(string.Format("Osai | Lettura ODL, currODL: {0} --> currIdxODL prec: {1}", currODL, currIdxODL));
|
||||
// provo a salvare nuovo ODL
|
||||
int.TryParse(currODL, out currIdxODL);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
if (DateTime.Now.Subtract(lastWarnODL).TotalSeconds > 15)
|
||||
{
|
||||
lgError(exc, "Errore in fase di chiamata URL x ODL corrente | URL chiamato: {0}", urlGetCurrODL);
|
||||
lastWarnODL = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// imposto currODL a vuoto!
|
||||
currODL = "";
|
||||
if (periodicLog)
|
||||
{
|
||||
lgInfo($"OSAI | Lettura ODL non effettuata: IobOnline: {IobOnline} | currODL impostato a vuoto");
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(currODL) && currODL != "0")
|
||||
{
|
||||
// controllo se è passato intervallo minimo tra 2 controlli/elaborazioni
|
||||
// x distanziare invio e ridurre letture
|
||||
if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay))
|
||||
{
|
||||
// se sono differenti MOSTRO...
|
||||
if (contapezziPLC != contapezziIOB)
|
||||
{
|
||||
// registro contapezzi
|
||||
lgInfo($"Differenza Contapezzi: contapezziPLC: {contapezziPLC} | contapezziIOB {contapezziIOB}");
|
||||
}
|
||||
// verifico se variato contapezzi in area STD PAR6711... e se
|
||||
// passato ritardo minimo...
|
||||
if (contapezziPLC > contapezziIOB)
|
||||
{
|
||||
// salvo nuovo contapezzi (incremento di 1...) + richiesta
|
||||
// refresh conteggio
|
||||
contapezziIOB++;
|
||||
needRefreshPzCount = true;
|
||||
// salvo in semaforo!
|
||||
B_input += 1 << 2;
|
||||
// registro contapezzi
|
||||
lgInfo($"contapezziPLC OSAI: {contapezziPLC} | contapezziIOB {contapezziIOB}");
|
||||
}
|
||||
|
||||
// invio a server contapezzi (aggiornato)
|
||||
string retVal = utils.callUrl(urlSetPzCount + contapezziIOB.ToString());
|
||||
// verifica se tutto OK
|
||||
if (retVal != contapezziIOB.ToString())
|
||||
{
|
||||
// errore salvataggio contapezzi
|
||||
lgInfo($"Errore salvataggio Contapezzi OSAI: contapezziPLC {contapezziPLC} | contapezziIOB {contapezziIOB} | risposta: {retVal}");
|
||||
// rileggo il counter pezzi da server
|
||||
pzCntReload(true);
|
||||
}
|
||||
// resetto timer...
|
||||
lastPzCountSend = DateTime.Now;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay))
|
||||
{
|
||||
lgInfo($"Attenzione: mancanza ODL non procedo con gestione contapezzi. contapezziPLC OSAI: {contapezziPLC} | contapezziIOB {contapezziIOB}");
|
||||
// resetto timer...
|
||||
lastPzCountSend = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
// controllo le condizioni x costruire il bit1 RUN!
|
||||
if (oData.mode_select == 2 && oData.status == 2)
|
||||
{
|
||||
B_input += 1 << 1;
|
||||
}
|
||||
// errore su bit3
|
||||
if (oData.mode_select == 6)
|
||||
{
|
||||
B_input += 1 << 3;
|
||||
}
|
||||
// auto su bit4
|
||||
if (oData.mode_select != 2)
|
||||
{
|
||||
B_input += 1 << 4;
|
||||
}
|
||||
// emergenza su bit5
|
||||
if (oData.mode_select == 9)
|
||||
{
|
||||
B_input += 1 << 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format("Trasformazione B_input: {0}", B_input));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
+550
-544
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,12 @@ namespace IOB_WIN_NEXT
|
||||
// gestione invio ritardato contapezzi
|
||||
pzCountDelay = utils.CRI("pzCountDelay");
|
||||
|
||||
// gestione restart OpcUa client...
|
||||
if (!string.IsNullOrEmpty(getOptPar("MAX_TRY_PING")))
|
||||
{
|
||||
int.TryParse(getOptPar("MAX_TRY_PING"), out maxTryPing);
|
||||
}
|
||||
|
||||
enablePzCountByApp = utils.CRB("enableContapezzi");
|
||||
enablePzCountByIob = (getOptPar("ENABLE_PZCOUNT") == "TRUE");
|
||||
disablePzCounteByIob = (getOptPar("DISABLE_PZCOUNT") == "TRUE");
|
||||
@@ -476,6 +482,35 @@ namespace IOB_WIN_NEXT
|
||||
return changed;
|
||||
}
|
||||
|
||||
internal void procRunMode(ref string currRun)
|
||||
{
|
||||
// variabili RUN... se richiesto invio runMode
|
||||
if (opcUaParams.runModeSend)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(opcUaParams.keyRunMode))
|
||||
{
|
||||
currRun = getDataItemValue(opcUaParams.keyRunMode);
|
||||
if (!string.IsNullOrEmpty(currRun))
|
||||
{
|
||||
// se ho valore --> invio
|
||||
string sVal = "";
|
||||
string descr = $"RunModeVal";
|
||||
DateTime locTStamp = DateTime.Now;
|
||||
sVal = $"Change: {locTStamp.ToString()} | descr: {descr} | Id: {opcUaParams.keyRunMode} | Val: {currRun}";
|
||||
accodaFLog(sVal, qEncodeFLog(descr, currRun));
|
||||
|
||||
// se richiesto provo a tradurre
|
||||
if (opcUaParams.runModeTrad)
|
||||
{
|
||||
string RunModeDescr = itemTranslation("RunMode", currRun);
|
||||
descr = $"RunMode";
|
||||
accodaFLog(sVal, qEncodeFLog(descr, RunModeDescr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void sendDataItemListToServer(NodeId StartNodeId)
|
||||
{
|
||||
// converto gli attuali nell'elenco dataitem...
|
||||
@@ -922,16 +957,29 @@ namespace IOB_WIN_NEXT
|
||||
// se valido il check ping lo eseguo... altrimenti lo do x buono
|
||||
bool checkPing = !opcUaParams.pingAsPowerOn;
|
||||
string currRun = "";
|
||||
if (!checkPing)
|
||||
int currTryPing = maxTryPing;
|
||||
while (currTryPing > 0 && !checkPing)
|
||||
{
|
||||
checkPing = (testPingMachine == IPStatus.Success);
|
||||
if (!checkPing)
|
||||
{
|
||||
checkPing = (testPingMachine == IPStatus.Success);
|
||||
}
|
||||
currTryPing--;
|
||||
// se ping KO --> aspetto prima di ripetere test
|
||||
if (!checkPing)
|
||||
{
|
||||
Random rand = new Random();
|
||||
Thread.Sleep(rand.Next(pingServerMsTimeout * 2));
|
||||
}
|
||||
}
|
||||
|
||||
// bit 0 (poweron) imposto a 1 SE pingo + PowerOn=="ON"...
|
||||
bool powerOnOk = checkPing && hasPowerOn;
|
||||
|
||||
// controllo se sono poweroff e se non ho dati buoni da > lastCurrentMaxElapsed --> disconnetto
|
||||
if (!powerOnOk && adesso.Subtract(lastCurrent).TotalSeconds > lastCurrentMaxElapsed)
|
||||
if (!powerOnOk && (adesso.Subtract(lastCurrent).TotalSeconds > lastCurrentMaxElapsed))
|
||||
{
|
||||
lgInfo("Timeout per mencata comunicazione --> disconnessione adapter OpcUa!");
|
||||
tryDisconnect();
|
||||
}
|
||||
|
||||
@@ -1113,7 +1161,7 @@ namespace IOB_WIN_NEXT
|
||||
application.ApplicationType = ApplicationType.Client;
|
||||
|
||||
// load the application configuration.
|
||||
string confPath = $"{Application.StartupPath}\\DATA\\CONF\\IobOpcUaClient.Config.xml";
|
||||
string confPath = $"{Application.StartupPath}\\DATA\\IobOpcUaClient.Config.xml";
|
||||
await application.LoadApplicationConfiguration(confPath, silent: false).ConfigureAwait(false);
|
||||
// check the application certificate.
|
||||
await application.CheckApplicationInstanceCertificate(silent: false, minimumKeySize: 0).ConfigureAwait(false);
|
||||
|
||||
+128
-108
@@ -3,26 +3,12 @@ using Newtonsoft.Json;
|
||||
using Opc.Ua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobOpcUaCMS : IobOpcUa
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Modalità cambio ODL
|
||||
/// </summary>
|
||||
protected string CHANGE_ODL_MODE = "";
|
||||
|
||||
protected bool testDone = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -44,6 +30,113 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#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)
|
||||
{
|
||||
// uso metodo base x ora
|
||||
return base.executeTasks(task2exe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
if (utils.CRB("enableContapezzi"))
|
||||
{
|
||||
// check condizione validazione
|
||||
if (checkMultiCondition(opcUaParams.condCountEnabled) || opcUaParams.condCountEnabled.checkList.Count == 0)
|
||||
{
|
||||
// cerco parametro contapezzi...
|
||||
string currPzCount = getDataItemValue(opcUaParams.keyPartCount);
|
||||
|
||||
// se ho un contapezzi... processo...
|
||||
if (!string.IsNullOrEmpty(currPzCount))
|
||||
{
|
||||
int newVal = -1;
|
||||
bool fatto = Int32.TryParse(currPzCount, out newVal);
|
||||
|
||||
if (fatto)
|
||||
{
|
||||
// gestione decremento contapezzi: viene "messo via" solo SE c'è un
|
||||
// effettivo decremento contapezzi...
|
||||
if (newVal < contapezziPLC)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC) --> pzCountResetted = true");
|
||||
}
|
||||
|
||||
// salvo nuovo valore contapezziPLC
|
||||
contapezziPLC = newVal > -1 ? newVal : contapezziPLC;
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in decodifica valore contapezzi, valore rilevato: {currPzCount}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in decodifica valore contapezzi da {opcUaParams.keyPartCount} | valore vuoto!");
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGE_ODL_MODE == "PZCOUNT_RESET")
|
||||
{
|
||||
// controllo comunque, se è ZERO il contapezzi, e sul server è maggiore il
|
||||
// valore x ODL e NON abilitato il trigger reset --> abilito trigger...
|
||||
if (!pzCountResetted && contapezziPLC == 0 && contapezziIOB > 0)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC==0 e IOB>PLC) --> pzCountResetted = true");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua reset del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool resetcontapezziPLC()
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua IMPOSTAZIONE FORZATA del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool setcontapezziPLC(int newPzCount)
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Modalità cambio ODL
|
||||
/// </summary>
|
||||
protected string CHANGE_ODL_MODE = "";
|
||||
|
||||
protected bool testDone = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -85,6 +178,27 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
// variabili RUN...
|
||||
currRun = getDataItemValue(opcUaParams.keyRunMode);
|
||||
// variabili RUN... se richiesto invio runMode
|
||||
if (opcUaParams.runModeSend)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(currRun))
|
||||
{
|
||||
// se ho valore --> invio
|
||||
string sVal = "";
|
||||
string descr = $"RunModeVal";
|
||||
DateTime locTStamp = DateTime.Now;
|
||||
sVal = $"Change: {locTStamp.ToString()} | descr: {descr} | Id: {opcUaParams.keyRunMode} | Val: {currRun}";
|
||||
accodaFLog(sVal, qEncodeFLog(descr, currRun));
|
||||
|
||||
// se richiesto provo a tradurre
|
||||
if (opcUaParams.runModeTrad)
|
||||
{
|
||||
string RunModeDescr = itemTranslation("RunMode", currRun);
|
||||
descr = $"RunMode";
|
||||
accodaFLog(sVal, qEncodeFLog(descr, RunModeDescr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// salvo running come = working...
|
||||
isRunning = isWorking;
|
||||
@@ -274,99 +388,5 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
// uso metodo base x ora
|
||||
return base.executeTasks(task2exe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
if (utils.CRB("enableContapezzi"))
|
||||
{
|
||||
// check condizione validazione
|
||||
if (checkMultiCondition(opcUaParams.condCountEnabled) || opcUaParams.condCountEnabled.checkList.Count == 0)
|
||||
{
|
||||
// cerco parametro contapezzi...
|
||||
string currPzCount = getDataItemValue(opcUaParams.keyPartCount);
|
||||
|
||||
// se ho un contapezzi... processo...
|
||||
if (!string.IsNullOrEmpty(currPzCount))
|
||||
{
|
||||
int newVal = -1;
|
||||
bool fatto = Int32.TryParse(currPzCount, out newVal);
|
||||
|
||||
if (fatto)
|
||||
{
|
||||
// gestione decremento contapezzi: viene "messo via" solo SE c'è un effettivo decremento contapezzi...
|
||||
if (newVal < contapezziPLC)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC) --> pzCountResetted = true");
|
||||
}
|
||||
|
||||
// salvo nuovo valore contapezziPLC
|
||||
contapezziPLC = newVal > -1 ? newVal : contapezziPLC;
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in decodifica valore contapezzi, valore rilevato: {currPzCount}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in decodifica valore contapezzi da {opcUaParams.keyPartCount} | valore vuoto!");
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGE_ODL_MODE == "PZCOUNT_RESET")
|
||||
{
|
||||
// controllo comunque, se è ZERO il contapezzi, e sul server è maggiore il valore x ODL e NON abilitato il trigger reset --> abilito trigger...
|
||||
if (!pzCountResetted && contapezziPLC == 0 && contapezziIOB > 0)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC==0 e IOB>PLC) --> pzCountResetted = true");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua reset del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool resetcontapezziPLC()
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua IMPOSTAZIONE FORZATA del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool setcontapezziPLC(int newPzCount)
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
+112
-109
@@ -3,26 +3,12 @@ using Newtonsoft.Json;
|
||||
using Opc.Ua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobOpcUaEwon : IobOpcUa
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Modalità cambio ODL
|
||||
/// </summary>
|
||||
protected string CHANGE_ODL_MODE = "";
|
||||
|
||||
protected bool testDone = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -43,6 +29,113 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#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)
|
||||
{
|
||||
// uso metodo base x ora
|
||||
return base.executeTasks(task2exe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
if (utils.CRB("enableContapezzi"))
|
||||
{
|
||||
// check condizione validazione
|
||||
if (checkMultiCondition(opcUaParams.condCountEnabled) || opcUaParams.condCountEnabled.checkList.Count == 0)
|
||||
{
|
||||
// cerco parametro contapezzi...
|
||||
string currPzCount = getDataItemValue(opcUaParams.keyPartCount);
|
||||
|
||||
// se ho un contapezzi... processo...
|
||||
if (!string.IsNullOrEmpty(currPzCount))
|
||||
{
|
||||
int newVal = -1;
|
||||
bool fatto = Int32.TryParse(currPzCount, out newVal);
|
||||
|
||||
if (fatto)
|
||||
{
|
||||
// gestione decremento contapezzi: viene "messo via" solo SE c'è un
|
||||
// effettivo decremento contapezzi...
|
||||
if (newVal < contapezziPLC)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC) --> pzCountResetted = true");
|
||||
}
|
||||
|
||||
// salvo nuovo valore contapezziPLC
|
||||
contapezziPLC = newVal > -1 ? newVal : contapezziPLC;
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in decodifica valore contapezzi, valore rilevato: {currPzCount}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError("Errore in decodifica valore contapezzi, valore vuoto!");
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGE_ODL_MODE == "PZCOUNT_RESET")
|
||||
{
|
||||
// controllo comunque, se è ZERO il contapezzi, e sul server è maggiore il
|
||||
// valore x ODL e NON abilitato il trigger reset --> abilito trigger...
|
||||
if (!pzCountResetted && contapezziPLC == 0 && contapezziIOB > 0)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC==0 e IOB>PLC) --> pzCountResetted = true");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua reset del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool resetcontapezziPLC()
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua IMPOSTAZIONE FORZATA del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool setcontapezziPLC(int newPzCount)
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Modalità cambio ODL
|
||||
/// </summary>
|
||||
protected string CHANGE_ODL_MODE = "";
|
||||
|
||||
protected bool testDone = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -82,11 +175,15 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
B_input = powerOnOk ? 1 : 0;
|
||||
|
||||
#if false
|
||||
// variabili RUN...
|
||||
if (!string.IsNullOrEmpty(opcUaParams.keyRunMode))
|
||||
{
|
||||
currRun = getDataItemValue(opcUaParams.keyRunMode);
|
||||
}
|
||||
#endif
|
||||
|
||||
procRunMode(ref currRun);
|
||||
|
||||
// salvo running come = working...
|
||||
isRunning = isWorking;
|
||||
@@ -137,7 +234,7 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
List<WriteValue> nodes2Write = new List<WriteValue>();
|
||||
nodes2Write.Add(commWriteVal);
|
||||
|
||||
|
||||
UA_ref.WriteNodes(nodes2Write);
|
||||
}
|
||||
catch (Exception exc)
|
||||
@@ -271,99 +368,5 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
// uso metodo base x ora
|
||||
return base.executeTasks(task2exe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
if (utils.CRB("enableContapezzi"))
|
||||
{
|
||||
// check condizione validazione
|
||||
if (checkMultiCondition(opcUaParams.condCountEnabled) || opcUaParams.condCountEnabled.checkList.Count == 0)
|
||||
{
|
||||
// cerco parametro contapezzi...
|
||||
string currPzCount = getDataItemValue(opcUaParams.keyPartCount);
|
||||
|
||||
// se ho un contapezzi... processo...
|
||||
if (!string.IsNullOrEmpty(currPzCount))
|
||||
{
|
||||
int newVal = -1;
|
||||
bool fatto = Int32.TryParse(currPzCount, out newVal);
|
||||
|
||||
if (fatto)
|
||||
{
|
||||
// gestione decremento contapezzi: viene "messo via" solo SE c'è un effettivo decremento contapezzi...
|
||||
if (newVal < contapezziPLC)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC) --> pzCountResetted = true");
|
||||
}
|
||||
|
||||
// salvo nuovo valore contapezziPLC
|
||||
contapezziPLC = newVal > -1 ? newVal : contapezziPLC;
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in decodifica valore contapezzi, valore rilevato: {currPzCount}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError("Errore in decodifica valore contapezzi, valore vuoto!");
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGE_ODL_MODE == "PZCOUNT_RESET")
|
||||
{
|
||||
// controllo comunque, se è ZERO il contapezzi, e sul server è maggiore il valore x ODL e NON abilitato il trigger reset --> abilito trigger...
|
||||
if (!pzCountResetted && contapezziPLC == 0 && contapezziIOB > 0)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC==0 e IOB>PLC) --> pzCountResetted = true");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua reset del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool resetcontapezziPLC()
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua IMPOSTAZIONE FORZATA del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool setcontapezziPLC(int newPzCount)
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,10 @@
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using Opc.Ua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobOpcUaEwonBLM : IobOpcUaEwon
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -37,6 +25,10 @@ namespace IOB_WIN_NEXT
|
||||
sendKeyRichiesta = true;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vera scrittura parametri
|
||||
/// </summary>
|
||||
@@ -49,7 +41,8 @@ namespace IOB_WIN_NEXT
|
||||
if (opcUaParams.SetupConf.SetupMode == IOB_UT_NEXT.MachineSetupMode.MECOLPRESS)
|
||||
{
|
||||
List<WriteValue> nodes2Write = new List<WriteValue>();
|
||||
// faccio un check tra i valori in memoria che devono corrispondere e se NON corrispondono --> metto valore in scrittura...
|
||||
// faccio un check tra i valori in memoria che devono corrispondere e se NON
|
||||
// corrispondono --> metto valore in scrittura...
|
||||
int numDiff = 0;
|
||||
foreach (var item in opcUaParams.SetupConf.checkParList)
|
||||
{
|
||||
@@ -98,11 +91,10 @@ namespace IOB_WIN_NEXT
|
||||
UA_ref.WriteNodes(nodes2Write);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,12 @@
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using Opc.Ua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobOpcUaEwonMecolpress : IobOpcUaEwon
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -37,6 +27,10 @@ namespace IOB_WIN_NEXT
|
||||
sendKeyRichiesta = true;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vera scrittura parametri
|
||||
/// </summary>
|
||||
@@ -49,7 +43,8 @@ namespace IOB_WIN_NEXT
|
||||
if (opcUaParams.SetupConf.SetupMode == IOB_UT_NEXT.MachineSetupMode.MECOLPRESS)
|
||||
{
|
||||
List<WriteValue> nodes2Write = new List<WriteValue>();
|
||||
// faccio un check tra i valori in memoria che devono corrispondere e se NON corrispondono --> metto valore in scrittura...
|
||||
// faccio un check tra i valori in memoria che devono corrispondere e se NON
|
||||
// corrispondono --> metto valore in scrittura...
|
||||
int numDiff = 0;
|
||||
foreach (var item in opcUaParams.SetupConf.checkParList)
|
||||
{
|
||||
@@ -86,7 +81,7 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
// accodo x scrittura
|
||||
nodes2Write.Add(commWriteVal);
|
||||
lgInfo($"richiesta scrittura valore | nodeId: {commWriteVal.NodeId } | targetPar: {item.TargetParam} | val {commWriteVal.Value.Value}");
|
||||
lgInfo($"richiesta scrittura valore | nodeId: {commWriteVal.NodeId} | targetPar: {item.TargetParam} | val {commWriteVal.Value.Value}");
|
||||
}
|
||||
|
||||
// x ora NON eseguo
|
||||
@@ -101,7 +96,6 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,72 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
if (utils.CRB("enableContapezzi"))
|
||||
{
|
||||
// check condizione validazione
|
||||
if (checkMultiCondition(opcUaParams.condCountEnabled) || opcUaParams.condCountEnabled.checkList.Count == 0)
|
||||
{
|
||||
// cerco parametro contapezzi...
|
||||
string currPzCount = getDataItemValue(opcUaParams.keyPartCount);
|
||||
|
||||
// se ho un contapezzi... processo...
|
||||
if (!string.IsNullOrEmpty(currPzCount))
|
||||
{
|
||||
int newVal = -1;
|
||||
bool fatto = Int32.TryParse(currPzCount, out newVal);
|
||||
|
||||
if (fatto)
|
||||
{
|
||||
// gestione decremento contapezzi: viene "messo via" solo SE c'è un
|
||||
// effettivo decremento contapezzi...
|
||||
if (newVal < contapezziPLC)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC) --> pzCountResetted = true");
|
||||
}
|
||||
|
||||
// salvo nuovo valore contapezziPLC
|
||||
contapezziPLC = newVal > -1 ? newVal : contapezziPLC;
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in decodifica valore contapezzi, valore rilevato: {currPzCount}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError("Errore in decodifica valore contapezzi, valore vuoto!");
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGE_ODL_MODE == "PZCOUNT_RESET")
|
||||
{
|
||||
// controllo comunque, se è ZERO il contapezzi, e sul server è maggiore il
|
||||
// valore x ODL e NON abilitato il trigger reset --> abilito trigger...
|
||||
if (!pzCountResetted && contapezziPLC == 0 && contapezziIOB > 0)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC==0 e IOB>PLC) --> pzCountResetted = true");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -151,69 +217,5 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
if (utils.CRB("enableContapezzi"))
|
||||
{
|
||||
// check condizione validazione
|
||||
if (checkMultiCondition(opcUaParams.condCountEnabled) || opcUaParams.condCountEnabled.checkList.Count == 0)
|
||||
{
|
||||
// cerco parametro contapezzi...
|
||||
string currPzCount = getDataItemValue(opcUaParams.keyPartCount);
|
||||
|
||||
// se ho un contapezzi... processo...
|
||||
if (!string.IsNullOrEmpty(currPzCount))
|
||||
{
|
||||
int newVal = -1;
|
||||
bool fatto = Int32.TryParse(currPzCount, out newVal);
|
||||
|
||||
if (fatto)
|
||||
{
|
||||
// gestione decremento contapezzi: viene "messo via" solo SE c'è un effettivo decremento contapezzi...
|
||||
if (newVal < contapezziPLC)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC) --> pzCountResetted = true");
|
||||
}
|
||||
|
||||
// salvo nuovo valore contapezziPLC
|
||||
contapezziPLC = newVal > -1 ? newVal : contapezziPLC;
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in decodifica valore contapezzi, valore rilevato: {currPzCount}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError("Errore in decodifica valore contapezzi, valore vuoto!");
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGE_ODL_MODE == "PZCOUNT_RESET")
|
||||
{
|
||||
// controllo comunque, se è ZERO il contapezzi, e sul server è maggiore il valore x ODL e NON abilitato il trigger reset --> abilito trigger...
|
||||
if (!pzCountResetted && contapezziPLC == 0 && contapezziIOB > 0)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC==0 e IOB>PLC) --> pzCountResetted = true");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -176,11 +176,34 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
B_input = powerOnOk ? 1 : 0;
|
||||
|
||||
// variabili RUN...
|
||||
if (!string.IsNullOrEmpty(opcUaParams.keyRunMode))
|
||||
procRunMode(ref currRun);
|
||||
#if false
|
||||
// variabili RUN... se richiesto invio runMode
|
||||
if (opcUaParams.runModeSend)
|
||||
{
|
||||
currRun = getDataItemValue(opcUaParams.keyRunMode);
|
||||
if (!string.IsNullOrEmpty(opcUaParams.keyRunMode))
|
||||
{
|
||||
currRun = getDataItemValue(opcUaParams.keyRunMode);
|
||||
if (!string.IsNullOrEmpty(currRun))
|
||||
{
|
||||
// se ho valore --> invio
|
||||
string sVal = "";
|
||||
string descr = $"RunModeVal";
|
||||
DateTime locTStamp = DateTime.Now;
|
||||
sVal = $"Change: {locTStamp.ToString()} | descr: {descr} | Id: {opcUaParams.keyRunMode} | Val: {currRun}";
|
||||
accodaFLog(sVal, qEncodeFLog(descr, currRun));
|
||||
|
||||
// se richiesto provo a tradurre
|
||||
if (opcUaParams.runModeTrad)
|
||||
{
|
||||
string RunModeDescr = itemTranslation("RunMode", currRun);
|
||||
descr = $"RunMode";
|
||||
accodaFLog(sVal, qEncodeFLog(descr, RunModeDescr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// salvo running come = working...
|
||||
isRunning = isWorking;
|
||||
|
||||
@@ -111,6 +111,14 @@ namespace IOB_WIN_NEXT
|
||||
return writeResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
// non fa nulal (non ha contapezzi)
|
||||
}
|
||||
|
||||
public override bool resetcontapezziPLC()
|
||||
{
|
||||
bool answ = false;
|
||||
|
||||
+111
-109
@@ -3,26 +3,12 @@ using Newtonsoft.Json;
|
||||
using Opc.Ua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobOpcUaOmron : IobOpcUa
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Modalità cambio ODL
|
||||
/// </summary>
|
||||
protected string CHANGE_ODL_MODE = "";
|
||||
|
||||
protected bool testDone = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -43,6 +29,113 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#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)
|
||||
{
|
||||
// uso metodo base x ora
|
||||
return base.executeTasks(task2exe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
if (utils.CRB("enableContapezzi"))
|
||||
{
|
||||
// check condizione validazione
|
||||
if (checkMultiCondition(opcUaParams.condCountEnabled) || opcUaParams.condCountEnabled.checkList.Count == 0)
|
||||
{
|
||||
// cerco parametro contapezzi...
|
||||
string currPzCount = getDataItemValue(opcUaParams.keyPartCount);
|
||||
|
||||
// se ho un contapezzi... processo...
|
||||
if (!string.IsNullOrEmpty(currPzCount))
|
||||
{
|
||||
int newVal = -1;
|
||||
bool fatto = Int32.TryParse(currPzCount, out newVal);
|
||||
|
||||
if (fatto)
|
||||
{
|
||||
// gestione decremento contapezzi: viene "messo via" solo SE c'è un
|
||||
// effettivo decremento contapezzi...
|
||||
if (newVal < contapezziPLC)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC) --> pzCountResetted = true");
|
||||
}
|
||||
|
||||
// salvo nuovo valore contapezziPLC
|
||||
contapezziPLC = newVal > -1 ? newVal : contapezziPLC;
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in decodifica valore contapezzi, valore rilevato: {currPzCount}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError("Errore in decodifica valore contapezzi, valore vuoto!");
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGE_ODL_MODE == "PZCOUNT_RESET")
|
||||
{
|
||||
// controllo comunque, se è ZERO il contapezzi, e sul server è maggiore il
|
||||
// valore x ODL e NON abilitato il trigger reset --> abilito trigger...
|
||||
if (!pzCountResetted && contapezziPLC == 0 && contapezziIOB > 0)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC==0 e IOB>PLC) --> pzCountResetted = true");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua reset del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool resetcontapezziPLC()
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua IMPOSTAZIONE FORZATA del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool setcontapezziPLC(int newPzCount)
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Modalità cambio ODL
|
||||
/// </summary>
|
||||
protected string CHANGE_ODL_MODE = "";
|
||||
|
||||
protected bool testDone = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -82,11 +175,15 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
B_input = powerOnOk ? 1 : 0;
|
||||
|
||||
#if false
|
||||
// variabili RUN...
|
||||
if (!string.IsNullOrEmpty(opcUaParams.keyRunMode))
|
||||
{
|
||||
currRun = getDataItemValue(opcUaParams.keyRunMode);
|
||||
}
|
||||
#endif
|
||||
|
||||
procRunMode(ref currRun);
|
||||
|
||||
// salvo running come = working...
|
||||
isRunning = isWorking;
|
||||
@@ -271,100 +368,5 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
// uso metodo base x ora
|
||||
return base.executeTasks(task2exe);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua vero processing contapezzi
|
||||
/// </summary>
|
||||
public override void processContapezzi()
|
||||
{
|
||||
if (utils.CRB("enableContapezzi"))
|
||||
{
|
||||
// check condizione validazione
|
||||
if (checkMultiCondition(opcUaParams.condCountEnabled) || opcUaParams.condCountEnabled.checkList.Count == 0)
|
||||
{
|
||||
// cerco parametro contapezzi...
|
||||
string currPzCount = getDataItemValue(opcUaParams.keyPartCount);
|
||||
|
||||
// se ho un contapezzi... processo...
|
||||
if (!string.IsNullOrEmpty(currPzCount))
|
||||
{
|
||||
int newVal = -1;
|
||||
bool fatto = Int32.TryParse(currPzCount, out newVal);
|
||||
|
||||
if (fatto)
|
||||
{
|
||||
// gestione decremento contapezzi: viene "messo via" solo SE c'è un effettivo decremento contapezzi...
|
||||
if (newVal < contapezziPLC)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC) --> pzCountResetted = true");
|
||||
}
|
||||
|
||||
// salvo nuovo valore contapezziPLC
|
||||
contapezziPLC = newVal > -1 ? newVal : contapezziPLC;
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in decodifica valore contapezzi, valore rilevato: {currPzCount}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError("Errore in decodifica valore contapezzi, valore vuoto!");
|
||||
}
|
||||
}
|
||||
|
||||
if (CHANGE_ODL_MODE == "PZCOUNT_RESET")
|
||||
{
|
||||
// controllo comunque, se è ZERO il contapezzi, e sul server è maggiore il valore x ODL e NON abilitato il trigger reset --> abilito trigger...
|
||||
if (!pzCountResetted && contapezziPLC == 0 && contapezziIOB > 0)
|
||||
{
|
||||
pzCountResetted = true;
|
||||
// incremento contatore richiesta
|
||||
countKeyRichiesta = countKeyRichiesta + 1;
|
||||
// log
|
||||
lgInfo("Contapezzi resettato (PLC==0 e IOB>PLC) --> pzCountResetted = true");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua reset del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool resetcontapezziPLC()
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua IMPOSTAZIONE FORZATA del contapezzi, NON POSSIBILE in questa versione
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override bool setcontapezziPLC(int newPzCount)
|
||||
{
|
||||
bool answ = false;
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
}
|
||||
}
|
||||
@@ -427,7 +427,6 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
B_input += (1 << 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// controllo se sono poweroff e se non ho dati buoni da > 2 minuti --> disconnetto
|
||||
@@ -488,7 +487,8 @@ namespace IOB_WIN_NEXT
|
||||
lgTrace($"Invio variazione dataitem per {dataItemMem.Count} elementi");
|
||||
sendDataItemListToServer(startNodeId);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
lgTrace("Nessuna variazione DataItem da trasmettere");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,11 +176,15 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
B_input = powerOnOk ? 1 : 0;
|
||||
|
||||
#if false
|
||||
// variabili RUN...
|
||||
if (!string.IsNullOrEmpty(opcUaParams.keyRunMode))
|
||||
{
|
||||
currRun = getDataItemValue(opcUaParams.keyRunMode);
|
||||
}
|
||||
#endif
|
||||
|
||||
procRunMode(ref currRun);
|
||||
|
||||
// salvo running come = working...
|
||||
isRunning = isWorking;
|
||||
|
||||
+12
-15
@@ -1,27 +1,12 @@
|
||||
using IOB_UT_NEXT;
|
||||
using MapoSDK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
public class IobPing : IobGeneric
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected int PoweroffTimeoutSec = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Veto controllo status x log...
|
||||
/// </summary>
|
||||
protected DateTime vetoCheckStatus = DateTime.Now;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -111,6 +96,7 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override connessione
|
||||
/// </summary>
|
||||
public override void tryConnect()
|
||||
@@ -156,5 +142,16 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int PoweroffTimeoutSec = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Veto controllo status x log...
|
||||
/// </summary>
|
||||
protected DateTime vetoCheckStatus = DateTime.Now;
|
||||
|
||||
#endregion Protected Fields
|
||||
}
|
||||
}
|
||||
+661
-647
File diff suppressed because it is too large
Load Diff
@@ -77,75 +77,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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
|
||||
* - 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 Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -216,5 +147,75 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#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
|
||||
* - 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 Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -41,95 +33,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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>
|
||||
@@ -168,7 +71,8 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
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...
|
||||
// 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;
|
||||
@@ -265,7 +169,8 @@ namespace IOB_WIN_NEXT
|
||||
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...
|
||||
// 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;
|
||||
@@ -349,5 +254,102 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#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
|
||||
}
|
||||
}
|
||||
+135
-137
@@ -35,12 +35,6 @@ namespace IOB_WIN_NEXT
|
||||
*
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int strobeVal = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -55,137 +49,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
#if false
|
||||
protected bool hasAlarms
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
int numErrors = 0;
|
||||
uint currStatus = 0;
|
||||
if (alarmMaps != null)
|
||||
{
|
||||
// leggo a ciclo le aree degli allarmi CONFIGURATI, se ne trovo --> segnalo allarme...
|
||||
foreach (var item in alarmMaps)
|
||||
{
|
||||
// banchi in WORD (2 byte) --> scompongo
|
||||
for (int i = 0; i < item.size / 2; i++)
|
||||
{
|
||||
currStatus = S7.Net.Types.Counter.FromByteArray(RawInput.Skip(item.index + 2 * i).Take(2).ToArray());
|
||||
// verifica e decremento blink...
|
||||
item.checkBlinkCounter(i, (uint)currStatus);
|
||||
|
||||
// verifico SE sia variato... confronto allarmi filtrato stile blink per bit status:
|
||||
// - allarmi che iniziano per # IGNORATI
|
||||
// - altri allarmi con un countdown da MAX_COUNTER_BLINK a 0 per il fronte di discesa
|
||||
if (item.isChanged(i, currStatus))
|
||||
{
|
||||
if (currStatus > 0)
|
||||
{
|
||||
numErrors++;
|
||||
}
|
||||
// registro gli allarmi attivi e trasmetto...
|
||||
if (sendAlarmVariations(item.memAddr, i, item.alarmsState[i], (uint)(item.alarmsMask[i] & currStatus), item.messages))
|
||||
{
|
||||
// se inviato --> salvo stato da current...
|
||||
item.updStatusVal(i, (uint)(item.alarmsMask[i] & currStatus));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
answ = numErrors > 0;
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void checkStrobeHack()
|
||||
{
|
||||
// verifico SE ho un hack sulla var DB85.DB268
|
||||
byte[] byteCtrlW = new byte[2];
|
||||
bool fatto = S7ReadBB(ref byteCtrlW, "DB85.DBB268", 2);
|
||||
ushort valCtrlW = S7.Net.Types.Word.FromByteArray(byteCtrlW.ToArray());
|
||||
// se vale 1 --> resetto strobe!
|
||||
if (valCtrlW == 1)
|
||||
{
|
||||
// aggiunta finale bit a 0 x chiusura processing..
|
||||
var MemBlock = S7.Net.Types.Int.ToByteArray(0);
|
||||
var memAddrWrite = "DB85.DBB308";
|
||||
// imposto valore strobe x check successivi
|
||||
var taskOk = S7WriteBB(ref MemBlock, memAddrWrite);
|
||||
if (taskOk)
|
||||
{
|
||||
strobeVal = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgInfo("SiemensComeca: Strobe attivo su DBB308, ack non rilevato su DBB268");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// - per lo scopo specifico IN REALTA' non conta lo stato macchina.... ma lo inviamo lo stesso
|
||||
/// </summary>
|
||||
protected override void decodeToBaseBitmap()
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* bitmap MAPO STANDARD
|
||||
* B0: POWER_ON
|
||||
* B1: RUN
|
||||
* B2: pzCount
|
||||
* B3: allarme
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
//bool fatto = false;
|
||||
//ushort valW = 0;
|
||||
|
||||
var MemInt = new byte[2];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
|
||||
// processo dagli stati + gravi...
|
||||
if (hasAlarms)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
|
||||
// verifico SE ho strobe/hack da chiudere
|
||||
if (strobeVal != 0)
|
||||
{
|
||||
checkStrobeHack();
|
||||
}
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -278,5 +141,140 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int strobeVal = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#if false
|
||||
protected bool hasAlarms
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
int numErrors = 0;
|
||||
uint currStatus = 0;
|
||||
if (alarmMaps != null)
|
||||
{
|
||||
// leggo a ciclo le aree degli allarmi CONFIGURATI, se ne trovo --> segnalo allarme...
|
||||
foreach (var item in alarmMaps)
|
||||
{
|
||||
// banchi in WORD (2 byte) --> scompongo
|
||||
for (int i = 0; i < item.size / 2; i++)
|
||||
{
|
||||
currStatus = S7.Net.Types.Counter.FromByteArray(RawInput.Skip(item.index + 2 * i).Take(2).ToArray());
|
||||
// verifica e decremento blink...
|
||||
item.checkBlinkCounter(i, (uint)currStatus);
|
||||
|
||||
// verifico SE sia variato... confronto allarmi filtrato stile blink per
|
||||
// bit status:
|
||||
// - allarmi che iniziano per # IGNORATI
|
||||
// - altri allarmi con un countdown da MAX_COUNTER_BLINK a 0 per il
|
||||
// fronte di discesa
|
||||
if (item.isChanged(i, currStatus))
|
||||
{
|
||||
if (currStatus > 0)
|
||||
{
|
||||
numErrors++;
|
||||
}
|
||||
// registro gli allarmi attivi e trasmetto...
|
||||
if (sendAlarmVariations(item.memAddr, i, item.alarmsState[i], (uint)(item.alarmsMask[i] & currStatus), item.messages))
|
||||
{
|
||||
// se inviato --> salvo stato da current...
|
||||
item.updStatusVal(i, (uint)(item.alarmsMask[i] & currStatus));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
answ = numErrors > 0;
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// - per lo scopo specifico IN REALTA' non conta lo stato macchina.... ma lo inviamo lo stesso
|
||||
/// </summary>
|
||||
protected override void decodeToBaseBitmap()
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
|
||||
/* -----------------------------------------------------
|
||||
* bitmap MAPO STANDARD
|
||||
* B0: POWER_ON
|
||||
* B1: RUN
|
||||
* B2: pzCount
|
||||
* B3: allarme
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
//bool fatto = false;
|
||||
//ushort valW = 0;
|
||||
|
||||
var MemInt = new byte[2];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
|
||||
// processo dagli stati + gravi...
|
||||
if (hasAlarms)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
|
||||
// verifico SE ho strobe/hack da chiudere
|
||||
if (strobeVal != 0)
|
||||
{
|
||||
checkStrobeHack();
|
||||
}
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void checkStrobeHack()
|
||||
{
|
||||
// verifico SE ho un hack sulla var DB85.DB268
|
||||
byte[] byteCtrlW = new byte[2];
|
||||
bool fatto = S7ReadBB(ref byteCtrlW, "DB85.DBB268", 2);
|
||||
ushort valCtrlW = S7.Net.Types.Word.FromByteArray(byteCtrlW.ToArray());
|
||||
// se vale 1 --> resetto strobe!
|
||||
if (valCtrlW == 1)
|
||||
{
|
||||
// aggiunta finale bit a 0 x chiusura processing..
|
||||
var MemBlock = S7.Net.Types.Int.ToByteArray(0);
|
||||
var memAddrWrite = "DB85.DBB308";
|
||||
// imposto valore strobe x check successivi
|
||||
var taskOk = S7WriteBB(ref MemBlock, memAddrWrite);
|
||||
if (taskOk)
|
||||
{
|
||||
strobeVal = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lgInfo("SiemensComeca: Strobe attivo su DBB308, ack non rilevato su DBB268");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -63,80 +63,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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: allarme creatore
|
||||
*
|
||||
*
|
||||
* - BIT di stato
|
||||
* - DBX0.0 - Macchina On: Segnale pulito di informazione sullo stato della macchina. 0->Aux OFF, 1->Aux ON
|
||||
* - DBX0.1 – Macchina in Allarme: Segnale pulito di macchina in allarme. 0->Nessun Allarme, 1->E’ presente almeno un allarme/anomalia
|
||||
* - DBX0.2 – Macchina in Ciclo: Segnale pulito sullo stato di funzionamento. 0->La macchina NON sta eseguendo un ciclo automatico, 1->La macchina sta eseguendo un ciclo automatico.
|
||||
* - DBX0.3 – Macchina Non in Produzione: Segnale pulito sullo stato della macchina. 0->Macchina accesa e in lavorazione automatica, 1->Macchina accesa ma NON sta eseguendo un ciclo automatico.
|
||||
* - DBX0.4 – Macchina In Ciclo Continuità: Segnale pulito sullo stato di funzionamento. 1->La macchina sta eseguendo un ciclo automatico con carico/scarico pezzo autonomo, 0-> Altrimenti. NON HA SENSO perché NON HANNO il robot...
|
||||
* - DBX0.7 – Assi In Moto: Segnale pulito sullo stato di movimento Assi. 0->Tutti gli assi della macchina sono fermi, 1->Almeno un asse si sta muovendo.
|
||||
* - DBX1.0 – Impulso Start Ciclo: Impulso a fronte positivo (0->1) della durata di 1’’ che rappresenta l’evento di Start Ciclo.
|
||||
* - DBX1.1 – Impulso Fine Ciclo: Impulso a fronte positivo (0->1) della durata di 1’’ che rappresenta l’evento di Fine Ciclo. Attenzione! Questo impulso viene generato solo se il Ciclo Automatico finisce correttamente. Non viene generato nel caso in cui il Ciclo Automatico venga interrotto da allarmi.
|
||||
* - DBX1.3 – Impulso Conta Pezzi: Impulso a fronte positivo (0->1) della durata di 1’’ generato al completamento di ogni programma pezzo.
|
||||
* - DBX2.0 – Preallarmi Pezzi: Segnale pulito di segnalazione Preallarme Pezzi impostabile su CN. 0->Preallarme Disattivo, 1->Preallarme Attivo
|
||||
* - DBX2.1 – Allarme Pezzi: Segnale pulito di segnalazione Allarme Pezzi impostabile su CN. 0->Allarme Disattivo, 1->Allarme Attivo.
|
||||
* - DBX2.3 – Fine Vita Utensile: Segnale pulito di segnalazione Allarme Fine Vita Creatore. 0->Allarme Disattivo, 1->Allarme Attivo.
|
||||
* - DBX2.7 – Ciclo In Attesa: Segnale pulito sullo stato di funzionamento. 1->Ciclo Automatico attivo ma tutti assi fermi, 0->Altrimenti.
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[0];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
if ((mainData & (1 << 2)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
|
||||
// controllo il bit MAIN dello status
|
||||
if ((mainData & (1 << 1)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
|
||||
// considero come MANUALE NON ciclo in continuo...
|
||||
if ((mainData & (1 << 3)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
|
||||
// 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>
|
||||
@@ -277,5 +203,79 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#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: allarme creatore
|
||||
*
|
||||
*
|
||||
* - BIT di stato
|
||||
* - DBX0.0 - Macchina On: Segnale pulito di informazione sullo stato della macchina. 0->Aux OFF, 1->Aux ON
|
||||
* - DBX0.1 – Macchina in Allarme: Segnale pulito di macchina in allarme. 0->Nessun Allarme, 1->E’ presente almeno un allarme/anomalia
|
||||
* - DBX0.2 – Macchina in Ciclo: Segnale pulito sullo stato di funzionamento. 0->La macchina NON sta eseguendo un ciclo automatico, 1->La macchina sta eseguendo un ciclo automatico.
|
||||
* - DBX0.3 – Macchina Non in Produzione: Segnale pulito sullo stato della macchina. 0->Macchina accesa e in lavorazione automatica, 1->Macchina accesa ma NON sta eseguendo un ciclo automatico.
|
||||
* - DBX0.4 – Macchina In Ciclo Continuità: Segnale pulito sullo stato di funzionamento. 1->La macchina sta eseguendo un ciclo automatico con carico/scarico pezzo autonomo, 0-> Altrimenti. NON HA SENSO perché NON HANNO il robot...
|
||||
* - DBX0.7 – Assi In Moto: Segnale pulito sullo stato di movimento Assi. 0->Tutti gli assi della macchina sono fermi, 1->Almeno un asse si sta muovendo.
|
||||
* - DBX1.0 – Impulso Start Ciclo: Impulso a fronte positivo (0->1) della durata di 1’’ che rappresenta l’evento di Start Ciclo.
|
||||
* - DBX1.1 – Impulso Fine Ciclo: Impulso a fronte positivo (0->1) della durata di 1’’ che rappresenta l’evento di Fine Ciclo. Attenzione! Questo impulso viene generato solo se il Ciclo Automatico finisce correttamente. Non viene generato nel caso in cui il Ciclo Automatico venga interrotto da allarmi.
|
||||
* - DBX1.3 – Impulso Conta Pezzi: Impulso a fronte positivo (0->1) della durata di 1’’ generato al completamento di ogni programma pezzo.
|
||||
* - DBX2.0 – Preallarmi Pezzi: Segnale pulito di segnalazione Preallarme Pezzi impostabile su CN. 0->Preallarme Disattivo, 1->Preallarme Attivo
|
||||
* - DBX2.1 – Allarme Pezzi: Segnale pulito di segnalazione Allarme Pezzi impostabile su CN. 0->Allarme Disattivo, 1->Allarme Attivo.
|
||||
* - DBX2.3 – Fine Vita Utensile: Segnale pulito di segnalazione Allarme Fine Vita Creatore. 0->Allarme Disattivo, 1->Allarme Attivo.
|
||||
* - DBX2.7 – Ciclo In Attesa: Segnale pulito sullo stato di funzionamento. 1->Ciclo Automatico attivo ma tutti assi fermi, 0->Altrimenti.
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[0];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
if ((mainData & (1 << 2)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
|
||||
// controllo il bit MAIN dello status
|
||||
if ((mainData & (1 << 1)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
|
||||
// considero come MANUALE NON ciclo in continuo...
|
||||
if ((mainData & (1 << 3)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
@@ -50,88 +49,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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 (1=attiva/premuta, 0=armed)
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
//bool fatto = false;
|
||||
ushort currStatus = 0;
|
||||
ushort allarme = 0;
|
||||
//ushort valW = 0;
|
||||
|
||||
var MemInt = new byte[2];
|
||||
|
||||
// recupero
|
||||
//fatto = S7ReadBB(ref MemInt, "DB6.DBW204", 2);
|
||||
//valW = S7.Net.Types.Word.FromByteArray(MemInt.ToArray());
|
||||
//var testalW = S7.Net.Types.Word.FromByteArray(RawInput.Skip(204).Take(2).ToArray());
|
||||
currStatus = S7.Net.Types.Word.FromByteArray(RawInput.Skip(204).Take(2).ToArray());
|
||||
|
||||
//fatto = S7ReadBB(ref MemInt, "DB6.DBW206", 2);
|
||||
//valW = S7.Net.Types.Word.FromByteArray(MemInt.ToArray());
|
||||
//allarme = valW;
|
||||
allarme = S7.Net.Types.Word.FromByteArray(RawInput.Skip(206).Take(2).ToArray());
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
|
||||
// processo dagli stati + gravi...
|
||||
if (allarme > 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
|
||||
switch (currStatus)
|
||||
{
|
||||
case 1:
|
||||
byteSignals += (1 << 1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
byteSignals += (1 << 4);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
byteSignals += (1 << 5);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo($"Trasformazione dati: Status:{currStatus} | alarm:{allarme} --> B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -280,5 +197,87 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#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 (1=attiva/premuta, 0=armed)
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
//bool fatto = false;
|
||||
ushort currStatus = 0;
|
||||
ushort allarme = 0;
|
||||
//ushort valW = 0;
|
||||
|
||||
var MemInt = new byte[2];
|
||||
|
||||
// recupero
|
||||
//fatto = S7ReadBB(ref MemInt, "DB6.DBW204", 2);
|
||||
//valW = S7.Net.Types.Word.FromByteArray(MemInt.ToArray());
|
||||
//var testalW = S7.Net.Types.Word.FromByteArray(RawInput.Skip(204).Take(2).ToArray());
|
||||
currStatus = S7.Net.Types.Word.FromByteArray(RawInput.Skip(204).Take(2).ToArray());
|
||||
|
||||
//fatto = S7ReadBB(ref MemInt, "DB6.DBW206", 2);
|
||||
//valW = S7.Net.Types.Word.FromByteArray(MemInt.ToArray());
|
||||
//allarme = valW;
|
||||
allarme = S7.Net.Types.Word.FromByteArray(RawInput.Skip(206).Take(2).ToArray());
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
|
||||
// processo dagli stati + gravi...
|
||||
if (allarme > 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
|
||||
switch (currStatus)
|
||||
{
|
||||
case 1:
|
||||
byteSignals += (1 << 1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
byteSignals += (1 << 4);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
byteSignals += (1 << 5);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo($"Trasformazione dati: Status:{currStatus} | alarm:{allarme} --> B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -95,6 +95,31 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Enums
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dati override in formato dictionary
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Dictionary<string, string> getDynData()
|
||||
{
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
ushort valStatus = S7.Net.Types.Word.FromByteArray(RawInput.Skip(0).Take(2).ToArray());
|
||||
ushort valPosit = S7.Net.Types.Word.FromByteArray(RawInput.Skip(2).Take(2).ToArray());
|
||||
outVal.Add("CURR_STATO", ((statoMacchina)valStatus).ToString());
|
||||
outVal.Add("CURR_POSIT", ((posizioneSequenza)valPosit).ToString());
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid)
|
||||
/// </summary>
|
||||
public override void processOverride()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -263,30 +288,5 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupero dati override in formato dictionary
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Dictionary<string, string> getDynData()
|
||||
{
|
||||
Dictionary<string, string> outVal = new Dictionary<string, string>();
|
||||
ushort valStatus = S7.Net.Types.Word.FromByteArray(RawInput.Skip(0).Take(2).ToArray());
|
||||
ushort valPosit = S7.Net.Types.Word.FromByteArray(RawInput.Skip(2).Take(2).ToArray());
|
||||
outVal.Add("CURR_STATO", ((statoMacchina)valStatus).ToString());
|
||||
outVal.Add("CURR_POSIT", ((posizioneSequenza)valPosit).ToString());
|
||||
return outVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid)
|
||||
/// </summary>
|
||||
public override void processOverride()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -58,14 +58,6 @@ namespace IOB_WIN_NEXT
|
||||
*
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -81,80 +73,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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: Macchina in LAVORAZIONE
|
||||
* - DBX0.1: Macchina in CICLO
|
||||
* - DBX0.2: Macchina in MANUALE
|
||||
* - DBX0.3: Macchina in ALLARME
|
||||
* - DBX0.4: Macchina in EMERGENZA
|
||||
----------------------------------------------------- */
|
||||
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
B_input = currPLC.IsConnected ? 1 : 0;
|
||||
|
||||
// recupero byte segnali...
|
||||
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 << 0)) != 0 && (mainData & (1 << 1)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
// manuale
|
||||
if ((mainData & (1 << 2)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
// allarme
|
||||
if ((mainData & (1 << 3)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
// emergenza
|
||||
if ((mainData & (1 << 4)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 5);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[3]} --> B_input: {B_input}"));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -299,5 +217,87 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#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: Macchina in LAVORAZIONE
|
||||
* - DBX0.1: Macchina in CICLO
|
||||
* - DBX0.2: Macchina in MANUALE
|
||||
* - DBX0.3: Macchina in ALLARME
|
||||
* - DBX0.4: Macchina in EMERGENZA
|
||||
----------------------------------------------------- */
|
||||
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
B_input = currPLC.IsConnected ? 1 : 0;
|
||||
|
||||
// recupero byte segnali...
|
||||
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 << 0)) != 0 && (mainData & (1 << 1)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
// manuale
|
||||
if ((mainData & (1 << 2)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
// allarme
|
||||
if ((mainData & (1 << 3)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
// emergenza
|
||||
if ((mainData & (1 << 4)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 5);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[3]} --> B_input: {B_input}"));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -60,16 +60,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected int counterPlc2MesWrote = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
protected bool useNewSend = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -118,77 +108,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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: RUN STATE
|
||||
* - DBX0.1: CYCLE
|
||||
* - DBX0.2: MANUAL MODE
|
||||
* - DBX0.3: GENERAL ALARM
|
||||
* - DBX0.4: ESTOP (1=OK, 0 = emergency)
|
||||
* - DBX0.5: SAFETY DOORS
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[0];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
if ((mainData & (1 << 0)) == 1)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
|
||||
// EMERGENZA
|
||||
if ((mainData & (1 << 5)) == 1)
|
||||
{
|
||||
byteSignals += (1 << 5);
|
||||
}
|
||||
// ALLARME
|
||||
if ((mainData & (1 << 3)) == 1)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
|
||||
// MANUALE ...
|
||||
if ((mainData & (1 << 2)) == 1)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[3]} --> B_input: {B_input}"));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -561,8 +480,8 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
public override void processWhatchDog()
|
||||
{
|
||||
// scrive nel primo byte, ultimo bit, il watchdog, mentre scrive nel primo 1 = setup, 0 = run
|
||||
// scrivo 1 volta al secondo il contatore incrementale su area apposita
|
||||
// scrive nel primo byte, ultimo bit, il watchdog, mentre scrive nel primo 1 = setup, 0
|
||||
// = run scrivo 1 volta al secondo il contatore incrementale su area apposita
|
||||
DateTime adesso = DateTime.Now;
|
||||
if (adesso.Subtract(lastPLCWatchDog).TotalSeconds > watchDogPeriod)
|
||||
{
|
||||
@@ -581,5 +500,86 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected int counterPlc2MesWrote = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
protected bool useNewSend = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#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: RUN STATE
|
||||
* - DBX0.1: CYCLE
|
||||
* - DBX0.2: MANUAL MODE
|
||||
* - DBX0.3: GENERAL ALARM
|
||||
* - DBX0.4: ESTOP (1=OK, 0 = emergency)
|
||||
* - DBX0.5: SAFETY DOORS
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[0];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
if ((mainData & (1 << 0)) == 1)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
|
||||
// EMERGENZA
|
||||
if ((mainData & (1 << 5)) == 1)
|
||||
{
|
||||
byteSignals += (1 << 5);
|
||||
}
|
||||
// ALLARME
|
||||
if ((mainData & (1 << 3)) == 1)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
|
||||
// MANUALE ...
|
||||
if ((mainData & (1 << 2)) == 1)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo(string.Format($"Trasformazione dati: RawInput:{RawInput[3]} --> B_input: {B_input}"));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
+110
-112
@@ -1,8 +1,6 @@
|
||||
using MapoSDK;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
@@ -25,12 +23,12 @@ namespace IOB_WIN_NEXT
|
||||
* B00..B15 --> 16 byte di allarmi (osmosi, depurazione, 6 x filtri)
|
||||
* B20..B35 --> 16 byte di stati (osmosi, depurazione, 6 x filtri)
|
||||
* B40..B49 --> 5 valori uint lettura parametri
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* STRUTTURA MEMORIA DB101: (scrittura) 14byte, solo 2 impiegati x ora
|
||||
* NB: segnali da tenere attivi ALMENO 3 secondi x farli recepire
|
||||
*
|
||||
*
|
||||
* B0.0 Bit Azzeramento volume acqua OSMOSI
|
||||
* B0.1 Bit Azzeramento volume acqua DEPURAZIONE
|
||||
*
|
||||
@@ -38,12 +36,6 @@ namespace IOB_WIN_NEXT
|
||||
*
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected bool EmergencyBypass = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -64,6 +56,114 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#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)
|
||||
{
|
||||
lgInfo($"Chiamata executeTasks specifica IobSiemensNWS: {task2exe.Count} task ricevuti");
|
||||
// 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.forceResetPzCount:
|
||||
// usato x resettare i contatori osmosi inversa e depurazione processo
|
||||
// scrittura BIT su DB101.DBB0 per
|
||||
MemBlock = new byte[1];
|
||||
// scrivo 3 x resettare entrambi i contatori
|
||||
MemBlock = S7.Net.Types.Byte.ToByteArray(3);
|
||||
memAddrWrite = "DB101.DB0";
|
||||
// scrivo!
|
||||
taskOk = S7WriteBB(ref MemBlock, memAddrWrite);
|
||||
// attesa 3.5 sec sec
|
||||
Thread.Sleep(3500);
|
||||
// predispongo x reset valore 0...
|
||||
MemBlock = S7.Net.Types.Byte.ToByteArray(0);
|
||||
|
||||
break;
|
||||
|
||||
// lasciato commentato, da rivalutare...
|
||||
#if false
|
||||
case taskType.setParameter:
|
||||
// richiedo da URL i parametri WRITE da popolare
|
||||
lgInfo("setParameter --> 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;
|
||||
#endif
|
||||
|
||||
default:
|
||||
taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC";
|
||||
break;
|
||||
}
|
||||
|
||||
lgInfo($"executeTask | task name: {tName} | task value: {taskVal}");
|
||||
// aggiungo task!
|
||||
taskDone.Add(item.Key, taskVal);
|
||||
if (!string.IsNullOrEmpty(memAddrWrite))
|
||||
{
|
||||
// scrivo!
|
||||
taskOk = S7WriteBB(ref MemBlock, memAddrWrite);
|
||||
}
|
||||
if (taskOk)
|
||||
{
|
||||
// aggiorno valore memoria... SE presente
|
||||
if (memMap.mMapWrite.ContainsKey(item.Key))
|
||||
{
|
||||
memMap.mMapWrite[item.Key].value = item.Value;
|
||||
lgInfo($"Aggiornato valore in mMapWrite per {item.Key}");
|
||||
}
|
||||
lgInfo($"Eseguita con successo S7WriteBB per executeTasks: {item.Key} | {item.Value}");
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
return taskDone;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected bool EmergencyBypass = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -116,107 +216,5 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
lgInfo($"Chiamata executeTasks specifica IobSiemensNWS: {task2exe.Count} task ricevuti");
|
||||
// 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.forceResetPzCount:
|
||||
// usato x resettare i contatori osmosi inversa e depurazione
|
||||
// processo scrittura BIT su DB101.DBB0 per
|
||||
MemBlock = new byte[1];
|
||||
// scrivo 3 x resettare entrambi i contatori
|
||||
MemBlock = S7.Net.Types.Byte.ToByteArray(3);
|
||||
memAddrWrite = "DB101.DB0";
|
||||
// scrivo!
|
||||
taskOk = S7WriteBB(ref MemBlock, memAddrWrite);
|
||||
// attesa 3.5 sec sec
|
||||
Thread.Sleep(3500);
|
||||
// predispongo x reset valore 0...
|
||||
MemBlock = S7.Net.Types.Byte.ToByteArray(0);
|
||||
|
||||
break;
|
||||
|
||||
// lasciato commentato, da rivalutare...
|
||||
#if false
|
||||
case taskType.setParameter:
|
||||
// richiedo da URL i parametri WRITE da popolare
|
||||
lgInfo("setParameter --> 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;
|
||||
#endif
|
||||
|
||||
default:
|
||||
taskVal = $"taskReq: {tName} | key: {item.Key} | val: {item.Value} | SKIPPED | NO EXEC";
|
||||
break;
|
||||
}
|
||||
|
||||
lgInfo($"executeTask | task name: {tName} | task value: {taskVal}");
|
||||
// aggiungo task!
|
||||
taskDone.Add(item.Key, taskVal);
|
||||
if (!string.IsNullOrEmpty(memAddrWrite))
|
||||
{
|
||||
// scrivo!
|
||||
taskOk = S7WriteBB(ref MemBlock, memAddrWrite);
|
||||
}
|
||||
if (taskOk)
|
||||
{
|
||||
// aggiorno valore memoria... SE presente
|
||||
if (memMap.mMapWrite.ContainsKey(item.Key))
|
||||
{
|
||||
memMap.mMapWrite[item.Key].value = item.Value;
|
||||
lgInfo($"Aggiornato valore in mMapWrite per {item.Key}");
|
||||
}
|
||||
lgInfo($"Eseguita con successo S7WriteBB per executeTasks: {item.Key} | {item.Value}");
|
||||
}
|
||||
else
|
||||
{
|
||||
lgError($"Errore in S7WriteBB durante executeTasks: {item.Key} | {item.Value}");
|
||||
}
|
||||
}
|
||||
}
|
||||
return taskDone;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -40,77 +32,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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>
|
||||
@@ -270,5 +191,84 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#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
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
@@ -46,12 +44,6 @@ namespace IOB_WIN_NEXT
|
||||
*
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected bool EmergencyBypass = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -72,61 +64,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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: MagOutPieno
|
||||
* B6: MagInVuoto
|
||||
* B7: Emergenza armata (1)
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[0];
|
||||
|
||||
// copio il primo byte
|
||||
int byteSignals = RawInput[0];
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals |= (1 << 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
byteSignals &= ~(1 << 0);
|
||||
}
|
||||
|
||||
// se bypass emergenza attivo --> forzo a ARMED...
|
||||
if (EmergencyBypass)
|
||||
{
|
||||
byteSignals |= (1 << 7);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo($"Trasformazione dati: B0: {mainData} --> B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -275,5 +212,66 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected bool EmergencyBypass = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#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: MagOutPieno
|
||||
* B6: MagInVuoto
|
||||
* B7: Emergenza armata (1)
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[0];
|
||||
|
||||
// copio il primo byte
|
||||
int byteSignals = RawInput[0];
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals |= (1 << 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
byteSignals &= ~(1 << 0);
|
||||
}
|
||||
|
||||
// se bypass emergenza attivo --> forzo a ARMED...
|
||||
if (EmergencyBypass)
|
||||
{
|
||||
byteSignals |= (1 << 7);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo($"Trasformazione dati: B0: {mainData} --> B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -59,15 +59,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected int counterPlc2MesWrote = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -83,86 +74,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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: anomalia
|
||||
*
|
||||
*
|
||||
* - BIT di stato
|
||||
* - DBX2.0: macchina accesa
|
||||
* - DBX2.1: CICLO AUTO = NON HO ANOMALIE/ALLARMI (0 --> allarme)
|
||||
* - DBX2.2: contapezzi
|
||||
* - DBX2.3: MACCHINA IN CICLO AUTO = LAVORA
|
||||
* - DBX2.4: ERRORE tra part code MES/SAET (blu)
|
||||
* - DBX2.5: Anomalia presente (rosso)
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[2];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
if ((mainData & (1 << 3)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
|
||||
// controllo il bit ALLARME
|
||||
if ((mainData & (1 << 1)) == 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
|
||||
// controllo il bit ANOMALIA
|
||||
if ((mainData & (1 << 5)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
|
||||
// considero NON auto come manuale...
|
||||
if ((mainData & (1 << 3)) == 0)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// processo il watchdog!
|
||||
counterPlc2Mes = S7.Net.Types.Int.FromByteArray(RawInput.Skip(0).Take(2).ToArray());
|
||||
// ogni 60 registro...
|
||||
if (Math.Abs(counterPlc2Mes - counterPlc2MesWrote) > 60)
|
||||
{
|
||||
lgInfo($"WatchDog da PLC: {counterPlc2Mes}");
|
||||
counterPlc2MesWrote = counterPlc2Mes;
|
||||
}
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo($"Trasformazione dati: RawInput:{RawInput[3]} --> B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -338,5 +249,94 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int counterMes2Plc = 0;
|
||||
protected int counterPlc2Mes = 0;
|
||||
protected int counterPlc2MesWrote = 0;
|
||||
protected DateTime lastPLCWatchDog;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#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: anomalia
|
||||
*
|
||||
*
|
||||
* - BIT di stato
|
||||
* - DBX2.0: macchina accesa
|
||||
* - DBX2.1: CICLO AUTO = NON HO ANOMALIE/ALLARMI (0 --> allarme)
|
||||
* - DBX2.2: contapezzi
|
||||
* - DBX2.3: MACCHINA IN CICLO AUTO = LAVORA
|
||||
* - DBX2.4: ERRORE tra part code MES/SAET (blu)
|
||||
* - DBX2.5: Anomalia presente (rosso)
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[2];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
if ((mainData & (1 << 3)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
|
||||
// controllo il bit ALLARME
|
||||
if ((mainData & (1 << 1)) == 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
|
||||
// controllo il bit ANOMALIA
|
||||
if ((mainData & (1 << 5)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
|
||||
// considero NON auto come manuale...
|
||||
if ((mainData & (1 << 3)) == 0)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// processo il watchdog!
|
||||
counterPlc2Mes = S7.Net.Types.Int.FromByteArray(RawInput.Skip(0).Take(2).ToArray());
|
||||
// ogni 60 registro...
|
||||
if (Math.Abs(counterPlc2Mes - counterPlc2MesWrote) > 60)
|
||||
{
|
||||
lgInfo($"WatchDog da PLC: {counterPlc2Mes}");
|
||||
counterPlc2MesWrote = counterPlc2Mes;
|
||||
}
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo($"Trasformazione dati: RawInput:{RawInput[3]} --> B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -59,82 +59,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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 (1=attiva/premuta, 0=armed)
|
||||
*
|
||||
* - BIT di stato
|
||||
* DB29 blocco dati letto dal MES Byte Bit
|
||||
* CicloOn Bool 0 0
|
||||
* MacchOn Bool 0 1
|
||||
* ManualeOn Bool 0 2
|
||||
* AllarmiOn Bool 0 3
|
||||
* EmergenzaOn Bool 0 4
|
||||
* EmergenzaPremuta Bool 0 5
|
||||
* ContapezziAssoluto DInt 2
|
||||
* Comtapezzi parziale DInt 6
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[0];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
|
||||
// lavora --> bit0 e bit1: cicloOn AND macchOn
|
||||
if ((mainData & (1 << 0)) != 0 && (mainData & (1 << 1)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
|
||||
// controllo il bit ALARM
|
||||
if ((mainData & (1 << 3)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
// controllo il bit emergenza dello status
|
||||
if ((mainData & (1 << 5)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 5);
|
||||
}
|
||||
|
||||
// check MANUALE ...
|
||||
if ((mainData & (1 << 2)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
|
||||
// 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>
|
||||
@@ -248,6 +172,7 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
taskVal = "SKIPPED | NO EXEC";
|
||||
break;
|
||||
@@ -264,5 +189,81 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#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 (1=attiva/premuta, 0=armed)
|
||||
*
|
||||
* - BIT di stato
|
||||
* DB29 blocco dati letto dal MES Byte Bit
|
||||
* CicloOn Bool 0 0
|
||||
* MacchOn Bool 0 1
|
||||
* ManualeOn Bool 0 2
|
||||
* AllarmiOn Bool 0 3
|
||||
* EmergenzaOn Bool 0 4
|
||||
* EmergenzaPremuta Bool 0 5
|
||||
* ContapezziAssoluto DInt 2
|
||||
* Comtapezzi parziale DInt 6
|
||||
*
|
||||
----------------------------------------------------- */
|
||||
|
||||
byte mainData = RawInput[0];
|
||||
|
||||
int byteSignals = 0;
|
||||
// bit 0 (poweron) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSignals += (1 << 0);
|
||||
}
|
||||
|
||||
// lavora --> bit0 e bit1: cicloOn AND macchOn
|
||||
if ((mainData & (1 << 0)) != 0 && (mainData & (1 << 1)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 1);
|
||||
}
|
||||
|
||||
// controllo il bit ALARM
|
||||
if ((mainData & (1 << 3)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 3);
|
||||
}
|
||||
// controllo il bit emergenza dello status
|
||||
if ((mainData & (1 << 5)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 5);
|
||||
}
|
||||
|
||||
// check MANUALE ...
|
||||
if ((mainData & (1 << 2)) != 0)
|
||||
{
|
||||
byteSignals += (1 << 4);
|
||||
}
|
||||
|
||||
// salvo!
|
||||
B_input = byteSignals;
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo($"Trasformazione dati: RawInput:{RawInput[0]} --> B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
+232
-229
@@ -17,12 +17,6 @@ namespace IOB_WIN_NEXT
|
||||
* mod: 2019.04.06: aggiunta indicazione (IOB--> PLC) di stato setup su DB701.B0.4
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected Dictionary<string, string> lastReadAlarms = new Dictionary<string, string>();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -38,228 +32,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private int checkAlarmBank(string memAddrAlarms)
|
||||
{
|
||||
int trovato = 0;
|
||||
uint valDW = 0;
|
||||
var MemBlockPZ = new byte[4];
|
||||
bool fatto = S7ReadBB(ref MemBlockPZ, memAddrAlarms, 4);
|
||||
//if (fatto)
|
||||
//{
|
||||
valDW = S7.Net.Types.DWord.FromByteArray(MemBlockPZ.ToArray());
|
||||
// se <> 0 --> log e accodo a dynData
|
||||
if (valDW != 0)
|
||||
{
|
||||
string key = $"MTH_ALARM_{memAddrAlarms}_{valDW}";
|
||||
var biteVal = baseUtils.binaryForm(valDW);
|
||||
lgInfo($"Stato allarmi rilevati: {key} | {valDW} | {biteVal}");
|
||||
// accodo a dictionary
|
||||
string almMsg = $"{DateTime.Now} | val {valDW} | {biteVal}";
|
||||
// se non ci fosse aggiungo
|
||||
if (!lastReadAlarms.ContainsKey(key))
|
||||
{
|
||||
lastReadAlarms.Add(key, almMsg);
|
||||
}
|
||||
trovato++;
|
||||
}
|
||||
//}
|
||||
return trovato;
|
||||
}
|
||||
|
||||
private void checkAlarms()
|
||||
{
|
||||
// leggo i banchi allarmi : cablato D700.DBDW2 --> D700 DBDW14, sono 4 banchi a 32 bit da verificare
|
||||
|
||||
int trovati = 0;
|
||||
// ciclo nei 4 banchi...
|
||||
trovati += checkAlarmBank("DB700.DBDW2");
|
||||
trovati += checkAlarmBank("DB700.DBDW6");
|
||||
trovati += checkAlarmBank("DB700.DBDW10");
|
||||
trovati += checkAlarmBank("DB700.DBDW14");
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Decodifica il resto dell'area TORRI x i dati accessori (allarmi, ...)
|
||||
/// </summary>
|
||||
protected override void decodeOtherData()
|
||||
{
|
||||
if (verboseLog)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// </summary>
|
||||
protected override void decodeToBaseBitmap()
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
// TORRI: leggo i primi 8 bit hard coded...
|
||||
int byteSem = RawInput[0];
|
||||
|
||||
// azzero powerOn...
|
||||
byteSem &= ~(1 << 0);
|
||||
// bit 0 (powerOn) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSem += (1 << 0);
|
||||
}
|
||||
|
||||
// azzero i bit NON gestiti (2-5-6-7)
|
||||
byteSem &= ~(1 << 2);
|
||||
byteSem &= ~(1 << 5);
|
||||
byteSem &= ~(1 << 6);
|
||||
byteSem &= ~(1 << 7);
|
||||
// leggo bit DB700.B1.4 e lo porto al bit 5 --> ciclo test/accensione/spegnimento
|
||||
if ((RawInput[1] & (1 << 4)) != 0) //se RawInput[1] & 16-- > 5° bit-- > TEST
|
||||
{
|
||||
byteSem += (1 << 5);
|
||||
}
|
||||
// salvo infine variabile bit x invio
|
||||
B_input = byteSem;
|
||||
|
||||
// se ho il bit di allarme
|
||||
if ((RawInput[0] & (1 << 3)) != 0)
|
||||
{
|
||||
checkAlarms();
|
||||
}
|
||||
|
||||
// procedo SOLO SE è enabled IOB
|
||||
if (IobOnline)
|
||||
{
|
||||
try
|
||||
{
|
||||
currODL = utils.callUrl(urlGetCurrODL);
|
||||
// solo SE HO un ODL...
|
||||
if (string.IsNullOrEmpty(currODL) || currODL == "0")
|
||||
{
|
||||
if (periodicLog)
|
||||
{
|
||||
lgInfo($"SiemensTorri | Lettura ODL andata a vuoto: currODL: {currODL}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// se variato o scaduto timeout log...
|
||||
if (periodicLog || (currIdxODL.ToString() != currODL))
|
||||
{
|
||||
lgInfo($"SiemensTorri | Lettura ODL, currODL: {currODL} --> currIdxODL prec: {currIdxODL}");
|
||||
}
|
||||
// provo a salvare nuovo ODL
|
||||
int.TryParse(currODL, out currIdxODL);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
if (DateTime.Now.Subtract(lastWarnODL).TotalSeconds > 15)
|
||||
{
|
||||
lgError(exc, $"Errore in fase di chiamata URL x ODL corrente | URL chiamato: {urlGetCurrODL}");
|
||||
lastWarnODL = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// imposto currODL a vuoto!
|
||||
currODL = "";
|
||||
if (periodicLog)
|
||||
{
|
||||
lgInfo($"Fanuc | Lettura ODL non effettuata: IobOnline: {IobOnline} | currODL impostato a vuoto");
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(currODL) && currODL != "0")
|
||||
{
|
||||
// ora processo il contapezzi...
|
||||
string retVal = "";
|
||||
// controllo se è passato intervallo minimo tra 2 controlli/elaborazioni x distanziare invio e ridurre letture
|
||||
if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay))
|
||||
{
|
||||
// Salvo il contapezzi della macchina
|
||||
retVal = utils.callUrlNow(urlSetPzCountMAC + contapezziPLC.ToString());
|
||||
// verifica se tutto OK, ovvero conferma i pezzi inviati
|
||||
if (retVal != contapezziPLC.ToString())
|
||||
{
|
||||
// errore salvataggio contapezzi
|
||||
lgInfo($"Errore salvataggio Contapezzi PLC SIEMENST-TORRI: {contapezziPLC} | contapezziIOB {contapezziIOB} | Valore tornato: {retVal}");
|
||||
// rileggo il counter pezzi da server
|
||||
pzCntReload(true);
|
||||
}
|
||||
|
||||
// se sono differenti MOSTRO...
|
||||
if (contapezziPLC != contapezziIOB)
|
||||
{
|
||||
// registro contapezzi
|
||||
lgInfo($"Differenza Contapezzi: contapezziPLC: {contapezziPLC} | contapezziIOB: {contapezziIOB}");
|
||||
}
|
||||
if ((contapezziPLC > contapezziIOB))
|
||||
{
|
||||
// salvo nuovo contapezzi (incremento di 1...) + richiesta refresh conteggio
|
||||
contapezziIOB++;
|
||||
needRefreshPzCount = true;
|
||||
// salvo in semaforo!
|
||||
B_input += 1 << 2;
|
||||
// registro contapezzi
|
||||
lgInfo($"contapezziPLC SIEMENST-TORRI: {contapezziPLC} | contapezziIOB {contapezziIOB}");
|
||||
}
|
||||
|
||||
// Salvo il contapezzi della macchina
|
||||
retVal = utils.callUrlNow(urlSetPzCount + contapezziIOB.ToString());
|
||||
// verifica se tutto OK, ovvero conferma i pezzi inviati
|
||||
if (retVal != contapezziIOB.ToString())
|
||||
{
|
||||
// errore salvataggio contapezzi
|
||||
lgInfo($"Errore salvataggio contapezziPLC SIEMENST-TORRI: {contapezziPLC} | contapezziIOB {contapezziIOB} | Valore tornato: {retVal}");
|
||||
// rileggo il counter pezzi da server
|
||||
pzCntReload(true);
|
||||
}
|
||||
|
||||
// verifico se variato contapezzi... e se passato ritardo minimo...
|
||||
if ((contapezziPLC - contapezziIOB) > minSendPzCountBlock)
|
||||
{
|
||||
trySendPzCountBlock();
|
||||
}
|
||||
|
||||
// invio a server contapezzi (aggiornato)
|
||||
retVal = utils.callUrlNow(urlSetPzCount + contapezziIOB.ToString());
|
||||
// verifica se tutto OK
|
||||
if (retVal != contapezziIOB.ToString())
|
||||
{
|
||||
// errore salvataggio contapezzi
|
||||
lgInfo($"Errore salvataggio Contapezzi SIEMENS-TORRI: contapezziPLC {contapezziPLC} | contapezziIOB {contapezziIOB} | risposta: {retVal}");
|
||||
// rileggo il counter pezzi da server
|
||||
pzCntReload(true);
|
||||
}
|
||||
|
||||
// resetto timer...
|
||||
lastPzCountSend = DateTime.Now;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay))
|
||||
{
|
||||
lgInfo($"Attenzione: mancanza ODL non procedo con gestione contapezzi. contapezziPLC SIEMENST-TORRI: {contapezziPLC} | contapezziIOB: {contapezziIOB}");
|
||||
// resetto timer...
|
||||
lastPzCountSend = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo("Trasformazione B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -409,7 +181,8 @@ namespace IOB_WIN_NEXT
|
||||
outVal.Add("FEED_OVER", RawInput[19].ToString());
|
||||
outVal.Add("RAPID_OVER", RawInput[20].ToString());
|
||||
outVal.Add("CURR_MODE", decodeCurrMode(RawInput[21]));
|
||||
// recupero RPM pezzo/mola !!!FARE!!! cambio nome da config, qui sono 01:conduttrice e 02:operatrice (3013), mentre sono pezzo/mola nella V100
|
||||
// recupero RPM pezzo/mola !!!FARE!!! cambio nome da config, qui sono 01:conduttrice e
|
||||
// 02:operatrice (3013), mentre sono pezzo/mola nella V100
|
||||
valDW = S7.Net.Types.DWord.FromByteArray(RawInput.Skip(24).Take(4).ToArray());
|
||||
outVal.Add("RPM_01", valDW.ToString());
|
||||
valDW = S7.Net.Types.DWord.FromByteArray(RawInput.Skip(28).Take(4).ToArray());
|
||||
@@ -510,5 +283,235 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected Dictionary<string, string> lastReadAlarms = new Dictionary<string, string>();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Decodifica il resto dell'area TORRI x i dati accessori (allarmi, ...)
|
||||
/// </summary>
|
||||
protected override void decodeOtherData()
|
||||
{
|
||||
if (verboseLog)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua decodifica aree memoria alla bitmap usata x MAPO
|
||||
/// </summary>
|
||||
protected override void decodeToBaseBitmap()
|
||||
{
|
||||
// init a zero...
|
||||
B_input = 0;
|
||||
// TORRI: leggo i primi 8 bit hard coded...
|
||||
int byteSem = RawInput[0];
|
||||
|
||||
// azzero powerOn...
|
||||
byteSem &= ~(1 << 0);
|
||||
// bit 0 (powerOn) imposto a 1 SE connected...
|
||||
if (currPLC.IsConnected)
|
||||
{
|
||||
byteSem += (1 << 0);
|
||||
}
|
||||
|
||||
// azzero i bit NON gestiti (2-5-6-7)
|
||||
byteSem &= ~(1 << 2);
|
||||
byteSem &= ~(1 << 5);
|
||||
byteSem &= ~(1 << 6);
|
||||
byteSem &= ~(1 << 7);
|
||||
// leggo bit DB700.B1.4 e lo porto al bit 5 --> ciclo test/accensione/spegnimento
|
||||
if ((RawInput[1] & (1 << 4)) != 0) //se RawInput[1] & 16-- > 5° bit-- > TEST
|
||||
{
|
||||
byteSem += (1 << 5);
|
||||
}
|
||||
// salvo infine variabile bit x invio
|
||||
B_input = byteSem;
|
||||
|
||||
// se ho il bit di allarme
|
||||
if ((RawInput[0] & (1 << 3)) != 0)
|
||||
{
|
||||
checkAlarms();
|
||||
}
|
||||
|
||||
// procedo SOLO SE è enabled IOB
|
||||
if (IobOnline)
|
||||
{
|
||||
try
|
||||
{
|
||||
currODL = utils.callUrl(urlGetCurrODL);
|
||||
// solo SE HO un ODL...
|
||||
if (string.IsNullOrEmpty(currODL) || currODL == "0")
|
||||
{
|
||||
if (periodicLog)
|
||||
{
|
||||
lgInfo($"SiemensTorri | Lettura ODL andata a vuoto: currODL: {currODL}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// se variato o scaduto timeout log...
|
||||
if (periodicLog || (currIdxODL.ToString() != currODL))
|
||||
{
|
||||
lgInfo($"SiemensTorri | Lettura ODL, currODL: {currODL} --> currIdxODL prec: {currIdxODL}");
|
||||
}
|
||||
// provo a salvare nuovo ODL
|
||||
int.TryParse(currODL, out currIdxODL);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
if (DateTime.Now.Subtract(lastWarnODL).TotalSeconds > 15)
|
||||
{
|
||||
lgError(exc, $"Errore in fase di chiamata URL x ODL corrente | URL chiamato: {urlGetCurrODL}");
|
||||
lastWarnODL = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// imposto currODL a vuoto!
|
||||
currODL = "";
|
||||
if (periodicLog)
|
||||
{
|
||||
lgInfo($"Fanuc | Lettura ODL non effettuata: IobOnline: {IobOnline} | currODL impostato a vuoto");
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(currODL) && currODL != "0")
|
||||
{
|
||||
// ora processo il contapezzi...
|
||||
string retVal = "";
|
||||
// controllo se è passato intervallo minimo tra 2 controlli/elaborazioni x
|
||||
// distanziare invio e ridurre letture
|
||||
if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay))
|
||||
{
|
||||
// Salvo il contapezzi della macchina
|
||||
retVal = utils.callUrlNow(urlSetPzCountMAC + contapezziPLC.ToString());
|
||||
// verifica se tutto OK, ovvero conferma i pezzi inviati
|
||||
if (retVal != contapezziPLC.ToString())
|
||||
{
|
||||
// errore salvataggio contapezzi
|
||||
lgInfo($"Errore salvataggio Contapezzi PLC SIEMENST-TORRI: {contapezziPLC} | contapezziIOB {contapezziIOB} | Valore tornato: {retVal}");
|
||||
// rileggo il counter pezzi da server
|
||||
pzCntReload(true);
|
||||
}
|
||||
|
||||
// se sono differenti MOSTRO...
|
||||
if (contapezziPLC != contapezziIOB)
|
||||
{
|
||||
// registro contapezzi
|
||||
lgInfo($"Differenza Contapezzi: contapezziPLC: {contapezziPLC} | contapezziIOB: {contapezziIOB}");
|
||||
}
|
||||
if ((contapezziPLC > contapezziIOB))
|
||||
{
|
||||
// salvo nuovo contapezzi (incremento di 1...) + richiesta refresh conteggio
|
||||
contapezziIOB++;
|
||||
needRefreshPzCount = true;
|
||||
// salvo in semaforo!
|
||||
B_input += 1 << 2;
|
||||
// registro contapezzi
|
||||
lgInfo($"contapezziPLC SIEMENST-TORRI: {contapezziPLC} | contapezziIOB {contapezziIOB}");
|
||||
}
|
||||
|
||||
// Salvo il contapezzi della macchina
|
||||
retVal = utils.callUrlNow(urlSetPzCount + contapezziIOB.ToString());
|
||||
// verifica se tutto OK, ovvero conferma i pezzi inviati
|
||||
if (retVal != contapezziIOB.ToString())
|
||||
{
|
||||
// errore salvataggio contapezzi
|
||||
lgInfo($"Errore salvataggio contapezziPLC SIEMENST-TORRI: {contapezziPLC} | contapezziIOB {contapezziIOB} | Valore tornato: {retVal}");
|
||||
// rileggo il counter pezzi da server
|
||||
pzCntReload(true);
|
||||
}
|
||||
|
||||
// verifico se variato contapezzi... e se passato ritardo minimo...
|
||||
if ((contapezziPLC - contapezziIOB) > minSendPzCountBlock)
|
||||
{
|
||||
trySendPzCountBlock();
|
||||
}
|
||||
|
||||
// invio a server contapezzi (aggiornato)
|
||||
retVal = utils.callUrlNow(urlSetPzCount + contapezziIOB.ToString());
|
||||
// verifica se tutto OK
|
||||
if (retVal != contapezziIOB.ToString())
|
||||
{
|
||||
// errore salvataggio contapezzi
|
||||
lgInfo($"Errore salvataggio Contapezzi SIEMENS-TORRI: contapezziPLC {contapezziPLC} | contapezziIOB {contapezziIOB} | risposta: {retVal}");
|
||||
// rileggo il counter pezzi da server
|
||||
pzCntReload(true);
|
||||
}
|
||||
|
||||
// resetto timer...
|
||||
lastPzCountSend = DateTime.Now;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DateTime.Now >= lastPzCountSend.AddMilliseconds(pzCountDelay))
|
||||
{
|
||||
lgInfo($"Attenzione: mancanza ODL non procedo con gestione contapezzi. contapezziPLC SIEMENST-TORRI: {contapezziPLC} | contapezziIOB: {contapezziIOB}");
|
||||
// resetto timer...
|
||||
lastPzCountSend = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
// log opzionale!
|
||||
if (verboseLog)
|
||||
{
|
||||
lgInfo("Trasformazione B_input: {B_input}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private int checkAlarmBank(string memAddrAlarms)
|
||||
{
|
||||
int trovato = 0;
|
||||
uint valDW = 0;
|
||||
var MemBlockPZ = new byte[4];
|
||||
bool fatto = S7ReadBB(ref MemBlockPZ, memAddrAlarms, 4);
|
||||
//if (fatto)
|
||||
//{
|
||||
valDW = S7.Net.Types.DWord.FromByteArray(MemBlockPZ.ToArray());
|
||||
// se <> 0 --> log e accodo a dynData
|
||||
if (valDW != 0)
|
||||
{
|
||||
string key = $"MTH_ALARM_{memAddrAlarms}_{valDW}";
|
||||
var biteVal = baseUtils.binaryForm(valDW);
|
||||
lgInfo($"Stato allarmi rilevati: {key} | {valDW} | {biteVal}");
|
||||
// accodo a dictionary
|
||||
string almMsg = $"{DateTime.Now} | val {valDW} | {biteVal}";
|
||||
// se non ci fosse aggiungo
|
||||
if (!lastReadAlarms.ContainsKey(key))
|
||||
{
|
||||
lastReadAlarms.Add(key, almMsg);
|
||||
}
|
||||
trovato++;
|
||||
}
|
||||
//}
|
||||
return trovato;
|
||||
}
|
||||
|
||||
private void checkAlarms()
|
||||
{
|
||||
// leggo i banchi allarmi : cablato D700.DBDW2 --> D700 DBDW14, sono 4 banchi a 32 bit
|
||||
// da verificare
|
||||
|
||||
int trovati = 0;
|
||||
// ciclo nei 4 banchi...
|
||||
trovati += checkAlarmBank("DB700.DBDW2");
|
||||
trovati += checkAlarmBank("DB700.DBDW6");
|
||||
trovati += checkAlarmBank("DB700.DBDW10");
|
||||
trovati += checkAlarmBank("DB700.DBDW14");
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
+146
-145
@@ -9,13 +9,13 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
/// <summary>
|
||||
/// Generica classe per implementare WebPageScraping (scaricamento web pages anche js-based x recupero informazioni)
|
||||
/// Generica classe per implementare WebPageScraping (scaricamento web pages anche js-based x
|
||||
/// recupero informazioni)
|
||||
/// </summary>
|
||||
public class IobWPS : IobGeneric, IDisposable
|
||||
{
|
||||
@@ -27,40 +27,6 @@ namespace IOB_WIN_NEXT
|
||||
*
|
||||
* -------------------------------------------------------------------------------- */
|
||||
|
||||
#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>
|
||||
/// 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>
|
||||
@@ -76,115 +42,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#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>
|
||||
private void reloadAdapterConf()
|
||||
{
|
||||
// init obj display
|
||||
newDisplayData currDispData = new newDisplayData();
|
||||
lgInfo("BEGIN reloadAdapterConf");
|
||||
// inizializzo LUT decodifica
|
||||
string jsonConf = getOptPar("LUT_CONF");
|
||||
if (!string.IsNullOrEmpty(jsonConf))
|
||||
{
|
||||
string jsonFullPath = $"{Application.StartupPath}/DATA/CONF/{jsonConf}";
|
||||
lgInfo($"Apertura file {jsonFullPath}");
|
||||
StreamReader reader = new StreamReader(jsonFullPath);
|
||||
string jsonData = reader.ReadToEnd();
|
||||
if (!string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
try
|
||||
{
|
||||
monitoredItems = JsonConvert.DeserializeObject<MonitoredItemsConf>(jsonData);
|
||||
// salvo baseUri
|
||||
baseUri = monitoredItems.SrvData.baseUri;
|
||||
lgInfo($"baseUri = {baseUri}");
|
||||
// imposto a zero la bitmap x riavvio!
|
||||
B_input = 0;
|
||||
// FORZO invio dati...
|
||||
accodaSigIN(ref currDispData);
|
||||
// loggo!
|
||||
lgInfo($"init input bitmap to zero: {B_input}");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Eccezione in decodifica conf json");
|
||||
}
|
||||
}
|
||||
reader.Dispose();
|
||||
}
|
||||
lgInfo("DONE reloadAdapterConf");
|
||||
raiseRefresh(currDispData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Avvio del WebDriver
|
||||
/// </summary>
|
||||
private void startDriver()
|
||||
{
|
||||
if (monitoredItems.SrvData.driverName == "CHROME")
|
||||
{
|
||||
lgInfo("Starting CHROME Driver");
|
||||
// preparo opzione headless x CHROME
|
||||
var o = new ChromeOptions();
|
||||
o.AddArgument("headless");
|
||||
ChromeDriverService service = ChromeDriverService.CreateDefaultService(Application.StartupPath);
|
||||
service.HideCommandPromptWindow = true;
|
||||
driver = new ChromeDriver(service, o);
|
||||
}
|
||||
else
|
||||
{
|
||||
lgInfo("Starting FIREFOX Driver");
|
||||
// preparo opzione headless x FIREFOX
|
||||
var o = new FirefoxOptions();
|
||||
o.AddArgument("-headless");
|
||||
o.SetPreference("app.update.auto", false);
|
||||
o.SetPreference("app.update.enabled", false);
|
||||
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(Application.StartupPath);
|
||||
service.HideCommandPromptWindow = true;
|
||||
driver = new FirefoxDriver(service, o);
|
||||
}
|
||||
// aggiungo timeout x JScripts
|
||||
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
|
||||
driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(20);
|
||||
// imposto pagina di acquisizione
|
||||
driver.Navigate().GoToUrl(baseUri);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void Dispose()
|
||||
@@ -387,5 +244,149 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#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>
|
||||
/// 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 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>
|
||||
private void reloadAdapterConf()
|
||||
{
|
||||
// init obj display
|
||||
newDisplayData currDispData = new newDisplayData();
|
||||
lgInfo("BEGIN reloadAdapterConf");
|
||||
// inizializzo LUT decodifica
|
||||
string jsonConf = getOptPar("LUT_CONF");
|
||||
if (!string.IsNullOrEmpty(jsonConf))
|
||||
{
|
||||
string jsonFullPath = $"{Application.StartupPath}/DATA/CONF/{jsonConf}";
|
||||
lgInfo($"Apertura file {jsonFullPath}");
|
||||
StreamReader reader = new StreamReader(jsonFullPath);
|
||||
string jsonData = reader.ReadToEnd();
|
||||
if (!string.IsNullOrEmpty(jsonData))
|
||||
{
|
||||
try
|
||||
{
|
||||
monitoredItems = JsonConvert.DeserializeObject<MonitoredItemsConf>(jsonData);
|
||||
// salvo baseUri
|
||||
baseUri = monitoredItems.SrvData.baseUri;
|
||||
lgInfo($"baseUri = {baseUri}");
|
||||
// imposto a zero la bitmap x riavvio!
|
||||
B_input = 0;
|
||||
// FORZO invio dati...
|
||||
accodaSigIN(ref currDispData);
|
||||
// loggo!
|
||||
lgInfo($"init input bitmap to zero: {B_input}");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lgError(exc, "Eccezione in decodifica conf json");
|
||||
}
|
||||
}
|
||||
reader.Dispose();
|
||||
}
|
||||
lgInfo("DONE reloadAdapterConf");
|
||||
raiseRefresh(currDispData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Avvio del WebDriver
|
||||
/// </summary>
|
||||
private void startDriver()
|
||||
{
|
||||
if (monitoredItems.SrvData.driverName == "CHROME")
|
||||
{
|
||||
lgInfo("Starting CHROME Driver");
|
||||
// preparo opzione headless x CHROME
|
||||
var o = new ChromeOptions();
|
||||
o.AddArgument("headless");
|
||||
ChromeDriverService service = ChromeDriverService.CreateDefaultService(Application.StartupPath);
|
||||
service.HideCommandPromptWindow = true;
|
||||
driver = new ChromeDriver(service, o);
|
||||
}
|
||||
else
|
||||
{
|
||||
lgInfo("Starting FIREFOX Driver");
|
||||
// preparo opzione headless x FIREFOX
|
||||
var o = new FirefoxOptions();
|
||||
o.AddArgument("-headless");
|
||||
o.SetPreference("app.update.auto", false);
|
||||
o.SetPreference("app.update.enabled", false);
|
||||
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(Application.StartupPath);
|
||||
service.HideCommandPromptWindow = true;
|
||||
driver = new FirefoxDriver(service, o);
|
||||
}
|
||||
// aggiungo timeout x JScripts
|
||||
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
|
||||
driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(20);
|
||||
// imposto pagina di acquisizione
|
||||
driver.Navigate().GoToUrl(baseUri);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
@@ -81,6 +78,11 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
public string nodeId { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Valore Registrato in formato byte array
|
||||
/// </summary>
|
||||
public byte[] rawByte { get; set; } = new byte[1];
|
||||
|
||||
/// <summary>
|
||||
/// Valore (in sec) del periodo di downsampling (0 --> NON usato)
|
||||
/// </summary>
|
||||
@@ -101,11 +103,6 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
public string value { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Valore Registrato in formato byte array
|
||||
/// </summary>
|
||||
public byte[] rawByte { get; set; } = new byte[1];
|
||||
|
||||
/// <summary>
|
||||
/// Timestamp data-ora evento registrato
|
||||
/// </summary>
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
|
||||
+130
-137
@@ -1,16 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading;
|
||||
using TwinCAT;
|
||||
using System.Threading.Tasks;
|
||||
using TwinCAT.Ads;
|
||||
using TwinCAT.Ads.TypeSystem;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TwinCAT.TypeSystem;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
@@ -20,48 +14,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
public class TcAdsClient
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// elenco delle variabili monitorate x change event
|
||||
/// </summary>
|
||||
private List<string> _MonitVars = new List<string>();
|
||||
|
||||
private int _status;
|
||||
|
||||
private List<int> addedSignalationList = new List<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario di conversione da indice a index group e index offset
|
||||
/// </summary>
|
||||
private Dictionary<int, Tuple<int, int>> addressList;
|
||||
|
||||
private TwinCAT.Ads.TcAdsClient adsClient;
|
||||
|
||||
private CancellationTokenSource cts;
|
||||
|
||||
private System.Threading.Tasks.Task dispatchertask;
|
||||
|
||||
#if false
|
||||
//private Action<object> dispatcher;
|
||||
private int eventHandle;
|
||||
|
||||
private int SegnalazioniADSEventHandle, StatusChangedEventHandle, MessageQueuedEventHandle;
|
||||
|
||||
private int notifyposition;
|
||||
#endif
|
||||
private AdsStream notifyStream;
|
||||
|
||||
private object lockobj = new object();
|
||||
|
||||
private AdsStream newNotificationStream;
|
||||
|
||||
|
||||
|
||||
private Symbol StatoMacchina;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
public System.Collections.Concurrent.ConcurrentQueue<ComandiADS> CodaComandi;
|
||||
@@ -84,9 +36,13 @@ namespace IOB_WIN_NEXT
|
||||
/// <summary>
|
||||
/// Inizializza un oggetto ADS x gestione classe comunicazione con TwinCat
|
||||
/// </summary>
|
||||
/// <param name="MonitVars">Lista dei nomi delle variabili da gestire ad eventChange (es stato macchina)</param>
|
||||
/// <param name="MonitVars">
|
||||
/// Lista dei nomi delle variabili da gestire ad eventChange (es stato macchina)
|
||||
/// </param>
|
||||
/// <param name="indirizzo">indirizzo tipo AmsNetId</param>
|
||||
/// <param name="porta">Porta comunicazione: Connect to local PLC - Runtime 1 - TwinCAT2 Port=801, TwinCAT3 Port=851</param>
|
||||
/// <param name="porta">
|
||||
/// Porta comunicazione: Connect to local PLC - Runtime 1 - TwinCAT2 Port=801, TwinCAT3 Port=851
|
||||
/// </param>
|
||||
public TcAdsClient(List<string> MonitVars, string indirizzo = "local", int porta = 851)
|
||||
{
|
||||
_MonitVars = MonitVars;
|
||||
@@ -139,7 +95,7 @@ namespace IOB_WIN_NEXT
|
||||
StatoMacchina.ValueChanged += StatoMacchina_ValueChanged;
|
||||
|
||||
#if false
|
||||
notifyposition = 0;
|
||||
notifyposition = 0;
|
||||
#endif
|
||||
cts = new CancellationTokenSource();
|
||||
|
||||
@@ -213,6 +169,128 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
adsClient.Dispose();
|
||||
}
|
||||
|
||||
public TcAdsSymbolInfo GetSymbolInfo(string nome)
|
||||
{
|
||||
try
|
||||
{
|
||||
var symbol = InfoLoader.FindSymbol(nome);
|
||||
return symbol;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public object ReadVariabile(ref TcAdsSymbolInfo variabile)
|
||||
{
|
||||
var comando = new ComandiADS { ComandoScrittua = false, Symbol = variabile };
|
||||
return ReadVariabile(comando);
|
||||
}
|
||||
|
||||
public object ReadVariabile(string symbolName, Type type = null)
|
||||
{
|
||||
var comando = new ComandiADS { ComandoScrittua = false, SymbolName = symbolName };
|
||||
return ReadVariabile(comando);
|
||||
}
|
||||
|
||||
public bool WriteVariabile(string symbolName, object value, bool syncronous = false)
|
||||
{
|
||||
var comando = new ComandiADS { Value = value, ComandoScrittua = true, SymbolName = symbolName };
|
||||
return WriteVariabile(comando, syncronous);
|
||||
}
|
||||
|
||||
public bool WriteVariabile(TcAdsSymbolInfo symbol, object value, bool syncronous = false)
|
||||
{
|
||||
var comando = new ComandiADS { Value = value, ComandoScrittua = true, Symbol = symbol };
|
||||
return WriteVariabile(comando, syncronous);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Public Classes
|
||||
|
||||
public class ComandiADS
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
public bool ComandoScrittua;
|
||||
public bool Error;
|
||||
public TcAdsSymbolInfo Symbol;
|
||||
public string SymbolName;
|
||||
public ManualResetEventSlim Updating;
|
||||
public object Value;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public ComandiADS()
|
||||
{
|
||||
Updating = new ManualResetEventSlim(false);
|
||||
}
|
||||
|
||||
public ComandiADS(string name)
|
||||
{
|
||||
SymbolName = name;
|
||||
Updating = new ManualResetEventSlim(false);
|
||||
}
|
||||
|
||||
public ComandiADS(TcAdsSymbolInfo info)
|
||||
{
|
||||
Symbol = info;
|
||||
Updating = new ManualResetEventSlim(false);
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
}
|
||||
|
||||
#endregion Public Classes
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// elenco delle variabili monitorate x change event
|
||||
/// </summary>
|
||||
private List<string> _MonitVars = new List<string>();
|
||||
|
||||
private int _status;
|
||||
|
||||
private List<int> addedSignalationList = new List<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario di conversione da indice a index group e index offset
|
||||
/// </summary>
|
||||
private Dictionary<int, Tuple<int, int>> addressList;
|
||||
|
||||
private TwinCAT.Ads.TcAdsClient adsClient;
|
||||
|
||||
private CancellationTokenSource cts;
|
||||
|
||||
private System.Threading.Tasks.Task dispatchertask;
|
||||
|
||||
#if false
|
||||
//private Action<object> dispatcher;
|
||||
private int eventHandle;
|
||||
|
||||
private int SegnalazioniADSEventHandle, StatusChangedEventHandle, MessageQueuedEventHandle;
|
||||
|
||||
private int notifyposition;
|
||||
#endif
|
||||
private object lockobj = new object();
|
||||
private AdsStream newNotificationStream;
|
||||
private AdsStream notifyStream;
|
||||
private Symbol StatoMacchina;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void commandDispatcher(object tk)
|
||||
@@ -327,90 +405,5 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
adsClient.Dispose();
|
||||
}
|
||||
|
||||
public TcAdsSymbolInfo GetSymbolInfo(string nome)
|
||||
{
|
||||
try
|
||||
{
|
||||
var symbol = InfoLoader.FindSymbol(nome);
|
||||
return symbol;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public object ReadVariabile(ref TcAdsSymbolInfo variabile)
|
||||
{
|
||||
var comando = new ComandiADS { ComandoScrittua = false, Symbol = variabile };
|
||||
return ReadVariabile(comando);
|
||||
}
|
||||
|
||||
public object ReadVariabile(string symbolName, Type type = null)
|
||||
{
|
||||
var comando = new ComandiADS { ComandoScrittua = false, SymbolName = symbolName };
|
||||
return ReadVariabile(comando);
|
||||
}
|
||||
|
||||
public bool WriteVariabile(string symbolName, object value, bool syncronous = false)
|
||||
{
|
||||
var comando = new ComandiADS { Value = value, ComandoScrittua = true, SymbolName = symbolName };
|
||||
return WriteVariabile(comando, syncronous);
|
||||
}
|
||||
|
||||
public bool WriteVariabile(TcAdsSymbolInfo symbol, object value, bool syncronous = false)
|
||||
{
|
||||
var comando = new ComandiADS { Value = value, ComandoScrittua = true, Symbol = symbol };
|
||||
return WriteVariabile(comando, syncronous);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Public Classes
|
||||
|
||||
public class ComandiADS
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
public bool ComandoScrittua;
|
||||
public bool Error;
|
||||
public TcAdsSymbolInfo Symbol;
|
||||
public string SymbolName;
|
||||
public ManualResetEventSlim Updating;
|
||||
public object Value;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public ComandiADS()
|
||||
{
|
||||
Updating = new ManualResetEventSlim(false);
|
||||
}
|
||||
|
||||
public ComandiADS(string name)
|
||||
{
|
||||
SymbolName = name;
|
||||
Updating = new ManualResetEventSlim(false);
|
||||
}
|
||||
|
||||
public ComandiADS(TcAdsSymbolInfo info)
|
||||
{
|
||||
Symbol = info;
|
||||
Updating = new ManualResetEventSlim(false);
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
}
|
||||
|
||||
#endregion Public Classes
|
||||
}
|
||||
}
|
||||
+143
-155
@@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections;
|
||||
using NLog;
|
||||
using Opc.Ua;
|
||||
using Opc.Ua.Client;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
@@ -15,20 +13,6 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
public class opcUaMonitItemChange : EventArgs
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Monitored Item da notificare
|
||||
/// </summary>
|
||||
private readonly MonitoredItem _monitoredItem;
|
||||
|
||||
/// <summary>
|
||||
/// Valore notifica
|
||||
/// </summary>
|
||||
private readonly MonitoredItemNotification _notification;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -62,6 +46,20 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Monitored Item da notificare
|
||||
/// </summary>
|
||||
private readonly MonitoredItem _monitoredItem;
|
||||
|
||||
/// <summary>
|
||||
/// Valore notifica
|
||||
/// </summary>
|
||||
private readonly MonitoredItemNotification _notification;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -69,28 +67,6 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
public class UAClient
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private readonly string currIob;
|
||||
private readonly Action<IList, IList> m_validateResponse;
|
||||
private ApplicationConfiguration m_configuration;
|
||||
private Session m_session;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected static Logger lg;
|
||||
protected static bool isLogVerbose = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The user identity to use when creating the session.
|
||||
/// </summary>
|
||||
public IUserIdentity CurrUserIdentity { get; set; } = new UserIdentity();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
@@ -127,6 +103,11 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// The user identity to use when creating the session.
|
||||
/// </summary>
|
||||
public IUserIdentity CurrUserIdentity { get; set; } = new UserIdentity();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the server URL.
|
||||
/// </summary>
|
||||
@@ -139,105 +120,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Handles the certificate validation event.
|
||||
/// This event is triggered every time an untrusted certificate is received from the server.
|
||||
/// </summary>
|
||||
private void CertificateValidation(CertificateValidator sender, CertificateValidationEventArgs e)
|
||||
{
|
||||
bool certificateAccepted = true;
|
||||
|
||||
// ****
|
||||
// Implement a custom logic to decide if the certificate should be
|
||||
// accepted or not and set certificateAccepted flag accordingly.
|
||||
// The certificate can be retrieved from the e.Certificate field
|
||||
// ***
|
||||
|
||||
ServiceResult error = e.Error;
|
||||
while (error != null)
|
||||
{
|
||||
lgError($"{error.StatusCode} | {error.Code} | {error.LocalizedText}");
|
||||
error = error.InnerResult;
|
||||
}
|
||||
|
||||
if (certificateAccepted)
|
||||
{
|
||||
lgInfo($"Untrusted Certificate accepted. SubjectName = {e.Certificate.SubjectName}");
|
||||
}
|
||||
|
||||
e.AcceptAll = certificateAccepted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle DataChange notifications from Server
|
||||
/// </summary>
|
||||
private void OnMonitoredItemNotification(MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Log MonitoredItem Notification event
|
||||
MonitoredItemNotification notification = e.NotificationValue as MonitoredItemNotification;
|
||||
|
||||
// sollevo evento notifica vaziazione MonitoredItem
|
||||
if (eh_MonItChange != null)
|
||||
{
|
||||
eh_MonItChange(this, new opcUaMonitItemChange(monitoredItem, notification));
|
||||
}
|
||||
lgTrace($"Notification Received | Variable: {monitoredItem.DisplayName} | Value: {notification.Value}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lgError($"OnMonitoredItemNotification error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgError(string message)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = currIob;
|
||||
lg.Error(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgInfo(string message)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = currIob;
|
||||
lg.Info(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgDebug(string message)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = currIob;
|
||||
lg.Info(message);
|
||||
}
|
||||
/// <summary>
|
||||
/// Effettua logging TRACE corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgTrace(string message)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = currIob;
|
||||
lg.Trace(message);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -385,14 +267,11 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
try
|
||||
{
|
||||
// Define the UA Method to call
|
||||
// Parent node - Objects\CTT\Methods
|
||||
// Method node - Objects\CTT\Methods\Add
|
||||
// Define the UA Method to call Parent node - Objects\CTT\Methods Method node - Objects\CTT\Methods\Add
|
||||
NodeId objectId = new NodeId("ns=2;s=Methods");
|
||||
NodeId methodId = new NodeId("ns=2;s=Methods_Add");
|
||||
|
||||
// Define the method parameters
|
||||
// Input argument requires a Float and an UInt32 value
|
||||
// Define the method parameters Input argument requires a Float and an UInt32 value
|
||||
object[] inputArguments = new object[] { (float)10.5, (uint)10 };
|
||||
IList<object> outputArguments = null;
|
||||
|
||||
@@ -429,8 +308,8 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
lgInfo("Connecting...");
|
||||
|
||||
// Get the endpoint by connecting to server's discovery endpoint.
|
||||
// Try to find the first endopint without security.
|
||||
// Get the endpoint by connecting to server's discovery endpoint. Try to find
|
||||
// the first endopint without security.
|
||||
EndpointDescription endpointDescription = CoreClientUtils.SelectEndpoint(ServerUrl, false);
|
||||
|
||||
EndpointConfiguration endpointConfiguration = EndpointConfiguration.Create(m_configuration);
|
||||
@@ -573,7 +452,6 @@ namespace IOB_WIN_NEXT
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read a SINGLE of nodes value (RAW) from Server
|
||||
/// </summary>
|
||||
@@ -590,7 +468,6 @@ namespace IOB_WIN_NEXT
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
#region Read the Value attribute of a node by calling the Session.ReadValue method
|
||||
|
||||
try
|
||||
@@ -614,8 +491,6 @@ namespace IOB_WIN_NEXT
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Read a list of nodes from Server
|
||||
/// </summary>
|
||||
@@ -813,8 +688,7 @@ namespace IOB_WIN_NEXT
|
||||
return monItList;
|
||||
}
|
||||
|
||||
/// Write a list of nodes to the Server
|
||||
/// </summary>
|
||||
/// Write a list of nodes to the Server </summary>
|
||||
public void WriteNodes(List<WriteValue> node2Write)
|
||||
{
|
||||
if (m_session == null || m_session.Connected == false)
|
||||
@@ -1002,5 +876,119 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected static bool isLogVerbose = false;
|
||||
protected static Logger lg;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging DEBUG corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgDebug(string message)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = currIob;
|
||||
lg.Info(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgError(string message)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = currIob;
|
||||
lg.Error(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgInfo(string message)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = currIob;
|
||||
lg.Info(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua logging TRACE corretto impostanto anche la variabile IOB prima di scrivere...
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected void lgTrace(string message)
|
||||
{
|
||||
lg.Factory.Configuration.Variables["codIOB"] = currIob;
|
||||
lg.Trace(message);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly string currIob;
|
||||
private readonly Action<IList, IList> m_validateResponse;
|
||||
private ApplicationConfiguration m_configuration;
|
||||
private Session m_session;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Handles the certificate validation event. This event is triggered every time an
|
||||
/// untrusted certificate is received from the server.
|
||||
/// </summary>
|
||||
private void CertificateValidation(CertificateValidator sender, CertificateValidationEventArgs e)
|
||||
{
|
||||
bool certificateAccepted = true;
|
||||
|
||||
// **** Implement a custom logic to decide if the certificate should be accepted or not
|
||||
// and set certificateAccepted flag accordingly. The certificate can be retrieved from
|
||||
// the e.Certificate field ***
|
||||
|
||||
ServiceResult error = e.Error;
|
||||
while (error != null)
|
||||
{
|
||||
lgError($"{error.StatusCode} | {error.Code} | {error.LocalizedText}");
|
||||
error = error.InnerResult;
|
||||
}
|
||||
|
||||
if (certificateAccepted)
|
||||
{
|
||||
lgInfo($"Untrusted Certificate accepted. SubjectName = {e.Certificate.SubjectName}");
|
||||
}
|
||||
|
||||
e.AcceptAll = certificateAccepted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle DataChange notifications from Server
|
||||
/// </summary>
|
||||
private void OnMonitoredItemNotification(MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Log MonitoredItem Notification event
|
||||
MonitoredItemNotification notification = e.NotificationValue as MonitoredItemNotification;
|
||||
|
||||
// sollevo evento notifica vaziazione MonitoredItem
|
||||
if (eh_MonItChange != null)
|
||||
{
|
||||
eh_MonItChange(this, new opcUaMonitItemChange(monitoredItem, notification));
|
||||
}
|
||||
lgTrace($"Notification Received | Variable: {monitoredItem.DisplayName} | Value: {notification.Value}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
lgError($"OnMonitoredItemNotification error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
using EgwProxy.MultiCncLib.CNC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IOB_WIN_NEXT
|
||||
{
|
||||
|
||||
@@ -54,12 +54,12 @@ goto END
|
||||
|
||||
:RemoteDebug
|
||||
REM copia script verso server remoto
|
||||
echo Debug remoto: effettuo robocopy sync (verificare remote per cliente)
|
||||
REM echo Debug remoto: effettuo robocopy sync (verificare remote per cliente)
|
||||
|
||||
REM FINASSI
|
||||
ROBOCOPY . \\10.150.0.1\Steamware\IOB-WIN-NEXT-DEB /MIR
|
||||
REM ROBOCOPY . \\10.150.0.1\Steamware\IOB-WIN-NEXT-DEB /MIR
|
||||
REM Baglietto
|
||||
REM ROBOCOPY . \\192.168.60.15\Steamware\IOB-WIN-NEXT-DEB /MIR
|
||||
ROBOCOPY . \\192.168.60.15\Steamware\IOB-WIN-NEXT-DEB /MIR
|
||||
|
||||
goto END
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@ namespace IOB_WIN_NEXT
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Indirizzo di base degli Holding Register
|
||||
/// </summary>
|
||||
public int holdRegBaseAddr = 40001;
|
||||
|
||||
/// <summary>
|
||||
/// Indirizzo IP del PLC
|
||||
/// </summary>
|
||||
@@ -40,11 +45,6 @@ namespace IOB_WIN_NEXT
|
||||
/// </summary>
|
||||
public int pingMsTimeout = 250;
|
||||
|
||||
/// <summary>
|
||||
/// Indirizzo di base degli Holding Register
|
||||
/// </summary>
|
||||
public int holdRegBaseAddr= 40001;
|
||||
|
||||
/// <summary>
|
||||
/// Porta di comunicazione
|
||||
/// </summary>
|
||||
@@ -54,8 +54,8 @@ namespace IOB_WIN_NEXT
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementazione classe connessione SIEMENS con S7.net,
|
||||
/// comprensiva dei parametri delle aree di memoria
|
||||
/// Implementazione classe connessione SIEMENS con S7.net, comprensiva dei parametri delle aree
|
||||
/// di memoria
|
||||
/// </summary>
|
||||
public class connParamS7
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user