Aggiunta copia multipla dei grezzi

This commit is contained in:
RenzoL
2021-12-02 09:41:32 +01:00
parent 791ed3480c
commit 5e9d068078
6 changed files with 259 additions and 87 deletions
@@ -169,6 +169,10 @@
<DependentUpon>InputPwdWndV.xaml</DependentUpon>
</Compile>
<Compile Include="InputPwdWnd\InputPwdWndVM.vb" />
<Compile Include="MultiCopyRawPartWnd\MultiCopyRawPartWndV.xaml.vb">
<DependentUpon>MultiCopyRawPartWndV.xaml</DependentUpon>
</Compile>
<Compile Include="MultiCopyRawPartWnd\MultiCopyRawPartWndVM.vb" />
<Compile Include="AddSectionXMaterialWnd\AddSectionXMaterialWndV.xaml.vb">
<DependentUpon>AddSectionXMaterialWndV.xaml</DependentUpon>
</Compile>
@@ -356,6 +360,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MultiCopyRawPartWnd\MultiCopyRawPartWndV.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="AddSectionXMaterialWnd\AddSectionXMaterialWndV.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -95,7 +95,8 @@ Public Class MyMachGroupVM
End Sub
Public Overrides Function Copy() As Core.MyMachGroupVM
Public Function Copy(Optional Qty As Integer = 1) As Core.MyMachGroupVM
Dim BeamWallMachGroup As MyMachGroupVM = Nothing
If nType = BWType.BEAM Then
EgtResetCurrMachGroup()
' recupero lista dei pezzi BTL originali
@@ -104,50 +105,51 @@ Public Class MyMachGroupVM
PartList.Add(BTLPartVM.RetrieveBTLPartFromPart(Part.nPartId))
Next
' verifico che nessun pezzo da copiare abbia raggiunto il numero massimo
If Not VerifyPartCount(PartList) Then Return Nothing
' creo nuovo gruppo di lavorazione
Map.refMachGroupPanelVM.AddMachGroup()
Dim nCurrMachGroup As Integer = EgtGetCurrMachGroup()
Dim sCurrMachGroupName As String = ""
EgtGetMachGroupName(nCurrMachGroup, sCurrMachGroupName)
' scrivo dati per variabili P di comunicazione con la macchina in gruppo di lavorazione
EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, Map.refProdManagerVM.CurrProd.nProdId)
EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, sMATERIAL)
EgtSetInfo(nCurrMachGroup, MGR_RPT_PATTID, nCurrMachGroup)
' scrivo dati costruzione grezzo in gruppo di lavorazione
EgtSetInfo(nCurrMachGroup, MGR_RPT_BARLEN, dL)
For Index = 0 To m_PartVMList.Count - 1
' creo copia del pezzo
Dim nPartDuploId As Integer = EgtDuploNew(PartList(Index).nPartId)
' elimino valori calcolo dell'originale
MyMachGroupPanelVM.DuploRemoveProjCalc(nPartDuploId)
' lo rendo std
EgtSetMode(nPartDuploId, GDB_MD.STD)
If Not VerifyPartCount(PartList, Qty) Then Return Nothing
' creo nuovi gruppi di lavorazione
For Ind = 1 To Qty
Map.refMachGroupPanelVM.AddMachGroup()
Dim nCurrMachGroup As Integer = EgtGetCurrMachGroup()
Dim sCurrMachGroupName As String = ""
EgtGetMachGroupName(nCurrMachGroup, sCurrMachGroupName)
' scrivo dati per variabili P di comunicazione con la macchina in gruppo di lavorazione
EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, Map.refProdManagerVM.CurrProd.nProdId)
EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, sMATERIAL)
EgtSetInfo(nCurrMachGroup, MGR_RPT_PATTID, nCurrMachGroup)
' scrivo dati costruzione grezzo in gruppo di lavorazione
EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & (Index + 1), nPartDuploId & "," & m_PartVMList(Index).sPOSX)
Next
Dim BeamMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.GetLastMachGroup()
' eseguo script creazione grezzo
Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt"
If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdType.RAWPART, False) Then
BeamMachGroup.DeleteMachGroup()
Dim LogFile As String() = File.ReadAllLines(sLogPath)
If LogFile.Count >= 2 AndAlso Not IsNothing(LogFile(1)) Then
MessageBox.Show(LogFile(1), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error)
EgtSetInfo(nCurrMachGroup, MGR_RPT_BARLEN, dL)
For Index = 0 To m_PartVMList.Count - 1
' creo copia del pezzo
Dim nPartDuploId As Integer = EgtDuploNew(PartList(Index).nPartId)
' elimino valori calcolo dell'originale
MyMachGroupPanelVM.DuploRemoveProjCalc(nPartDuploId)
' lo rendo std
EgtSetMode(nPartDuploId, GDB_MD.STD)
' scrivo dati costruzione grezzo in gruppo di lavorazione
EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & (Index + 1), nPartDuploId & "," & m_PartVMList(Index).sPOSX)
Next
BeamWallMachGroup = Map.refMachGroupPanelVM.GetLastMachGroup()
' eseguo script creazione grezzo
Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt"
If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdType.RAWPART, False) Then
BeamWallMachGroup.DeleteMachGroup()
Dim LogFile As String() = File.ReadAllLines(sLogPath)
If LogFile.Count >= 2 AndAlso Not IsNothing(LogFile(1)) Then
MessageBox.Show(LogFile(1), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error)
End If
Return Nothing
End If
Return Nothing
End If
' aggiorno contatore pezzi usati in Prod
For Each Part In PartList
Part.RefreshPartInProd()
' aggiorno contatore pezzi usati in Prod
For Each Part In PartList
Part.RefreshPartInProd()
Next
'aggiorno lista pezzi
BeamWallMachGroup.MyMachGroupM.RefreshPartList()
BeamWallMachGroup.MyMachGroupM.RefreshGroupData()
' aggiorno dati ultilizzo barra
BeamWallMachGroup.UpdateUsage()
BWSetView(VT.TOP, False)
Next
'aggiorno lista pezzi
BeamMachGroup.MyMachGroupM.RefreshPartList()
BeamMachGroup.MyMachGroupM.RefreshGroupData()
' aggiorno dati ultilizzo barra
BeamMachGroup.UpdateUsage()
BWSetView(VT.TOP, False)
Return BeamMachGroup
Else
Dim sPartArray(m_PartVMList.Count - 1) As String
' ciclo per salvare in un array di stringhe i valori di POSX e POSY prima di resettare
@@ -163,52 +165,54 @@ Public Class MyMachGroupVM
PartList.Add(BTLPartVM.RetrieveBTLPartFromPart(Part.nPartId))
Next
' verifico che nessun pezzo da copiare abbia raggiunto il numero massimo
If Not VerifyPartCount(PartList) Then Return Nothing
' creo nuovo gruppo di lavorazione
Map.refMachGroupPanelVM.AddMachGroup()
Dim nCurrMachGroup As Integer = EgtGetCurrMachGroup()
Dim sCurrMachGroupName As String = ""
EgtGetMachGroupName(nCurrMachGroup, sCurrMachGroupName)
' scrivo dati per variabili P di comunicazione con la macchina in gruppo di lavorazione
EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, Map.refProdManagerVM.CurrProd.nProdId)
EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, sMATERIAL)
EgtSetInfo(nCurrMachGroup, MGR_RPT_PATTID, nCurrMachGroup)
' scrivo dati costruzione grezzo in gruppo di lavorazione
EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELLEN, dL)
EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELWIDTH, dW)
For Index = 0 To m_PartVMList.Count - 1
' creo copia del pezzo
Dim nPartDuploId As Integer = EgtDuploNew(PartList(Index).nPartId)
' elimino valori calcolo dell'originale
MyMachGroupPanelVM.DuploRemoveProjCalc(nPartDuploId)
' lo rendo std
EgtSetMode(nPartDuploId, GDB_MD.STD)
If Not VerifyPartCount(PartList, Qty) Then Return Nothing
' creo nuovi gruppi di lavorazione
For ind = 1 To Qty
Map.refMachGroupPanelVM.AddMachGroup()
Dim nCurrMachGroup As Integer = EgtGetCurrMachGroup()
Dim sCurrMachGroupName As String = ""
EgtGetMachGroupName(nCurrMachGroup, sCurrMachGroupName)
' scrivo dati per variabili P di comunicazione con la macchina in gruppo di lavorazione
EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, Map.refProdManagerVM.CurrProd.nProdId)
EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, sMATERIAL)
EgtSetInfo(nCurrMachGroup, MGR_RPT_PATTID, nCurrMachGroup)
' scrivo dati costruzione grezzo in gruppo di lavorazione
EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & (Index + 1), nPartDuploId & "," & sPartArray(Index))
Next
Dim WallMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.GetLastMachGroup()
' eseguo script creazione grezzo
Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt"
If Not ExecWall(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdType.RAWPART, False) Then
WallMachGroup.DeleteMachGroup()
Dim LogFile As String() = File.ReadAllLines(sLogPath)
If LogFile.Count >= 2 AndAlso Not IsNothing(LogFile(1)) Then
MessageBox.Show(LogFile(1), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error)
EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELLEN, dL)
EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELWIDTH, dW)
For Index = 0 To m_PartVMList.Count - 1
' creo copia del pezzo
Dim nPartDuploId As Integer = EgtDuploNew(PartList(Index).nPartId)
' elimino valori calcolo dell'originale
MyMachGroupPanelVM.DuploRemoveProjCalc(nPartDuploId)
' lo rendo std
EgtSetMode(nPartDuploId, GDB_MD.STD)
' scrivo dati costruzione grezzo in gruppo di lavorazione
EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & (Index + 1), nPartDuploId & "," & sPartArray(Index))
Next
BeamWallMachGroup = Map.refMachGroupPanelVM.GetLastMachGroup()
' eseguo script creazione grezzo
Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt"
If Not ExecWall(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdType.RAWPART, False) Then
BeamWallMachGroup.DeleteMachGroup()
Dim LogFile As String() = File.ReadAllLines(sLogPath)
If LogFile.Count >= 2 AndAlso Not IsNothing(LogFile(1)) Then
MessageBox.Show(LogFile(1), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error)
End If
Return Nothing
End If
Return Nothing
End If
' aggiorno contatore pezzi usati in Prod
For Each Part In PartList
Part.RefreshPartInProd()
' aggiorno contatore pezzi usati in Prod
For Each Part In PartList
Part.RefreshPartInProd()
Next
'aggiorno lista pezzi
BeamWallMachGroup.MyMachGroupM.RefreshPartList()
BeamWallMachGroup.MyMachGroupM.RefreshGroupData()
' aggiorno dati ultilizzo barra
BeamWallMachGroup.UpdateUsage()
BWSetView(VT.TOP, False)
Next
'aggiorno lista pezzi
WallMachGroup.MyMachGroupM.RefreshPartList()
WallMachGroup.MyMachGroupM.RefreshGroupData()
' aggiorno dati ultilizzo barra
WallMachGroup.UpdateUsage()
BWSetView(VT.TOP, False)
Return WallMachGroup
End If
Return BeamWallMachGroup
End Function
Friend Function ReDrawBeamMachgroup() As Boolean
@@ -284,12 +288,12 @@ Public Class MyMachGroupVM
FirstBeam.NotifyPropertyChanged(NameOf(FirstBeam.sOffset))
End Sub
Private Function VerifyPartCount(SelParts As List(Of BTLPartVM)) As Boolean
Private Function VerifyPartCount(SelParts As List(Of BTLPartVM), Optional Qty As Integer = 1) As Boolean
Dim sPartToAdd As String = "Raggiunto numero di pezzi da produrre per:"
Dim bPartToAdd As Boolean = False
For Each Part In SelParts
' verifico se ci sono pezzi da aggiungere
If Not Part.CanAddPartToCount() Then
If Not Part.CanAddPartToCount(Qty) Then
bPartToAdd = True
sPartToAdd &= Environment.NewLine & "- PDN" & Part.nPDN & " | BTL QTY " & Part.nCNT & " | ADDED QTY " & Part.nADDED
End If
@@ -0,0 +1,49 @@
<EgtWPFLib5:EgtCustomWindow x:Class="MultiCopyRawPartWndV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"
xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.ViewerOptimizer"
xmlns:EgtBEAMWALLCORE="clr-namespace:EgtBEAMWALL.Core;assembly=EgtBEAMWALL.Core"
Style="{DynamicResource {x:Type EgtWPFLib5:EgtCustomWindow}}"
WindowStyle="None" ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
WindowStartupLocation="CenterOwner"
IsClosable="False"
IsMinimizable="False"
IsResizable="False"
Title="MultiCopyRawPart">
<Grid Margin="5,5,5,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding ChooseQty_Msg}"
Grid.Row="0"
Margin="0,0,0,5"/>
<EgtWPFLib5:EgtTextBox Text="{Binding nQuantity}"
Grid.Row="1"
Margin="0,0,0,5"/>
<Grid Grid.Row="2" Margin="0,0,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Button Content="{Binding Ok_Msg}"
Command="{Binding Ok_Command}"
IsDefault="True"
Grid.Column="1"
Style="{StaticResource EgtWPFLib5_InputButton}"/>
<Button Content="{Binding Cancel_Msg}"
IsCancel="True"
Grid.Column="3"
Style="{StaticResource EgtWPFLib5_InputButton}"/>
</Grid>
</Grid>
</EgtWPFLib5:EgtCustomWindow>
@@ -0,0 +1,18 @@
Public Class MultiCopyRawPartWndV
Private WithEvents m_MultiCopyRawPartWndVM As MultiCopyRawPartWndVM
Sub New(Owner As Window, MultiCopyRawPartWndVM As MultiCopyRawPartWndVM)
MyBase.New(Owner)
' This call is required by the designer.
InitializeComponent()
Me.DataContext = MultiCopyRawPartWndVM
' Assegno al riferimento locale al VM il VM preso dal DataContext
m_MultiCopyRawPartWndVM = MultiCopyRawPartWndVM
End Sub
Private Sub CloseWindow(bDialogResult As Boolean) Handles m_MultiCopyRawPartWndVM.m_CloseWindow
Me.DialogResult = bDialogResult
End Sub
End Class
@@ -0,0 +1,85 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Imports EgtBEAMWALL.Core
Public Class MultiCopyRawPartWndVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Friend Event m_CloseWindow(bDialogResult As Boolean)
Private m_nQuantity As Integer
Public Property nQuantity As Integer
Get
Return m_nQuantity
End Get
Set
m_nQuantity = value
End Set
End Property
' Definizione comandi
Private m_cmdOk As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "MESSAGES"
Public ReadOnly Property ChooseQty_Msg As String
Get
Return EgtMsg(61888)
End Get
End Property
Public ReadOnly Property Ok_Msg As String
Get
Return EgtMsg(61761)
End Get
End Property
Public ReadOnly Property Cancel_Msg As String
Get
Return EgtMsg(61763)
End Get
End Property
#End Region ' MESSAGES
#Region "CONSTRUCTOR"
Sub New()
End Sub
#End Region ' CONSTRUCTOR
#Region "COMMANDS"
#Region "Ok"
Public ReadOnly Property Ok_Command As ICommand
Get
If m_cmdOk Is Nothing Then
m_cmdOk = New Command(AddressOf Ok)
End If
Return m_cmdOk
End Get
End Property
Public Sub Ok()
'verifico che il campo contenga un valore valido
If Not IsNothing(m_nQuantity) AndAlso m_nQuantity > 0 AndAlso m_nQuantity < 99 Then
RaiseEvent m_CloseWindow(True)
Else
MessageBox.Show(EgtMsg(61887), EgtMsg(30007))
End If
End Sub
#End Region ' Ok
#End Region ' COMMANDS
End Class
@@ -270,10 +270,18 @@ Public Class TopPanelVM
''' </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()
Dim NewMachGroup As MyMachGroupVM = SelMachGroup.Copy(nQty)
If Not IsNothing(NewMachGroup) Then
' lo seleziono
Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup = NewMachGroup