Merge branch 'release/IobManMultiClient_01'

This commit is contained in:
Samuele Locatelli
2024-12-16 18:47:19 +01:00
25 changed files with 1234 additions and 167 deletions
+1
View File
@@ -24,6 +24,7 @@
<add key="BaseArg" value="MODE=MAN IOB=" />
<!--<add key="BaseArg" value="" />-->
<!--<add key="ArgsList" value="SIMUL_00,SIMUL_00" />-->
<add key="TargetConfFile" value="/CONF/target.json" />
<add key="ArgsConfFile" value="/CONF/process.json" />
<!--Gestione riavvio periodico: ora e min di avvio, periodo ripetizione in minuti -->
<add key="fullRestartHour" value="0" />
+29
View File
@@ -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"
}
}
}
+1
View File
@@ -0,0 +1 @@
[ "SIMUL_01", "SIMUL_02", "SIMUL_03", "SIMUL_04" ]
+5 -1
View File
@@ -1 +1,5 @@
[ "SIMUL_01", "SIMUL_02", "SIMUL_03", "SIMUL_04" ]
{
"SIMUL_00": "PING-TEST",
"SIMUL_01": "IOB-WIN-NEXT",
"SIMUL_02": "IOB-WIN-MTC"
}
+20
View File
@@ -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"
}
}
+11 -1
View File
@@ -197,6 +197,7 @@
<Link>VersGen.cs</Link>
</Compile>
<Compile Include="Enum.cs" />
<Compile Include="TargetConfig.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="iobAdapt.cs" />
<Compile Include="IOBManPanel.cs">
@@ -243,8 +244,17 @@
<None Include="CONF\.placeholder">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="CONF\process-legacy.json" />
<None Include="CONF\iob-man-config.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="CONF\target.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="CONF\license.json" />
<None Include="CONF\process.json" />
<None Include="CONF\process.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="logs\.placeholder">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+1
View File
@@ -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
+328 -144
View File
@@ -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
/// <summary>
/// Elenco ARGS (uno per child da avviare)
/// </summary>
public List<string> ArgsList = new List<string>();
#endregion Public Fields
#region Public Constructors
/// <summary>
@@ -54,21 +47,6 @@ namespace IOB_MAN
#endregion Public Constructors
#region Public Methods
/// <summary>
/// Cerca nell'elenco il processo corrente
/// </summary>
/// <param name="processlist"></param>
/// <param name="id"></param>
/// <returns></returns>
public static Process myGetProcByID(Process[] processlist, int id)
{
return processlist.FirstOrDefault(pr => pr.Id == id);
}
#endregion Public Methods
#region Protected Fields
/// <summary>
@@ -136,26 +114,6 @@ namespace IOB_MAN
/// </summary>
protected int numProcRunning;
/// <summary>
/// Path dell'exe da chiamare
/// </summary>
protected string TargetExe = "";
/// <summary>
/// Directory log generale x IOB-WIN (dentro ci sono x singoli IOB)
/// </summary>
protected string TargetLogDir = "";
/// <summary>
/// Name dell'exe da chiamare
/// </summary>
protected string TargetName = "";
/// <summary>
/// File target x conf NLog
/// </summary>
protected string TargetNLogConf = "";
/// <summary>
/// Dataora prossima scadenza riavvio automatico
/// </summary>
@@ -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;
/// <summary>
@@ -204,11 +164,31 @@ namespace IOB_MAN
/// </summary>
private SemaphoreSlim _sync = new SemaphoreSlim(1);
/// <summary>
/// Dizionario ARGS (uno per child da avviare, nome IOB + tipo target EXE)
/// </summary>
private Dictionary<string, string> ArgsList = new Dictionary<string, string>();
/// <summary>
/// Binding source degli elementi gestiti..
/// </summary>
private BindingSource ElencoIOB = new BindingSource();
/// <summary>
/// CodIOB selezionato con right click
/// </summary>
private string selCodIob = "";
/// <summary>
/// Path di base data la row corrente selezionata con right click
/// </summary>
private string selIobTgtPath = "";
/// <summary>
/// Dizionario applicazioni target da lanciare
/// </summary>
private Dictionary<string, TargetConfig> TargetList = new Dictionary<string, TargetConfig>();
#endregion Private Fields
#region Private Methods
@@ -221,14 +201,17 @@ namespace IOB_MAN
/// </summary>
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<Process> 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<iobAdapt> allItems = (IList<iobAdapt>)ElencoIOB.List;
bool needRem = false;
List<Process> processList = new List<Process>();
// 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
/// <param name="doReset">resetta elenco</param>
private void closeAllChild(bool doReset)
{
List<iobAdapt> listKilled = new List<iobAdapt>();
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<string> 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<Process> processList = new List<Process>();
// 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();
}
/// <summary>
/// DoubleClick su DGV
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgvManagedItems_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
// seleziono riga...
@@ -826,6 +877,11 @@ namespace IOB_MAN
}
}
/// <summary>
/// Formattazione celle
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgvManagedItems_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (this.dgvManagedItems.Columns[e.ColumnIndex].Name == "iobOnline")
@@ -894,6 +950,40 @@ namespace IOB_MAN
}
}
/// <summary>
/// Click celle DGV (right)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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();
}
/// <summary>
/// Caricamento aprametri x lancio client apps
/// </summary>
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<Dictionary<string, TargetConfig>>(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<List<string>>(jsonData);
// se modalità legacy --> deserializzo come lista e aggiungo info...
if (jsonData.StartsWith("["))
{
var rawList = JsonConvert.DeserializeObject<List<string>>(jsonData);
//ArgsList = rawList.ToDictionary();
foreach (var item in rawList)
{
ArgsList.Add(item, TargetName);
}
}
// altrimenti provo a deserializzare come dizionario...
else
{
ArgsList = JsonConvert.DeserializeObject<Dictionary<string, string>>(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
/// </summary>
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);
}
}
/// <summary>
/// Avvio di un child process da parametro ARG
/// </summary>
/// <param name="procArg"></param>
/// <param name="indice"></param>
private void startChildProc(string procArg, int indice = -1)
/// <param name="tgtName">Nome Target EXE</param>
/// <param name="codIob">Args da passare all'exe (IOB name da caricare)</param>
/// <param name="indice">posizione (opzionale) in lista</param>
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)
+6 -1
View File
@@ -44,6 +44,11 @@ namespace IOB_MAN
/// </summary>
public string IobType { get; set; } = "";
/// <summary>
/// Nome dell'exe
/// </summary>
public string ExeName { get; set; } = "";
/// <summary>
/// DataOra ultima comunicazione IN (con PLC)
/// </summary>
@@ -119,7 +124,7 @@ namespace IOB_MAN
}
/// <summary>
/// init classe gestione dati IOB su Redis
/// Init classe gestione dati IOB su Redis
/// </summary>
/// <param name="codServer"></param>
/// <param name="codIob"></param>
+1 -1
View File
@@ -1,5 +1,5 @@
<body>
<h3>MAPO-IOB-WIN</h3>
<h3>MAPO-IOB-MAN</h3>
<b>v: {{CURRENT-REL}}</b>
<br />
<i>Acquisitore MAPO-IOB per sistemi Windows</i>
+2 -2
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.0.0.0</version>
<url>http://seriate.steamware.net:8083/SWS/MAPO/IOB-WIN/{{BRANCHNAME}}/MAPO-IOB-WIN.zip</url>
<changelog>http://seriate.steamware.net:8083/SWS/MAPO/IOB-WIN/{{BRANCHNAME}}/ChangeLog.html</changelog>
<url>http://seriate.steamware.net:8083/SWS/MAPO/IOB-MAN/{{BRANCHNAME}}/MAPO-IOB-WIN.zip</url>
<changelog>http://seriate.steamware.net:8083/SWS/MAPO/IOB-MAN/{{BRANCHNAME}}/ChangeLog.html</changelog>
<mandatory>false</mandatory>
</item>
+28
View File
@@ -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
{
/// <summary>
/// Nome eseguibile ( x kill e ricerca)
/// </summary>
public string ExeName { get; set; } = "";
/// <summary>
/// Path completo eseguibile
/// </summary>
public string ExePath { get; set; } = "";
/// <summary>
/// Folder dove sono presenti i log generati dall'eseguibile
/// </summary>
public string LogDir { get; set; } = "";
/// <summary>
/// Path file di conf NLog da gestire
/// </summary>
public string NLogPath { get; set; } = "";
}
}
+12
View File
@@ -67,6 +67,12 @@ namespace IOB_MAN
[DisplayName("IOB")]
public string CodIOB { get; set; }
/// <summary>
/// Nome del target obj avviato
/// </summary>
[DisplayName("Prog")]
public string TgtName { get; set; }
/// <summary>
/// Tipo macchina/CNC/PLC
/// </summary>
@@ -202,6 +208,12 @@ namespace IOB_MAN
}
}
/// <summary>
/// Nome dell'EXE avviato
/// </summary>
[DisplayName("Exe")]
public string ExeName { get; set; }
#endregion Public Properties
}
}
+37
View File
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>IOB_WIN_MTC_CLI</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
<Configurations>Debug;Release;Remote_DEBUG</Configurations>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MTConnect.NET" Version="6.5.1" />
<PackageReference Include="NLog" Version="5.3.4" />
<PackageReference Include="Spectre.Console" Version="0.49.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IOB-UT-NEXT\IOB-UT-NEXT.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="logs\.placeholder.log">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="&quot;$(ProjectDir)postBuildTgt.bat&quot; &quot;$(ConfigurationName)&quot; &quot;$(TargetDir)&quot;" />
</Target>
</Project>
+601
View File
@@ -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
/// <summary>
/// Init classe
/// </summary>
public IobComm()
{
}
/// <summary>
/// Init Classe
/// </summary>
/// <param name="opcAddr"></param>
public IobComm(string opcAddr)
{
baseUrl = opcAddr;
}
/// <summary>
/// Init Classe
/// </summary>
/// <param name="opcAddr"></param>
/// <param name="titolo"></param>
/// <param name="sottotitolo"></param>
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<string>();
dispData = new Dictionary<string, double>();
// primo display
msgData.Add("Starting CLI setup...");
DoDisplayAsync();
}
/// <summary>
/// Esecuzione log secondo conf
/// </summary>
/// <param name="msg"></param>
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}");
}
}
/// <summary>
/// Esecuzione probe call indipendente
/// </summary>
public void ForceProbe()
{
// init
sw.Restart();
msgData = new List<string>();
dispData = new Dictionary<string, double>();
// 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<string>();
dispData = new Dictionary<string, double>();
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<string>();
dispData = new Dictionary<string, double>();
ForceProbe();
}
else if (answ.Key == ConsoleKey.R)
{
msgData = new List<string>();
dispData = new Dictionary<string, double>();
client.Stop();
Task.Delay(500);
dtStart = DateTime.Now;
StartClient();
msgData.Add($"Client restarted!");
}
else if (answ.Key == ConsoleKey.S)
{
msgData = new List<string>();
dispData = new Dictionary<string, double>();
client.Stop();
msgData.Add($"Client stopped!");
}
}
doLog("...closing Now!");
}
private DateTime displayVeto = DateTime.Now;
/// <summary>
/// Avvio del thread principale
/// </summary>
public void StartClient()
{
// init
sw.Restart();
msgData = new List<string>();
dispData = new Dictionary<string, double>();
// 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
/// <summary>
/// Main display function
/// </summary>
/// <param name="msgList"></param>
/// <param name="graphData"></param>
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<string> commandList = new List<string>() {
"R = Restart Service | S = Stop Service | P = force probe",
"C = toggle console log | F = toggle file log | Press ESC to exit"
};
/// <summary>
/// Dizionario variabili conteggio collezionate
/// </summary>
private Dictionary<string, int> DataCounters = new Dictionary<string, int>();
private Dictionary<string, double> dispData = new Dictionary<string, double>();
private bool inRefresh = false;
private List<string> msgData = new List<string>();
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<string>();
msgData.Add($"Client Started!");
msgData.Add(sep);
DoDisplayAsync();
}
private void Client_ClientStopped(object sender, EventArgs e)
{
msgData = new List<string>();
msgData.Add($"Client Stopped!");
msgData.Add(sep);
DoDisplayAsync();
}
private void Client_ConnectionError(object sender, Exception exc)
{
msgData = new List<string>();
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<string>();
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<string>();
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<string>();
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<string>();
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<string>();
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
}
}
+39
View File
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<variable name="logDir" value="${basedir}/logs"/>
<targets>
<target xsi:type="File"
name="f_base"
fileName="${logDir}/${var:codIOB:default=0000}/${shortdate}.log"
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true} | ${message}"
archiveFileName="${logDir}/${var:codIOB:default=0000}/${shortdate}.{###}.log"
archiveNumbering="Sequence"
archiveAboveSize="10240000"
maxArchiveFiles="90"
enableArchiveFileCompression="false"
keepFileOpen="false"
/>
<target xsi:type="File"
name="f_error"
fileName="${logDir}/${var:codIOB:default=0000}/${shortdate}_err.log"
layout="${longdate} [${uppercase:${level}}] ${logger:shortName=true} | ${message}${newline}${exception:format=tostring}"
archiveFileName="${logDir}/${var:codIOB:default=0000}/${shortdate}_err.{###}.log"
archiveNumbering="Sequence"
archiveAboveSize="10240000"
maxArchiveFiles="90"
enableArchiveFileCompression="false"
keepFileOpen="false"
/>
</targets>
<rules>
<!-- Logging Levels (Trace, Debug, Info, Warn, Error, Fatal)-->
<logger name="*" minlevel="Trace" maxlevel="Warn" final="true" writeTo="f_base" />
<logger name="*" minlevel="Error" writeTo="f_error" />
</rules>
</nlog>
+28
View File
@@ -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!");
@@ -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"
}
}
}
+39
View File
@@ -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!
+16 -2
View File
@@ -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
+1 -1
View File
@@ -10,7 +10,7 @@
<appSettings>
<add key="appName" value="IOB-WIN-NEXT" />
<!--<add key="appVers" value="develop" />-->
<add key="enableTest" value="true" />
<add key="enableTest" value="false" />
<add key="enableContapezzi" value="true" />
<add key="enableMode" value="true" />
<add key="enableOverrides" value="false" />
+4 -5
View File
@@ -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");
}
}
+2 -1
View File
@@ -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<LadderIO>(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<LadderIO>(rLamp);
if (string.IsNullOrEmpty(ladderResp.ErrorMessage))
+1 -7
View File
@@ -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
+1 -1
View File
@@ -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