prima modifica: se non vanno letture stoppa adapter (ma salva richeista di provare a riconnettere, DA GESTIRE!!!)

This commit is contained in:
Samuele E. Locatelli
2016-12-07 14:54:06 +01:00
parent b6cffb88ae
commit ed5451b8e6
7 changed files with 123 additions and 88 deletions
@@ -1902,17 +1902,17 @@ Namespace CNC
Case Else : szErrorDesc = "- ERRORE PMC INESISTENTE -"
End Select
'Stampo il messaggio
If Config.Settings.Settings.Debug > 0 Then
'If nReturn <> Focas1.EW_SOCKET Then 'tranne su errore di connessione
'CMSCncLib.App.Runtime.Log.WW("ERR pmc_wrpmcrng on F_RW_DWord CNC.FANUC", "Return=" & nReturn, True)
MsgBox(szErrorDesc & vbLf & "Occurred in: " & Position, MsgBoxStyle.Exclamation + MsgBoxStyle.ApplicationModal, "Error on Fanuc CNC Data Window")
'End If
End If
''Stampo il messaggio
'If (Config.Settings.Settings.Debug > 0) Then
' 'If nReturn <> Focas1.EW_SOCKET Then 'tranne su errore di connessione
' 'CMSCncLib.App.Runtime.Log.WW("ERR pmc_wrpmcrng on F_RW_DWord CNC.FANUC", "Return=" & nReturn, True)
' MsgBox(szErrorDesc & vbLf & "Occurred in: " & Position, MsgBoxStyle.Exclamation + MsgBoxStyle.ApplicationModal, "Error on Fanuc CNC Data Window")
' 'End If
'End If
Return True 'presenza errore
End If
End If
Return False 'assenza errori
Return False 'assenza errori
End Function
+6
View File
@@ -53,6 +53,7 @@ namespace MTC_Adapter
base.tryDisconnect();
// disconnetto
ncDevice.Disconnect();
connectionOk = false;
}
public override void tryConnect()
@@ -67,6 +68,11 @@ namespace MTC_Adapter
{
//altrimenti disconnette...
ncDevice.Disconnect();
connectionOk = false;
}
else
{
connectionOk = true;
}
}
}
+3 -1
View File
@@ -117,6 +117,7 @@ namespace MTC_Adapter
try
{
FANUC_ref.Disconnect(ref szStatusConnection);
connectionOk = false;
lg.Info(szStatusConnection);
lg.Info("Effettuata disconnessione adapter FANUC!");
}
@@ -140,6 +141,7 @@ namespace MTC_Adapter
{
FANUC_ref.Connect(ref szStatusConnection);
lg.Info(szStatusConnection);
connectionOk = true;
// refresh stato allarmi!!!
if (connectionOk)
{
@@ -152,7 +154,7 @@ namespace MTC_Adapter
}
else
{
lg.Error("Impossibile effettuare refresh completo stato allarmi, connessione mancante...");
lg.Error("Impossibile procedere, connessione mancante...");
}
}
catch (Exception exc)
+83 -51
View File
@@ -556,6 +556,14 @@ namespace MTC_Adapter
/// </summary>
protected bool adpRunning;
/// <summary>
/// valore booleano (richiesta di riavvio automatico)
/// </summary>
protected bool adpTryRestart;
/// <summary>
/// porta x adapter (x restart)
/// </summary>
protected int adpPortNum;
/// <summary>
/// DataOra ultimo avvio adapter x watchdog
/// </summary>
protected DateTime adpStartRun;
@@ -1280,8 +1288,10 @@ namespace MTC_Adapter
loadSubMode();
loadOtherFile();
// Start the adapter lib with the port number in the text box
// salvo porta!
mAdapter.Port = port;
adpPortNum = port;
// avvio!
mAdapter.Start();
// setto status a ON
@@ -1394,6 +1404,7 @@ namespace MTC_Adapter
mAlarmCNC.Normal();
mAlarmPLC.Normal();
mAlarmGeneral.Normal();
adpTryRestart = true;
parentForm.displayTaskAndWait("Adapter Started!");
}
/// <summary>
@@ -1409,10 +1420,12 @@ namespace MTC_Adapter
/// <summary>
/// ferma l'adapter...
/// </summary>
public void stopAdapter()
/// <param name="tryRestart">indica se si debba tentare di riavviare l'adapter (con caduta connessione viene fermato in automatico)</param>
public void stopAdapter(bool tryRestart)
{
parentForm.displayTaskAndWait("Stopping adapter...");
mStatus.Value = "OFF";
adpTryRestart = false;
mStatus.Value = "INACTIVE";
// faccio una chiamata extra ad ogni metodo di check...
gaterAndSend(gatherCycle.HF);
gaterAndSend(gatherCycle.MF);
@@ -1432,7 +1445,11 @@ namespace MTC_Adapter
lg.Error(exc, "Eccezione in chiusura Adapter");
}
dtStopAdp = DateTime.Now;
parentForm.displayTaskAndWait("Adapter Stopped!");
adpPortNum = mAdapter.Port;
adpTryRestart = tryRestart;
// chiudo!
parentForm.resetProgBar();
parentForm.displayTaskAndWait("Adapter Stopped.");
}
/// <summary>
@@ -1464,54 +1481,64 @@ namespace MTC_Adapter
}
if (adpRunning)
{
// processing degli strobes di allarme (da ULTIMA rappresentazione vettore dell'ADP)
processAlarm();
// processo e svuoto eventuali code di invio per Codici M/S/T
trySendCodMST();
// ciclo HF: recupero update status & strobes vari
if (ciclo == gatherCycle.HF)
// try / catch generale altrimenti segno che è disconnesso...
try
{
// parte che eseguo SEMPRE: RECUPERO stato di tutti gli strobe/status e degli ack attualmente noti
getStrobeAndAckStatus();
// processing degli strobes di allarme (da ULTIMA rappresentazione vettore dell'ADP)
processAlarm();
// processo e svuoto eventuali code di invio per Codici M/S/T
trySendCodMST();
// faccio refresh degli allarmi segnalati (da strobe su vettore locale)
refreshAlarmState(STRB_DW0, true);
// acquisizione degli status
processStatus();
// processing degli strobes
processStrobe();
// ciclo HF: recupero update status & strobes vari
if (ciclo == gatherCycle.HF)
{
// parte che eseguo SEMPRE: RECUPERO stato di tutti gli strobe/status e degli ack attualmente noti
getStrobeAndAckStatus();
// faccio refresh degli allarmi segnalati (da strobe su vettore locale)
refreshAlarmState(STRB_DW0, true);
// acquisizione degli status
processStatus();
// processing degli strobes
processStrobe();
}
else if (ciclo == gatherCycle.MF)
{
// leggo parametri a media freq (dati globali, path, assi, Unità Operatrice)
getGlobalData();
getUnOp();
getPath();
getAxis();
}
// ciclo lento
else if (ciclo == gatherCycle.LF)
{
// leggo EVENTUALI parametri da config file
getConfigParam();
///acquisisco dati su programma in esecuzione e dati generali (stato, orologio, power...)
getSlowChangingData();
// eventuale log!
if (utils.CRB("recTime")) logTimeResults();
}
// ciclo lentissimo
else if (ciclo == gatherCycle.VLF)
{
lg.Info("Richiesta lettura completa allarmi attivi");
// faccio comunque rilettura completa allarmi...
forceAlarmCheck();
}
// INVIO dati variati!
mAdapter.SendChanged();
}
else if (ciclo == gatherCycle.MF)
catch (Exception exc)
{
// leggo parametri a media freq (dati globali, path, assi, Unità Operatrice)
getGlobalData();
getUnOp();
getPath();
getAxis();
// segnalo eccezione e indico disconnesso...
lg.Error(exc, "Errore in gestione ciclo principale ADP, fermo adapter");
parentForm.fermaAdapter(true);
}
// ciclo lento
else if (ciclo == gatherCycle.LF)
{
// leggo EVENTUALI parametri da config file
getConfigParam();
///acquisisco dati su programma in esecuzione e dati generali (stato, orologio, power...)
getSlowChangingData();
// eventuale log!
if (utils.CRB("recTime")) logTimeResults();
}
// ciclo lentissimo
else if (ciclo == gatherCycle.VLF)
{
lg.Info("Richiesta lettura completa allarmi attivi");
// faccio comunque rilettura completa allarmi...
forceAlarmCheck();
}
// INVIO dati variati!
mAdapter.SendChanged();
// tolgo flag running
adpRunning = false;
}
@@ -1537,8 +1564,8 @@ namespace MTC_Adapter
{
// log connessione KO
lg.Error("CicloMF - Connessione non disponibile, provo a riconnettere");
// provo a riconnettere...
tryConnect();
// provo a riconnettere SE abilitato tryRestart...
if(adpTryRestart) tryConnect();
}
if (eh_refreshed != null)
{
@@ -1615,15 +1642,20 @@ namespace MTC_Adapter
{
}
protected bool _connOk = false;
/// <summary>
/// Dummy method: verifica stato conensisone OK
/// Salva verifica stato connessione OK
/// </summary>
/// <returns></returns>
public virtual bool connectionOk
{
get
{
return true;
return _connOk;
}
set
{
_connOk = value;
}
}
+5 -5
View File
@@ -1051,9 +1051,9 @@
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.lblApp,
this.lblStatus,
this.lblVers,
this.MainProgrBar,
this.lblVers});
this.lblStatus});
this.statusStrip1.Location = new System.Drawing.Point(0, 716);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(785, 25);
@@ -1471,7 +1471,7 @@
this.tbConf.Location = new System.Drawing.Point(4, 22);
this.tbConf.Name = "tbConf";
this.tbConf.Padding = new System.Windows.Forms.Padding(3);
this.tbConf.Size = new System.Drawing.Size(777, 636);
this.tbConf.Size = new System.Drawing.Size(777, 640);
this.tbConf.TabIndex = 1;
this.tbConf.Text = "XML CONFIG";
//
@@ -1481,7 +1481,7 @@
this.wbXmlConf.Location = new System.Drawing.Point(3, 3);
this.wbXmlConf.MinimumSize = new System.Drawing.Size(20, 20);
this.wbXmlConf.Name = "wbXmlConf";
this.wbXmlConf.Size = new System.Drawing.Size(771, 630);
this.wbXmlConf.Size = new System.Drawing.Size(771, 634);
this.wbXmlConf.TabIndex = 0;
//
// tpSIM
@@ -1501,7 +1501,7 @@
this.tpSIM.Controls.Add(this.groupBox12);
this.tpSIM.Location = new System.Drawing.Point(4, 22);
this.tpSIM.Name = "tpSIM";
this.tpSIM.Size = new System.Drawing.Size(777, 636);
this.tpSIM.Size = new System.Drawing.Size(777, 640);
this.tpSIM.TabIndex = 2;
this.tpSIM.Text = "SIMULATION";
//
+17 -4
View File
@@ -438,7 +438,7 @@ namespace MTC_Adapter
avviaAdapter();
}
private void avviaAdapter()
public void avviaAdapter()
{
displayTaskAndWait("Adapter starting");
@@ -468,7 +468,7 @@ namespace MTC_Adapter
slowCount = utils.CRI("slowCount");
alarmSyncCount = utils.CRI("alarmSyncCount");
displayTaskAndWait("Timers Ready");
displayTaskAndWait("Adapter Running...");
}
/// <summary>
@@ -478,7 +478,15 @@ namespace MTC_Adapter
/// <param name="e"></param>
private void stop_Click(object sender, EventArgs e)
{
agObj.stopAdapter();
fermaAdapter(false);
}
/// <summary>
/// Ferma l'adapter
/// </summary>
/// <param name="tryRestart">determina se si debba tentare riavvio automatico (per caduta connessione)</param>
public void fermaAdapter(bool tryRestart)
{
agObj.stopAdapter(tryRestart);
// salvo!
savePersistLayer(defPersLayerFile);
savePersistLayer(histPersLayerFile);
@@ -516,6 +524,11 @@ namespace MTC_Adapter
}
}
public void resetProgBar()
{
MainProgrBar.Value = 0;
}
private void checkAlarmSync()
{
alarmSyncCount--;
@@ -1538,7 +1551,7 @@ namespace MTC_Adapter
private void closeAdapter()
{
agObj.stopAdapter();
agObj.stopAdapter(false);
// salvo!
savePersistLayer(defPersLayerFile);
savePersistLayer(histPersLayerFile);
-18
View File
@@ -138,24 +138,6 @@
<metadata name="K.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="X.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Y.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Z.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="I.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="J.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="K.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>104, 17</value>
</metadata>