Files
OmagVIEWPlus/Warehouse/Box.vb
T
Nicola Pievani 65dee8bf4c OmagVIEWPlus 2.3a1:
-> aggiornamento automatico della lista "PartList";
-> verifica funzionamento ultima versione.
2021-01-07 14:08:14 +00:00

395 lines
13 KiB
VB.net

Imports EgtWPFLib5
Public Class Box
Inherits VMBase
#Region "FIELDS & PROPERTIES"
' riferiento al bottone corrente
Private m_refBoxV As BoxV
' riferimento al magazzino corrente
Private m_refWarehouse As WarehouseVM
#Region "PROPERTIES"
' Identificativo del pallet
Private m_Id As Integer
Public ReadOnly Property Id As Integer
Get
Return m_Id
End Get
End Property
' indice per la configurazione dell'origine del box: G500-> 500
Private m_OrigDefCN As Integer
Public ReadOnly Property OrigDefCN As Integer
Get
Return m_OrigDefCN
End Get
End Property
' immagine da caricare nel bottone
Private m_ImagePath As String
Public ReadOnly Property ImagePath As String
Get
Return m_ImagePath
End Get
End Property
' indice della colonna del magazzino
Private m_ColumnWarehouse As ColumnsWarehouse
Public ReadOnly Property ColumnWarehouse As ColumnsWarehouse
Get
Return m_ColumnWarehouse
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)
Get
Return m_MyListPart
End Get
Set(value As List(Of Part))
m_MyListPart = value
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
Return (m_State <> States.AVAILABLE)
End Get
Set(value As Boolean)
' ripulisco la lista dei pezzi del box
m_MyListPart.Clear()
If value Then
m_State = States.NOT_AVAILABLE
Else
m_State = States.AVAILABLE
End If
' salvo le info nel file Warehouse.ini
WarehauseWritePrivateProfileString("Warehouse", "Box" & m_refWarehouse.Id.ToString & Id.ToString, CInt(m_State).ToString & " ,G" & m_OrigDefCN.ToString)
NotifyPropertyChanged("ImagePath")
NotifyPropertyChanged("BackGroundColor")
NotifyPropertyChanged("Image_Visibility")
NotifyPropertyChanged("nFillPercentage")
m_refWarehouse.NotifyPropertyChanged("VisibilityUnloadedBtn")
End Set
End Property
' definisco il colore di sfondo in funzione dello stato del bottone
Private m_BackGroundColor As SolidColorBrush = DirectCast(New BrushConverter().ConvertFrom("LightGray"), SolidColorBrush)
Public ReadOnly Property BackGroundColor As SolidColorBrush
Get
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
m_BackGroundColor = DirectCast(New BrushConverter().ConvertFrom("LightGray"), SolidColorBrush)
End Select
Return m_BackGroundColor
End Get
End Property
Public ReadOnly Property InfoBox As String
Get
Dim sInfo As String = String.Empty
sInfo = "G" & m_OrigDefCN.ToString
Dim nPart As Integer = 0
Dim nIdProj As Integer = 0
For Each ItemPart In m_MyListPart
nIdProj = ItemPart.IdProject
If ItemPart.enPlace = Place.ON_BOX Then
nPart = nPart + 1
End If
Next
sInfo &= System.Environment.NewLine & "IdProj: " & nIdProj.ToString
sInfo &= System.Environment.NewLine & "Counter: " & nPart.ToString
Return sInfo
End Get
End Property
#End Region ' PROPERTIES
#Region "STATES"
' definizione del tipo di box
Private m_enConfigBox As ConfigBox
Friend ReadOnly Property enConfigBox As ConfigBox
Get
Return m_enConfigBox
End Get
End Property
' definizione dello stato del Box
Private m_State As States
Public Property State As States
Get
Return m_State
End Get
Set(value As States)
m_State = value
WarehauseWritePrivateProfileString("Warehouse", "Box" & m_refWarehouse.Id.ToString & Id.ToString, CInt(m_State).ToString & " ,G" & m_OrigDefCN.ToString)
NotifyPropertyChanged("State_IsChecked")
End Set
End Property
Private m_IsActive As Boolean = False
Friend ReadOnly Property IsActive As Boolean
Get
Return m_IsActive
End Get
End Property
#End Region ' STATES
Private m_Livello As Integer
Private m_Fila As Integer
Private m_MaxLivello As Integer = 1
Private m_MaxFila As Integer = 1
Private m_Warehouse_IsActive As Boolean
' 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
Dim nPartOnBox As Integer = 0
' quando leggo la configurazione da file ini conosco solo lo satato, se lo stato è FULL ignoro le liste del box
If m_State <> States.FULL Then
For Each ItemPart In m_MyListPart
' conto il numero di pezzi attualmente depositati nel box
If ItemPart.enPlace = Place.ON_BOX Then
nPartOnBox = nPartOnBox + 1
End If
' 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
If m_FillPercentage = 100 Then
m_State = States.FULL
m_refWarehouse.SetCurrentWerahouse()
NotifyPropertyChanged("State")
End If
NotifyPropertyChanged("BackGroundColor")
Return m_FillPercentage
End Get
End Property
' messaggio a video del livello di riempimento del Box corrente
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_nPartOnBox.ToString & "/" & m_nPart.ToString
Case States.LOADING
'Message = m_FillPercentage.ToString & " %"
Message = m_nPartOnBox.ToString & "/" & m_nPart.ToString
'Case States.AVAILABLE
' Message = m_FillPercentage.ToString & " %"
End Select
Return Message
End Get
End Property
' se il magazzino è ATTIVO (non è impiegato per lo scarico) allora nascondo le immagini dei pallet/rack
Public ReadOnly Property Percentage_Visibility As Visibility
Get
Return If(m_Warehouse_IsActive, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
' se il magazzino è DISATTIVO (non è impiegato per lo scarico) allora nascondo le immagini dei pallet/rack
Public ReadOnly Property Image_Visibility As Visibility
Get
Return If(Not m_Warehouse_IsActive And State <> States.NOT_AVAILABLE, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Sub New(nId As Integer, enConfigBox As ConfigBox, Warehouse As WarehouseVM, enStatus As States, nOrigDef As Integer, enColumnWarehouse As ColumnsWarehouse)
m_Id = nId
m_enConfigBox = enConfigBox
m_refWarehouse = Warehouse
m_State = enStatus
m_OrigDefCN = nOrigDef
m_ColumnWarehouse = enColumnWarehouse
If m_enConfigBox = ConfigBox.PALLET Then
m_ImagePath = "/Resources/Pallet.png"
Else
m_ImagePath = "/Resources/Rack.png"
End If
m_refBoxV = New BoxV
m_refBoxV.DataContext = Me
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
' restituisce l'altezza corrente del pallet
Public Function GetPalletOffsetZ() As Double
' recupero l'altezza del pallet
Dim dHeight As Double = 0
' inizializzo l'altezza di deposito con lo spessore del pezzo
For Each ItemPart In MyListPart
dHeight = ItemPart.Height
Exit For
Next
For Each ItemPart In MyListPart
If ItemPart.enPlace = Place.ON_BOX Then
dHeight = dHeight + ItemPart.Height
End If
Next
Return dHeight
End Function
' restituisce la coordinata X in funzione delle dimensioni del pezzo da depositare
Public Function GetRackOffsetZ(LocalPart As Part) As Double
' decido di lavorare nel piano della piastrella
Dim nCounter As Double = 0
Dim dHeight As Double = 1
' inizializzo l'altezza di deposito con lo spessore del pezzo
For Each ItemPart In MyListPart
dHeight = ItemPart.Height
Exit For
Next
For Each ItemPart In MyListPart
If ItemPart.enPlace = Place.ON_BOX Then
nCounter = nCounter + 1
dHeight = ItemPart.Height
End If
Next
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
' restituisce la coordinata X in funzione delle dimensioni del pezzo da depositare
Public Function GetRackOffsetY(LocalPart As Part) As Double
Dim OffsetY As Double = 0
OffsetY = LocalPart.MinRectY / 2 - (Map.refUnloadingAreaVM.VacuumDimY / 2 - LocalPart.MoveTable2.m_vtDelta.y)
If OffsetY < 0 Then
OffsetY = 0
End If
Return OffsetY
End Function
' restituisce la coordinata X in funzione delle dimensioni del pezzo da depositare
Public Function GetRackOffsetX(LocalPart As Part) As Double
Dim OffsetX As Double = Map.refUnloadingAreaVM.OffsetRackY
OffsetX = OffsetX + LocalPart.MoveTable2.m_vtDelta.x
Return OffsetX
End Function
'--------------------------------------------------------------------------------------------------------------------
Friend Sub SetState(State As States)
m_State = State
Select Case m_State
Case States.AVAILABLE, States.NOT_AVAILABLE
m_FillPercentage = 0
Case States.FULL
m_FillPercentage = 100
End Select
NotifyPropertyChanged("FillPercentage")
NotifyPropertyChanged("State_IsChecked")
End Sub
Friend Sub SetWarehouse_IsActive(bIsActive As Boolean)
m_Warehouse_IsActive = bIsActive
NotifyPropertyChanged("Percentage_Visibility")
NotifyPropertyChanged("Image_Visibility")
End Sub
Friend Sub SetIsActive(IsActive As Boolean)
m_IsActive = IsActive
End Sub
Friend Sub FillBox(Livello As Integer, Fila As Integer)
m_Livello = Livello
m_Fila = Fila
If m_MaxLivello = 0 OrElse m_MaxFila = 0 Then
m_FillPercentage = 0
Else
m_FillPercentage = CInt(Math.Round((((m_Livello - 1) * m_MaxFila) + m_Fila) / (m_MaxLivello * m_MaxFila) * 100))
End If
NotifyPropertyChanged("FillPercentage")
End Sub
Friend Sub MaxFillBox(MaxLivello As Integer, MaxFila As Integer)
m_MaxLivello = MaxLivello
m_MaxFila = MaxFila
End Sub
#End Region ' METHODS
End Class