fbfaad64cf
- correzioni per spostamento pezzi tra tavole con e senza rotazioni (per immagine lastra).
369 lines
17 KiB
VB.net
369 lines
17 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtPHOTOLib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class MyMachGroupPanelVM
|
|
Inherits MachGroupPanelVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' le liste devono essere svuotate iìogni volta che carico/creo un progetto
|
|
Private m_SlabNameListOrig As New List(Of String)
|
|
Public ReadOnly Property SlabNameListOrig As List(Of String)
|
|
Get
|
|
Return m_SlabNameListOrig
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SlabNameListCurr As New List(Of String)
|
|
Public Property SlabNameListCurr As List(Of String)
|
|
Get
|
|
Return m_SlabNameListCurr
|
|
End Get
|
|
Set(value As List(Of String))
|
|
m_SlabNameListCurr = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' FIELDS & REGION
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
MyBase.New()
|
|
' Creo riferimento a questa classe in OmagOFFICEMap
|
|
OmagOFFICEMap.SetRefMachGroupPanelVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Sub Init()
|
|
' Recupero la macchina di default
|
|
Dim sDefaultMachine As String = String.Empty
|
|
GetMainPrivateProfileString(S_MACH, K_CURRMACH, "", sDefaultMachine)
|
|
EgtSetCurrMachine(sDefaultMachine)
|
|
InitMachGroupPanel(True, OmagOFFICEMap.refMachinePanelVM.MachineList.ToList(), sDefaultMachine, BASE_MACH_GROUP & "1")
|
|
End Sub
|
|
|
|
Public Overrides Sub AddMachGroup()
|
|
If NewMachGroup() Then
|
|
' creo oggetto gruppo creato
|
|
Dim nNewMachGroupID As Integer = EgtGetCurrMachGroup()
|
|
Dim sNewMachGroupName As String = String.Empty
|
|
Dim sNewMachGroupMachineName As String = String.Empty
|
|
EgtGetMachGroupName(EgtGetCurrMachGroup(), sNewMachGroupName)
|
|
EgtGetMachGroupMachineName(nNewMachGroupID, sNewMachGroupMachineName)
|
|
Dim MyMachGroup As MyMachGroup = New MyMachGroup(EgtGetCurrMachGroup, sNewMachGroupName, sNewMachGroupMachineName, EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers"))
|
|
' lo aggiungo alla lista
|
|
MachGroupList.Add(MyMachGroup)
|
|
' e lo seleziono
|
|
SelectedMachGroup = MyMachGroup
|
|
EgtZoom(ZM.ALL)
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Sub LoadMachGroupList()
|
|
' Carico i gruppi di lavorazione nella lista
|
|
Dim nId = EgtGetFirstMachGroup()
|
|
While nId <> GDB_ID.NULL
|
|
Dim sName As String = String.Empty
|
|
Dim sMachine As String = String.Empty
|
|
EgtGetMachGroupName(nId, sName)
|
|
EgtGetMachGroupMachineName(nId, sMachine)
|
|
Dim NewMyMachGoup As MyMachGroup = New MyMachGroup(nId, sName, sMachine, EgtGetFirstNameInGroup(nId, "Opers"))
|
|
NewMyMachGoup.IsValid = VerifyMachExists(sMachine)
|
|
MachGroupList.Add(NewMyMachGoup)
|
|
If OmagOFFICEMap.refMainWindowVM.MainWindowM.m_SlabDB Then
|
|
Dim sSlabNameDB As String = String.Empty
|
|
EgtGetInfo(nId, INFO_SLABNAME, sSlabNameDB)
|
|
Try
|
|
If Not m_SlabNameListOrig.Exists(Function(value As String)
|
|
Return value = sSlabNameDB
|
|
End Function) Then
|
|
m_SlabNameListOrig.Add(sSlabNameDB)
|
|
End If
|
|
Catch ex As Exception
|
|
End Try
|
|
End If
|
|
nId = EgtGetNextMachGroup(nId)
|
|
End While
|
|
End Sub
|
|
|
|
Public Overrides Function OnPreNewMachGroup() As Boolean
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
Return True
|
|
End Function
|
|
|
|
' NB: Anche se ho già aggiunto il nuovo gruppo di lavorazione, non l'ho ancora reso corrente (viene fatto dopo), quindi
|
|
' non posso usare CurrentMachine perchè è ancora impostata quella precedente!!!
|
|
Public Overrides Function OnPostNewMachGroup() As Boolean
|
|
' Salvo macchina del gruppo come nuovo default
|
|
Dim sCurrMachName As String = String.Empty
|
|
EgtGetCurrMachineName(sCurrMachName)
|
|
CurrentMachine.GetMachineClass(sCurrMachName)
|
|
OmagOFFICEMap.refMainWindowVM.MainWindowM.sMachinesRoot = Path.GetDirectoryName(OmagOFFICEMap.refMachinePanelVM.SelectedMachine.DirPath)
|
|
WriteMainPrivateProfileString(S_MACH, K_CURRMACH, sCurrMachName)
|
|
' Ricarico la macchina corrente
|
|
InitCurrentMachine(OmagOFFICEMap.refMainWindowVM.MainWindowM.sMachinesRoot, sCurrMachName,
|
|
OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.PRODUCTION_LINE),
|
|
OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.ENABLE_MILL),
|
|
OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.ENABLE_POLISHING),
|
|
OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.ENABLE_WJ),
|
|
True)
|
|
' Se macchina con più tavole, chiedo quale usare
|
|
Dim nTabInd As Integer = 1
|
|
Dim nTabCnt As Integer = CamAuto.GetTableCount()
|
|
If nTabCnt > 1 And nTabCnt <= 4 Then
|
|
Dim dlg As New SelectTableWindowV(Application.Current.MainWindow, New SelectTableWindowVM(nTabCnt))
|
|
dlg.ShowDialog()
|
|
nTabInd = dlg.m_SelTable
|
|
End If
|
|
EgtSetTable(GetTableName(nTabInd))
|
|
' leggo nome attrezzaggio di default
|
|
Dim sDefaultSetUpName As String = String.Empty
|
|
Dim sMachineIniPath As String = OmagOFFICEMap.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & sCurrMachName & "\" & sCurrMachName & ".ini"
|
|
EgtUILib.GetPrivateProfileString(S_SETUP, K_DEFAULT, "", sDefaultSetUpName, sMachineIniPath)
|
|
' se è attiva l'opzione, rendo corrente l'attrezzaggio di default
|
|
If Not String.IsNullOrEmpty(sDefaultSetUpName) Then
|
|
If Not EgtImportSetup(sDefaultSetUpName) Then
|
|
EgtOutLog("Error loading default setup " & sDefaultSetUpName)
|
|
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 9) & " " & sDefaultSetUpName, EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
End If
|
|
End If
|
|
' Aggiungo eventuale sovratavola
|
|
EstCalc.AddAdditionalTable()
|
|
' Aggiorno grezzo iniziale
|
|
EstCalc.UpdateRawPart()
|
|
' Imposto materiale corrente
|
|
EstCalc.SetMaterialName()
|
|
' Imposto flag tagli ridotti
|
|
EstCalc.SetReducedCut(CurrentMachine.bReducedCut)
|
|
' Imposto flag tastatura su tagli inclinati
|
|
EstCalc.SetSideAngCutProbeFlag( CurrentMachine.nSacProbe > 0)
|
|
' Imposto flag lavaggio
|
|
EstCalc.SetWashingFlag(CurrentMachine.nWashing <> 0)
|
|
Return True
|
|
End Function
|
|
|
|
Public Overrides Function OnPreSetCurrMachGroup() As Boolean
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Deseleziono tutto in Nesting e nel VeinMatching
|
|
OmagOFFICE.refNestingTabVM.DeselectAllParts(True)
|
|
Return True
|
|
End Function
|
|
|
|
Public Overrides Function OnPostSetCurrMachGroup() As Boolean
|
|
' Imposto vista solo tavola
|
|
EgtSetMachineLook(MCH_LOOK.TAB)
|
|
CurrentMachine.GetMachineClass(SelectedMachGroup.Machine)
|
|
If IsNothing(OmagOFFICEMap.refMachinePanelVM.SelectedMachine) Then Return False
|
|
OmagOFFICEMap.refMainWindowVM.MainWindowM.sMachinesRoot = Path.GetDirectoryName(OmagOFFICEMap.refMachinePanelVM.SelectedMachine.DirPath)
|
|
' Ricarico la macchina corrente
|
|
InitCurrentMachine(OmagOFFICEMap.refMainWindowVM.MainWindowM.sMachinesRoot, SelectedMachGroup.Machine,
|
|
OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.PRODUCTION_LINE),
|
|
OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.ENABLE_MILL),
|
|
OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.ENABLE_POLISHING),
|
|
OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.ENABLE_WJ),
|
|
True)
|
|
' Imposto tab Disposizione
|
|
OmagOFFICEMap.refOptionPanelVM.SelItem = OptionPanelVM.Tabs.NESTING
|
|
' Aggiorno grezzo iniziale
|
|
EstCalc.UpdateRawPart()
|
|
' Aggiorno materiale corrente
|
|
CurrentMachine.SetCurrMatByName(EstCalc.GetMaterialName())
|
|
' Aggiorno flag tagli ridotti
|
|
CurrentMachine.bReducedCut = EstCalc.GetReducedCut()
|
|
' Aggiorno stato flag tastatura tagli inclinati
|
|
if CurrentMachine.nSacProbe >= 0 Then CurrentMachine.nSacProbe = If( EstCalc.GetSideAngCutProbeFlag(), 1, 0)
|
|
' Aggiorno flag lavaggio
|
|
if CurrentMachine.nWashing >= 0 Then CurrentMachine.nWashing = If( EstCalc.GetWashingFlag(), 1, 0)
|
|
' Verifico compatibilità lavorazioni, setup, materiale e spessore grezzo
|
|
If Not SetUpUtility.IsValidToolHeadExitInSetUp() Then
|
|
OmagOFFICEMap.refMachinePanelVM.SetUp_Background = Brushes.Red
|
|
Else
|
|
OmagOFFICEMap.refMachinePanelVM.SetUp_Background = OmagOFFICEDictionary.Button_Static_Background
|
|
End If
|
|
' Verifico che gli utensili delle lavorazioni correnti siano attrezzati (necessario perchè potrei aver cambiato gli utensili delle lavorazioni)
|
|
' e che le lavorazioni correnti siano compatibili con materiale e spessore
|
|
|
|
' Inizializzo l'elenco delle lavorazioni correnti
|
|
Dim CurrMachining As New CurrMachWindowVM
|
|
|
|
' Lama
|
|
Dim bOkCurrSawing As Boolean = True
|
|
Dim bOkCurrWaterjetting As Boolean = True
|
|
Dim bOkSetUp As Boolean = True
|
|
Dim bOkMatThick As Boolean = True
|
|
Dim sTUUID As String = String.Empty
|
|
If Not String.IsNullOrWhiteSpace(CurrentMachine.sCurrSawing) Then
|
|
EgtMdbSetCurrMachining(CurrentMachine.sCurrSawing)
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sTUUID)
|
|
bOkSetUp = bOkSetUp And SetUpUtility.IsToolInSetUp(sTUUID)
|
|
bOkMatThick = bOkMatThick And CurrMachWindowVM.VerifyMatThickCompatibility()
|
|
Else
|
|
bOkCurrSawing = False
|
|
End If
|
|
' Fresa
|
|
If Not String.IsNullOrWhiteSpace(CurrentMachine.sCurrMilling) Then
|
|
EgtMdbSetCurrMachining(CurrentMachine.sCurrMilling)
|
|
sTUUID = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sTUUID)
|
|
bOkSetUp = bOkSetUp And SetUpUtility.IsToolInSetUp(sTUUID)
|
|
bOkMatThick = bOkMatThick And CurrMachWindowVM.VerifyMatThickCompatibility()
|
|
End If
|
|
' Foretto
|
|
If Not String.IsNullOrWhiteSpace(CurrentMachine.sCurrDrilling) Then
|
|
EgtMdbSetCurrMachining(CurrentMachine.sCurrDrilling)
|
|
sTUUID = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sTUUID)
|
|
bOkSetUp = bOkSetUp And SetUpUtility.IsToolInSetUp(sTUUID)
|
|
bOkMatThick = bOkMatThick And CurrMachWindowVM.VerifyMatThickCompatibility()
|
|
End If
|
|
' Waterjet
|
|
If Not String.IsNullOrWhiteSpace(CurrentMachine.sCurrWaterJetting) Then
|
|
EgtMdbSetCurrMachining(CurrentMachine.sCurrWaterJetting)
|
|
sTUUID = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sTUUID)
|
|
bOkSetUp = bOkSetUp And SetUpUtility.IsToolInSetUp(sTUUID)
|
|
bOkMatThick = bOkMatThick And CurrMachWindowVM.VerifyMatThickCompatibility()
|
|
Else
|
|
bOkCurrWaterjetting = False
|
|
End If
|
|
' Imposto il colore del pulsante SetUp
|
|
If Not bOkSetUp Then
|
|
OmagOFFICEMap.refMachinePanelVM.SetUp_Background = Brushes.Red
|
|
Else
|
|
OmagOFFICEMap.refMachinePanelVM.SetUp_Background = DirectCast(New BrushConverter().ConvertFrom("#1C1D22"), SolidColorBrush)
|
|
End If
|
|
' Imposto il colore di sfondo del pulsante SettingMachinig
|
|
If Not bOkMatThick Or Not bOkCurrSawing Then
|
|
If Not bOkMatThick Or Not bOkCurrWaterjetting Then
|
|
OmagOFFICEMap.refOptionPanelVM.RawPart_Background = Brushes.Red
|
|
OmagOFFICEMap.refRawPartTabVM.CurrMach_Background = Brushes.Red
|
|
Else
|
|
OmagOFFICEMap.refOptionPanelVM.RawPart_Background = OmagOFFICEDictionary.TabControl_Header_Background
|
|
OmagOFFICEMap.refRawPartTabVM.CurrMach_Background = DirectCast(New BrushConverter().ConvertFrom("#1C1D22"), SolidColorBrush)
|
|
End If
|
|
Else
|
|
OmagOFFICEMap.refOptionPanelVM.RawPart_Background = OmagOFFICEDictionary.TabControl_Header_Background
|
|
OmagOFFICEMap.refRawPartTabVM.CurrMach_Background = DirectCast(New BrushConverter().ConvertFrom("#1C1D22"), SolidColorBrush)
|
|
End If
|
|
|
|
' Se non esiste il grezzo vado subito alla sua definizione
|
|
If EstCalc.GetRawId() = GDB_ID.NULL Then
|
|
OmagOFFICEMap.refOptionPanelVM.SelItem = OptionPanelVM.Tabs.RAWPART
|
|
End If
|
|
|
|
Dim sPhotoName As String = EstPhoto.GetPhotoName
|
|
|
|
' aggiungo alla lista delle lastre correnti/orig
|
|
Dim sSlabNameDB As String = GetSlabName()
|
|
LoadSlabsList(sSlabNameDB)
|
|
|
|
' imposto la visibilità dei comandi per il waterjet
|
|
OmagOFFICEMap.refNestingTabVM.Set_WJ_Cmd_Visibility()
|
|
|
|
Return True
|
|
End Function
|
|
|
|
Public Sub LoadSlabsList(sSlabNameDB As String)
|
|
If Not OmagOFFICEMap.refMainWindowVM.MainWindowM.m_SlabDB Then Return
|
|
Dim sFileProject As String = String.Empty
|
|
EgtGetCurrFilePath(sFileProject)
|
|
If Not String.IsNullOrEmpty(sSlabNameDB) Then
|
|
OmagOFFICEMap.refRawPartTabVM.SetMaterialFromDB(EstCalc.GetMaterialPhoto())
|
|
Try
|
|
If Not m_SlabNameListCurr.Exists(Function(value As String)
|
|
Return value = sSlabNameDB
|
|
End Function) Then
|
|
m_SlabNameListCurr.Add(sSlabNameDB)
|
|
End If
|
|
Catch ex As Exception
|
|
End Try
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Function OnPreRemoveCurrMachGroup() As Boolean
|
|
Dim sSlabName As String = GetSlabName()
|
|
' rendo AVAILABLE la lastra nel DB dell'OMAGPhoto
|
|
If OmagOFFICEMap.refMainWindowVM.MainWindowM.m_SlabDB Then
|
|
PhotoMap.refOptionPanelVM.SetAvailableSlab(sSlabName)
|
|
For Each ItemSlab In m_SlabNameListCurr
|
|
If ItemSlab = sSlabName Then
|
|
m_SlabNameListCurr.Remove(ItemSlab)
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Parcheggio tutti i pezzi presenti nella lastra
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(GetRawId())
|
|
While nPartId <> GDB_ID.NULL
|
|
' Recupero identificativo del successivo
|
|
Dim nNextPartId As Integer = EgtGetNextPartInRawPart(nPartId)
|
|
' Metto in parcheggio
|
|
EstCalc.StoreOnePart(nPartId)
|
|
' Eventuale notifica al VeinMatching
|
|
VeinMatching.OnRemovePartFromRaw(nPartId)
|
|
' Passo al successivo
|
|
nPartId = nNextPartId
|
|
End While
|
|
|
|
' Elimino eventuale fotografia e contorno associati
|
|
Dim nPhoto As Integer = EstPhoto.GetPhoto()
|
|
EgtErase(nPhoto)
|
|
Dim nContour As Integer = EstPhoto.GetContour()
|
|
EgtErase(nContour)
|
|
' Elimino eventuale fotografia del VeinMatching associata
|
|
VeinMatching.RemoveUnusedPhotos()
|
|
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class
|
|
|
|
Public Class MyMachGroup
|
|
Inherits MachGroup
|
|
|
|
Private m_nOpersGroupId As Integer = 0
|
|
Public ReadOnly Property nOpersGroupId As Integer
|
|
Get
|
|
Return m_nOpersGroupId
|
|
End Get
|
|
End Property
|
|
|
|
#Region "ToolTip"
|
|
|
|
Public Overrides ReadOnly Property MachGroupToolTip As String
|
|
Get
|
|
Dim sSlabName As String = String.Empty
|
|
If Not EgtGetInfo(Id, INFO_SLABNAME, sSlabName) Then sSlabName = "---"
|
|
Dim sMaterial As String = String.Empty
|
|
If Not EgtGetInfo(Id, INFO_PROJMAT, sMaterial) Then sMaterial = "---"
|
|
Dim dSlabHeight As Double = 0
|
|
If Not EgtGetInfo(Id, INFO_SLABHEIGHT, dSlabHeight) Then dSlabHeight = 0
|
|
Dim sCurrSawing As String = String.Empty
|
|
If Not EgtGetInfo(m_nOpersGroupId, INFO_CURRSAWING, sCurrSawing) Then sCurrSawing = "---"
|
|
Return EgtMsg(91683) & sSlabName & Environment.NewLine & ' Name:
|
|
EgtMsg(91684) & sMaterial & Environment.NewLine & ' Material:
|
|
EgtMsg(91685) & LenToString(dSlabHeight, 3) & Environment.NewLine & ' Thickness:
|
|
EgtMsg(91686) & sCurrSawing & Environment.NewLine & ' Sawing:
|
|
EgtMsg(91687) & Machine ' Machine:
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' ToolTip
|
|
|
|
Sub New(nId As Integer, sName As String, sMachine As String, nOpersGroupId As Integer)
|
|
MyBase.New(nId, sName, sMachine)
|
|
m_nOpersGroupId = nOpersGroupId
|
|
End Sub
|
|
|
|
End Class |