Files
OmagVIEWPlus/UnloadingArea/UnloadingAreaVM.vb
T
Nicola Pievani d950fc1060 OmagVIEWPlus 2.2j1:
-> nuova definizione dei pezzi (classe Part)
-> nuova gestione dei magazzini
-> aggiunta pagina per la selezione dei pezzi manuali
-> nuova configurazione delle variabili.
2020-10-09 08:13:48 +00:00

836 lines
31 KiB
VB.net

Imports System.Collections.ObjectModel
Imports EgtUILib
Imports EgtWPFLib5
Public Class UnloadingAreaVM
Inherits VMBase
'-----------------------------------------------------------------------------------------
' non è più utilizzato perchè sono solo due oggetti!
Private m_WarehouseList As New ObservableCollection(Of WarehouseVM)
Public ReadOnly Property WarehouseList As ObservableCollection(Of WarehouseVM)
Get
Return m_WarehouseList
End Get
End Property
'-----------------------------------------------------------------------------------------
' definsice se deve ricalcolato la disposizione dei pezzi nel magazzino
Private m_bOrganizeWarehouse As Boolean = False
Public Property bOrganizeWarehouse As Boolean
Get
Return m_bOrganizeWarehouse
End Get
Set(value As Boolean)
m_bOrganizeWarehouse = value
End Set
End Property
'' magazzino A: contiene 3 GridBox per un totale di 6 pallet e 3 rack
'Private m_WarehouseA As WarehouseVM
'Public ReadOnly Property WarehouseA As WarehouseVM
' Get
' Return m_WarehouseA
' End Get
'End Property
'' magazzino A: contiene 3 GridBox per un totale di 6 pallet e 3 rack
'Private m_WarehouseB As WarehouseVM
'Public ReadOnly Property WarehouseB As WarehouseVM
' Get
' Return m_WarehouseB
' End Get
'End Property
' indica il magazzino attivo (letto dalla macchina)
Private m_ActiveWarehouse As Warehouses
Public ReadOnly Property ActiveWarehouse As Warehouses
Get
Return m_ActiveWarehouse
End Get
End Property
' attendo la definizione dei pezzi manuali
Private m_IsChecked_Manual As Boolean = False
Public Property IsChecked_Manual As Boolean
Get
' se la lastra è prenotata e non ci sono pezzi sul tavolo
If m_IsChecked_Manual AndAlso GetParts(Place.ON_TABLE).Count = 0 Then
Map.refSceneHostVM.MainScene.SetObjFilterForSel(False, False, True, False, False)
Else
Map.refSceneHostVM.MainScene.SetStatusNull()
End If
Return m_IsChecked_Manual
End Get
Set(value As Boolean)
m_IsChecked_Manual = value
NotifyPropertyChanged("ManualUnload")
NotifyPropertyChanged("VisibilityTextReserve")
NotifyPropertyChanged("IsChecked_Manual")
End Set
End Property
#Region "PARTS"
' elenco pezzi da scaricare (già ordinati) definita dalla funzione: CamAuto/MyUpdateVacuumsForUnloading()
Private m_ListPart As New List(Of Part)
Friend Property ListPart As List(Of Part)
Get
Return m_ListPart
End Get
Set(value As List(Of Part))
m_ListPart = value
End Set
End Property
' salvo locamente il pezzo correntemente manipolato dallo scaricatore
Private m_CurrPartTable1 As Part
Public Property CurrPartTable1 As Part
Get
Return m_CurrPartTable1
End Get
Set(value As Part)
m_CurrPartTable1 = value
End Set
End Property
' salvo locamente il pezzo correntemente manipolato dal pallettizzatore
Private m_CurrPartTable2 As Part
Public Property CurrPartTable2 As Part
Get
Return m_CurrPartTable2
End Get
Set(value As Part)
m_CurrPartTable2 = value
End Set
End Property
' salvo localmente l'ultimo Box utilizzato nel magazzino
Private m_CurrBox As Box
Public Property CurrBox As Box
Get
Return m_CurrBox
End Get
Set(value As Box)
m_CurrBox = value
End Set
End Property
' salvo l'IdProj attualmente in lavorazione sulla tavola 2
Private m_IdProjTable2 As New Proj(-1)
Public Property IdProjTable2 As Proj
Get
Return m_IdProjTable2
End Get
Set(value As Proj)
m_IdProjTable2 = value
End Set
End Property
#End Region ' PARTS
#Region "OFFSET PALLET/RACK"
' quanto fuori dalle corse devono essere posizionati i pezzi per determinare le giuste ventose
Private m_OffsetRullerX As Double = 0
Public ReadOnly Property OffsetRullerX As Double
Get
Return m_OffsetRullerX
End Get
End Property
Private m_OffsetRullerY As Double = 0
Public ReadOnly Property OffsetRullerY As Double
Get
Return m_OffsetRullerY
End Get
End Property
' le origini dei pallet sono in basso a siniatra (nel piano xy), gli offset restituiscono il centro
Private m_OffsetPalletX As Double = 0
Public ReadOnly Property OffsetPalletX As Double
Get
Return m_OffsetPalletX
End Get
End Property
Private m_OffsetPalletY As Double = 0
Public ReadOnly Property OffsetPalletY As Double
Get
Return m_OffsetPalletY
End Get
End Property
Private m_OffsetPalletZ As Double = 0
Public ReadOnly Property OffsetPalletZ As Double
Get
Return m_OffsetPalletZ
End Get
End Property
' le origini sono in mezzo al rack (nel piano xy)
Private m_OffsetRackX As Double = 0
Public ReadOnly Property OffsetRackX As Double
Get
Return m_OffsetRackX
End Get
End Property
Private m_OffsetRackY As Double = 0
Public ReadOnly Property OffsetRackY As Double
Get
Return m_OffsetRackY
End Get
End Property
Private m_OffsetRackZ As Double = 0
Public ReadOnly Property OffsetRackZ As Double
Get
Return m_OffsetRackZ
End Get
End Property
Private m_AngRack As Double
Public ReadOnly Property AngRack As Double
Get
Return m_AngRack
End Get
End Property
' altezza massima sul pallet
Private m_MaxHeight As Double
Public ReadOnly Property MaxHeight As Double
Get
Return m_MaxHeight
End Get
End Property
' lunghezza massima caricabile su pallet
Private m_MaxLength As Double
Public ReadOnly Property MaxLength As Double
Get
Return m_MaxLength
End Get
End Property
' larghezza massima caricabile su pallet
Private m_MaxWidth As Double
Public ReadOnly Property MaxWidth As Double
Get
Return m_MaxWidth
End Get
End Property
' numero massimo di pezzi su rack
Private m_MaxTile As Integer
Public ReadOnly Property MaxTile As Integer
Get
Return m_MaxTile
End Get
End Property
#End Region ' Offset pallet/rack
#Region "PROPERTIES"
' bottone per la selezione della scena
Public Property refScenaIsChecked As Boolean
Get
Return Map.refMainWindowVM.SceneIsChecked
End Get
Set(value As Boolean)
Map.refMainWindowVM.SceneIsChecked = value
End Set
End Property
' notifico nella grafica la percentuale di pezzi presenti sulla tavola
Public ReadOnly Property Table1Percentage As String
Get
' numero di pezzi buoni rimasti sulla tavola
Dim nTable As Integer = GetParts(Place.ON_TABLE).Count
' numero di pezzi scartati rimasti sulla tavola
Dim nWaist As Integer = GetParts(Place.ON_TABLE, StatusPart.WASTE).Count
' numero totale di pezzi da scaricare
Dim nTotal As Integer = GetParts(Place.ON_TABLE).Count + GetParts(Place.ON_TABLE, StatusPart.WASTE).Count
nTotal = nTotal + GetParts(Place.ON_MOTOR_RULLER).Count + GetParts(Place.ON_MOTOR_RULLER, StatusPart.WASTE).Count
nTotal = nTotal + GetParts(Place.ON_BOX).Count + GetParts(Place.ON_BOX, StatusPart.WASTE).Count
nTotal = nTotal + GetParts(Place.ON_MANUAL_BOX).Count + GetParts(Place.ON_MANUAL_BOX, StatusPart.WASTE).Count
' notifico anche la finestra delle info
NotifyPropertyChanged("InfoTable1")
If Map.refMainWindowVM.WaitingConfirmManualPart Then
Return "--"
End If
' restituisce la parcentula di pezzi prelevabili (esclusi quelli da scartare)
Return DoubleToString(If(nTotal = 0, 0, nTable / nTotal * 100), 0) & "%"
End Get
End Property
' notifico il numero di pezzi presenti sulla rulliera motorizzata (anche progetti diversi)
Public ReadOnly Property TableDifference As String
Get
NotifyPropertyChanged("InfoRuller")
Dim nCount As Integer = GetAllParts(Place.ON_MOTOR_RULLER).Count
nCount = nCount + GetAllParts(Place.ON_MOTOR_RULLER, StatusPart.NOT_LOADED).Count
Return DoubleToString(nCount, 0)
End Get
End Property
Public ReadOnly Property InfoTable1 As String
Get
Dim sInfo As String = String.Empty
sInfo &= "IdProj: " & Map.refMainWindowVM.MainWindowM.nProjInd.ToString
sInfo &= System.Environment.NewLine & "Counter Good: " & GetParts(Place.ON_TABLE).Count.ToString
sInfo &= System.Environment.NewLine & "Counter Waste: " & GetParts(Place.ON_TABLE, StatusPart.WASTE).Count.ToString
Return sInfo
End Get
End Property
Public ReadOnly Property InfoRuller As String
Get
Dim sInfo As String = String.Empty
sInfo &= "IdProj Table1: " & Map.refMainWindowVM.MainWindowM.nProjInd.ToString
sInfo &= System.Environment.NewLine & "Counter : " & GetParts(Place.ON_MOTOR_RULLER).Count.ToString
sInfo &= System.Environment.NewLine & "IdProj Table2: " & m_IdProjTable2.nProjInd
sInfo &= System.Environment.NewLine & "Counter Good: " & GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER).Count.ToString
' devo contare anche i pezzi da scaricare manualmente (ed emettere un messaggio di avviso)
sInfo &= System.Environment.NewLine & "Counter not unloadble: " & GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER, StatusPart.NOT_LOADED).Count.ToString
Return sInfo
End Get
End Property
' testo all'interno del bottone per la prenotazione
Private m_ManualUnload As String = String.Empty
Public ReadOnly Property ManualUnload As String
Get
If Not m_IsChecked_Manual Then
m_ManualUnload = "Reserve"
' se non sono nalla scena deseleziono tutto
If Not refScenaIsChecked Then
EgtDeselectAll()
End If
Else
m_ManualUnload = "Cancel"
End If
Return m_ManualUnload
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
Get
If Not m_IsChecked_Manual Then
m_VisibilityTextReserve = Visibility.Collapsed
Else
m_VisibilityTextReserve = Visibility.Visible
End If
Return m_VisibilityTextReserve
End Get
End Property
' messaggio di avvenuto prenotazione e conseguete stop di impianto
Private m_TextReserve As String = "Waiting selection manual part"
Public ReadOnly Property TextReserve As String
Get
Return m_TextReserve
End Get
End Property
' rendo visibile la freccia se: scarico manuale, pezzo non afferrabile
Private m_RullerArrowVisibility As Visibility = Visibility.Collapsed
Public Property RullerArrowVisibility As Visibility
Get
Return m_RullerArrowVisibility
End Get
Set(value As Visibility)
m_RullerArrowVisibility = value
NotifyPropertyChanged("RullerArrowVisibility")
NotifyPropertyChanged("RullerArrowImage")
End Set
End Property
Private m_RullerArrowImage As String = "/Resources/WhiteArrow.png"
Public ReadOnly Property RullerArrowImage As String
Get
If m_RullerArrowVisibility = Visibility.Visible Then
m_RullerArrowImage = "/Resources/RedArrow.png"
Else
m_RullerArrowImage = "/Resources/WhiteArrow.png"
End If
Return m_RullerArrowImage
End Get
End Property
' rendo visibile le freccia se: attesa di caricare la tavola
Private m_Table1ArrowVisibility As Visibility = Visibility.Collapsed
Public Property Table1ArrowVisibility As Visibility
Get
Return m_Table1ArrowVisibility
End Get
Set(value As Visibility)
m_Table1ArrowVisibility = value
NotifyPropertyChanged("Table1ArrowVisibility")
NotifyPropertyChanged("Table1ArrowImage")
End Set
End Property
Private m_Table1ArrowImage As String = "/Resources/WhiteArrow.png"
Public ReadOnly Property Table1ArrowImage As String
Get
If m_Table1ArrowVisibility = Visibility.Visible Then
m_Table1ArrowImage = "/Resources/RedArrow.png"
Else
m_Table1ArrowImage = "/Resources/WhiteArrow.png"
End If
Return m_Table1ArrowImage
End Get
End Property
#End Region ' PROPERTIES
Private m_TileType As Integer
Public ReadOnly Property TileType As String
Get
Return m_TileType.ToString
End Get
End Property
Private m_Table1Counter As Integer
Public ReadOnly Property Table1Counter As String
Get
Return m_Table1Counter.ToString
End Get
End Property
Private m_Table2Counter As Integer
Public ReadOnly Property Table2Counter As String
Get
Return m_Table2Counter.ToString
End Get
End Property
Private m_TileThickness As Double
Public ReadOnly Property TileThickness As String
Get
Return LenToString(m_TileThickness, 1)
End Get
End Property
Private m_LastSlab As Boolean
Public ReadOnly Property LastSlab As Boolean
Get
Return m_LastSlab
End Get
End Property
' definizione comandi
Private m_cmdChangeWarehouse As ICommand
Private m_cmdUnloadedWaistPart As ICommand
Private m_cmdUnloadedManualPart As ICommand
#Region "CONSTRUCTOR"
Sub New()
Map.SetRefUnloadingAreaVM(Me)
Init()
m_WarehouseList.Add(New WarehouseVM(Warehouses.A))
m_WarehouseList.Add(New WarehouseVM(Warehouses.B))
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
' Modificato eliminando la lista m_WarehouseList
Friend Sub SetActiveWarehouse(ActiveWarehouse As Warehouses)
' verifico che il valore sia corretto, alrimenti assegno 0-> entrambi i magazzini sono disattivi
If ActiveWarehouse < 0 OrElse ActiveWarehouse > 2 Then
m_ActiveWarehouse = 0
Else
m_ActiveWarehouse = ActiveWarehouse
End If
' attivo il magazzino selezionato
If ActiveWarehouse = Warehouses.A Then
GetWarehouse(Warehouses.A).SetIsActive(True)
GetWarehouse(Warehouses.B).SetIsActive(False)
OutLogProcess("ActiveWarehouse() -> Attivo magazzino A")
ElseIf ActiveWarehouse = Warehouses.B Then
GetWarehouse(Warehouses.A).SetIsActive(False)
GetWarehouse(Warehouses.B).SetIsActive(True)
OutLogProcess("ActiveWarehouse() -> Attivo magazzino B")
Else
GetWarehouse(Warehouses.A).SetIsActive(False)
GetWarehouse(Warehouses.B).SetIsActive(False)
OutLogProcess("ActiveWarehouse() -> Disattivo magazzini A B")
End If
End Sub
'--------------------------------------------------------------------------------------
Friend Sub SetBoxIsActive(BoxId As Integer)
If Not m_ActiveWarehouse > 0 AndAlso m_ActiveWarehouse <= 2 Then
m_WarehouseList(GetWarehouseIndex(Warehouses.A)).SetBoxIsActive(0)
m_WarehouseList(GetWarehouseIndex(Warehouses.A)).SetBoxIsActive(0)
Else
m_WarehouseList(GetWarehouseIndex(m_ActiveWarehouse)).SetBoxIsActive(BoxId)
End If
End Sub
Friend Sub SetBoxState(Warehouse As Warehouses, Id As Integer, State As States)
Dim x = GetWarehouseIndex(Warehouse)
m_WarehouseList(GetWarehouseIndex(Warehouse)).SetBoxState(Id, State)
End Sub
Friend Sub FillActiveBox(Livello As Integer, Riga As Integer)
If ActiveWarehouse = 0 Then Return
m_WarehouseList(GetWarehouseIndex(m_ActiveWarehouse)).FillActiveBox(Livello, Riga)
End Sub
Friend Sub MaxFillActiveBox(MaxLivello As Integer, MaxRiga As Integer)
If ActiveWarehouse = 0 Then Return
m_WarehouseList(GetWarehouseIndex(m_ActiveWarehouse)).MaxFillActiveBox(MaxLivello, MaxRiga)
End Sub
Friend Sub SetTableCounters(Table1Counter As Integer, Table2Counter As Integer)
m_Table1Counter = Table1Counter
m_Table2Counter = Table2Counter
NotifyPropertyChanged("TableDifference")
End Sub
Friend Sub SetTable2Counter(Table2Counter As Integer)
m_Table2Counter = Table2Counter
NotifyPropertyChanged("Table2Counter")
End Sub
'Friend Sub SetTable1Percentage(Table1CurrRow As Integer, Table1NRow As Integer)
' m_Table1CurrRow = Table1CurrRow
' m_Table1NRow = Table1NRow
' NotifyPropertyChanged("Table1Percentage")
'End Sub
Friend Sub SetTileType(TyleType As Integer)
m_TileType = TyleType
NotifyPropertyChanged("TileType")
End Sub
Friend Sub SetTileThickness(TileThickness As Double)
m_TileThickness = TileThickness
NotifyPropertyChanged("TileThickness")
End Sub
Friend Sub SetLastSlab(LastSlab As Boolean)
m_LastSlab = LastSlab
NotifyPropertyChanged("LastSlab")
End Sub
Friend Shared Function GetWarehouseIndex(Warehouse As Warehouses) As Integer
If Warehouse = Warehouses.A Then
Return 0
ElseIf Warehouse = Warehouses.B Then
Return 1
Else
EgtOutLog("Warehouse index out of range")
Return 0
End If
End Function
'--------------------------------------------------------------------------------------
#End Region ' METHODS
#Region "New METHODS"
Public Function Init() As Boolean
' verifico che siano state caricate correttamente le costanti
Dim bSetOffset As Boolean = SetOffset(K_PALLETX, m_OffsetPalletX) AndAlso
SetOffset(K_PALLETY, m_OffsetPalletY) AndAlso
SetOffset(K_PALLETZ, m_OffsetPalletZ) AndAlso
SetOffset(K_RACKX, m_OffsetRackX) AndAlso
SetOffset(K_RACKZ, m_OffsetRackZ) AndAlso
SetOffset(K_RACKY, m_OffsetRackY) AndAlso
SetOffset(K_ANGRACK, m_AngRack) AndAlso
SetOffset(K_RULLERX, m_OffsetRullerX) AndAlso
SetOffset(K_RULLERY, m_OffsetRullerY)
Dim bSetMaxPallet As Boolean = SetMaxPallet(K_MAX_HEIGHT, m_MaxHeight) AndAlso
SetMaxPallet(K_MAX_LENGTH, m_MaxLength) AndAlso
SetMaxPallet(K_MAX_WIDTH, m_MaxWidth)
Dim bSetMaxRack As Boolean = SetMaxTileRack(K_MAX_TILE, m_MaxTile)
Return bSetOffset And bSetMaxPallet And bSetMaxRack
End Function
' leggo dalla configurazione gli offset dei pallet e dei rack
Public Function SetOffset(sName As String, ByRef dVal As Double) As Boolean
Dim sVal As String = String.Empty
If GetMainPrivateProfileString(S_OFFSET, sName, "0", sVal) < 0 Then
EgtOutLog("Error reading file Config.ini [Offset] -> " & sName)
Return False
Else
If Not StringToLen(sVal, dVal) Then
EgtOutLog("Error reading file Config.ini [Offset] -> " & sName & " is not numeric")
Return False
End If
End If
Return True
End Function
' leggo le dimensioni massime caricabili su pallet
Public Function SetMaxPallet(ByVal sName As String, ByRef dVal As Double) As Boolean
Dim sVal As String = String.Empty
If GetMainPrivateProfileString(S_BOX, sName, "0", sVal) < 0 Then
EgtOutLog("Error reading file Config.ini [Box] -> " & sName)
Return False
Else
If Not StringToLen(sVal, dVal) Then
EgtOutLog("Error reading file Config.ini [Box] -> " & sName & " is not numeric")
Return False
End If
End If
Return True
End Function
' leggo del dimansioni massim e caricabili su rack
Public Function SetMaxTileRack(ByVal sName As String, ByRef nVal As Integer) As Boolean
Dim sVal As String = String.Empty
If GetMainPrivateProfileString(S_BOX, sName, "0", sVal) < 0 Then
EgtOutLog("Error reading file Config.ini [Box] -> " & sName)
Return False
Else
If Not IsNumeric(sVal) Then
EgtOutLog("Error reading file Config.ini [Box] -> " & sName & " is not numeric")
Return False
End If
End If
nVal = CInt(sVal)
Return True
End Function
' restituisco la lista di tutti i pezzi identificati dalla stessa posizione (di default quelli buoni) del progetto corrente
Public Function GetParts(DefinePlce As Place, Optional DefineStatus As StatusPart = StatusPart.GOOD) As ObservableCollection(Of Part)
Dim CurrList As New ObservableCollection(Of Part)
For Each Item In Map.refUnloadingAreaVM.ListPart
If Item.IdProject = Map.refMainWindowVM.MainWindowM.nProjInd And Item.enPlace = DefinePlce And DefineStatus = Item.enStatus Then
CurrList.Add(Item)
End If
Next
Return CurrList
End Function
' restituisco la lista di tutti i pezzi identificati dalla stessa posizione (di default quelli buoni) del progetto indicato
Public Function GetParts(IdProj As Integer, DefinePlce As Place, Optional DefineStatus As StatusPart = StatusPart.GOOD) As ObservableCollection(Of Part)
Dim CurrList As New ObservableCollection(Of Part)
For Each Item In Map.refUnloadingAreaVM.ListPart
If Item.IdProject = IdProj And Item.enPlace = DefinePlce And DefineStatus = Item.enStatus Then
CurrList.Add(Item)
End If
Next
Return CurrList
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)
For Each Item In Map.refUnloadingAreaVM.ListPart
If Item.enPlace = DefinePlce And DefineStatus = Item.enStatus Then
CurrList.Add(Item)
End If
Next
Return CurrList
End Function
Public Function GetWarehouse(WarehouseId As Warehouses) As WarehouseVM
For Each ItemWarehouse In m_WarehouseList
If ItemWarehouse.Id = WarehouseId Then Return ItemWarehouse
Next
Return Nothing
End Function
' restituisce il magazzino corrente, se nessun magazzino corrente restituisco nothing
Public Function GetCurrentWarehouse() As WarehouseVM
If ActiveWarehouse = Warehouses.A Then
Return GetWarehouse(Warehouses.A)
ElseIf ActiveWarehouse = Warehouses.B Then
Return GetWarehouse(Warehouses.B)
End If
Return Nothing
End Function
' quando si ha conferma dell'organizzazione del magazzino allora organizzo la pallettizzazione (false: mancano i Box)
Public Function OrganaizeWarehouse(Optional ByVal Me_Warehouse As WarehouseVM = Nothing) As Boolean
' Se il progetto è terminato (scarico dell'ultimo pezzo avvenuto)
If m_IdProjTable2.enStatus = StatusProj.DONE Then
' ricerco il primo proggetto in attesa di essere alaborato dalla tavola 2 (LOADING)
For Each ItemProj In Map.refMainWindowVM.MainWindowM.ProjIndList
If ItemProj.enStatus = StatusProj.LOADING Then
m_IdProjTable2 = ItemProj
Exit For
End If
Next
ElseIf Map.refMainWindowVM.MainWindowM.ProjIndList.Count = 0 Then
' se non ci sono progetti esco
Return True
ElseIf Map.refMainWindowVM.MainWindowM.ProjIndList.Count = 1 Then
m_IdProjTable2 = Map.refMainWindowVM.MainWindowM.ProjIndList(0)
End If
OutLogProcess("OrganaizeWarehouse() -> Nuovo progetto per scarico macchin 2: " & m_IdProjTable2.nProjInd.ToString)
' questa veriabile è comandata all'interno del Refresh
'If Not m_bOrganizeWarehouse Then Return True
' recupero il magazzino attivo
Dim CurrWarehause As WarehouseVM = GetCurrentWarehouse()
If Not IsNothing(Me_Warehouse) Then
CurrWarehause = Me_Warehouse
End If
If IsNothing(CurrWarehause) Then Return False
' lista dei box disponibili (pallet/rack)
Dim nPallet As Integer = 0
Dim nRack As Integer = 0
Dim AvailablePalletList As New ObservableCollection(Of Box)
Dim AvailableRackList As New ObservableCollection(Of Box)
For Each ItemGridBox In CurrWarehause.GridBoxList
For Each ItemBox In ItemGridBox.CurrBoxList
If ItemBox.State = States.AVAILABLE Then
If ItemGridBox.IsPallet Then
AvailablePalletList.Add(ItemBox)
nPallet = nPallet + 1
Else
AvailableRackList.Add(ItemBox)
nRack = nRack + 1
End If
End If
Next
Next
' divido i pezzi in due liste (palle/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)
' tutti quelli già sul rullo
For Each ItemPart In GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER)
If ItemPart.enUnloading = Unloading.AUTOMATIC Then
If ItemPart.MinRectX > m_MaxLength Or ItemPart.MinRectY > m_MaxWidth Then
RackPartList.Add(ItemPart)
nPartOnRack = nPartOnRack + 1
Else
PalletPartList.Add(ItemPart)
nPartOnPallet = nPartOnPallet + 1
End If
End If
Next
' tutti quelli ancora sul tavolo
For Each ItemPart In GetParts(m_IdProjTable2.nProjInd, Place.ON_TABLE)
If ItemPart.enUnloading = Unloading.AUTOMATIC Then
If ItemPart.MinRectX > m_MaxLength Or ItemPart.MinRectY > m_MaxWidth Then
RackPartList.Add(ItemPart)
nPartOnRack = nPartOnRack + 1
Else
PalletPartList.Add(ItemPart)
nPartOnPallet = nPartOnPallet + 1
End If
End If
Next
' recupero l'altezza del primo pezzo, altrimenti esco
Dim dHeightTile As Double = 0
If PalletPartList.Count > 0 Then
dHeightTile = PalletPartList(0).Height
Else
EgtOutLog("Warning: no parts for unloading")
Return True
End If
' verifico la presenza del numero minimo di rack: impossibile scaricare-> cambio magazzino
Dim nTemRack As Integer = CInt(Math.Ceiling(nPartOnRack / m_MaxTile))
If nTemRack > nRack Then
EgtOutLog("Error: needs rack for unloading some parts")
Return False
End If
' verifico numero di pallet necessari-> cambio magazzino
Dim nTemPallet As Integer = CInt(Math.Ceiling((nPartOnPallet * dHeightTile) / (m_MaxHeight)))
If nTemPallet > nPallet Then
EgtOutLog("Error: needs more pallets for unloading")
Return False
End If
' riempio i box con i part che ho trovato, partendo dai rack perchè sono i pezzi più grandi
For IndexPart = 0 To RackPartList.Count - 1
For IndexBox = 0 To nTemRack - 1
If IndexPart <= RackPartList.Count - 1 Then
RackPartList(IndexPart).IdBox = AvailableRackList(IndexBox).Id
RackPartList(IndexPart).enWarehouse = CurrWarehause.Id
AvailableRackList(IndexBox).MyListPart.Add(RackPartList(IndexPart))
IndexPart = IndexPart + 1
End If
If IndexPart > 0 Then
IndexPart = IndexPart - 1
End If
Next
Next
For IndexPart = 0 To PalletPartList.Count - 1
For IndexBox = 0 To nTemPallet - 1
If IndexPart <= PalletPartList.Count - 1 Then
PalletPartList(IndexPart).IdBox = AvailablePalletList(IndexBox).Id
PalletPartList(IndexPart).enWarehouse = CurrWarehause.Id
AvailablePalletList(IndexBox).MyListPart.Add(PalletPartList(IndexPart))
IndexPart = IndexPart + 1
End If
Next
If IndexPart > 0 Then
IndexPart = IndexPart - 1
End If
Next
OutLogProcess("OrganaizeWarehouse() -> Organizzato magazzino per progetto: " & m_IdProjTable2.nProjInd.ToString)
Return True
End Function
#End Region 'New METHODS
#Region "COMMANDS"
#Region "Confirm"
' Returns a command that manage the MainWindow_Unloaded command
Public ReadOnly Property UnloadedWaistPart_Command() As ICommand
Get
If m_cmdUnloadedWaistPart Is Nothing Then
m_cmdUnloadedWaistPart = New Command(AddressOf UnloadedWaistPart)
End If
Return m_cmdUnloadedWaistPart
End Get
End Property
' scarico tutti i pezzi rovinati rimasti sulla rulliera
Public Sub UnloadedWaistPart()
For Each ItemPart In GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER, StatusPart.NOT_LOADED)
ItemPart.enPlace = Place.ON_WASTE_BOX
Next
' Pezzi attualmente sulla rulliera motorizzata
NotifyPropertyChanged("TableDifference")
End Sub
#End Region ' Confirm
#Region "Unloaded"
Public ReadOnly Property UnloadedManualPart_Command() As ICommand
Get
If m_cmdUnloadedManualPart Is Nothing Then
m_cmdUnloadedManualPart = New Command(AddressOf UnloadedManualPart)
End If
Return m_cmdUnloadedManualPart
End Get
End Property
' scarico tutti i pezzi manuali rimasti sulla rulliera
Public Sub UnloadedManualPart()
Dim bManualUnloaded As Boolean = False
For Each ItemPart In GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER, StatusPart.GOOD)
If ItemPart.enUnloading = Unloading.MANUAL Then
ItemPart.enPlace = Place.ON_MANUAL_BOX
bManualUnloaded = True
End If
Next
' se non ci sono pezzi del progetto corrente sulla rulliera considero il progetto terminato
If GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER).Count > 0 Then Return
If bManualUnloaded Then m_IdProjTable2.enStatus = StatusProj.DONE
OutLogProcess("UnloadedManualPart() -> Pezzi manuali scaricati")
OutLogProcess("UnloadedManualPart() -> Progetto terimnato: " & m_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("UnloadedManualPart() -> Eliminato file: " & sFile)
End If
End Sub
#End Region ' Unloaded
#End Region ' COMMANDS
End Class