prima bozza gestione allarmi SIEMENS
This commit is contained in:
@@ -1072,133 +1072,7 @@ Retry: nRetry += 1
|
||||
End Function
|
||||
|
||||
#If False Then
|
||||
|
||||
Public Function getPathGCode1Shot() As Focas1.ODBGCD
|
||||
' RIFERIMENTO:
|
||||
' C:\Users\samuele\Documents\FOCAS A02B-0207-K737_04.20\Document\SpecE\Misc\cnc_rdgcode.htm
|
||||
|
||||
Dim nPathIdx As Integer
|
||||
Dim nNumAxisRead As Integer
|
||||
Dim nReturn As Integer
|
||||
|
||||
Dim actGCode As Focas1.ODBGCD
|
||||
' inizializzo
|
||||
actGCode = New Focas1.ODBGCD
|
||||
|
||||
'leggo il numero del processo attivo
|
||||
nPathIdx = GetActivePath()
|
||||
'leggo num max assi dal cn
|
||||
nNumAxisRead = Focas1.MAX_AXIS
|
||||
|
||||
If Is30Series Then
|
||||
|
||||
' leggo tutto!!! 0-27 (28 elementi)
|
||||
nReturn = Focas1.cnc_rdgcode(nLibHandle(nPathIdx), -2, 1, 4, actGCode)
|
||||
|
||||
If F_CheckRetError_Cnc(nReturn, "cnc_rdgcode RefreshPathGCode CNC.FANUC.CMS_CncLib") Then
|
||||
Throw New CmsNcException("ERR cnc_rdgcode RefreshPathGCode CNC.FANUC.CMS_CncLib")
|
||||
End If
|
||||
End If
|
||||
|
||||
Return actGCode
|
||||
|
||||
End Function
|
||||
#End If
|
||||
|
||||
#If False Then
|
||||
|
||||
Public Function getAllAxisLoad() As Focas1.ODBSVLOAD
|
||||
' RIFERIMENTO:
|
||||
' C:\Users\samuele\Documents\FOCAS A02B-0207-K737_04.20\Document\SpecE\Position\cnc_rdsvmeter.htm
|
||||
|
||||
Dim nPathIdx As Integer
|
||||
Dim nNumAxisRead As Integer
|
||||
Dim nReturn As Integer
|
||||
|
||||
Dim caricoAssi As Focas1.ODBSVLOAD
|
||||
|
||||
'leggo il numero del processo attivo
|
||||
nPathIdx = GetActivePath()
|
||||
'leggo num max assi dal cn
|
||||
nNumAxisRead = Focas1.MAX_AXIS
|
||||
|
||||
If Is30Series Then
|
||||
|
||||
' leggo tutto!!!
|
||||
nReturn = Focas1.cnc_rdsvmeter(nLibHandle(nPathIdx), nNumAxisRead, caricoAssi)
|
||||
|
||||
If F_CheckRetError_Cnc(nReturn, "cnc_rdsvmeter RefreshAxisMeter CNC.FANUC.CMS_CncLib") Then
|
||||
Throw New CmsNcException("ERR cnc_rdsvmeter RefreshAxisMeter CNC.FANUC.CMS_CncLib")
|
||||
End If
|
||||
End If
|
||||
|
||||
Return caricoAssi
|
||||
|
||||
End Function
|
||||
|
||||
Public Function getGlobalFeedrate() As Focas1.ODBACT
|
||||
' RIFERIMENTO:
|
||||
' C:\Users\samuele\Documents\FOCAS A02B-0207-K737_04.20\Document\SpecE\Position\cnc_actf.htm
|
||||
|
||||
Dim nPathIdx As Integer
|
||||
Dim nNumAxisRead As Integer
|
||||
Dim nReturn As Integer
|
||||
|
||||
Dim feedData As Focas1.ODBACT
|
||||
' inizializzo
|
||||
feedData = New Focas1.ODBACT
|
||||
|
||||
'leggo il numero del processo attivo
|
||||
nPathIdx = GetActivePath()
|
||||
'leggo num max assi dal cn
|
||||
nNumAxisRead = Focas1.MAX_AXIS
|
||||
|
||||
If Is30Series Then
|
||||
|
||||
' leggo feed globale
|
||||
nReturn = Focas1.cnc_actf(nLibHandle(nPathIdx), feedData)
|
||||
|
||||
If F_CheckRetError_Cnc(nReturn, "cnc_actf RefreshActFeedRate CNC.FANUC.CMS_CncLib") Then
|
||||
Throw New CmsNcException("ERR cnc_actf RefreshActFeedRate CNC.FANUC.CMS_CncLib")
|
||||
End If
|
||||
End If
|
||||
|
||||
Return feedData
|
||||
|
||||
End Function
|
||||
|
||||
Public Function getSpindleLoad() As Focas1.ODBSPN
|
||||
' RIFERIMENTO:
|
||||
' C:\Users\samuele\Documents\FOCAS A02B-0207-K737_04.20\Document\SpecE\Position\cnc_rdspload.htm
|
||||
' RICHIEDE DRIVER ESTESO!!! NON VA!!!
|
||||
|
||||
Dim nPathIdx As Integer
|
||||
Dim nNumAxisRead As Integer
|
||||
Dim nReturn As Integer
|
||||
|
||||
Dim allData As Focas1.ODBSPN
|
||||
' inizializzo
|
||||
allData = New Focas1.ODBSPN
|
||||
|
||||
'leggo il numero del processo attivo
|
||||
nPathIdx = GetActivePath()
|
||||
'leggo num max assi dal cn
|
||||
nNumAxisRead = Focas1.MAX_AXIS
|
||||
|
||||
If Is30Series Then
|
||||
|
||||
' leggo feed globale
|
||||
nReturn = Focas1.cnc_rdspload(nLibHandle(nPathIdx), -1, allData)
|
||||
|
||||
If F_CheckRetError_Cnc(nReturn, "cnc_rdspload RefreshAllSpindleLoad CNC.FANUC.CMS_CncLib") Then
|
||||
Throw New CmsNcException("ERR cnc_rdspload RefreshAllSpindleLoad CNC.FANUC.CMS_CncLib")
|
||||
End If
|
||||
End If
|
||||
|
||||
Return allData
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
Public Function getCncAlarm() As Focas1.ODBALMMSG2
|
||||
' RIFERIMENTO:
|
||||
@@ -1269,34 +1143,7 @@ Retry: nRetry += 1
|
||||
|
||||
End Function
|
||||
|
||||
Public Function getSpindleSpeed() As Focas1.ODBSPEED
|
||||
' RIFERIMENTO:
|
||||
' C:\Users\samuele\Documents\FOCAS A02B-0207-K737_04.20\Document\SpecE\Position\cnc_rdspeed.htm
|
||||
|
||||
Dim nPathIdx As Integer
|
||||
Dim nNumAxisRead As Integer
|
||||
Dim nReturn As Integer
|
||||
|
||||
Dim speedAssi As Focas1.ODBSPEED
|
||||
|
||||
'leggo il numero del processo attivo
|
||||
nPathIdx = GetActivePath()
|
||||
'leggo num max assi dal cn
|
||||
nNumAxisRead = Focas1.MAX_AXIS
|
||||
|
||||
If Is30Series Then
|
||||
|
||||
' leggo tutto!!!
|
||||
nReturn = Focas1.cnc_rdspeed(nLibHandle(nPathIdx), -1, speedAssi)
|
||||
|
||||
If F_CheckRetError_Cnc(nReturn, "cnc_rdspeed RefreshAxisSpeed CNC.FANUC.CMS_CncLib") Then
|
||||
Throw New CmsNcException("ERR cnc_rdspeed RefreshAxisSpeed CNC.FANUC.CMS_CncLib")
|
||||
End If
|
||||
End If
|
||||
|
||||
Return speedAssi
|
||||
|
||||
End Function
|
||||
|
||||
#End If
|
||||
|
||||
#End Region
|
||||
|
||||
@@ -12,6 +12,9 @@ Namespace CNC
|
||||
|
||||
Private m_DataSvcRW As DataSvc
|
||||
Private m_DriveSVC As DrivesSvc
|
||||
Private m_AlarmService As AlarmSvc
|
||||
Private m_AlarmGuid As System.Guid
|
||||
Private currAlarms As Alarm()
|
||||
|
||||
Private itemRead() As Item
|
||||
Private itemWrite As Item
|
||||
@@ -60,6 +63,9 @@ Namespace CNC
|
||||
Try
|
||||
m_DataSvcRW = New DataSvc
|
||||
m_DriveSVC = New DrivesSvc
|
||||
m_AlarmService = New AlarmSvc("eng")
|
||||
' sottoscrivo allarmi...
|
||||
m_AlarmGuid = m_AlarmService.Subscribe(New AlarmListChanged(AddressOf AlarmList))
|
||||
|
||||
Catch ex As System.IO.FileNotFoundException
|
||||
' intercetta l'exception se non lanciato sopra l'hmi
|
||||
@@ -1076,6 +1082,8 @@ Namespace CNC
|
||||
ReDim itemRead(maxProc - 1)
|
||||
For i As Integer = 0 To maxProc - 1
|
||||
itemRead(i) = New Item("/Channel/SelectedFunctions/ncFktAct[u" & i + 1 & ",1,#" & maxGruppi & "]") ' leggo TUTTI i gruppi...
|
||||
' verificare sintassi...[u1,1,64] al posto di [u1,1,#64]
|
||||
'itemRead(i) = New Item("/Channel/SelectedFunctions/ncFktAct[u" & i + 1 & ",1," & maxGruppi & "]") ' leggo TUTTI i gruppi...
|
||||
Next i
|
||||
|
||||
'lettura
|
||||
@@ -1102,6 +1110,53 @@ Namespace CNC
|
||||
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' procedura per risposta alla segnalazione di allarmi...
|
||||
''' </summary>
|
||||
''' <param name="guid"></param>
|
||||
''' <param name="alarms"></param>
|
||||
Public Sub AlarmList(guid As Guid, alarms() As Alarm)
|
||||
' are we in GUI thread (main) ?
|
||||
' No we are Not in GUI thread => send message to GUI thread
|
||||
If (False) Then
|
||||
'If (lstAlarms.InvokeRequired) Then
|
||||
|
||||
' chiamo delegato
|
||||
'AlarmListChanged alarmDelegate = New AlarmListChanged(AlarmList);
|
||||
'BeginInvoke(alarmDelegate, New Object[] { guid, alarms });
|
||||
Else
|
||||
' sono in main thread --> eseguo!
|
||||
|
||||
' check if guid Is correct
|
||||
If (m_AlarmGuid.Equals(guid)) Then
|
||||
' salvo!
|
||||
currAlarms = alarms
|
||||
|
||||
'// clear the listbox
|
||||
'lstAlarms.Items.Clear();
|
||||
'setStatus("new alarms");
|
||||
'// go through the array for each alarm
|
||||
'foreach(Alarm element In alarms)
|
||||
'{
|
||||
'// write the timeStamp, alarmnumber And the alarmmessage to
|
||||
'// the listbox
|
||||
'lstAlarms.Items.Add(element.TimeStamp.ToString() + " | " +
|
||||
'element.Id.ToString() + " | " +
|
||||
'element.Message);
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Function getCncAlarm() As Alarm()
|
||||
' RIFERIMENTO:
|
||||
' SynumerikOperate_Net, pg 101 --> 110
|
||||
|
||||
'' restituisco vettore allarmi...
|
||||
Return currAlarms
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
|
||||
@@ -178,7 +178,6 @@ namespace MTC_Adapter
|
||||
/// <summary>
|
||||
/// Vettore degli allarmi CNC attivi
|
||||
/// </summary>
|
||||
//public CMSCncLib.OPENcontrol.MSGERROR allarmiCNC;
|
||||
public Dictionary<string, string> allarmiCNC = new Dictionary<string, string>();
|
||||
/// <summary>
|
||||
/// estende l'init della classe base...
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Siemens.Sinumerik.Operate.Services;
|
||||
|
||||
namespace MTC_Adapter
|
||||
{
|
||||
@@ -186,7 +187,7 @@ namespace MTC_Adapter
|
||||
/// <summary>
|
||||
/// Vettore degli allarmi CNC attivi
|
||||
/// </summary>
|
||||
public CMSCncLib.Focas1.ODBALMMSG2 allarmiCNC;
|
||||
public Alarm[] allarmiCNC;
|
||||
|
||||
/// <summary>
|
||||
/// estende l'init della classe base...
|
||||
@@ -614,47 +615,12 @@ namespace MTC_Adapter
|
||||
bool fatto = false;
|
||||
try
|
||||
{
|
||||
#if false
|
||||
// se ho allarmi li accodo...
|
||||
if (allNcData.lastncerror != 0)
|
||||
{
|
||||
|
||||
if (utils.CRI("loglevel") > 5)
|
||||
{
|
||||
lg.Info(string.Format("Allarmi CNC: {0} ", allNcData.lastncerror));
|
||||
}
|
||||
string alarmText = string.Format("CNC Alarm - Cod: {0}", allNcData.lastncerror);
|
||||
|
||||
// tolgo eventuali allarmi CNC...
|
||||
allarmiCNC.Clear();
|
||||
allarmiCNC.Add(allNcData.lastncerror.ToString(), alarmText);
|
||||
|
||||
//// 2017.05.09 gestione allarmi commentata
|
||||
//mAlarmCNC.Add(MTConnect.Condition.Level.FAULT, alarmText, allNcData.lastncerror.ToString(), "", "");
|
||||
//// mostro in form!
|
||||
//sb1.AppendLine(alarmText);
|
||||
//parentForm.dataMonitor_1 += sb1.ToString();
|
||||
|
||||
//// 2017.05.09 gestione allarmi commentata
|
||||
//// il codice è corretto (manca prima aprte codice + traduzione), se cerco di trovare oggett completo NON c'è, verificare con Andrea...
|
||||
//sb1.AppendLine(string.Format("Allarmi CNC: {0}", allNcData.lastncerror));
|
||||
|
||||
parentForm.commPlcActive = true;
|
||||
//inizio = DateTime.Now;
|
||||
//OSAI_ref.O_ReadCurrentErrorMsg(ref allarmiCNC);
|
||||
//if (utils.CRB("recTime")) TimingData.addResult("R-CNC-ERROR-MSG", DateTime.Now.Subtract(inizio).Ticks);
|
||||
//checkCNCAlarms();
|
||||
parentForm.commPlcActive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
allarmiCNC.Clear();
|
||||
allarmiCNC = new Dictionary<string, string>();
|
||||
// 2017.05.09 gestione allarmi commentata
|
||||
//allarmiCNC = new CMSCncLib.OPENcontrol.MSGERROR();
|
||||
}
|
||||
fatto = true;
|
||||
#endif
|
||||
parentForm.commPlcActive = true;
|
||||
inizio = DateTime.Now;
|
||||
allarmiCNC = SIEMENS_ref.getCncAlarm();
|
||||
if (utils.CRB("recTime")) TimingData.addResult("R-CNC-ERROR-MSG", DateTime.Now.Subtract(inizio).Ticks);
|
||||
parentForm.commPlcActive = false;
|
||||
fatto = true;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
@@ -765,36 +731,40 @@ namespace MTC_Adapter
|
||||
private void checkCNCAlarms()
|
||||
{
|
||||
// faccio parse allarmi: se ci sono invio e presento
|
||||
sendAlarmIfPresent(allarmiCNC.msg1);
|
||||
sendAlarmIfPresent(allarmiCNC.msg2);
|
||||
sendAlarmIfPresent(allarmiCNC.msg3);
|
||||
sendAlarmIfPresent(allarmiCNC.msg4);
|
||||
sendAlarmIfPresent(allarmiCNC.msg5);
|
||||
sendAlarmIfPresent(allarmiCNC.msg6);
|
||||
sendAlarmIfPresent(allarmiCNC.msg7);
|
||||
sendAlarmIfPresent(allarmiCNC.msg8);
|
||||
sendAlarmIfPresent(allarmiCNC.msg9);
|
||||
sendAlarmIfPresent(allarmiCNC.msg10);
|
||||
if (allarmiCNC != null)
|
||||
{
|
||||
if (allarmiCNC.Length > 0)
|
||||
{
|
||||
foreach (Alarm allarme in allarmiCNC)
|
||||
{
|
||||
sendAlarmIfPresent(allarme);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invia singolo allarme CNC se presente
|
||||
/// </summary>
|
||||
/// <param name="allarme"></param>
|
||||
protected void sendAlarmIfPresent(CMSCncLib.Focas1.ODBALMMSG2_data allarme)
|
||||
protected void sendAlarmIfPresent(Alarm allarme)
|
||||
{
|
||||
// controllo valore...
|
||||
if (allarme.alm_no > 0)
|
||||
if (allarme.Id > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (utils.CRI("loglevel") > 5)
|
||||
{
|
||||
lg.Info(string.Format("Allarmi CNC: NUM {0} | MESS: {1} | ASSE: {2} | TYPE: {3}", allarme.alm_no, allarme.alm_msg, allarme.axis, allarme.type));
|
||||
lg.Info(string.Format("Allarmi CNC: Id {0} | MESS: {1} | CAT: {2} | SRC: {3}", allarme.Id, allarme.Message, allarme.Category, allarme.Source));
|
||||
}
|
||||
|
||||
// da gestire instance = PATH!!! 1/2, x cui raddoppia i messaggi...
|
||||
|
||||
string codAllarme = string.Format("P{0}:{1}", allarme.Instance, allarme.Id);
|
||||
#if false
|
||||
// se ho asse accodo ad asse altrimenti no...
|
||||
string codAllarme = string.Format("T{0}-N{1}", allarme.type, allarme.alm_no);
|
||||
if (allarme.axis == 0)
|
||||
{
|
||||
mAlarmCNC.Add(MTConnect.Condition.Level.FAULT, allarme.alm_msg, codAllarme, "", "");
|
||||
@@ -802,10 +772,14 @@ namespace MTC_Adapter
|
||||
else
|
||||
{
|
||||
vettAxis[allarme.axis - 1].mAxAlarmCNC.Add(MTConnect.Condition.Level.FAULT, allarme.alm_msg, codAllarme, "", "");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// mostro in form!
|
||||
sb.AppendLine(codAllarme);
|
||||
parentForm.dataMonitor_1 += sb.ToString();
|
||||
|
||||
mAlarmCNC.Add(MTConnect.Condition.Level.FAULT, allarme.Message, codAllarme, "", "");
|
||||
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -977,7 +951,7 @@ namespace MTC_Adapter
|
||||
SIEMENS_ref.getPathGCodeMod(2, ref vettGCod);
|
||||
if (utils.CRB("recTime")) TimingData.addResult("R-GCodModal", DateTime.Now.Subtract(inizio).Ticks);
|
||||
|
||||
|
||||
|
||||
|
||||
#if false
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -104,6 +104,10 @@
|
||||
<HintPath>..\packages\NLog.4.4.4\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Siemens.Sinumerik.Operate.Services, Version=4.7.3.2, Culture=neutral, PublicKeyToken=bdd90fa02fd1c4ee, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>ExtLib\Siemens.Sinumerik.Operate.Services.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -178,6 +182,8 @@
|
||||
<None Include="Resources\CMS\SIEMENS.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<Content Include="ExtLib\Siemens.Sinumerik.Operate.Services.dll" />
|
||||
<Content Include="ExtLib\Siemens.Sinumerik.Operate.Services.Wrapper.dll" />
|
||||
<Content Include="Readme\ToDos_Siemens.txt" />
|
||||
<Content Include="Resources\SCM\SCM_ESA.xml" />
|
||||
<Content Include="Readme\Analisi tempi.txt" />
|
||||
|
||||
Reference in New Issue
Block a user