bab90cf7dc
- implementazione copia rawpart travi - selezione dei pezzi btl in prod - implementazione accesso Db con codice chiave
263 lines
10 KiB
VB.net
263 lines
10 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class MyMachGroupPanelVM
|
|
Inherits NewMachGroupPanelVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Public ReadOnly Property m_MyMachGroupPanelM As MyMachGroupPanelM
|
|
Get
|
|
Return m_MachGroupPanelM
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(MachGroupPanelM As MachGroupPanelM)
|
|
MyBase.New(MachGroupPanelM)
|
|
' Recupero la macchina di default
|
|
Dim sDefaultMachine As String = String.Empty
|
|
GetMainPrivateProfileString(S_MACH, K_CURRMACH, "", sDefaultMachine)
|
|
' Creo riferimento a questa classe in Map
|
|
Map.SetRefMachGroupPanelVM(Me)
|
|
' elimino copie da cancellare
|
|
DeleteDuplo()
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Protected Overrides Sub CreateMachGroupVMList()
|
|
Dim all As New List(Of MachGroupVM)
|
|
For Each MachGroupM In m_MachGroupPanelM.GetMachGroups()
|
|
If DirectCast(MachGroupM, MyMachGroupM).nMachineType = MachineType.BEAM Then
|
|
all.Add(New BeamMachGroupVM(MachGroupM))
|
|
Else
|
|
all.Add(New WallMachGroupVM(MachGroupM))
|
|
End If
|
|
Next
|
|
|
|
For Each MachGroupvM As MachGroupVM In all
|
|
AddHandler MachGroupvM.PropertyChanged, AddressOf OnMachGroupVMPropertyChanged
|
|
Next
|
|
|
|
MachGroupVMList = New ObservableCollection(Of MachGroupVM)(all)
|
|
AddHandler MachGroupVMList.CollectionChanged, AddressOf OnMachGroupVMListChanged
|
|
End Sub
|
|
|
|
Public Overrides Function InitMachGroupList(Optional bUseDefaults As Boolean = False) As Boolean
|
|
' Svuoto precedente lista di MachGroup
|
|
MachGroupVMList.Clear()
|
|
' aggiorno copie
|
|
m_MyMachGroupPanelM.UpdateDuplo()
|
|
' verifico se esistono già gruppi di lavorazione o se devo creare il primo
|
|
Dim bOk As Boolean = False
|
|
Dim nId = EgtGetFirstMachGroup()
|
|
If nId <> GDB_ID.NULL Then
|
|
bOk = EgtSetCurrMachGroup(nId)
|
|
End If
|
|
If Not bOk Then Return True
|
|
' carico lista dei gruppi di lavorazione
|
|
m_MachGroupPanelM.MachGroupMList = MyMachGroupPanelM.LoadMyMachGroups(Map.refMachinePanelVM.MachineList.ToList())
|
|
' elimino copie da cancellare
|
|
m_MyMachGroupPanelM.DeleteDuplo()
|
|
If bOk Then SelectedMachGroup = MachGroupVMList(0)
|
|
EgtZoom(ZM.ALL)
|
|
Return True
|
|
End Function
|
|
|
|
Public Function RefreshMachGroupList() As Boolean
|
|
' carico lista dei gruppi di lavorazione
|
|
For Each MachGroup As MyMachGroupM In MyMachGroupPanelM.UpdateFromNestingMyMachGroups(Map.refMachinePanelVM.MachineList.ToList())
|
|
m_MachGroupPanelM.AddMachGroup(MachGroup)
|
|
Next
|
|
' aggiorno contatore pezzi in produzione
|
|
For Each MachGroup As MyMachGroupVM In MachGroupVMList
|
|
For Each Part In MachGroup.PartVMList
|
|
' aggiorno calcolo pezzi in produzione
|
|
Dim BTLPart As BTLPartVM = Part.RetrieveBTLPartFromPart()
|
|
If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd()
|
|
Next
|
|
Next
|
|
' seleziono primo MachGroup
|
|
If MachGroupVMList.Count > 0 Then SelectedMachGroup = MachGroupVMList(0)
|
|
EgtZoom(ZM.ALL)
|
|
Return True
|
|
End Function
|
|
|
|
' funzione che cancella tutti i pezzi segnati da eliminare
|
|
Public Sub DeleteDuplo()
|
|
' reset necessario per poter accedere direttamente al grezzo dalle info pezzo e al MachGroup tramite la gerarchia Db geometrico
|
|
EgtResetCurrMachGroup()
|
|
Dim bDuploToDeleteFound As Boolean = False
|
|
Dim nPartId As Integer = EgtGetFirstPart()
|
|
While nPartId <> GDB_ID.NULL
|
|
Dim bIsToDelete As Boolean = False
|
|
If DuploGetToDelete(nPartId, bIsToDelete) AndAlso bIsToDelete Then
|
|
' verifico se ci sono copie
|
|
Dim nDuploCount As Integer = 0
|
|
EgtDuploCount(nPartId, nDuploCount)
|
|
Dim DuploList As New List(Of Integer)
|
|
If nDuploCount > 0 AndAlso EgtDuploList(nPartId, DuploList) Then
|
|
bDuploToDeleteFound = True
|
|
' cancello tutti i pezzi copia nelle barre
|
|
For Each nDuploId In DuploList
|
|
' recupero grezzo cui appartiene
|
|
Dim nRawPartId As Integer
|
|
EgtGetInfo(nDuploId, "!LST", nRawPartId)
|
|
' recupero gruppo di lavorazione
|
|
Dim nMachGroupId As Integer = EgtGetParent(EgtGetParent(EgtGetParent(nRawPartId)))
|
|
' lo setto come corrente
|
|
EgtSetCurrMachGroup(nMachGroupId)
|
|
' elimino pezzo copia
|
|
EgtRemovePartFromRawPart(nDuploId)
|
|
EgtErase(nDuploId)
|
|
'' recupero gruppo di lavorazione e trave dell'interfaccia
|
|
Dim BeamMachGroup As BeamMachGroupVM = MachGroupVMList.FirstOrDefault(Function(x) x.Id = nMachGroupId)
|
|
Dim Beam As BeamVM = BeamMachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nDuploId)
|
|
EgtSetCurrMachGroup(BeamMachGroup.Id)
|
|
Beam.DeletePart()
|
|
Next
|
|
End If
|
|
DuploResetToDelete(nPartId)
|
|
End If
|
|
nPartId = EgtGetNextPart(nPartId)
|
|
End While
|
|
' se cancellato almeno un pezzo, salvo
|
|
If bDuploToDeleteFound Then
|
|
Map.refProdManagerVM.Save()
|
|
End If
|
|
EgtResetCurrMachGroup()
|
|
End Sub
|
|
|
|
Friend Shared Function DuploGetToDelete(nSouId As Integer, ByRef bToDelete As Boolean) As Boolean
|
|
If IsNothing(nSouId) Then Return False
|
|
Return EgtGetInfo(nSouId, DUPLO_TODELETE, bToDelete)
|
|
End Function
|
|
|
|
Public Shared Function DuploSetToDelete(nSouId As Integer) As Boolean
|
|
If IsNothing(nSouId) Then Return False
|
|
Return EgtSetInfo(nSouId, DUPLO_TODELETE, True)
|
|
End Function
|
|
|
|
Private Shared Function DuploResetToDelete(nSouId As Integer) As Boolean
|
|
If IsNothing(nSouId) Then Return False
|
|
Return EgtSetInfo(nSouId, DUPLO_TODELETE, "")
|
|
End Function
|
|
|
|
Friend Shared Sub DuploRemoveProjCalc(nPartDuploId As Integer)
|
|
EgtSetInfo(nPartDuploId, ITG_PROJ_ERR, "")
|
|
EgtSetInfo(nPartDuploId, ITG_PROJ_MSG, "")
|
|
EgtSetInfo(nPartDuploId, ITG_PROJ_ROT, "")
|
|
EgtSetInfo(nPartDuploId, ITG_PROJ_FALL, "")
|
|
EgtSetInfo(nPartDuploId, ITG_PROJ_TIME, "")
|
|
End Sub
|
|
|
|
Public Overrides Sub AddMachGroup()
|
|
Dim SelMyMachine As MyMachine = Map.refMachinePanelVM.SelectedMachine
|
|
Dim MyMachGroupM As MyMachGroupM = m_MyMachGroupPanelM.NewMyMachGroup(SelMyMachine.Name, SelMyMachine.nType)
|
|
'' creo oggetto gruppo creato
|
|
'Dim sNewMachGroupName As String = String.Empty
|
|
'Dim sNewMachGroupMachineName As String = String.Empty
|
|
'EgtGetMachGroupName(nNewMachGroupID, sNewMachGroupName)
|
|
'EgtGetMachGroupMachineName(nNewMachGroupID, sNewMachGroupMachineName)
|
|
'Dim MyMachGroup As MyMachGroupM
|
|
'If Map.refMachinePanelVM.SelectedMachine.nType = MachineType.BEAM Then
|
|
' MyMachGroup = New BeamMachGroupVM(nNewMachGroupID, sNewMachGroupName, sNewMachGroupMachineName)
|
|
'Else
|
|
' MyMachGroup = New WallMachGroup(nNewMachGroupID, sNewMachGroupName, sNewMachGroupMachineName)
|
|
'End If
|
|
'' lo aggiungo alla lista
|
|
'MachGroupList.Add(MyMachGroup)
|
|
' e lo seleziono
|
|
SelectedMachGroup = MachGroupVMList.FirstOrDefault(Function(x) x.MachGroupM Is MyMachGroupM)
|
|
End Sub
|
|
|
|
Public Overrides Function OnPreSetCurrMachGroup() As Boolean
|
|
EgtSetCurrentContext(Map.refSceneHostVM.MainScene.GetCtx())
|
|
Return True
|
|
End Function
|
|
|
|
Public Overrides Function OnPostSetCurrMachGroup() As Boolean
|
|
' resetto eventuale selezione pezzo
|
|
DirectCast(SelectedMachGroup, MyMachGroupVM).SelPart = Nothing
|
|
' Imposto vista solo tavola
|
|
EgtSetMachineLook(MCH_LOOK.TAB)
|
|
Dim View As VT
|
|
For Each Mach As MyMachine In Map.refMachinePanelVM.MachineList
|
|
If Mach.Name = SelectedMachGroup.Machine Then
|
|
If Mach.nType = Core.ConstBeam.MachineType.BEAM Then
|
|
View = VT.ISO_SW
|
|
Else
|
|
View = VT.TOP
|
|
End If
|
|
Exit For
|
|
End If
|
|
Next
|
|
EgtSetView(View, False)
|
|
EgtZoom(ZM.ALL)
|
|
Return True
|
|
End Function
|
|
|
|
' funzione che seleziona primo gruppo
|
|
Friend Sub SelFirstMachGroup()
|
|
If Not IsNothing(Me) AndAlso Not IsNothing(MachGroupVMList) AndAlso MachGroupVMList.Count > 0 Then
|
|
SelectedMachGroup = MachGroupVMList(0)
|
|
Else
|
|
SelectedMachGroup = Nothing
|
|
EgtResetCurrMachGroup()
|
|
' nascondo tutti i pezzi
|
|
Map.refProjectVM.BTLStructureVM.HideAll()
|
|
End If
|
|
End Sub
|
|
|
|
' funzione che seleziona ultimo gruppo
|
|
Friend Sub SelLastMachGroup()
|
|
If Not IsNothing(Me) AndAlso Not IsNothing(MachGroupVMList) AndAlso MachGroupVMList.Count > 0 Then
|
|
SelectedMachGroup = MachGroupVMList(MachGroupVMList.Count - 1)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Function GetLastMachGroup() As MachGroupVM
|
|
If Not IsNothing(Me) AndAlso Not IsNothing(MachGroupVMList) AndAlso MachGroupVMList.Count > 0 Then
|
|
Return MachGroupVMList(MachGroupVMList.Count - 1)
|
|
End If
|
|
Return Nothing
|
|
End Function
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "EVENTS"
|
|
|
|
Protected Overrides Sub OnMachGroupAdded(sender As Object, e As MachGroupAddedEventArgs)
|
|
Dim MachGroupVM As MachGroupVM = Nothing
|
|
Select Case DirectCast(e.NewMachGroupM, MyMachGroupM).nMachineType
|
|
Case Core.ConstBeam.MachineType.BEAM
|
|
MachGroupVM = New BeamMachGroupVM(e.NewMachGroupM)
|
|
Case Core.ConstBeam.MachineType.WALL
|
|
MachGroupVM = New WallMachGroupVM(e.NewMachGroupM)
|
|
Case Core.ConstBeam.MachineType.NULL
|
|
Return
|
|
End Select
|
|
MachGroupVMList.Add(MachGroupVM)
|
|
NotifyPropertyChanged(NameOf(MachGroupVMList))
|
|
End Sub
|
|
|
|
Protected Overrides Sub OnMachGroupVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs)
|
|
Select Case e.PropertyName
|
|
'Case nameof(sender.sMATERIAL)
|
|
End Select
|
|
End Sub
|
|
|
|
#End Region ' EVENTS
|
|
|
|
End Class
|