709ccc19dd
-cambio versione -aggiunto controllo su parametri generali
523 lines
21 KiB
VB.net
523 lines
21 KiB
VB.net
Imports System.Buffers.Binary
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
Imports Sharp7
|
|
|
|
Public Class SIEMENSSharp7Comm
|
|
|
|
Private m_DBVariableList As New List(Of DBBuffer) ' Buffer list
|
|
|
|
Private IntBuffer() As Byte = {0, 0}
|
|
Private BoolBuffer() As Byte = {0}
|
|
Private DIntBuffer() As Byte = {0, 0, 0, 0}
|
|
Private RealBuffer() As Byte = {0, 0, 0, 0}
|
|
Private StringBuffer(65536) As Byte ' Buffer
|
|
Private Client As New S7Client ' Client Object
|
|
|
|
' lista variabili in lettura
|
|
Private Shared m_ReadingVars(100) As CommVar
|
|
|
|
' lista dei messaggi di errore attivi
|
|
Private m_ActiveMessages As New List(Of SiemensReadMessages)
|
|
|
|
Private m_MachManaging As MachManaging
|
|
Friend ReadOnly Property MachManaging As MachManaging
|
|
Get
|
|
Return m_MachManaging
|
|
End Get
|
|
End Property
|
|
|
|
Private m_RefreshTime As Integer = 10
|
|
Private m_WaitingRefreshTime As Integer = 20
|
|
Private m_RefreshCounter As Integer = 0
|
|
Private m_IsRefreshing As Boolean = False
|
|
|
|
Public Sub New(MachManaging As MachManaging)
|
|
m_MachManaging = MachManaging
|
|
End Sub
|
|
|
|
Public Shared Function InitVar(Variable As CommVar) As CommVar
|
|
Dim Index As Integer = Array.IndexOf(m_ReadingVars, Nothing)
|
|
m_ReadingVars(Index) = Variable
|
|
Return m_ReadingVars(Index)
|
|
End Function
|
|
|
|
' Avvio la connessione Hardware-Client
|
|
Friend Function InitConnection() As Boolean
|
|
' Ip del PLC
|
|
Dim sIp As String = ""
|
|
GetPrivateProfileString(S_GENERAL, K_IP, "", sIp, CurrentMachine.sMachIniFile)
|
|
' unità usate dal PLC (Rack e Slot)
|
|
Dim nRack As Integer = GetPrivateProfileInt(S_GENERAL, K_RACK, 0, CurrentMachine.sMachIniFile)
|
|
Dim nSlot As Integer = GetPrivateProfileInt(S_GENERAL, K_SLOT, 0, CurrentMachine.sMachIniFile)
|
|
Map.refMachManaging.DebugMessage(1, "Tentativo di connessione a CN Siemens con Sharp7")
|
|
Map.refMachManaging.DebugMessage(1, "IP: " & sIp)
|
|
Map.refMachManaging.DebugMessage(1, "Rack: " & nRack)
|
|
Map.refMachManaging.DebugMessage(1, "Slot: " & nSlot)
|
|
Dim nResult As Integer = Client.ConnectTo(sIp, nRack, nSlot)
|
|
If nResult = 0 Then
|
|
Map.refMachManaging.DebugMessage(1, "Connessione effettuata")
|
|
Else
|
|
Map.refMachManaging.DebugMessage(1, "Connessione fallita con codice di errore: " & nResult)
|
|
End If
|
|
' se la connessione è restituisce 0
|
|
Return nResult = 0
|
|
End Function
|
|
|
|
' chiudo la connessione
|
|
Friend Sub CloseConnection()
|
|
Dim nResult As Integer = Client.Disconnect()
|
|
If Map.refMachManaging.Debug > 0 Then
|
|
If nResult = 0 Then
|
|
EgtOutLog("Disconnessione effettuata")
|
|
Else
|
|
EgtOutLog("Disconnessione fallita con codice di errore: " & nResult)
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Friend Sub RefreshConnection()
|
|
If m_RefreshCounter < m_RefreshTime Then
|
|
m_RefreshCounter += 1
|
|
Else
|
|
' riavvio connessione
|
|
m_IsRefreshing = True
|
|
CloseConnection()
|
|
InitConnection()
|
|
m_IsRefreshing = False
|
|
m_RefreshCounter = 0
|
|
End If
|
|
End Sub
|
|
|
|
Private Function WaitingRefresh() As Boolean
|
|
If Not m_IsRefreshing Then Return True
|
|
Dim WaitingCounter As Integer = 0
|
|
While m_IsRefreshing < m_WaitingRefreshTime
|
|
If Not m_IsRefreshing Then Return True
|
|
Threading.Thread.Sleep(100)
|
|
End While
|
|
EgtOutLog("Waiting reconnection timeout!")
|
|
Return False
|
|
End Function
|
|
|
|
#Region "Read Variables"
|
|
|
|
Public Sub RefreshAllVars()
|
|
WaitingRefresh()
|
|
m_DBVariableList.Clear()
|
|
For Each Var In m_ReadingVars
|
|
' rileggo solo variabili continue
|
|
If Not IsNothing(Var) AndAlso Var.nReadType = CommVar.ReadTypes.CONTINUOUS Then
|
|
Dim CompleteAddressSplit() As String = Var.sAddress.Split(":"c)
|
|
Dim nDBAddress As Integer = 0
|
|
Integer.TryParse(CompleteAddressSplit(0), nDBAddress)
|
|
If nDBAddress = 0 Then Return
|
|
Dim DBBuffer As DBBuffer = m_DBVariableList.FirstOrDefault(Function(x) x.DBAddress = nDBAddress)
|
|
If IsNothing(DBBuffer) Then
|
|
Dim Buffer(65536) As Byte
|
|
Dim nAddressByte As Integer = 0
|
|
Select Case nDBAddress
|
|
Case 301
|
|
nAddressByte = 8
|
|
Case 302
|
|
nAddressByte = 46
|
|
End Select
|
|
Map.refMachManaging.DebugMessage(1, "Lettura di " & nAddressByte & " byte dalla variabile " & nDBAddress)
|
|
Dim nResult As Integer = 1234567890
|
|
Try
|
|
nResult = Client.DBRead(nDBAddress, 0, nAddressByte, Buffer)
|
|
Catch ex As Exception
|
|
nResult = 1234567890
|
|
Map.refMachManaging.DebugMessage(1, "Lettura di " & nDBAddress & " ha generato un'eccezione")
|
|
Map.refMachManaging.DebugMessage(1, ex.ToString())
|
|
End Try
|
|
If nResult = 0 Then
|
|
Map.refMachManaging.DebugMessage(1, "Lettura di " & nDBAddress & " effettuata")
|
|
If Map.refMachManaging.Debug > 1 Then
|
|
'For Index = 0 To Buffer.Count - 1
|
|
' Map.refMachManaging.DebugMessage(2, Index & ": " & Buffer(Index))
|
|
'Next
|
|
End If
|
|
Else
|
|
Map.refMachManaging.DebugMessage(2, "Lettura fallita con codice di errore: " & nResult)
|
|
End If
|
|
If nResult = 0 Then
|
|
DBBuffer = New DBBuffer(nDBAddress, Buffer)
|
|
m_DBVariableList.Add(DBBuffer)
|
|
End If
|
|
End If
|
|
If Not IsNothing(DBBuffer) Then
|
|
Dim PositionAddressSplit() As String = CompleteAddressSplit(1).Split("."c)
|
|
Dim nStartIndex As Integer = 0
|
|
Integer.TryParse(PositionAddressSplit(0), nStartIndex)
|
|
Select Case CompleteAddressSplit(2)
|
|
Case 1
|
|
Dim nBytePositionIndex As Integer = 0
|
|
Integer.TryParse(PositionAddressSplit(1), nBytePositionIndex)
|
|
Dim nPower As Integer = Math.Pow(2, nBytePositionIndex)
|
|
' Dim bValue As Boolean = (TestBuffer(nStartIndex) And nPower) = nPower
|
|
Map.refMachManaging.DebugMessage(2, "Lettura variabile " & nDBAddress & ":" & nStartIndex & "." & nBytePositionIndex)
|
|
Var.SetValue(If((DBBuffer.DBValue(nStartIndex) And nPower) = nPower, 1, 0))
|
|
Map.refMachManaging.DebugMessage(2, "Variabile " & nDBAddress & ":" & nStartIndex & "." & nBytePositionIndex & " (Tipo 1) = " & Var.sValue)
|
|
Case 2
|
|
'Dim x = BitConverter.ToInt16(TestBuffer, nStartIndex)
|
|
Dim nValue As Int16 = BitConverter.ToInt16(DBBuffer.DBValue, nStartIndex)
|
|
Map.refMachManaging.DebugMessage(2, "Lettura variabile " & nDBAddress & ":" & nStartIndex)
|
|
Var.SetValue(BinaryPrimitives.ReverseEndianness(nValue))
|
|
Map.refMachManaging.DebugMessage(2, "Variabile " & nDBAddress & ":" & nStartIndex & " (Tipo 2) = " & Var.sValue)
|
|
Case 3
|
|
' Dim x = BitConverter.ToInt32(TestBuffer, nStartIndex)
|
|
Dim nValue As Integer = BitConverter.ToInt32(DBBuffer.DBValue, nStartIndex)
|
|
Map.refMachManaging.DebugMessage(2, "Lettura variabile " & nDBAddress & ":" & nStartIndex)
|
|
Var.SetValue(BinaryPrimitives.ReverseEndianness(nValue))
|
|
Map.refMachManaging.DebugMessage(2, "Variabile " & nDBAddress & ":" & nStartIndex & " (Tipo 3) = " & Var.sValue)
|
|
End Select
|
|
End If
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Friend Function WriteVariable(Address As String, Value As String) As Boolean
|
|
WaitingRefresh()
|
|
Dim CompleteAddressSplit() As String = Address.Split(":"c)
|
|
Dim nDBAddress As Integer = 0
|
|
Integer.TryParse(CompleteAddressSplit(0), nDBAddress)
|
|
If nDBAddress = 0 Then Return False
|
|
Dim PositionAddressSplit() As String = CompleteAddressSplit(1).Split("."c)
|
|
Dim nStartIndex As Integer = 0
|
|
Integer.TryParse(PositionAddressSplit(0), nStartIndex)
|
|
Select Case CompleteAddressSplit(2)
|
|
Case 1
|
|
' rileggo int16
|
|
Dim Buffer(1) As Byte
|
|
Client.DBRead(nDBAddress, nStartIndex, 1, Buffer)
|
|
Dim nBytePositionIndex As Integer = 0
|
|
Integer.TryParse(PositionAddressSplit(1), nBytePositionIndex)
|
|
Dim nPower As Integer = Math.Pow(2, nBytePositionIndex)
|
|
Dim nNewValue As Integer = 0
|
|
If Not Integer.TryParse(Value, nNewValue) Then Return False
|
|
Dim nOldValue As Integer = If((Buffer(0) And nPower) = nPower, 1, 0)
|
|
If nOldValue = nNewValue Then
|
|
Return True
|
|
ElseIf nOldValue = 0 Then
|
|
Buffer(0) = Buffer(0) Or nPower
|
|
ElseIf nOldValue = 1 Then
|
|
Buffer(0) = Buffer(0) Xor nPower
|
|
Else
|
|
Return False
|
|
End If
|
|
' Buffer(0) = Buffer(0) And nPower
|
|
If Map.refMachManaging.Debug > 1 Then
|
|
EgtOutLog("Scrittura variabile " & Address & " (Tipo 1) con valore " & Value)
|
|
'For Index = 0 To Buffer.Count - 1
|
|
' EgtOutLog(Index & ": " & Buffer(Index))
|
|
'Next
|
|
End If
|
|
Dim nResult As Integer = Client.DBWrite(nDBAddress, nStartIndex, 1, Buffer) ' DbNumber, Start, Amount, Buffer
|
|
' Return WriteBool(nDBAddress, nStartIndex, bValue)
|
|
If Map.refMachManaging.Debug > 1 Then
|
|
If nResult <> 0 Then
|
|
EgtOutLog("Scrittura variabile " & nDBAddress & ":" & nStartIndex & " con valore " & Value & " effettuata")
|
|
Else
|
|
EgtOutLog("Scrittura variabile " & nDBAddress & ":" & nStartIndex & " con valore " & Value & " fallita")
|
|
End If
|
|
End If
|
|
Return nResult = 0
|
|
Case 2
|
|
Dim nValue As Int16 = 0
|
|
If Not Int16.TryParse(Value, nValue) Then Return False
|
|
If Map.refMachManaging.Debug > 1 Then
|
|
EgtOutLog("Scrittura variabile " & Address & " (Tipo 2) con valore " & Value)
|
|
End If
|
|
Dim bResult As Boolean = WriteInt(nDBAddress, nStartIndex, nValue)
|
|
If Map.refMachManaging.Debug > 1 Then
|
|
If bResult Then
|
|
EgtOutLog("Scrittura variabile " & nDBAddress & ":" & nStartIndex & " con valore " & Value & " effettuata")
|
|
Else
|
|
EgtOutLog("Scrittura variabile " & nDBAddress & ":" & nStartIndex & " con valore " & Value & " fallita")
|
|
End If
|
|
End If
|
|
Return bResult
|
|
Case 3
|
|
Dim nValue As Integer = 0
|
|
If Not Integer.TryParse(Value, nValue) Then Return False
|
|
If Map.refMachManaging.Debug > 1 Then
|
|
EgtOutLog("Scrittura variabile " & Address & " (Tipo 3) con valore " & Value)
|
|
End If
|
|
Dim bResult As Boolean = WriteDInt(nDBAddress, nStartIndex, nValue)
|
|
If Map.refMachManaging.Debug > 1 Then
|
|
If bResult Then
|
|
EgtOutLog("Scrittura variabile " & nDBAddress & ":" & nStartIndex & " con valore " & Value & " effettuata")
|
|
Else
|
|
EgtOutLog("Scrittura variabile " & nDBAddress & ":" & nStartIndex & " con valore " & Value & " fallita")
|
|
End If
|
|
End If
|
|
Return bResult
|
|
Case 4
|
|
Dim dValue As Single = 0
|
|
If Not StringToDoubleAdv(Value, dValue) Then Return False
|
|
If Map.refMachManaging.Debug > 1 Then
|
|
EgtOutLog("Scrittura variabile " & Address & " (Tipo 4) con valore " & Value)
|
|
End If
|
|
Dim bResult As Boolean = WriteReal(nDBAddress, nStartIndex, dValue)
|
|
If Map.refMachManaging.Debug > 1 Then
|
|
If bResult Then
|
|
EgtOutLog("Scrittura variabile " & nDBAddress & ":" & nStartIndex & " con valore " & Value & " effettuata")
|
|
Else
|
|
EgtOutLog("Scrittura variabile " & nDBAddress & ":" & nStartIndex & " con valore " & Value & " fallita")
|
|
End If
|
|
End If
|
|
Return bResult
|
|
End Select
|
|
Return False
|
|
End Function
|
|
|
|
#End Region ' Read Variables
|
|
|
|
Friend Function ReadInt(DBNumber As Integer, Start As Integer, ByRef Value As Integer) As Boolean
|
|
WaitingRefresh()
|
|
' Read 2 bytes from the DBNumber starting from Start and puts them into ReadBuffer.
|
|
Dim Result As Integer = Client.DBRead(DBNumber, Start, 2, IntBuffer) ' DbNumber, Start, Amount, Buffer
|
|
If Result = 0 Then
|
|
Value = S7.GetIntAt(IntBuffer, 0)
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Friend Function WriteInt(DBNumber As Integer, Start As Integer, Value As Int16) As Boolean
|
|
WaitingRefresh()
|
|
S7.SetIntAt(IntBuffer, 0, Value)
|
|
' Read "Size" bytes from the DB "DBNumber" starting from 0 and puts them into Buffer.
|
|
Dim Result As Integer = Client.DBWrite(DBNumber, Start, 2, IntBuffer) ' DbNumber, Start, Amount, Buffer
|
|
Return Result = 0
|
|
End Function
|
|
|
|
Friend Function ReadBool(DBNumber As Integer, Start As Integer, ByRef Value As Boolean) As Boolean
|
|
WaitingRefresh()
|
|
' Read 2 bytes from the DBNumber starting from Start and puts them into ReadBuffer.
|
|
Dim Result As Integer = Client.DBRead(DBNumber, Start, 1, BoolBuffer) ' DbNumber, Start, Amount, Buffer
|
|
If Result = 0 Then
|
|
Value = BitConverter.ToBoolean(BoolBuffer, 0)
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Friend Function WriteBool(DBNumber As Integer, Start As Integer, Value As Boolean) As Boolean
|
|
WaitingRefresh()
|
|
|
|
If Value Then
|
|
BoolBuffer(0) = &H1
|
|
Else
|
|
BoolBuffer(0) = &H0
|
|
End If
|
|
' Read "Size" bytes from the DB "DBNumber" starting from 0 and puts them into Buffer.
|
|
Dim Result As Integer = Client.DBWrite(DBNumber, Start, 1, BoolBuffer) ' DbNumber, Start, Amount, Buffer
|
|
Return Result = 0
|
|
End Function
|
|
|
|
Friend Function ReadDInt(DBNumber As Integer, Start As Integer, ByRef Value As Integer) As Boolean
|
|
WaitingRefresh()
|
|
' Read 2 bytes from the DBNumber starting from Start and puts them into ReadBuffer.
|
|
Dim Result As Integer = Client.DBRead(DBNumber, Start, 4, DIntBuffer) ' DbNumber, Start, Amount, Buffer
|
|
If Result = 0 Then
|
|
Value = S7.GetDIntAt(DIntBuffer, 0)
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Friend Function WriteDInt(DBNumber As Integer, Start As Integer, Value As Integer) As Boolean
|
|
WaitingRefresh()
|
|
S7.SetDIntAt(DIntBuffer, 0, Value)
|
|
' Read "Size" bytes from the DB "DBNumber" starting from 0 and puts them into Buffer.
|
|
Dim Result As Integer = Client.DBWrite(DBNumber, Start, 4, DIntBuffer) ' DbNumber, Start, Amount, Buffer
|
|
Return Result = 0
|
|
End Function
|
|
|
|
Friend Function ReadReal(DBNumber As Integer, Start As Integer, ByRef Value As Double) As Boolean
|
|
WaitingRefresh()
|
|
' Read 4 bytes from the DBNumber starting from Start and puts them into ReadBuffer.
|
|
Dim Result As Integer = Client.DBRead(DBNumber, Start, 4, RealBuffer) ' DbNumber, Start, Amount, Buffer
|
|
If Result = 0 Then
|
|
Value = S7.GetRealAt(RealBuffer, 0)
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Friend Function WriteReal(DBNumber As Integer, Start As Integer, Value As Single) As Boolean
|
|
WaitingRefresh()
|
|
S7.SetRealAt(RealBuffer, 0, Value)
|
|
' Read "Size" bytes from the DB "DBNumber" starting from 0 and puts them into Buffer.
|
|
Dim Result As Integer = Client.DBWrite(DBNumber, Start, 4, RealBuffer) ' DbNumber, Start, Amount, Buffer
|
|
Return Result = 0
|
|
End Function
|
|
|
|
Friend Function ReadString(DBNumber As Integer, Start As Integer, Length As Integer, ByRef Value As String) As Boolean
|
|
WaitingRefresh()
|
|
' Read 2 bytes from the DBNumber starting from Start and puts them into ReadBuffer.
|
|
Dim Result As Integer = Client.DBRead(DBNumber, Start, Length, StringBuffer) ' DbNumber, Start, Amount, Buffer
|
|
If Result = 0 Then
|
|
Value = S7.GetStringAt(StringBuffer, 0)
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Friend Function WriteString(DBNumber As Integer, Start As Integer, Value As String) As Boolean
|
|
WaitingRefresh()
|
|
|
|
If Value.Length > 65535 Then
|
|
Return False
|
|
End If
|
|
S7.SetStringAt(StringBuffer, 0, 65535, Value)
|
|
' Read "Size" bytes from the DB "DBNumber" starting from 0 and puts them into Buffer.
|
|
Dim Result As Integer = Client.DBWrite(DBNumber, Start, Value.Length + 2, StringBuffer) ' DbNumber, Start, Amount, Buffer
|
|
Return Result = 0
|
|
End Function
|
|
|
|
Friend Function ResetStep(bReset As Boolean) As Boolean
|
|
WaitingRefresh()
|
|
Dim varResetStep As Variable = Map.refMachCommandMessagePanelVM.MainVariablesList(19) ' Map.refMachCommandMessagePanelVM.MainVariablesList.FirstOrDefault(Function(x) x.sName = RESET_STEP)
|
|
If bReset Then
|
|
Map.refMachManaging.DebugMessage(1, "Imposto variabile ResetStep a 1")
|
|
varResetStep.sValue = 1
|
|
Threading.Thread.Sleep(100)
|
|
Dim nResetStepOk As Integer = 0
|
|
Dim ResetStepOk As Variable = Map.refMachCommandMessagePanelVM.MainVariablesList.FirstOrDefault(Function(x) x.sName = RESET_STEP_OK)
|
|
Dim ResetMachine As Variable = Map.refMachCommandMessagePanelVM.MainVariablesList.FirstOrDefault(Function(x) x.sName = RESET_STATE)
|
|
While nResetStepOk <> 1
|
|
If ResetMachine.sValue = "1" Then
|
|
Return False
|
|
End If
|
|
Map.refMachManaging.DebugMessage(1, "Rileggo variabili")
|
|
RefreshAllVars()
|
|
Map.refMachManaging.DebugMessage(1, "Leggo valore ResetStepOk")
|
|
Integer.TryParse(ResetStepOk.sValue, nResetStepOk)
|
|
Threading.Thread.Sleep(1000)
|
|
End While
|
|
End If
|
|
varResetStep.sValue = 0
|
|
Map.refMachManaging.DebugMessage(1, "Imposto variabile ResetStep a 0")
|
|
Return True
|
|
End Function
|
|
|
|
Friend Sub ReadPLCMessages()
|
|
WaitingRefresh()
|
|
|
|
Dim nPlc_Msg As New List(Of Byte)
|
|
For Index As Integer = 1 To 6
|
|
Dim nIndex As Integer = Index
|
|
Dim PLCMessagesVariable As Variable = Map.refMachCommandMessagePanelVM.MainVariablesList.FirstOrDefault(Function(x) x.sName = PLC_MESSAGES & nIndex)
|
|
If IsNothing(PLCMessagesVariable) OrElse IsNothing(PLCMessagesVariable.sValue) Then Return
|
|
Dim nTemp As Int16 = 0
|
|
Int16.TryParse(PLCMessagesVariable.sValue, nTemp)
|
|
nTemp = BinaryPrimitives.ReverseEndianness(nTemp)
|
|
Dim Bytes As Byte() = BitConverter.GetBytes(nTemp)
|
|
nPlc_Msg.AddRange(Bytes)
|
|
Next
|
|
Dim BitArray As New BitArray(nPlc_Msg.ToArray())
|
|
Dim ErrorList As New List(Of Integer)
|
|
For BitIndex = 0 To BitArray.Count - 1
|
|
If BitIndex <= 169 AndAlso BitArray(BitIndex) Then
|
|
ErrorList.Add(BitIndex)
|
|
End If
|
|
Next
|
|
ShowPLCError(ErrorList)
|
|
End Sub
|
|
|
|
Friend Sub ShowPLCError(ErrorNumber As List(Of Integer))
|
|
' resetto stati bFound
|
|
For Each Message In m_ActiveMessages
|
|
Message.bFound = False
|
|
Next
|
|
|
|
For index As Integer = 0 To ErrorNumber.Count - 1
|
|
Dim nIndex As Integer = index
|
|
Dim NewMessageInList As SiemensReadMessages = m_ActiveMessages.FirstOrDefault(Function(x) x.nIndex = 0.ToString())
|
|
' se il messaggio e' gia' in lista
|
|
If Not IsNothing(NewMessageInList) Then
|
|
' lo segno come trovato
|
|
NewMessageInList.bFound = True
|
|
Else
|
|
' lo aggiungo
|
|
Dim NewMessage As SiemensReadMessages = New SiemensReadMessages(0.ToString())
|
|
NewMessage.bFound = True
|
|
m_ActiveMessages.Add(NewMessage)
|
|
m_SiemensAlarmCallbackDlg(0, 0)
|
|
End If
|
|
Next
|
|
|
|
' cancello messaggi non trovati
|
|
For Index = m_ActiveMessages.Count - 1 To 0 Step -1
|
|
Dim Message As SiemensReadMessages = m_ActiveMessages(Index)
|
|
If Not Message.bFound Then
|
|
m_SiemensAlarmCallbackDlg(Message.nIndex, 1)
|
|
m_ActiveMessages.RemoveAt(Index)
|
|
End If
|
|
Next
|
|
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Friend Class DBBuffer
|
|
|
|
Private m_DBAddress As Integer
|
|
Public ReadOnly Property DBAddress As Integer
|
|
Get
|
|
Return m_DBAddress
|
|
End Get
|
|
End Property
|
|
|
|
Private m_DBValue(65536) As Byte
|
|
Public ReadOnly Property DBValue As Byte()
|
|
Get
|
|
Return m_DBValue
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(DBAddress As Integer, DBValue As Byte())
|
|
m_DBAddress = DBAddress
|
|
m_DBValue = DBValue
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class SiemensReadMessages
|
|
|
|
Private m_nIndex As Integer
|
|
Public ReadOnly Property nIndex As Integer
|
|
Get
|
|
Return m_nIndex
|
|
End Get
|
|
End Property
|
|
Private m_sMessage As String
|
|
Public ReadOnly Property sMessage As String
|
|
Get
|
|
Return m_sMessage
|
|
End Get
|
|
End Property
|
|
Friend Sub SetMessage(sValue As String)
|
|
m_sMessage = sValue
|
|
End Sub
|
|
|
|
Private m_bFound As Boolean = False
|
|
Friend Property bFound As Boolean
|
|
Get
|
|
Return m_bFound
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bFound = value
|
|
End Set
|
|
End Property
|
|
Public Sub New(nIndex As Integer)
|
|
m_nIndex = nIndex
|
|
m_sMessage = sMessage
|
|
End Sub
|
|
|
|
End Class
|