diff --git a/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelVM.vb b/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelVM.vb index 4ca99c68..49ba993a 100644 --- a/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelVM.vb +++ b/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelVM.vb @@ -172,7 +172,7 @@ Public Class LeftPanelVM Return False ElseIf Not IsNothing(Map.refProjectVM.SupervisorMachGroupPanelVM.SelectedMachGroup) Then Dim SelMachgroup As MyMachGroupVM = DirectCast(Map.refProjectVM.SupervisorMachGroupPanelVM.SelectedMachGroup, MyMachGroupVM) - Return SelMachgroup.nProduction_State <= ItemState.Confirmed + Return SelMachgroup.nProduction_State <= ItemState.WIP Else Return m_LeftPanel_IsEnabled End If @@ -234,6 +234,7 @@ Public Class LeftPanelVM Public ReadOnly Property DonePart_Visibility As Visibility Get + ' per test -> 'Return Visibility.Visible Return If(Not IsNothing(Map.refSupervisorManagerVM.CurrProd) AndAlso Map.refSupervisorManagerVM.CurrProd.nType = BWType.BEAM, Visibility.Visible, Visibility.Collapsed) End Get End Property @@ -392,8 +393,9 @@ Public Class LeftPanelVM ''' Public Sub ProduceAll() If IsNothing(Map.refSupervisorManagerVM.CurrProd) Then Return - If IsNothing(Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.Count = 0) Then Return - If Not Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.Any(Function(x As MyMachGroupVM) x.nProduction_State <= 1) Then Return + If IsNothing(Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList) OrElse Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.Count = 0 Then Return + If Not Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.Any(Function(x As MyMachGroupVM) x.nProduction_State <= ItemState.Confirmed) Then Return + If Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.Any(Function(x As MyMachGroupVM) x.dtStartTime <> DateTime.MinValue) Then Return Dim ToDoList As List(Of MachGroupVM) = Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.Where(Function(x As MyMachGroupVM) x.nProduction_State <= 1 AndAlso Not x.bResetWhileCutting AndAlso x.dtStartTime = DateTime.MinValue AndAlso Not x.bToBeProduced).ToList() If Not IsNothing(ToDoList) AndAlso ToDoList.Count > 0 Then MyMachGroupVM.Produce(ToDoList) @@ -422,14 +424,21 @@ Public Class LeftPanelVM Public Sub DoneRawPart() If IsNothing(Map.refSupervisorManagerVM.CurrProd) Then Return If IsNothing(Map.refProjectVM.SupervisorMachGroupPanelVM.SelectedMachGroup) Then Return - If (Not IsNothing(Map.refMachManaging) AndAlso Map.refMachManaging.bConnected AndAlso m_SelOPState.Id <> OPStates.End) OrElse - Map.refSupervisorMachGroupPanelVM.MachGroupVMList.Any(Function(x As MyMachGroupVM) x.bToBeProduced) Then Return Dim SelMachGroup As MyMachGroupVM = Map.refProjectVM.SupervisorMachGroupPanelVM.SelectedMachGroup + If (Not IsNothing(Map.refMachManaging) AndAlso Map.refMachManaging.bConnected AndAlso m_SelOPState.Id <> OPStates.End) OrElse + Map.refSupervisorMachGroupPanelVM.MachGroupVMList.Any(Function(x As MyMachGroupVM) (x.bToBeProduced AndAlso x.Id <> SelMachGroup.Id) OrElse + (x.nProduction_State = ItemState.WIP AndAlso x.Id <> SelMachGroup.Id) OrElse + (x.dtStartTime <> DateTime.MinValue AndAlso x.dtEndTime = DateTime.MinValue AndAlso x.Id <> SelMachGroup.Id)) Then Return ' scrivo tutti pezzi completati For PartIndex = 0 To SelMachGroup.PartVMList.Count - 1 Dim Part As PartVM = SelMachGroup.PartVMList(PartIndex) SetDonePart(SelMachGroup, Part) Next + ' aggiorno bottoni + NotifyPropertyChanged(NameOf(DeleteRawPart_IsEnabled)) + NotifyPropertyChanged(NameOf(DoneRawPart_IsEnabled)) + NotifyPropertyChanged(NameOf(MoveRawPart_IsEnabled)) + NotifyPropertyChanged(NameOf(ResetRawPart_IsEnabled)) ' se avanzamento singolo, sblocco produzione di tutti gli altri If CurrentMachine.Flow = FlowTypes.ONEBYONE Then MyMachGroupVM.UpdateProduceIsEnabledForAll() @@ -543,6 +552,11 @@ Public Class LeftPanelVM 'SelMachGroup.NotifyPropertyChanged(NameOf(SelMachGroup.Production_Background)) 'SelMachGroup.NotifyPropertyChanged(NameOf(SelMachGroup.Produce_IsEnabled)) + ' aggiorno bottoni + NotifyPropertyChanged(NameOf(DeleteRawPart_IsEnabled)) + NotifyPropertyChanged(NameOf(DoneRawPart_IsEnabled)) + NotifyPropertyChanged(NameOf(MoveRawPart_IsEnabled)) + NotifyPropertyChanged(NameOf(ResetRawPart_IsEnabled)) ' se avanzamento singolo, sblocco produzione di tutti gli altri If CurrentMachine.Flow = FlowTypes.ONEBYONE Then MyMachGroupVM.UpdateProduceIsEnabledForAll() @@ -727,6 +741,13 @@ Public Class LeftPanelVM MachGroup.nProduction_State = ItemState.Produced MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Production_Background)) MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Produce_IsEnabled)) + ' reset delle variabili di invio alla macchina + MachGroup.ResetProduce() + ' aggiorno bottoni + NotifyPropertyChanged(NameOf(DeleteRawPart_IsEnabled)) + NotifyPropertyChanged(NameOf(DoneRawPart_IsEnabled)) + NotifyPropertyChanged(NameOf(MoveRawPart_IsEnabled)) + NotifyPropertyChanged(NameOf(ResetRawPart_IsEnabled)) ' se avanzamento singolo, sblocco produzione di tutti gli altri If CurrentMachine.Flow = FlowTypes.ONEBYONE Then MyMachGroupVM.UpdateProduceIsEnabledForAll() diff --git a/EgtBEAMWALL.Supervisor/MachGroupPanel/MyMachGroupVM.vb b/EgtBEAMWALL.Supervisor/MachGroupPanel/MyMachGroupVM.vb index a8a1fc5d..711c7e75 100644 --- a/EgtBEAMWALL.Supervisor/MachGroupPanel/MyMachGroupVM.vb +++ b/EgtBEAMWALL.Supervisor/MachGroupPanel/MyMachGroupVM.vb @@ -106,6 +106,7 @@ Public Class MyMachGroupVM CurrMachGroup.NotifyPropertyChanged(NameOf(CurrMachGroup.Produce_IsEnabled)) Next End Sub + #End Region ' Machgroup #Region "Parts" @@ -271,6 +272,11 @@ Public Class MyMachGroupVM For Each MachGroup As MyMachGroupVM In MachGroupList ' cerco primo indice di pezzo non in produzione Dim NewIndex As Integer = Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.IndexOf(Map.refProjectVM.SupervisorMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) DirectCast(x, MyMachGroupVM).dtStartTime = DateTime.MinValue AndAlso DirectCast(x, MyMachGroupVM).bToBeProduced = False)) + ' se pezzo da produrre gia' iniziato + If MachGroup.dtStartTime <> DateTime.MinValue Then + ' decremento indice di 1 + NewIndex -= 1 + End If ' segno pezzo da produrre MachGroup.m_bToBeProduced = True MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Production_Background)) diff --git a/EgtBEAMWALL.Supervisor/MainWindow/MainWindowVM.vb b/EgtBEAMWALL.Supervisor/MainWindow/MainWindowVM.vb index 30cf25b8..c824b2e0 100644 --- a/EgtBEAMWALL.Supervisor/MainWindow/MainWindowVM.vb +++ b/EgtBEAMWALL.Supervisor/MainWindow/MainWindowVM.vb @@ -192,14 +192,20 @@ Public Class MainWindowVM ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub CloseApplication() + ' se macchina sta funzionando + If Not IsNothing(Map.refMachManaging) AndAlso Map.refMachManaging.bConnected AndAlso + (Map.refLeftPanelVM.SelOPState.Id <> OPStates.End AndAlso Map.refLeftPanelVM.SelOPState.Id <> OPStates.Unspecified) Then + MessageBox.Show("Impossible closing software while machine is working. If you want to close, first press reset and stop the machine!", "Error", MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If ' disconnetto comunicazione con macchina MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.DISCONNECT)) - ' termino thread di comunicazione con Db ed altri programmi - ViewerOptimizerCommThread.StopThread() - ' Verifico modifica parametri in Configurazione e chiedo il salvataggio - If Map.refMainMenuVM.SelPage = Pages.CONFIG Then Map.refConfigurationPageVM.VerifyConfigPageModification() - ' Chiudo la finestra principale del programma - Application.Current.MainWindow.Close() + ' termino thread di comunicazione con Db ed altri programmi + ViewerOptimizerCommThread.StopThread() + ' Verifico modifica parametri in Configurazione e chiedo il salvataggio + If Map.refMainMenuVM.SelPage = Pages.CONFIG Then Map.refConfigurationPageVM.VerifyConfigPageModification() + ' Chiudo la finestra principale del programma + Application.Current.MainWindow.Close() End Sub #End Region ' CloseApplication diff --git a/EgtBEAMWALL.ViewerOptimizer/SupervisorCommThread/SupervisorComm.vb b/EgtBEAMWALL.ViewerOptimizer/SupervisorCommThread/SupervisorComm.vb index 67bf75be..750348f7 100644 --- a/EgtBEAMWALL.ViewerOptimizer/SupervisorCommThread/SupervisorComm.vb +++ b/EgtBEAMWALL.ViewerOptimizer/SupervisorCommThread/SupervisorComm.vb @@ -33,13 +33,13 @@ Public Class SupervisorComm Dim bReloadFile As Boolean = False For Each MachGroupModification In MachGroupList If MachGroupModification.ItemType = StatusMapItemType.Part Then - Dim Part As BTLPartVM = CALCPanelVM.GetBTLPartVMFromPartId(MachGroupModification.ItemId) + Dim BTLPart As BTLPartVM = CALCPanelVM.GetBTLPartVMFromPartId(MachGroupModification.ItemId) Select Case MachGroupModification.Operation Case Core.StatusMapOpType.PartStart ' non faccio nulla - Case Core.StatusMapOpType.PartEnd - Part.NotifyPropertyChanged(NameOf(Part.nDONE)) - Part.NotifyPropertyChanged(NameOf(Part.Background)) + Case Core.StatusMapOpType.PartEnd, StatusMapOpType.ResetPartStart, StatusMapOpType.ResetPartEnd + BTLPart.NotifyPropertyChanged(NameOf(BTLPart.nDONE)) + BTLPart.NotifyPropertyChanged(NameOf(BTLPart.Background)) End Select ElseIf MachGroupModification.ItemType = StatusMapItemType.Comm Then ' se arriva richiesta da supervisore di blocco e salvataggio @@ -103,6 +103,7 @@ Public Class SupervisorComm MachGroup.ResetSupervisorId() End Select 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 @@ -113,6 +114,8 @@ Public Class SupervisorComm Part.dtEndTime = MachGroupModification.DtEvent Part.nProduction_State = ItemState.Produced Part.NotifyPropertyChanged(NameOf(Part.Background)) + BTLPart.NotifyPropertyChanged(NameOf(BTLPart.nDONE)) + BTLPart.NotifyPropertyChanged(NameOf(BTLPart.Background)) Case Core.StatusMapOpType.ResetPartStart Part.dtStartTime = DateTime.MinValue Part.nProduction_State = ItemState.Assigned @@ -121,6 +124,8 @@ Public Class SupervisorComm Part.dtEndTime = DateTime.MinValue Part.nProduction_State = ItemState.WIP Part.NotifyPropertyChanged(NameOf(Part.Background)) + BTLPart.NotifyPropertyChanged(NameOf(BTLPart.nDONE)) + BTLPart.NotifyPropertyChanged(NameOf(BTLPart.Background)) End Select ElseIf MachGroupModification.ItemType = StatusMapItemType.Comm Then ' se arriva richiesta da supervisore di blocco e salvataggio