- Integrazione dei comandi Num di COMMTest

This commit is contained in:
Emmanuele Sassi
2021-11-04 18:01:43 +01:00
parent ace6bbc35c
commit 78470c8ad0
33 changed files with 2071 additions and 780 deletions
@@ -8,19 +8,23 @@ Imports EgtWPFLib5
Public Class MachCommandMessagePanelVM
Inherits VMBase
Public Enum MachineOperatingState
Start = 1
[Stop] = 2
[End] = 3
SetPoint = 4
Pending = 5
Unspecified = 100
End Enum
Private m_AlarmTimer As New DispatcherTimer
Private m_MachManagingThread As Thread
Public ReadOnly Property MachManagingThread As Thread
Get
Return m_MachManagingThread
End Get
End Property
Private m_MainVariablesList As List(Of Variable)
Public ReadOnly Property MainVariablesList As List(Of Variable)
Get
Return m_MainVariablesList
End Get
End Property
Private m_bPrinterLink As Boolean = False
Public ReadOnly Property bPrinterLink As Boolean
Get
@@ -87,40 +91,32 @@ Public Class MachCommandMessagePanelVM
NotifyPropertyChanged(NameOf(VarValue))
End Sub
Private m_AxisList As ObservableCollection(Of Axis)
'Private m_OPState As MachineOperatingState
Public ReadOnly Property AxisList As ObservableCollection(Of Axis)
Get
Return m_AxisList
End Get
End Property
'Public ReadOnly Property OPState As MachineOperatingState
' Get
' Return m_OPState
' End Get
'End Property
Private m_OPState As MachineOperatingState
Public ReadOnly Property OPState As MachineOperatingState
Get
Return m_OPState
End Get
End Property
Public ReadOnly Property sOPState As String
Get
Select Case m_OPState
Case MachineOperatingState.Start
Return "START"
Case MachineOperatingState.Stop
Return "STOP"
Case MachineOperatingState.End
Return "RESET"
Case MachineOperatingState.SetPoint
Return "SETPOINT"
Case MachineOperatingState.Pending
Return "PENDING"
Case Else
Return "UNSPECIFIED"
End Select
End Get
End Property
'Public ReadOnly Property sOPState As String
' Get
' Select Case m_OPState
' Case MachineOperatingState.Start
' Return "START"
' Case MachineOperatingState.Stop
' Return "STOP"
' Case MachineOperatingState.End
' Return "RESET"
' Case MachineOperatingState.SetPoint
' Return "SETPOINT"
' Case MachineOperatingState.Pending
' Return "PENDING"
' Case Else
' Return "UNSPECIFIED"
' End Select
' End Get
'End Property
Private m_ErrCycle As New List(Of Alarm)
Private m_ErrCycleCount As Integer = 0
@@ -166,30 +162,14 @@ Public Class MachCommandMessagePanelVM
Private m_cmdStop As ICommand
Private m_cmdReset As ICommand
Private m_cmdStep As ICommand
Private m_cmdSearchFilePath As ICommand
Private m_cmdAddProgram As ICommand
Private m_cmdRemoveProgram As ICommand
Private m_cmdReadVar As ICommand
Private m_cmdWriteVar As ICommand
Private m_cmdDeleteAlarms As ICommand
Private m_cmdSetPoint As ICommand
Private m_cmdPrintLabel As ICommand
Public Sub New()
Map.SetRefMachCommandMessagePanelVM(Me)
' impostazioni timer degli allarmi
m_AlarmTimer.Interval = TimeSpan.FromMilliseconds(1500)
AddHandler m_AlarmTimer.Tick, AddressOf AlarmTimer_Tick
' impostazione assi (leggerli da conf macchina)
m_AxisList = New ObservableCollection(Of Axis)({New Axis(ASSE_X),
New Axis(ASSE_Y),
New Axis(ASSE_Z),
New Axis(ASSE_C),
New Axis(ASSE_B)})
' verifico se stampante collegata
m_bPrinterLink = (GetMainPrivateProfileInt(S_PRINTER, K_ENABLE, 0) = 1)
' connetto stampante etichette
If bPrinterLink Then LabelPrinter.ConnectPrinter()
NotifyPropertyChanged(NameOf(Connect_Background))
End Sub
@@ -307,25 +287,41 @@ Public Class MachCommandMessagePanelVM
't = Map.refMachManaging.Tpa.remObject.SetVariableCommand(ISOCNC.Remoting.VariableCommands.ReadVar, "0.TESTA.C", "")
't = Map.refMachManaging.Tpa.remObject.SetVariableCommand(ISOCNC.Remoting.VariableCommands.ReadVar, "0.TESTA.B", "")
RWVariableManager.InitVar(ASSE_X, GetVarPathByName(ASSE_X), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(ASSE_Y, GetVarPathByName(ASSE_Y), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(ASSE_Z, GetVarPathByName(ASSE_Z), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(ASSE_B, GetVarPathByName(ASSE_B), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(P_PROD, GetVarPathByName(P_PROD), CommVar.CommVarTypes.CONTINUOUS)
RWVariableManager.InitVar(P_MACHGROUP, GetVarPathByName(P_MACHGROUP), CommVar.CommVarTypes.CONTINUOUS)
RWVariableManager.InitVar(P_PART, GetVarPathByName(P_PART), CommVar.CommVarTypes.CONTINUOUS)
RWVariableManager.InitVar(P_STATE, GetVarPathByName(P_STATE), CommVar.CommVarTypes.CONTINUOUS)
RWVariableManager.InitVar(RESET_STATE, GetVarPathByName(RESET_STATE), CommVar.CommVarTypes.CONTINUOUS)
RWVariableManager.InitVar(VPAR & "1", GetVarPathByName(VPAR & "1"), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(VPAR & "2", GetVarPathByName(VPAR & "2"), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(VPAR & "3", GetVarPathByName(VPAR & "3"), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(VPAR & "4", GetVarPathByName(VPAR & "4"), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(VPAR & "5", GetVarPathByName(VPAR & "5"), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(VPAR & "6", GetVarPathByName(VPAR & "6"), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(VPAR & "7", GetVarPathByName(VPAR & "7"), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(VPAR & "8", GetVarPathByName(VPAR & "8"), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(VPAR & "9", GetVarPathByName(VPAR & "9"), CommVar.CommVarTypes.ONETIME)
RWVariableManager.InitVar(VPAR & "10", GetVarPathByName(VPAR & "10"), CommVar.CommVarTypes.ONETIME)
' inizializzo le variabili principali
Dim Index As Integer = 1
Dim CommVariable As CommVar = MachManaging.InitVar(S_MAINVARIABLES, Index)
While Not IsNothing(CommVariable)
m_MainVariablesList.Add(New Variable(CommVariable))
Index += 1
CommVariable = MachManaging.InitVar(S_MAINVARIABLES, Index)
End While
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 1)))
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 2)))
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 3)))
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 4)))
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 5)))
'm_MainVariablesList.Add(New Variable(MachManaging.InitVar(S_MAINVARIABLES, 6)))
'RWVariableManager.InitVar(ASSE_X, GetVarPathByName(ASSE_X), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(ASSE_Y, GetVarPathByName(ASSE_Y), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(ASSE_Z, GetVarPathByName(ASSE_Z), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(ASSE_B, GetVarPathByName(ASSE_B), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(P_PROD, GetVarPathByName(P_PROD), CommVar.CommVarTypes.CONTINUOUS)
'RWVariableManager.InitVar(P_MACHGROUP, GetVarPathByName(P_MACHGROUP), CommVar.CommVarTypes.CONTINUOUS)
'RWVariableManager.InitVar(P_PART, GetVarPathByName(P_PART), CommVar.CommVarTypes.CONTINUOUS)
'RWVariableManager.InitVar(P_STATE, GetVarPathByName(P_STATE), CommVar.CommVarTypes.CONTINUOUS)
'RWVariableManager.InitVar(RESET_STATE, GetVarPathByName(RESET_STATE), CommVar.CommVarTypes.CONTINUOUS)
'RWVariableManager.InitVar(VPAR & "1", GetVarPathByName(VPAR & "1"), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(VPAR & "2", GetVarPathByName(VPAR & "2"), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(VPAR & "3", GetVarPathByName(VPAR & "3"), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(VPAR & "4", GetVarPathByName(VPAR & "4"), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(VPAR & "5", GetVarPathByName(VPAR & "5"), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(VPAR & "6", GetVarPathByName(VPAR & "6"), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(VPAR & "7", GetVarPathByName(VPAR & "7"), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(VPAR & "8", GetVarPathByName(VPAR & "8"), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(VPAR & "9", GetVarPathByName(VPAR & "9"), CommVar.CommVarTypes.ONETIME)
'RWVariableManager.InitVar(VPAR & "10", GetVarPathByName(VPAR & "10"), CommVar.CommVarTypes.ONETIME)
End Sub
Public ReadOnly Property Disconnect_Command As ICommand
@@ -400,66 +396,6 @@ Public Class MachCommandMessagePanelVM
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.SETPOINT))
End Sub
Public ReadOnly Property PrintLabel_Command As ICommand
Get
If m_cmdPrintLabel Is Nothing Then m_cmdPrintLabel = New Command(AddressOf PrintLabel)
Return m_cmdPrintLabel
End Get
End Property
Public Sub PrintLabel()
DbControllers.m_LogMachineController.Create(MachLog.CreateResultLog(LogCommandTypes.ALARM, CommandStates.ERROR_, ResultTypes.EXECUTED, ""))
DbControllers.m_LogMachineController.Create(MachLog.CreateAlarmLog(5, 7, "Allaaaaaaaarmeeeeeeeeee!!", 7645, DateTime.Now()))
DbControllers.m_LogMachineController.Create(MachLog.CreateOPStateLog(85))
DbControllers.m_LogMachineController.Create(MachLog.CreateReadLog(True, "E80048", "46"))
'LabelPrinter.SetTestPrintVariables(2, 34, 76)
'LabelPrinter.Print()
End Sub
Public ReadOnly Property AddProgram_Command As ICommand
Get
If m_cmdAddProgram Is Nothing Then m_cmdAddProgram = New Command(AddressOf AddProgram)
Return m_cmdAddProgram
End Get
End Property
Public Sub AddProgram(ByVal param As Object)
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.SENDPROG))
End Sub
Public ReadOnly Property RemoveProgram_Command As ICommand
Get
If m_cmdRemoveProgram Is Nothing Then m_cmdRemoveProgram = New Command(AddressOf RemoveProgram)
Return m_cmdRemoveProgram
End Get
End Property
Public Sub RemoveProgram(ByVal param As Object)
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.REMOVEPROG))
End Sub
Public ReadOnly Property ReadVar_Command As ICommand
Get
If m_cmdReadVar Is Nothing Then m_cmdReadVar = New Command(AddressOf ReadVar)
Return m_cmdReadVar
End Get
End Property
Public Sub ReadVar(ByVal param As Object)
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.READ))
End Sub
Public ReadOnly Property WriteVar_Command As ICommand
Get
If m_cmdWriteVar Is Nothing Then m_cmdWriteVar = New Command(AddressOf WriteVar)
Return m_cmdWriteVar
End Get
End Property
Public Sub WriteVar(ByVal param As Object)
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.WRITE))
End Sub
Public ReadOnly Property DeleteAlarms_Command As ICommand
Get
@@ -579,20 +515,25 @@ Public Class MachCommandMessagePanelVM
End Sub
Friend Sub AxisCoordinatesCallbackDlg(AxisValue As Double, AxisIndex As Integer)
m_AxisList(AxisIndex).SetValue(AxisValue)
Map.refAxesPanelVM.AxisCoordinatesCallbackDlg(AxisValue, AxisIndex)
End Sub
Friend Sub OpStateCallbackDlg(newOpState As MachineOperatingState)
If newOpState <> MachineOperatingState.Unspecified Then
Dim bDifferent As Boolean = (m_OPState <> newOpState)
m_OPState = newOpState
If bDifferent Then
For Each MachGroup As MyMachGroupVM In Map.refSupervisorMachGroupPanelVM.MachGroupVMList
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Produce_IsEnabled))
Next
End If
End If
Map.refLeftPanelVM.NotifyPropertyChanged(NameOf(Map.refLeftPanelVM.sOPState))
Friend Sub OpStateCallbackDlg(newOpState As Integer)
Dim NewState As OPState = Map.refLeftPanelVM.OPStateList.FirstOrDefault(Function(x) x.Id = newOpState)
Select Case CurrentMachine.NCType
Case NCTypes.TPA
If newOpState <> TPA_OPState.Unspecified Then
Dim bDifferent As Boolean = (Map.refLeftPanelVM.SelOPState.Id <> newOpState)
Map.refLeftPanelVM.SetOPState(NewState)
If bDifferent Then
For Each MachGroup As MyMachGroupVM In Map.refSupervisorMachGroupPanelVM.MachGroupVMList
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Produce_IsEnabled))
Next
End If
End If
Case NCTypes.NUM_FLEXIUM
Map.refLeftPanelVM.SetOPState(NewState)
End Select
DbControllers.m_LogMachineController.Create(MachLog.CreateOPStateLog(newOpState))
End Sub
@@ -608,7 +549,7 @@ Public Class MachCommandMessagePanelVM
End Sub
Private Sub SetAxisValue(VarName As String, VarValue As String)
Dim Axis As Axis = m_AxisList.FirstOrDefault(Function(x) x.sName = VarName)
Dim Axis As Axis = Map.refAxesPanelVM.AxesList.FirstOrDefault(Function(x) x.sName = VarName)
If Not IsNothing(Axis) Then
Axis.SetValue(VarValue)
End If
@@ -618,34 +559,6 @@ Public Class MachCommandMessagePanelVM
End Class
Public Class Axis
Inherits VMBase
Private m_Name As String
Public ReadOnly Property sName As String
Get
Return m_Name
End Get
End Property
Private m_Value As Double
Public ReadOnly Property sValue As Double
Get
Return m_Value
End Get
End Property
Friend Sub SetValue(value As Double)
m_Value = value
NotifyPropertyChanged(NameOf(sValue))
End Sub
Public Sub New(Name As String)
m_Name = Name
End Sub
End Class
Class Alarm
Private m_sCode As String