1384 lines
39 KiB
C#
1384 lines
39 KiB
C#
using IOB_UT;
|
|
using NLog;
|
|
using NLog.Config;
|
|
using NLog.Targets;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
|
|
namespace IOB_WIN
|
|
{
|
|
public partial class AdapterForm : Form
|
|
{
|
|
#region inizializzazione contatori
|
|
|
|
/// <summary>
|
|
/// contatore veloce
|
|
/// </summary>
|
|
protected int fastCount;
|
|
/// <summary>
|
|
/// contatore normale
|
|
/// </summary>
|
|
protected int normCount;
|
|
/// <summary>
|
|
/// contatore lento
|
|
/// </summary>
|
|
protected int slowCount;
|
|
/// <summary>
|
|
/// contatore sync allarmi
|
|
/// </summary>
|
|
protected int verySlowCount;
|
|
/// <summary>
|
|
/// Contatore campionamento memoria
|
|
/// </summary>
|
|
protected int sampleMemCount;
|
|
/// <summary>
|
|
/// ultimo tentativo riavvio...
|
|
/// </summary>
|
|
protected DateTime lastStartTry;
|
|
/// <summary>
|
|
/// Data-Ora prima apertura FORM...
|
|
/// </summary>
|
|
protected DateTime firstStart;
|
|
|
|
#endregion
|
|
|
|
#region inizializzazione oggetti base
|
|
|
|
/// <summary>
|
|
/// oggetto logging
|
|
/// </summary>
|
|
public static Logger lg;
|
|
/// <summary>
|
|
/// Oggetto x gestione dell'adapter GENERICO (x poter usare metodi di ognuno...)
|
|
/// </summary>
|
|
public IobGeneric iobObj;
|
|
/// <summary>
|
|
/// configurazione caricata
|
|
/// </summary>
|
|
public IobConfiguration IOBConf;
|
|
/// <summary>
|
|
/// tipo di adapter prescelto...
|
|
/// </summary>
|
|
public tipoAdapter tipoScelto = tipoAdapter.SIMULA;
|
|
/// <summary>
|
|
/// Vendor macchina
|
|
/// </summary>
|
|
public string curVendor = "";
|
|
/// <summary>
|
|
/// Modello macchina
|
|
/// </summary>
|
|
public string curModel = "";
|
|
/// <summary>
|
|
/// Codice IOB della macchina cui connettersi (x scegliere corretto file di conf...)
|
|
/// </summary>
|
|
protected string CurrIOB { get; set; }
|
|
/// <summary>
|
|
/// Temnpo attesa std in MS
|
|
/// </summary>
|
|
protected int waitRecMSec = 30000;
|
|
|
|
#endregion
|
|
|
|
#region utils ed helpers
|
|
|
|
/// <summary>
|
|
/// Effettua un trim della stringa al numero max di linee da mostrare a video
|
|
/// </summary>
|
|
/// <param name="newString"></param>
|
|
/// <returns></returns>
|
|
public string limitLine2show(string newString)
|
|
{
|
|
// se num righe superiore a limite trimmo...
|
|
if (newString.Split('\n').Length > nLine2show)
|
|
{
|
|
//int idx = newString.LastIndexOf('\r');
|
|
int idx = newString.LastIndexOf(Environment.NewLine);
|
|
newString = newString.Substring(0, idx);
|
|
}
|
|
return newString;
|
|
}
|
|
/// <summary>
|
|
/// Logwatcher (in modalità "accodamento in testa" ultimi messaggi...)
|
|
/// </summary>
|
|
public string logWatcher
|
|
{
|
|
get
|
|
{
|
|
return lblLogfile.Text;
|
|
}
|
|
set
|
|
{
|
|
lblLogfile.Text = limitLine2show($"{value}{Environment.NewLine}{lblLogfile.Text}");
|
|
lblLogfile.Refresh();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Task watcher (in modalità "accodamento in testa" ultimi messaggi...)
|
|
/// </summary>
|
|
public string taskWatcher
|
|
{
|
|
get
|
|
{
|
|
return lblTaskLog.Text;
|
|
}
|
|
set
|
|
{
|
|
lblTaskLog.Text = limitLine2show($"{value}{Environment.NewLine}{lblTaskLog.Text}");
|
|
lblTaskLog.Refresh();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Effettua logging INFO corretto impostanto anche la variabile IOB prima di scrivere...
|
|
/// </summary>
|
|
/// <param name="txt2log"></param>
|
|
protected void lgInfo(string txt2log)
|
|
{
|
|
lg.Factory.Configuration.Variables["codIOB"] = this.CurrIOB;
|
|
lg.Info(txt2log);
|
|
// salvo anche in logwatcher...
|
|
newDisplayData currDispData = new newDisplayData();
|
|
currDispData.newLiveLogData = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} | INFO | {txt2log}";
|
|
updateFormDisplay(currDispData);
|
|
}
|
|
/// <summary>
|
|
/// Effettua logging ERROR corretto impostanto anche la variabile IOB prima di scrivere...
|
|
/// </summary>
|
|
/// <param name="txt2log"></param>
|
|
protected void lgError(string txt2log)
|
|
{
|
|
lg.Factory.Configuration.Variables["codIOB"] = this.CurrIOB;
|
|
lg.Error(txt2log);
|
|
// salvo anche in logwatcher...
|
|
newDisplayData currDispData = new newDisplayData();
|
|
currDispData.newLiveLogData = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} | ERROR | {txt2log}";
|
|
updateFormDisplay(currDispData);
|
|
}
|
|
|
|
|
|
private class Item
|
|
{
|
|
public string Name;
|
|
public int Value;
|
|
public Item(string name, int value)
|
|
{
|
|
Name = name; Value = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// mostra un testo sulla status bar + LOG
|
|
/// </summary>
|
|
/// <param name="txt2show"></param>
|
|
public void displayTaskAndLog(string txt2show)
|
|
{
|
|
lblStatus.Text = txt2show;
|
|
lblStatus.Invalidate();
|
|
lgInfo(txt2show);
|
|
}
|
|
/// <summary>
|
|
/// Mostra update delle statistiche di comunicazione (numero chiamate, tempo medio...)
|
|
/// </summary>
|
|
/// <param name="txt2show"></param>
|
|
public void updateComStats(string txt2show)
|
|
{
|
|
lblComStats.Text = string.Format("{0} | ", txt2show);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region gestione form e visibilità
|
|
|
|
|
|
/// <summary>
|
|
/// File configurazione default
|
|
/// </summary>
|
|
public string defConfFilePath
|
|
{
|
|
get
|
|
{
|
|
return string.Format(@"{0}\{1}.ini", utils.confDir, CurrIOB);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Avvio MainForm
|
|
/// </summary>
|
|
/// <param name="codIOB"></param>
|
|
public AdapterForm(string codIOB)
|
|
{
|
|
CurrIOB = codIOB;
|
|
// continuo avvio...
|
|
InitializeComponent();
|
|
lblStatus.Text = "Loading";
|
|
|
|
checkEditMes2Plc();
|
|
|
|
// inizializzo orologi
|
|
firstStart = DateTime.Now;
|
|
lastStartTry = DateTime.Now;
|
|
|
|
waitRecMSec = utils.CRI("waitRecMSec");
|
|
|
|
#if DEBUG
|
|
// Setup the logging view for Sentinel - http://sentinel.codeplex.com
|
|
var sentinelTarget = new NLogViewerTarget()
|
|
{
|
|
Name = "sentinel",
|
|
Address = "udp://127.0.0.1:9999",
|
|
IncludeNLogData = false
|
|
};
|
|
var sentinelRule = new LoggingRule("*", LogLevel.Trace, sentinelTarget);
|
|
LogManager.Configuration.AddTarget("sentinel", sentinelTarget);
|
|
LogManager.Configuration.LoggingRules.Add(sentinelRule);
|
|
|
|
#endif
|
|
|
|
LogManager.ReconfigExistingLoggers();
|
|
|
|
lg = LogManager.GetCurrentClassLogger();
|
|
displayTaskAndLog("MainForm Starting");
|
|
|
|
// se abilitato autoload conf leggo file corretto...
|
|
if (utils.CRB("autoLoadConf"))
|
|
{
|
|
try
|
|
{
|
|
loadIniFile(defConfFilePath);
|
|
lgInfo("INI LOADED");
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
displayTaskAndLog(string.Format("Eccezione in autoLoadConf: {0}", exc));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// definisco e avvio tipo adapter generico
|
|
tipoScelto = tipoAdapter.ND;
|
|
curVendor = "ACME";
|
|
curModel = "NONE";
|
|
IOBConf = new IobConfiguration();
|
|
loadIobType();
|
|
displayTaskAndLog("Waiting for config file selection");
|
|
}
|
|
|
|
// Start timer periodico comunicazione
|
|
gather.Interval = utils.CRI("timerIntMs");
|
|
gather.Enabled = true;
|
|
displayTaskAndLog(string.Format("Main timer set: {0}ms", gather.Interval));
|
|
// Start timer periodico interfaccia
|
|
displTimer.Interval = utils.CRI("timerIntMs");
|
|
displTimer.Enabled = true;
|
|
|
|
displayTaskAndLog("Program Running");
|
|
|
|
try
|
|
{
|
|
// verifico server online...
|
|
if (iobObj.checkServerAlive)
|
|
{
|
|
// segnalo reboot (programma)...
|
|
iobObj.callUrl(iobObj.urlReboot, true);
|
|
}
|
|
else
|
|
{
|
|
displayTaskAndLog("AdapterForm: Server OFFLINE");
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
lgError(string.Format("AdapterForm: EXCEPTION in fase di chiamata URL di reboot:{0}{1}{2}", iobObj.urlReboot, Environment.NewLine, exc));
|
|
}
|
|
displayTaskAndLog("Main Form OK");
|
|
}
|
|
/// <summary>
|
|
/// Fase chiusura Form
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
closeAdapter();
|
|
}
|
|
/// <summary>
|
|
/// Mostrata form
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void MainForm_Shown(object sender, EventArgs e)
|
|
{
|
|
displayTaskAndLog("Main Form SHOWN");
|
|
}
|
|
/// <summary>
|
|
/// Completato resize form
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void MainForm_Resize(object sender, EventArgs e)
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region gestione metodi specifici FORM
|
|
|
|
private void checkSendTask()
|
|
{
|
|
// avvio fase invio con adapter (code MST)
|
|
iobObj.getAndSend(gatherCycle.VHF);
|
|
}
|
|
private void checkFastTask()
|
|
{
|
|
// decremento...
|
|
fastCount--;
|
|
// se il counter è a zero eseguo...
|
|
if (fastCount <= 0)
|
|
{
|
|
fastCount = utils.CRI("fastCount");
|
|
|
|
// avvio fase raccolta dati e invio con adapter
|
|
iobObj.getAndSend(gatherCycle.HF);
|
|
}
|
|
}
|
|
private void checkNormTask()
|
|
{
|
|
// decremento...
|
|
normCount--;
|
|
// se il counter è a zero eseguo...
|
|
if (normCount <= 0)
|
|
{
|
|
normCount = utils.CRI("normCount");
|
|
|
|
// avvio fase raccolta dati e invio con adapter
|
|
iobObj.getAndSend(gatherCycle.MF);
|
|
}
|
|
}
|
|
private void checkSlowTask()
|
|
{
|
|
slowCount--;
|
|
if (slowCount <= 0)
|
|
{
|
|
slowCount = utils.CRI("slowCount");
|
|
|
|
// avvio fase raccolta dati e invio con adapter
|
|
iobObj.getAndSend(gatherCycle.LF);
|
|
}
|
|
}
|
|
|
|
private void checkVerySlowData()
|
|
{
|
|
verySlowCount--;
|
|
if (verySlowCount <= 0)
|
|
{
|
|
verySlowCount = utils.CRI("verySlowCount");
|
|
// avvio fase raccolta dati e invio con adapter
|
|
iobObj.getAndSend(gatherCycle.VLF);
|
|
}
|
|
}
|
|
|
|
private void checkSampleMem()
|
|
{
|
|
// decremento contatore...
|
|
sampleMemCount--;
|
|
if (sampleMemCount <= 0)
|
|
{
|
|
sampleMemCount = utils.CRI("sampleMemCount");
|
|
// avvio fase raccolta dati e invio con adapter
|
|
iobObj.saveMemDump(dumpType.SAMPLE);
|
|
}
|
|
}
|
|
private void refreshFormData()
|
|
{
|
|
// aggiorno visualizzazioni varie in form...
|
|
evQueueLen = iobObj.QueueIN.Count;
|
|
flQueueLen = iobObj.QueueFLog.Count;
|
|
}
|
|
private void gather_Tick(object sender, EventArgs e)
|
|
{
|
|
bool doLog = false;
|
|
if (iobObj != null)
|
|
{
|
|
if (iobObj.periodicLog)
|
|
{
|
|
doLog = true;
|
|
}
|
|
try
|
|
{
|
|
refreshFormData();
|
|
// check esecuzione SendTask (VHF) COMUNQUE...
|
|
checkSendTask();
|
|
// eseguo cicli attivi SOLO se adapter è in EFFETTIVO running...
|
|
if (iobObj.adpRunning)
|
|
{
|
|
if (iobObj.connectionOk)
|
|
{
|
|
// se richiesto faccio memory DUMP INIZIALE!
|
|
if (iobObj.doStartMemDump)
|
|
{
|
|
lgInfo("Inizio dump memoria");
|
|
iobObj.saveMemDump(dumpType.STARTUP);
|
|
// fatto! non ripeto...
|
|
iobObj.doStartMemDump = false;
|
|
lgInfo("Finito dump memoria");
|
|
}
|
|
// controllo se sia abilitato sampleDump della meoria (periodico)
|
|
if (iobObj.doSampleMemory)
|
|
{
|
|
checkSampleMem();
|
|
}
|
|
// check esecuzione FastTask
|
|
checkFastTask();
|
|
// check esecuzione NormTask
|
|
checkNormTask();
|
|
// check esecuzione SlowTask
|
|
checkSlowTask();
|
|
// check esecuzione AlarmSync
|
|
checkVerySlowData();
|
|
if (utils.CRI("waitEndCycle") > 0)
|
|
{
|
|
Thread.Sleep(utils.CRI("waitEndCycle"));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec);
|
|
if (iobObj.adpTryRestart && (DateTime.Now > dtVeto))
|
|
{
|
|
if (doLog)
|
|
{
|
|
lgInfo(string.Format("Retry Time Elapsed ({0} ms)--> tryConnect", waitRecMSec));
|
|
}
|
|
lastStartTry = DateTime.Now;
|
|
iobObj.tryConnect();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (doLog)
|
|
{
|
|
lgInfo("Adapter stopped");
|
|
}
|
|
// verifico SE debba tentare il riavvio, ovvero NON running ma adpTryRestart e non ho riprovato x oltre waitRecMSec
|
|
DateTime dtVeto = lastStartTry.AddMilliseconds(waitRecMSec);
|
|
if (iobObj.adpTryRestart && (DateTime.Now > dtVeto))
|
|
{
|
|
lastStartTry = DateTime.Now;
|
|
avviaAdapter(chkForceDequeue.Checked);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
lgError(string.Format("Eccezione in fase di gatherTick: {0}{1}", Environment.NewLine, exc));
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Chiusura adapter
|
|
/// </summary>
|
|
private void closeAdapter()
|
|
{
|
|
fermaTutto(true, false, true);
|
|
}
|
|
/// <summary>
|
|
/// Ferma tutti i componenti adapter + update buttons
|
|
/// </summary>
|
|
/// <param name="stopTimer">indica se fermare il timer (gather) principale (solo se non si chiude)</param>
|
|
/// <param name="tryRestart">indica se tentare di riconnettersi</param>
|
|
/// <param name="forceDequeue">indica se sia richeisto di SVUOTARE le code delel info</param>
|
|
private void fermaTutto(bool stopTimer, bool tryRestart, bool forceDequeue)
|
|
{
|
|
iobObj.stopAdapter(tryRestart, forceDequeue);
|
|
// salvo!
|
|
savePersistLayer(utils.defPersLayerFile);
|
|
savePersistLayer(utils.histPersLayerFile);
|
|
|
|
stop.Enabled = false;
|
|
start.Enabled = true;
|
|
restart.Enabled = false;
|
|
|
|
if (stopTimer)
|
|
{
|
|
gather.Enabled = false;
|
|
iobObj.tryDisconnect();
|
|
}
|
|
|
|
newDisplayData currDispData = new newDisplayData();
|
|
currDispData.semIn = Semaforo.SS;
|
|
currDispData.semOut = Semaforo.SS;
|
|
updateFormDisplay(currDispData);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Carica file ini della configurazione richiesta
|
|
/// </summary>
|
|
/// <param name="iniConfFile"></param>
|
|
private void loadIniFile(string iniConfFile)
|
|
{
|
|
// out di cosa faccio...
|
|
displayTaskAndLog(string.Format("Loading iniConfFile: {0}", iniConfFile));
|
|
// leggo file
|
|
IniFile fIni = new IniFile(iniConfFile);
|
|
|
|
// leggo vendor e modello...
|
|
curVendor = fIni.ReadString("MACHINE", "VENDOR", "ACME");
|
|
curModel = fIni.ReadString("MACHINE", "MODEL", "NONE");
|
|
// verifico tipo adapter
|
|
try
|
|
{
|
|
tipoScelto = (tipoAdapter)Enum.Parse(typeof(tipoAdapter), fIni.ReadString("IOB", "CNCTYPE", "DEMO"));
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
lgError($"Eccezione in conversione tipo adapter: richiesto un tipo non codificato...{Environment.NewLine}{exc}");
|
|
tipoScelto = tipoAdapter.ND;
|
|
}
|
|
// carivo vettore parametri opzionai
|
|
Dictionary<string, string> optParRead = new Dictionary<string, string>();
|
|
string[] optParRows = fIni.ReadSection("OPTPAR");
|
|
if (optParRows.Length > 0)
|
|
{
|
|
try
|
|
{
|
|
string[] kvp;
|
|
foreach (var item in optParRows)
|
|
{
|
|
kvp = item.Split('=');
|
|
optParRead.Add(kvp[0], kvp[1]);
|
|
}
|
|
lgInfo($"Caricati {optParRead.Count} parametri opzionali da OPTPAR");
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
lgError(string.Format("EXCEPTION in fase di lettura OPTPAR: {0}{1}", Environment.NewLine, exc));
|
|
}
|
|
}
|
|
// inizializzio conf IOB
|
|
IOBConf = new IobConfiguration
|
|
{
|
|
pingMsTimeout = fIni.ReadInteger("IOB", "PING_MS_TIMEOUT", 500),
|
|
vendor = curVendor,
|
|
model = curModel,
|
|
tipoIob = tipoScelto,
|
|
optPar = optParRead,
|
|
versIOB = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(),
|
|
codIOB = CurrIOB, // fIni.ReadString("IOB", "IDXMACC", "0"),
|
|
cncIpAddr = fIni.ReadString("CNC", "IP", "::1"),
|
|
cncPort = fIni.ReadString("CNC", "PORT", "0"),
|
|
iniFileName = iniConfFile,
|
|
cpuType = fIni.ReadString("CNC", "CPUTYPE", ""),
|
|
rack = (short)fIni.ReadInteger("CNC", "RACK", 0),
|
|
slot = (short)fIni.ReadInteger("CNC", "SLOT", 0),
|
|
serverData = new serverMapo(fIni.ReadString("SERVER", "MPIP", "::1"), fIni.ReadString("SERVER", "MPURL", "/"), fIni.ReadString("SERVER", "CMDBASE", "/"), fIni.ReadString("SERVER", "CMDFLOG", "/"), fIni.ReadString("SERVER", "CMDALIVE", "/"), fIni.ReadString("SERVER", "CMDENABLED", "/"), fIni.ReadString("SERVER", "CMDREBO", "/"), fIni.ReadString("SERVER", "CMD_ODL_STARTED", "/IOB/getCurrOdlStart/")),
|
|
MAX_COUNTER_BLINK = Convert.ToInt32(fIni.ReadString("BLINK", "MAX_COUNTER_BLINK", "1")),
|
|
BLINK_FILT = Convert.ToInt32(fIni.ReadString("BLINK", "BLINK_FILT", "0"))
|
|
};
|
|
lgInfo($"Creato IOBConf!");
|
|
|
|
loadIobType();
|
|
// avvio macchina con adapter specificato...
|
|
if (utils.CRB("autoStartOnLoad"))
|
|
{
|
|
displayTaskAndLog("Auto Starting...");
|
|
// avvio!
|
|
avviaAdapter(chkForceDequeue.Checked);
|
|
displayTaskAndLog("Auto Started!");
|
|
}
|
|
try
|
|
{
|
|
// segnalo reboot (programma)... metto in coda invio...
|
|
//iobObj.sendToMoonPro(urlType.FLog, "IOB INI Loaded");
|
|
//iobObj.QueueFLog.Enqueue(iobObj.qEncodeFLog("IOB-STATUS", "IOB INI Loaded"));
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
lgError(string.Format("EXCEPTION in fase di chiamata URL di segnalazione caricamento INI file:{0}{1}", Environment.NewLine, exc));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Salva su file l'oggetto di persistenza dati
|
|
/// </summary>
|
|
/// <param name="filePath"></param>
|
|
public void savePersistLayer(string filePath)
|
|
{
|
|
// in primis check semaforo salvataggio...
|
|
if (!iobObj.adpSaving)
|
|
{
|
|
// alzo semaforo salvataggio
|
|
iobObj.adpSaving = true;
|
|
// se HO dei dati...
|
|
if (iobObj.persistenceLayer != null)
|
|
{
|
|
try
|
|
{
|
|
utils.WritePlain(iobObj.persistenceLayer, filePath);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
lgError(string.Format("Errore salvataggio file{0}{1}", Environment.NewLine, exc));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lgInfo("persistenceLayer null, non salvato...");
|
|
}
|
|
// abbasso semaforo salvataggio
|
|
iobObj.adpSaving = false;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region Area BackGroundWorker
|
|
|
|
|
|
/// <summary>
|
|
/// Effettua update form una volta ricevuto OBJ che contiene le varie innovazioni...
|
|
/// </summary>
|
|
/// <param name="newData"></param>
|
|
public void updateFormDisplay(newDisplayData newData)
|
|
{
|
|
// ciclo x ogni oggetto x caricare le innovazioni...
|
|
if (newData != null)
|
|
{
|
|
// RealTime display
|
|
if (!string.IsNullOrWhiteSpace(newData.newInData))
|
|
{
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(newData.newSignalData))
|
|
{
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(newData.newFLogData))
|
|
{
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(newData.newUrlCallData))
|
|
{
|
|
}
|
|
|
|
// Bitmap lettura attuale
|
|
if (newData.counter >= 0)
|
|
{
|
|
lblCounter.Text = newData.counter.ToString();
|
|
}
|
|
// Bitmap lettura attuale
|
|
if (!string.IsNullOrWhiteSpace(newData.currBitmap))
|
|
{
|
|
lblBitmap.Text = newData.currBitmap;
|
|
lblBitmap.Refresh();
|
|
}
|
|
// LiveLog
|
|
if (!string.IsNullOrWhiteSpace(newData.newLiveLogData))
|
|
{
|
|
logWatcher = newData.newLiveLogData;
|
|
}
|
|
// semafori
|
|
if (newData.semOut != Semaforo.ND)
|
|
{
|
|
//aggiorno comunque!
|
|
sOUT = newData.semOut;
|
|
}
|
|
if (newData.semIn != Semaforo.ND)
|
|
{
|
|
//aggiorno comunque!
|
|
sIN = newData.semIn;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Worker x azioni VERSO IL SERVER MES su thread separato
|
|
/// </summary>
|
|
private BackgroundWorker bgWorkerMES;
|
|
|
|
// Set up the BackgroundWorker object by
|
|
// attaching event handlers.
|
|
private void InitializeBgWorkerMes()
|
|
{
|
|
bgWorkerMES.DoWork += BgWorkerMES_DoWork;
|
|
bgWorkerMES.RunWorkerCompleted += BgWorkerMES_RunWorkerCompleted;
|
|
bgWorkerMES.ProgressChanged += BgWorkerMES_ProgressChanged;
|
|
}
|
|
|
|
private void BgWorkerMES_ProgressChanged(object sender, ProgressChangedEventArgs e)
|
|
{
|
|
//throw new NotImplementedException();
|
|
}
|
|
|
|
private void BgWorkerMES_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
|
{
|
|
//throw new NotImplementedException();
|
|
}
|
|
|
|
private void BgWorkerMES_DoWork(object sender, DoWorkEventArgs e)
|
|
{
|
|
//throw new NotImplementedException();
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing && (components != null))
|
|
{
|
|
components.Dispose();
|
|
// chiudo ANCHE background worker
|
|
if (bgWorkerMES != null)
|
|
{
|
|
bgWorkerMES.Dispose();
|
|
}
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
#if false
|
|
|
|
//handler for DoWork Event
|
|
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
|
|
{
|
|
//your background process task
|
|
//.
|
|
//.
|
|
//.
|
|
//calculate progress percentage
|
|
int progPercentage = 10;
|
|
//notify the progress. backGroundWorker_ProgressChanged() will be called
|
|
backgroundWorker.ReportProgress(progPercentage);
|
|
}
|
|
//Handler for Button Click Event
|
|
private void btnDoSomeAsyncTask_Click(object sender, EventArgs e)
|
|
{
|
|
if (backgroundWorker == null)
|
|
{
|
|
//initialize backgroundworker
|
|
backgroundWorker = new BackgroundWorker();
|
|
}
|
|
else
|
|
{
|
|
bool start = true;
|
|
//check whether operation is already in progress
|
|
if (backgroundWorker.IsBusy)
|
|
{
|
|
if (MessageBox.Show("The requested task already in progress. Abort current process continue with the fresh task?",
|
|
"Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
|
|
{
|
|
start = false;
|
|
}
|
|
else //cancel the current operation
|
|
{
|
|
//for this operation WorkerSupportsCancellation shoulb
|
|
backgroundWorker.CancelAsync();
|
|
}
|
|
}
|
|
if (start)
|
|
{
|
|
#if false
|
|
//Call the hooked method backGroundWorker_DoWork() containing object sent in DoWorkEventArgs
|
|
backgroundWorker.RunWorkerAsync(objectToBeUsedInAsyncOperation);
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
//Handler for progress Changed Event
|
|
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
|
|
{
|
|
//update the UI here
|
|
((MainForm)this.Parent).advProgBar();
|
|
#if false
|
|
progressBar.Value = e.ProgressPercentage;
|
|
#endif
|
|
}
|
|
//Handler For RunWorkerCompleted event
|
|
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
|
{
|
|
//Task to be performed after completion of background task.Like Give some message.
|
|
MessageBox.Show("Task Completed");
|
|
}
|
|
#endif
|
|
|
|
#endregion
|
|
|
|
|
|
private void mLoadConf_Click(object sender, EventArgs e)
|
|
{
|
|
// mostro selettore file x leggere adapter..
|
|
OpenFileDialog openFileDial = new OpenFileDialog();
|
|
|
|
// directory iniziale
|
|
openFileDial.InitialDirectory = utils.confDir; // string.Format(@"{0}\{1}", Application.StartupPath, utils.CRS("dataConfPath"));
|
|
// Set filter options and filter index.
|
|
openFileDial.Filter = "INI Files (.ini)|*.ini|All Files (*.*)|*.*";
|
|
openFileDial.FilterIndex = 1;
|
|
// altre opzioni
|
|
openFileDial.Multiselect = false;
|
|
|
|
// Call the ShowDialog method to show the dialog box.
|
|
DialogResult userClickedOK = openFileDial.ShowDialog();
|
|
|
|
// Process input if the user clicked OK.
|
|
if (userClickedOK == DialogResult.OK)
|
|
{
|
|
string iniConfFile = openFileDial.FileName;
|
|
loadIniFile(iniConfFile);
|
|
lgInfo("INI LOADED");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// carica IOB richiesto
|
|
/// </summary>
|
|
private void loadIobType()
|
|
{
|
|
switch (tipoScelto)
|
|
{
|
|
case tipoAdapter.SIMULA:
|
|
iobObj = new IobSimula(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.FANUC:
|
|
iobObj = new IobFanuc(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.KAWASAKI:
|
|
iobObj = new IobKawasaki(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.OMRON:
|
|
iobObj = new IobOmron(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.OSAI_OPEN:
|
|
case tipoAdapter.OSAI_CNDEX:
|
|
case tipoAdapter.OSAI_VB6:
|
|
// versione CVCncLib
|
|
iobObj = new IobOSAI(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.SIEMENS:
|
|
iobObj = new IobSiemens(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.SIEMENS_APROCHIM:
|
|
iobObj = new IobSiemensAprochim(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.SIEMENS_AT2001:
|
|
iobObj = new IobSiemensAt2001(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.SIEMENS_COMUR:
|
|
iobObj = new IobSiemensComur(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.SIEMENS_FAPE:
|
|
iobObj = new IobSiemensFape(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.SIEMENS_INGENIA:
|
|
iobObj = new IobSiemensIngenia(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.SIEMENS_LASCO:
|
|
iobObj = new IobSiemensLasco(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.SIEMENS_PRESSOIL_CEI:
|
|
iobObj = new IobSiemensPressoilCei(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.SIEMENS_SAET:
|
|
iobObj = new IobSiemensSaet(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.SIEMENS_TORRI:
|
|
iobObj = new IobSiemensTorri(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.WPS:
|
|
iobObj = new IobWPS(this, IOBConf);
|
|
start.Enabled = true;
|
|
break;
|
|
case tipoAdapter.ND:
|
|
default:
|
|
iobObj = new IobSimula(this, IOBConf);
|
|
start.Enabled = false;
|
|
break;
|
|
}
|
|
lblCNC.Text = string.Format("CNC: {0} [{1}:{2}]", IOBConf.tipoIob, IOBConf.cncIpAddr, IOBConf.cncPort);
|
|
lblSrvUrl.Text = string.Format("SRV: {0} | URL: {1}{2}", IOBConf.serverData.MPIP, IOBConf.serverData.MPURL, IOBConf.serverData.CMDBASE);
|
|
|
|
// carico i default values su interfaccia
|
|
setDefaults();
|
|
|
|
displayTaskAndLog(string.Format("Caricata conf per adapter {0}", tipoScelto));
|
|
}
|
|
|
|
/// <summary>
|
|
/// impostazione valori defaults
|
|
/// </summary>
|
|
private void setDefaults()
|
|
{
|
|
stop.Enabled = false;
|
|
|
|
evQueueLen = 0;
|
|
flQueueLen = 0;
|
|
nLine2show = utils.CRI("numRowConsole");
|
|
}
|
|
/// <summary>
|
|
/// Visualizzazione stato di comunicazione attiva con PLC
|
|
/// </summary>
|
|
public bool commPlcActive
|
|
{
|
|
set
|
|
{
|
|
// se true --> comunica/verde, altrimenti grigio
|
|
lblCNC.ForeColor = value ? Color.SeaGreen : Color.Black;
|
|
statusStrip1.Refresh();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Visualizzazione stato di comunicazione attiva con PLC:
|
|
/// 0 = NO PING
|
|
/// 1 = PING OK
|
|
/// 2 = IOB enabled
|
|
/// </summary>
|
|
public int commSrvActive
|
|
{
|
|
set
|
|
{
|
|
switch (value)
|
|
{
|
|
case 0:
|
|
lblSrvUrl.ForeColor = Color.Red;
|
|
break;
|
|
case 1:
|
|
lblSrvUrl.ForeColor = Color.OrangeRed;
|
|
break;
|
|
case 2:
|
|
lblSrvUrl.ForeColor = Color.SeaGreen;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
statusStrip1.Refresh();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Avvio dell'adapter
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void start_Click(object sender, EventArgs e)
|
|
{
|
|
avviaAdapter(chkForceDequeue.Checked);
|
|
// salvo che ho avviato adapter
|
|
lgInfo("Completato LOAD Adapter");
|
|
}
|
|
/// <summary>
|
|
/// Avvio l'adapter
|
|
/// </summary>
|
|
/// <param name="resetQueue">indica se sia richeisto di SVUOTARE le code delel info</param>
|
|
public void avviaAdapter(bool resetQueue)
|
|
{
|
|
displayTaskAndLog("Adapter starting");
|
|
// se NON sta girando...
|
|
if (!iobObj.adpRunning)
|
|
{
|
|
iobObj.startAdapter(resetQueue);
|
|
displayTaskAndLog("Adapter started!");
|
|
|
|
// fix buttons start/stop/dump
|
|
start.Enabled = false;
|
|
stop.Enabled = true;
|
|
restart.Enabled = true;
|
|
|
|
displayTaskAndLog("Start Timers");
|
|
// inizializzo contatori fast/mid/slow
|
|
fastCount = utils.CRI("fastCount");
|
|
normCount = utils.CRI("normCount");
|
|
slowCount = utils.CRI("slowCount");
|
|
verySlowCount = utils.CRI("verySlowCount");
|
|
displayTaskAndLog("Adapter Running...");
|
|
// init max queue
|
|
maxEvQueue = 1;
|
|
maxFlQueue = 1;
|
|
// forzo check allarmi..
|
|
iobObj.forceAlarmCheck();
|
|
|
|
try
|
|
{
|
|
// segnalo reboot (programma)...
|
|
//iobObj.sendToMoonPro(urlType.FLog, "IOB Started");
|
|
//iobObj.QueueFLog.Enqueue(iobObj.qEncodeFLog("IOB-STATUS", "IOB Started"));
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
lgError(string.Format("EXCEPTION in fase di chiamata URL di segnalazione AVVIO IOB:{0}{1}", Environment.NewLine, exc));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
displayTaskAndLog("Adapter STILL Running...");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Button restart
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void restart_Click(object sender, EventArgs e)
|
|
{
|
|
string message = "Attenzione: con l'operazione di reset veranno persi (e non inviati) i dati eventualmente accumulati (indipendentemente dalla selezione del checkbox 'svuota coda').";
|
|
string caption = "Conferma Reset Dati IOB";
|
|
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
|
|
DialogResult result;
|
|
|
|
// verifica con messagebox
|
|
result = MessageBox.Show(message, caption, buttons);
|
|
// solo se ho conferma da utente
|
|
if (result == DialogResult.Yes)
|
|
{
|
|
// faccio stop... SENZA inviare
|
|
fermaAdapter(false, false);
|
|
displayTaskAndLog("RESTARTING: Adapter Stopped");
|
|
// rileggo INI
|
|
loadIniFile(defConfFilePath);
|
|
displayTaskAndLog("RESTARTING: Ini File Reloaded");
|
|
// faccio start... CON RESET delel code
|
|
avviaAdapter(true);
|
|
displayTaskAndLog("RESTARTING: Adapter Started");
|
|
// resetto i data monitor...
|
|
dataMonitor_0 = "";
|
|
dataMonitor_1 = "";
|
|
dataMonitor_2 = "";
|
|
dataMonitor_3 = "";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// fermata dell'adapter
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void stop_Click(object sender, EventArgs e)
|
|
{
|
|
fermaAdapter(false, chkForceDequeue.Checked);
|
|
// salvo che ho fermato adapter
|
|
lgInfo("UNLOAD Adapter");
|
|
}
|
|
/// <summary>
|
|
/// Ferma l'adapter
|
|
/// </summary>
|
|
/// <param name="tryRestart">determina se si debba tentare riavvio automatico (per caduta connessione)</param>
|
|
/// <param name="forceDequeue">indica se sia richeisto di SVUOTARE le code delel info</param>
|
|
public void fermaAdapter(bool tryRestart, bool forceDequeue)
|
|
{
|
|
fermaTutto(false, tryRestart, forceDequeue);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Stringa dati monitoraggio mostrata (1 SX)...
|
|
/// </summary>
|
|
public string dataMonitor_0
|
|
{
|
|
get
|
|
{
|
|
return lblRawData.Text;
|
|
}
|
|
set
|
|
{
|
|
lblRawData.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Stringa dati monitoraggio mostrata (1 SX)...
|
|
/// </summary>
|
|
public string dataMonitor_1
|
|
{
|
|
get
|
|
{
|
|
return lblOutMessage.Text;
|
|
}
|
|
set
|
|
{
|
|
lblOutMessage.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Stringa dati monitoraggio mostrata (2 centro)...
|
|
/// </summary>
|
|
public string dataMonitor_2
|
|
{
|
|
get
|
|
{
|
|
return lblOutMessage2.Text;
|
|
}
|
|
set
|
|
{
|
|
lblOutMessage2.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Stringa dati monitoraggio mostrata (3 dx)...
|
|
/// </summary>
|
|
public string dataMonitor_3
|
|
{
|
|
get
|
|
{
|
|
return lblOutMessage3.Text;
|
|
}
|
|
set
|
|
{
|
|
lblOutMessage3.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// label del numero di record processati (libera)
|
|
/// </summary>
|
|
public string dataProcLabel
|
|
{
|
|
get
|
|
{
|
|
return lblDataProc.Text;
|
|
}
|
|
set
|
|
{
|
|
lblDataProc.Text = value;
|
|
}
|
|
}
|
|
protected int maxEvQueue { get; set; }
|
|
protected int maxFlQueue { get; set; }
|
|
|
|
protected int qEvLen { get; set; }
|
|
protected int qFlLen { get; set; }
|
|
|
|
public int evQueueLen
|
|
{
|
|
set
|
|
{
|
|
qEvLen = value;
|
|
lblQueueLen.Text = qEvLen.ToString();
|
|
int totQueue = qEvLen + qFlLen;
|
|
lblQueueLenTop.Text = totQueue == 0 ? "realtime" : $"{totQueue} (waiting)";
|
|
// se supero max precedente, ed è > 10... loggo!
|
|
if (qEvLen > maxEvQueue && qEvLen > 10)
|
|
{
|
|
maxEvQueue = qEvLen;
|
|
lgInfo($"[WARN] Coda EV di {value} record");
|
|
}
|
|
else
|
|
{
|
|
maxEvQueue--;
|
|
maxEvQueue = maxEvQueue < qEvLen ? qEvLen : maxEvQueue;
|
|
}
|
|
}
|
|
get
|
|
{
|
|
return qEvLen;
|
|
}
|
|
}
|
|
public int flQueueLen
|
|
{
|
|
set
|
|
{
|
|
qFlLen = value;
|
|
lblQueueFLogLen.Text = qFlLen.ToString();
|
|
int totQueue = qEvLen + qFlLen;
|
|
lblQueueLenTop.Text = totQueue == 0 ? "realtime" : $"{totQueue} (waiting)";
|
|
// se supero max precedente, ed è > 10... loggo!
|
|
if (qFlLen > maxFlQueue && qFlLen > 10)
|
|
{
|
|
maxFlQueue = qFlLen;
|
|
lgInfo($"[WARN] Coda FLog di {value} record");
|
|
}
|
|
else
|
|
{
|
|
maxFlQueue--;
|
|
maxFlQueue = maxFlQueue < qFlLen ? qFlLen : maxFlQueue;
|
|
}
|
|
}
|
|
get
|
|
{
|
|
return qFlLen;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Numero max linee da mostrare (da controllo)...
|
|
/// </summary>
|
|
public int nLine2show
|
|
{
|
|
get
|
|
{
|
|
int answ = 5;
|
|
try
|
|
{
|
|
Int32.TryParse(nLines.Text, out answ);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
nLines.Text = value.ToString();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Imposta COLORE SFONDO x Semaforo IN
|
|
/// </summary>
|
|
public Semaforo sIN
|
|
{
|
|
set
|
|
{
|
|
bIN.BackColor = decSemaforo(value);
|
|
bIN.Refresh();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Imposta COLORE SFONDO x Semaforo OUT
|
|
/// </summary>
|
|
public Semaforo sOUT
|
|
{
|
|
set
|
|
{
|
|
bOUT.BackColor = decSemaforo(value);
|
|
bOUT.Refresh();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Decodifica colore da valore semaforico
|
|
/// </summary>
|
|
/// <param name="valore"></param>
|
|
/// <returns></returns>
|
|
public Color decSemaforo(Semaforo valore)
|
|
{
|
|
Color colore = Color.LightGray;
|
|
switch (valore)
|
|
{
|
|
case Semaforo.SV:
|
|
colore = Color.LightGreen;
|
|
break;
|
|
case Semaforo.SG:
|
|
colore = Color.LightGoldenrodYellow;
|
|
break;
|
|
case Semaforo.SR:
|
|
colore = Color.Red;
|
|
break;
|
|
case Semaforo.SS:
|
|
colore = Color.DarkGray;
|
|
break;
|
|
default:
|
|
colore = Color.LightGray;
|
|
break;
|
|
}
|
|
return colore;
|
|
}
|
|
|
|
private void displTimer_Tick(object sender, EventArgs e)
|
|
{
|
|
}
|
|
|
|
private void TabData_Selected(object sender, TabControlEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void fixComboParameters()
|
|
{
|
|
if (iobObj != null)
|
|
{
|
|
if (iobObj.memMap != null)
|
|
{
|
|
if (iobObj.memMap.mMapWrite != null)
|
|
{
|
|
if (iobObj.memMap.mMapWrite.Count > 0)
|
|
{
|
|
List<string> parametri = new List<string>();
|
|
foreach (var item in iobObj.memMap.mMapWrite)
|
|
{
|
|
parametri.Add(item.Key);
|
|
}
|
|
cmbParamValues.DataSource = parametri;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void checkEditMes2Plc()
|
|
{
|
|
cmbParamValues.Enabled = enableEditMes2Plc;
|
|
txtValue.Enabled = enableEditMes2Plc;
|
|
if (enableEditMes2Plc)
|
|
{
|
|
// aggiorno (se possibile) i parametri selezionabili...
|
|
fixComboParameters();
|
|
}
|
|
}
|
|
public bool enableEditMes2Plc { get; set; }
|
|
|
|
private void ChkEdit_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
toggleEditMes2Plc();
|
|
}
|
|
|
|
private void toggleEditMes2Plc()
|
|
{
|
|
// abilita i campi --> PLC per editing
|
|
enableEditMes2Plc = !enableEditMes2Plc;
|
|
checkEditMes2Plc();
|
|
}
|
|
|
|
private void BtnSendPLC_Click(object sender, EventArgs e)
|
|
{
|
|
// invia a MES il parametro selezionato (es ART / ODL / PRG NAME, come task2exe..)
|
|
Dictionary<string, string> forcedTask = new Dictionary<string, string>();
|
|
// guardo i parametri...
|
|
if (txtValue.Text != "")
|
|
{
|
|
forcedTask.Add(cmbParamValues.SelectedValue.ToString(), txtValue.Text);
|
|
}
|
|
#if false
|
|
// accodo SE !=""
|
|
if (currItemCode != "")
|
|
{
|
|
forcedTask.Add("setArt", currItemCode);
|
|
}
|
|
if (currOrdCode != "")
|
|
{
|
|
forcedTask.Add("setComm", currOrdCode);
|
|
}
|
|
if (currPrgName != "")
|
|
{
|
|
forcedTask.Add("setProg", currPrgName);
|
|
}
|
|
#endif
|
|
// chiedo esecuzione task!
|
|
iobObj.processTask(forcedTask);
|
|
toggleEditMes2Plc();
|
|
}
|
|
|
|
private void BtnOpenLog_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string logPath = $"{System.AppDomain.CurrentDomain.BaseDirectory}logs\\{CurrIOB}\\{DateTime.Today:yyyy-MM-dd}.log";
|
|
Process.Start(logPath);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
lgError($"Eccezione in show log (MAIN):{Environment.NewLine}{exc}");
|
|
}
|
|
}
|
|
|
|
private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
}
|