bac7b490be
Aggiunto reset stato calc in prod su modifiche
533 lines
16 KiB
VB.net
533 lines
16 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.Collections.Specialized
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports System.Windows.Input
|
|
Imports System.Windows.Media
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public MustInherit Class PartVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Protected m_PartM As PartM
|
|
Public ReadOnly Property PartM As PartM
|
|
Get
|
|
Return m_PartM
|
|
End Get
|
|
End Property
|
|
|
|
Protected m_ParentMachGroupVM As MyMachGroupVM
|
|
Public ReadOnly Property ParentMachGroupVM As MyMachGroupVM
|
|
Get
|
|
Return m_ParentMachGroupVM
|
|
End Get
|
|
End Property
|
|
|
|
' Id geometrico del pezzo
|
|
Public ReadOnly Property nPartId As Integer
|
|
Get
|
|
Return m_PartM.nPartId
|
|
End Get
|
|
End Property
|
|
|
|
' Proj del pezzo
|
|
Public Property nProjId As Integer
|
|
Get
|
|
Return m_PartM.nProjId
|
|
End Get
|
|
Set(value As Integer)
|
|
m_PartM.nProjId = value
|
|
End Set
|
|
End Property
|
|
|
|
' Info del pezzo
|
|
Public ReadOnly Property nPDN As Integer
|
|
Get
|
|
Return m_PartM.nPDN
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sNAM As String
|
|
Get
|
|
Return m_PartM.sNAM
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sL As String
|
|
Get
|
|
Return LenToString(m_PartM.dL, 3)
|
|
End Get
|
|
End Property
|
|
Public Property dL As Double
|
|
Get
|
|
Return m_PartM.dL
|
|
End Get
|
|
Set(value As Double)
|
|
m_PartM.dL = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property sW As String
|
|
Get
|
|
Return LenToString(m_PartM.dW, 3)
|
|
End Get
|
|
End Property
|
|
Public Property dW As Double
|
|
Get
|
|
Return m_PartM.dW
|
|
End Get
|
|
Set(value As Double)
|
|
m_PartM.dW = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property sH As String
|
|
Get
|
|
Return LenToString(m_PartM.dH, 3)
|
|
End Get
|
|
End Property
|
|
Public Property dH As Double
|
|
Get
|
|
Return m_PartM.dH
|
|
End Get
|
|
Set(value As Double)
|
|
m_PartM.dH = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Overridable Property sPOSX As String
|
|
Get
|
|
Return LenToString(m_PartM.dPOSX, 3)
|
|
End Get
|
|
Set(value As String)
|
|
StringToLen(value, m_PartM.dPOSX)
|
|
End Set
|
|
End Property
|
|
Public Property dPOSX As Double
|
|
Get
|
|
Return m_PartM.dPOSX
|
|
End Get
|
|
Set(value As Double)
|
|
m_PartM.dPOSX = value
|
|
NotifyPropertyChanged(NameOf(sPOSX))
|
|
End Set
|
|
End Property
|
|
|
|
Public Property nCNT As Integer
|
|
Get
|
|
Return m_PartM.nCNT
|
|
End Get
|
|
Set(value As Integer)
|
|
m_PartM.nCNT = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property sINVERTED As String
|
|
Get
|
|
Return m_PartM.nINVERTED & "°"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sROTATED As String
|
|
Get
|
|
Return m_PartM.nROTATED & "°"
|
|
End Get
|
|
End Property
|
|
|
|
Public Property sMATERIAL As String
|
|
Get
|
|
Return m_PartM.sMATERIAL
|
|
End Get
|
|
Set(value As String)
|
|
m_PartM.sMATERIAL = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property nGlobalState As CalcStates
|
|
Get
|
|
Return m_PartM.nCALC_GlobalState
|
|
End Get
|
|
End Property
|
|
|
|
Public Property nCALC_GlobalERR As Integer
|
|
Get
|
|
Return m_PartM.nCALC_GlobalERR
|
|
End Get
|
|
Set(value As Integer)
|
|
m_PartM.nCALC_GlobalERR = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property nState As CalcStates
|
|
Get
|
|
Return m_PartM.nCALC_State
|
|
End Get
|
|
Set(value As CalcStates)
|
|
m_PartM.nCALC_State = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property Calc_Background As SolidColorBrush
|
|
Get
|
|
If m_PartM.nCALC_GlobalState = CalcStates.OK Then
|
|
Return Brushes.Green
|
|
ElseIf m_PartM.nCALC_GlobalState = CalcStates.NOTCALCULATED Then
|
|
Return Brushes.LightGray
|
|
ElseIf m_PartM.nCALC_GlobalState = CalcStates.INFO Then
|
|
Return Brushes.Green
|
|
ElseIf m_PartM.nCALC_GlobalState = CalcStates.WARNING Then
|
|
Return Brushes.Orange
|
|
ElseIf m_PartM.nCALC_GlobalState = CalcStates.ERROR_ Then
|
|
Return Brushes.Red
|
|
Else
|
|
Return Brushes.Red
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CALC_ROT_Visibility As Visibility
|
|
Get
|
|
Return If(m_PartM.nCALC_ROT <> 0, Visibility.Visible, Visibility.Collapsed)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CALC_FALL_Visibility As Visibility
|
|
Get
|
|
Return If(m_PartM.nCALC_FALL <> 0, Visibility.Visible, Visibility.Collapsed)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CALC_ERR_Letter As String
|
|
Get
|
|
Select Case m_PartM.nCALC_GlobalERR
|
|
Case 22
|
|
Return "c"
|
|
Case 19, 23, 24, 25
|
|
Return "e"
|
|
Case 17
|
|
Return "w"
|
|
Case < 0
|
|
Return "i"
|
|
Case Else
|
|
Return ""
|
|
End Select
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CALC_ERR_Foreground As SolidColorBrush
|
|
Get
|
|
Select Case m_PartM.nCALC_GlobalState
|
|
Case CalcStates.ERROR_
|
|
Return Brushes.Red
|
|
Case CalcStates.WARNING
|
|
Return Brushes.Orange
|
|
Case CalcStates.INFO
|
|
Return Brushes.Green
|
|
Case Else
|
|
Return Brushes.Red
|
|
End Select
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property nCALC_ERR As Integer
|
|
Get
|
|
Return m_PartM.nCALC_ERR
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sCALC_MSG As String
|
|
Get
|
|
Return m_PartM.sCALC_MSG
|
|
End Get
|
|
End Property
|
|
|
|
Public Property nCALC_ROT As Integer
|
|
Get
|
|
Return m_PartM.nCALC_ROT
|
|
End Get
|
|
Set(value As Integer)
|
|
m_PartM.nCALC_ROT = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property nCALC_FALL As Integer
|
|
Get
|
|
Return m_PartM.nCALC_FALL
|
|
End Get
|
|
Set(value As Integer)
|
|
m_PartM.nCALC_FALL = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property nCALC_TIME As Integer
|
|
Get
|
|
Return m_PartM.nCALC_TIME
|
|
End Get
|
|
Set(value As Integer)
|
|
m_PartM.nCALC_TIME = value
|
|
End Set
|
|
End Property
|
|
|
|
' lista delle feature del pezzo
|
|
Protected m_FeatureVMList As ObservableCollection(Of BTLFeatureVM)
|
|
Public Property FeatureVMList As ObservableCollection(Of BTLFeatureVM)
|
|
Get
|
|
Return m_FeatureVMList
|
|
End Get
|
|
Set(value As ObservableCollection(Of BTLFeatureVM))
|
|
m_FeatureVMList = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected m_SelFeatureVM As BTLFeatureVM
|
|
Public Property SelFeatureVM As BTLFeatureVM
|
|
Get
|
|
Return m_SelFeatureVM
|
|
End Get
|
|
Set(value As BTLFeatureVM)
|
|
m_SelFeatureVM = value
|
|
If Not IsNothing(m_SelFeatureVM) Then
|
|
DirectCast(m_SelFeatureVM, BTLFeatureVM).SelGeomFeature()
|
|
Else
|
|
EgtDeselectAll()
|
|
End If
|
|
EgtDraw()
|
|
NotifyPropertyChanged(NameOf(SelFeatureVM))
|
|
End Set
|
|
End Property
|
|
|
|
Public Property dtStartTime As DateTime
|
|
Get
|
|
Return m_PartM.dtStartTime
|
|
End Get
|
|
Set(value As DateTime)
|
|
m_PartM.dtStartTime = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property dtEndTime As DateTime
|
|
Get
|
|
Return m_PartM.dtEndTime
|
|
End Get
|
|
Set(value As DateTime)
|
|
m_PartM.dtEndTime = value
|
|
End Set
|
|
End Property
|
|
|
|
' definizione comandi
|
|
Private m_cmdDeletePart As ICommand
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(PartM As PartM, ParentMachGroupVM As MyMachGroupVM)
|
|
m_PartM = PartM
|
|
m_ParentMachGroupVM = ParentMachGroupVM
|
|
AddHandler m_PartM.BTLFeatureAdded, AddressOf OnBTLFeatureAdded
|
|
CreateBTLFeatureVMList()
|
|
' Aggiorno stato da stati feature
|
|
CalcGlobalUpdate()
|
|
NotifyPropertyChanged(NameOf(CALC_FALL_Visibility))
|
|
End Sub
|
|
'Sub New(nParentMachGroup As MyMachGroupM, nPartId As Integer)
|
|
' m_ParentMachGroup = nParentMachGroup
|
|
' SetPartId(nPartId)
|
|
' m_FeatureVMList = New ObservableCollection(Of BTLFeatureM)
|
|
'End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
Private Sub CreateBTLFeatureVMList()
|
|
Dim all As List(Of BTLFeatureVM) = (From BTLFeatureM In m_PartM.GetBTLFeatures()
|
|
Select New BTLFeatureVM(BTLFeatureM)).ToList()
|
|
|
|
For Each BTLFeatureVM As BTLFeatureVM In all
|
|
AddHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged
|
|
Next
|
|
|
|
m_FeatureVMList = New ObservableCollection(Of BTLFeatureVM)(all)
|
|
AddHandler m_FeatureVMList.CollectionChanged, AddressOf OnBTLFeatureVMListChanged
|
|
End Sub
|
|
|
|
' funzione che aggiorna lo stato e gli errori dopo calcolo
|
|
Public Sub CalcPartUpdate(ERR As Integer, ROT As Integer, MSG As String)
|
|
EgtSetInfo(nPartId, ITG_PROD_ERR, ERR, True)
|
|
EgtSetInfo(nPartId, ITG_PROD_MSG, MSG, True)
|
|
EgtSetInfo(nPartId, ITG_PROD_ROT, ROT, True)
|
|
m_PartM.nCALC_ERR = ERR
|
|
m_PartM.nCALC_ROT = ROT
|
|
m_PartM.sCALC_MSG = MSG
|
|
If ERR = 0 Then
|
|
nState = CalcStates.OK
|
|
ElseIf ERR = 17 Then
|
|
nState = CalcStates.WARNING
|
|
ElseIf ERR > 0 Then
|
|
nState = CalcStates.ERROR_
|
|
ElseIf ERR < 0 Then
|
|
nState = CalcStates.INFO
|
|
End If
|
|
NotifyPropertyChanged(NameOf(Calc_Background))
|
|
End Sub
|
|
|
|
Friend Sub ResetCalcPart()
|
|
EgtRemoveInfo(nPartId, ITG_PROD_ERR)
|
|
EgtRemoveInfo(nPartId, ITG_PROD_MSG)
|
|
EgtRemoveInfo(nPartId, ITG_PROD_ROT)
|
|
EgtRemoveInfo(nPartId, ITG_PROD_FALL)
|
|
m_PartM.nCALC_GlobalState = CalcStates.NOTCALCULATED
|
|
m_PartM.nCALC_State = CalcStates.NOTCALCULATED
|
|
m_PartM.nCALC_GlobalERR = 0
|
|
m_PartM.nCALC_ERR = 0
|
|
m_PartM.nCALC_ROT = 0
|
|
m_PartM.nCALC_FALL = 0
|
|
m_PartM.sCALC_MSG = ""
|
|
NotifyPropertyChanged(NameOf(Calc_Background))
|
|
NotifyPropertyChanged(NameOf(CALC_FALL_Visibility))
|
|
NotifyPropertyChanged(NameOf(CALC_ROT_Visibility))
|
|
NotifyPropertyChanged(NameOf(CALC_ERR_Letter))
|
|
NotifyPropertyChanged(NameOf(CALC_ERR_Foreground))
|
|
ParentMachGroupVM.ResetCalcMachGroup()
|
|
End Sub
|
|
|
|
Public Sub CalcFallUpdate(FALL As Integer)
|
|
EgtSetInfo(nPartId, ITG_PROD_FALL, FALL, True)
|
|
m_PartM.nCALC_FALL = 0
|
|
NotifyPropertyChanged(NameOf(nCALC_FALL))
|
|
End Sub
|
|
|
|
' funzione che aggiorna lo stato e gli errori dopo calcolo
|
|
Public Sub CalcGlobalUpdate()
|
|
m_PartM.nCALC_GlobalState = nState
|
|
For Each Feature In FeatureVMList
|
|
If Not Feature.bDO Then
|
|
ElseIf Feature.nState = CalcStates.NOTCALCULATED Then
|
|
m_PartM.nCALC_GlobalState = CalcStates.NOTCALCULATED
|
|
Exit For
|
|
ElseIf Feature.nState = CalcStates.INFO And m_PartM.nCALC_GlobalState = CalcStates.OK Then
|
|
m_PartM.nCALC_GlobalState = CalcStates.INFO
|
|
ElseIf Feature.nState = CalcStates.WARNING And (m_PartM.nCALC_GlobalState = CalcStates.OK Or m_PartM.nCALC_GlobalState = CalcStates.INFO) Then
|
|
m_PartM.nCALC_GlobalState = CalcStates.WARNING
|
|
ElseIf Feature.nState = CalcStates.ERROR_ And (m_PartM.nCALC_GlobalState = CalcStates.OK Or m_PartM.nCALC_GlobalState = CalcStates.INFO Or m_PartM.nCALC_GlobalState = CalcStates.WARNING) Then
|
|
m_PartM.nCALC_GlobalState = CalcStates.ERROR_
|
|
End If
|
|
If Feature.nCALC_ERR = 22 Then
|
|
m_PartM.nCALC_GlobalERR = 22
|
|
ElseIf Feature.nCALC_ERR > 0 And m_PartM.nCALC_GlobalERR <= 0 Then
|
|
m_PartM.nCALC_GlobalERR = Feature.nCALC_ERR
|
|
ElseIf Feature.nCALC_ERR < 0 And m_PartM.nCALC_GlobalERR = 0 Then
|
|
m_PartM.nCALC_GlobalERR = Feature.nCALC_ERR
|
|
End If
|
|
Next
|
|
NotifyPropertyChanged(NameOf(Calc_Background))
|
|
NotifyPropertyChanged(NameOf(CALC_ROT_Visibility))
|
|
NotifyPropertyChanged(NameOf(CALC_ERR_Letter))
|
|
NotifyPropertyChanged(NameOf(CALC_ERR_Foreground))
|
|
End Sub
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "DeletePart"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property DeletePart_Command() As ICommand
|
|
Get
|
|
If m_cmdDeletePart Is Nothing Then
|
|
m_cmdDeletePart = New Command(AddressOf DeletePart)
|
|
End If
|
|
Return m_cmdDeletePart
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Overridable Sub DeletePart()
|
|
EgtRemovePartFromRawPart(m_PartM.nPartId)
|
|
' Recupero Id BTLPart originale
|
|
Dim BTLPart As BTLPartVM = RetrieveBTLPartFromPart()
|
|
' elimino pezzo copia
|
|
EgtErase(m_PartM.nPartId)
|
|
' elimino info pezzo su mach group
|
|
Dim sInfo As String = ""
|
|
Dim Index As Integer = 1
|
|
Dim sSplitInfo() As String
|
|
Dim bFound As Boolean = False
|
|
While EgtGetInfo(ParentMachGroupVM.Id, MGR_RPT_PART & Index, sInfo)
|
|
If Not String.IsNullOrWhiteSpace(sInfo) Then
|
|
sSplitInfo = sInfo.Split(","c)
|
|
If bFound Then
|
|
EgtSetInfo(ParentMachGroupVM.Id, MGR_RPT_PART & Index - 1, sInfo)
|
|
End If
|
|
If sSplitInfo(0) = nPartId Then
|
|
bFound = True
|
|
End If
|
|
End If
|
|
Index += 1
|
|
End While
|
|
If bFound Then
|
|
EgtSetInfo(ParentMachGroupVM.Id, MGR_RPT_PART & Index - 1, "")
|
|
End If
|
|
' rimuovo dalla lista pezzi
|
|
Index = ParentMachGroupVM.PartVMList.IndexOf(Me)
|
|
If Index = 0 Then
|
|
If ParentMachGroupVM.PartVMList.Count > 0 Then
|
|
ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(0)
|
|
Else
|
|
ParentMachGroupVM.SelPart = Nothing
|
|
End If
|
|
ElseIf Index = ParentMachGroupVM.PartVMList.Count - 1 Then
|
|
If ParentMachGroupVM.PartVMList.Count > 1 Then
|
|
ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(ParentMachGroupVM.PartVMList.Count - 2)
|
|
Else
|
|
ParentMachGroupVM.SelPart = Nothing
|
|
End If
|
|
Else
|
|
ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(Index - 1)
|
|
End If
|
|
ParentMachGroupVM.PartVMList.Remove(Me)
|
|
' aggiorno contatore pezzi usati in Prod
|
|
If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd()
|
|
End Sub
|
|
|
|
Friend Function RetrieveBTLPartFromPart() As BTLPartVM
|
|
Dim BTLPartId As Integer = EgtDuploGetOriginal(nPartId)
|
|
Return Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = BTLPartId)
|
|
End Function
|
|
|
|
#End Region ' DeletePart
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
#Region "EVENTS"
|
|
|
|
Private Sub OnBTLFeatureAdded(sender As Object, e As BTLFeatureAddedEventArgs)
|
|
Dim BTLFeatureVM As BTLFeatureVM = New BTLFeatureVM(e.NewBTLFeature)
|
|
FeatureVMList.Add(BTLFeatureVM)
|
|
End Sub
|
|
|
|
Private Sub OnBTLFeatureVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
|
|
If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then
|
|
For Each BTLFeatureVM As BTLFeatureVM In e.NewItems
|
|
AddHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged
|
|
Next
|
|
End If
|
|
If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then
|
|
For Each BTLFeatureVM As BTLFeatureVM In e.OldItems
|
|
RemoveHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub OnBTLFeatureVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs)
|
|
'Select Case e.PropertyName
|
|
' Case NameOf(sender.nSelGRP), NameOf(sender.nSelSIDE)
|
|
'End Select
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
End Class
|