Files
Demetrio Cassarino b10cfb3913 Optmizer 3.0.1.5
-sistemata grafica progressbar per verifica
-aggiunto creazione btlinfo nuovo progetto
-aggiunto reset feature
-sistemato creazione pdf
2026-01-23 11:18:35 +01:00

165 lines
9.3 KiB
VB.net

Imports EgtBEAMWALL.Core
Imports EgtBEAMWALL.DataLayer.DatabaseModels
Public Class SupervisorComm
Private m_BlockedWnd As BlockedWndV
Private m_bTickInExecution As Boolean = False
Private m_CurrSession_ProdId As Integer = 0
Private m_CurrSession_Index As Integer = 0
Sub New()
End Sub
Friend Sub Timer_Tick()
If m_bTickInExecution Then
EgtUILib.EgtOutLog("Tick gia' in esecuzione!!")
Return
End If
m_bTickInExecution = True
' se arriva info di cambio progetto
Dim ActiveSessionList As List(Of StatusMapModel) = DbControllers.m_StatusMapController.GetProd(m_SupervisorId)
Dim MySession As StatusMapModel = ActiveSessionList.FirstOrDefault(Function(x) x.Session = DbControllers.m_SupervisorId)
If Not IsNothing(MySession) Then
If m_CurrSession_ProdId <> MySession.ItemId OrElse MySession.Index < m_CurrSession_Index Then
m_CurrSession_ProdId = MySession.ItemId
m_CurrSession_Index = MySession.Index
End If
If MySession.Index > m_CurrSession_Index Then
' recupero elementi modificati
Dim MessagesList As List(Of StatusMapModel) = DbControllers.m_StatusMapController.GetFrom(m_SupervisorId, m_CurrSession_Index + 1)
For Each Message In MessagesList
Select Case Message.ItemType
Case StatusMapItemType.Comm
Select Case Message.Operation
Case StatusMapOpType.OpenPageInViewOptimRequest
Map.refMainMenuVM.OpenPageFromSupervisor(Math.Abs(Message.ItemId))
Case StatusMapOpType.ChangeProdInOptimizerRequest
Map.refProdManagerVM.OpenProjectFromSupervisor(Message.ItemId)
End Select
End Select
Next
m_CurrSession_Index = MySession.Index
End If
End If
' se sono in pagina ottimizzatore
If Map.refMainMenuVM.SelPage = Pages.OPTIMIZERPAGE Then
' se non c'e' un progetto attivo, esco
If IsNothing(ProjectManagerVM.CurrProd) Then
m_bTickInExecution = False
Return
End If
' verifico se c'e' una sessione aperta sul progetto corrente
Dim nModificationIndex As Integer = -1
ActiveSessionList = DbControllers.m_StatusMapController.GetProd(m_SupervisorId)
For Each ActiveSession In ActiveSessionList
If Not IsNothing(ProjectManagerVM.CurrProd) AndAlso ActiveSession.ItemId = ProjectManagerVM.CurrProd.nProdId Then
nModificationIndex = ActiveSession.Index
End If
Next
If nModificationIndex = -1 Then
m_bTickInExecution = False
Return
End If
' verifico se ci sono modifiche
If nModificationIndex <> ProjectManagerVM.CurrProd.nModificationIndex Then
' recupero elementi modificati
Dim MachGroupList As List(Of StatusMapModel) = DbControllers.m_StatusMapController.GetFrom(m_SupervisorId, ProjectManagerVM.CurrProd.nModificationIndex + 1)
If Not IsNothing(MachGroupList) Then
Dim bReloadFile As Boolean = False
For Each MachGroupModification In MachGroupList
If MachGroupModification.ItemType = StatusMapItemType.MachGroup Then
Dim MachGroup As MyMachGroupVM = Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) x.Id = MachGroupModification.ItemId)
If Not IsNothing(MachGroup) Then
Select Case MachGroupModification.Operation
Case Core.StatusMapOpType.PartStart
MachGroup.dtStartTime = MachGroupModification.DtEvent
MachGroup.nProduction_State = ItemState.WIP
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.nProduction_State))
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Background))
Case Core.StatusMapOpType.PartEnd
MachGroup.dtEndTime = MachGroupModification.DtEvent
MachGroup.nProduction_State = ItemState.Produced
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Background))
Case Core.StatusMapOpType.ResetPartStart
MachGroup.dtStartTime = DateTime.MinValue
MachGroup.nProduction_State = ItemState.Assigned
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.nProduction_State))
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Background))
Case Core.StatusMapOpType.ResetPartEnd
MachGroup.dtEndTime = DateTime.MinValue
MachGroup.nProduction_State = ItemState.WIP
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.nProduction_State))
MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Background))
Case Core.StatusMapOpType.MachGroupRemovedFromSupervisor
MachGroup.ResetSupervisorId()
Case Core.StatusMapOpType.MachGroupValidationUpdate
CALCPanelVM.ProcessResults(MachGroup)
End Select
End If
ElseIf MachGroupModification.ItemType = StatusMapItemType.Part Then
Dim BTLPart As BTLPartVM = CALCPanelVM.GetBTLPartVMFromPartId(MachGroupModification.ItemId)
Dim Part As PartVM = CALCPanelVM.GetPartVMFromPartId(MachGroupModification.ItemId)
Select Case MachGroupModification.Operation
Case Core.StatusMapOpType.PartStart
If Not IsNothing(Part) Then
Part.dtStartTime = MachGroupModification.DtEvent
Part.nProduction_State = ItemState.WIP
Part.NotifyPropertyChanged(NameOf(Part.Background))
End If
Case Core.StatusMapOpType.PartEnd
If Not IsNothing(Part) Then
Part.dtEndTime = MachGroupModification.DtEvent
Part.nProduction_State = ItemState.Produced
Part.NotifyPropertyChanged(NameOf(Part.Background))
End If
If Not IsNothing(BTLPart) Then
BTLPart.NotifyPropertyChanged(NameOf(BTLPart.nDONE))
BTLPart.NotifyPropertyChanged(NameOf(BTLPart.Background))
End If
Case Core.StatusMapOpType.ResetPartStart
If Not IsNothing(Part) Then
Part.dtStartTime = DateTime.MinValue
Part.nProduction_State = ItemState.Assigned
Part.NotifyPropertyChanged(NameOf(Part.Background))
End If
Case Core.StatusMapOpType.ResetPartEnd
If Not IsNothing(Part) Then
Part.dtEndTime = DateTime.MinValue
Part.nProduction_State = ItemState.WIP
Part.NotifyPropertyChanged(NameOf(Part.Background))
End If
If Not IsNothing(BTLPart) Then
BTLPart.NotifyPropertyChanged(NameOf(BTLPart.nDONE))
BTLPart.NotifyPropertyChanged(NameOf(BTLPart.Background))
End If
Case Core.StatusMapOpType.SetPartScrapped
If Not IsNothing(Part) Then
Part.nProduction_State = ItemState.Scrapped
Part.NotifyPropertyChanged(NameOf(Part.Background))
End If
End Select
ElseIf MachGroupModification.ItemType = StatusMapItemType.Comm Then
' se arriva richiesta da supervisore di blocco e salvataggio
Select Case MachGroupModification.Operation
Case StatusMapOpType.SupervisorStopRequest
' blocco interfaccia fino a notifica di sblocco
SupervisorCommThread.SetViewerOptimizerBlocked(True)
Case StatusMapOpType.SupervisorReleaseStop
Dim MachGroupId As Integer = -1
If Not String.IsNullOrWhiteSpace(MachGroupModification.Val) Then Integer.TryParse(MachGroupModification.Val, MachGroupId)
If IsNothing(MachGroupId) Then MachGroupId = -1
SupervisorCommThread.SetViewerOptimizerBlocked(False, MachGroupId)
End Select
End If
Next
End If
' aggiorno indice del prod
ProjectManagerVM.CurrProd.SetModificationIndex(nModificationIndex)
End If
End If
m_bTickInExecution = False
End Sub
End Class