diff --git a/IOB-MAN/App.config b/IOB-MAN/App.config
index 48fb581c..e93a43f8 100644
--- a/IOB-MAN/App.config
+++ b/IOB-MAN/App.config
@@ -24,6 +24,7 @@
+
diff --git a/IOB-MAN/CONF/iob-man-config.json b/IOB-MAN/CONF/iob-man-config.json
new file mode 100644
index 00000000..e392c7ca
--- /dev/null
+++ b/IOB-MAN/CONF/iob-man-config.json
@@ -0,0 +1,29 @@
+{
+ "ListIOB": {
+ "SIMUL_00": "PING-TEST",
+ "SIMUL_01": "IOB-WIN-NEXT",
+ "SIMUL_02": "IOB-WIN-MTC",
+ "SIMUL_04": "IOB-WIN-NEXT",
+ "SIMUL_05": "IOB-WIN-NEXT"
+ },
+ "TargetConfig": {
+ "IOB-WIN-NEXT": {
+ "ExeName": "IOB-WIN-NEXT",
+ "ExePath": "C:\\Steamware\\IOB-WIN-NEXT\\IOB-WIN-NEXT.exe",
+ "LogDir": "C:\\Steamware\\IOB-WIN-NEXT\\logs\\",
+ "NLogPath": "C:\\Steamware\\IOB-WIN-NEXT\\NLog.config"
+ },
+ "IOB-WIN-MTC": {
+ "ExeName": "IOB-WIN-MTC",
+ "ExePath": "C:\\Steamware\\IOB-WIN-MTC\\IOB-WIN-MTC.exe",
+ "LogDir": "C:\\Steamware\\IOB-WIN-MTC\\logs\\",
+ "NLogPath": "C:\\Steamware\\IOB-WIN-MTC\\NLog.config"
+ },
+ "PING-TEST": {
+ "ExeName": "cmd",
+ "ExePath": "C:\\Steamware\\IOB-WIN-NEXT\\Resources\\Test.bat",
+ "LogDir": "C:\\Steamware\\IOB-WIN-NEXT\\logs\\",
+ "NLogPath": "C:\\Steamware\\IOB-WIN-NEXT\\NLog.config"
+ }
+ }
+}
\ No newline at end of file
diff --git a/IOB-MAN/CONF/process-legacy.json b/IOB-MAN/CONF/process-legacy.json
new file mode 100644
index 00000000..ca0ead80
--- /dev/null
+++ b/IOB-MAN/CONF/process-legacy.json
@@ -0,0 +1 @@
+[ "SIMUL_01", "SIMUL_02", "SIMUL_03", "SIMUL_04" ]
\ No newline at end of file
diff --git a/IOB-MAN/CONF/process.json b/IOB-MAN/CONF/process.json
index ca0ead80..3ccd6622 100644
--- a/IOB-MAN/CONF/process.json
+++ b/IOB-MAN/CONF/process.json
@@ -1 +1,5 @@
-[ "SIMUL_01", "SIMUL_02", "SIMUL_03", "SIMUL_04" ]
\ No newline at end of file
+{
+ "SIMUL_00": "PING-TEST",
+ "SIMUL_01": "IOB-WIN-NEXT",
+ "SIMUL_02": "IOB-WIN-MTC"
+}
\ No newline at end of file
diff --git a/IOB-MAN/CONF/target.json b/IOB-MAN/CONF/target.json
new file mode 100644
index 00000000..39014569
--- /dev/null
+++ b/IOB-MAN/CONF/target.json
@@ -0,0 +1,20 @@
+{
+ "IOB-WIN-NEXT": {
+ "ExeName": "IOB-WIN-NEXT",
+ "ExePath": "C:\\Steamware\\IOB-WIN-NEXT\\IOB-WIN-NEXT.exe",
+ "LogDir": "C:\\Steamware\\IOB-WIN-NEXT\\logs\\",
+ "NLogPath": "C:\\Steamware\\IOB-WIN-NEXT\\NLog.config"
+ },
+ "IOB-WIN-MTC": {
+ "ExeName": "IOB-WIN-MTC",
+ "ExePath": "C:\\Steamware\\IOB-WIN-MTC\\IOB-WIN-MTC.exe",
+ "LogDir": "C:\\Steamware\\IOB-WIN-MTC\\logs\\",
+ "NLogPath": "C:\\Steamware\\IOB-WIN-MTC\\NLog.config"
+ },
+ "PING-TEST": {
+ "ExeName": "cmd",
+ "ExePath": "C:\\Steamware\\IOB-WIN-NEXT\\Resources\\Test.bat",
+ "LogDir": "C:\\Steamware\\IOB-WIN-NEXT\\logs\\",
+ "NLogPath": "C:\\Steamware\\IOB-WIN-NEXT\\NLog.config"
+ }
+}
\ No newline at end of file
diff --git a/IOB-MAN/IOB-MAN.csproj b/IOB-MAN/IOB-MAN.csproj
index 73aa1385..5a92e2fc 100644
--- a/IOB-MAN/IOB-MAN.csproj
+++ b/IOB-MAN/IOB-MAN.csproj
@@ -197,6 +197,7 @@
VersGen.cs
+
@@ -243,8 +244,17 @@
Always
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
-
+
+ PreserveNewest
+
Always
diff --git a/IOB-MAN/IOBManPanel.Designer.cs b/IOB-MAN/IOBManPanel.Designer.cs
index 2894166c..90c4e610 100644
--- a/IOB-MAN/IOBManPanel.Designer.cs
+++ b/IOB-MAN/IOBManPanel.Designer.cs
@@ -386,6 +386,7 @@
this.dgvManagedItems.TabIndex = 76;
this.dgvManagedItems.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvManagedItems_CellDoubleClick);
this.dgvManagedItems.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dgvManagedItems_CellFormatting);
+ this.dgvManagedItems.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dgvManagedItems_CellMouseClick);
this.dgvManagedItems.SelectionChanged += new System.EventHandler(this.dgvManagedItems_SelectionChanged);
//
// UI_Timer
diff --git a/IOB-MAN/IOBManPanel.cs b/IOB-MAN/IOBManPanel.cs
index d4875e1f..e5f7674e 100644
--- a/IOB-MAN/IOBManPanel.cs
+++ b/IOB-MAN/IOBManPanel.cs
@@ -1,6 +1,7 @@
using Newtonsoft.Json;
using RestSharp;
using RestSharp.Serializers.NewtonsoftJson;
+using SharpCompress.Common;
using SteamWare.IO;
using SteamWare.Logger;
using SteamWare.Scheduler;
@@ -15,21 +16,13 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
+using System.Web.Hosting;
using System.Windows.Forms;
namespace IOB_MAN
{
public partial class IOBManPanel : Form
{
- #region Public Fields
-
- ///
- /// Elenco ARGS (uno per child da avviare)
- ///
- public List ArgsList = new List();
-
- #endregion Public Fields
-
#region Public Constructors
///
@@ -54,21 +47,6 @@ namespace IOB_MAN
#endregion Public Constructors
- #region Public Methods
-
- ///
- /// Cerca nell'elenco il processo corrente
- ///
- ///
- ///
- ///
- public static Process myGetProcByID(Process[] processlist, int id)
- {
- return processlist.FirstOrDefault(pr => pr.Id == id);
- }
-
- #endregion Public Methods
-
#region Protected Fields
///
@@ -136,26 +114,6 @@ namespace IOB_MAN
///
protected int numProcRunning;
- ///
- /// Path dell'exe da chiamare
- ///
- protected string TargetExe = "";
-
- ///
- /// Directory log generale x IOB-WIN (dentro ci sono x singoli IOB)
- ///
- protected string TargetLogDir = "";
-
- ///
- /// Name dell'exe da chiamare
- ///
- protected string TargetName = "";
-
- ///
- /// File target x conf NLog
- ///
- protected string TargetNLogConf = "";
-
///
/// Dataora prossima scadenza riavvio automatico
///
@@ -191,7 +149,9 @@ namespace IOB_MAN
#region Private Fields
private const int SW_SHOWMAXIMIZED = 3;
+
private const int SW_SHOWMINIMIZED = 2;
+
private const int SW_SHOWNORMAL = 1;
///
@@ -204,11 +164,31 @@ namespace IOB_MAN
///
private SemaphoreSlim _sync = new SemaphoreSlim(1);
+ ///
+ /// Dizionario ARGS (uno per child da avviare, nome IOB + tipo target EXE)
+ ///
+ private Dictionary ArgsList = new Dictionary();
+
///
/// Binding source degli elementi gestiti..
///
private BindingSource ElencoIOB = new BindingSource();
+ ///
+ /// CodIOB selezionato con right click
+ ///
+ private string selCodIob = "";
+
+ ///
+ /// Path di base data la row corrente selezionata con right click
+ ///
+ private string selIobTgtPath = "";
+
+ ///
+ /// Dizionario applicazioni target da lanciare
+ ///
+ private Dictionary TargetList = new Dictionary();
+
#endregion Private Fields
#region Private Methods
@@ -221,14 +201,17 @@ namespace IOB_MAN
///
private void apriChild()
{
- // preventivamente CHIUDO TUTTO
- forceKillByName(TargetName);
+ // preventivamente CHIUDO TUTTO per i programmi configurati...
+ foreach (var item in TargetList)
+ {
+ forceKillByName(item.Value.ExeName);
+ }
//closeAllChild(true);
Thread.Sleep(250);
// avvio i child
foreach (var item in ArgsList)
{
- startChildProc(item);
+ startChildProc(item.Value, item.Key);
}
numProcAvviati = ArgsList.Count;
updateNumRunning();
@@ -242,10 +225,11 @@ namespace IOB_MAN
// ciclo su row selezionate
foreach (DataGridViewRow riga in dgvManagedItems.SelectedRows)
{
+ var iobRec = ((iobAdapt)ElencoIOB[riga.Index]);
// verifico che sia già chiuso...
- if (((iobAdapt)ElencoIOB[riga.Index]).isRunning == false)
+ if (iobRec.isRunning == false)
{
- startChildProc(((iobAdapt)ElencoIOB[riga.Index]).CodIOB, riga.Index);
+ startChildProc(iobRec.TgtName, iobRec.CodIOB, riga.Index);
// rimuovo vecchia riga...
ElencoIOB.RemoveAt(riga.Index);
}
@@ -262,6 +246,14 @@ namespace IOB_MAN
{
ProcessStartInfo psi = null;
+ // recupero exe di default...
+ string TargetExe = utils.CRS("targetExe");
+ if (string.IsNullOrEmpty(TargetExe))
+ {
+ //TargetExe = string.Format(@"{0}\Resources\Test.bat", Application.StartupPath);
+ TargetExe = $@"{Application.StartupPath}\Resources\Test.bat";
+ }
+
// da testare x aprire chiudere risorsa...
psi = new ProcessStartInfo
{
@@ -285,7 +277,7 @@ namespace IOB_MAN
private void AutoUpdater_ApplicationExitEvent()
{
- utils.lgInfo("Chiusura IOB-WIN");
+ utils.lgInfo("Chiusura IOB-MAN");
Thread.Sleep(100);
// chiudo tutto
closeAllChild(true);
@@ -320,20 +312,17 @@ namespace IOB_MAN
{
foreach (iobAdapt item in ElencoIOB.List)
{
- if (item.isRunning)
+ try
{
- try
- {
- Process p = Process.GetProcessById(item.pID);
- // cerco e chiudo quelli che mi interessano...
- var windowsHandle = p.MainWindowHandle;
- ShowWindowAsync(windowsHandle, SW_SHOWNORMAL);
- }
- catch (Exception exc)
- {
- // errore era già chiuso..
- utils.lgError($"Errore in SHOW windows:{Environment.NewLine}{exc}");
- }
+ Process p = Process.GetProcessById(item.pID);
+ // cerco e chiudo quelli che mi interessano...
+ var windowsHandle = p.MainWindowHandle;
+ ShowWindowAsync(windowsHandle, SW_SHOWNORMAL);
+ }
+ catch (Exception exc)
+ {
+ // errore era già chiuso..
+ utils.lgError($"Errore in SHOW windows:{Environment.NewLine}{exc}");
}
}
}
@@ -342,20 +331,17 @@ namespace IOB_MAN
{
foreach (iobAdapt item in ElencoIOB.List)
{
- if (item.isRunning)
+ try
{
- try
- {
- Process p = Process.GetProcessById(item.pID);
- // cerco e chiudo quelli che mi interessano...
- var windowsHandle = p.MainWindowHandle;
- ShowWindowAsync(windowsHandle, SW_SHOWMINIMIZED);
- }
- catch (Exception exc)
- {
- // errore era già chiuso..
- utils.lgError($"Errore in HIDE windows:{Environment.NewLine}{exc}");
- }
+ Process p = Process.GetProcessById(item.pID);
+ // cerco e chiudo quelli che mi interessano...
+ var windowsHandle = p.MainWindowHandle;
+ ShowWindowAsync(windowsHandle, SW_SHOWMINIMIZED);
+ }
+ catch (Exception exc)
+ {
+ // errore era già chiuso..
+ utils.lgError($"Errore in HIDE windows:{Environment.NewLine}{exc}");
}
}
}
@@ -411,7 +397,7 @@ namespace IOB_MAN
// definisco limite temporale alle 21 di 2 gg prima...
DateTime minDate = DateTime.Today.AddHours(-27);
- // SOLO SE selezionato in dgv...
+ string TargetLogDir = utils.CRS("TargetLogDir");
string logDir = TargetLogDir;
if (dgvManagedItems.SelectedRows.Count > 0)
{
@@ -423,7 +409,15 @@ namespace IOB_MAN
// verifico che sia già chiuso...
var iobData = (iobAdapt)ElencoIOB[riga.Index];
// calcolo folder
- logDir = Path.Combine(TargetLogDir, iobData.CodIOB);
+ string exeName = !string.IsNullOrEmpty(iobData.TgtName) ? iobData.TgtName : "";
+ if (TargetList.Count > 0 && TargetList.ContainsKey(exeName))
+ {
+ logDir = Path.Combine(TargetList[exeName].LogDir, iobData.CodIOB);
+ }
+ else
+ {
+ logDir = Path.Combine(TargetLogDir, iobData.CodIOB);
+ }
// recupero file odierno
DirectoryInfo dI = new DirectoryInfo(logDir);
@@ -548,7 +542,7 @@ namespace IOB_MAN
btnStartSel.Visible = selected;
}
- private bool checkIstance(iobAdapt item, Process[] processList)
+ private bool checkIstance(iobAdapt item, List processList)
{
bool needRem;
// verifico se non sia già stato segnato x rimozione...)
@@ -561,9 +555,9 @@ namespace IOB_MAN
// verifico se esista il processo...
try
{
- if (processList.Length > 0)
+ if (processList.Count > 0)
{
- Process p = myGetProcByID(processList, item.pID);
+ Process p = processList.FirstOrDefault(pr => pr.Id == item.pID);
if (p != null)
{
needRem = p.HasExited;
@@ -631,16 +625,23 @@ namespace IOB_MAN
{
IList allItems = (IList)ElencoIOB.List;
bool needRem = false;
+ List processList = new List();
- // 2020.02.01 passato chiamata specifica x leggere in 1 sola volta TUTTO elenco processi
- // (x nome)...
- Process[] processList = Process.GetProcessesByName(TargetName);
+ // 2024.12.16 chiamata parallela controllo processi
+ // chiamo in parallelo la ricerca di tutti i TIPI di EXE gestiti...
+ Parallel.ForEach(TargetList, item =>
+ {
+ // 2020.02.01 passato chiamata specifica x leggere in 1 sola volta elenco processi da nome
+ var tempProcList = Process.GetProcessesByName(item.Key);
+ processList.AddRange(tempProcList.ToList());
+ }
+ );
// ciclo
Parallel.ForEach(allItems, item =>
- {
- needRem = checkIstance(item, processList);
- }
+ {
+ needRem = checkIstance(item, processList);
+ }
);
// aggiorno datagrid!
dgvManagedItems.Invalidate();
@@ -705,6 +706,7 @@ namespace IOB_MAN
/// resetta elenco
private void closeAllChild(bool doReset)
{
+ List listKilled = new List();
item2rem.Clear();
foreach (iobAdapt item in ElencoIOB.List)
{
@@ -713,42 +715,86 @@ namespace IOB_MAN
// processod a elenco noto
foreach (var item in item2rem)
{
- if (item.isRunning)
+ try
{
- try
+ Process p = Process.GetProcessById(item.pID);
+ p.CloseMainWindow();
+ p.WaitForExit(waitForExitMsec);
+ if (!p.HasExited)
{
- Process p = Process.GetProcessById(item.pID);
- p.CloseMainWindow();
- p.WaitForExit(waitForExitMsec);
- if (!p.HasExited)
- {
- utils.lgError($"Process not exited, now calling p.Kill()");
- p.Kill();
- }
- // indico NON running su datasource
- if (doReset)
- {
- ElencoIOB.Remove(item);
- }
- else
- {
- item.isRunning = false;
- }
+ utils.lgError($"Process not exited, now calling p.Kill()");
+ p.Kill();
}
- catch (Exception exc)
+ else
{
- Logging.Instance.Error($"Errore in fase di chiusura processo (pid: {item.pID} ) da elenco {exc}");
+ listKilled.Add(item);
+ }
+ // indico NON running su datasource
+ if (doReset)
+ {
+ ElencoIOB.Remove(item);
+ listKilled.Add(item);
+ }
+ else
+ {
+ item.isRunning = false;
+ }
+ }
+ catch (Exception exc)
+ {
+ Logging.Instance.Error($"Errore in fase di chiusura processo (pid: {item.pID} ) da elenco {exc}");
+ }
+ }
+ // elimino da elenco i killed...
+ foreach (var item in listKilled)
+ {
+ item2rem.Remove(item);
+ }
+
+ // verifico elenco ExeName rimasti attivi
+ List listExeRemain = item2rem.Select(x => x.ExeName).Distinct().ToList();
+
+ // se ce ne fossero...
+ if (listExeRemain.Count > 0)
+ {
+ // elimino x nome...
+ foreach (var item in TargetList)
+ {
+ forceKillByName(item.Key);
+ Thread.Sleep(waitForExitMsec / 5);
+ forceKillByName(item.Value.ExeName);
+ }
+
+ // cerco processi...
+ List processList = new List();
+
+ // 2024.12.16 chiamata parallela controllo processi
+ // chiamo in parallelo la ricerca di tutti i TIPI di EXE gestiti...
+ Parallel.ForEach(TargetList, item =>
+ {
+ // 2020.02.01 passato chiamata specifica x leggere in 1 sola volta elenco processi da nome
+ var tempProcList = Process.GetProcessesByName(item.Key);
+ processList.AddRange(tempProcList.ToList());
+ }
+ );
+
+ if (processList.Count > 0)
+ {
+ // attendo 2 * waitForExitMsec che i processi possano chiudersi gracefully...
+ Thread.Sleep(waitForExitMsec * 1);
+ foreach (var item in listExeRemain)
+ {
+ forceKillByName(item);
+ }
+ // ripeto seconda volta x sicurezza
+ Thread.Sleep(waitForExitMsec * 2);
+ foreach (var item in listExeRemain)
+ {
+ forceKillByName(item);
}
}
}
- if (item2rem.Count > 0)
- { // attendo 2*waitForExitMsec che i processi possano chiudersi gracefully...
- Thread.Sleep(waitForExitMsec * 2);
- forceKillByName(TargetName);
- // ripeto seconda volta x sicurezza
- Thread.Sleep(waitForExitMsec * 4);
- forceKillByName(TargetName);
- }
+
// verifico se resettare
if (doReset)
{
@@ -783,7 +829,7 @@ namespace IOB_MAN
p.Kill();
}
}
- catch(Exception exc)
+ catch (Exception exc)
{
Logging.Instance.Error($"closeSingleChild | Errore in chiusura processo (pid: {item.pID} ){Environment.NewLine}{exc}");
}
@@ -797,6 +843,11 @@ namespace IOB_MAN
UI_Timer.Dispose();
}
+ ///
+ /// DoubleClick su DGV
+ ///
+ ///
+ ///
private void dgvManagedItems_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
// seleziono riga...
@@ -826,6 +877,11 @@ namespace IOB_MAN
}
}
+ ///
+ /// Formattazione celle
+ ///
+ ///
+ ///
private void dgvManagedItems_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (this.dgvManagedItems.Columns[e.ColumnIndex].Name == "iobOnline")
@@ -894,6 +950,40 @@ namespace IOB_MAN
}
}
+ ///
+ /// Click celle DGV (right)
+ ///
+ ///
+ ///
+ private void dgvManagedItems_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Right)
+ {
+ // You can show a context menu or perform other actions here
+ ContextMenu contextMenu = new ContextMenu();
+ contextMenu.MenuItems.Add(new MenuItem("Show LOG folder", IobFolderOpenLog));
+ contextMenu.MenuItems.Add(new MenuItem("Show CONF folder", IobFolderOpenConf));
+ contextMenu.MenuItems.Add(new MenuItem("Show APP folder", IobFolderOpenApp));
+ contextMenu.Show(dgvManagedItems, dgvManagedItems.PointToClient(Cursor.Position));
+
+ // salvo info riga selezionata...
+ int pid = -1;
+ if (e.RowIndex >= 0)
+ {
+ selCodIob = ((iobAdapt)ElencoIOB[e.RowIndex]).CodIOB;
+ // cerco da conf...
+ if (ArgsList.ContainsKey(selCodIob))
+ {
+ string tgtKey = ArgsList[selCodIob];
+ if (TargetList.ContainsKey(tgtKey))
+ {
+ selIobTgtPath = Path.GetDirectoryName(TargetList[tgtKey].ExePath);
+ }
+ }
+ }
+ }
+ }
+
private void dgvManagedItems_SelectionChanged(object sender, EventArgs e)
{
checkButtons();
@@ -1025,6 +1115,21 @@ namespace IOB_MAN
});
}
+ private void IobFolderOpenApp(object sender, EventArgs e)
+ {
+ Process.Start("explorer.exe", selIobTgtPath);
+ }
+
+ private void IobFolderOpenConf(object sender, EventArgs e)
+ {
+ Process.Start("explorer.exe", Path.Combine(selIobTgtPath, "DATA", "CONF"));
+ }
+
+ private void IobFolderOpenLog(object sender, EventArgs e)
+ {
+ Process.Start("explorer.exe", Path.Combine(selIobTgtPath, "logs", selCodIob));
+ }
+
private void IOBManPanel_FormClosing(object sender, FormClosingEventArgs e)
{
closeAllChild(true);
@@ -1033,12 +1138,55 @@ namespace IOB_MAN
closeTimers();
}
+ ///
+ /// Caricamento aprametri x lancio client apps
+ ///
private void loadArgList()
{
- // in primis cerco SE ESISTA il file json di configuraizone parametri avvio
+ TargetList.Clear();
+ ArgsList.Clear();
+ // cerco se ho il file conf dei target, altrimenti lo popolo coi valori default "applicativo (legacy mode)
+ // in primis cerco SE ESISTA il file json di configurazione parametri avvio
+ string tgtFName = utils.CRS("TargetConfFile");
+ string TargetName = utils.CRS("appNameExt");
+ string jsonTgtFName = $"{Application.StartupPath}{tgtFName}";
+ // verifico se esista il file richiesto
+ if (File.Exists(jsonTgtFName))
+ {
+ // leggo il file json
+ using (StreamReader reader = new StreamReader(jsonTgtFName))
+ {
+ string rawData = reader.ReadToEnd();
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ TargetList = JsonConvert.DeserializeObject>(rawData);
+ }
+ }
+ }
+ else
+ {
+ string TargetExe = utils.CRS("targetExe");
+ if (string.IsNullOrEmpty(TargetExe))
+ {
+ //TargetExe = string.Format(@"{0}\Resources\Test.bat", Application.StartupPath);
+ TargetExe = $@"{Application.StartupPath}\Resources\Test.bat";
+ }
+ string TargetNLogConf = utils.CRS("TargetNLogConf");
+ string TargetLogDir = utils.CRS("TargetLogDir");
+
+ TargetConfig defTgt = new TargetConfig()
+ {
+ ExePath = TargetExe,
+ LogDir = TargetLogDir,
+ NLogPath = TargetLogDir
+ };
+ TargetList.Add(TargetName, defTgt);
+ }
+
+ // in primis cerco SE ESISTA il file json di configurazione parametri avvio
string fileName = utils.CRS("ArgsConfFile");
string jsonFileName = $"{Application.StartupPath}{fileName}";
- // verifico se esista il file richeisto
+ // verifico se esista il file richiesto
if (File.Exists(jsonFileName))
{
// leggo il file json
@@ -1046,7 +1194,21 @@ namespace IOB_MAN
string jsonData = reader.ReadToEnd();
if (!string.IsNullOrEmpty(jsonData))
{
- ArgsList = JsonConvert.DeserializeObject>(jsonData);
+ // se modalità legacy --> deserializzo come lista e aggiungo info...
+ if (jsonData.StartsWith("["))
+ {
+ var rawList = JsonConvert.DeserializeObject>(jsonData);
+ //ArgsList = rawList.ToDictionary();
+ foreach (var item in rawList)
+ {
+ ArgsList.Add(item, TargetName);
+ }
+ }
+ // altrimenti provo a deserializzare come dizionario...
+ else
+ {
+ ArgsList = JsonConvert.DeserializeObject>(jsonData);
+ }
}
}
else
@@ -1060,7 +1222,7 @@ namespace IOB_MAN
// ne creo rand (5-15) di default...
for (int i = 0; i < rand.Next(5, 10); i++)
{
- ArgsList.Add($"127.0.0.{i + 1}");
+ ArgsList.Add($"127.0.0.{i + 1}", TargetName);
}
}
else
@@ -1068,7 +1230,7 @@ namespace IOB_MAN
var elenco = ArgsString.Split(',');
foreach (var item in elenco)
{
- ArgsList.Add(item);
+ ArgsList.Add(item, TargetName);
}
}
// serializzo e salvo file!
@@ -1082,22 +1244,12 @@ namespace IOB_MAN
///
private void loadConfig()
{
- ArgsList.Clear();
waitForExitMsec = utils.CRI("waitForExitMsec");
checkPeriod = utils.CRI("checkPeriod");
uiPeriod = utils.CRI("uiPeriod");
forceCheckPeriodMult = utils.CRI("forceCheckPeriodMult");
- TargetExe = utils.CRS("targetExe");
- TargetNLogConf = utils.CRS("TargetNLogConf");
- TargetLogDir = utils.CRS("TargetLogDir");
ApiUrl = utils.CRS("ApiUrl");
- TargetName = utils.CRS("appNameExt");
- if (string.IsNullOrEmpty(TargetExe))
- {
- //TargetExe = string.Format(@"{0}\Resources\Test.bat", Application.StartupPath);
- TargetExe = $@"{Application.StartupPath}\Resources\Test.bat";
- }
- utils.lgInfo($"Target exe: {TargetExe}");
+
// caricamento configurazione argomenti di avvio processi
loadArgList();
}
@@ -1209,7 +1361,7 @@ namespace IOB_MAN
foreach (var item in proc2restart)
{
// riavvio!
- startChildProc(item.Value.CodIOB, item.Key);
+ startChildProc(item.Value.TgtName, item.Value.CodIOB, item.Key);
}
// update!
updateStatus();
@@ -1273,23 +1425,51 @@ namespace IOB_MAN
// scrivo conf x programma IOB-MAN
File.WriteAllText($@"{Application.StartupPath}\NLog.config", rawData);
- // scrivo conf x IOB-WIN gestiti
- File.WriteAllText(TargetNLogConf, rawData);
+ // scrivo conf x SW gestiti
+ foreach (var item in TargetList)
+ {
+ if (!File.Exists(item.Value.NLogPath))
+ {
+ // verifico folder parent...
+ string parentDir = Path.GetDirectoryName(item.Value.NLogPath);
+ if (!Directory.Exists(parentDir))
+ {
+ Directory.CreateDirectory(parentDir);
+ }
+ }
+ File.WriteAllText(item.Value.NLogPath, rawData);
+ }
}
///
/// Avvio di un child process da parametro ARG
///
- ///
- ///
- private void startChildProc(string procArg, int indice = -1)
+ /// Nome Target EXE
+ /// Args da passare all'exe (IOB name da caricare)
+ /// posizione (opzionale) in lista
+ private void startChildProc(string tgtName, string codIob, int indice = -1)
{
ProcessStartInfo psi = null;
// da testare x aprire chiudere risorsa...
+ string TargetExe = utils.CRS("targetExe");
+ if (string.IsNullOrEmpty(TargetExe))
+ {
+ //TargetExe = string.Format(@"{0}\Resources\Test.bat", Application.StartupPath);
+ TargetExe = $@"{Application.StartupPath}\Resources\Test.bat";
+ }
+ string currTgtExe = TargetExe;
+ if (TargetList.Count > 0)
+ {
+ if (TargetList.ContainsKey(tgtName))
+ {
+ currTgtExe = TargetList[tgtName].ExePath;
+ }
+ }
psi = new ProcessStartInfo
{
- FileName = TargetExe,
- Arguments = $"{utils.CRS("BaseArg")}{procArg}",
+ //FileName = TargetExe,
+ FileName = currTgtExe,
+ Arguments = $"{utils.CRS("BaseArg")}{codIob}",
WindowStyle = ProcessWindowStyle.Minimized
};
@@ -1299,8 +1479,12 @@ namespace IOB_MAN
// accodo nuovo IOB...
iobAdapt newIob = new iobAdapt();
DateTime adesso = DateTime.Now;
- newIob.redisMan = new RedisIobCache("", procArg);
- newIob.CodIOB = procArg;
+ newIob.redisMan = new RedisIobCache("", codIob);
+ newIob.CodIOB = codIob;
+ newIob.TgtName = tgtName;
+ //newIob.ExeName = p.ProcessName;
+ newIob.ExeName = FileVersionInfo.GetVersionInfo(currTgtExe).FileDescription ?? p.ProcessName;
+ //newIob.ExeName = tgtName;
newIob.startTime = adesso;
newIob.pID = p.Id;
newIob.isRunning = true;
@@ -1313,7 +1497,7 @@ namespace IOB_MAN
{
ElencoIOB.Insert(indice, newIob);
}
- utils.lgInfo($"Avviato child process per {procArg} | pid: {p.Id}");
+ utils.lgInfo($"Avviato child process per {codIob} | pid: {p.Id}");
}
private void txtTOutAutoCheck_TextChanged(object sender, EventArgs e)
diff --git a/IOB-MAN/RedisMan.cs b/IOB-MAN/RedisMan.cs
index c550295c..47945010 100644
--- a/IOB-MAN/RedisMan.cs
+++ b/IOB-MAN/RedisMan.cs
@@ -44,6 +44,11 @@ namespace IOB_MAN
///
public string IobType { get; set; } = "";
+ ///
+ /// Nome dell'exe
+ ///
+ public string ExeName { get; set; } = "";
+
///
/// DataOra ultima comunicazione IN (con PLC)
///
@@ -119,7 +124,7 @@ namespace IOB_MAN
}
///
- /// init classe gestione dati IOB su Redis
+ /// Init classe gestione dati IOB su Redis
///
///
///
diff --git a/IOB-MAN/Resources/ChangeLog.html b/IOB-MAN/Resources/ChangeLog.html
index 7ab91d78..69157ffa 100644
--- a/IOB-MAN/Resources/ChangeLog.html
+++ b/IOB-MAN/Resources/ChangeLog.html
@@ -1,5 +1,5 @@
- MAPO-IOB-WIN
+ MAPO-IOB-MAN
v: {{CURRENT-REL}}
Acquisitore MAPO-IOB per sistemi Windows
diff --git a/IOB-MAN/Resources/manifest.xml b/IOB-MAN/Resources/manifest.xml
index f66a7e99..511313e7 100644
--- a/IOB-MAN/Resources/manifest.xml
+++ b/IOB-MAN/Resources/manifest.xml
@@ -1,7 +1,7 @@
-
1.0.0.0
- http://seriate.steamware.net:8083/SWS/MAPO/IOB-WIN/{{BRANCHNAME}}/MAPO-IOB-WIN.zip
- http://seriate.steamware.net:8083/SWS/MAPO/IOB-WIN/{{BRANCHNAME}}/ChangeLog.html
+ http://seriate.steamware.net:8083/SWS/MAPO/IOB-MAN/{{BRANCHNAME}}/MAPO-IOB-WIN.zip
+ http://seriate.steamware.net:8083/SWS/MAPO/IOB-MAN/{{BRANCHNAME}}/ChangeLog.html
false
\ No newline at end of file
diff --git a/IOB-MAN/TargetConfig.cs b/IOB-MAN/TargetConfig.cs
new file mode 100644
index 00000000..6ae3d34e
--- /dev/null
+++ b/IOB-MAN/TargetConfig.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace IOB_MAN
+{
+ public class TargetConfig
+ {
+ ///
+ /// Nome eseguibile ( x kill e ricerca)
+ ///
+ public string ExeName { get; set; } = "";
+ ///
+ /// Path completo eseguibile
+ ///
+ public string ExePath { get; set; } = "";
+ ///
+ /// Folder dove sono presenti i log generati dall'eseguibile
+ ///
+ public string LogDir { get; set; } = "";
+ ///
+ /// Path file di conf NLog da gestire
+ ///
+ public string NLogPath { get; set; } = "";
+ }
+}
diff --git a/IOB-MAN/iobAdapt.cs b/IOB-MAN/iobAdapt.cs
index c93fea1a..d9b7552e 100644
--- a/IOB-MAN/iobAdapt.cs
+++ b/IOB-MAN/iobAdapt.cs
@@ -67,6 +67,12 @@ namespace IOB_MAN
[DisplayName("IOB")]
public string CodIOB { get; set; }
+ ///
+ /// Nome del target obj avviato
+ ///
+ [DisplayName("Prog")]
+ public string TgtName { get; set; }
+
///
/// Tipo macchina/CNC/PLC
///
@@ -202,6 +208,12 @@ namespace IOB_MAN
}
}
+ ///
+ /// Nome dell'EXE avviato
+ ///
+ [DisplayName("Exe")]
+ public string ExeName { get; set; }
+
#endregion Public Properties
}
}
\ No newline at end of file
diff --git a/IOB-WIN-MTC-CLI/IOB-WIN-MTC-CLI.csproj b/IOB-WIN-MTC-CLI/IOB-WIN-MTC-CLI.csproj
new file mode 100644
index 00000000..9aa5404f
--- /dev/null
+++ b/IOB-WIN-MTC-CLI/IOB-WIN-MTC-CLI.csproj
@@ -0,0 +1,37 @@
+
+
+
+ Exe
+ net8.0
+ IOB_WIN_MTC_CLI
+ enable
+ enable
+ true
+ true
+ Debug;Release;Remote_DEBUG
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Always
+
+
+ Always
+
+
+
+
+
+
+
+
diff --git a/IOB-WIN-MTC-CLI/IobComm.cs b/IOB-WIN-MTC-CLI/IobComm.cs
new file mode 100644
index 00000000..d85d6636
--- /dev/null
+++ b/IOB-WIN-MTC-CLI/IobComm.cs
@@ -0,0 +1,601 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using IOB_UT_NEXT;
+using MTConnect;
+using MTConnect.Assets;
+using MTConnect.Clients;
+using MTConnect.Devices;
+using MTConnect.Observations;
+using MTConnect.Streams;
+using NLog;
+using Spectre.Console;
+
+namespace IOB_WIN_MTC_CLI
+{
+ public class IobComm
+ {
+ #region Public Constructors
+
+ ///
+ /// Init classe
+ ///
+ public IobComm()
+ {
+ }
+
+ ///
+ /// Init Classe
+ ///
+ ///
+ public IobComm(string opcAddr)
+ {
+ baseUrl = opcAddr;
+ }
+
+ ///
+ /// Init Classe
+ ///
+ ///
+ ///
+ ///
+ public IobComm(string opcAddr, string titolo, string sottotitolo)
+ {
+ baseUrl = opcAddr;
+ title = titolo;
+ subtitle = sottotitolo;
+ }
+
+ #endregion Public Constructors
+
+ #region Public Methods
+
+ public void DoConfig()
+ {
+ msgData = new List();
+ dispData = new Dictionary();
+
+ // primo display
+ msgData.Add("Starting CLI setup...");
+ DoDisplayAsync();
+ }
+
+ ///
+ /// Esecuzione log secondo conf
+ ///
+ ///
+ public void doLog(string msg = "")
+ {
+ try
+ {
+ if (fileLog)
+ {
+ lg.Info($"{msg}");
+ }
+
+ if (consoleLog)
+ {
+ Console.WriteLine(msg);
+ }
+ }
+ catch (Exception exc)
+ {
+ Console.WriteLine($"Eccezione in log:{Environment.NewLine}{exc}");
+ }
+ }
+
+ ///
+ /// Esecuzione probe call indipendente
+ ///
+ public void ForceProbe()
+ {
+ // init
+ sw.Restart();
+ msgData = new List();
+ dispData = new Dictionary();
+
+ // primo display
+ msgData.Add("Calling PROBE...");
+ DoDisplayAsync();
+
+ // inizio processing
+ var prbClient = new MTConnectHttpProbeClient(baseUrl);
+ prbClient.Timeout = 20000;
+ var prbDoc = prbClient.Get();
+ // preparo output
+ if (prbDoc == null)
+ {
+ msgData.Add($"Preliminari Probe | {sw.ElapsedMilliseconds}ms | No answer, continue...");
+ }
+ else
+ {
+ displayProbeDoc("Preliminari Probe RECEIVED", prbDoc);
+ }
+ }
+
+ public void MainLoop()
+ {
+ sw.Restart();
+ msgData = new List();
+ dispData = new Dictionary();
+
+ ConsoleKeyInfo answ = Console.ReadKey();
+ while (answ.Key != ConsoleKey.Escape)
+ {
+ msgData.Add($"CONSOLE LOG: {consoleLog}");
+ msgData.Add($"FILE LOG: {fileLog}");
+ DoDisplayAsync();
+
+ answ = Console.ReadKey();
+ // controllo key...
+ if (answ.Key == ConsoleKey.C)
+ {
+ consoleLog = !consoleLog;
+ }
+ else if (answ.Key == ConsoleKey.F)
+ {
+ fileLog = !fileLog;
+ }
+ else if (answ.Key == ConsoleKey.P)
+ {
+ msgData = new List();
+ dispData = new Dictionary();
+ ForceProbe();
+ }
+ else if (answ.Key == ConsoleKey.R)
+ {
+ msgData = new List();
+ dispData = new Dictionary();
+ client.Stop();
+ Task.Delay(500);
+ dtStart = DateTime.Now;
+ StartClient();
+ msgData.Add($"Client restarted!");
+ }
+ else if (answ.Key == ConsoleKey.S)
+ {
+ msgData = new List();
+ dispData = new Dictionary();
+ client.Stop();
+ msgData.Add($"Client stopped!");
+ }
+ }
+ doLog("...closing Now!");
+ }
+
+ private DateTime displayVeto = DateTime.Now;
+
+ ///
+ /// Avvio del thread principale
+ ///
+ public void StartClient()
+ {
+ // init
+ sw.Restart();
+ msgData = new List();
+ dispData = new Dictionary();
+
+ // primo display
+ msgData.Add("Client App setup...");
+ DoDisplayAsync();
+
+ // setup client
+ client = new MTConnectHttpClient(baseUrl);
+ // sample interval
+ client.Interval = 500;
+ // timeout x richieste
+ client.Timeout = 4000;
+ // timeout riconnessione
+ client.ReconnectionInterval = 5000;
+
+ // aggancio eventi
+ if (enabAsset)
+ {
+ client.AssetsReceived += Client_AssetsReceived;
+ }
+ client.ClientStarted += Client_ClientStarted;
+ client.ClientStopped += Client_ClientStopped;
+ client.ConnectionError += Client_ConnectionError;
+ client.CurrentReceived += Client_CurrentReceived;
+ client.ProbeReceived += Client_ProbeReceived;
+ if (enabSample)
+ {
+ client.SampleReceived += Client_SampleReceived;
+ }
+ if (enabObserv)
+ {
+ // conviene usare sample x avere la stessa cosa ma con altre info...
+ client.ObservationReceived += Client_ObservationReceived;
+ }
+
+ msgData.Add($"Setup completed! | {sw.ElapsedMilliseconds}ms");
+ DoDisplayAsync();
+
+ // vero avvio
+ client.Start();
+ msgData.Add($"Client Started | {sw.ElapsedMilliseconds} ms");
+ DoDisplayAsync();
+ }
+
+ #endregion Public Methods
+
+ #region Protected Fields
+
+ protected bool enabAsset = true;
+ protected bool enabObserv = false;
+ protected bool enabSample = true;
+
+ #endregion Protected Fields
+
+ #region Protected Properties
+
+ protected bool consoleLog { get; set; } = false;
+
+ protected bool fileLog { get; set; } = true;
+
+ #endregion Protected Properties
+
+ #region Protected Methods
+
+ ///
+ /// Main display function
+ ///
+ ///
+ ///
+ protected async Task DoDisplayAsync()
+ {
+ // attesa che non sia in corso update
+ while (inRefresh || displayVeto > DateTime.Now)
+ {
+ //Thread.Sleep(rand.Next(50, 150));
+ await Task.Delay(rand.Next(50, 150));
+ }
+
+ try
+ {
+ inRefresh = true;
+ displayVeto = DateTime.Now.AddMilliseconds(1000);
+ AnsiConsole.Clear();
+
+ // titolo
+ AnsiConsole.Write(
+ new FigletText(title)
+ .LeftJustified()
+ .Color(Color.Cyan1));
+
+ var rule = new Rule(subtitle);
+ rule.RightJustified();
+ AnsiConsole.Write(rule);
+
+ // se presenti messaggi
+ if (msgData.Count > 0)
+ {
+ foreach (var msg in msgData)
+ {
+ if (fileLog)
+ {
+ lg.Info(msg);
+ }
+ AnsiConsole.MarkupLine(msg);
+ }
+ rule = new Rule();
+ rule.RuleStyle("grey dim");
+ AnsiConsole.Write(rule);
+ }
+
+ // se presenti graph...
+ if (dispData.Count > 0)
+ {
+ foreach (var graph in dispData)
+ {
+ }
+ rule = new Rule();
+ rule.RuleStyle("grey dim");
+ AnsiConsole.Write(rule);
+ }
+
+ // comandi
+ if (commandList.Count > 0)
+ {
+ // mostro cmd list...
+ foreach (var cmd in commandList)
+ {
+ AnsiConsole.MarkupLine(cmd);
+ }
+
+ rule = new Rule();
+ rule.RuleStyle("grey dim");
+ AnsiConsole.Write(rule);
+ }
+ string uptime = $"Uptime: {DateTime.Now.Subtract(dtStart).TotalMinutes:N1} min";
+ AnsiConsole.WriteLine(uptime);
+ }
+ catch (Exception exc)
+ {
+ Console.WriteLine($"Eccezione in DoDisplay:{Environment.NewLine}{exc}");
+ }
+ inRefresh = false;
+ }
+
+ #endregion Protected Methods
+
+ #region Private Fields
+
+ private DateTime dtStart = DateTime.Now;
+
+ private static Logger lg = LogManager.GetCurrentClassLogger();
+
+ private string baseUrl = "192.168.1.27:5000";
+
+ private List commandList = new List() {
+ "R = Restart Service | S = Stop Service | P = force probe",
+ "C = toggle console log | F = toggle file log | Press ESC to exit"
+ };
+
+ ///
+ /// Dizionario variabili conteggio collezionate
+ ///
+ private Dictionary DataCounters = new Dictionary();
+
+ private Dictionary dispData = new Dictionary();
+ private bool inRefresh = false;
+ private List msgData = new List();
+ private Random rand = new Random();
+ private string sep = "------------------------";
+
+ private string subtitle = "EgalWare 2024+";
+
+ private Stopwatch sw = new Stopwatch();
+
+ private string title = "MtConnect Client";
+
+ #endregion Private Fields
+
+ #region Private Properties
+
+ private MTConnectHttpClient client { get; set; } = new MTConnectHttpClient("");
+
+ #endregion Private Properties
+
+ #region Private Methods
+
+ private void Client_AssetsReceived(object sender, MTConnect.Assets.IAssetsResponseDocument document)
+ {
+ displayAsset(document);
+ }
+
+ private void Client_ClientStarted(object sender, EventArgs e)
+ {
+ msgData = new List();
+ msgData.Add($"Client Started!");
+ msgData.Add(sep);
+ DoDisplayAsync();
+ }
+
+ private void Client_ClientStopped(object sender, EventArgs e)
+ {
+ msgData = new List();
+ msgData.Add($"Client Stopped!");
+ msgData.Add(sep);
+ DoDisplayAsync();
+ }
+
+ private void Client_ConnectionError(object sender, Exception exc)
+ {
+ msgData = new List();
+ msgData.Add($"Connection ERROR returned!");
+ msgData.Add($"{exc}");
+ msgData.Add(sep);
+ DoDisplayAsync();
+ }
+
+ private void Client_CurrentReceived(object sender, MTConnect.Streams.IStreamsResponseDocument document)
+ {
+ displayCurrent(document);
+ }
+
+ private void Client_ObservationReceived(object sender, IObservation observ)
+ {
+ msgData = new List();
+ msgData.Add("OBSERVATION");
+ msgData.Add(sep);
+ processObservation(observ);
+ }
+
+ private void Client_ProbeReceived(object sender, MTConnect.Devices.IDevicesResponseDocument document)
+ {
+ displayProbeDoc("Client Probe RECEIVED", document);
+ }
+
+ private void Client_SampleReceived(object sender, MTConnect.Streams.IStreamsResponseDocument document)
+ {
+ displaySample(document);
+ }
+
+ private void displayAsset(IAssetsResponseDocument document)
+ {
+ msgData = new List();
+ int numAssets = 0;
+ msgData.Add("ASSET received");
+ doLog(sep);
+ foreach (var asset in document.Assets)
+ {
+ // Print AssetId to the Console
+ doLog($"Asset: {asset.AssetId}");
+ numAssets++;
+ }
+ msgData.Add($" Found [green]{numAssets} Assets[/]");
+
+ DoDisplayAsync();
+ }
+
+ private void displayCurrent(IStreamsResponseDocument document)
+ {
+ msgData = new List();
+ int numStream = 0;
+ int numCompo = 0;
+ msgData.Add($"CURRENT received!");
+
+ foreach (var deviceStream in document.Streams)
+ {
+ // DeviceStream
+ msgData.Add($" Stream: {deviceStream.Name}");
+ numStream++;
+
+ // Component Streams
+ foreach (var componentStream in deviceStream.ComponentStreams)
+ {
+ processData(componentStream);
+ numCompo++;
+ }
+ }
+ msgData.Add($" Found [green]{numStream} Streams[/]");
+ msgData.Add($" Found [yellow]{numCompo} Components[/]");
+
+ DoDisplayAsync();
+ }
+
+ private void displayProbeDoc(string message, IDevicesResponseDocument prbDoc)
+ {
+ msgData = new List();
+ msgData.Add(message);
+ msgData.Add(sep);
+
+ foreach (var device in prbDoc.Devices)
+ {
+ // Device
+ msgData.Add($"DEV: {device.Id}");
+ int numDataItem = 0;
+ int numComponents = 0;
+ int numCompositions = 0;
+
+ // All DataItems (traverse the entire Device model)
+ if (device.DataItems.Count() > 0)
+ {
+ foreach (var dataItem in device.GetDataItems())
+ {
+ lg.Trace($" DItm | {dataItem.IdPath}");
+ numDataItem++;
+ }
+ }
+ msgData.Add($" Found [green]{numDataItem} DataItems[/]");
+
+ // All Components (traverse the entire Device model)
+ if (device.Components.Count() > 0)
+ {
+ foreach (var component in device.GetComponents())
+ {
+ lg.Trace($" Comp | {component.IdPath}");
+ numComponents++;
+ }
+ }
+ msgData.Add($" Found [blue]{numComponents} Components[/]");
+
+ // All Compositions (traverse the entire Device model)
+ if (device.Compositions.Count() > 0)
+ {
+ foreach (var composition in device.GetCompositions())
+ {
+ lg.Trace($" Cpst | {composition.IdPath}");
+ numCompositions++;
+ }
+ }
+ msgData.Add($" Found [yellow]{numCompositions} Compositions[/]");
+ }
+ msgData.Add(sep);
+
+ DoDisplayAsync();
+ }
+
+ private void displaySample(IStreamsResponseDocument document)
+ {
+ msgData = new List();
+ int numStream = 0;
+ int numCompo = 0;
+ msgData.Add($"SAMPLE");
+
+ foreach (var deviceStream in document.Streams)
+ {
+ // DeviceStream
+ msgData.Add($" Stream: {deviceStream.Name}");
+ numStream++;
+
+ // Component Streams
+ foreach (var componentStream in deviceStream.ComponentStreams)
+ {
+ processData(componentStream);
+ numCompo++;
+ }
+ }
+ msgData.Add($" Found [green]{numStream} Streams[/]");
+ msgData.Add($" Found [yellow]{numCompo} Components[/]");
+
+ DoDisplayAsync();
+ }
+
+ private void processData(IComponentStream dataStream)
+ {
+ int numCondition = 0;
+ int numEvent = 0;
+ int numSample = 0;
+ // DataItems (Samples, Events, and Conditions)
+ foreach (var observation in dataStream.Observations)
+ {
+ processObservation(observation);
+ switch (observation.Category)
+ {
+ case DataItemCategory.CONDITION:
+ numCondition++;
+ break;
+
+ case DataItemCategory.EVENT:
+ numEvent++;
+ break;
+
+ case DataItemCategory.SAMPLE:
+ numSample++;
+ break;
+
+ default:
+ break;
+ }
+ }
+ msgData.Add($" Component {dataStream.Name} | {numCondition} Conditions | {numEvent} Events | {numSample} Samples");
+ }
+
+ private void processObservation(IObservation observation)
+ {
+ string sMsg = $" - {observation.DataItemId} | {observation.Category}";
+#if false
+ switch (observation.Category)
+ {
+ case MTConnect.Devices.DataItemCategory.CONDITION:
+ break;
+
+ case MTConnect.Devices.DataItemCategory.EVENT:
+ break;
+
+ case MTConnect.Devices.DataItemCategory.SAMPLE:
+ break;
+
+ default:
+ break;
+ }
+#endif
+ if (observation.Values != null && observation.Values.Count() > 0)
+ {
+ foreach (var item in observation.Values)
+ {
+ sMsg += $" | {item.Key}: {item.Value}";
+ }
+ }
+ doLog(sMsg);
+ }
+
+ #endregion Private Methods
+ }
+}
\ No newline at end of file
diff --git a/IOB-WIN-MTC-CLI/NLog.config b/IOB-WIN-MTC-CLI/NLog.config
new file mode 100644
index 00000000..cd1bcc98
--- /dev/null
+++ b/IOB-WIN-MTC-CLI/NLog.config
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/IOB-WIN-MTC-CLI/Program.cs b/IOB-WIN-MTC-CLI/Program.cs
new file mode 100644
index 00000000..5be9fcc8
--- /dev/null
+++ b/IOB-WIN-MTC-CLI/Program.cs
@@ -0,0 +1,28 @@
+// See https://aka.ms/new-console-template for more information
+using IOB_WIN_MTC_CLI;
+using MTConnect;
+using MTConnect.Clients;
+using Spectre.Console;
+
+
+IobComm iobComm = new IobComm();
+
+iobComm.DoConfig();
+
+#if false
+
+// inizio con probe preliminare
+iobComm.ForceProbe();
+// attesa
+await Task.Delay(2000);
+
+#endif
+
+// avvio client
+iobComm.StartClient();
+
+// avvio loop
+iobComm.MainLoop();
+
+// chiudo
+iobComm.doLog("...closing CLI Now!");
\ No newline at end of file
diff --git a/IOB-WIN-MTC-CLI/Properties/launchSettings.json b/IOB-WIN-MTC-CLI/Properties/launchSettings.json
new file mode 100644
index 00000000..fbb8eef9
--- /dev/null
+++ b/IOB-WIN-MTC-CLI/Properties/launchSettings.json
@@ -0,0 +1,20 @@
+{
+ "profiles": {
+ "WSL": {
+ "commandName": "WSL2",
+ "distributionName": ""
+ },
+ "RemoteDebug": {
+ "commandName": "Project",
+ "remoteDebugEnabled": true,
+ "remoteDebugMachine": "10.51.90.9:4026",
+ "authenticationMode": "Windows"
+ },
+ "Local": {
+ "commandName": "Project",
+ "remoteDebugEnabled": false,
+ "remoteDebugMachine": "10.51.90.9:4026",
+ "authenticationMode": "Windows"
+ }
+ }
+}
\ No newline at end of file
diff --git a/IOB-WIN-MTC-CLI/postBuildTgt.bat b/IOB-WIN-MTC-CLI/postBuildTgt.bat
new file mode 100644
index 00000000..4a25373d
--- /dev/null
+++ b/IOB-WIN-MTC-CLI/postBuildTgt.bat
@@ -0,0 +1,39 @@
+@echo off
+echo Effettua pulizia post build: configurazione %1. directory %2
+
+if %1 == "Release" goto Release
+if %1 == "Debug" goto Debug
+if %1 == "Remote_DEBUG" goto RemoteDebug
+
+:Release
+REM INIZIO eliminando i files pdb
+del /S %2"*.pdb""
+del /S %2"*.xml""
+del /S %2"lib/*.pdb""
+echo Release: eliminato pdb + xml!!!
+goto END
+
+:Debug
+echo Debug: nulla da eliminare
+
+REM copia script verso server remoto
+REM ROBOCOPY . \\10.150.0.1\Steamware\IOB-WIN-NEXT-DEB /MIR
+
+goto END
+
+
+:RemoteDebug
+REM copia script verso server remoto
+REM echo Debug remoto: effettuo robocopy sync (verificare remote per cliente)
+
+REM IOB-WIN-SIM
+REM ROBOCOPY . \\IOB-WIN-SIMULA\Steamware\IOB-WIN-NEXT-DEB /MIR
+
+REM IOBVPN4MACHINE
+REM ROBOCOPY . \\10.51.90.5\Steamware\TestCli /MIR
+ROBOCOPY bin\Remote_DEBUG\net8.0 \\10.51.90.9\Steamware\TestCli\IOB-WIN-MTC-CLI /MIR
+
+goto END
+
+:END
+echo Fatto!
\ No newline at end of file
diff --git a/IOB-WIN-MTC.sln b/IOB-WIN-MTC.sln
index 15815fd9..573643d4 100644
--- a/IOB-WIN-MTC.sln
+++ b/IOB-WIN-MTC.sln
@@ -14,6 +14,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IOB-UT-NEXT", "IOB-UT-NEXT\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IOB-WIN-MTC", "IOB-WIN-MTC\IOB-WIN-MTC.csproj", "{7A396F36-0C79-470B-B909-356451DFE8C5}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IOB-WIN-MTC-CLI", "IOB-WIN-MTC-CLI\IOB-WIN-MTC-CLI.csproj", "{6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -48,8 +50,8 @@ Global
{90512E12-29FC-460D-94CC-648C2A072DBD}.Remote_DEBUG|Any CPU.Build.0 = Debug|Any CPU
{90512E12-29FC-460D-94CC-648C2A072DBD}.Remote_DEBUG|x86.ActiveCfg = Remote_DEBUG|x86
{90512E12-29FC-460D-94CC-648C2A072DBD}.Remote_DEBUG|x86.Build.0 = Remote_DEBUG|x86
- {7A396F36-0C79-470B-B909-356451DFE8C5}.Debug|Any CPU.ActiveCfg = Remote_DEBUG|Any CPU
- {7A396F36-0C79-470B-B909-356451DFE8C5}.Debug|Any CPU.Build.0 = Remote_DEBUG|Any CPU
+ {7A396F36-0C79-470B-B909-356451DFE8C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7A396F36-0C79-470B-B909-356451DFE8C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A396F36-0C79-470B-B909-356451DFE8C5}.Debug|x86.ActiveCfg = Debug|Any CPU
{7A396F36-0C79-470B-B909-356451DFE8C5}.Debug|x86.Build.0 = Debug|Any CPU
{7A396F36-0C79-470B-B909-356451DFE8C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -60,6 +62,18 @@ Global
{7A396F36-0C79-470B-B909-356451DFE8C5}.Remote_DEBUG|Any CPU.Build.0 = Remote_DEBUG|Any CPU
{7A396F36-0C79-470B-B909-356451DFE8C5}.Remote_DEBUG|x86.ActiveCfg = Release|Any CPU
{7A396F36-0C79-470B-B909-356451DFE8C5}.Remote_DEBUG|x86.Build.0 = Release|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Debug|x86.Build.0 = Debug|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Release|x86.ActiveCfg = Release|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Release|x86.Build.0 = Release|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Remote_DEBUG|Any CPU.ActiveCfg = Remote_DEBUG|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Remote_DEBUG|Any CPU.Build.0 = Remote_DEBUG|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Remote_DEBUG|x86.ActiveCfg = Release|Any CPU
+ {6326D2C7-061F-4EC5-B8FF-5B072EFCFF52}.Remote_DEBUG|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/IOB-WIN-NEXT/App.config b/IOB-WIN-NEXT/App.config
index 1e27ee77..268bca55 100644
--- a/IOB-WIN-NEXT/App.config
+++ b/IOB-WIN-NEXT/App.config
@@ -10,7 +10,7 @@
-
+
diff --git a/IOB-WIN-NEXT/IobOpc/OpcUaSiemens.cs b/IOB-WIN-NEXT/IobOpc/OpcUaSiemens.cs
index 14140cb0..e7b8be68 100644
--- a/IOB-WIN-NEXT/IobOpc/OpcUaSiemens.cs
+++ b/IOB-WIN-NEXT/IobOpc/OpcUaSiemens.cs
@@ -77,6 +77,7 @@ namespace IOB_WIN_NEXT.IobOpc
forceDbSync = true;
break;
+ case taskType.endProd:
case taskType.startSetup:
forceDbSync = true;
// se richiesto reset aggiungo!
@@ -84,6 +85,7 @@ namespace IOB_WIN_NEXT.IobOpc
{
addResetPzCount = true;
}
+ lgInfo($"Chiamato {tName} | addResetPzCount: {addResetPzCount}");
break;
}
}
@@ -97,12 +99,9 @@ namespace IOB_WIN_NEXT.IobOpc
}
}
// se NON c'è già sync DB
- if (!task2exe.ContainsKey("forceResetPzCount"))
+ if (addResetPzCount && !task2exe.ContainsKey("forceResetPzCount"))
{
- if (addResetPzCount)
- {
- task2exe.Add("forceResetPzCount", "0");
- }
+ task2exe.Add("forceResetPzCount", "0");
}
}
diff --git a/IOB-WIN-NEXT/IobRest/Citizen.cs b/IOB-WIN-NEXT/IobRest/Citizen.cs
index 9f3b1977..7c6115f3 100644
--- a/IOB-WIN-NEXT/IobRest/Citizen.cs
+++ b/IOB-WIN-NEXT/IobRest/Citizen.cs
@@ -39,7 +39,6 @@ namespace IOB_WIN_NEXT.IobRest
// sistemo conf errori e samplePeriod...
lgInfo("Rest - 02");
- // fixme todo levare forzatura test iniziale...
if (EnableTest)
{
PrelimCitizenRestTest();
@@ -520,6 +519,7 @@ namespace IOB_WIN_NEXT.IobRest
// se il valore è zero --> proseguo con yellow!
if (signVal == 0)
{
+ Task.Delay(samplePeriod / 4);
string yLamp = ExecuteCallGet(GetUrlResource("GetLampYellow"));
ladderResp = JsonConvert.DeserializeObject(yLamp);
if (string.IsNullOrEmpty(ladderResp.ErrorMessage))
@@ -532,6 +532,7 @@ namespace IOB_WIN_NEXT.IobRest
// se il valore è zero --> proseguo con red!
if (signVal == 0)
{
+ Task.Delay(samplePeriod / 4);
string rLamp = ExecuteCallGet(GetUrlResource("GetLampRed"));
ladderResp = JsonConvert.DeserializeObject(rLamp);
if (string.IsNullOrEmpty(ladderResp.ErrorMessage))
diff --git a/TestRemoteCLI/MTConnect/Program.cs b/TestRemoteCLI/MTConnect/Program.cs
index e9c8b22f..f4695172 100644
--- a/TestRemoteCLI/MTConnect/Program.cs
+++ b/TestRemoteCLI/MTConnect/Program.cs
@@ -16,12 +16,6 @@ namespace MTConnect
{
internal class Program
{
- #region Protected Fields
-
- protected static string sep = "------------------------";
-
- #endregion Protected Fields
-
#region Private Fields
private static MTConnectHttpClient client;
@@ -30,7 +24,7 @@ namespace MTConnect
private static string currentDirectory = Directory.GetCurrentDirectory();
private static string filePath = Path.Combine(currentDirectory, "file.log");
-
+ private static string sep = "------------------------";
private static Stopwatch sw = new Stopwatch();
#endregion Private Fields
diff --git a/TestRemoteCLI/MTConnect/postBuildTgt.bat b/TestRemoteCLI/MTConnect/postBuildTgt.bat
index 8466581a..0dfbac99 100644
--- a/TestRemoteCLI/MTConnect/postBuildTgt.bat
+++ b/TestRemoteCLI/MTConnect/postBuildTgt.bat
@@ -62,7 +62,7 @@ REM ROBOCOPY . \\IOB-WIN-SIMULA\Steamware\IOB-WIN-NEXT-DEB /MIR
REM IOBVPN4MACHINE
REM ROBOCOPY . \\10.51.90.5\Steamware\TestCli /MIR
-ROBOCOPY . \\10.51.90.9\Steamware\TestCli /MIR
+ROBOCOPY . \\10.51.90.9\Steamware\TestCli\CLI /MIR
goto END