diff --git a/IOB-WIN/IOB-WIN/App.config b/IOB-WIN/IOB-WIN/App.config
index 38ef20f..b46102f 100644
--- a/IOB-WIN/IOB-WIN/App.config
+++ b/IOB-WIN/IOB-WIN/App.config
@@ -15,7 +15,7 @@
-
+
@@ -34,6 +34,6 @@
-
+
\ No newline at end of file
diff --git a/IOB-WIN/IOB-WIN/DATA/DAT/PersistData.dat b/IOB-WIN/IOB-WIN/DATA/DAT/PersistData.dat
new file mode 100644
index 0000000..5f28270
--- /dev/null
+++ b/IOB-WIN/IOB-WIN/DATA/DAT/PersistData.dat
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/IOB-WIN/IOB-WIN/IOB-WIN.csproj b/IOB-WIN/IOB-WIN/IOB-WIN.csproj
index d3e8fa1..f6f5f2a 100644
--- a/IOB-WIN/IOB-WIN/IOB-WIN.csproj
+++ b/IOB-WIN/IOB-WIN/IOB-WIN.csproj
@@ -54,6 +54,7 @@
VersGen.cs
+
@@ -66,6 +67,10 @@
+
+
+ Always
+
Always
@@ -87,6 +92,11 @@
Always
+
+ Always
+
+
+
Designer
diff --git a/IOB-WIN/IOB-WIN/IobGeneric.cs b/IOB-WIN/IOB-WIN/IobGeneric.cs
index cec4849..0c5e3f0 100644
--- a/IOB-WIN/IOB-WIN/IobGeneric.cs
+++ b/IOB-WIN/IOB-WIN/IobGeneric.cs
@@ -1,4 +1,6 @@
-using System;
+using IOB_UT;
+using NLog;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,6 +10,81 @@ namespace IOB_WIN
{
public class IobGeneric
{
+ ///
+ /// alias booleano false = R
+ ///
+ public bool R = false;
+ ///
+ /// alias booleano true = W
+ ///
+ public bool W = true;
+ ///
+ /// wrapper di log
+ ///
+ public static Logger lg;
+ ///
+ /// valore booleano di check se sia in fase di COMUNICAZIONE ATTIVA con il PLC/NC
+ ///
+ protected bool adpCommAct;
+ ///
+ /// valore booleano di check se sia stato AVVIATO l'adapter (Running)
+ ///
+ public bool adpRunning = false;
+ ///
+ /// valore booleano di check se l'adapter STIA SALVANDO
+ ///
+ public bool adpSaving = false;
+ ///
+ /// valore booleano (richiesta di riavvio automatico)
+ ///
+ public bool adpTryRestart;
+ ///
+ /// Ultimo valore watchdog rilevato
+ ///
+ public bool lastWatchDog = false;
+ ///
+ /// Determina se utilizzare blocchi di memoria IOT contigui (e quindi processing "monoblocco" semplificato"=
+ ///
+ public bool procIotMem = false;
+ ///
+ /// porta x adapter (x restart)
+ ///
+ protected int adpPortNum;
+ ///
+ /// DataOra ultimo avvio adapter x watchdog
+ ///
+ protected DateTime adpStartRun;
+ ///
+ /// Data/ora ultimo avvio adapter
+ ///
+ public DateTime dtAvvioAdp = DateTime.Now;
+ ///
+ /// Data/ora ultimo spegnimento adapter
+ ///
+ public DateTime dtStopAdp = DateTime.Now;
+ ///
+ /// vettore gestione cronometraggi
+ ///
+ public DateTime inizio;
+ ///
+ /// Conteggio ATTUALE ore macchina ON
+ ///
+ public double contOreMaccOn;
+ ///
+ /// Conteggio ATTUALE ore macchina IN LAVORO
+ ///
+ public double contOreMaccLav;
+
+ ///
+ /// Form chiamante
+ ///
+ protected MainForm parentForm;
+ ///
+ /// Conf adapter corrente
+ ///
+ public IobConfiguration currIobConf;
+
+
///
/// inizializzo l'oggetto sulla form SULLA BASE DEL FILE DI CONFIGURAZIONE letto
///
@@ -15,228 +92,712 @@ namespace IOB_WIN
///
public IobGeneric(MainForm caller, IobConfiguration IOBConf)
{
-#if false
lg = LogManager.GetCurrentClassLogger();
lg.Info("Avvio preliminare AdapterGeneric");
-
- procIotMem = utils.CRB("procIotMem");
-
- currAdpConf = adpConf;
-
- // inizializzo vettore gruppi assi, MAX 20!!!
- FeedRateGrp = new int[20];
-
+ // configurazione...
+ currIobConf = IOBConf;
// salvo il form chiamante
parentForm = caller;
-
- // item disponibilità
- mAdapter.AddDataItem(mAvail);
- mAvail.Value = "AVAILABLE";
- mMessage.Value = "";
-
- // assets
- mAdapter.AddDataItem(mAssetChg);
- mAdapter.AddDataItem(mAssetRem);
- mAssetChg.Value = "";
- mAssetRem.Value = "";
-
- // status, clock, emergency stop
- mAdapter.AddDataItem(mStatus);
- mAdapter.AddDataItem(mAccTime);
- mAdapter.AddDataItem(mAccTimeWork);
- mAdapter.AddDataItem(mSlittaTast);
- mAdapter.AddDataItem(mClock);
- mAdapter.AddDataItem(mPower);
- mAdapter.AddDataItem(mProcSel);
- mAdapter.AddDataItem(mEStop);
-
- // programma e produzione
- mAdapter.AddDataItem(mOperator);
-
- // modalità esecutiva e funzionale
- mFunctionalMode.Value = "";
- mAdapter.AddDataItem(mFunctionalMode);
-
-
- // testing e autodiagnostica
- mAdapter.AddDataItem(mTestingData);
-
- // strobe/status non riconosciuti
- mAdapter.AddDataItem(mUnkStatus);
- mAdapter.AddDataItem(mUnkStrobe);
-
- // Aree memoria
- vettMemArea = new MemArea[adpConf.nMemArea];
- for (int i = 0; i < adpConf.nMemArea; i++)
- {
- vettMemArea[i] = new MemArea(adpConf.MemArea[i]);
- mAdapter.AddDataItem(vettMemArea[i].mMemAreaProgName);
- mAdapter.AddDataItem(vettMemArea[i].mMemAreaRunning);
- mAdapter.AddDataItem(vettMemArea[i].mMemAreaProgNumExe);
- mAdapter.AddDataItem(vettMemArea[i].mMemAreaProgNumRep);
- }
- // Pompe vuoto
- vettVacPump = new VacuumPump[adpConf.nVacuumPump];
- for (int i = 0; i < adpConf.nVacuumPump; i++)
- {
- vettVacPump[i] = new VacuumPump(adpConf.VacuumPump[i]);
- mAdapter.AddDataItem(vettVacPump[i].mVacPumpStatus);
- mAdapter.AddDataItem(vettVacPump[i].mVacPumpWrkTime);
- }
- // Attuatori vuoto
- vettVacAct = new VacuumAct[adpConf.nVacuumAct];
- for (int i = 0; i < adpConf.nVacuumAct; i++)
- {
- vettVacAct[i] = new VacuumAct(adpConf.VacuumAct[i]);
- mAdapter.AddDataItem(vettVacAct[i].mVacActCount);
- }
- // Lubrorefrigeranti
- vettLubro = new Lubro[adpConf.nLubro];
- for (int i = 0; i < adpConf.nLubro; i++)
- {
- vettLubro[i] = new Lubro(adpConf.Lubro[i]);
- mAdapter.AddDataItem(vettLubro[i].mLubroNum);
- mAdapter.AddDataItem(vettLubro[i].mLubroStatus);
- }
- // Slitta Mag
- vettSlittaMag = new SlittaMag[adpConf.nSlittaMag];
- for (int i = 0; i < adpConf.nSlittaMag; i++)
- {
- vettSlittaMag[i] = new SlittaMag(adpConf.SlittaMag[i]);
- mAdapter.AddDataItem(vettSlittaMag[i].mSlittaMagCount);
- }
- // Protezione Mag
- vettProtMag = new ProtMag[adpConf.nProtMag];
- for (int i = 0; i < adpConf.nProtMag; i++)
- {
- vettProtMag[i] = new ProtMag(adpConf.ProtMag[i]);
- mAdapter.AddDataItem(vettProtMag[i].mProtMagCount);
- }
- // Cooler
- vettCooler = new Cooler[adpConf.nCooler];
- for (int i = 0; i < adpConf.nCooler; i++)
- {
- vettCooler[i] = new Cooler(adpConf.Cooler[i]);
- mAdapter.AddDataItem(vettCooler[i].mCoolStatus);
- }
- // Press
- vettPress = new Press[adpConf.nPress];
- for (int i = 0; i < adpConf.nPress; i++)
- {
- vettPress[i] = new Press(adpConf.Press[i]);
- mAdapter.AddDataItem(vettPress[i].mPressValIst);
- }
- // Temp
- vettTempe = new Tempe[adpConf.nTemp];
- for (int i = 0; i < adpConf.nTemp; i++)
- {
- vettTempe[i] = new Tempe(adpConf.Temp[i]);
- mAdapter.AddDataItem(vettTempe[i].mTempValIst);
- }
- // Path
- vettPath = new Path[adpConf.nPath];
- for (int i = 0; i < adpConf.nPath; i++)
- {
- vettPath[i] = new Path(adpConf.Path[i]);
- mAdapter.AddDataItem(vettPath[i].mPathFeed);
- mAdapter.AddDataItem(vettPath[i].mPathFeedOver);
- mAdapter.AddDataItem(vettPath[i].mPathRapidOver);
- mAdapter.AddDataItem(vettPath[i].mPathJogOver);
- mAdapter.AddDataItem(vettPath[i].mPathSpindleOver_01);
- mAdapter.AddDataItem(vettPath[i].mPathSpindleOver_02);
- mAdapter.AddDataItem(vettPath[i].mPathSpindleOver_03);
- mAdapter.AddDataItem(vettPath[i].mPathSpindleOver_04);
- mAdapter.AddDataItem(vettPath[i].mPathPosActX);
- mAdapter.AddDataItem(vettPath[i].mPathPosActY);
- mAdapter.AddDataItem(vettPath[i].mPathPosActZ);
- mAdapter.AddDataItem(vettPath[i].mPathPosActI);
- mAdapter.AddDataItem(vettPath[i].mPathPosActJ);
- mAdapter.AddDataItem(vettPath[i].mPathPosActK);
- // aggiunta x revisione 2016.05.05
- mAdapter.AddDataItem(vettPath[i].mPathType);
- mAdapter.AddDataItem(vettPath[i].mPathPartId);
- mAdapter.AddDataItem(vettPath[i].mPathPartCount);
- mAdapter.AddDataItem(vettPath[i].mPathCodM);
- mAdapter.AddDataItem(vettPath[i].mPathCodS);
- mAdapter.AddDataItem(vettPath[i].mPathCodT);
- mAdapter.AddDataItem(vettPath[i].mPathRunMode);
- mAdapter.AddDataItem(vettPath[i].mPathExeMode);
- mAdapter.AddDataItem(vettPath[i].mPathCurrProg);
- mAdapter.AddDataItem(vettPath[i].mPathCurrArea);
- mAdapter.AddDataItem(vettPath[i].mPathCurrProgRowNum);
- mAdapter.AddDataItem(vettPath[i].mPathActiveAxes);
- mAdapter.AddDataItem(vettPath[i].mPathCodG_Act);
- mAdapter.AddDataItem(vettPath[i].mPathSubMode);
- // aggiungo condizioni allarme...
- mAdapter.AddDataItem(vettPath[i].mPathAlarmCNC);
- mAdapter.AddDataItem(vettPath[i].mPathAlarmPLC);
- }
- // UnOp
- vettUnOp = new UnOp[adpConf.nUnOp];
- for (int i = 0; i < adpConf.nUnOp; i++)
- {
- vettUnOp[i] = new UnOp(adpConf.UnOp[i]);
- mAdapter.AddDataItem(vettUnOp[i].mUnOpToolId);
- mAdapter.AddDataItem(vettUnOp[i].mUnOpNumCU);
- mAdapter.AddDataItem(vettUnOp[i].mUnOpStatus);
- mAdapter.AddDataItem(vettUnOp[i].mUnOpVitaRes);
- mAdapter.AddDataItem(vettUnOp[i].mUnOpVitaResType);
- mAdapter.AddDataItem(vettUnOp[i].mUnOpSpeed);
- mAdapter.AddDataItem(vettUnOp[i].mUnOpSpeedOverr);
- mAdapter.AddDataItem(vettUnOp[i].mUnOpLoad);
- mAdapter.AddDataItem(vettUnOp[i].mUnOpAccTime);
- mAdapter.AddDataItem(vettUnOp[i].mUnOpKRev);
- }
- // Assi
- vettAxis = new Axis[adpConf.nAxis];
- for (int i = 0; i < adpConf.nAxis; i++)
- {
- vettAxis[i] = new Axis(adpConf.Axis[i]);
- mAdapter.AddDataItem(vettAxis[i].mAxMainProc);
- mAdapter.AddDataItem(vettAxis[i].mAxIsMaster);
- mAdapter.AddDataItem(vettAxis[i].mAxMastId);
- mAdapter.AddDataItem(vettAxis[i].mAxType);
- mAdapter.AddDataItem(vettAxis[i].mAxDir);
- mAdapter.AddDataItem(vettAxis[i].mAxLoad);
- mAdapter.AddDataItem(vettAxis[i].mAxPosAct);
- mAdapter.AddDataItem(vettAxis[i].mAxPosTgt);
- mAdapter.AddDataItem(vettAxis[i].mAxFeedAct);
- mAdapter.AddDataItem(vettAxis[i].mAxFeedOver);
- mAdapter.AddDataItem(vettAxis[i].mAxAccelAct);
- mAdapter.AddDataItem(vettAxis[i].mAxAccTime);
- mAdapter.AddDataItem(vettAxis[i].mAxBattery);
- mAdapter.AddDataItem(vettAxis[i].mAxDistDone);
- mAdapter.AddDataItem(vettAxis[i].mAxInvDDone);
- mAdapter.AddDataItem(vettAxis[i].mAxAlarmCNC);
- mAdapter.AddDataItem(vettAxis[i].mAxAlarmPLC);
- }
-
-
-
- // messaggi ulteriori
- mAdapter.AddDataItem(mMessage);
-
- // allarmi "base"
- mAdapter.AddDataItem(mAlarmCNC);
- mAdapter.AddDataItem(mAlarmPLC);
-
- // azioni utente
- mAdapter.AddDataItem(mUserAction);
-
- // inizializzo vettori code MST x num path...
- codaM = new List[adpConf.nPath];
- codaS = new List[adpConf.nPath];
- codaT = new List[adpConf.nPath];
- for (int i = 0; i < adpConf.nPath; i++)
- {
- codaM[i] = new List();
- codaS[i] = new List();
- codaT[i] = new List();
- }
-
+
// concluso!
- lg.Info("Istanziata classe preliminare AdapterGeneric");
+ lg.Info("Istanziata classe preliminare IOBGeneric");
+ }
+
+
+ #region metodi adapter
+
+
+ ///
+ /// lettura file di persistenza
+ ///
+ public void loadPersData()
+ {
+#if false
+ try
+ {
+ // nuova lettura valori da file persistenza...
+ contOreMaccOn = getStoredValDouble("ACC_TIME");
+ contOreMaccLav = getStoredValDouble("ACC_TIME_WORK");
+ contSlittaTast = getStoredValDouble("SlittaTastatore_Count");
+
+ for (int i = 0; i < currAdpConf.nUnOp; i++)
+ {
+ contGiriElettrom[i] = getStoredValUInt(string.Format("UnOp_{0:00}_AccTime", i + 1));
+ currNumCambiUt[i] = getStoredValUInt(string.Format("UnOp_{0:00}_NumCU", i + 1));
+ }
+
+ for (int i = 0; i < currAdpConf.nAxis; i++)
+ {
+ contDistMovAssi[i] = getStoredValUInt(string.Format("Axis_{0:00}_DistDone", i + 1));
+ contNumInvAssi[i] = getStoredValUInt(string.Format("Axis_{0:00}_InvDDone", i + 1));
+ contAccTimeAssi[i] = getStoredValDouble(string.Format("Axis_{0:00}_AccTime", i + 1));
+ }
+
+ for (int i = 0; i < currAdpConf.nVacuumPump; i++)
+ {
+ currVacPumpWrkTime[i] = getStoredValUInt(string.Format("VacPump_{0:00}_WrkTime", i + 1));
+ }
+
+ for (int i = 0; i < currAdpConf.nVacuumAct; i++)
+ {
+ currVacActCount[i] = getStoredValUInt(string.Format("VacAct_{0:00}_Count", i + 1));
+ }
+
+ for (int i = 0; i < currAdpConf.nLubro; i++)
+ {
+ currLubroCount[i] = getStoredValUInt(string.Format("Lubro_{0:00}_Count", i + 1));
+ }
+
+ for (int i = 0; i < currAdpConf.nSlittaMag; i++)
+ {
+ currSlittaMag[i] = getStoredValUInt(string.Format("SlittaMagazzino_{0:00}_Count", i + 1));
+ }
+
+ for (int i = 0; i < mCounters.Length; i++)
+ {
+ currCounters[i] = getStoredValUInt(string.Format("Counter_{0:000}", i + 1));
+ }
+
+ for (int i = 0; i < currAdpConf.nProtMag; i++)
+ {
+ currProtMag[i] = getStoredValUInt(string.Format("ProtMagazzino_{0:00}_Count", i + 1));
+ }
+
+ }
+ catch (Exception exc)
+ {
+ lg.Error(string.Format("Eccezione in decodifica valori PersLayer: {0}{1}", Environment.NewLine, exc));
+ }
+#endif
+ }
+
+ ///
+ /// Avvia l'adapter sulla porta richiesta
+ ///
+ ///
+ public virtual void startAdapter(int port)
+ {
+ lg.Info("Starting adapter...");
+#if false
+ parentForm.commPlcActive = false;
+ adpRunning = true;
+ dtAvvioAdp = DateTime.Now;
+ TimingData.resetData();
+ // inizializzo vettori di utility..
+ loadAllarmi();
+ loadSubMode();
+ loadOtherFile();
+
+ // salvo porta!
+ mAdapter.Port = port;
+ adpPortNum = port;
+ // avvio!
+ mAdapter.Start();
+
+ // setto status a ON
+ mStatus.Value = "ON";
+
+ // resetto running flag...
+ adpCommAct = false;
+
+ // avvio i sample vectors...
+ istOreMaccOn = new sampleVect();
+ istOreMaccLav = new sampleVect();
+ istSlittaTast = new sampleVect();
+
+ // carico valori da adapter x i conteggi
+ contOreMaccOn = currAdpConf.ContOreMaccOn;
+ contOreMaccLav = currAdpConf.ContOreMaccLav;
+ contSlittaTast = currAdpConf.ContSlittaTast;
+ contGiriElettrom = new uint[currAdpConf.nUnOp];
+ istGiriElettrom = new sampleVect[currAdpConf.nUnOp];
+ currNumCambiUt = new uint[currAdpConf.nUnOp];
+ istNumCambiUt = new sampleVect[currAdpConf.nUnOp];
+ for (int i = 0; i < currAdpConf.nUnOp; i++)
+ {
+ // leggo tutti i dati...
+ List> listaDR = currAdpConf.UnOp[i].dataRefList;
+ // punto all'item
+ DataRefItem riContRpm = listaDR.Find(x => x.Key == string.Format("UnOp_{0:00}_AccTime", i + 1));
+ DataRefItem riContNumCU = listaDR.Find(x => x.Key == string.Format("UnOp_{0:00}_NumCU", i + 1));
+ // recupero valore giri...
+ UInt32 contTotGiri = Convert.ToUInt32(riContRpm.Value);
+ // recupero valore num cambi ut...
+ UInt32 contNumCU = Convert.ToUInt32(riContNumCU.Value);
+ // salvo valore letto
+ contGiriElettrom[i] = contTotGiri;
+ currNumCambiUt[i] = contNumCU;
+ istGiriElettrom[i] = new sampleVect();
+ istNumCambiUt[i] = new sampleVect();
+ }
+ // imposto num assi e leggo valori salvati...
+ contDistMovAssi = new double[currAdpConf.nAxis];
+ istDistMovAssi = new sampleVect[currAdpConf.nAxis];
+ istLoadAssi = new sampleVect[currAdpConf.nAxis];
+ contNumInvAssi = new uint[currAdpConf.nAxis];
+ istAccTimeAssi = new sampleVect[currAdpConf.nAxis];
+ contAccTimeAssi = new double[currAdpConf.nAxis];
+ istNumInvAssi = new sampleVect[currAdpConf.nAxis];
+ lastChekAccumTimeAxis = DateTime.Now;
+ for (int i = 0; i < currAdpConf.nAxis; i++)
+ {
+ // leggo tutti i dati...
+ List> listaDR = currAdpConf.Axis[i].dataRefList;
+ // punto all'item
+ DataRefItem riContDist = listaDR.Find(x => x.Key == string.Format("Axis_{0:00}_DistDone", i + 1));
+ DataRefItem riNumInv = listaDR.Find(x => x.Key == string.Format("Axis_{0:00}_Invers", i + 1));
+ DataRefItem riAccTime = listaDR.Find(x => x.Key == string.Format("Axis_{0:00}_AccTime", i + 1));
+ // recupero valori...
+ contDistMovAssi[i] = Convert.ToUInt32(riContDist.Value);
+ contNumInvAssi[i] = Convert.ToUInt32(riNumInv.Value);
+ contAccTimeAssi[i] = Convert.ToDouble(riAccTime.Value);
+ vettAxis[i].mAxAlarmCNC.Normal();
+ vettAxis[i].mAxAlarmPLC.Normal();
+ istDistMovAssi[i] = new sampleVect();
+ istLoadAssi[i] = new sampleVect();
+ istAccTimeAssi[i] = new sampleVect();
+ istNumInvAssi[i] = new sampleVect();
+ }
+ currPathPartId = new string[currAdpConf.nPath];
+ istPathPartId = new string[currAdpConf.nPath];
+ currPathProgrName = new string[currAdpConf.nPath];
+ istPathProgrName = new string[currAdpConf.nPath];
+ currPathPartCount = new uint[currAdpConf.nPath];
+ istPathPartCount = new sampleVect[currAdpConf.nPath];
+ for (int i = 0; i < currAdpConf.nPath; i++)
+ {
+ // leggo tutti i dati...
+ List> listaDR = currAdpConf.Path[i].dataRefList;
+ // punto all'item
+ DataRefItem riPathProgr = listaDR.Find(x => x.Key == string.Format("Path_{0:00}_PartId", i + 1));
+ DataRefItem riPathPzTot = listaDR.Find(x => x.Key == string.Format("Path_{0:00}_PZ_TOT", i + 1));
+ // recupero valori...
+ currPathPartId[i] = riPathProgr.Value;
+ currPathPartCount[i] = Convert.ToUInt32(riPathPzTot.Value);
+ currPathProgrName[i] = "";
+ vettPath[i].mPathAlarmCNC.Normal();
+ vettPath[i].mPathAlarmPLC.Normal();
+ istPathPartCount[i] = new sampleVect();
+ }
+ currVacPumpWrkTime = new uint[currAdpConf.nVacuumPump];
+ istVacPumpWrkTime = new sampleVect[currAdpConf.nVacuumPump];
+ for (int i = 0; i < currAdpConf.nVacuumPump; i++)
+ {
+ // leggo tutti i dati...
+ List> listaDR = currAdpConf.VacuumPump[i].dataRefList;
+ // punto all'item
+ DataRefItem riVacPumpWrk = listaDR.Find(x => x.Key == string.Format("VacPump_{0:00}_WrkTime", i + 1));
+ // recupero valori...
+ currVacPumpWrkTime[i] = Convert.ToUInt32(riVacPumpWrk.Value);
+ istVacPumpWrkTime[i] = new sampleVect();
+ }
+ currVacActCount = new uint[currAdpConf.nVacuumAct];
+ istVacActCount = new sampleVect[currAdpConf.nVacuumAct];
+ for (int i = 0; i < currAdpConf.nVacuumAct; i++)
+ {
+ // leggo tutti i dati...
+ List> listaDR = currAdpConf.VacuumAct[i].dataRefList;
+ // punto all'item
+ DataRefItem riVacActCount = listaDR.Find(x => x.Key == string.Format("VacAct_{0:00}_Count", i + 1));
+ // recupero valori...
+ currVacActCount[i] = Convert.ToUInt32(riVacActCount.Value);
+ istVacActCount[i] = new sampleVect();
+ }
+ currLubroCount = new uint[currAdpConf.nLubro];
+ istLubroCount = new sampleVect[currAdpConf.nLubro];
+ for (int i = 0; i < currAdpConf.nLubro; i++)
+ {
+ // leggo tutti i dati...
+ List> listaDR = currAdpConf.Lubro[i].dataRefList;
+ // punto all'item
+ DataRefItem riLubro = listaDR.Find(x => x.Key == string.Format("Lubro_{0:00}_Count", i + 1));
+ // recupero valori...
+ currLubroCount[i] = Convert.ToUInt32(riLubro.Value);
+ istLubroCount[i] = new sampleVect();
+ }
+ currSlittaMag = new uint[currAdpConf.nSlittaMag];
+ istSlittaMag = new sampleVect[currAdpConf.nSlittaMag];
+ for (int i = 0; i < currAdpConf.nSlittaMag; i++)
+ {
+ // leggo tutti i dati...
+ List> listaDR = currAdpConf.SlittaMag[i].dataRefList;
+ // punto all'item
+ DataRefItem riSlittaMag = listaDR.Find(x => x.Key == string.Format("SlittaMagazzino_{0:00}_Count", i + 1));
+ // recupero valori...
+ currSlittaMag[i] = Convert.ToUInt32(riSlittaMag.Value);
+ istSlittaMag[i] = new sampleVect();
+ }
+ currProtMag = new uint[currAdpConf.nProtMag];
+ istProtMag = new sampleVect[currAdpConf.nProtMag];
+ for (int i = 0; i < currAdpConf.nProtMag; i++)
+ {
+ // leggo tutti i dati...
+ List> listaDR = currAdpConf.ProtMag[i].dataRefList;
+ // punto all'item
+ DataRefItem riProtMag = listaDR.Find(x => x.Key == string.Format("ProtMagazzino_{0:00}_Count", i + 1));
+ // recupero valori...
+ currProtMag[i] = Convert.ToUInt32(riProtMag.Value);
+ istProtMag[i] = new sampleVect();
+ }
+
+ //mAlarmSystem.Normal();
+ mAlarmCNC.Normal();
+ mAlarmPLC.Normal();
+#endif
+ //mAlarmGeneral.Normal();
+ adpTryRestart = true;
+ parentForm.displayTaskAndWait("Adapter Started!");
+ }
+
+ ///
+ /// ferma l'adapter...
+ ///
+ /// indica se si debba tentare di riavviare l'adapter (con caduta connessione viene fermato in automatico)
+ public void stopAdapter(bool tryRestart)
+ {
+#if false
+ parentForm.displayTaskAndWait("Stopping adapter...");
+ adpTryRestart = false;
+ mStatus.Value = "INACTIVE";
+ // faccio una chiamata extra ad ogni metodo di check...
+ gaterAndSend(gatherCycle.HF);
+ gaterAndSend(gatherCycle.MF);
+ gaterAndSend(gatherCycle.LF);
+ gaterAndSend(gatherCycle.VLF);
+ parentForm.displayTaskAndWait("Stopping adapter - last periodic data read...");
+
+ // chiudo la connessione all'adapter...
+ tryDisconnect();
+ // Stop everything...
+ try
+ {
+ mAdapter.Stop();
+ }
+ catch (Exception exc)
+ {
+ lg.Error(exc, "Eccezione in chiusura Adapter");
+ }
+ dtStopAdp = DateTime.Now;
+ adpPortNum = mAdapter.Port;
+ adpTryRestart = tryRestart;
+ adpRunning = false;
+ // chiudo!
+ parentForm.resetProgBar();
+ parentForm.dataMonitor_1 = "... not connected, waiting for data ...";
+ parentForm.dataMonitor_2 = "";
+ parentForm.dataMonitor_3 = "";
+ parentForm.displayTaskAndWait("Adapter Stopped.");
+ parentForm.commPlcActive = false;
+#endif
+ }
+
+ ///
+ /// effettua recupero dati ed invio valori modificati...
+ ///
+ ///
+ public void gaterAndSend(gatherCycle ciclo)
+ {
+#if false
+ // controllo connessione/connettività
+ if (connectionOk)
+ {
+ // controllo non sia già in esecuzione...
+ if (!adpCommAct)
+ {
+ // provo ad avviare
+ try
+ {
+ // avvio fase raccolta dati
+ mAdapter.Begin();
+ // imposto flag adapter running..
+ adpCommAct = true;
+ adpStartRun = DateTime.Now;
+ }
+ catch (Exception exc)
+ {
+ parentForm.displayTaskAndWait(string.Format("Adapter NOT STARTED!!!{0}{1}", Environment.NewLine, exc));
+ adpCommAct = false;
+ adpStartRun = DateTime.Now;
+ }
+ if (adpCommAct)
+ {
+ // try / catch generale altrimenti segno che è disconnesso...
+ try
+ {
+ // processing degli strobes di allarme (da ULTIMA rappresentazione vettore dell'ADP)
+ processAlarm();
+
+ bool showDebugData = false;
+
+ // verifico se processare tutto "in un colpo solo"
+ if (procIotMem)
+ {
+ processAllMemory();
+ // ciclo lento x log...
+ if (ciclo == gatherCycle.LF)
+ {
+ // eventuale log!
+ if (utils.CRB("recTime")) logTimeResults();
+ }
+ }
+ // oppure in "modalità classica" con multistep...
+ else
+ {
+ // ciclo VHF x invii...
+ if (ciclo == gatherCycle.VHF)
+ {
+ // processo e svuoto eventuali code di invio per Codici M/S/T
+ trySendCodMST();
+ }
+ // POI CONTROLLO cicli + lenti di lettura...
+ // ciclo HF: recupero update status & strobes vari
+ if (ciclo == gatherCycle.HF)
+ {
+ // parte che eseguo SEMPRE: RECUPERO stato di tutti gli strobe/status e degli ack attualmente noti
+ getStrobeAndAckStatus();
+
+ // faccio refresh degli allarmi segnalati (da strobe su vettore locale)
+ refreshAlarmState(STRB_DW0, true);
+ // acquisizione degli status
+ processStatus();
+ // processing degli strobes
+ processStrobe();
+ }
+ else if (ciclo == gatherCycle.MF)
+ {
+ resetDebugConsole();
+ // leggo parametri a media freq (dati globali, path, assi, Unità Operatrice)
+ getGlobalData();
+ getUnOp();
+ getPath();
+ getAxis();
+
+ // se NON in modalità PROD eseguo chiamate "extra" x allarmi
+ if (utils.CRS("mode") == "debug")
+ {
+ // SOLO in modalità testing forzo il controllo continuo allarmi...
+ forceAlarmCheck();
+ }
+ // salva richiesta update x dati debug
+ showDebugData = true;
+ }
+ // ciclo lento
+ else if (ciclo == gatherCycle.LF)
+ {
+ // leggo EVENTUALI parametri da config file
+ getConfigParam();
+ ///acquisisco dati su programma in esecuzione e dati generali (stato, orologio, power...)
+ getSlowChangingData();
+
+ // eventuale log!
+ if (utils.CRB("recTime")) logTimeResults();
+ }
+ // ciclo lentissimo
+ else if (ciclo == gatherCycle.VLF)
+ {
+ lg.Info("Richiesta lettura completa allarmi attivi");
+ // faccio comunque rilettura completa allarmi...
+ forceAlarmCheck();
+ }
+ }
+ if (showDebugData)
+ {
+ // verifica se debba salvare e mostrare dati
+ checkSavePersDataLayer();
+ }
+
+ // INVIO dati variati!
+ mAdapter.SendChanged();
+ }
+ catch (Exception exc)
+ {
+ // segnalo eccezione e indico disconnesso...
+ lg.Error(exc, string.Format("Errore in gestione ciclo principale ADP, fermo adapter{0}{1}", Environment.NewLine, exc));
+ parentForm.fermaAdapter(true);
+ }
+ // tolgo flag running
+ adpCommAct = false;
+ }
+ else
+ {
+ lg.Info("ADP not running...");
+ }
+ }
+ else
+ {
+ // log ADP running
+ lg.Error("Non eseguo chiamata: ADP ancora in running");
+ // se è bloccato da oltre maxSec lo sblocco...
+ if (DateTime.Now.Subtract(adpStartRun).TotalSeconds > utils.CRI("maxAdapterLockSec"))
+ {
+ // tolgo flag running
+ adpCommAct = false;
+ adpStartRun = DateTime.Now;
+ }
+ }
+ }
+ else
+ {
+ // log connessione KO
+ lg.Error("CicloMF - Connessione non disponibile, provo a riconnettere");
+ // provo a riconnettere SE abilitato tryRestart...
+ if (adpTryRestart && !connectionOk)
+ {
+ lg.Info("ConnKO - tryConnect");
+ tryConnect();
+ }
+ }
+ if (eh_refreshed != null)
+ {
+ eh_refreshed(this, new EventArgs());
+ }
+#endif
+ }
+
+ public void resetDebugConsole()
+ {
+#if false
+ // resetto console debug...
+ parentForm.dataMonitor_1 = "";
+ parentForm.dataMonitor_2 = "";
+ parentForm.dataMonitor_3 = "";
+ // indico msg allarme NON inviati
+ alarmMsgDispl = false;
+#endif
+ }
+
+ ///
+ /// Metodo base connessione...
+ ///
+ public virtual void tryConnect()
+ {
+
+ }
+ ///
+ /// Metodo base disconnessione...
+ ///
+ public virtual void tryDisconnect()
+ {
+
+ }
+ protected bool _connOk = false;
+ ///
+ /// Salva verifica stato connessione OK
+ ///
+ ///
+ public virtual bool connectionOk
+ {
+ get
+ {
+ return _connOk;
+ }
+ set
+ {
+ _connOk = value;
+ }
+ }
+
+ #endregion
+
+ #region layer persistenza dati
+
+ ///
+ /// Dizionario di persistenza per i valori da salvare da/su file
+ ///
+ public Dictionary persistenceLayer;
+
+ ///
+ /// recupera valore salvato in persistence layer (se non c'è crea...)
+ ///
+ ///
+ ///
+ private string getStoredVal(string keyVal)
+ {
+ string value = "";
+ try
+ {
+ if (persistenceLayer != null)
+ {
+ if (!persistenceLayer.TryGetValue(keyVal, out value))
+ {
+ persistenceLayer.Add(keyVal, "0");
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ lg.Error(string.Format("Eccezione in getStoredVal: {0}{1}", Environment.NewLine, exc));
+ }
+ return value;
+ }
+ ///
+ /// recupera valore salvato in persistence layer (se non c'è crea...) come UINT
+ ///
+ ///
+ ///
+ private uint getStoredValUInt(string keyVal)
+ {
+ uint answ = 0;
+ try
+ {
+ answ = Convert.ToUInt32(getStoredVal(keyVal));
+ }
+ catch (Exception exc)
+ {
+ lg.Error(string.Format("Eccezione in getStoredValUInt: {0}{1}", Environment.NewLine, exc));
+ }
+ // verifico che il valore sia minore di 9/10 del valore massimo...
+ answ = (answ < (uint.MaxValue / 10 * 9)) ? answ : 0;
+ return answ;
+ }
+ ///
+ /// recupera valore salvato in persistence layer (se non c'è crea...) come INT
+ ///
+ ///
+ ///
+ private long getStoredValLong(string keyVal)
+ {
+ long answ = 0;
+ try
+ {
+ answ = Convert.ToInt64(getStoredVal(keyVal));
+ }
+ catch
+ { }
+ // verifico che il valore sia minore di 9/10 del valore massimo...
+ answ = (answ < (long.MaxValue / 10 * 9)) ? answ : 0;
+ return answ;
+ }
+ ///
+ /// recupera valore salvato in persistence layer (se non c'è crea...) come double
+ ///
+ ///
+ ///
+ private double getStoredValDouble(string keyVal)
+ {
+ double answ = 0;
+ try
+ {
+ answ = Convert.ToDouble(getStoredVal(keyVal));
+ }
+ catch (Exception exc)
+ {
+ lg.Error(string.Format("Eccezione in getStoredValDouble: {0}{1}", Environment.NewLine, exc));
+ }
+ answ = (answ < (double.MaxValue / 10 * 9)) ? answ : 0;
+ return answ;
+ }
+
+ ///
+ /// Aggiorna un valore del dizionario in SOSTITUZIONE
+ ///
+ ///
+ ///
+ ///
+ /// Nuovo valore incrementato
+ private void updateValString(int i, string newVal, string searchString)
+ {
+ // stringa da cercare..
+ string keyVal = string.Format(searchString, i + 1);
+ // salvo in ram!
+ persistenceLayer[keyVal] = newVal;
+ }
+ ///
+ /// Aggiorna un valore del dizionario in SOSTITUZIONE e lo restituisce
+ ///
+ ///
+ ///
+ ///
+ /// Nuovo valore incrementato
+ private void updateValUInt(int i, uint newVal, string searchString)
+ {
+ // stringa da cercare..
+ string keyVal = string.Format(searchString, i + 1);
+ // salvo in ram!
+ persistenceLayer[keyVal] = newVal.ToString();
+ }
+ ///
+ /// Aggiorna un valore del dizionario in INCREMENTO e lo restituisce
+ ///
+ ///
+ ///
+ ///
+ /// Nuovo valore incrementato
+ private uint updateValUIntByIncr(int i, uint delta, string searchString)
+ {
+ // stringa da cercare..
+ string keyVal = string.Format(searchString, i + 1);
+ // recupero valore precedente...
+ uint contAct = getStoredValUInt(keyVal);
+ // nuovo valore...
+ contAct += delta;
+ // salvo in ram!
+ persistenceLayer[keyVal] = contAct.ToString();
+ // rendo il valore!
+ return contAct;
+ }
+ ///
+ /// Aggiorna un valore del dizionario in INCREMENTO e lo restituisce
+ ///
+ ///
+ ///
+ ///
+ /// Nuovo valore incrementato
+ private long updateValLongByIncr(int i, long delta, string searchString)
+ {
+ // stringa da cercare..
+ string keyVal = string.Format(searchString, i + 1);
+ // recupero valore precedente...
+ long contAct = getStoredValLong(keyVal);
+ // nuovo valore...
+ contAct += delta;
+ // salvo in ram!
+ persistenceLayer[keyVal] = contAct.ToString();
+ // rendo il valore!
+ return contAct;
+ }
+ ///
+ /// Aggiorna un valore del dizionario in INCREMENTO e lo restituisce
+ ///
+ ///
+ ///
+ ///
+ /// Nuovo valore incrementato
+ private double updateValDoubleByIncr(int i, double delta, string searchString)
+ {
+ // stringa da cercare..
+ string keyVal = string.Format(searchString, i + 1);
+ // recupero valore precedente...
+ double contAct = getStoredValDouble(keyVal);
+ // nuovo valore...
+ contAct += delta;
+ // salvo in ram!
+ persistenceLayer[keyVal] = contAct.ToString();
+ // rendo il valore!
+ return contAct;
+ }
+
+ #endregion
+
+
+ ///
+ /// effettua ogni log period una rilettura di TUTTI gli allarmi...
+ ///
+ public virtual void forceAlarmCheck()
+ {
+#if false
+ // carico status allarmi (completo)
+ StFlag32 forceAlarm = (StFlag32)unchecked((int)UInt32.MaxValue);
+ try
+ {
+ refreshAlarmState(forceAlarm, false);
+ }
+ catch
+ {
+ lg.Error("Errore in fase di esecuzione di forceAlarmCheck");
+ }
+ if (utils.CRB("recTime")) logTimeResults();
#endif
}
}
diff --git a/IOB-WIN/IOB-WIN/IobSiemens.cs b/IOB-WIN/IOB-WIN/IobSiemens.cs
new file mode 100644
index 0000000..47547b8
--- /dev/null
+++ b/IOB-WIN/IOB-WIN/IobSiemens.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using IOB_UT;
+
+namespace IOB_WIN
+{
+ public class IobSiemens : IobGeneric
+ {
+ ///
+ /// estende l'init della classe base...
+ ///
+ ///
+ ///
+ public IobSiemens(MainForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
+ {
+#if false
+ // è little endian (NON serve conversione)
+ hasBigEndian = false;
+
+ lg.Info("Start init Adapter FANUC all'IP {0}", utils.CRS("ipPLC"));
+
+ parentForm.commPlcActive = true;
+ Runtime.CreateNC(CNC.NcType.FANUC, utils.CRS("ipPLC"));
+ parentForm.commPlcActive = false;
+ // inizializzo posizioni assi...
+ prevPosAxis = new double[adpConf.nAxis];
+ prevDirAxis = new int[adpConf.nAxis];
+
+ FANUC_ref = (FANUC)Runtime.NC;
+ if (utils.CRB("verbose")) lg.Info("FANUC_ref da CMSCncLib");
+
+ // disconnetto e connetto...
+ if (utils.CRB("verbose")) lg.Info("FANUC: tryDisconnect");
+ tryDisconnect();
+ lg.Info("FANUC: tryConnect");
+ tryConnect();
+ lg.Info("End init Adapter FANUC");
+#endif
+ }
+ }
+}
diff --git a/IOB-WIN/IOB-WIN/MainForm.Designer.cs b/IOB-WIN/IOB-WIN/MainForm.Designer.cs
index 342889b..24dcc5c 100644
--- a/IOB-WIN/IOB-WIN/MainForm.Designer.cs
+++ b/IOB-WIN/IOB-WIN/MainForm.Designer.cs
@@ -33,7 +33,7 @@
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.lblApp = new System.Windows.Forms.ToolStripStatusLabel();
this.lblVers = new System.Windows.Forms.ToolStripStatusLabel();
- this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
+ this.MainProgrBar = new System.Windows.Forms.ToolStripProgressBar();
this.lblComStats = new System.Windows.Forms.ToolStripStatusLabel();
this.lblStatus = new System.Windows.Forms.ToolStripStatusLabel();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
@@ -51,10 +51,17 @@
this.start = new System.Windows.Forms.Button();
this.port = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
+ this.STATUS_STRB_DW0 = new System.Windows.Forms.TextBox();
+ this.lblPLC_ADP = new System.Windows.Forms.Label();
+ this.gbMonitor = new System.Windows.Forms.GroupBox();
+ this.lblOutMessage3 = new System.Windows.Forms.Label();
+ this.lblOutMessage2 = new System.Windows.Forms.Label();
+ this.lblOutMessage = new System.Windows.Forms.Label();
this.statusStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.groupBox1.SuspendLayout();
+ this.gbMonitor.SuspendLayout();
this.SuspendLayout();
//
// statusStrip1
@@ -63,12 +70,12 @@
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.lblApp,
this.lblVers,
- this.toolStripProgressBar1,
+ this.MainProgrBar,
this.lblComStats,
this.lblStatus});
- this.statusStrip1.Location = new System.Drawing.Point(0, 349);
+ this.statusStrip1.Location = new System.Drawing.Point(0, 402);
this.statusStrip1.Name = "statusStrip1";
- this.statusStrip1.Size = new System.Drawing.Size(706, 25);
+ this.statusStrip1.Size = new System.Drawing.Size(974, 25);
this.statusStrip1.TabIndex = 0;
this.statusStrip1.Text = "statusStrip1";
//
@@ -85,10 +92,10 @@
this.lblVers.Size = new System.Drawing.Size(18, 20);
this.lblVers.Text = "...";
//
- // toolStripProgressBar1
+ // MainProgrBar
//
- this.toolStripProgressBar1.Name = "toolStripProgressBar1";
- this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 19);
+ this.MainProgrBar.Name = "MainProgrBar";
+ this.MainProgrBar.Size = new System.Drawing.Size(100, 19);
//
// lblComStats
//
@@ -109,7 +116,7 @@
this.FileTSMI});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Size = new System.Drawing.Size(706, 28);
+ this.menuStrip1.Size = new System.Drawing.Size(974, 28);
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
//
@@ -159,7 +166,7 @@
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
- this.tableLayoutPanel1.Size = new System.Drawing.Size(706, 42);
+ this.tableLayoutPanel1.Size = new System.Drawing.Size(974, 42);
this.tableLayoutPanel1.TabIndex = 66;
//
// lblTopCent
@@ -168,10 +175,10 @@
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblTopCent.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.lblTopCent.Location = new System.Drawing.Point(180, 0);
+ this.lblTopCent.Location = new System.Drawing.Point(247, 0);
this.lblTopCent.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblTopCent.Name = "lblTopCent";
- this.lblTopCent.Size = new System.Drawing.Size(345, 42);
+ this.lblTopCent.Size = new System.Drawing.Size(479, 42);
this.lblTopCent.TabIndex = 68;
this.lblTopCent.Text = "IOB loaded: N.A.";
this.lblTopCent.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -182,9 +189,9 @@
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblTopDx.AutoSize = true;
- this.lblTopDx.Location = new System.Drawing.Point(532, 0);
+ this.lblTopDx.Location = new System.Drawing.Point(733, 0);
this.lblTopDx.Name = "lblTopDx";
- this.lblTopDx.Size = new System.Drawing.Size(171, 42);
+ this.lblTopDx.Size = new System.Drawing.Size(238, 42);
this.lblTopDx.TabIndex = 69;
this.lblTopDx.Text = "...";
this.lblTopDx.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@@ -197,7 +204,7 @@
this.lblTopSx.AutoSize = true;
this.lblTopSx.Location = new System.Drawing.Point(3, 0);
this.lblTopSx.Name = "lblTopSx";
- this.lblTopSx.Size = new System.Drawing.Size(170, 42);
+ this.lblTopSx.Size = new System.Drawing.Size(237, 42);
this.lblTopSx.TabIndex = 70;
this.lblTopSx.Text = "...";
this.lblTopSx.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -227,6 +234,7 @@
this.dump.TabIndex = 4;
this.dump.Text = "Show Dump";
this.dump.UseVisualStyleBackColor = true;
+ this.dump.Click += new System.EventHandler(this.dump_Click);
//
// stop
//
@@ -237,6 +245,7 @@
this.stop.TabIndex = 3;
this.stop.Text = "Stop";
this.stop.UseVisualStyleBackColor = true;
+ this.stop.Click += new System.EventHandler(this.stop_Click);
//
// start
//
@@ -247,6 +256,7 @@
this.start.TabIndex = 2;
this.start.Text = "Start";
this.start.UseVisualStyleBackColor = true;
+ this.start.Click += new System.EventHandler(this.start_Click);
//
// port
//
@@ -271,11 +281,90 @@
this.label1.Text = "Port";
this.label1.Visible = false;
//
+ // STATUS_STRB_DW0
+ //
+ this.STATUS_STRB_DW0.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.STATUS_STRB_DW0.Location = new System.Drawing.Point(582, 97);
+ this.STATUS_STRB_DW0.Margin = new System.Windows.Forms.Padding(4);
+ this.STATUS_STRB_DW0.Name = "STATUS_STRB_DW0";
+ this.STATUS_STRB_DW0.Size = new System.Drawing.Size(387, 28);
+ this.STATUS_STRB_DW0.TabIndex = 69;
+ //
+ // lblPLC_ADP
+ //
+ this.lblPLC_ADP.AutoSize = true;
+ this.lblPLC_ADP.Location = new System.Drawing.Point(517, 101);
+ this.lblPLC_ADP.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.lblPLC_ADP.Name = "lblPLC_ADP";
+ this.lblPLC_ADP.Size = new System.Drawing.Size(63, 17);
+ this.lblPLC_ADP.TabIndex = 68;
+ this.lblPLC_ADP.Text = "BIT-MAP";
+ //
+ // gbMonitor
+ //
+ this.gbMonitor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.gbMonitor.BackColor = System.Drawing.Color.Black;
+ this.gbMonitor.Controls.Add(this.lblOutMessage3);
+ this.gbMonitor.Controls.Add(this.lblOutMessage2);
+ this.gbMonitor.Controls.Add(this.lblOutMessage);
+ this.gbMonitor.ForeColor = System.Drawing.SystemColors.Control;
+ this.gbMonitor.Location = new System.Drawing.Point(3, 137);
+ this.gbMonitor.Margin = new System.Windows.Forms.Padding(0);
+ this.gbMonitor.Name = "gbMonitor";
+ this.gbMonitor.Padding = new System.Windows.Forms.Padding(0);
+ this.gbMonitor.Size = new System.Drawing.Size(971, 265);
+ this.gbMonitor.TabIndex = 70;
+ this.gbMonitor.TabStop = false;
+ this.gbMonitor.Text = "Monitor variabili";
+ //
+ // lblOutMessage3
+ //
+ this.lblOutMessage3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.lblOutMessage3.AutoSize = true;
+ this.lblOutMessage3.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lblOutMessage3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
+ this.lblOutMessage3.Location = new System.Drawing.Point(459, 15);
+ this.lblOutMessage3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.lblOutMessage3.Name = "lblOutMessage3";
+ this.lblOutMessage3.Size = new System.Drawing.Size(16, 15);
+ this.lblOutMessage3.TabIndex = 62;
+ this.lblOutMessage3.Text = "...";
+ //
+ // lblOutMessage2
+ //
+ this.lblOutMessage2.Anchor = System.Windows.Forms.AnchorStyles.Top;
+ this.lblOutMessage2.AutoSize = true;
+ this.lblOutMessage2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lblOutMessage2.ForeColor = System.Drawing.Color.Yellow;
+ this.lblOutMessage2.Location = new System.Drawing.Point(245, 15);
+ this.lblOutMessage2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.lblOutMessage2.Name = "lblOutMessage2";
+ this.lblOutMessage2.Size = new System.Drawing.Size(16, 15);
+ this.lblOutMessage2.TabIndex = 61;
+ this.lblOutMessage2.Text = "...";
+ //
+ // lblOutMessage
+ //
+ this.lblOutMessage.AutoSize = true;
+ this.lblOutMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lblOutMessage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
+ this.lblOutMessage.Location = new System.Drawing.Point(4, 15);
+ this.lblOutMessage.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.lblOutMessage.Name = "lblOutMessage";
+ this.lblOutMessage.Size = new System.Drawing.Size(16, 15);
+ this.lblOutMessage.TabIndex = 60;
+ this.lblOutMessage.Text = "...";
+ //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(706, 374);
+ this.ClientSize = new System.Drawing.Size(974, 427);
+ this.Controls.Add(this.gbMonitor);
+ this.Controls.Add(this.STATUS_STRB_DW0);
+ this.Controls.Add(this.lblPLC_ADP);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.statusStrip1);
@@ -294,6 +383,8 @@
this.tableLayoutPanel1.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
+ this.gbMonitor.ResumeLayout(false);
+ this.gbMonitor.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -308,7 +399,7 @@
private System.Windows.Forms.ContextMenuStrip trayMenu;
private System.Windows.Forms.ToolStripStatusLabel lblApp;
private System.Windows.Forms.ToolStripStatusLabel lblVers;
- private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
+ private System.Windows.Forms.ToolStripProgressBar MainProgrBar;
private System.Windows.Forms.ToolStripStatusLabel lblComStats;
private System.Windows.Forms.ToolStripStatusLabel lblStatus;
private System.Windows.Forms.ToolStripMenuItem FileTSMI;
@@ -323,5 +414,11 @@
private System.Windows.Forms.Button start;
private System.Windows.Forms.TextBox port;
private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox STATUS_STRB_DW0;
+ private System.Windows.Forms.Label lblPLC_ADP;
+ private System.Windows.Forms.GroupBox gbMonitor;
+ private System.Windows.Forms.Label lblOutMessage3;
+ private System.Windows.Forms.Label lblOutMessage2;
+ private System.Windows.Forms.Label lblOutMessage;
}
}
\ No newline at end of file
diff --git a/IOB-WIN/IOB-WIN/MainForm.cs b/IOB-WIN/IOB-WIN/MainForm.cs
index db2b8ad..4f9d15f 100644
--- a/IOB-WIN/IOB-WIN/MainForm.cs
+++ b/IOB-WIN/IOB-WIN/MainForm.cs
@@ -27,7 +27,6 @@ namespace IOB_WIN
/// contatore veloce
///
protected int fastCount;
-#if false
///
/// contatore normale
///
@@ -40,7 +39,6 @@ namespace IOB_WIN
/// contatore sync allarmi
///
protected int alarmSyncCount;
-#endif
///
/// timer base in avvio
///
@@ -75,21 +73,7 @@ namespace IOB_WIN
#endregion
#region utils ed helpers
-
-#if false
- public static void EnableTab(TabPage page, bool enable)
- {
- EnableControls(page.Controls, enable);
- }
- private static void EnableControls(Control.ControlCollection ctls, bool enable)
- {
- foreach (Control ctl in ctls)
- {
- ctl.Enabled = enable;
- EnableControls(ctl.Controls, enable);
- }
- }
-#endif
+
private class Item
{
public string Name;
@@ -122,6 +106,27 @@ namespace IOB_WIN
#region gestione form e visibilità
+ // apro eseguibile dump
+ private void dump_Click(object sender, EventArgs e)
+ {
+ apriDumpAgent();
+ }
+ ///
+ /// apre agent di dump in CMD
+ ///
+ private static void apriDumpAgent()
+ {
+ string path = Application.StartupPath;
+ try
+ {
+ Process.Start(string.Format(@"{0}\..\..\dump\dump.exe", path));
+ }
+ catch
+ {
+ Process.Start(string.Format(@"{0}\dump\dump.exe", path));
+ }
+ }
+
///
/// Avvio MainForm
///
@@ -165,23 +170,19 @@ namespace IOB_WIN
// se abilitato autoload conf leggo file corretto...
if (utils.CRB("autoLoadConf"))
{
-#if false
- loadXmlFile(defConfFilePath);
- lg.Info("XML LOADED");
- loadPersistLayer(defPersLayerFile);
+ loadIniFile(utils.defConfFilePath);
+ lg.Info("INI LOADED");
+ loadPersistLayer(utils.defPersLayerFile);
lg.Info("PersLayerFile READ");
- agObj.loadPersData();
-#endif
+ iobObj.loadPersData();
lg.Info("PersLayerFile LOADED");
}
else
{
// definisco e avvio tipo adapter generico
tipoScelto = tipoAdapter.ND;
-#if false
- adpConf = new AdapterConf();
- loadAdapterType();
-#endif
+ IOBConf = new IobConfiguration();
+ loadIobType();
displayTaskAndWait("Waiting for config file selection");
}
@@ -231,7 +232,7 @@ namespace IOB_WIN
displayTaskAndWait("Main Form SHOWN");
}
///
- /// COmpletato resize form
+ /// Completato resize form
///
///
///
@@ -355,23 +356,19 @@ namespace IOB_WIN
/// determina se tentare di riconnettersi
private void fermaTutto(bool stopTimer, bool tryRestart)
{
-#if false
- agObj.stopAdapter(tryRestart);
+ iobObj.stopAdapter(tryRestart);
// salvo!
- savePersistLayer(defPersLayerFile);
- savePersistLayer(histPersLayerFile);
+ savePersistLayer(utils.defPersLayerFile);
+ savePersistLayer(utils.histPersLayerFile);
stop.Enabled = false;
dump.Enabled = false;
start.Enabled = true;
-#endif
if (stopTimer)
{
gather.Enabled = false;
-#if false
- agObj.tryDisconnect();
-#endif
+ iobObj.tryDisconnect();
}
}
@@ -396,19 +393,82 @@ namespace IOB_WIN
serverUrl = fIni.ReadString("SERVER", "MPURL", "/")
};
- loadAdapterType();
+ loadIobType();
// avvio macchina con adapter specificato...
if (utils.CRB("autoStartOnLoad"))
{
displayTaskAndWait("Auto Starting...");
-#if false
// avvio!
- avviaAdapter();
-#endif
+ avviaAdapter();
displayTaskAndWait("Auto Started!");
}
}
+ ///
+ /// Salva su file l'oggetto di persistenza dati
+ ///
+ ///
+ public void savePersistLayer(string filePath)
+ {
+ // in primis check semaforo salvataggio...
+ if (!iobObj.adpSaving)
+ {
+ // alzo semaforo salvataggio
+ iobObj.adpSaving = true;
+ // se HO dei dati...
+ if (iobObj.persistenceLayer != null)
+ {
+ try
+ {
+ utils.WritePlain(iobObj.persistenceLayer, filePath);
+ }
+ catch (Exception exc)
+ {
+ lg.Error(string.Format("Errore salvataggio file{0}{1}", Environment.NewLine, exc));
+ }
+ }
+ else
+ {
+ lg.Info("persistenceLayer null, non salvato...");
+ }
+ // abbasso semaforo salvataggio
+ iobObj.adpSaving = false;
+ }
+ }
+ ///
+ /// Carica da file l'oggetto di persistenza dati
+ ///
+ ///
+ public void loadPersistLayer(string filePath)
+ {
+ // inizializzo prima di leggere...
+ iobObj.persistenceLayer = new Dictionary();
+ iobObj.persistenceLayer = utils.ReadPlain(filePath);
+
+ // 2017.03.23 check problema files corrotti...
+ if (iobObj.persistenceLayer.Count == 0)
+ {
+ // se avesse letto un valore NON coerente (senza righe) PROVA a leggere a ritroso vecchi files... da histPersLayerFile e precedenti...
+ int numDD = 0;
+ int maxNumDD = utils.CRI("maxNumDD");
+ Dictionary lastRead = new Dictionary();
+ // continuo fino a che non leggo almeno 1 riga valida e non ho raggiunto maxDD
+ while (numDD < maxNumDD && lastRead.Count == 0)
+ {
+ // leggo il file storico alla data anticipata... (ci provo...)
+ try
+ {
+ lastRead = utils.ReadPlain(utils.prevPersLayerFile(numDD));
+ }
+ catch
+ { }
+ numDD++;
+ }
+ // se sono uscito PROVO a passare il file storico letto buono (oppure vuoto...)
+ iobObj.persistenceLayer = lastRead;
+ }
+ }
+
#endregion
private void mLoadConf_Click(object sender, EventArgs e)
@@ -433,19 +493,17 @@ namespace IOB_WIN
string iniConfFile = openFileDial.FileName;
loadIniFile(iniConfFile);
lg.Info("INI LOADED");
-#if false
- loadPersistLayer(defPersLayerFile);
+ loadPersistLayer(utils.defPersLayerFile);
lg.Info("PersLayerFile READ");
- agObj.loadPersData();
+ iobObj.loadPersData();
lg.Info("PersLayerFile LOADED");
-#endif
}
}
///
- /// carica adapter richiesto
+ /// carica IOB richiesto
///
- private void loadAdapterType()
+ private void loadIobType()
{
switch (tipoScelto)
{
@@ -457,10 +515,10 @@ namespace IOB_WIN
iobObj = new IobFanuc(this, IOBConf);
start.Enabled = true;
break;
- //case tipoAdapter.SIEMENS:
- // agObj = new AdapterSiemens(this, adpConf);
- // start.Enabled = true;
- // break;
+ case tipoAdapter.SIEMENS:
+ iobObj = new IobSiemens(this, IOBConf);
+ start.Enabled = true;
+ break;
case tipoAdapter.ND:
default:
iobObj = new IobDemo(this, IOBConf);
@@ -471,10 +529,96 @@ namespace IOB_WIN
lblTopCent.Text = string.Format("IOB {0}", IOBConf.codIOB);
lblTopDx.Text = string.Format("SRV: {0}{1}URL: {2}", IOBConf.serverIpAddr, Environment.NewLine, IOBConf.serverUrl);
- //// carico i default values su interfaccia
- //setDefaults();
+ // carico i default values su interfaccia
+ setDefaults();
displayTaskAndWait(string.Format("Caricata conf per adapter {0}", tipoScelto));
}
+
+ ///
+ /// impostazione valori defaults
+ ///
+ private void setDefaults()
+ {
+ stop.Enabled = false;
+ dump.Enabled = false;
+
+ STATUS_STRB_DW0.Text = utils.binaryForm(0);
+
+ MainProgrBar.Minimum = 0;
+ MainProgrBar.Maximum = 1000;
+ MainProgrBar.Value = 0;
+ MainProgrBar.Step = 1;
+ }
+
+ ///
+ /// Avvio dell'adapter
+ ///
+ ///
+ ///
+ private void start_Click(object sender, EventArgs e)
+ {
+ avviaAdapter();
+ iobObj.loadPersData();
+ // salvo che ho avviato adapter
+ lg.Info("Completato LOAD Adapter");
+ }
+
+ public void avviaAdapter()
+ {
+ displayTaskAndWait("Adapter starting");
+ // se NON sta girando...
+ if (!iobObj.adpRunning)
+ {
+ int porta = Convert.ToInt32(port.Text);
+ iobObj.startAdapter(porta);
+ displayTaskAndWait("Adapter started!");
+
+ // fix buttons start/stop/dump
+ start.Enabled = false;
+ stop.Enabled = true;
+ dump.Enabled = true;
+ if (utils.CRB("openDumpOnStart"))
+ {
+ displayTaskAndWait("Dump Window starting");
+ apriDumpAgent();
+ displayTaskAndWait("Dump Windows OK");
+ }
+
+ displayTaskAndWait("Start Timers");
+ // inizializzo contatori fast/mid/slow
+ fastCount = utils.CRI("fastCount");
+ normCount = utils.CRI("normCount");
+ slowCount = utils.CRI("slowCount");
+ alarmSyncCount = utils.CRI("alarmSyncCount");
+ displayTaskAndWait("Adapter Running...");
+ // forzo check allarmi..
+ iobObj.forceAlarmCheck();
+ }
+ else
+ {
+ displayTaskAndWait("Adapter STILL Running...");
+ }
+ }
+
+ ///
+ /// fermata dell'adapter
+ ///
+ ///
+ ///
+ private void stop_Click(object sender, EventArgs e)
+ {
+ fermaAdapter(false);
+ // salvo che ho fermato adapter
+ lg.Info("UNLOAD Adapter");
+ }
+ ///
+ /// Ferma l'adapter
+ ///
+ /// determina se si debba tentare riavvio automatico (per caduta connessione)
+ public void fermaAdapter(bool tryRestart)
+ {
+ fermaTutto(false, tryRestart);
+ }
}
}
diff --git a/IOB-WIN/IOB-WIN/dump/build.bat b/IOB-WIN/IOB-WIN/dump/build.bat
new file mode 100644
index 0000000..afc9d95
--- /dev/null
+++ b/IOB-WIN/IOB-WIN/dump/build.bat
@@ -0,0 +1 @@
+cl dump.c ws2_32.lib
\ No newline at end of file
diff --git a/IOB-WIN/IOB-WIN/dump/dump.c b/IOB-WIN/IOB-WIN/dump/dump.c
new file mode 100644
index 0000000..cad2cef
--- /dev/null
+++ b/IOB-WIN/IOB-WIN/dump/dump.c
@@ -0,0 +1,184 @@
+#include
+#ifdef _WIN32
+#include
+#else
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#endif
+
+#include
+#include
+
+#define PORT 7878
+#define HOST "localhost"
+#define BUFFER_SIZE 1024
+
+#ifndef _WIN32
+#define SOCKET int
+#define closesocket close
+#endif
+
+void cleanup_and_exit(int ret)
+{
+#ifdef _WIN32
+ WSACleanup();
+#endif
+ exit(ret);
+}
+
+void usage()
+{
+ fprintf(stderr, "Usage: dump [-t timeout] [host] [port] [file]\n host defaults to localhost\n port defaults to 7878\n file defaults to stdout\n");
+ exit(0);
+}
+
+int main(int argc, char **argv)
+{
+ char hostname[100];
+ SOCKET sd;
+ struct sockaddr_in pin;
+ struct hostent *hp;
+ char buffer[BUFFER_SIZE];
+ int port;
+ FILE *file;
+ char dump = 0;
+ char **argvp = argv;
+ time_t start = 0;
+ int remaining = 1, timeout = 0, nfds;
+ struct fd_set fds;
+ struct timeval tv, *tvp = 0;
+
+#ifdef _WIN32
+ WSADATA wsaData;
+ if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0) {
+ fprintf(stderr, "WSAStartup failed\n");
+ cleanup_and_exit(1);
+ }
+#endif
+
+ if (argc > 1) {
+ if (strcmp(argv[1], "-h") == 0) {
+ usage();
+ } else if (strcmp(argv[1], "-t") == 0) {
+ if (argc < 3) {
+ fprintf(stderr, "Missing timeout argument\n");
+ usage();
+ }
+ timeout = atoi(argv[2]);
+ argc -= 2;
+ argvp += 2;
+ }
+ }
+
+ strcpy(hostname,HOST);
+ if (argc > 1) {
+ strcpy(hostname,argvp[1]);
+ }
+
+ port = PORT;
+ if (argc > 2) {
+ port = atoi(argvp[2]);
+ }
+
+ file = stdout;
+ if (argc > 3) {
+ file = fopen(argvp[3], "w");
+ if (file == NULL) {
+ perror("fopen");
+ fprintf(stderr, "Cannot open file %s\n", argv[3]);
+ exit(1);
+ }
+ dump = 1;
+ }
+
+ /* go find out about the desired host machine */
+ if ((hp = gethostbyname(hostname)) == (void*) 0) {
+ perror("gethostbyname");
+ cleanup_and_exit(1);
+ }
+
+ /* fill in the socket structure with host information */
+ memset(&pin, 0, sizeof(pin));
+ pin.sin_family = AF_INET;
+ memcpy(&pin.sin_addr.s_addr, hp->h_addr, hp->h_length);
+ pin.sin_port = htons(port);
+
+ /* grab an Internet domain socket */
+ if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
+ perror("socket");
+ cleanup_and_exit(1);
+ }
+
+ /* connect to PORT on HOST */
+ if (connect(sd,(struct sockaddr *) &pin, sizeof(pin)) == -1) {
+ perror("connect");
+ cleanup_and_exit(1);
+ }
+
+ if (dump) {
+ printf("Connected to %s port %d\n", hostname, port);
+ }
+
+ /* wait for a message to come back from the server */
+ if (timeout > 0) {
+ start = time(0);
+ remaining = timeout;
+ tv.tv_usec = 0;
+ tvp = &tv;
+ }
+#ifdef _WIN32
+ nfds = 1;
+#else
+ nfds = sd + 1;
+#endif
+ while (remaining > 0) {
+ int n;
+
+ FD_ZERO(&fds);
+ FD_SET(sd, &fds);
+ tv.tv_sec = remaining;
+ n = select(nfds, &fds, (fd_set*) 0, (fd_set*) 0, tvp);
+ if (n < 0) {
+ closesocket(sd);
+ perror("recv");
+ cleanup_and_exit(1);
+ } else if (n > 0) {
+ int count = recv(sd, buffer, BUFFER_SIZE, 0);
+ if (count == -1) {
+ closesocket(sd);
+ perror("recv");
+ cleanup_and_exit(1);
+ }
+ if (count == 0)
+ break;
+ fwrite(buffer, 1, count, file);
+ if (dump) {
+ fputc('.', stdout);
+ fflush(stdout);
+ }
+ fflush(file);
+ }
+
+ if (timeout > 0) {
+ time_t now = time(0);
+ remaining -= (int) (now - start);
+ start = now;
+ }
+ }
+
+ if (dump) printf("\nFinished\n");
+
+ fclose(file);
+ closesocket(sd);
+#ifdef _WIN32
+ WSACleanup();
+#endif
+
+ return 0;
+}
diff --git a/IOB-WIN/IOB-WIN/dump/dump.exe b/IOB-WIN/IOB-WIN/dump/dump.exe
new file mode 100644
index 0000000..caa249c
Binary files /dev/null and b/IOB-WIN/IOB-WIN/dump/dump.exe differ
diff --git a/IOB-WIN/IOB-WIN/utils.cs b/IOB-WIN/IOB-WIN/utils.cs
index c60f73f..db92f35 100644
--- a/IOB-WIN/IOB-WIN/utils.cs
+++ b/IOB-WIN/IOB-WIN/utils.cs
@@ -1,4 +1,5 @@
-using System.Windows.Forms;
+using System;
+using System.Windows.Forms;
namespace IOB_WIN
{
@@ -64,6 +65,26 @@ namespace IOB_WIN
return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("defaultPersLayerFile"));
}
}
+
+ ///
+ /// file persistenza generale
+ ///
+ public static string histPersLayerFile
+ {
+ get
+ {
+ return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now);
+ }
+ }
+ ///
+ /// file persistenza generale data attuale ANTICIPATA di xx giorni
+ ///
+ /// num DD di anticipo
+ ///
+ public static string prevPersLayerFile(int numDD)
+ {
+ return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now.AddDays(-numDD));
+ }
///
/// File icona default
///