272 lines
10 KiB
VB.net
272 lines
10 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class OptimizePanelVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Friend Enum PartType As Integer
|
|
MATERIAL = 0
|
|
ALL = 1
|
|
End Enum
|
|
|
|
Friend Enum OriginType As Integer
|
|
STANDARD = 0
|
|
FROM_BTL = 1
|
|
End Enum
|
|
|
|
Private m_PartTypeList As New List(Of IdNameStruct)({New IdNameStruct(PartType.MATERIAL, "Materiale"),
|
|
New IdNameStruct(PartType.ALL, "Tutti")})
|
|
Public ReadOnly Property PartTypeList As List(Of IdNameStruct)
|
|
Get
|
|
Return m_PartTypeList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelPartType As IdNameStruct
|
|
Public Property SelPartType As IdNameStruct
|
|
Get
|
|
Return m_SelPartType
|
|
End Get
|
|
Set(value As IdNameStruct)
|
|
m_SelPartType = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_OriginTypeList As New List(Of IdNameStruct)({New IdNameStruct(OriginType.STANDARD, "Standard"),
|
|
New IdNameStruct(OriginType.FROM_BTL, "Da BTL")})
|
|
Public ReadOnly Property OriginTypeList As List(Of IdNameStruct)
|
|
Get
|
|
Return m_OriginTypeList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SelOriginType As IdNameStruct
|
|
Public Property SelOriginType As IdNameStruct
|
|
Get
|
|
Return m_SelOriginType
|
|
End Get
|
|
Set(value As IdNameStruct)
|
|
m_SelOriginType = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_OptimizePanel_IsEnabled As Boolean = True
|
|
Public ReadOnly Property OptimizePanel_IsEnabled As Boolean
|
|
Get
|
|
Return m_OptimizePanel_IsEnabled
|
|
End Get
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property Optimize_Msg As String
|
|
Get
|
|
Return EgtMsg(61833)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Warehouse_ToolTip As String
|
|
Get
|
|
Return EgtMsg(61920)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' Definizione comandi
|
|
Private m_cmdOptimize As ICommand
|
|
Private m_cmdWarehouse As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' aggiungo riferimento a Map
|
|
Map.SetRefOptimizePanelVM(Me)
|
|
m_SelPartType = PartTypeList(0)
|
|
m_SelOriginType = OriginTypeList(0)
|
|
NotifyPropertyChanged(NameOf(SelPartType))
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub SetOptimizePanelIsEnabled(bIsEnabled As Boolean)
|
|
m_OptimizePanel_IsEnabled = bIsEnabled
|
|
NotifyPropertyChanged(NameOf(OptimizePanel_IsEnabled))
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "Optimize"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Open.
|
|
''' </summary>
|
|
Public ReadOnly Property Optimize_Command As ICommand
|
|
Get
|
|
If m_cmdOptimize Is Nothing Then
|
|
m_cmdOptimize = New Command(AddressOf Optimize)
|
|
End If
|
|
Return m_cmdOptimize
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Open. This method is invoked by the OpenCommand.
|
|
''' </summary>
|
|
Friend Sub Optimize()
|
|
If IsNothing(m_SelPartType) OrElse IsNothing(m_SelOriginType) Then Return
|
|
If IsNothing(Map.refProjectVM.BTLStructureVM) OrElse IsNothing(Map.refProjectVM.BTLStructureVM.BTLPartVMList) OrElse Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count = 0 Then Return
|
|
Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt"
|
|
Dim dSectionTime As Double = GetMainPrivateProfileDouble(S_NEST, K_SECTIONTIME, 1)
|
|
Dim dPartTime As Double = GetMainPrivateProfileDouble(S_NEST, K_PARTTIME, 1)
|
|
Dim dTotSectionTime As Double = 0
|
|
Dim dTotPartTime As Double = 0
|
|
Dim SectionList As New List(Of SParam)
|
|
' disabilito interfaccia
|
|
Map.refProjectVM.SetCalcRunning(True)
|
|
' se ho selezionato nest per materiale e c'è una sezione selezionata diversa da sezione nulla
|
|
If m_SelPartType.Id = PartType.MATERIAL AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelSection) AndAlso Map.refProjectVM.BTLStructureVM.SelSection.dH <> -1 Then
|
|
SectionList.Add(New SParam(Map.refProjectVM.BTLStructureVM.SelSection, 0, 0))
|
|
dTotSectionTime = dSectionTime
|
|
dTotPartTime = dPartTime * Map.refProjectVM.BTLStructureVM.BTLPartVMList.Sum(Function(x) If(x.bDO AndAlso x.Section = SectionList(0).SectXMat, 1, 0))
|
|
Else
|
|
' altrimenti prendo tutte le sezioni
|
|
For Each CurrSection In Map.refProjectVM.BTLStructureVM.SectionList
|
|
If CurrSection.dH = -1 Then Continue For
|
|
SectionList.Add(New SParam(CurrSection, 0, 0))
|
|
dTotSectionTime += dSectionTime
|
|
Next
|
|
dTotPartTime = dPartTime * Map.refProjectVM.BTLStructureVM.BTLPartVMList.Sum(Function(x) If(x.bDO AndAlso SectionList.Any(Function(y) y.SectXMat = x.Section), 1, 0))
|
|
End If
|
|
' apro finestra di attesa nesting
|
|
Dim NestingRunninWndVM As New NestingRunningWndVM(SectionList, dTotSectionTime + dTotPartTime)
|
|
Dim NestingRunningWnd As New NestingRunningWndV(Application.Current.MainWindow, NestingRunninWndVM)
|
|
NestingRunningWnd.ShowDialog()
|
|
'' recupero parametri di calcolo
|
|
'Dim dRawL As Double = 0
|
|
'Dim dRawW As Double = 0
|
|
'Dim WhType = GetMainPrivateProfileInt(S_GENERAL, K_WAREHOUSE, 1)
|
|
'Dim sWarehouseIniPath As String = ""
|
|
'Dim dOffset As Double = WarehouseHelper.GetOffset(Map.refProjectVM.BTLStructureVM.nPROJTYPE)
|
|
'Dim dStartOffset As Double = 0
|
|
'Dim dKerf As Double = 0
|
|
'Select Case WhType
|
|
' Case WarehouseType.BASIC
|
|
' Dim nQuantity As Integer = WarehouseHelper.GetQuantity(Map.refProjectVM.BTLStructureVM.nPROJTYPE)
|
|
' If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then
|
|
' ' leggo lunghezza barra
|
|
' WarehouseHelper.GetCurrentDimensions(Map.refProjectVM.BTLStructureVM.nPROJTYPE, 0, dRawL)
|
|
' ' leggo start offset e quantity
|
|
' dStartOffset = WarehouseHelper.GetStartOffset()
|
|
' ' riporto la stessa lunghezza in tutte le sezioni
|
|
' For Each Section In SectionList
|
|
' Section.dL = dRawL
|
|
' Section.nQuantity = nQuantity
|
|
' Next
|
|
' ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then
|
|
' If Not WarehouseHelper.GetCurrentDimensions(Map.refProjectVM.BTLStructureVM.nPROJTYPE, dRawW, dRawL) Then
|
|
' ' riabilito interfaccia
|
|
' Map.refProjectVM.SetCalcRunning(False)
|
|
' Return
|
|
' End If
|
|
' ' leggo kerf e quantity
|
|
' dKerf = WarehouseHelper.GetKerf()
|
|
' ' riporto le stesse dimensioni in tutte le sezioni
|
|
' For Each Section In SectionList
|
|
' Section.dL = dRawL
|
|
' Section.dW = dRawW
|
|
' Section.nQuantity = nQuantity
|
|
' Next
|
|
' End If
|
|
' Case WarehouseType.MEDIUM
|
|
' Dim sCurrL As String
|
|
' Dim nIndex As Integer = 1
|
|
' ' aggiungo le sezioni con diverse lunghezze in base al warehouse
|
|
' If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then
|
|
' ' leggo start offset
|
|
' dStartOffset = WarehouseHelper.GetStartOffset()
|
|
' ' leggo lunghezza barra e quantity
|
|
' WarehouseHelper.GetDimensionsAndQuantityForList(Map.refProjectVM.BTLStructureVM.nPROJTYPE, SectionList)
|
|
' ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then
|
|
' dKerf = WarehouseHelper.GetKerf()
|
|
' If Not WarehouseHelper.GetDimensionsAndQuantityForList(Map.refProjectVM.BTLStructureVM.nPROJTYPE, SectionList) Then
|
|
' ' riabilito interfaccia
|
|
' Map.refProjectVM.SetCalcRunning(False)
|
|
' Return
|
|
' End If
|
|
' End If
|
|
'End Select
|
|
'' attivo loading progress
|
|
'Map.refMyStatusBarVM.StartLoading("Nesting started", True)
|
|
'Dim DimensionsList As New List(Of List(Of SParam))
|
|
'' le raggruppo per sezione
|
|
'For Each Section In SectionList
|
|
' Dim Dimension As List(Of SParam) = DimensionsList.FirstOrDefault(Function(x) x(0).SectXMat = Section.SectXMat)
|
|
' If Not IsNothing(Dimension) Then
|
|
' Dimension.Add(Section)
|
|
' Else
|
|
' DimensionsList.Add(New List(Of SParam)({Section}))
|
|
' End If
|
|
'Next
|
|
'' per ogni gruppo di sezioni
|
|
'For Each Dimension In DimensionsList
|
|
' 'Dim SectionPartList As New List(Of BTLPartM)(Map.refProjectVM.BTLStructureVM.BTLPartVMList.Where(Function(x) x.Section = Section.SectXMat).ToList())
|
|
' Dim SectionPartList As List(Of BTLPartM) = (From x In Map.refProjectVM.BTLStructureVM.BTLPartVMList
|
|
' Where x.Section = Dimension(0).SectXMat AndAlso x.bDO
|
|
' Select x.BTLPartM).ToList()
|
|
' Dim nNestTime As Integer = Math.Max(5, dSectionTime) + (dPartTime * SectionPartList.Count)
|
|
' ' passo a lua lista id pezzi da nestare
|
|
' ExecNesting(sLogPath, CurrentMachine.sMachineName, SectionPartList, Dimension, dStartOffset, dOffset, dKerf, nNestTime)
|
|
'Next
|
|
'' update liste grezzi e pezzi della grafica
|
|
'Map.refProjectVM.MachGroupPanelVM.RefreshMachGroupList()
|
|
'' disattivo loading progress
|
|
'Map.refMyStatusBarVM.EndLoading("Nesting completed")
|
|
'' seleziono ultimo gruppo
|
|
'Map.refProjectVM.MachGroupPanelVM.SelLastMachGroup()
|
|
'' riabilito interfaccia
|
|
'Map.refProjectVM.SetCalcRunning(False)
|
|
'' chiudo finestra di attesa nesting
|
|
'NestingRunninWndVM.Cancel()
|
|
End Sub
|
|
|
|
#End Region ' Optimize
|
|
|
|
#Region "Warehouse"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Open.
|
|
''' </summary>
|
|
Public ReadOnly Property Warehouse_Command As ICommand
|
|
Get
|
|
If m_cmdWarehouse Is Nothing Then
|
|
m_cmdWarehouse = New Command(AddressOf Warehouse)
|
|
End If
|
|
Return m_cmdWarehouse
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Open. This method is invoked by the OpenCommand.
|
|
''' </summary>
|
|
Friend Sub Warehouse()
|
|
Dim WarehouseWnd As New WarehouseWndV(Application.Current.MainWindow, New WarehouseWndVM())
|
|
WarehouseWnd.ShowDialog()
|
|
End Sub
|
|
|
|
#End Region ' Warehouse
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|