- gestito sinclock su lista ThreadCommand in Supervisor
This commit is contained in:
@@ -40,7 +40,7 @@ Public Class LeftPanelVM
|
||||
Return m_SelChannel
|
||||
End Get
|
||||
Set(ByVal value As IdNameStruct)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.SETCHANNEL, value.Id))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.SETCHANNEL, value.Id))
|
||||
m_SelChannel = value
|
||||
End Set
|
||||
End Property
|
||||
@@ -86,7 +86,7 @@ Public Class LeftPanelVM
|
||||
Return m_SelOPMode
|
||||
End Get
|
||||
Set(ByVal value As OPState)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.SETOPMODE, value.Id))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.SETOPMODE, value.Id))
|
||||
' se MDI
|
||||
If value.Id = OPModes.Mdi Then
|
||||
' mostro pagina comandi MDI
|
||||
|
||||
@@ -163,7 +163,7 @@ Public Class MDIPageVM
|
||||
''' </summary>
|
||||
Friend Sub SendMDI()
|
||||
If Not String.IsNullOrWhiteSpace(m_sMDICommand_Text) Then
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.MDI, m_sMDICommand_Text))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.MDI, m_sMDICommand_Text))
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -427,11 +427,11 @@ Public Class MachCommandMessagePanelVM
|
||||
End Property
|
||||
|
||||
Public Sub Disconnect()
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.DISCONNECT))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.DISCONNECT))
|
||||
End Sub
|
||||
|
||||
Public Sub SetOPState(OpState As Integer)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.SETOPMODE))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.SETOPMODE))
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property Start_Command As ICommand
|
||||
@@ -442,7 +442,7 @@ Public Class MachCommandMessagePanelVM
|
||||
End Property
|
||||
|
||||
Public Sub Start(ByVal param As Object)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.START))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.START))
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property Stop_Command As ICommand
|
||||
@@ -453,7 +453,7 @@ Public Class MachCommandMessagePanelVM
|
||||
End Property
|
||||
|
||||
Public Sub [Stop](ByVal param As Object)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.STOP_))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.STOP_))
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property Reset_Command As ICommand
|
||||
@@ -464,7 +464,7 @@ Public Class MachCommandMessagePanelVM
|
||||
End Property
|
||||
|
||||
Public Sub Reset(ByVal param As Object)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.RESET))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.RESET))
|
||||
' annullo stato di pronto ad essere lavorato di tutti i programmi
|
||||
If Not IsNothing(Map.refProjectVM.SupervisorMachGroupPanelVM) Then Map.refProjectVM.SupervisorMachGroupPanelVM.ResetAllMachGroups()
|
||||
End Sub
|
||||
@@ -477,7 +477,7 @@ Public Class MachCommandMessagePanelVM
|
||||
End Property
|
||||
|
||||
Public Sub [Step](ByVal param As Object)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.STEP_))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.STEP_))
|
||||
End Sub
|
||||
|
||||
Public ReadOnly Property SetPoint_Command As ICommand
|
||||
@@ -488,7 +488,7 @@ Public Class MachCommandMessagePanelVM
|
||||
End Property
|
||||
|
||||
Public Sub SetPoint(ByVal param As Object)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.SETPOINT))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.SETPOINT))
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -500,7 +500,7 @@ Public Class MachCommandMessagePanelVM
|
||||
End Property
|
||||
|
||||
Public Sub DeleteAlarms(ByVal param As Object)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.DELETEALARMS))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.DELETEALARMS))
|
||||
End Sub
|
||||
|
||||
Public Function GetVarPathByName(Name As String) As String
|
||||
|
||||
@@ -10,6 +10,9 @@ Imports EgtBEAMWALL.Supervisor.CommVar
|
||||
|
||||
Public Class MachManaging
|
||||
|
||||
' lock per aggiunta elemento a lista MachGroup
|
||||
Private Shared Lock_CommandList As New Object
|
||||
|
||||
Private m_bConnected As Boolean = False
|
||||
Public ReadOnly Property bConnected As Boolean
|
||||
Get
|
||||
@@ -53,6 +56,17 @@ Public Class MachManaging
|
||||
Return m_CommandList
|
||||
End Get
|
||||
End Property
|
||||
Friend Shared Sub AddToCommandList(value As ThreadCommand)
|
||||
SyncLock Lock_CommandList
|
||||
For CommandIndex = m_CommandList.Count - 1 To 0 Step -1
|
||||
Dim Command As ThreadCommand = m_CommandList(CommandIndex)
|
||||
If Command.ProcessingStatus = ThreadCommand.ProcessingStatuses.DONE Then
|
||||
m_CommandList.Remove(Command)
|
||||
End If
|
||||
Next
|
||||
CommandList.Add(value)
|
||||
End SyncLock
|
||||
End Sub
|
||||
|
||||
Private m_bStartPending As Boolean = False
|
||||
Public ReadOnly Property StartPending As Boolean
|
||||
@@ -771,9 +785,13 @@ Public Class MachManaging
|
||||
|
||||
Private Sub CommandList_CollectionChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
|
||||
If Not IsNothing(e.NewItems) Then
|
||||
For Each Command In e.NewItems
|
||||
ExecuteCommand(DirectCast(Command, ThreadCommand))
|
||||
m_CommandList.Remove(Command)
|
||||
For CommandIndex = 0 To e.NewItems.Count - 1
|
||||
Dim Command As ThreadCommand = e.NewItems(CommandIndex)
|
||||
If Command.ProcessingStatus = ThreadCommand.ProcessingStatuses.WAITING Then
|
||||
Command.SetProcessingStatus(ThreadCommand.ProcessingStatuses.PROCESSING)
|
||||
ExecuteCommand(DirectCast(Command, ThreadCommand))
|
||||
Command.SetProcessingStatus(ThreadCommand.ProcessingStatuses.DONE)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -54,6 +54,12 @@ End Class
|
||||
|
||||
Public Class ThreadCommand
|
||||
|
||||
Public Enum ProcessingStatuses
|
||||
WAITING = 1
|
||||
PROCESSING = 2
|
||||
DONE = 3
|
||||
End Enum
|
||||
|
||||
Private m_CommandType As CommandTypes
|
||||
Public ReadOnly Property CommandType As CommandTypes
|
||||
Get
|
||||
@@ -95,6 +101,16 @@ Public Class ThreadCommand
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_ProcessingStatus As ProcessingStatuses = ProcessingStatuses.WAITING
|
||||
Public ReadOnly Property ProcessingStatus As ProcessingStatuses
|
||||
Get
|
||||
Return m_ProcessingStatus
|
||||
End Get
|
||||
End Property
|
||||
Friend Sub SetProcessingStatus(value As ProcessingStatuses)
|
||||
m_ProcessingStatus = value
|
||||
End Sub
|
||||
|
||||
Protected Sub New()
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -277,31 +277,31 @@ Public Class MainMenuVM
|
||||
|
||||
Private Function InitINPUTS() As Boolean
|
||||
' fermo e riavvio lettura variabili per includere quelle della pagina input
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.STOPREAD_NUMFLEXIUM))
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.READ_NUMFLEXIUM))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.STOPREAD_NUMFLEXIUM))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.READ_NUMFLEXIUM))
|
||||
Map.refMainWindowVM.NotifyPropertyChanged(NameOf(Map.refMainWindowVM.nSelTabPage))
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function ExitINPUTS() As Boolean
|
||||
' fermo e riavvio lettura variabili per includere quelle della pagina input
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.STOPREAD_NUMFLEXIUM))
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.READ_NUMFLEXIUM))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.STOPREAD_NUMFLEXIUM))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.READ_NUMFLEXIUM))
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function InitOUTPUTS() As Boolean
|
||||
' fermo e riavvio lettura variabili per includere quelle della pagina input
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.STOPREAD_NUMFLEXIUM))
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.READ_NUMFLEXIUM))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.STOPREAD_NUMFLEXIUM))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.READ_NUMFLEXIUM))
|
||||
Map.refMainWindowVM.NotifyPropertyChanged(NameOf(Map.refMainWindowVM.nSelTabPage))
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Private Function ExitOUTPUTS() As Boolean
|
||||
' fermo e riavvio lettura variabili per includere quelle della pagina input
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.STOPREAD_NUMFLEXIUM))
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.READ_NUMFLEXIUM))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.STOPREAD_NUMFLEXIUM))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.READ_NUMFLEXIUM))
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ Public Class MainWindowVM
|
||||
Return
|
||||
End If
|
||||
' disconnetto comunicazione con macchina
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.DISCONNECT))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.DISCONNECT))
|
||||
' termino thread di comunicazione con Db ed altri programmi
|
||||
ViewerOptimizerCommThread.StopThread()
|
||||
' Verifico modifica parametri in Configurazione e chiedo il salvataggio
|
||||
|
||||
@@ -64,7 +64,7 @@ Public Class Variable
|
||||
Return CommVar.sValue
|
||||
End Get
|
||||
Set(value As String)
|
||||
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.WRITE, {CommVar.nType}, Nothing, {CommVar.sAddress, value}))
|
||||
MachManaging.AddToCommandList(ThreadCommand.CreateCommand(CommandTypes.WRITE, {CommVar.nType}, Nothing, {CommVar.sAddress, value}))
|
||||
NotifyPropertyChanged(NameOf(sValue))
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Reference in New Issue
Block a user