Files
egtbeamwall/EgtBEAMWALL.ViewerOptimizer/TopPanel/TopPanelVM.vb
T
Emmanuele Sassi ee558cecd6 - Migliorie Calc pezzi
- Correzione flip e rot dei duplo
- Cambiata gestione ricalcolo in supervisore
- Aggiunti controlli su comunicazione tra programmi
- Gestione apertura progetto con s/blocco duplo
- Gestione errore ricalcolo in supervisore
- Aggiunti controlli su cicli di comunicazione tra programmi
2022-02-03 21:49:05 +01:00

477 lines
16 KiB
VB.net

Imports System.Collections.ObjectModel
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5
Public Class TopPanelVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Private Property m_GridDims As New ObservableCollection(Of GridDimension)
Public Property GridDims As ObservableCollection(Of GridDimension)
Get
Return m_GridDims
End Get
Set
m_GridDims = Value
NotifyPropertyChanged(NameOf(GridDims))
End Set
End Property
Friend Enum Tabs As Integer
OPTIMIZATION = 0
STATISTICS = 1
End Enum
Private m_SelTab As Tabs = Tabs.OPTIMIZATION
Public Property SelTab As Integer
Get
Return m_SelTab
End Get
Set(value As Integer)
m_SelTab = value
End Set
End Property
Friend Sub SetSelTab(SelTab As Tabs)
If m_SelTab = Tabs.STATISTICS Then
Map.refInstrumentPanelVM.SetStatisticsIsChecked(False)
End If
m_SelTab = SelTab
NotifyPropertyChanged(NameOf(SelTab))
End Sub
Private m_TopPanel_IsEnabled As Boolean = True
Public ReadOnly Property TopPanel_IsEnabled As Boolean
Get
Return m_TopPanel_IsEnabled
End Get
End Property
Public ReadOnly Property QParameter_Visibility As Visibility
Get
Return If(Not IsNothing(Map.refProjectVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
' Definizione comandi
Private m_cmdProduceAllRawPart As ICommand
Private m_cmdProduceRawPart As ICommand
Private m_cmdCopyRawPart As ICommand
Private m_cmdRemoveRawPart As ICommand
Private m_cmdRemovePart As ICommand
Private m_cmdMoveUpPart As ICommand
Private m_cmdMoveDownPart As ICommand
Private m_cmdReOrderPart As ICommand
Public ReadOnly Property MovePart_Visibility As Visibility
Get
If Not IsNothing(Map.refProjectVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) Then
Return If(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM, Visibility.Visible, Visibility.Collapsed)
End If
Return Visibility.Collapsed
End Get
End Property
#Region "Messages"
Public ReadOnly Property ProduceRawPart_ToolTip As String
Get
Return EgtMsg(61912)
End Get
End Property
Public ReadOnly Property ResetCALCRawPart_ToolTip As String
Get
Return EgtMsg(61924)
End Get
End Property
Public ReadOnly Property ProduceAllRawPart_ToolTip As String
Get
Return EgtMsg(61913)
End Get
End Property
Public ReadOnly Property CopyRawPart_ToolTip As String
Get
Return EgtMsg(61914)
End Get
End Property
Public ReadOnly Property RemoveRawPart_ToolTip As String
Get
Return EgtMsg(61915)
End Get
End Property
Public ReadOnly Property ReOrderPart_ToolTip As String
Get
Return EgtMsg(61916)
End Get
End Property
Public ReadOnly Property MoveUpPart_ToolTip As String
Get
Return EgtMsg(61917)
End Get
End Property
Public ReadOnly Property MoveDownPart_ToolTip As String
Get
Return EgtMsg(61918)
End Get
End Property
Public ReadOnly Property RemovePart_ToolTip As String
Get
Return EgtMsg(61919)
End Get
End Property
#End Region ' Messages
#End Region 'FIELDS & PROPERTIES
Sub New()
' imposto riferimento su mappa
Map.SetRefTopPanelVM(Me)
' imposto dimensioni colonne/righe della Grid
DimensionsIniFile.ReadGridDimensions(ConstDims.TOPPANEL_OPTIMIZER, GridDims)
End Sub
#Region "METHODS"
Friend Sub SetTopPanelIsEnabled(bIsEnabled As Boolean)
m_TopPanel_IsEnabled = bIsEnabled
NotifyPropertyChanged(NameOf(TopPanel_IsEnabled))
End Sub
Friend Sub UpdateQParameterVisibility()
NotifyPropertyChanged(NameOf(QParameter_Visibility))
End Sub
#End Region ' METHODS
#Region "COMMANDS"
#Region "ProduceRawPart"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property ProduceRawPart_Command As ICommand
Get
If m_cmdProduceRawPart Is Nothing Then
m_cmdProduceRawPart = New Command(AddressOf ProduceRawPart)
End If
Return m_cmdProduceRawPart
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub ProduceRawPart()
If IsNothing(Map.refProdManagerVM.CurrProd) Then Return
Dim ErrorMsg As String = ""
If Not Produce(Map.refMachGroupPanelVM.SelectedMachGroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then
MessageBox.Show(ErrorMsg)
End If
End Sub
Private Function Produce(MachGroup As MyMachGroupVM, ByRef ErrorMsg As String) As Boolean
If IsNothing(MachGroup) Then Return False
' se barra gia' assegnata a supervisore, esco
If MachGroup.nProduction_State >= ItemState.Assigned Then Return False
If MachGroup.nGlobalState = CalcStates.OK Or MachGroup.nGlobalState = CalcStates.INFO Then
' se ci sono modifiche, salvo il pogetto
If EgtGetModified() Then
Map.refProdManagerVM.Save()
End If
' mando al supervisore
DbControllers.m_MachGroupController.UpdateSupervisor(Map.refProdManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_SupervisorId)
DbControllers.m_MachGroupController.UpdateOrder(Map.refProdManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_MachGroupController.GetMinIndex(Map.refProdManagerVM.CurrProd.nProdId) + 1)
MachGroup.SentToSupervisor()
For Each Part As PartVM In MachGroup.PartVMList
DbControllers.m_PartController.UpdateStatus(Map.refProdManagerVM.CurrProd.nProdId, MachGroup.Id, Part.nPartId, ItemState.Assigned)
Part.nProduction_State = ItemState.Assigned
Part.NotifyPropertyChanged(NameOf(Part.Background))
' blocco modifica del pezzo
EgtDuploSetLocked(Part.nPartId)
Next
Else
ErrorMsg = String.Format("Impossible sending {0} to supervisor because not machinable!", MachGroup.Name)
'MessageBox.Show(String.Format("Impossible sending {0} to supervisor because it is not machinable!", MachGroup.Name))
End If
End Function
#End Region ' ProduceRawPart
#Region "ProduceAllRawPart"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property ProduceAllRawPart_Command As ICommand
Get
If m_cmdProduceAllRawPart Is Nothing Then
m_cmdProduceAllRawPart = New Command(AddressOf ProduceAllRawPart)
End If
Return m_cmdProduceAllRawPart
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub ProduceAllRawPart()
If IsNothing(Map.refProdManagerVM.CurrProd) Then Return
If Map.refMachGroupPanelVM.MachGroupVMList.Count > 0 Then
Dim MachgroupErrorList As New List(Of MachGroupVM)
For Each Machgroup In Map.refMachGroupPanelVM.MachGroupVMList
Dim ErrorMsg As String = ""
If Not Produce(Machgroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then
MachgroupErrorList.Add(Machgroup)
End If
Next
If MachgroupErrorList.Count > 0 Then
Dim sMachGroups As String = ""
For Each MachGroup In MachgroupErrorList
sMachGroups &= " " & MachGroup.Name & ","
Next
sMachGroups = sMachGroups.Trim({" "c, ","c})
MessageBox.Show(String.Format("Impossible sending {0} to supervisor because not machinable!", sMachGroups))
End If
End If
End Sub
#End Region ' ProduceAllRawPart
#Region "CopyRawPart"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property CopyRawPart_Command As ICommand
Get
If m_cmdCopyRawPart Is Nothing Then
m_cmdCopyRawPart = New Command(AddressOf CopyRawPart)
End If
Return m_cmdCopyRawPart
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub CopyRawPart()
If IsNothing(Map.refProdManagerVM.CurrProd) Then Return
Dim nQty As Integer = 1
' se premuto shift
If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then
Dim MultiCopyRawPartWndVM As New MultiCopyRawPartWndVM()
Dim MultiCopyRawPartWnd As New MultiCopyRawPartWndV(Application.Current.MainWindow, MultiCopyRawPartWndVM)
If Not MultiCopyRawPartWnd.ShowDialog() Then Return
nQty = MultiCopyRawPartWndVM.nQuantity
End If
Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup
If IsNothing(SelMachGroup) Then Return
' creo copia
Dim NewMachGroup As MyMachGroupVM = SelMachGroup.Copy(nQty)
If Not IsNothing(NewMachGroup) Then
' lo seleziono
Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup = NewMachGroup
End If
End Sub
#End Region ' CopyRawPart
#Region "RemoveRawPart"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property RemoveRawPart_Command As ICommand
Get
If m_cmdRemoveRawPart Is Nothing Then
m_cmdRemoveRawPart = New Command(AddressOf RemoveRawPart)
End If
Return m_cmdRemoveRawPart
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub RemoveRawPart()
If IsNothing(Map.refProdManagerVM.CurrProd) Then Return
' se premuto shift
If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then
' cancello tutti
For Index = Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 To 0 Step -1
Dim CurrMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(Index)
' se barra gia' assegnata a supervisore, esco
If CurrMachGroup.nProduction_State >= ItemState.Assigned Then Continue For
CurrMachGroup.DeleteMachGroup()
Next
Else
Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup
If IsNothing(SelMachGroup) Then Return
' se barra gia' assegnata a supervisore, esco
If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return
SelMachGroup.DeleteMachGroup()
End If
' se nessun grezzo, rimetto tutti i pezzi invisibili
If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then
Map.refProjectVM.BTLStructureVM.HideAll(True)
End If
End Sub
#End Region ' RemoveRawPart
#Region "RemovePart"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property RemovePart_Command As ICommand
Get
If m_cmdRemovePart Is Nothing Then
m_cmdRemovePart = New Command(AddressOf RemovePart)
End If
Return m_cmdRemovePart
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub RemovePart()
If IsNothing(Map.refProdManagerVM.CurrProd) Then Return
Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup
If IsNothing(SelMachGroup) Then Return
' se barra gia' assegnata a supervisore, esco
If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return
Dim SelPart As PartVM = SelMachGroup.SelPart
If IsNothing(SelPart) Then Return
SelPart.DeletePart()
SelMachGroup.UpdateUsage()
SelMachGroup.ResetCalcMachGroup()
End Sub
#End Region ' RemovePart
#Region "MoveUpPart"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property MoveUpPart_Command As ICommand
Get
If m_cmdMoveUpPart Is Nothing Then
m_cmdMoveUpPart = New Command(AddressOf MoveUpPart)
End If
Return m_cmdMoveUpPart
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub MoveUpPart()
If IsNothing(Map.refProdManagerVM.CurrProd) Then Return
Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup
If IsNothing(SelMachGroup) Then Return
' se barra gia' assegnata a supervisore, esco
If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return
Dim SelPart As PartVM = SelMachGroup.SelPart
If IsNothing(SelPart) Then Return
If SelMachGroup.nType = MachineType.BEAM Then
SelMachGroup.MoveBeam(SelPart, MoveDirections.UP)
EgtDraw()
' riseleziono trave
SelMachGroup.SelPart = SelPart
End If
SelMachGroup.ResetCalcMachGroup()
End Sub
#End Region ' MoveUpPart
#Region "MoveDownPart"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property MoveDownPart_Command As ICommand
Get
If m_cmdMoveDownPart Is Nothing Then
m_cmdMoveDownPart = New Command(AddressOf MoveDownPart)
End If
Return m_cmdMoveDownPart
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub MoveDownPart()
If IsNothing(Map.refProdManagerVM.CurrProd) Then Return
Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup
If IsNothing(SelMachGroup) Then Return
' se barra gia' assegnata a supervisore, esco
If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return
Dim SelPart As PartVM = SelMachGroup.SelPart
If IsNothing(SelPart) Then Return
If SelMachGroup.nType = MachineType.BEAM Then
SelMachGroup.MoveBeam(SelPart, MoveDirections.DOWN)
EgtDraw()
' riseleziono trave
SelMachGroup.SelPart = SelPart
End If
SelMachGroup.ResetCalcMachGroup()
End Sub
#End Region ' MoveDownPart
#Region "ReOrderPart"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
Public ReadOnly Property ReOrderPart_Command As ICommand
Get
If m_cmdReOrderPart Is Nothing Then
m_cmdReOrderPart = New Command(AddressOf ReOrderPart)
End If
Return m_cmdReOrderPart
End Get
End Property
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub ReOrderPart()
If IsNothing(Map.refProdManagerVM.CurrProd) Then Return
Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup
If IsNothing(SelMachGroup) Then Return
' se barra gia' assegnata a supervisore, esco
If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return
Dim SelPart As PartVM = SelMachGroup.SelPart
If IsNothing(SelPart) Then Return
If SelMachGroup.nType = MachineType.BEAM Then
SelMachGroup.ReorderBeam()
' riseleziono trave
If Not IsNothing(SelPart) AndAlso (IsNothing(SelMachGroup.SelPart) OrElse SelPart.nPartId <> SelMachGroup.SelPart.nPartId) Then
SelMachGroup.SelPart = SelPart
End If
End If
SelMachGroup.ResetCalcMachGroup()
End Sub
#End Region ' ReOrderPart
#End Region ' COMMANDS
End Class