Files
egtbeamwall/EgtBEAMWALL.Supervisor/MachGroupPanel/SupervisorMachGroupPanelVM.vb
T
Emmanuele Sassi d611f66d43 Modifiche comunicazione tra Opt e Sup
Correzioni e migliorie
2021-08-02 15:32:39 +02:00

91 lines
3.1 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.IO
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5
Public Class SupervisorMachGroupPanelVM
Inherits MyMachGroupPanelVM
#Region "FIELDS & PROPERTIES"
' lock per aggiunta elemento a lista MachGroup
Private m_Lock_AddMachGroup As New Object
' Dictionari delle modifiche sui machgroup
' key => LastModificationIndex, LastFileLoadIndex
Private m_MachGroupFullList As New Dictionary(Of Integer, Integer())
Public Property MachGroupFullList As Dictionary(Of Integer, Integer())
Get
Return m_MachGroupFullList
End Get
Set(value As Dictionary(Of Integer, Integer()))
m_MachGroupFullList = value
End Set
End Property
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Sub New(MachGroupPanelM As MachGroupPanelM)
MyBase.New(MachGroupPanelM)
' riferimento su map
Map.SetRefSupervisorMachGroupPanelVM(Me)
BindingOperations.EnableCollectionSynchronization(m_MachGroupVMList, m_Lock_AddMachGroup)
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Public Sub AddMachGroupToSupervisor(MachGroup As MyMachGroupVM)
SyncLock (m_Lock_AddMachGroup)
MachGroupVMList.Add(MachGroup)
End SyncLock
' notifico stato
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Produce_IsEnabled))
End Sub
Public Sub ReloadProjectFile()
Map.refSceneHostVM.MainController.ResetModified()
Map.refSceneHostVM.MainController.OpenProject(Map.refSupervisorManagerVM.CurrProd.sProdPath, False)
RefreshSupervisorMachGroups(Map.refMachinePanelVM.MachineList.ToList())
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Public Shared Sub RefreshSupervisorMachGroups(MachineList As List(Of Machine))
' Carico i gruppi di lavorazione nella lista
Dim nId = EgtGetFirstMachGroup()
While nId <> GDB_ID.NULL
' se gia' presente, vado al prossimo
If Map.refMachGroupPanelVM.MachGroupVMList.Any(Function(x) x.Id = nId) Then Continue While
' altrimenti lo carico
EgtSetCurrMachGroup(nId)
Dim sName As String = String.Empty
Dim sMachine As String = String.Empty
EgtGetMachGroupName(nId, sName)
EgtGetMachGroupMachineName(nId, sMachine)
' cerco la macchina tra quelle presenti
Dim UsedMachine As MyMachine = Nothing
Dim bOk As Boolean = Machine.SearchMachine(sMachine, MachineList, UsedMachine)
If Not bOk OrElse UsedMachine.nType = MachineType.NULL Then
EgtOutLog("Machine incompatible with beam & wall machining!!")
ElseIf UsedMachine.nType = MachineType.BEAM Then
Map.refMachGroupPanelVM.m_MyMachGroupPanelM.AddMachGroup(BeamMachGroupM.CreateBeamMachGroup(nId, sName, sMachine))
ElseIf UsedMachine.nType = MachineType.WALL Then
Map.refMachGroupPanelVM.m_MyMachGroupPanelM.AddMachGroup(WallMachGroupM.CreateWallMachGroup(nId, sName, sMachine))
End If
nId = EgtGetNextMachGroup(nId)
End While
EgtResetCurrMachGroup()
End Sub
#End Region ' METHODS
End Class