194 lines
5.7 KiB
VB.net
194 lines
5.7 KiB
VB.net
Public Class MachLog
|
|
|
|
#Region "Private Fields"
|
|
|
|
Public Enum MachLogTypes
|
|
NULL = 0
|
|
PART_STATUS = 1
|
|
MACHGROUP_STATUS = 2
|
|
MACHINE_MODE = 3
|
|
MACHINE_STATUS = 4
|
|
MACHINE_COMMAND = 5
|
|
READ_VAR = 6
|
|
WRITE_VAR = 7
|
|
ALARM = 8
|
|
OPERATOR_MSG = 9
|
|
PROGRAM_SEND = 10
|
|
APPLICATION = 11
|
|
End Enum
|
|
|
|
Private m_AlarmDateTime As DateTime
|
|
Private m_nProdId As Integer
|
|
Private m_ResultType As MachLogTypes
|
|
Private m_SupervisorId As String
|
|
Private m_VarValue As String
|
|
|
|
' variabili del log macchina
|
|
Public ReadOnly Property EventType As MachLogTypes
|
|
Get
|
|
Return m_ResultType
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property EventDateTime As DateTime
|
|
Get
|
|
Return m_AlarmDateTime
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property EventValue As String
|
|
Get
|
|
Return m_VarValue
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sEventType As String
|
|
Get
|
|
Select Case m_ResultType
|
|
Case MachLogTypes.PART_STATUS
|
|
Return String.Format("({0}) Stato pezzo", 1)
|
|
Case MachLogTypes.MACHGROUP_STATUS
|
|
Return String.Format("({0}) Stato barra", 2)
|
|
Case MachLogTypes.MACHINE_MODE = 3
|
|
Return String.Format("({0}) Modalità macchina", 3)
|
|
Case MachLogTypes.MACHINE_STATUS = 4
|
|
Return String.Format("({0}) Stato macchina", 4)
|
|
Case MachLogTypes.MACHINE_COMMAND = 5
|
|
Return String.Format("({0}) Comando macchina", 5)
|
|
Case MachLogTypes.READ_VAR = 6
|
|
Return String.Format("({0}) Lettura variabile", 6)
|
|
Case MachLogTypes.WRITE_VAR = 7
|
|
Return String.Format("({0}) Scrittura variabile", 7)
|
|
Case MachLogTypes.ALARM = 8
|
|
Return String.Format("({0}) Allarme", 8)
|
|
Case MachLogTypes.OPERATOR_MSG = 9
|
|
Return String.Format("({0}) Messaggio opertore", 9)
|
|
Case MachLogTypes.PROGRAM_SEND = 10
|
|
Return String.Format("({0}) Invio programma", 10)
|
|
Case Else
|
|
Return "Altro"
|
|
End Select
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property sEventDateTime As String
|
|
Get
|
|
Return m_AlarmDateTime
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property sEventValue As String
|
|
Get
|
|
Return m_VarValue
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sPROD As String
|
|
Get
|
|
Return m_VarValue
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region "Protected Constructors"
|
|
|
|
Protected Sub New()
|
|
m_AlarmDateTime = DateTime.MinValue
|
|
m_nProdId = 0
|
|
m_ResultType = ResultTypes.NULL
|
|
m_SupervisorId = ""
|
|
m_VarValue = ""
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "Public Properties"
|
|
|
|
Public ReadOnly Property AlarmDateTime As Date
|
|
Get
|
|
Return m_AlarmDateTime
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ProdId As Integer
|
|
Get
|
|
Return m_nProdId
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ResultType As ResultTypes
|
|
Get
|
|
Return m_ResultType
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property VarAddress As String
|
|
Get
|
|
Return m_SupervisorId
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property VarValue As String
|
|
Get
|
|
Return m_VarValue
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region "Internal Methods"
|
|
|
|
Public Shared Function CreateAlarmLog(AlarmOperation As Integer, AlarmType As Integer, AlarmMessage As String, AlarmCode As String, AlarmDateTime As String)
|
|
Dim NewMachLog As New MachLog
|
|
DateTime.TryParse(AlarmDateTime, NewMachLog.m_AlarmDateTime)
|
|
Return NewMachLog
|
|
End Function
|
|
|
|
Public Shared Function CreateOPStateLog(newOpState As Integer)
|
|
Dim NewMachLog As New MachLog
|
|
NewMachLog.m_nProdId = newOpState
|
|
NewMachLog.m_AlarmDateTime = DateTime.Now()
|
|
Return NewMachLog
|
|
End Function
|
|
|
|
Public Shared Function CreateReadLog(CommandExecutedCorrectly As Boolean, VarAddress As String, VarValue As String)
|
|
Dim NewMachLog As New MachLog
|
|
NewMachLog.m_SupervisorId = VarAddress
|
|
NewMachLog.m_VarValue = VarValue
|
|
NewMachLog.m_AlarmDateTime = DateTime.Now()
|
|
Return NewMachLog
|
|
End Function
|
|
|
|
Public Shared Function CreateResultLog(CommandType As LogCommandTypes, CommandState As CommandStates, ResultType As ResultTypes, Description As String)
|
|
Dim NewMachLog As New MachLog
|
|
NewMachLog.m_ResultType = ResultType
|
|
NewMachLog.m_AlarmDateTime = DateTime.Now()
|
|
Return NewMachLog
|
|
End Function
|
|
|
|
Public Shared Function CreateMachLog(EventType As MachLogTypes, EventDateTime As DateTime, Value As String, nProdId As Integer, SupervisorID As String)
|
|
Dim NewMachEvent As New MachLog
|
|
NewMachEvent.m_ResultType = EventType
|
|
NewMachEvent.m_AlarmDateTime = EventDateTime
|
|
NewMachEvent.m_VarValue = Value
|
|
NewMachEvent.m_nProdId = nProdId
|
|
NewMachEvent.m_SupervisorId = SupervisorID
|
|
Return NewMachEvent
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
#Region "Public Methods"
|
|
|
|
Public Shared Function CreateMachLog(AlarmCode As String, AlarmDateTime As Date, AlarmMessage As String, AlarmOperation As Integer, AlarmType As Integer, CommandExecutedCorrectly As Boolean, CommandState As CommandStates, CommandType As LogCommandTypes, Description As String, newOpState As Integer, ResultType As ResultTypes, VarAddress As String, VarValue As String) As MachLog
|
|
|
|
Dim NewMachLog As New MachLog
|
|
NewMachLog.m_AlarmDateTime = AlarmDateTime
|
|
NewMachLog.m_nProdId = newOpState
|
|
NewMachLog.m_ResultType = ResultType
|
|
NewMachLog.m_SupervisorId = VarAddress
|
|
NewMachLog.m_VarValue = VarValue
|
|
|
|
Return NewMachLog
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
End Class |