This commit is contained in:
RenzoL
2021-10-19 15:45:00 +02:00
6 changed files with 324 additions and 184 deletions
@@ -142,7 +142,8 @@ Public Class AddSectionXMaterialWndVM
If NewSectXMatItem.dW = SectionListItem.dW AndAlso NewSectXMatItem.dH = SectionListItem.dH Then
' Se le sezioni sono uguali allora indago sui materiali
For Index As Integer = 0 To SectionListItem.sMaterial.Count - 1
If Not NewSectXMatItem.MaterialForSameSection_List.Contains(SectionListItem.sMaterial(Index)) And Not NewSectXMatItem.sMaterial.Contains(SectionListItem.sMaterial(Index)) Then
If Not NewSectXMatItem.MaterialForSameSection_List.Contains(SectionListItem.sMaterial(Index)) And
Not NewSectXMatItem.sMaterial.Contains(SectionListItem.sMaterial(Index)) Then
NewSectXMatItem.MaterialForSameSection_List.Add(SectionListItem.sMaterial(Index))
End If
If NewSectXMatItem.MaterialForSameSection_List.Count > 0 Then
@@ -154,7 +155,8 @@ Public Class AddSectionXMaterialWndVM
If NewSectXMatItem.dH = SectionListItem.dH Then
' Se le sezioni sono uguali allora indago sui materiali
For Index As Integer = 0 To SectionListItem.sMaterial.Count - 1
If Not NewSectXMatItem.MaterialForSameSection_List.Contains(SectionListItem.sMaterial(Index)) And Not NewSectXMatItem.sMaterial.Contains(SectionListItem.sMaterial(Index)) Then
If Not NewSectXMatItem.MaterialForSameSection_List.Contains(SectionListItem.sMaterial(Index)) And
Not NewSectXMatItem.sMaterial.Contains(SectionListItem.sMaterial(Index)) Then
NewSectXMatItem.MaterialForSameSection_List.Add(SectionListItem.sMaterial(Index))
End If
If NewSectXMatItem.MaterialForSameSection_List.Count > 0 Then
@@ -9,6 +9,11 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
@@ -18,15 +23,27 @@
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1"
Text="{Binding NestingRunning_Msg}"
Text="{Binding Section_Msg}"
TextAlignment="Center"/>
<ProgressBar Grid.Row="3"
<TextBlock Grid.Row="2"
Text="{Binding Nesting_Msg}"
TextAlignment="Center"/>
<ProgressBar Grid.Row="4"
Minimum="0"
Maximum="100"
Value="{Binding Progress_Value}"
Value="{Binding CurrProgress_Value}"
Height="20"
Margin="40,0,40,0"/>
<Button Grid.Row="5" Content="Cancel"
<ProgressBar Grid.Row="6"
Minimum="0"
Maximum="100"
Value="{Binding TotProgress_Value}"
Height="20"
Margin="40,0,40,0"/>
<TextBlock Grid.Row="8"
Text="{Binding TotProgress_Msg}"
TextAlignment="Center"/>
<Button Grid.Row="10" Content="Cancel"
IsDefault="False"
IsCancel="True"
Width="70"
@@ -12,23 +12,71 @@ Public Class NestingRunningWndVM
Private m_Waiting_Timer As New DispatcherTimer
Private m_TotIntervals As Integer = 0
Private m_Step As Double = 1
Private m_Progress_Value As Double = 0
Private m_SectionList As List(Of SParam)
Private m_SectionIndex As Integer
Public Property Progress_Value As Double
Private m_SectionProgressList As New List(Of SectionProgress)
Friend ReadOnly Property SectionProgressList As List(Of SectionProgress)
Get
Return m_Progress_Value
Return m_SectionProgressList
End Get
End Property
Public ReadOnly Property RunningSection As SectionProgress
Get
Dim CurrRunningSection As SectionProgress = m_SectionProgressList.FirstOrDefault(Function(x) x.nState <> SectionProgress.NestStates.DONE)
Return If(Not IsNothing(CurrRunningSection), CurrRunningSection, Nothing)
End Get
End Property
Private m_CurrProgress_Value As Double = 0
Public Property CurrProgress_Value As Double
Get
Return m_CurrProgress_Value
End Get
Set(value As Double)
m_Progress_Value = value
m_CurrProgress_Value = value
End Set
End Property
Private m_TotProgress_Value As Double = 0
Public Property TotProgress_Value As Double
Get
Return Math.Floor(m_TotProgress_Value)
End Get
Set(value As Double)
m_TotProgress_Value = value
End Set
End Property
' tempo parziale e totale del segmento corrente
Friend Shared m_CurrState As SectionProgress.NestStates
Friend Shared m_CurrTime As Double
Friend Shared m_TotTime As Double
#Region "Messages"
Public ReadOnly Property NestingRunning_Msg As String
Public ReadOnly Property Section_Msg As String
Get
Return "Nesting running..."
Return "Section: " & m_SectionProgressList(m_SectionIndex).Section.sSectionXMaterial & "(" & m_SectionIndex + 1 & "/" & m_SectionProgressList.Count() & ")"
End Get
End Property
Public ReadOnly Property Nesting_Msg As String
Get
Select Case m_CurrState
Case SectionProgress.NestStates.ADDPART
Return "Calculating wall orientation..."
Case SectionProgress.NestStates.NEST
Return "Nesting walls in rawparts..."
Case SectionProgress.NestStates.CALCRAWPART
Return "Genereting rawparts with nested parts..."
End Select
End Get
End Property
Public ReadOnly Property TotProgress_Msg As String
Get
Return m_TotProgress_Value.ToString("0.#") & "%"
End Get
End Property
@@ -39,19 +87,58 @@ Public Class NestingRunningWndVM
#End Region ' FIELDS & PROPERTIES
Sub New(SectionList As List(Of SParam), TimeToWait As Double)
m_SectionList = SectionList
m_TotIntervals = Math.Ceiling(TimeToWait)
m_Step = 100 / m_TotIntervals
' avvio contatore
m_Waiting_Timer.Interval = TimeSpan.FromMilliseconds(1000)
Sub New(SelPartType As Integer)
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)
SectionProgress.SetPartSectionTimes(dPartTime, dSectionTime)
' disabilito interfaccia
Map.refProjectVM.SetCalcRunning(True)
' se ho selezionato nest per materiale e c'è una sezione selezionata diversa da sezione nulla
If SelPartType = OptimizePanelVM.PartType.MATERIAL AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelSection) AndAlso Map.refProjectVM.BTLStructureVM.SelSection.dH <> -1 Then
m_SectionProgressList.Add(New SectionProgress(Map.refProjectVM.BTLStructureVM.SelSection))
Else
' altrimenti prendo tutte le sezioni
For Each CurrSection In Map.refProjectVM.BTLStructureVM.SectionList
If CurrSection.dH = -1 Then Continue For
m_SectionProgressList.Add(New SectionProgress(CurrSection))
Next
End If
' imposto contatore
m_Waiting_Timer.Interval = TimeSpan.FromMilliseconds(700)
AddHandler m_Waiting_Timer.Tick, AddressOf WaitingTimer_Tick
m_Waiting_Timer.Start()
End Sub
Private Sub WaitingTimer_Tick()
m_Progress_Value += m_Step
NotifyPropertyChanged(NameOf(Progress_Value))
Dim CurrTime As Double = 0
Dim CurrTotTime As Double = 0
Dim TotalTime As Double = 0
For Index = 0 To m_SectionProgressList.Count - 1
Dim SectionProgress As SectionProgress = m_SectionProgressList(Index)
If Index < m_SectionIndex Then
CurrTime += SectionProgress.dTotSectionTime
ElseIf Index = m_SectionIndex Then
Select Case m_CurrState
Case SectionProgress.NestStates.ADDPART
CurrTotTime = 100
CurrTime += m_CurrTime * SectionProgress.dAddPartTime / 100
Case SectionProgress.NestStates.NEST
CurrTotTime = 100
CurrTime += SectionProgress.dAddPartTime + m_CurrTime * SectionProgress.dCalcNestTime / 100
Case SectionProgress.NestStates.CALCRAWPART
CurrTotTime = 100
CurrTime += SectionProgress.dAddPartTime + SectionProgress.dCalcNestTime + m_CurrTime * SectionProgress.dCalcRawPartTime / 100
End Select
End If
TotalTime += SectionProgress.dTotSectionTime
Next
m_TotProgress_Value = CurrTime / TotalTime * 100
m_CurrProgress_Value = m_CurrTime
NotifyPropertyChanged(NameOf(CurrProgress_Value))
NotifyPropertyChanged(NameOf(TotProgress_Value))
NotifyPropertyChanged(NameOf(Section_Msg))
NotifyPropertyChanged(NameOf(Nesting_Msg))
NotifyPropertyChanged(NameOf(TotProgress_Msg))
End Sub
Friend Sub DoNesting()
@@ -75,9 +162,8 @@ Public Class NestingRunningWndVM
' leggo start offset e quantity
dStartOffset = WarehouseHelper.GetStartOffset()
' riporto la stessa lunghezza in tutte le sezioni
For Each Section In m_SectionList
Section.dL = dRawL
Section.nQuantity = nQuantity
For Each SectionProgress In m_SectionProgressList
SectionProgress.SParamList.Add(New SParam(SectionProgress.Section, dRawL, nQuantity))
Next
ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then
If Not WarehouseHelper.GetCurrentDimensions(Map.refProjectVM.BTLStructureVM.nPROJTYPE, dRawW, dRawL) Then
@@ -89,10 +175,8 @@ Public Class NestingRunningWndVM
' leggo kerf e quantity
dKerf = WarehouseHelper.GetKerf()
' riporto le stesse dimensioni in tutte le sezioni
For Each Section In m_SectionList
Section.dL = dRawL
Section.dW = dRawW
Section.nQuantity = nQuantity
For Each SectionProgress In m_SectionProgressList
SectionProgress.SParamList.Add(New SParam(SectionProgress.Section, dRawW, dRawL, nQuantity))
Next
End If
Case WarehouseType.MEDIUM
@@ -103,10 +187,10 @@ Public Class NestingRunningWndVM
' leggo start offset
dStartOffset = WarehouseHelper.GetStartOffset()
' leggo lunghezza barra e quantity
WarehouseHelper.GetDimensionsAndQuantityForList(Map.refProjectVM.BTLStructureVM.nPROJTYPE, m_SectionList)
WarehouseHelper.GetDimensionsAndQuantityForList(Map.refProjectVM.BTLStructureVM.nPROJTYPE, m_SectionProgressList)
ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then
dKerf = WarehouseHelper.GetKerf()
If Not WarehouseHelper.GetDimensionsAndQuantityForList(Map.refProjectVM.BTLStructureVM.nPROJTYPE, m_SectionList) Then
If Not WarehouseHelper.GetDimensionsAndQuantityForList(Map.refProjectVM.BTLStructureVM.nPROJTYPE, m_SectionProgressList) Then
' riabilito interfaccia
Map.refProjectVM.SetCalcRunning(False)
CloseNesting()
@@ -114,34 +198,47 @@ Public Class NestingRunningWndVM
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 m_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
'' 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 m_SectionProgressList
' Dim Dimension As List(Of SParam) = DimensionsList.FirstOrDefault(Function(x) x(0).SectXMat = Section.SParam.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
'For Each Dimension In DimensionsList
' calcolo lista dei pezzi per ogni sezione
For Each SectionProgress In m_SectionProgressList
'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
Where x.Section = SectionProgress.Section AndAlso x.bDO
Select x.BTLPartM).ToList()
Dim nNestTime As Integer = Math.Max(5, dSectionTime) + (dPartTime * SectionPartList.Count)
SectionProgress.SetSectionPartList(SectionPartList)
Next
' avvio timer avanzamento nesting
m_CurrState = SectionProgress.NestStates.NULL
m_TotTime = 0
m_CurrTime = 0
m_Waiting_Timer.Start()
' calcolo nesting
For m_SectionIndex = 0 To m_SectionProgressList.Count - 1
Dim SectionProgress As SectionProgress = m_SectionProgressList(m_SectionIndex)
' passo a lua lista id pezzi da nestare
If Not ExecNesting(sLogPath, CurrentMachine.sMachineName, SectionPartList, Dimension, dStartOffset, dOffset, dKerf, nNestTime) Then
If SectionProgress.SectionPartList.Count > 0 AndAlso SectionProgress.SParamList.Count > 0 AndAlso
Not ExecNesting(sLogPath, CurrentMachine.sMachineName, SectionProgress.SectionPartList, SectionProgress.SParamList, dStartOffset, dOffset, dKerf, SectionProgress.dCalcNestTime) Then
Exit For
End If
Next
' update liste grezzi e pezzi della grafica
Map.refProjectVM.MachGroupPanelVM.RefreshMachGroupList()
' disattivo loading progress
Map.refMyStatusBarVM.EndLoading("Nesting completed")
'' disattivo loading progress
'Map.refMyStatusBarVM.EndLoading("Nesting completed")
' seleziono ultimo gruppo
Map.refProjectVM.MachGroupPanelVM.SelLastMachGroup()
' riabilito interfaccia
@@ -179,7 +276,7 @@ Public Class NestingRunningWndVM
' chiedo conferma
If MessageBox.Show("Are you sure you want to stop the nesting?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.No Then Return
' fermo il nesting
Map.refMyStatusBarVM.StopProgress()
Map.refOptimizePanelVM.m_StopNesting = True
'' fermo timer e chiudo finestra
'CloseNesting()
End Sub
@@ -189,3 +286,89 @@ Public Class NestingRunningWndVM
#End Region ' COMMANDS
End Class
Public Class SectionProgress
Public Enum NestStates As Integer
NULL = 0
START = 1
ADDRAWPART = -1
ADDPART = -2
NEST = 4
CALCRAWPART = -3
DONE = -4
End Enum
Private Shared m_dSectionTime As Double
Private Shared m_dPartTime As Double
Private m_Section As SectionXMaterial
Public ReadOnly Property Section As SectionXMaterial
Get
Return m_Section
End Get
End Property
Private m_SParamList As New List(Of SParam)
Public ReadOnly Property SParamList As List(Of SParam)
Get
Return m_SParamList
End Get
End Property
Private m_SectionPartList As New List(Of BTLPartM)
Public ReadOnly Property SectionPartList As List(Of BTLPartM)
Get
Return m_SectionPartList
End Get
End Property
Private m_nState As NestStates = 0
Public ReadOnly Property nState As NestStates
Get
Return m_nState
End Get
End Property
Public Sub SetState(value As NestStates)
m_nState = value
End Sub
Public ReadOnly Property dTotSectionTime As Double
Get
Return If(SectionPartList.Count > 0 AndAlso SParamList.Count > 0, dAddPartTime + dCalcNestTime + dCalcRawPartTime, 0)
End Get
End Property
Public ReadOnly Property dAddPartTime As Double
Get
Return If(SectionPartList.Count > 0 AndAlso SParamList.Count > 0, Math.Max(SectionPartList.Count / 5, 2), 0)
End Get
End Property
Public ReadOnly Property dCalcNestTime As Double
Get
Return If(SectionPartList.Count > 0 AndAlso SParamList.Count > 0, Math.Max(5, m_dSectionTime) + (m_dPartTime * SectionPartList.Count), 0)
End Get
End Property
Public ReadOnly Property dCalcRawPartTime As Double
Get
Return If(SectionPartList.Count > 0 AndAlso SParamList.Count > 0, Math.Max(SectionPartList.Count / 20, 2), 0)
End Get
End Property
Sub New(Section As SectionXMaterial)
m_Section = Section
End Sub
Friend Shared Sub SetPartSectionTimes(PartTime As Double, SectionTime As Double)
m_dPartTime = PartTime
m_dSectionTime = SectionTime
End Sub
Friend Sub SetSectionPartList(SectionPartList As List(Of BTLPartM))
m_SectionPartList = SectionPartList
End Sub
End Class
@@ -1,4 +1,5 @@
Imports System.Collections.ObjectModel
Imports System.Threading
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5
@@ -8,7 +9,10 @@ Public Class OptimizePanelVM
#Region "FIELDS & PROPERTIES"
Friend Enum PartType As Integer
Friend m_bNestingRunning As Boolean = False
Friend m_StopNesting As Boolean = False
Public Enum PartType As Integer
MATERIAL = 0
ALL = 1
End Enum
@@ -102,6 +106,30 @@ Public Class OptimizePanelVM
NotifyPropertyChanged(NameOf(OptimizePanel_IsEnabled))
End Sub
Friend Function ProcessEvents(ByVal nProg As Integer, ByVal nPause As Integer) As Integer
If nProg > 0 And nProg <= 100 Then
NestingRunningWndVM.m_CurrState = SectionProgress.NestStates.NEST
NestingRunningWndVM.m_CurrTime = nProg
ElseIf nProg > 100 And nProg <= 200 Then
NestingRunningWndVM.m_CurrState = SectionProgress.NestStates.ADDPART
NestingRunningWndVM.m_CurrTime = nProg - 100
ElseIf nProg > 200 And nProg <= 300 Then
NestingRunningWndVM.m_CurrState = SectionProgress.NestStates.CALCRAWPART
NestingRunningWndVM.m_CurrTime = nProg - 200
End If
' Costringo ad aggiornare
UpdateUI()
' Eventuale attesa
Thread.Sleep(nPause)
' Ritorno eventuale stop
If m_StopNesting Then
m_StopNesting = False
Return 1
Else
Return 0
End If
End Function
#End Region ' METHODS
#Region "COMMANDS"
@@ -126,118 +154,27 @@ Public Class OptimizePanelVM
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)
m_bNestingRunning = True
Dim NestingRunningWndVM As New NestingRunningWndVM(m_SelPartType.Id)
Dim NestingRunningWnd As New NestingRunningWndV(Application.Current.MainWindow, NestingRunningWndVM)
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()
m_bNestingRunning = False
' mostro risultati
Dim sResult As String = ""
For Each Section In NestingRunningWndVM.SectionProgressList
If Section.SParamList.Count = 0 Then
sResult &= Section.Section.sSectionXMaterial & ": no raw part found in the warehouse!" & Environment.NewLine
End If
For Each Part In Section.SectionPartList
If Part.nINPROD <> Part.nCNT + Part.nADDED Then
sResult &= Section.Section.sSectionXMaterial & " - " & Part.nPDN & ": partially nested!" & "(" & Part.nINPROD & "/" & Part.nCNT + Part.nADDED & ")" & Environment.NewLine
End If
Next
Next
If Not IsNothing(sResult) Then
MessageBox.Show(sResult, "", MessageBoxButton.OK, MessageBoxImage.Information)
End If
End Sub
#End Region ' Optimize
@@ -48,6 +48,11 @@ Public Class MyStatusBarVM
End Function
Private Function ProcessEvents(ByVal nProg As Integer, ByVal nPause As Integer) As Integer
' se nesting in corso
If Map.refOptimizePanelVM.m_bNestingRunning Then
' gestisco nel nesting
Return Map.refOptimizePanelVM.ProcessEvents(nProg, nPause)
End If
' Se previsto, imposto progress
If nProg > 0 Then SetLoadingProgress(Math.Min(nProg, 100))
' Costringo ad aggiornare
@@ -111,43 +111,39 @@ Module WarehouseHelper
' funzione che restituisce la quantita' di grezzi per sezione
Public Function GetDimensionsAndQuantityForList(Type As BWType, ByRef SectionList As List(Of SParam)) As Boolean
Public Function GetDimensionsAndQuantityForList(Type As BWType, ByRef SectionList As List(Of SectionProgress)) As Boolean
Dim nIndex As Integer = 1
Dim sSection As String = ""
Dim CheckList As New List(Of Integer)
Dim NewSectionList As New List(Of SParam)
While GenInterface.GetPrivateProfileString(If(Type = BWType.BEAM, WRH_BEAM, WRH_WALL), If(Type = BWType.BEAM, WRH_L, WRH_S) & nIndex, "", sSection, GetWarehouseIniPath()) > 0
If String.IsNullOrWhiteSpace(sSection) Then Return False
If String.IsNullOrWhiteSpace(sSection) Then Continue While
Dim sSectionValues() As String = sSection.Split(","c)
Dim dW As Double = 0
Dim dL As Double = 0
Dim nQty As Integer = 0
Select Case Type
Case BWType.BEAM
For Each Section In SectionList
If Section.SectXMat.dW = sSectionValues(0) AndAlso Section.SectXMat.dH = sSectionValues(1) AndAlso Section.SectXMat.MaterialForSameSection_List(0) = sSectionValues(2) Then
If Not StringToDouble(sSectionValues(3), Section.dL) Then Return False
If Not Integer.TryParse(sSectionValues(4), Section.nQuantity) Then Return False
CheckList.Add(SectionList.IndexOf(Section))
For Each SectionProgress In SectionList
If SectionProgress.Section.dW = sSectionValues(0) AndAlso SectionProgress.Section.dH = sSectionValues(1) AndAlso SectionProgress.Section.MaterialForSameSection_List(0) = sSectionValues(2) Then
If Not StringToDouble(sSectionValues(3), dL) Then Continue While
If Not Integer.TryParse(sSectionValues(4), nQty) Then Continue While
SectionProgress.SParamList.Add(New SParam(SectionProgress.Section, dL, nQty))
End If
Next
Case BWType.WALL
For Each Section In SectionList
Dim sSectionData As String = ""
GetPrivateProfileString(If(Type = BWType.BEAM, S_BEAM_LIST, S_WALL_LIST), sSectionValues(0), "", sSectionData, GetWarehouseIniPath())
Dim SectionData() As String = sSectionData.Split(","c)
If Section.SectXMat.dH = SectionData(0) AndAlso Section.SectXMat.sMaterial.Contains(SectionData(1)) Then
Dim dW As Double = 0
Dim dL As Double = 0
Dim nQty As Integer = 0
If Not StringToDouble(sSectionValues(1), dW) Then Return False
If Not StringToDouble(sSectionValues(2), dL) Then Return False
If Not Integer.TryParse(sSectionValues(3), nQty) Then Return False
NewSectionList.Add(New SParam(Section.SectXMat, dW, dL, nQty))
CheckList.Add(SectionList.IndexOf(Section))
Dim sSectionData As String = ""
GetPrivateProfileString(If(Type = BWType.BEAM, S_BEAM_LIST, S_WALL_LIST), sSectionValues(0), "", sSectionData, GetWarehouseIniPath())
Dim SectionData() As String = sSectionData.Split(","c)
For Each SectionProgress In SectionList
If SectionProgress.Section.dH = SectionData(0) AndAlso SectionProgress.Section.sMaterial.Contains(SectionData(1)) Then
If Not StringToDouble(sSectionValues(1), dW) Then Continue While
If Not StringToDouble(sSectionValues(2), dL) Then Continue While
If Not Integer.TryParse(sSectionValues(3), nQty) Then Continue While
SectionProgress.SParamList.Add(New SParam(SectionProgress.Section, dW, dL, nQty))
End If
Next
End Select
nIndex += 1
End While
SectionList = NewSectionList
Return True
End Function