diff --git a/EgtStoneLib/CamAuto.vb b/EgtStoneLib/CamAuto.vb index 1884257..0b2902b 100644 --- a/EgtStoneLib/CamAuto.vb +++ b/EgtStoneLib/CamAuto.vb @@ -413,7 +413,7 @@ Friend Module CamAuto End If Else ' pezzi automatici (recupero la lista di apparenenza del pezzo) - Dim LocalPartList As List(Of Part) = GetPartList(TmpPart.MinRectX) + Dim LocalPartList As List(Of Part) = GetPartialList(TmpPart.MinRectX, PartListMax, PartListMedium, PartListMin) If LocalPartList.Count = 0 Then LocalPartList.Add(TmpPart) Else @@ -565,20 +565,46 @@ Friend Module CamAuto End If Map.refUnloadingAreaVM.ClearOutputMessage() Map.refUnloadingAreaVM.SetOutputMessage("Ended loading project.") + ' aggiorno la lista dei progetti + If Not IsNothing(Map.refUnloadingAreaVM.m_refTablePartWindowVM) Then + Map.refUnloadingAreaVM.m_refTablePartWindowVM.RefreshProject() + End If Return bOk End Function ' assegnata la lunghezza del pezzo restiruisce la lista di appartenenza - Private Function GetPartList(MinRectX As Double) As List(Of Part) + Public Function GetPartialList(MinRectX As Double, ByRef LocalPartListMax As List(Of Part), ByRef LocalPartListMedium As List(Of Part), ByRef LocalPartListMin As List(Of Part)) As List(Of Part) If MinRectX - Map.refUnloadingAreaVM.MaxLength > EPS_SMALL Then - Return PartListMax + Return LocalPartListMax ElseIf MinRectX - 600 > EPS_SMALL Then - Return PartListMedium + Return LocalPartListMedium Else - Return PartListMin + Return LocalPartListMin End If End Function + ' rimuove i pezzi che appartengono allo stesso Layer dello stesso box del pezzo rovinato + Public Function RemuovePartSameLayer(ByRef CurrList As List(Of Part), WastePart As Part, bNewBox As Boolean) As Boolean + Dim IndexPart As Integer = 0 + ' costruisco la lista degli indici da rimuovere nella lista Medium + Dim RemoveList As New List(Of Part) + For IndexPart = 0 To CurrList.Count - 1 + If bNewBox AndAlso CurrList(IndexPart).nLayer = WastePart.nLayer AndAlso CurrList(IndexPart).IdBox = WastePart.IdBox Then + ' se appartengono allo stesso layer del box corrente + RemoveList.Add(CurrList(IndexPart)) + ElseIf CurrList(IndexPart).IdBox <> WastePart.IdBox Then + ' se appartengono ad un box differente + RemoveList.Add(CurrList(IndexPart)) + End If + Next + ' rimuovo i pezzi che ho calcolato al punto sopra + For Each ItemIndex In RemoveList + CurrList.Remove(ItemIndex) + Next + Return True + End Function + + ' calcolo il nesting della lista passata Public Function MyNesting1D(LocalPartList As List(Of Part), ByRef PrecWidthLayer As Double, ByRef LastLayerList As List(Of Part), nLayerIndex As Integer, Optional bStop As Boolean = False) As Boolean ' se la lista da nestare è vuot allora esco siìubito If LocalPartList.Count < 1 Then Return False @@ -676,6 +702,7 @@ Friend Module CamAuto Return True End Function + ' calcolo il nesting tra due liste Public Function JoinNesting1D(PrecListPart As List(Of Part), CurrListPart As List(Of Part), LastLayerList As List(Of Part), ByRef dDiffY As Double, nCurrLayer As Integer) As Boolean ' se una delle due liste da nestare è vuota allora esco If PrecListPart.Count < 1 Or CurrListPart.Count < 1 Then Return False @@ -715,53 +742,6 @@ Friend Module CamAuto End If End Function - ' riceve in ingresso la lista dei pezzi e la superficie disponibile -> i pezzi non devono essere raggruppati in categorie - Public Sub MyNestingSideBySide(LocalPartList As List(Of Part), ByVal ActualWidthPallet As Double) - Dim nCurrLayer As Integer = 0 - Dim dTollerance As Double = Map.refUnloadingAreaVM.MinTollerance - Dim dMaxTollerance As Double = Map.refUnloadingAreaVM.MaxTollerance - Dim dMaxDist As Double = 170 - ' lista dei pezzi per il Layer corrente - Dim ListPartLayer As New List(Of Part) - ' definisco la posizione all'interno del Layer - Dim nCurrPos As Integer = 0 - ' superficie disponibile di deposito sul pallet - Dim dDiff As Double = ActualWidthPallet - dTollerance - ' devo necessariamente impilare i pezzi (non posso porvare ad affiancarli) - Dim dCreateTile As Boolean = False - ' costruisco i layer - Dim IndexPart As Integer = 0 - While IndexPart < LocalPartList.Count() - 1 - ' se è il primo pezzo del Layer allora non considero al tolleranza - Dim CurrTollerance As Double = dTollerance - If nCurrPos = 0 Then - dTollerance = 0 - End If - ' inserisco il pezzo nello spazio rimanete del Layer e calcolo lo spazio disponibile - dDiff = dDiff - LocalPartList(IndexPart).MinRectY - dTollerance - ' se il pezzo non sborda - If dDiff >= -EPS_SMALL Then - ' defisco la posizione nel Layer - nCurrPos = nCurrPos + 1 - ' salvo il Layer Occupato dal pezzo - LocalPartList(IndexPart).nLayer = nCurrLayer - ' aggiungo il pezzo alla lista dei pezzi inseriti nel Layer - ListPartLayer.Add(LocalPartList(IndexPart)) - ' passo al pezzo successivo - IndexPart = IndexPart + 1 - Else - ' passo al Layer successivo - nCurrLayer = nCurrLayer + 1 - nCurrPos = 0 - ' calcolo la disposizione dei pezzi nel Layer corrente in Y - CalcOffsetPartY(ListPartLayer, ActualWidthPallet) - dDiff = ActualWidthPallet - ' ripulisco la lista dei pezzi all'interno del Layer - ListPartLayer.Clear() - End If - End While - End Sub - ' ricavuta la lista di pezzi che occupano un Layer, e la dimensione Y del Layer precedente determino la nuova disposizione Public Sub CalcOffsetPartY(ListPartLayer As List(Of Part), ByRef PrecWidthPallet As Double) ' distanza massima di sicurezza da mantenere tra i pezzi @@ -787,6 +767,8 @@ Friend Module CamAuto ' verifico che la distanza calcolata sia minore del valore massimo If dSplit > dMaxTollerance Then dSplit = dMaxTollerance + ElseIf dSplit < 10 Then + dSplit = 10 End If End If ' determino lo spazio occupato dai pezzi del Layer corrente @@ -816,6 +798,8 @@ Friend Module CamAuto ActualY = ActualY + ListPartLayer(IndexPart).MinRectY + dSplit bCalcOk = True End If + ' assegno la posizione del pezzo all'inerno del Layer + ListPartLayer(IndexPart).nPositionLayer = IndexPart If Not bCalcOk Then Map.refUnloadingAreaVM.ClearOutputMessage() Map.refUnloadingAreaVM.SetOutputMessage("Error in calc offset box.") diff --git a/GridStorage/WarehouseV.xaml.vb b/GridStorage/WarehouseV.xaml.vb deleted file mode 100644 index fd85553..0000000 --- a/GridStorage/WarehouseV.xaml.vb +++ /dev/null @@ -1,3 +0,0 @@ -Public Class WarehouseV - -End Class diff --git a/InfoWindow/InfoWindowV.xaml b/InfoWindow/InfoWindowV.xaml new file mode 100644 index 0000000..4be1552 --- /dev/null +++ b/InfoWindow/InfoWindowV.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + diff --git a/InfoWindow/InfoWindowV.xaml.vb b/InfoWindow/InfoWindowV.xaml.vb new file mode 100644 index 0000000..4070304 --- /dev/null +++ b/InfoWindow/InfoWindowV.xaml.vb @@ -0,0 +1,11 @@ +Public Class InfoWindowV + Private m_InfoWindowVM As InfoWindowVM + Sub New(Owner As Window, objInfoWindowVM As InfoWindowVM) + MyBase.New(Owner) + ' This call is required by the designer. + InitializeComponent() + ' Add any initialization after the InitializeComponent() call. + Me.DataContext = objInfoWindowVM + m_InfoWindowVM = objInfoWindowVM + End Sub +End Class diff --git a/InfoWindow/InfoWindowVM.vb b/InfoWindow/InfoWindowVM.vb new file mode 100644 index 0000000..30f1c29 --- /dev/null +++ b/InfoWindow/InfoWindowVM.vb @@ -0,0 +1,53 @@ +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class InfoWindowVM + Inherits VMBase + + Friend m_RefInfoWindowV As InfoWindowV + + Private m_Title As String = String.Empty + Public ReadOnly Property Title As String + Get + Return m_Title + End Get + End Property + + Private m_Messages As String = String.Empty + Public ReadOnly Property Messages As String + Get + Return m_Messages + End Get + End Property + + Private m_TryeAgain As Boolean = False + Public Property TryAgain As Boolean + Get + Return m_TryeAgain + End Get + Set(value As Boolean) + m_TryeAgain = value + m_StopTry = Not value + m_RefInfoWindowV.Close() + End Set + End Property + + Private m_StopTry As Boolean = False + Public Property StopTry As Boolean + Get + Return m_StopTry + End Get + Set(value As Boolean) + m_StopTry = value + m_TryeAgain = Not value + m_RefInfoWindowV.Close() + End Set + End Property + + Sub New(sMessages As String, sTitle As String) + m_Title = sTitle + m_Messages = sMessages + m_RefInfoWindowV = New InfoWindowV(Application.Current.MainWindow, Me) + End Sub + +End Class diff --git a/MainWindow/MainWindowVM.vb b/MainWindow/MainWindowVM.vb index 2738a4a..e34f4f2 100644 --- a/MainWindow/MainWindowVM.vb +++ b/MainWindow/MainWindowVM.vb @@ -239,6 +239,8 @@ Public Class MainWindowVM ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. Public Sub CloseApplication(ByVal param As Object) + ' salvo il deisegno del progetto corrente + EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & CURR_PROJ_NAME, NGE.BIN) ' Termino il Model m_MainWindowM.Close() ' chiudo il programma CameraManager diff --git a/MainWindow/Part.vb b/MainWindow/Part.vb index 2f7893a..240e253 100644 --- a/MainWindow/Part.vb +++ b/MainWindow/Part.vb @@ -61,6 +61,7 @@ Public Class Part Set(value As Integer) m_IdBox = value PartWritePrivateProfileString(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "IdBox", m_IdBox.ToString) + NotifyPropertyChanged("IdBox") End Set End Property @@ -73,6 +74,7 @@ Public Class Part Set(value As Warehouses) m_enWarehouse = value PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "IdWarehouse", CInt(m_enWarehouse)) + NotifyPropertyChanged("enWarehouse") End Set End Property @@ -93,6 +95,20 @@ Public Class Part Set(value As Integer) m_nLayer = value PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "IdLayer", CInt(m_nLayer)) + NotifyPropertyChanged("nLayer") + End Set + End Property + + ' indica la posizione occupata all'interno del Layer + Private m_nPositionLayer As Integer = 1 + Public Property nPositionLayer As Integer + Get + Return m_nPositionLayer + End Get + Set(value As Integer) + m_nPositionLayer = value + 'PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "PositionInLayer", CInt(m_nPositionLayer)) + NotifyPropertyChanged("nPositionLayer") End Set End Property @@ -173,6 +189,7 @@ Public Class Part Set(value As Place) m_enPlace = value PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, ConstIni.K_PLACE, CInt(m_enPlace)) + NotifyPropertyChanged("enPlace") End Set End Property @@ -185,6 +202,7 @@ Public Class Part Set(value As StatusPart) m_enStatus = value PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, ConstIni.K_STATUS, CInt(m_enStatus)) + NotifyPropertyChanged("enStatus") End Set End Property @@ -449,6 +467,17 @@ Public Class Part If String.IsNullOrEmpty(sVal) Then Return False End If + ' provo a caricare il disegno del progetto corrente (in fase di scarico) + If EgtOpenFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & CURR_PROJ_NAME) Then + ' imposto la macchina di lavoro + EgtSetCurrMachGroup(EgtGetFirstMachGroup()) + ' Attivo ultima fase di lavorazione + EgtSetCurrPhase(EgtGetPhaseCount()) + ' Nascondo lavorazioni + HideAllMachinings() + End If + + ' separo l'elenco di progetti Dim sItemIdProj As String() = sVal.Split(","c) For Each ItemId In sItemIdProj @@ -553,6 +582,9 @@ Public Class Part ' RawAngRotDeg PartGetPrivateProfileDouble(nIdProj, ConstIni.S_PART & nIdPart.ToString, "RawAngRotDeg" & nIndex.ToString, objRawMoveData.m_dRawAngRotDeg) Next + If LocalPart.enPlace = Place.ON_MOTOR_RULLER Then + EgtSetStatus(LocalPart.IdPart, GDB_ST.OFF) + End If Map.refUnloadingAreaVM.ListPart.Add(LocalPart) ' terminata la costruzione della lista dei pezzi, genero la lista per i box del progetto corrente @@ -560,9 +592,9 @@ Public Class Part ' ricavo il magazzino corrente If ItemWarehouse.Id = CType(nIdWarehouse, Warehouses) Then For Each ItemBox In ItemWarehouse.Boxes - ItemBox.State = States.LOADING If ItemBox.Id = LocalPart.IdBox Then ItemBox.MyListPart.Add(LocalPart) + ItemBox.State = States.LOADING End If Next End If diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index b734cf4..6110ec7 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -70,5 +70,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/MySceneHost/MySceneHostVM.vb b/MySceneHost/MySceneHostVM.vb index b7667d1..dfb6e04 100644 --- a/MySceneHost/MySceneHostVM.vb +++ b/MySceneHost/MySceneHostVM.vb @@ -434,11 +434,11 @@ Public Class MySceneHostVM EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel) Dim nId As Integer = EgtGetFirstObjInSelWin() - ''usato come test (tutto in una sola funzione) - 'Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId)) - 'If EgtGetRawPartFromPart(nPartId) = GDB_ID.NULL Then Return - 'Dim nStat As Integer = GDB_ST.ON_ - 'EgtGetStatus(nPartId, nStat) + 'usato come test (tutto in una sola funzione) + Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId)) + If EgtGetRawPartFromPart(nPartId) = GDB_ID.NULL Then Return + Dim nStat As Integer = GDB_ST.ON_ + EgtGetStatus(nPartId, nStat) 'If nStat = GDB_ST.SEL Then ' EgtDeselectObj(nPartId) 'Else @@ -447,10 +447,10 @@ Public Class MySceneHostVM While nId <> GDB_ID.NULL ' Recupero l'identificativo del pezzo cui appartiene - Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId)) + nPartId = EgtGetParent(EgtGetParent(nId)) Dim bPartInTable As Boolean = (EgtGetParent(nPartId) = GetRawId()) If EgtGetRawPartFromPart(nPartId) <> GDB_ID.NULL Then - Dim nStat As Integer = GDB_ST.ON_ + 'Dim nStat As Integer = GDB_ST.ON_ ' recupero lo stato del pezzo EgtGetStatus(nPartId, nStat) ' Se già selezionato @@ -628,10 +628,10 @@ Public Class MySceneHostVM m_bDrag = False m_nIdToSel = GDB_ID.NULL m_nIdToDesel = GDB_ID.NULL - ' Se nessun pezzo selezionato, reset flag posizione selezionati - If EgtGetSelectedObjCount() = 0 Then - m_nPartPos = PART_POS.NONE_TABLE - End If + '' Se nessun pezzo selezionato, reset flag posizione selezionati + 'If EgtGetSelectedObjCount() = 0 Then + ' m_nPartPos = PART_POS.NONE_TABLE + 'End If EgtDraw() End Sub diff --git a/SceneHost/SceneHostV.xaml b/MySceneHost/SceneHostV.xaml similarity index 100% rename from SceneHost/SceneHostV.xaml rename to MySceneHost/SceneHostV.xaml diff --git a/SceneHost/SceneHostV.xaml.vb b/MySceneHost/SceneHostV.xaml.vb similarity index 100% rename from SceneHost/SceneHostV.xaml.vb rename to MySceneHost/SceneHostV.xaml.vb diff --git a/NCCommunication/NCCommunication.vb b/NCCommunication/NCCommunication.vb index a666820..e8ed78c 100644 --- a/NCCommunication/NCCommunication.vb +++ b/NCCommunication/NCCommunication.vb @@ -24,15 +24,24 @@ Public Class NCCommunication End Enum Private m_bFirst As Boolean = True - + ' inidica che il pezzo sul manipolatore 2 deve essere scaricato a mano + Private m_IsTryAgainToUnload2 As Boolean = False + ' indica che ci sono pezzi che devono essere scaricati a mano Private m_bWaitingManualUnloading As Boolean = False ' in caso di errore in fase di pallettizzazione, quando è terminato lo scarico manuale dei pezzi allora torna False Private m_bErrorLoading As Boolean = False ' indica che il ricalcolo del nesting per il pezzo rotto è stato fatto (attendo, devo passare le nuove coordinate) - Private m_bAdjustNesting As Boolean = False - ' indica il pezzo che è attulamene agganciato alla ventosa + Private m_bAdjustNestingTab1 As Boolean = False + ' indica che il ricalcolo del nesting per il pezzo rotto è stato fatto (attendo, devo passare le nuove coordinate) + Private m_bAdjustNestingTab2 As Boolean = False ' pezzo precedente, il primo è creato in modo fittizio Private m_LocalPrecPart As New Part(-10, -10) + ' riferiento alla finestra delle informazioni + Private m_InfoWindowVM As InfoWindowVM + ' riferiento alla finestra informazioni della tavola 1 + Private m_InfoWindow1VM As InfoWindowVM + ' forzo l'apertura dei magazzini + Friend m_OpenWarehouse As Boolean = False ' Timer Private m_TimerIsBusy As Boolean = False @@ -94,7 +103,36 @@ Public Class NCCommunication Exit For End If Next - + ' se lo stato del manipolatore-1 è "1", "2" oppure "3" significa che il primo pezzo della lista è in fase di elaborazione + Dim nVal1 As Integer = 0 + If ReadInt("StatusMachine1Read", nVal1) Then + If Not IsNothing(Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE)) AndAlso + Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE).Count > 0 AndAlso + (nVal1 = 1 OrElse nVal1 = 2) Then + Map.refUnloadingAreaVM.CurrPartTable1 = Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE)(0) + ElseIf Not IsNothing(Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE, StatusPart.WASTE)) AndAlso + Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE).Count > 0 AndAlso + nVal1 = 3 Then + Dim nLastWastePart As Integer = Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE, StatusPart.WASTE).Count - 1 + If nLastWastePart > 0 Then + Map.refUnloadingAreaVM.CurrPartTable1 = Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE, StatusPart.WASTE)(nLastWastePart) + End If + End If + End If + ' se lo stato del manipolatore-2 è "1", "2" oppure "3" significa che il primo pezzo della lista è in fase di elaborazione + Dim nVal2 As Integer = 0 + If ReadInt("StatusMachine2Read", nVal2) Then + If Not IsNothing(Map.refUnloadingAreaVM.GetParts(Place.ON_MOTOR_RULLER)) AndAlso + Map.refUnloadingAreaVM.GetParts(Place.ON_MOTOR_RULLER).Count > 0 AndAlso + (nVal2 = 1 OrElse nVal2 = 2 OrElse nVal2 = 3) Then + Map.refUnloadingAreaVM.CurrPartTable2 = Map.refUnloadingAreaVM.GetParts(Place.ON_MOTOR_RULLER)(0) + ' recupero il box corrente di deposito + Dim LocalCurrWarehouse As WarehouseVM = Map.refUnloadingAreaVM.GetCurrentWarehouse() + If Not IsNothing(LocalCurrWarehouse) Then + Map.refUnloadingAreaVM.CurrBox = Map.refUnloadingAreaVM.GetPartBox(Map.refUnloadingAreaVM.CurrPartTable2, LocalCurrWarehouse) + End If + End If + End If ' Eseguo subito la prima lettura variabili Refresh() End Sub @@ -111,6 +149,13 @@ Public Class NCCommunication Private Sub Refresh() OutLogProcess("----------------------- " & My.Computer.Clock.LocalTime.ToLongTimeString & "-----------------------") + ' verifico se è stato attivato il bottone + Map.refUnloadingAreaVM.NotifyPropertyChanged("ShowTabParts") + ' eventualmente aggiorno la lista dei pezzi + If Not IsNothing(Map.refUnloadingAreaVM.m_refTablePartWindowVM) Then + Map.refUnloadingAreaVM.m_refTablePartWindowVM.NotifyPropertyChanged("CurrentPartList") + End If + 'Dim n1Value As Integer = 0 'Dim x As Boolean = m_NC.ReadInt(81, 0, n1Value) 'Dim y As Boolean = m_NC.WriteInt(81, 0, 547) @@ -194,6 +239,8 @@ Public Class NCCommunication If nCounterManual = 0 Then ' nascondo la freccai rossa Map.refUnloadingAreaVM.RullerArrowVisibility = Visibility.Collapsed + + ' carico il nuovo progetto Dim sProjNew As String = Map.refMainWindowVM.MainWindowM.sProjDir & "\" & CURR_PROJ_NEW Dim sProjLock As String = Map.refMainWindowVM.MainWindowM.sProjDir & "\" & CURR_PROJ_LOCK @@ -219,9 +266,9 @@ Public Class NCCommunication WriteInt("TakePhoto", 0) End If End If - '' avendo caricato un nuovo progetto devo disporre il nuovo magazzino (se non ho altri progetti prima) - 'Map.refUnloadingAreaVM.bOrganizeWarehouse = True - End If + '' avendo caricato un nuovo progetto devo disporre il nuovo magazzino (se non ho altri progetti prima) + 'Map.refUnloadingAreaVM.bOrganizeWarehouse = True + End If End If ' aggiorno l'elenco dei progetti in esecuzione nel file Warehouse.ini @@ -256,39 +303,111 @@ Public Class NCCommunication ' se esiste un pezzo corrente allora significa che è stato scaricato correttamente If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable1) Then ' comunico che il pezzo è stato depositato sulla rulliera (aggiorno il file ini del progetto) - Map.refUnloadingAreaVM.CurrPartTable1.enPlace = Place.ON_MOTOR_RULLER + If Not Map.refUnloadingAreaVM.CurrPartTable1.enStatus = StatusPart.WASTE Then + Map.refUnloadingAreaVM.CurrPartTable1.enPlace = Place.ON_MOTOR_RULLER + End If EgtSetStatus(Map.refUnloadingAreaVM.CurrPartTable1.IdPart, GDB_ST.OFF) EgtDraw() OutLogProcess("[1] Pezzo depositato su rulliera: " & Map.refUnloadingAreaVM.CurrPartTable1.IdPart.ToString) End If ' passo al pezzo successivo, e lo rendo corrente Map.refUnloadingAreaVM.CurrPartTable1 = UnLoadTable1(SimulPosTab, SimulPosStrip, SimulCAng) - ' - m_bAdjustNesting = False + m_bAdjustNestingTab1 = False + ' salvo il deisegno del progetto corrente + If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable1) Then + EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & CURR_PROJ_NAME, NGE.BIN) + End If + Case StatusMachine.CHANGE_POINT OutLogProcess("[1] Stato macchina 1: 3") - ' se esisteva un pezzo corrente allora significa chè è stato scartato + ' chiedo conferma su cosa fare If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable1) Then - ' comunico che il pezzo è stato sacrtato (aggiorno il file ini del progetto) - Map.refUnloadingAreaVM.CurrPartTable1.enStatus = StatusPart.WASTE - OutLogProcess("[1] Pezzo scartato sul tavolo: " & Map.refUnloadingAreaVM.CurrPartTable1.IdPart.ToString) - Dim nIdRegion As Integer = GeomCalc.GetRegionFromPart(Map.refUnloadingAreaVM.CurrPartTable1.IdPart) - If nIdRegion > 0 Then - EgtSetColor(nIdRegion, New Color3d(255, 0, 0, 80)) - EgtDraw() + ' creo la finestra per eseguire la richiesta + If IsNothing(m_InfoWindow1VM) Then + m_InfoWindow1VM = New InfoWindowVM("Do you want to try again?", "Error in unloading 1") + m_InfoWindow1VM.m_RefInfoWindowV.Show() + Map.refUnloadingAreaVM.EnablePage = False End If - ' ricalcolo il Nesting dei pezzi StatusPart.GOOD - If Not m_bAdjustNesting Then - m_bAdjustNesting = True - AdjustNesting1D(Map.refUnloadingAreaVM.CurrPartTable1) + If m_InfoWindow1VM.TryAgain Then + WriteInt("StatusMachine1", CInt(StatusMachine.LOADED_POINT)) + m_InfoWindow1VM = Nothing + Map.refUnloadingAreaVM.EnablePage = True + Exit Select + ElseIf m_InfoWindow1VM.StopTry Then + ' dichiaro che il pezzo è rovinato + Map.refUnloadingAreaVM.CurrPartTable1.enStatus = StatusPart.WASTE + OutLogProcess("[1] Pezzo scartato sul tavolo: " & Map.refUnloadingAreaVM.CurrPartTable1.IdPart.ToString) + m_InfoWindow1VM = Nothing + Map.refUnloadingAreaVM.EnablePage = True + ' comunico che la macchina è libera + WriteInt("StatusMachine1", 0) + ' coloro di rosso il pezzo non depositabile + Dim nIdRegion As Integer = GeomCalc.GetRegionFromPart(Map.refUnloadingAreaVM.CurrPartTable1.IdPart) + If nIdRegion > 0 Then + EgtSetColor(nIdRegion, New Color3d(255, 0, 0, 80)) + EgtDraw() + End If + ' se è l'ultimo pezzo comunico che il progetto è terminato + If Map.refUnloadingAreaVM.CurrPartTable1.IsLast Then + Map.refUnloadingAreaVM.IdProjTable2.enStatus = StatusProj.DONE + OutLogProcess("[3] Progetto terminato: " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString) + ' elimino il fiel lock + Dim sProjLock As String = Map.refMainWindowVM.MainWindowM.sProjDir & "\" & CURR_PROJ_LOCK + If My.Computer.FileSystem.FileExists(sProjLock) Then + My.Computer.FileSystem.DeleteFile(sProjLock) + OutLogProcess("[3] Eliminato file: " & sProjLock) + End If + Map.refUnloadingAreaVM.CurrPartTable1 = Nothing + Exit Select + End If + ' ricalcolo il Nesting dei pezzi StatusPart.GOOD + If Not m_bAdjustNestingTab1 Then + m_bAdjustNestingTab1 = True + AdjustNesting1D(Map.refUnloadingAreaVM.CurrPartTable1) + End If End If - End If - ' passo al pezzo successivo, e lo rendo corrente - Map.refUnloadingAreaVM.CurrPartTable1 = UnLoadTable1(SimulPosTab, SimulPosStrip, SimulCAng) + + '' se esisteva un pezzo corrente allora significa chè è stato scartato + 'If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable1) Then + ' ' comunico che il pezzo è stato sacrtato (aggiorno il file ini del progetto) + ' Map.refUnloadingAreaVM.CurrPartTable1.enStatus = StatusPart.WASTE + ' OutLogProcess("[1] Pezzo scartato sul tavolo: " & Map.refUnloadingAreaVM.CurrPartTable1.IdPart.ToString) + ' Dim nIdRegion As Integer = GeomCalc.GetRegionFromPart(Map.refUnloadingAreaVM.CurrPartTable1.IdPart) + ' If nIdRegion > 0 Then + ' EgtSetColor(nIdRegion, New Color3d(255, 0, 0, 80)) + ' EgtDraw() + ' End If + ' ' se è l'ultimo pezzo comunico che il progetto è terminato + ' If Map.refUnloadingAreaVM.CurrPartTable1.IsLast Then + ' Map.refUnloadingAreaVM.IdProjTable2.enStatus = StatusProj.DONE + ' OutLogProcess("[3] Progetto terminato: " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString) + ' ' elimino il fiel lock + ' Dim sProjLock As String = Map.refMainWindowVM.MainWindowM.sProjDir & "\" & CURR_PROJ_LOCK + ' If My.Computer.FileSystem.FileExists(sProjLock) Then + ' My.Computer.FileSystem.DeleteFile(sProjLock) + ' OutLogProcess("[3] Eliminato file: " & sProjLock) + ' End If + ' Map.refUnloadingAreaVM.CurrPartTable1 = Nothing + ' ' comunico macchina disponibile + ' WriteInt("StatusMachine1", 0) + ' Exit Select + ' End If + ' ' ricalcolo il Nesting dei pezzi StatusPart.GOOD + ' If Not m_bAdjustNestingTab1 Then + ' m_bAdjustNestingTab1 = True + ' AdjustNesting1D(Map.refUnloadingAreaVM.CurrPartTable1) + ' End If + 'End If + + '' passo al pezzo successivo, e lo rendo corrente + 'Map.refUnloadingAreaVM.CurrPartTable1 = UnLoadTable1(SimulPosTab, SimulPosStrip, SimulCAng) + '' salvo il deisegno del progetto corrente + 'If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable1) Then + ' EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & CURR_PROJ_NAME, NGE.BIN) + 'End If End Select - ' aggiorno Pezzi rimasti sul tavolo (esclusi quelli rovinati) Map.refUnloadingAreaVM.NotifyPropertyChanged("Table1Percentage") ' aggiorno Pezzi attualmente sulla rulliera motorizzata @@ -304,7 +423,7 @@ Public Class NCCommunication End If ' se ventose attivate simulo la posizione di scarico If nValue = 1 And bRefreshSimul Then - ' non eseguo nessun controllo perchè il posizionamento della ventosa + ' non eseguo nessun controllo perchè posizionamento della ventosa SimulUnloadingTab1(Map.refUnloadingAreaVM.CurrPartTable1, SimulPosStrip, SimulCAng) ' salvo il valore dell'ultimo pezzo prelevato m_LocalPrecPart = Map.refUnloadingAreaVM.CurrPartTable1 @@ -356,6 +475,11 @@ Public Class NCCommunication End If End If + ' se la finestra "Status Machine 2" è aperta allora la aggiorno + If Not IsNothing(Map.refUnloadingAreaVM.m_refStatuMachine2VM) Then + Map.refUnloadingAreaVM.m_refStatuMachine2VM.SetStatusMachine() + End If + ' recupero il MAGAZZINO attivo, se non c'è magazzino attivo il pallettizzatore aspetta Dim CurrWarehouse As WarehouseVM = Map.refUnloadingAreaVM.GetCurrentWarehouse() If IsNothing(CurrWarehouse) Then Return @@ -381,12 +505,14 @@ Public Class NCCommunication Case StatusMachine.WAITING_POINT OutLogProcess("[3] Stato macchina 2: 0") + Dim bWaitingForManual As Boolean = False ' verifico che sul rullo siano stati depositati tutti i pezzi che riempiono un Layer If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable2) AndAlso - Map.refUnloadingAreaVM.CurrPartTable2.enUnloading = Unloading.AUTOMATIC Then + Map.refUnloadingAreaVM.CurrPartTable2.enUnloading = Unloading.AUTOMATIC AndAlso + Map.refUnloadingAreaVM.CurrPartTable2.enPlace <> Place.ON_BOX Then + ' comunico che il pezzo è stato depositato nel Box Map.refUnloadingAreaVM.CurrPartTable2.enPlace = Place.ON_BOX OutLogProcess("[3] Pezzo depositato nel Box: " & Map.refUnloadingAreaVM.CurrPartTable2.IdPart.ToString & " - " & Map.refUnloadingAreaVM.CurrPartTable2.IdBox.ToString) - 'EgtSetStatus(Map.refUnloadingAreaVM.CurrPartTable2.IdPart, GDB_ST.OFF) ' aggiorno la percentuale del box If Not IsNothing(Map.refUnloadingAreaVM.CurrBox) Then Map.refUnloadingAreaVM.CurrBox.NotifyPropertyChanged("nFillPercentage") ' se è l'ultimo pezzo comunico che il progetto è terminato @@ -400,40 +526,98 @@ Public Class NCCommunication OutLogProcess("[3] Eliminato file: " & sFile) End If Map.refUnloadingAreaVM.CurrPartTable2 = Nothing + Exit Select End If ' nascondo la freccia rossa sulla rulliera Map.refUnloadingAreaVM.RullerArrowVisibility = Visibility.Collapsed + ElseIf Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable2) AndAlso + Map.refUnloadingAreaVM.CurrPartTable2.enUnloading = Unloading.MANUAL AndAlso + Map.refUnloadingAreaVM.CurrPartTable2.enPlace <> Place.ON_WASTE_BOX Then + bWaitingForManual = True + ' rendo visibile la freccia rossa sulla rulliera + Map.refUnloadingAreaVM.RullerArrowVisibility = Visibility.Visible + If ReadInt("UnloadManualRead", nValue) Then + bRaededVariable = True + If nValue = 0 Then + ' lo scarico manulae del pezzo è avvenuto + Map.refUnloadingAreaVM.ClearOutputMessage() + m_bErrorLoading = False + ' significa che il pezzo è stato tolto a mano (dove è finito?) + Map.refUnloadingAreaVM.CurrPartTable2.enStatus = StatusPart.NOT_LOADED + Map.refUnloadingAreaVM.CurrPartTable2.enPlace = Place.ON_WASTE_BOX + bWaitingForManual = False + OutLogProcess("[3] Pezzo non prelevabile : " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString) + ' se ultimo pezzo + If Map.refUnloadingAreaVM.CurrPartTable2.IsLast Then + Map.refUnloadingAreaVM.IdProjTable2.enStatus = StatusProj.DONE + OutLogProcess("[3] Progetto terminato: " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString) + ' elimino il file ini associato + Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString & ".ini" + If My.Computer.FileSystem.FileExists(sFile) Then + My.Computer.FileSystem.DeleteFile(sFile) + OutLogProcess("[3] Eliminato file: " & sFile) + End If + Map.refUnloadingAreaVM.CurrPartTable2 = Nothing + Exit Select + End If + ' nascondo il pezzo + EgtSetStatus(Map.refUnloadingAreaVM.CurrPartTable2.IdPart, GDB_ST.OFF) + ' Ricalcolo la disposizione dei pezzi nel deposito + AdjustNesting1DTab2(Map.refUnloadingAreaVM.CurrPartTable2) + End If + End If End If - ' verifico che un intero Layer sia stato depositato sulla ruelliera - If CompleteLayerForUnloading(Map.refUnloadingAreaVM.IdProjTable2.nProjInd) Then + ' verifico che un intero Layer sia stato depositato sulla ruelliera e che il pezzo corrente non debba essere scaricato a mano + If CompleteLayerForUnloading(Map.refUnloadingAreaVM.IdProjTable2.nProjInd) And Not bWaitingForManual Then ' salvo le coordinate per afferrare e depositare i pezzi (solo quelli automatici) Map.refUnloadingAreaVM.CurrPartTable2 = UnLoadTable2(CurrWarehouse, Map.refUnloadingAreaVM.IdProjTable2.nProjInd) End If + ' salvo il deisegno del progetto corrente + If Map.refMainWindowVM.MainWindowM.nProjInd = Map.refUnloadingAreaVM.IdProjTable2.nProjInd Then + EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & CURR_PROJ_NAME, NGE.BIN) + End If + Case StatusMachine.CHANGE_POINT OutLogProcess("[3] Stato macchina 2: 3") ' rendo visibile la freccia rossa sulla rulliera Map.refUnloadingAreaVM.RullerArrowVisibility = Visibility.Visible - ' scarico i pezzi manualmente - UnloadManualPart(CurrWarehouse) - ' verifico che il pezzo sia stato prelevato prima di passare al successivo (bottone di scarico manuale) - If ReadInt("UnloadManualRead", nValue) Then - bRaededVariable = True - ' se nValue = 1 signifa che non è ancora stato scaricato - If nValue = 0 Then - Map.refUnloadingAreaVM.ClearOutputMessage() - m_bErrorLoading = False - ' significa che il pezzo è stato tolto a mano (dove è finito?) - If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable2) AndAlso - Map.refUnloadingAreaVM.CurrPartTable2.enUnloading = Unloading.AUTOMATIC Then - Map.refUnloadingAreaVM.CurrPartTable2.enStatus = StatusPart.NOT_LOADED - Map.refUnloadingAreaVM.CurrPartTable2.enPlace = Place.ON_WASTE_BOX - OutLogProcess("[3] Pezzo non prelevabile : " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString) + ' chiedo conferma su cosa fare + If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable2) Then + If IsNothing(m_InfoWindowVM) Then + m_InfoWindowVM = New InfoWindowVM("Do you want to try again?", "Error in unloading 2") + m_InfoWindowVM.m_RefInfoWindowV.Show() + Map.refUnloadingAreaVM.EnablePage = False + End If + If m_InfoWindowVM.TryAgain Then + WriteInt("StatusMachine2", CInt(StatusMachine.LOADED_POINT)) + m_InfoWindowVM = Nothing + Map.refUnloadingAreaVM.EnablePage = True + ' nascondo la freccia rossa sulla rulliera + Map.refUnloadingAreaVM.RullerArrowVisibility = Visibility.Collapsed + Exit Select + ElseIf m_InfoWindowVM.StopTry Then + ' dichiaro che il pezzo deve essere scaricaro a mano + Map.refUnloadingAreaVM.CurrPartTable2.enUnloading = Unloading.MANUAL + OutLogProcess("[3] Pezzo non prelevabile : " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString) + m_InfoWindowVM = Nothing + Map.refUnloadingAreaVM.EnablePage = True + ' comunico che attendo lo scarico manuale del pezzo + WriteReal("UnloadManual", 1) + ' comunico che la macchina è libera + WriteInt("StatusMachine2", 0) + ' coloro di rosso il pezzo non depositabile + Dim nIdRegion As Integer = GeomCalc.GetRegionFromPart(Map.refUnloadingAreaVM.CurrPartTable2.IdPart) + If nIdRegion > 0 Then + EgtSetColor(nIdRegion, New Color3d(255, 0, 0, 80)) + EgtDraw() End If End If End If - WriteReal("UnloadManual", 1) - ' nessun pezzo, aspetto che la macchina torni as assere in stato 0->WAITING_POINT (comandato dalla macchina) - Map.refUnloadingAreaVM.CurrPartTable2 = Nothing + ' salvo il deisegno del progetto corrente + If Map.refMainWindowVM.MainWindowM.nProjInd = Map.refUnloadingAreaVM.IdProjTable2.nProjInd Then + EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & CURR_PROJ_NAME, NGE.BIN) + End If + End Select End If ' Pezzi attualmente sulla rulliera motorizzata @@ -443,6 +627,8 @@ Public Class NCCommunication End Sub +#Region "METHODS" + ' salvo le coordinate per afferrare e depositare il pezzo sulla tavola 1 Private Function UnLoadTable1(ByRef PosTable1 As Point3d, ByRef PosStrip As Point3d, ByRef C_Ang As Double) As Part Dim LocalPart As Part = Nothing @@ -508,27 +694,40 @@ Public Class NCCommunication ' comunico nuovo stato alla macchina-> 1 WriteInt("StatusMachine1", CInt(StatusMachine.LOADED_POINT)) - 'EgtUILib.WritePrivateProfileString("0", "81.140", "1", "c:\EgtData\OmagVIEWPlus\Config\NC_Debug.ini") - OutLogProcess("UnLoadTable1() -> Communico punto di prelievo pezzo: " & LocalPart.IdPart.ToString) - OutLogProcess("UnLoadTable1() -> Stato macchina 1: 1 - " & LocalPart.IdPart.ToString) + 'EgtUILib.WritePrivateProfileString("0", "81.140", "1", "c:\EgtData\OmagVIEWPlus\Config\NC_Debug.ini") + OutLogProcess("UnLoadTable1() -> Communico punto di prelievo pezzo: " & LocalPart.IdPart.ToString) + OutLogProcess("UnLoadTable1() -> Stato macchina 1: 1 - " & LocalPart.IdPart.ToString) - End If + End If Return LocalPart End Function ' verifico se ho terminato il carcio dei Box Private Function EndedUnloading() As Boolean If IsNothing(Map.refUnloadingAreaVM.GetCurrentWarehouse) Then Return True + 'If Not m_OpenWarehouse Then For Each ItemBox In Map.refUnloadingAreaVM.GetCurrentWarehouse.Boxes - If ItemBox.State = States.LOADING Then - OutLogProcess("EndedUnloading() -> Box G" & ItemBox.OrigDefCN.ToString & " index " & ItemBox.Id.ToString & " incompleto") - Return False - End If - Next - OutLogProcess("EndedUnloading() -> Terimnato riempimento Boxs") + ItemBox.NotifyPropertyChanged("nFillPercentage") + If ItemBox.State = States.LOADING Then + OutLogProcess("EndedUnloading() -> Box G" & ItemBox.OrigDefCN.ToString & " index " & ItemBox.Id.ToString & " incompleto") + Return False + End If + Next + OutLogProcess("EndedUnloading() -> Terimnato riempimento Boxs") + 'Else + ' For Each ItemBox In Map.refUnloadingAreaVM.GetCurrentWarehouse.Boxes + ' ItemBox.NotifyPropertyChanged("nFillPercentage") + ' If ItemBox.State = States.LOADING Or ItemBox.State = States.AVAILABLE Then + ' ItemBox.IsAvailable = False + ' OutLogProcess("Box " & ItemBox.Id.ToString & " non disponibile per il ricalcolo") + ' End If + ' Next + ' OutLogProcess("EndedUnloading() -> Terimnato riempimento Boxs") + 'End If Return True End Function + ' simulo il prelievo dal tavolo 1 Private Sub SimulLoadingTab1(ByVal LocalPart As Part, PosTable1 As Point3d) EgtSetMachineLook(MCH_LOOK.TAB_HEAD) ' simulo la posizione di prelievo @@ -539,6 +738,7 @@ Public Class NCCommunication EgtDraw() End Sub + ' simulo lo scarico sulla rulliera dal tavolo 1 Private Sub SimulUnloadingTab1(ByVal LocalPart As Part, PosStrip As Point3d, C_Ang As Double) ' rappresento graficamente il deposito sulla rulliera dei pezzi If LocalPart.MoveTable1.m_bCupsSecondSel Then @@ -583,7 +783,7 @@ Public Class NCCommunication Return False End Function - ' salvo il magazzino attivo (solo se è differente da quello corrente) + ' salvo il magazzino attivo (solo se è differente da quello corrente) e lo comunico Private Sub SetActiveWarehouse(CurrWarehouse As WarehouseVM) Dim nValue As Integer = 0 Dim dValue As Double = 0 @@ -631,6 +831,7 @@ Public Class NCCommunication Return bStorageFound End Function + ' verifico che un layer sia completamente disponibile sulla rulliera, oppure che ci sia un numero minimo (letto da configurazione) di pezzi Private Function CompleteLayerForUnloading(IdProjTable2 As Integer) As Boolean ' verifico quali sono i pezzi presenti sulla rulliera Dim ListPartRuller As New ObservableCollection(Of Part) @@ -645,7 +846,7 @@ Public Class NCCommunication ' in emergenza: se ho più di 4 pezzi inizio a scaricare Dim nMaxPart As Integer = 5 nMaxPart = GetMainPrivateProfileInt("BOX", "MinCountPartRuller", nMaxPart) - If ListPartRuller.Count > nMaxPart Then + If ListPartRuller.Count >= nMaxPart Then Return True End If ' recupero il Layer del primo pezzo inserito sulla rulliera @@ -679,13 +880,13 @@ Public Class NCCommunication ' salvo le coordinate per afferrare e depositare il pezzo sulla tavola 2 Private Function UnLoadTable2(CurrWarehouse As WarehouseVM, IdProjTable2 As Integer) As Part Dim LocalPart As Part = Nothing - ' devo ricercare i pezzi del progetto che sto scricando + ' devo ricercare i pezzi del progetto che sto scaricando If Not IsNothing(Map.refUnloadingAreaVM.GetParts(IdProjTable2, Place.ON_MOTOR_RULLER)) AndAlso Map.refUnloadingAreaVM.GetParts(IdProjTable2, Place.ON_MOTOR_RULLER).Count > 0 Then LocalPart = Map.refUnloadingAreaVM.GetParts(IdProjTable2, Place.ON_MOTOR_RULLER)(0) ' se lo scarico previsto è manuale allora interrompo If LocalPart.enUnloading = Unloading.MANUAL Then - Return Nothing + Return LocalPart End If Dim bFoundBox As Boolean = False ' ricerco tra tutti i box del magazzino quello che deve accogliere il pezzo @@ -704,7 +905,9 @@ Public Class NCCommunication PartWritePrivateProfilePoint(LocalPart.IdProject, ConstIni.S_PART & LocalPart.IdPart.ToString, "PointRuller", PointRuller) ' rappresento graficamente il deposito sulla rulliera dei pezzi -> solo per la versione Debug - SimulLouadingTab2(LocalPart, PointRuller) + If Map.refMainWindowVM.MainWindowM.nProjInd = Map.refUnloadingAreaVM.IdProjTable2.nProjInd Then + SimulLouadingTab2(LocalPart, PointRuller) + End If ' restitusco la dimensione x del pezzo WriteReal("Rect2DimX", LocalPart.MoveTable2.m_vtRect.x * 2) @@ -736,7 +939,9 @@ Public Class NCCommunication WriteReal("B_Box", B_Ang) ' eseguo la simulazione di scarico sul Pallet -> solo per la versione Debug - SimulLoadingPallet(LocalPart, PointPallet, ItemBox.Id, CurrWarehouse.Id) + If Map.refMainWindowVM.MainWindowM.nProjInd = Map.refUnloadingAreaVM.IdProjTable2.nProjInd Then + SimulLoadingPallet(LocalPart, PointPallet, ItemBox.Id, CurrWarehouse.Id) + End If Else C_Ang = -90 @@ -752,7 +957,9 @@ Public Class NCCommunication WriteReal("B_Box", B_Ang) ' eseguo la simulazione di deposito dei pezzi sul Rack (nel delle ventose) - SimulUnloadingRack(LocalPart, PointRacks, ItemBox.Id, CurrWarehouse.Id) + If Map.refMainWindowVM.MainWindowM.nProjInd = Map.refUnloadingAreaVM.IdProjTable2.nProjInd Then + SimulUnloadingRack(LocalPart, PointRacks, ItemBox.Id, CurrWarehouse.Id) + End If End If ' salvo le ventose che devono essere attivate @@ -768,11 +975,23 @@ Public Class NCCommunication Next If bFoundBox Then Exit For Next + If Not bFoundBox Then + ' verifico se manca la definizione del magazzino nel pezzo + If LocalPart.IdBox = -1 Then + Map.refUnloadingAreaVM.ClearOutputMessage() + Map.refUnloadingAreaVM.SetOutputMessage("Organize warehouse") + ' libero i magazzini + Map.refUnloadingAreaVM.IdProjTable2.enStatus = StatusProj.LOADING + ' forzo l'apertura dei magazzini + m_OpenWarehouse = True + Return Nothing + End If + End If End If Return LocalPart End Function - ' trasformo tutti i pezzi che devono essere depositati sui pallet in pezzi manuali + ' trasformo tutti i pezzi che devono essere depositati sui pallet (quelli sui rack rimangono sui rack) in pezzi manuali Private Sub UnloadManualPart(CurrWarehouse As WarehouseVM) If m_bErrorLoading Then Return ' recupero tutti i pezzi che sono ancora sulla rulliera e sul tavolo @@ -813,101 +1032,277 @@ Public Class NCCommunication m_bErrorLoading = True End Sub + ' in caso di mancato prelievo di un pezzo dalla tavola 1 ricalcolo la disposizione dei pezzi (eventualmente su altri pallet) Private Sub AdjustNesting1D(WastePart As Part) - Dim nCurrLayer As Integer = 0 - ' recupero l'eleco dei pezzi che stanno sulla rulliera e sulla tavola + ' recupero l'eleco dei pezzi BUONI che stanno sulla tavola Dim PartListTable As New ObservableCollection(Of Part) - PartListTable = Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE) + PartListTable = Map.refUnloadingAreaVM.GetParts(WastePart.IdProject, Place.ON_TABLE) ' se non ci sno pezzi sulla tavola esco If PartListTable.Count() < 1 Then Return End If - + ' box associato al pezzo Dim CurrBox As Box = Nothing + ' magazzino corrente Dim CurrWarehouse As WarehouseVM = Map.refUnloadingAreaVM.GetCurrentWarehouse() - ' prima di cambiare pallet verifico di poter continuare ad usare lo stesso (shift dei layer succesivi) - If Not IsNothing(CurrWarehouse) And WastePart.IdBox > -1 Then - For Each ItemGridBox In CurrWarehouse.GridBoxList - Dim bFoundBox As Boolean = False - For Each ItemBox In ItemGridBox.CurrBoxList - If ItemBox.Id = WastePart.IdBox Then - CurrBox = ItemBox - bFoundBox = True - Exit For - End If - Next - If bFoundBox Then - Exit For - End If - Next - ' conto il numero di pezzi del Layer a cui appartiene il pezzo - Dim CounterPartLayer As Integer = 0 + ' se c'è un magazzino corrrente allora trovo il box corrente di scarico + If Not IsNothing(CurrWarehouse) Then + ' recupero il Box associato al pezzo + CurrBox = Map.refUnloadingAreaVM.GetPartBox(WastePart, CurrWarehouse) + End If + ' se il Box di deposito è un rack + If WastePart.IdBox > 6 And Not IsNothing(CurrBox) Then + ' elimino il pezzo dall'elenco dei pezzi da depositare sul rack ed esco + CurrBox.MyListPart.Remove(WastePart) + Return + End If + + ' -------------------- COSTRUISCO LA PILA -------------------- + ' conto il numero di pezzi del Layer a cui appartiene il pezzo + Dim CounterPartLayer As Integer = 0 + If Not IsNothing(CurrBox) Then + ' conto il numero di pezzi presenti nel Layer For Each ItemLayer In CurrBox.MyListPart If ItemLayer.nLayer = WastePart.nLayer Then CounterPartLayer = CounterPartLayer + 1 End If Next - ' se contiene un solo pezzo allora Shifto tutti layer successivi in basso - For Each ItemLayer In CurrBox.MyListPart - ItemLayer.nLayer = ItemLayer.nLayer - 1 + ' se contiene un solo pezzo allora Shifto tutti i layer successivi del box in basso + If CounterPartLayer = 1 Then + For Each ItemLayer In CurrBox.MyListPart + If ItemLayer.nLayer > WastePart.nLayer Then + ItemLayer.nLayer = ItemLayer.nLayer - 1 + End If + Next + CurrBox.MyListPart.Remove(WastePart) + Return + End If + Else + ' conto il numero di pezzi presenti nel Layer + For Each ItemLayer In PartListTable + If ItemLayer.nLayer = WastePart.nLayer Then + CounterPartLayer = CounterPartLayer + 1 + End If Next - Return + ' se contiene un solo pezzo allora Shifto tutti i layer successivi del box in basso + If CounterPartLayer = 1 Then + For Each ItemLayer In PartListTable + ItemLayer.nLayer = ItemLayer.nLayer - 1 + Next + Return + End If + End If + ' ------------------------------------------------------------ + ' verifico se il pezzo rovinato è il primo del Layer (ricerco se ci sono altri pezzi sulla rulliera o nel Box) + Dim CounterPartInLayer As Integer = 1 + Dim PrecLayer As New List(Of Part) + If Not IsNothing(CurrBox) Then + ' cerco è già stato depositato sulla rulliera o sul box un pezzo dello stesso Layer + For Each ItemMyList In CurrBox.MyListPart + If (ItemMyList.enPlace = Place.ON_BOX Or ItemMyList.enPlace = Place.ON_MOTOR_RULLER) AndAlso ItemMyList.nLayer = WastePart.nLayer Then + CounterPartInLayer = CounterPartInLayer + 1 + ElseIf (ItemMyList.enPlace = Place.ON_BOX Or ItemMyList.enPlace = Place.ON_MOTOR_RULLER) AndAlso ItemMyList.nLayer = WastePart.nLayer - 1 Then + PrecLayer.Add(ItemMyList) + End If + Next + Else + ' se non esiste nessun box attivo allora cerco solo sulla rulliera + For Each ItemMyList In Map.refUnloadingAreaVM.GetParts(WastePart.IdProject, Place.ON_MOTOR_RULLER) + If ItemMyList.nLayer = WastePart.nLayer Then + CounterPartInLayer = CounterPartInLayer + 1 + ElseIf ItemMyList.nLayer = WastePart.nLayer - 1 Then + PrecLayer.Add(ItemMyList) + End If + Next End If - ' lista dei pezzi presenti sulll'ultimo Layer + ' lista dei pezzi presenti sull'ultimo Layer Dim LastLayerList As New List(Of Part) - 'Dim PartListOnRuller As New List(Of Part) + ' liste dei pezzi della tavola divisi per dimensione + Dim PartListMax As New List(Of Part) Dim PartListMedium As New List(Of Part) Dim PartListMin As New List(Of Part) - Dim dDiffY As Double = Map.refUnloadingAreaVM.OffsetPalletY * 2 - ' classifico i pezzi (medi e piccoli) sul tavolo + ' classifico i pezzi (medi e piccoli) ancora sul tavolo For Each ItemPartTable In PartListTable - If ItemPartTable.MinRectX > 600 AndAlso ItemPartTable.MinRectX <= Map.refUnloadingAreaVM.MaxLength AndAlso ItemPartTable.IdBox = WastePart.IdBox Then - PartListMedium.Add(ItemPartTable) - ElseIf ItemPartTable.MinRectX <= 600 AndAlso ItemPartTable.IdBox = WastePart.IdBox Then - PartListMin.Add(ItemPartTable) - End If + GetPartialList(ItemPartTable.MinRectX, PartListMax, PartListMedium, PartListMin).Add(ItemPartTable) Next - EgtOutLog("Start Nesting") - nCurrLayer = 0 + Dim bFilled As Boolean = False + ' rimuovo i pezzi che vanno su un altro Box e quelli dello stesso Layer solo se CounterPartLayer>1 + If CounterPartInLayer = 1 Then + CamAuto.RemuovePartSameLayer(PartListMedium, WastePart, If(CounterPartInLayer = 1, False, True)) + CamAuto.RemuovePartSameLayer(PartListMin, WastePart, If(CounterPartInLayer = 1, False, True)) + Else + CamAuto.RemuovePartSameLayer(PartListMedium, WastePart, If(CounterPartInLayer = 1, False, True)) + CamAuto.RemuovePartSameLayer(PartListMin, WastePart, If(CounterPartInLayer = 1, False, True)) - ' eseguo il Nesting1D dei pezzi correnti, costruisco l'enco dei pezzi da depositare sui pallet + ' -------------------- SOSTITUISCO IL PEZZO ------------------ + ' cerco se esiste un pezzo che possa occupare il buco + For Each ItemMedium In PartListMedium + If Math.Abs(ItemMedium.MinRectY - WastePart.MinRectY) < EPS_SMALL Then + ' allora questo pezzo può sostituire quello rovinato + ItemMedium.IdBox = WastePart.IdBox + ItemMedium.nLayer = WastePart.nLayer + ItemMedium.dOffestPartY = WastePart.dOffestPartY + PartListMedium.Remove(ItemMedium) + bFilled = True + Exit For + End If + Next + + If Not bFilled Then + ' cerco se esiste un pezzo che possa occupare il buco + For Each ItemMin In PartListMin + If Math.Abs(ItemMin.MinRectY - WastePart.MinRectY) < EPS_SMALL Then + ' allora questo pezzo può sostituire quello rovinato + ItemMin.IdBox = WastePart.IdBox + ItemMin.nLayer = WastePart.nLayer + ItemMin.dOffestPartY = WastePart.dOffestPartY + PartListMin.Remove(ItemMin) + bFilled = True + Exit For + End If + Next + End If + + If bFilled Then + ' ricavo l'elenco dei pezzi del Layer precedente + If Not IsNothing(CurrBox) Then + ' cerco è già stato depositato sulla rulliera o sul box un pezzo dello stesso Layer + For Each ItemMyList In CurrBox.MyListPart + If (ItemMyList.enPlace = Place.ON_BOX Or ItemMyList.enPlace = Place.ON_MOTOR_RULLER) AndAlso ItemMyList.nLayer = WastePart.nLayer Then + PrecLayer.Add(ItemMyList) + End If + Next + Else + ' se non esiste nessun box attivo allora cerco solo sulla rulliera + For Each ItemMyList In Map.refUnloadingAreaVM.GetParts(WastePart.IdProject, Place.ON_MOTOR_RULLER) + If ItemMyList.nLayer = WastePart.nLayer Then + PrecLayer.Add(ItemMyList) + End If + Next + End If + End If + + If bFilled Then + ' rimuovo i pezzi che vanno su un altro Box e quelli dello stesso Layer solo se CounterPartLayer>1 + CamAuto.RemuovePartSameLayer(PartListMedium, WastePart, True) + CamAuto.RemuovePartSameLayer(PartListMin, WastePart, True) + End If + End If + ' ------------------------------------------------------------ + + ' dimensione Y di depisoto disponibile sul pallet + Dim dDiffY As Double = Map.refUnloadingAreaVM.OffsetPalletY * 2 + + ' se primo del Layer allora calcolo lo spazio disponibile sul layer precedente + If CounterPartInLayer = 1 Then + If PrecLayer.Count > 0 Then + Dim dStart As Double = PrecLayer(0).dOffestPartY - PrecLayer(0).MinRectY / 2 + Dim dEnd As Double = PrecLayer(0).dOffestPartY - PrecLayer(0).MinRectY / 2 + For Each ItemPrec In PrecLayer + If dStart > ItemPrec.dOffestPartY Then + dStart = ItemPrec.dOffestPartY - ItemPrec.MinRectY / 2 + End If + If dEnd < ItemPrec.dOffestPartY Then + dEnd = ItemPrec.dOffestPartY + ItemPrec.MinRectY / 2 + End If + Next + dDiffY = dEnd - dStart + End If + End If + + If Map.refUnloadingAreaVM.OffsetPalletY * 2 - dDiffY - Map.refUnloadingAreaVM.MinTollerance * 2 > -EPS_SMALL Then + dDiffY = dDiffY + Map.refUnloadingAreaVM.MinTollerance * 2 + End If + + ' ripulisco la lista del Box corrente da tutti i pezzi successivi + If Not IsNothing(CurrBox) Then + Dim IndexPartBox As Integer = 0 + Dim RemoveList As New List(Of Part) + For IndexPartBox = 0 To CurrBox.MyListPart.Count - 1 + If CounterPartInLayer = 1 Then + If CurrBox.MyListPart(IndexPartBox).nLayer >= WastePart.nLayer Then + RemoveList.Add(CurrBox.MyListPart(IndexPartBox)) + CurrBox.MyListPart(IndexPartBox).IdBox = -1 + End If + Else + If CurrBox.MyListPart(IndexPartBox).nLayer > WastePart.nLayer Then + RemoveList.Add(CurrBox.MyListPart(IndexPartBox)) + CurrBox.MyListPart(IndexPartBox).IdBox = -1 + End If + End If + Next + For Each ItemIndex In RemoveList + CurrBox.MyListPart.Remove(ItemIndex) + Next + CurrBox.MyListPart.Remove(WastePart) + End If + + ' -------------------- CALCOLO IL NESTING -------------------- + EgtOutLog("Start Nesting") + Dim nCurrLayer As Integer = 0 + ' eseguo il Nesting1D dei pezzi correnti, costruisco l'elenco dei pezzi da depositare sui pallet If PartListMedium.Count > 0 And Not MyNesting1D(PartListMedium, dDiffY, LastLayerList, nCurrLayer) Then Map.refUnloadingAreaVM.ClearOutputMessage() - Map.refUnloadingAreaVM.SetOutputMessage("Impossible to renest part.") + Map.refUnloadingAreaVM.SetOutputMessage("Impossible to repeat nesting part.") + ' elimino le assegnazioni al box di tutti i pezzi che sono ancora sulla tavola + If Not IsNothing(CurrBox) Then + For Each ItemMyList In CurrBox.MyListPart + If ItemMyList.enPlace = Place.ON_TABLE Then + ItemMyList.IdBox = -1 + End If + Next + End If Return End If + ' recupero l'indice dell'ultimo Layer calcolato If LastLayerList.Count > 0 Then nCurrLayer = LastLayerList(0).nLayer - ' eseguo il nestin tra due liste + ' eseguo il nesting tra due liste If PartListMedium.Count > 0 And JoinNesting1D(PartListMedium, PartListMin, LastLayerList, dDiffY, nCurrLayer) Then nCurrLayer = nCurrLayer + 1 End If ' eseguo il nesting dei pezzi rimanenti If PartListMin.Count > 0 And Not MyNesting1D(PartListMin, dDiffY, LastLayerList, nCurrLayer) Then Map.refUnloadingAreaVM.ClearOutputMessage() - Map.refUnloadingAreaVM.SetOutputMessage("Impossible to renest part.") + Map.refUnloadingAreaVM.SetOutputMessage("Impossible to repeat nesting part.") + ' elimino le assegnazioni al box di tutti i pezzi che sono ancora sulla tavola + If Not IsNothing(CurrBox) Then + For Each ItemMyList In CurrBox.MyListPart + If ItemMyList.enPlace = Place.ON_TABLE Then + ItemMyList.IdBox = -1 + End If + Next + End If Return End If ' comunico che il processo di Nesting è terminato EgtOutLog("End Nesting") + ' ------------------------------------------------------------ + ' lista dei pezzi ceh devono essere riposizionati sullo stesso Pallet Dim ActualListPart As New List(Of Part) + + ' -------------------- RIORDINO LA LISTA -------------------- ' riordino l'elenco dei pezzi (dal Primo Layer all'ultimo Layer) Dim StartLayer As Integer = 0 Dim bLayerExist As Boolean = True + ' se trovo un pezzo che appartiene al layer allora rimango nel ciclo While bLayerExist bLayerExist = False + ' ricerco tutti i pezzi che appartengono allo stesso layer For Each ItemPart In PartListMedium If ItemPart.nLayer = StartLayer Then ActualListPart.Add(ItemPart) Dim IndexPart As Integer = 0 - ' rimuovo i pezzi appena ricalcolati dall'elenco dei pezzi + ' rimuovo il pezzi appena ricalcolato dall'elenco dei pezzi For IndexPart = 0 To Map.refUnloadingAreaVM.ListPart.Count - 1 - If Map.refUnloadingAreaVM.ListPart(IndexPart).IdPart = ItemPart.IdPart Then + If Map.refUnloadingAreaVM.ListPart(IndexPart).IdPart = ItemPart.IdPart AndAlso + Map.refUnloadingAreaVM.ListPart(IndexPart).IdProject = ItemPart.IdProject AndAlso + Map.refUnloadingAreaVM.ListPart(IndexPart).enPlace = Place.ON_TABLE Then Map.refUnloadingAreaVM.ListPart.RemoveAt(IndexPart) Exit For End If @@ -915,18 +1310,23 @@ Public Class NCCommunication bLayerExist = True End If Next + ' passo al Layer successivo StartLayer = StartLayer + 1 End While + bLayerExist = True StartLayer = StartLayer - 1 While bLayerExist bLayerExist = False + ' ricerco tutti i pezzi che appartengono allo stesso layer For Each ItemPart In PartListMin If ItemPart.nLayer = StartLayer Then ActualListPart.Add(ItemPart) For IndexPart = 0 To Map.refUnloadingAreaVM.ListPart.Count - 1 ' rimuovo i pezzi appena ricalcolati dall'elenco dei pezzi - If Map.refUnloadingAreaVM.ListPart(IndexPart).IdPart = ItemPart.IdPart Then + If Map.refUnloadingAreaVM.ListPart(IndexPart).IdPart = ItemPart.IdPart AndAlso + Map.refUnloadingAreaVM.ListPart(IndexPart).IdProject = ItemPart.IdProject AndAlso + Map.refUnloadingAreaVM.ListPart(IndexPart).enPlace = Place.ON_TABLE Then Map.refUnloadingAreaVM.ListPart.RemoveAt(IndexPart) Exit For End If @@ -934,8 +1334,10 @@ Public Class NCCommunication bLayerExist = True End If Next + ' passo al Layer successivo StartLayer = StartLayer + 1 End While + ' ------------------------------------------------------------ ' cancello il file PartList.ini e lo riscrivo completamente Dim nIdProj As Integer = Map.refUnloadingAreaVM.IdProjTable2.nProjInd @@ -945,47 +1347,81 @@ Public Class NCCommunication OutLogProcess("AdjustNesting1D-> Riscrivo l'elenco di prelievo dei pezzi" & sFile) End If - ' cerco il primo pallet disponibile - Dim IdBoxAvailable As Integer = -1 + ' -------------------- DEFINIZIONE DEI BOX ------------------ + Dim NewBox As Box = Nothing - Dim OldBox As Box = Nothing - If Not IsNothing(CurrWarehouse) Then - Dim OldIdBox As Integer = -1 - If ActualListPart.Count > 0 Then - OldIdBox = ActualListPart(0).IdBox - End If - For Each ItemGridBox In CurrWarehouse.GridBoxList - For Each ItemBox In ItemGridBox.CurrBoxList - If ItemBox.Id = OldIdBox Then - ItemBox.MyListPart.Clear() - End If - Next + ' se primo pezzo di un Layer allora non devo cambiare Pallet + If CounterPartInLayer = 1 Then + For Each ItemActual In ActualListPart + ' assegno il Layer + ItemActual.nLayer = ItemActual.nLayer + WastePart.nLayer + If Not IsNothing(CurrBox) Then + ' se esiste un Box allora assegno l'indirizzo del Box + NewBox = CurrBox + ItemActual.IdBox = CurrBox.Id + End If Next - - For Each ItemGridBox In CurrWarehouse.GridBoxList - For Each ItemBox In ItemGridBox.CurrBoxList - If ItemBox.State = States.AVAILABLE Then - If ItemGridBox.IsPallet Then - IdBoxAvailable = ItemBox.Id - NewBox = ItemBox - Exit For + ElseIf bFilled Then + For Each ItemActual In ActualListPart + ' assegno il Layer + ItemActual.nLayer = ItemActual.nLayer + WastePart.nLayer + 1 + If Not IsNothing(CurrBox) Then + ' se esiste un Box allora assegno l'indirizzo del Box + NewBox = CurrBox + ItemActual.IdBox = CurrBox.Id + End If + Next + Else + ' cerco il primo pallet disponibile + Dim IdBoxAvailable As Integer = -1 + If Not IsNothing(CurrWarehouse) Then + For Each ItemGridBox In CurrWarehouse.GridBoxList + For Each ItemBox In ItemGridBox.CurrBoxList + If ItemBox.State = States.AVAILABLE AndAlso ItemBox.MyListPart.Count = 0 Then + If ItemGridBox.IsPallet Then + IdBoxAvailable = ItemBox.Id + NewBox = ItemBox + Exit For + End If End If - End If + Next + ' se ho trovato un box disponibile + If IdBoxAvailable <> -1 Then Exit For Next - If IdBoxAvailable <> -1 Then Exit For - Next + End If End If + ' ------------------------------------------------------------ + ' ricavo l'indice da cui iniziare ad inserire i pezzi da depositare Dim IndexMaualPart As Integer = 0 For IndexMaualPart = 0 To Map.refUnloadingAreaVM.ListPart.Count - 1 - If Map.refUnloadingAreaVM.ListPart(IndexMaualPart).enUnloading = Unloading.MANUAL Then + If Map.refUnloadingAreaVM.ListPart(IndexMaualPart).IdProject = WastePart.IdProject And + Map.refUnloadingAreaVM.ListPart(IndexMaualPart).enUnloading = Unloading.MANUAL And + Map.refUnloadingAreaVM.ListPart(IndexMaualPart).enPlace = Place.ON_TABLE Then Exit For End If Next + Dim IndexRack As Integer = 0 + If PartListMax.Count > 0 Then + For IndexRack = 0 To Map.refUnloadingAreaVM.ListPart.Count - 1 + If Map.refUnloadingAreaVM.ListPart(IndexRack).IdProject = WastePart.IdProject And + Map.refUnloadingAreaVM.ListPart(IndexRack).IdPart = PartListMax(0).IdPart And + Map.refUnloadingAreaVM.ListPart(IndexRack).enPlace = Place.ON_TABLE Then + IndexMaualPart = IndexRack + Exit For + End If + Next + End If ' reinserisco i pezzi nella lista For Each ActualItemPart In ActualListPart - Map.refUnloadingAreaVM.ListPart.Insert(IndexMaualPart, ActualItemPart) + ' verifico che il pezzo non esiste già nella lista + For Each ItemPart In Map.refUnloadingAreaVM.ListPart + If ItemPart.IdProject = WastePart.IdProject AndAlso Not ItemPart.IdPart = ActualItemPart.IdPart Then + Map.refUnloadingAreaVM.ListPart.Insert(IndexMaualPart, ActualItemPart) + Exit For + End If + Next IndexMaualPart = IndexMaualPart + 1 ' modifico il colore dei pezzi che sono stati ricalcolati Dim nIdCurrRegion As Integer = GeomCalc.GetRegionFromPart(ActualItemPart.IdPart) @@ -994,24 +1430,399 @@ Public Class NCCommunication EgtDraw() End If If Not IsNothing(NewBox) Then + ' se ho trovato un Box su cui scaricare NewBox.MyListPart.Add(ActualItemPart) + ActualItemPart.IdBox = NewBox.Id + ElseIf IsNothing(NewBox) And (CounterPartInLayer = 1 Or bFilled) Then + ' se posso continuare a scaricare nei Layer successivi (senza aver definito la disponibilità dei magazzini) + If nIdCurrRegion > 0 Then + EgtSetColor(nIdCurrRegion, New Color3d(0, 85, 170, 80)) + EgtDraw() + End If + ElseIf IsNothing(NewBox) And (CounterPartInLayer <> 1 Or Not bFilled) Then + ' se devo cambiare Box (prima di aver definito il magazzino) + ActualItemPart.IdBox = -1 + If nIdCurrRegion > 0 Then + EgtSetColor(nIdCurrRegion, New Color3d(0, 150, 250, 80)) + EgtDraw() + End If End If Next ' salvo tutto nel file PartList.ini Dim nListCount As Integer = 0 - For Each ItemCurrList In Map.refUnloadingAreaVM.ListPart - If ItemCurrList.IdProject = nIdProj Then + Dim LastIndex As Integer = 0 + For LastIndex = 0 To Map.refUnloadingAreaVM.ListPart.Count - 1 + If Map.refUnloadingAreaVM.ListPart(LastIndex).IdProject = nIdProj Then nListCount = nListCount + 1 - ItemCurrList.SavePart(ItemCurrList.IdPart) - ItemCurrList.IdBox = IdBoxAvailable - ItemCurrList.dOffestPartY = ItemCurrList.dOffestPartY - PartWritePrivateProfileString(ItemCurrList.IdProject, "PartList", "IdPart" & nListCount.ToString, ItemCurrList.IdPart.ToString) + Map.refUnloadingAreaVM.ListPart(LastIndex).SavePart(Map.refUnloadingAreaVM.ListPart(LastIndex).IdPart) + Map.refUnloadingAreaVM.ListPart(LastIndex).IdBox = Map.refUnloadingAreaVM.ListPart(LastIndex).IdBox + Map.refUnloadingAreaVM.ListPart(LastIndex).dOffestPartY = Map.refUnloadingAreaVM.ListPart(LastIndex).dOffestPartY + If LastIndex > 0 Then + Map.refUnloadingAreaVM.ListPart(LastIndex - 1).SetIsLast(False) + End If + Map.refUnloadingAreaVM.ListPart(LastIndex).SetIsLast(True) + PartWritePrivateProfileString(Map.refUnloadingAreaVM.ListPart(LastIndex).IdProject, "PartList", "IdPart" & nListCount.ToString, Map.refUnloadingAreaVM.ListPart(LastIndex).IdPart.ToString) End If Next End Sub + ' in caso di mancato prelievo dei pezzi dalla tavola 2 ricalcolo la disposizione dei pezzi (eventualmente su altri pallet) + Private Sub AdjustNesting1DTab2(WastePart As Part) + ' recupero l'eleco dei pezzi BUONI che stanno sulla tavola (per il calcolo degli indici per il reinserimento dei pezzinella lista) + Dim PartListTable As New ObservableCollection(Of Part) + PartListTable = Map.refUnloadingAreaVM.GetParts(WastePart.IdProject, Place.ON_TABLE) + + 'Dim PartListRuller As New ObservableCollection(Of Part) + 'PartListRuller = Map.refUnloadingAreaVM.GetParts(WastePart.IdProject, Place.ON_MOTOR_RULLER) + '' se non ci sno pezzi sulla tavola esco + 'If PartListTable.Count() + PartListRuller.Count() < 1 Then + ' Return + 'End If + + ' box associato al pezzo + Dim CurrBox As Box = Nothing + ' magazzino corrente + Dim CurrWarehouse As WarehouseVM = Map.refUnloadingAreaVM.GetCurrentWarehouse() + ' se c'è un magazzino corrrente allora trovo il box corrente di scarico + If Not IsNothing(CurrWarehouse) Then + ' recupero il Box associato al pezzo + CurrBox = Map.refUnloadingAreaVM.GetPartBox(WastePart, CurrWarehouse) + Else + ' se non esiste un magazzino associato come faccio a scaricare? + Return + End If + ' se il Box di deposito è un rack + If WastePart.IdBox > 6 And Not IsNothing(CurrBox) Then + ' elimino il pezzo dall'elenco dei pezzi da depositare sul rack ed esco + CurrBox.MyListPart.Remove(WastePart) + Return + End If + + ' -------------------- COSTRUISCO LA PILA -------------------- + ' conto il numero di pezzi del Layer a cui appartiene il pezzo + Dim CounterPartLayer As Integer = 0 + If Not IsNothing(CurrBox) Then + ' conto il numero di pezzi presenti nel Layer + For Each ItemLayer In CurrBox.MyListPart + If ItemLayer.nLayer = WastePart.nLayer Then + CounterPartLayer = CounterPartLayer + 1 + End If + Next + ' se contiene un solo pezzo allora Shifto tutti i layer successivi del box in basso + If CounterPartLayer = 1 Then + For Each ItemLayer In CurrBox.MyListPart + If ItemLayer.nLayer > WastePart.nLayer Then + ItemLayer.nLayer = ItemLayer.nLayer - 1 + End If + Next + CurrBox.MyListPart.Remove(WastePart) + Return + End If + 'Else + ' ' conto il numero di pezzi presenti nel Layer + ' For Each ItemLayer In PartListTable + ' If ItemLayer.nLayer = WastePart.nLayer Then + ' CounterPartLayer = CounterPartLayer + 1 + ' End If + ' Next + ' ' se contiene un solo pezzo allora Shifto tutti i layer successivi del box in basso + ' If CounterPartLayer = 1 Then + ' For Each ItemLayer In PartListTable + ' ItemLayer.nLayer = ItemLayer.nLayer - 1 + ' Next + ' Return + ' End If + End If + ' ------------------------------------------------------------ + + '' verifico se il pezzo rovinato è il primo del Layer (ricerco se ci sono altri pezzi sulla rulliera o nel Box) + 'Dim CounterPartInLayer As Integer = 1 + 'Dim PrecLayer As New List(Of Part) + 'If Not IsNothing(CurrBox) Then + ' ' cerco è già stato depositato sulla rulliera o sul box un pezzo dello stesso Layer + ' For Each ItemMyList In CurrBox.MyListPart + ' If (ItemMyList.enPlace = Place.ON_BOX Or ItemMyList.enPlace = Place.ON_MOTOR_RULLER) AndAlso ItemMyList.nLayer = WastePart.nLayer Then + ' CounterPartInLayer = CounterPartInLayer + 1 + ' ElseIf (ItemMyList.enPlace = Place.ON_BOX Or ItemMyList.enPlace = Place.ON_MOTOR_RULLER) AndAlso ItemMyList.nLayer = WastePart.nLayer - 1 Then + ' PrecLayer.Add(ItemMyList) + ' End If + ' Next + 'Else + ' ' se non esiste nessun box attivo allora cerco solo sulla rulliera + ' For Each ItemMyList In Map.refUnloadingAreaVM.GetParts(WastePart.IdProject, Place.ON_MOTOR_RULLER) + ' If ItemMyList.nLayer = WastePart.nLayer Then + ' CounterPartInLayer = CounterPartInLayer + 1 + ' ElseIf ItemMyList.nLayer = WastePart.nLayer - 1 Then + ' PrecLayer.Add(ItemMyList) + ' End If + ' Next + 'End If + + '' se non è il prim del Layer cerco un pezzo Uguale che possa sostituirlo + + ' dimensione Y di depisoto disponibile sul pallet + 'Dim dDiffY As Double = Map.refUnloadingAreaVM.OffsetPalletY * 2 + + '' se primo del Layer allora calcolo lo spazio disponibile sul layer precedente + 'If CounterPartInLayer = 1 Then + ' If PrecLayer.Count > 0 Then + ' Dim dStart As Double = PrecLayer(0).dOffestPartY - PrecLayer(0).MinRectY / 2 + ' Dim dEnd As Double = PrecLayer(0).dOffestPartY - PrecLayer(0).MinRectY / 2 + ' For Each ItemPrec In PrecLayer + ' If dStart > ItemPrec.dOffestPartY Then + ' dStart = ItemPrec.dOffestPartY - ItemPrec.MinRectY / 2 + ' End If + ' If dEnd < ItemPrec.dOffestPartY Then + ' dEnd = ItemPrec.dOffestPartY + ItemPrec.MinRectY / 2 + ' End If + ' Next + ' dDiffY = dEnd - dStart + ' End If + 'End If + + '' lista dei pezzi presenti sull'ultimo Layer + 'Dim LastLayerList As New List(Of Part) + + ' liste dei pezzi della tavola divisi per dimensione + Dim PartListMax As New List(Of Part) + Dim PartListMedium As New List(Of Part) + Dim PartListMin As New List(Of Part) + + ' classifico i pezzi (medi e piccoli) ancora sul tavolo + For Each ItemPartTable In PartListTable + GetPartialList(ItemPartTable.MinRectX, PartListMax, PartListMedium, PartListMin).Add(ItemPartTable) + Next + + '' rimuovo i pezzi che vanno su un altro Box e quelli dello stesso Layer solo se CounterPartLayer>1 + 'CamAuto.RemuovePartSameLayer(PartListMedium, WastePart, False) + 'CamAuto.RemuovePartSameLayer(PartListMin, WastePart, False) + + ' lista dei pezzi da depositare su un nuovo pallet + Dim NewListPallet As New List(Of Part) + ' ripulisco la lista del Box corrente da tutti i pezzi successivi (che andranno su un altro pallet) e anche dalla lista + If Not IsNothing(CurrBox) Then + Dim IndexPartBox As Integer = 0 + Dim RemoveList As New List(Of Part) + For IndexPartBox = 0 To CurrBox.MyListPart.Count - 1 + If CurrBox.MyListPart(IndexPartBox).nLayer > WastePart.nLayer Then + RemoveList.Add(CurrBox.MyListPart(IndexPartBox)) + NewListPallet.Add(CurrBox.MyListPart(IndexPartBox)) + CurrBox.MyListPart(IndexPartBox).IdBox = -1 + CurrBox.MyListPart(IndexPartBox).nLayer = CurrBox.MyListPart(IndexPartBox).nLayer - WastePart.nLayer - 1 + '' rimuovo i pezzi appena ricalcolati dall'elenco dei pezzi + 'For IndexPart = 0 To Map.refUnloadingAreaVM.ListPart.Count - 1 + ' If Map.refUnloadingAreaVM.ListPart(IndexPart).IdPart = CurrBox.MyListPart(IndexPartBox).IdPart AndAlso + ' Map.refUnloadingAreaVM.ListPart(IndexPart).IdProject = CurrBox.MyListPart(IndexPartBox).IdProject AndAlso + ' Map.refUnloadingAreaVM.ListPart(IndexPart).enPlace = Place.ON_TABLE Then + ' Map.refUnloadingAreaVM.ListPart.RemoveAt(IndexPart) + ' Exit For + ' End If + 'Next + End If + Next + For Each ItemIndex In RemoveList + CurrBox.MyListPart.Remove(ItemIndex) + Next + CurrBox.MyListPart.Remove(WastePart) + End If + + '' -------------------- CALCOLO IL NESTING -------------------- + 'EgtOutLog("Start Nesting") + 'Dim nCurrLayer As Integer = 0 + '' eseguo il Nesting1D dei pezzi correnti, costruisco l'elenco dei pezzi da depositare sui pallet + 'If PartListMedium.Count > 0 And Not MyNesting1D(PartListMedium, dDiffY, LastLayerList, nCurrLayer) Then + ' Map.refUnloadingAreaVM.ClearOutputMessage() + ' Map.refUnloadingAreaVM.SetOutputMessage("Impossible to repeat nesting part.") + ' ' elimino le assegnazioni al box di tutti i pezzi che sono ancora sulla tavola + ' If Not IsNothing(CurrBox) Then + ' For Each ItemMyList In CurrBox.MyListPart + ' If ItemMyList.enPlace = Place.ON_TABLE Then + ' ItemMyList.IdBox = -1 + ' End If + ' Next + ' End If + ' Return + 'End If + + '' recupero l'indice dell'ultimo Layer calcolato + 'If LastLayerList.Count > 0 Then nCurrLayer = LastLayerList(0).nLayer + '' eseguo il nesting tra due liste + 'If PartListMedium.Count > 0 And JoinNesting1D(PartListMedium, PartListMin, LastLayerList, dDiffY, nCurrLayer) Then + ' nCurrLayer = nCurrLayer + 1 + 'End If + '' eseguo il nesting dei pezzi rimanenti + 'If PartListMin.Count > 0 And Not MyNesting1D(PartListMin, dDiffY, LastLayerList, nCurrLayer) Then + ' Map.refUnloadingAreaVM.ClearOutputMessage() + ' Map.refUnloadingAreaVM.SetOutputMessage("Impossible to repeat nesting part.") + ' ' elimino le assegnazioni al box di tutti i pezzi che sono ancora sulla tavola + ' If Not IsNothing(CurrBox) Then + ' For Each ItemMyList In CurrBox.MyListPart + ' If ItemMyList.enPlace = Place.ON_TABLE Then + ' ItemMyList.IdBox = -1 + ' End If + ' Next + ' End If + ' Return + 'End If + '' comunico che il processo di Nesting è terminato + 'EgtOutLog("End Nesting") + '' ------------------------------------------------------------ + + '' lista dei pezzi ceh devono essere riposizionati sullo stesso Pallet + 'Dim ActualListPart As New List(Of Part) + + '' -------------------- RIORDINO LA LISTA -------------------- + '' riordino l'elenco dei pezzi (dal Primo Layer all'ultimo Layer) + 'Dim StartLayer As Integer = 0 + 'Dim bLayerExist As Boolean = True + '' se trovo un pezzo che appartiene al layer allora rimango nel ciclo + 'While bLayerExist + ' bLayerExist = False + ' ' ricerco tutti i pezzi che appartengono allo stesso layer + ' For Each ItemPart In PartListMedium + ' If ItemPart.nLayer = StartLayer Then + ' ActualListPart.Add(ItemPart) + ' Dim IndexPart As Integer = 0 + ' ' rimuovo il pezzi appena ricalcolato dall'elenco dei pezzi + ' For IndexPart = 0 To Map.refUnloadingAreaVM.ListPart.Count - 1 + ' If Map.refUnloadingAreaVM.ListPart(IndexPart).IdPart = ItemPart.IdPart Then + ' Map.refUnloadingAreaVM.ListPart.RemoveAt(IndexPart) + ' Exit For + ' End If + ' Next + ' bLayerExist = True + ' End If + ' Next + ' ' passo al Layer successivo + ' StartLayer = StartLayer + 1 + 'End While + + 'bLayerExist = True + 'StartLayer = StartLayer - 1 + 'While bLayerExist + ' bLayerExist = False + ' ' ricerco tutti i pezzi che appartengono allo stesso layer + ' For Each ItemPart In PartListMin + ' If ItemPart.nLayer = StartLayer Then + ' ActualListPart.Add(ItemPart) + ' For IndexPart = 0 To Map.refUnloadingAreaVM.ListPart.Count - 1 + ' ' rimuovo i pezzi appena ricalcolati dall'elenco dei pezzi + ' If Map.refUnloadingAreaVM.ListPart(IndexPart).IdPart = ItemPart.IdPart Then + ' Map.refUnloadingAreaVM.ListPart.RemoveAt(IndexPart) + ' Exit For + ' End If + ' Next + ' bLayerExist = True + ' End If + ' Next + ' ' passo al Layer successivo + ' StartLayer = StartLayer + 1 + 'End While + '' ------------------------------------------------------------ + + '' cancello il file PartList.ini e lo riscrivo completamente + 'Dim nIdProj As Integer = Map.refUnloadingAreaVM.IdProjTable2.nProjInd + 'Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString & ".ini" + 'If My.Computer.FileSystem.FileExists(sFile) Then + ' My.Computer.FileSystem.DeleteFile(sFile) + ' OutLogProcess("AdjustNestingTab21D-> Riscrivo l'elenco di prelievo dei pezzi" & sFile) + 'End If + + ' -------------------- DEFINIZIONE DEI BOX ------------------ + + Dim NewBox As Box = Nothing + Dim IdBoxAvailable As Integer = -1 + If Not IsNothing(CurrWarehouse) Then + For Each ItemGridBox In CurrWarehouse.GridBoxList + For Each ItemBox In ItemGridBox.CurrBoxList + If ItemBox.State = States.AVAILABLE AndAlso ItemBox.MyListPart.Count = 0 Then + If ItemGridBox.IsPallet Then + IdBoxAvailable = ItemBox.Id + NewBox = ItemBox + Exit For + End If + End If + Next + ' se ho trovato un box disponibile + If IdBoxAvailable <> -1 Then Exit For + Next + End If + + ' ------------------------------------------------------------ + + '' ricavo l'indice da cui iniziare ad inserire i pezzi da depositare + 'Dim IndexMaualPart As Integer = 0 + 'For IndexMaualPart = 0 To Map.refUnloadingAreaVM.ListPart.Count - 1 + ' If Map.refUnloadingAreaVM.ListPart(IndexMaualPart).IdProject = WastePart.IdProject And + ' Map.refUnloadingAreaVM.ListPart(IndexMaualPart).enUnloading = Unloading.MANUAL And + ' Map.refUnloadingAreaVM.ListPart(IndexMaualPart).enPlace = Place.ON_TABLE Then + ' Exit For + ' End If + 'Next + + 'Dim IndexRack As Integer = 0 + 'If PartListMax.Count > 0 Then + ' For IndexRack = 0 To Map.refUnloadingAreaVM.ListPart.Count - 1 + ' If Map.refUnloadingAreaVM.ListPart(IndexRack).IdProject = WastePart.IdProject And + ' Map.refUnloadingAreaVM.ListPart(IndexRack).IdPart = PartListMax(0).IdPart And + ' Map.refUnloadingAreaVM.ListPart(IndexRack).enPlace = Place.ON_TABLE Then + ' IndexMaualPart = IndexRack + ' Exit For + ' End If + ' Next + 'End If + + ' reinserisco i pezzi nella lista + For Each ActualItemPart In NewListPallet + '' verifico che il pezzo non esiste già nella lista + 'For Each ItemPart In Map.refUnloadingAreaVM.ListPart + ' If ItemPart.IdProject = WastePart.IdProject AndAlso Not ItemPart.IdPart = ActualItemPart.IdPart Then + ' Map.refUnloadingAreaVM.ListPart.Insert(IndexMaualPart, ActualItemPart) + ' Exit For + ' End If + 'Next + 'IndexMaualPart = IndexMaualPart + 1 + + ' modifico il colore dei pezzi che sono stati ricalcolati + Dim nIdCurrRegion As Integer = GeomCalc.GetRegionFromPart(ActualItemPart.IdPart) + If nIdCurrRegion > 0 Then + EgtSetColor(nIdCurrRegion, New Color3d(0, 200, 200, 80)) + EgtDraw() + End If + If Not IsNothing(NewBox) Then + ' se ho trovato un Box su cui scaricare + NewBox.MyListPart.Add(ActualItemPart) + ActualItemPart.IdBox = NewBox.Id + ElseIf IsNothing(NewBox) Then + ' se devo cambiare Box (prima di aver definito il magazzino) + ActualItemPart.IdBox = -1 + If nIdCurrRegion > 0 Then + EgtSetColor(nIdCurrRegion, New Color3d(0, 150, 250, 80)) + EgtDraw() + End If + End If + Next + + ' salvo tutto nel file PartList.ini + Dim nListCount As Integer = 0 + Dim LastIndex As Integer = 0 + For LastIndex = 0 To Map.refUnloadingAreaVM.ListPart.Count - 1 + If Map.refUnloadingAreaVM.ListPart(LastIndex).IdProject = WastePart.IdProject Then + nListCount = nListCount + 1 + Map.refUnloadingAreaVM.ListPart(LastIndex).SavePart(Map.refUnloadingAreaVM.ListPart(LastIndex).IdPart) + Map.refUnloadingAreaVM.ListPart(LastIndex).IdBox = Map.refUnloadingAreaVM.ListPart(LastIndex).IdBox + Map.refUnloadingAreaVM.ListPart(LastIndex).dOffestPartY = Map.refUnloadingAreaVM.ListPart(LastIndex).dOffestPartY + If LastIndex > 0 Then + Map.refUnloadingAreaVM.ListPart(LastIndex - 1).SetIsLast(False) + End If + Map.refUnloadingAreaVM.ListPart(LastIndex).SetIsLast(True) + PartWritePrivateProfileString(Map.refUnloadingAreaVM.ListPart(LastIndex).IdProject, "PartList", "IdPart" & nListCount.ToString, Map.refUnloadingAreaVM.ListPart(LastIndex).IdPart.ToString) + End If + Next + End Sub + ' simulazione di carico dalla rulliera tavola 2 Private Sub SimulLouadingTab2(LocalPart As Part, PosRuller As Point3d) EgtSetStatus(LocalPart.IdPart, GDB_ST.ON_) @@ -1109,8 +1920,12 @@ Public Class NCCommunication EgtDraw() End Sub +#End Region ' Methos + +#Region "LETTURA SCRITTURA Siemens" + ' definito il nome della variabile recupero l'inidirzzo variabile PLC e restituisco il valore letto da PLC - Private Function ReadInt(sVarName As String, ByRef nValue As Integer) As Boolean + Friend Function ReadInt(sVarName As String, ByRef nValue As Integer) As Boolean Dim bok As Boolean = True Dim sVar As String = String.Empty ' leggo da file OmagVIEWPlus l'indirizzo della variabile associata @@ -1149,7 +1964,7 @@ Public Class NCCommunication End Function ' definito il nome della variabile recupero l'inidirzzo variabile PLC e restituisco il valore letto da PLC - Private Function ReadReal(sVarName As String, ByRef dValue As Double) As Boolean + Friend Function ReadReal(sVarName As String, ByRef dValue As Double) As Boolean Dim bok As Boolean = True Dim sVar As String = String.Empty ' leggo da file OmagVIEWPlus l'indirizzo della variabile associata @@ -1445,4 +2260,6 @@ Public Class NCCommunication Return False End Function +#End Region ' Lettura scriettura Siemens + End Class diff --git a/OmagVIEWPlus.vbproj b/OmagVIEWPlus.vbproj index c742c57..ab363c4 100644 --- a/OmagVIEWPlus.vbproj +++ b/OmagVIEWPlus.vbproj @@ -145,19 +145,27 @@ GridBoxesV.xaml - - WarehouseV.xaml + + InfoWindowV.xaml + - - + SceneHostV.xaml + + StatusMachine2V.xaml + + + + TablePartWindowV.xaml + + UnloadingAreaV.xaml @@ -173,6 +181,9 @@ BoxV.xaml + + WarehouseV.xaml + @@ -241,7 +252,15 @@ Designer MSBuild:Compile - + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + Designer MSBuild:Compile @@ -249,10 +268,14 @@ MSBuild:Compile Designer - + MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -312,6 +335,7 @@ + IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\OmagVIEWPlus\OmagVIEWPlusR32.exe diff --git a/StatusMachine2/StatusMachine2V.xaml b/StatusMachine2/StatusMachine2V.xaml new file mode 100644 index 0000000..09171c2 --- /dev/null +++ b/StatusMachine2/StatusMachine2V.xaml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StatusMachine2/StatusMachine2V.xaml.vb b/StatusMachine2/StatusMachine2V.xaml.vb new file mode 100644 index 0000000..434003f --- /dev/null +++ b/StatusMachine2/StatusMachine2V.xaml.vb @@ -0,0 +1,11 @@ +Public Class StatusMachine2V + Private m_StatusMachine2VM As StatusMachine2VM + Sub New(Owner As Window, objStatusMachine2VM As StatusMachine2VM) + MyBase.New(Owner) + ' This call is required by the designer. + InitializeComponent() + ' Add any initialization after the InitializeComponent() call. + Me.DataContext = objStatusMachine2VM + m_StatusMachine2VM = objStatusMachine2VM + End Sub +End Class diff --git a/StatusMachine2/StatusMachine2VM.vb b/StatusMachine2/StatusMachine2VM.vb new file mode 100644 index 0000000..313e73e --- /dev/null +++ b/StatusMachine2/StatusMachine2VM.vb @@ -0,0 +1,139 @@ +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class StatusMachine2VM + Inherits VMBase + + Friend m_RefStusMachine2V As StatusMachine2V + + Private m_Title As String = "Status machine 2" + Public ReadOnly Property Title As String + Get + Return m_Title + End Get + End Property + + Private m_MessagesIsHang As String = "Part is hanging" + Public ReadOnly Property MessagesIsHang As String + Get + Return m_MessagesIsHang + End Get + End Property + + Private m_MessagesStatus As String = "Status machine" + Public ReadOnly Property MessagesStatus As String + Get + Return m_MessagesStatus + End Get + End Property + + Private m_MessagesIsManual As String = "Unloaded manual" + Public ReadOnly Property MessagesIsManual As String + Get + Return m_MessagesIsManual + End Get + End Property + + Private m_IsHanging As Boolean = False + Public Property IsHanging As Boolean + Get + Return m_IsHanging + End Get + Set(value As Boolean) + m_IsHanging = value + End Set + End Property + + Private m_StatusMachine As String = String.Empty + Public Property StatusMachine As String + Get + Return m_StatusMachine + End Get + Set(value As String) + m_StatusMachine = value + NotifyPropertyChanged("StatusMachine") + End Set + End Property + Public Sub SetStatusMachine() + Dim nVal As Integer = 0 + If Map.refMainWindowVM.m_CNCommunication.ReadInt("StatusMachine2Read", nVal) Then + m_StatusMachine = nVal.ToString + NotifyPropertyChanged("StatusMachine") + End If + End Sub + + Private m_IsManualUnloaded As Boolean = False + Public Property IsManulaUnloaded As Boolean + Get + Return m_IsManualUnloaded + End Get + Set(value As Boolean) + m_IsManualUnloaded = value + NotifyPropertyChanged("IsManulaUnloaded") + End Set + End Property + + Private m_Apply As Boolean = False + Public Property Apply As Boolean + Get + Return m_Apply + End Get + Set(value As Boolean) + m_Apply = value + m_Cancel = Not value + If value Then + m_RefStusMachine2V.Close() + Map.refUnloadingAreaVM.StatusMachine2 = False + If Not IsNothing(Map.refMainWindowVM.m_CNCommunication) Then + ' definisco lo stato attuale del pezzo + If m_IsManualUnloaded And Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable2) Then + Map.refUnloadingAreaVM.CurrPartTable2.enUnloading = Unloading.MANUAL + Map.refUnloadingAreaVM.CurrPartTable2.enPlace = Place.ON_WASTE_BOX + End If + ' definisco lo stato della macchina + If m_IsHanging Then + Map.refMainWindowVM.m_CNCommunication.WriteInt("IsHanging", 1) + Map.refMainWindowVM.m_CNCommunication.WriteInt("StatusMachine2", 1) + Else + Map.refMainWindowVM.m_CNCommunication.WriteInt("IsHanging", 0) + Map.refMainWindowVM.m_CNCommunication.WriteInt("StatusMachine2", 0) + End If + + End If + End If + End Set + End Property + + Private m_Cancel As Boolean = False + Public Property Cancel As Boolean + Get + Return m_Cancel + End Get + Set(value As Boolean) + m_Cancel = value + m_Apply = Not value + Map.refUnloadingAreaVM.StatusMachine2 = False + If value Then + m_RefStusMachine2V.Close() + End If + End Set + End Property + + Sub New() + m_RefStusMachine2V = New StatusMachine2V(Application.Current.MainWindow, Me) + Dim nVal1 As Integer = 0 + Dim nVal2 As Integer = 0 + If Not IsNothing(Map.refMainWindowVM.m_CNCommunication) Then + If Map.refMainWindowVM.m_CNCommunication.ReadInt("IsHangingRead", nVal1) Then + If nVal1 = 1 Then + m_IsHanging = True + Else + m_IsHanging = False + End If + End If + If Map.refMainWindowVM.m_CNCommunication.ReadInt("StatusMachine2Read", nVal2) Then + m_StatusMachine = nVal2.ToString + End If + End If + End Sub +End Class diff --git a/TablePartWindow/TablePartWindowV.xaml b/TablePartWindow/TablePartWindowV.xaml new file mode 100644 index 0000000..488d821 --- /dev/null +++ b/TablePartWindow/TablePartWindowV.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TablePartWindow/TablePartWindowV.xaml.vb b/TablePartWindow/TablePartWindowV.xaml.vb new file mode 100644 index 0000000..36f91c5 --- /dev/null +++ b/TablePartWindow/TablePartWindowV.xaml.vb @@ -0,0 +1,11 @@ +Public Class TablePartWindowV + Private m_TablePartWindowVM As TablePartWindowVM + Sub New(Owner As Window, objTablePartWindowVM As TablePartWindowVM) + MyBase.New(Owner) + ' This call is required by the designer. + InitializeComponent() + ' Add any initialization after the InitializeComponent() call. + Me.DataContext = objTablePartWindowVM + m_TablePartWindowVM = objTablePartWindowVM + End Sub +End Class diff --git a/TablePartWindow/TablePartWindowVM.vb b/TablePartWindow/TablePartWindowVM.vb new file mode 100644 index 0000000..c53b12c --- /dev/null +++ b/TablePartWindow/TablePartWindowVM.vb @@ -0,0 +1,111 @@ +Imports EgtUILib +Imports EgtWPFLib5 +Imports System.Collections.ObjectModel + +Public Class TablePartWindowVM + Inherits VMBase + + Friend refTablePartWindowV As TablePartWindowV + + Private m_ProjetcList As New ObservableCollection(Of ProjectListParts) + Public Property ProjetcList As ObservableCollection(Of ProjectListParts) + Get + Return m_ProjetcList + End Get + Set(value As ObservableCollection(Of ProjectListParts)) + m_ProjetcList = value + End Set + End Property + + Private m_ProjSelected As ProjectListParts + Public Property ProjSelected As ProjectListParts + Get + Return m_ProjSelected + End Get + Set(value As ProjectListParts) + m_ProjSelected = value + NotifyPropertyChanged("CurrListPart") + End Set + End Property + + Public Sub RefreshProject() + Dim m_CurrentPartList As New ObservableCollection(Of Part) + Dim bAddNewList As Boolean = True + ' salvo le liste in funzione del numero di progetto + If Not IsNothing(Map.refUnloadingAreaVM) Then + For Each ItemPart In Map.refUnloadingAreaVM.ListPart + For Each Item In m_ProjetcList + If Item.IdProject = ItemPart.IdProject.ToString Then + bAddNewList = False + Exit For + End If + bAddNewList = True + Next + If bAddNewList Then + m_CurrentPartList.Add(ItemPart) + End If + Next + End If + If m_CurrentPartList.Count > 0 Then + m_ProjetcList.Add(New ProjectListParts(m_CurrentPartList)) + NotifyPropertyChanged("CurrentPartList") + ' seleziono come progetto quello in fase di scarico + m_ProjSelected = m_ProjetcList.Last + NotifyPropertyChanged("ProjetcList") + NotifyPropertyChanged("ProjSelected") + End If + End Sub + + Sub New(IdProj As Integer) + refTablePartWindowV = New TablePartWindowV(Application.Current.MainWindow, Me) + For Each Itemproj In Map.refMainWindowVM.MainWindowM.ProjIndList + Dim m_CurrentPartList As New ObservableCollection(Of Part) + ' salvo le liste in funzione del numero del numero di progetto + If Not IsNothing(Map.refUnloadingAreaVM) Then + For Each ItemPart In Map.refUnloadingAreaVM.ListPart + If ItemPart.IdProject = Itemproj.nProjInd Then + m_CurrentPartList.Add(ItemPart) + End If + Next + End If + If m_CurrentPartList.Count > 0 Then + m_ProjetcList.Add(New ProjectListParts(m_CurrentPartList)) + NotifyPropertyChanged("CurrentPartList") + m_ProjSelected = m_ProjetcList.Last + End If + Next + NotifyPropertyChanged("ProjetcList") + End Sub + +End Class + +Public Class ProjectListParts + Inherits VMBase + + Private m_CurrListPart As New ObservableCollection(Of Part) + Public Property CurrListPart As ObservableCollection(Of Part) + Get + Return m_CurrListPart + End Get + Set(value As ObservableCollection(Of Part)) + m_CurrListPart = value + End Set + End Property + + Private m_IdProject As String + Public Property IdProject As String + Get + Return m_IdProject + End Get + Set(value As String) + m_IdProject = value + End Set + End Property + + Sub New(obCurrListParts As ObservableCollection(Of Part)) + m_CurrListPart = obCurrListParts + If m_CurrListPart.Count > 0 Then + m_IdProject = m_CurrListPart(0).IdProject.ToString + End If + End Sub +End Class diff --git a/UnloadingArea/UnloadingAreaV.xaml b/UnloadingArea/UnloadingAreaV.xaml index cfb3192..3d3532a 100644 --- a/UnloadingArea/UnloadingAreaV.xaml +++ b/UnloadingArea/UnloadingAreaV.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:OmagVIEWPlus="clr-namespace:OmagVIEWPlus" xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"> - + @@ -54,13 +54,18 @@ - + + @@ -78,10 +83,14 @@ - + + Height="35" Width="100" + IsChecked="{Binding refScenaIsChecked}"/> diff --git a/UnloadingArea/UnloadingAreaVM.vb b/UnloadingArea/UnloadingAreaVM.vb index 297063a..9da6a32 100644 --- a/UnloadingArea/UnloadingAreaVM.vb +++ b/UnloadingArea/UnloadingAreaVM.vb @@ -5,6 +5,21 @@ Imports EgtWPFLib5 Public Class UnloadingAreaVM Inherits VMBase + Friend m_refStatuMachine2VM As StatusMachine2VM + Friend m_refTablePartWindowVM As TablePartWindowVM + + ' disabilito i comandi della pagina + Private m_EnablePage As Boolean = True + Public Property EnablePage As Boolean + Get + Return m_EnablePage + End Get + Set(value As Boolean) + m_EnablePage = value + NotifyPropertyChanged("EnablePage") + End Set + End Property + ' lista dei magazzini disponibii (A, B) Private m_WarehouseList As New ObservableCollection(Of WarehouseVM) Public ReadOnly Property WarehouseList As ObservableCollection(Of WarehouseVM) @@ -53,6 +68,26 @@ Public Class UnloadingAreaVM End Set End Property + ' apre la finestra per definire lo stato della macchina + Private m_StatusMachine2 As Boolean = False + Public Property StatusMachine2 As Boolean + Get + Return m_StatusMachine2 + End Get + Set(value As Boolean) + m_StatusMachine2 = value + If value Then + m_refStatuMachine2VM = New StatusMachine2VM() + m_refStatuMachine2VM.m_RefStusMachine2V.Show() + EnablePage = False + Else + m_refStatuMachine2VM = Nothing + EnablePage = True + End If + NotifyPropertyChanged("StatusMachine2") + End Set + End Property + ' messaggio da mostrare a video Private m_OutputMessage As String Public Property OutputMessage As String @@ -132,6 +167,31 @@ Public Class UnloadingAreaVM End Set End Property + ' permette la visualizzazione del bottone "List Part" + Public ReadOnly Property ShowTabParts As Visibility + Get + Return If(GetMainPrivateProfileInt("General", "ShowTabParts", 0) = 1, Visibility.Visible, Visibility.Hidden) + End Get + End Property + + Private m_WindowListPart As Boolean = False + Public Property WindowListPart As Boolean + Get + Return m_WindowListPart + End Get + Set(value As Boolean) + m_WindowListPart = value + If value Then + m_refTablePartWindowVM = New TablePartWindowVM(Map.refMainWindowVM.MainWindowM.nProjInd) + m_refTablePartWindowVM.refTablePartWindowV.Show() + Else + m_refStatuMachine2VM = Nothing + End If + NotifyPropertyChanged("StatusMachine2") + End Set + End Property + + #End Region ' PARTS #Region "OFFSET PALLET/RACK" @@ -288,7 +348,12 @@ Public Class UnloadingAreaVM Return "--" End If ' restituisce la parcentula di pezzi prelevabili (esclusi quelli da scartare) - Return DoubleToString(If(nTotal = 0, 0, nTable / nTotal * 100), 0) & "%" + Dim sMessage As String = nTable.ToString & "/" & nTotal.ToString + If nTotal = 0 Then + sMessage = "0" + End If + 'Return DoubleToString(If(nTotal = 0, 0, nTable / nTotal * 100), 0) & "%" + Return sMessage End Get End Property @@ -342,6 +407,14 @@ Public Class UnloadingAreaVM End Get End Property + ' messaggio sul bottone per la selezione dello stato del manipolatore2 + Private m_MsgMachine2 As String = "Machine 2" + Public ReadOnly Property MsgMachine2 As String + Get + Return m_MsgMachine2 + End Get + End Property + ' visibilità del testo a lato del bottone per la prenotazione Private m_VisibilityTextReserve As Visibility = Visibility.Collapsed Public ReadOnly Property VisibilityTextReserve As Visibility @@ -701,6 +774,25 @@ Public Class UnloadingAreaVM Return CurrList End Function + ' restituisce il Box assocauto al pezzo indicato + Public Function GetPartBox(CurrPart As Part, CurrWarehouse As WarehouseVM) As Box + Dim CurrBox As Box = Nothing + For Each ItemGridBox In CurrWarehouse.GridBoxList + Dim bFoundBox As Boolean = False + For Each ItemBox In ItemGridBox.CurrBoxList + If ItemBox.Id = CurrPart.IdBox Then + CurrBox = ItemBox + bFoundBox = True + Exit For + End If + Next + If bFoundBox Then + Exit For + End If + Next + Return CurrBox + End Function + ' restituisce la lista di tutti i pezzi identificati dalla stessa posizione (di default quelli buoni) di tutti i progetti caricati Public Function GetAllParts(DefinePlce As Place, Optional DefineStatus As StatusPart = StatusPart.GOOD) As ObservableCollection(Of Part) Dim CurrList As New ObservableCollection(Of Part) @@ -784,42 +876,55 @@ Public Class UnloadingAreaVM Next Next - ' divido i pezzi in due liste (palle/rack) solo quelli con scarico automatico + ' divido i pezzi in due liste (pallet/rack) solo quelli con scarico automatico Dim nPartOnPallet As Integer = 0 Dim nPartOnRack As Integer = 0 Dim RackPartList As New List(Of Part) Dim PalletPartList As New List(Of Part) + Dim NewPalletPartLisr As New List(Of Part) Dim dHeightTile As Double = 0 Dim dDistRack As Double = 0 - ' tutti quelli già sul rullo + ' tutti quelli già sul rullo (senza un Box definito) Dim ListMotorRuller As ObservableCollection(Of Part) = GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER) OutLogProcess("OrganaizeWarehouse() -> Pezzi sulla rulliera: " & ListMotorRuller.Count) For Each ItemPart In ListMotorRuller - If ItemPart.enUnloading = Unloading.AUTOMATIC Then + If ItemPart.enUnloading = Unloading.AUTOMATIC AndAlso ItemPart.IdBox = -1 Then If ItemPart.MinRectX > m_MaxLength Then RackPartList.Add(ItemPart) nPartOnRack = nPartOnRack + 1 dDistRack = ItemPart.Height Else - PalletPartList.Add(ItemPart) - nPartOnPallet = nPartOnPallet + 1 - dHeightTile = ItemPart.Height + If ItemPart.IdBox = -1 Then + PalletPartList.Add(ItemPart) + nPartOnPallet = nPartOnPallet + 1 + dHeightTile = ItemPart.Height + Else + NewPalletPartLisr.Add(ItemPart) + nPartOnPallet = nPartOnPallet + 1 + dHeightTile = ItemPart.Height + End If End If End If Next - ' tutti quelli ancora sul tavolo + ' tutti quelli ancora sul tavolo (senza un Box definito) Dim ListTable As ObservableCollection(Of Part) = GetParts(m_IdProjTable2.nProjInd, Place.ON_TABLE) OutLogProcess("OrganaizeWarehouse() -> Pezzi sul tavolo: " & ListTable.Count) For Each ItemPart In ListTable - If ItemPart.enUnloading = Unloading.AUTOMATIC Then + If ItemPart.enUnloading = Unloading.AUTOMATIC AndAlso ItemPart.IdBox = -1 Then If ItemPart.MinRectX > m_MaxLength Then RackPartList.Add(ItemPart) nPartOnRack = nPartOnRack + 1 dDistRack = ItemPart.Height Else - PalletPartList.Add(ItemPart) - nPartOnPallet = nPartOnPallet + 1 - dHeightTile = ItemPart.Height + If ItemPart.IdBox = -1 Then + PalletPartList.Add(ItemPart) + nPartOnPallet = nPartOnPallet + 1 + dHeightTile = ItemPart.Height + Else + NewPalletPartLisr.Add(ItemPart) + nPartOnPallet = nPartOnPallet + 1 + dHeightTile = ItemPart.Height + End If End If End If Next @@ -890,7 +995,7 @@ Public Class UnloadingAreaVM Next End If - ' verifico che il magazzino no sua già stato organizzato + ' verifico che il magazzino no sia già stato organizzato If PalletPartList.Count > 0 Then If PalletPartList(0).IdBox > -1 Then OutLogProcess("OrganaizeWarehouse() -> Magazzino pallet già organizzato per progetto: " & m_IdProjTable2.nProjInd.ToString) @@ -898,6 +1003,24 @@ Public Class UnloadingAreaVM End If End If + '' blocco la forzatura ad aprire il magazzino + 'Map.refMainWindowVM.m_CNCommunication.m_OpenWarehouse = False + + ' verifico che i pezzi siano definiti nella sequenza corretta (ovvero in Layer successivi) + Dim LastIndex As Integer = 0 + Dim nTestLayer As Integer = 0 + If PalletPartList.Count > 0 Then + nTestLayer = PalletPartList(0).nLayer + End If + For Each Item In PalletPartList + If nTestLayer > Item.nLayer Then + ClearOutputMessage() + SetOutputMessage("Error in list part") + Return False + End If + LastIndex = LastIndex + 1 + Next + ' parto dal primo layer calcolato Dim nCurrLayer As Integer = 0 ' definisco quale Layer deve essere riempito per tutti i pallet @@ -931,6 +1054,12 @@ Public Class UnloadingAreaVM ' indicizzo il nuovo strato di layer da salvare per i pallet SetCurrLayer = SetCurrLayer + 1 Next + + For Each ItemNewPallet In NewPalletPartLisr + ItemNewPallet.IdBox = ItemNewPallet.IdBox + 1 + Next + ClearOutputMessage() + SetOutputMessage("Warehouse confirmed") OutLogProcess("OrganaizeWarehouse() -> Organizzato magazzino per progetto: " & m_IdProjTable2.nProjInd.ToString) Return True End Function diff --git a/Warehouse/Box.vb b/Warehouse/Box.vb index 0f5a308..7c0db65 100644 --- a/Warehouse/Box.vb +++ b/Warehouse/Box.vb @@ -44,6 +44,39 @@ Public Class Box End Get End Property + ' dimensione Y dei pezzi che deve ospitare + Private m_DimPartY As Double = 0 + Public Property DimPartY As Double + Get + Return m_DimPartY + End Get + Set(value As Double) + m_DimPartY = value + End Set + End Property + + ' dimensione X dei pezi che deve ospitare + Private m_DimPartX As Double = 0 + Public Property DimPartX As Double + Get + Return m_DimPartX + End Get + Set(value As Double) + m_DimPartX = value + End Set + End Property + + ' definsce se il Box è stato riservato per ospitare un determinato tipo di pezzi + Private m_ReserveBox As Boolean = False + Public Property ReserveBox As Boolean + Get + Return m_ReserveBox + End Get + Set(value As Boolean) + m_ReserveBox = value + End Set + End Property + ' elenco dei pezzi che devono essere contenuti nel box Private m_MyListPart As New List(Of Part) Public Property MyListPart As List(Of Part) @@ -55,6 +88,18 @@ Public Class Box End Set End Property + ' definisce se il Box è modificabile da programma + Private m_IsAvailable As Boolean = True + Public Property IsAvailable As Boolean + Get + Return m_IsAvailable + End Get + Set(value As Boolean) + m_IsAvailable = value + NotifyPropertyChanged("IsAvailable") + End Set + End Property + ' comandato dal click in interfaccia Public Property State_IsChecked As Boolean Get @@ -85,6 +130,8 @@ Public Class Box Select Case m_State Case States.AVAILABLE m_BackGroundColor = DirectCast(New BrushConverter().ConvertFrom("LawnGreen"), SolidColorBrush) + Case States.LOADING + m_BackGroundColor = DirectCast(New BrushConverter().ConvertFrom("DarkOrange"), SolidColorBrush) Case States.FULL m_BackGroundColor = DirectCast(New BrushConverter().ConvertFrom("Red"), SolidColorBrush) Case States.NOT_AVAILABLE @@ -155,6 +202,8 @@ Public Class Box ' valore pecentuale di riempimento del box Private m_FillPercentage As Integer = 0 + Private m_nPartOnBox As Integer = 0 + Private m_nPart As Integer = 0 Public ReadOnly Property nFillPercentage As Integer Get Dim nPart As Integer = 0 @@ -166,11 +215,13 @@ Public Class Box If ItemPart.enPlace = Place.ON_BOX Then nPartOnBox = nPartOnBox + 1 End If - ' conto il numero totale di pezzi sani da caricare nel box - If ItemPart.enStatus = StatusPart.GOOD Then + ' conto il numero totale di pezzi sani e automatici da caricare nel box + If ItemPart.enStatus = StatusPart.GOOD And ItemPart.enUnloading = Unloading.AUTOMATIC Then nPart = nPart + 1 End If Next + m_nPart = nPart + m_nPartOnBox = nPartOnBox m_FillPercentage = If(nPart > 0, CInt(nPartOnBox / nPart * 100), 0) End If ' se raggiungo il massimo riempimento prevedibile allora comunico il nuovo stato @@ -188,15 +239,18 @@ Public Class Box Public ReadOnly Property FillPercentage As String Get Dim Message As String = "--" + Select Case m_State Case States.FULL ' definisco a video il livello di riempimento dedotto dallo stato FULL m_FillPercentage = 100 - Message = m_FillPercentage.ToString & " %" + 'Message = m_FillPercentage.ToString & " %" + Message = m_nPartOnBox.ToString & "/" & m_nPart.ToString Case States.LOADING - Message = m_FillPercentage.ToString & " %" - Case States.AVAILABLE - Message = m_FillPercentage.ToString & " %" + 'Message = m_FillPercentage.ToString & " %" + Message = m_nPartOnBox.ToString & "/" & m_nPart.ToString + 'Case States.AVAILABLE + ' Message = m_FillPercentage.ToString & " %" End Select Return Message End Get @@ -276,6 +330,7 @@ Public Class Box Dim RadAngRack As Double = Map.refUnloadingAreaVM.AngRack * Math.PI / 180 Dim OffsetX = dHeight / Math.Sin(RadAngRack) OffsetX = nCounter * OffsetX + LocalPart.nPositionLayer = CInt(nCounter) Return OffsetX End Function diff --git a/Warehouse/BoxV.xaml b/Warehouse/BoxV.xaml index 97bf86b..49b27e9 100644 --- a/Warehouse/BoxV.xaml +++ b/Warehouse/BoxV.xaml @@ -7,7 +7,8 @@ mc:Ignorable="d" d:DesignHeight="200" d:DesignWidth="200"> - = 1 And IsNumeric(sItems(0)) Then ' se il box è in fase di carico lo ridefinisco come non disponibile @@ -399,6 +402,7 @@ Public Class WarehouseVM End If End If + ' carico la definizione della sua origine Dim nOrig As Integer = 0 If sItems.Count >= 2 Then @@ -409,6 +413,24 @@ Public Class WarehouseVM EgtOutLog("Error reading file Config.ini [Warehause] -> " & sName & ", wrong CN orig definition") End If End If + + ' carico le dimensioni dei pezzi che devono occupare il pallet + Dim DimX As Double = 0 + Dim DimY As Double = 0 + If sItems.Count >= 3 Then + ' verifico che la scrittura sia corretta: 500 x 300 (oppure) 500 X 300 + If sItems(2).Contains("x"c) Or sItems(2).Contains("X"c) Then + sItems(2) = sItems(2).ToLower + Dim sDim As String() = sItems(2).Split("x"c) + ' carico le dimensioni dei pezzi + If sDim.Count = 2 Then + If Not (StringToLen(sDim(0), DimX) And StringToLen(sDim(1), DimY)) Then + EgtOutLog("Error reading file Config.ini [Warehause] -> " & sName & ", wrong definition: DimX x DimY ") + End If + End If + End If + End If + ' definisco la colonna di appartenenza Dim enColumnsWarehouse As ColumnsWarehouse = ColumnsWarehouse.THIRD If IdBox <= 2 Or IdBox = 7 Then @@ -416,12 +438,22 @@ Public Class WarehouseVM ElseIf IdBox = 3 Or IdBox = 4 Or IdBox = 8 Then enColumnsWarehouse = ColumnsWarehouse.SECOND End If + ' aggiungo il Box creato alla lista (solo se appartiene alla configurazione) Dim CurrBox As New Box(IdBox, If(bIsPallet, ConfigBox.PALLET, ConfigBox.RACK), Me, enStatus, nOrig, enColumnsWarehouse) + ' aggiungo eventualmente la definizione dei pezzi da ospitare + If DimX > 0 And DimY > 0 Then + CurrBox.ReserveBox = True + CurrBox.DimPartX = DimX + CurrBox.DimPartY = DimY + Else + CurrBox.ReserveBox = False + End If CurrBox.NotifyPropertyChanged("") m_Boxes.Add(CurrBox) Next + Return True End Function @@ -437,14 +469,19 @@ Public Class WarehouseVM WarehauseWritePrivateProfileString(S_WAREHOUSE, "Column" & Index.ToString & K_STORAGE & m_Id.ToString, If(ItemGridBox.IsPallet, "0", "1")) Index = Index + 1 Next + ' salvo la configurazione dei box For Index = 0 To m_Boxes.Count - 1 Dim sName As String = K_BOX & m_Id.ToString & m_Boxes(Index).Id.ToString ' converto lo stato nell'indice associato Dim nState As Integer = CInt(m_Boxes(Index).State) Dim sInfo As String = nState.ToString & ", G" & m_Boxes(Index).OrigDefCN.ToString + If m_Boxes(Index).ReserveBox Then + sInfo = sInfo & ", " & DoubleToString(m_Boxes(Index).DimPartX, 2) & "x" & DoubleToString(m_Boxes(Index).DimPartY, 2) + End If WarehauseWritePrivateProfileString(S_WAREHOUSE, sName, sInfo) Next + Return True End Function