5043d54802
- sistemazioni varie - aggiunta lavorazione waterjet e sua integrazione con i tagli.
651 lines
31 KiB
VB.net
651 lines
31 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib
|
|
|
|
Public Class ProjectMgrUC
|
|
|
|
' Riferimenti a pagine (condivisi tra tutte le istanze della classe)
|
|
Private Shared m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
Private Shared m_CurrProjPage As CurrentProjectPageUC
|
|
Private Shared m_CurrMachine As CurrentMachine
|
|
Private Shared m_CurrNcComm As CNCommunication
|
|
Friend Shared m_VeinMatchingWnd As VeinMatchingWindow = Nothing
|
|
|
|
Private Sub ProjectMgrUC_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
|
' Imposto i messaggi letti dal file dei messaggi
|
|
NewBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 3)
|
|
LoadBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 4)
|
|
SaveBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 5)
|
|
SaveNameBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 6)
|
|
CSVBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 8)
|
|
VeinMatchingBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 9)
|
|
RegisterBtn.Content = "REG" 'Shape Registration
|
|
ResetCutBtn.Content = EgtMsg(MSG_NESTPAGEUC + 6) 'Reset
|
|
SimulateBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 1) 'Simulate - Simula
|
|
WorkBtn.Content = EgtMsg(MSG_CADCUTPAGEUC + 2) 'Work - Lavora
|
|
End Sub
|
|
|
|
Private Sub ProjectMgrUC_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
' Impostazioni
|
|
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
|
m_CurrMachine = m_MainWindow.m_CurrentMachine
|
|
m_CurrNcComm = m_MainWindow.m_CNCommunication
|
|
' Se richiesto carico finestra per VeinMatching e ultimo intarsio
|
|
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.MAN_PHOTO) And
|
|
GetPrivateProfileInt(S_VEINMATCHING, K_VEINMA_ENABLE, 0, m_MainWindow.GetIniFile()) <> 0 And
|
|
IsNothing(m_VeinMatchingWnd) Then
|
|
' Finestra
|
|
m_VeinMatchingWnd = New VeinMatchingWindow
|
|
m_VeinMatchingWnd.Owner = m_MainWindow
|
|
m_VeinMatchingWnd.Show()
|
|
m_VeinMatchingWnd.Hide()
|
|
VeinMatching.m_nVeinCtx = GetVeinMatchingContext()
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
m_VeinMatchingWnd.AdjustPosition()
|
|
' Ultimo intarsio
|
|
VeinMatching.Open(m_MainWindow.GetVeinMatchingDir() & "\Inlay.vme")
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub NewBtn_Click(sender As Object, e As RoutedEventArgs) Handles NewBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False
|
|
' Se progetto modificato, chiedo se salvarlo
|
|
If EgtGetModified() Then
|
|
Dim SaveCurrProj As New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 1), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL)
|
|
Select Case SaveCurrProj.m_nPressedBtn
|
|
Case 0 ' Annulla
|
|
Return
|
|
Case 1 ' Si
|
|
m_CurrProjPage.SaveNamedProject()
|
|
m_CurrProjPage.SaveProject()
|
|
Case 2 ' No
|
|
' Non devo fare alcunchè
|
|
End Select
|
|
End If
|
|
' Gestione stato FastGrid
|
|
m_MainWindow.m_CadCutPageUC.m_FastGridSlabManager.OnPreNewProject()
|
|
' Cancello progetto salvato con nome da file ini
|
|
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, "", m_MainWindow.GetIniFile())
|
|
' Se ci sono pezzi in parcheggio, chiedo se conservarli
|
|
Dim bRetainParkedParts As Boolean = False
|
|
If EgtGetFirstPart() <> GDB_ID.NULL Then
|
|
' Conservare i pezzi in parcheggio ?
|
|
Dim RetainParkedParts As New EgtMsgBox(m_MainWindow, "", EgtMsg(91118), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL)
|
|
Select Case RetainParkedParts.m_nPressedBtn
|
|
Case 0 ' Annulla
|
|
Return
|
|
Case 1 ' Si
|
|
bRetainParkedParts = True
|
|
Case 2 ' No
|
|
' Non devo fare alcunchè
|
|
End Select
|
|
End If
|
|
' Scelta tavola della macchina
|
|
Dim nTabInd As Integer = ChooseTable()
|
|
' Creo nuovo progetto
|
|
m_CurrProjPage.NewProject(nTabInd, bRetainParkedParts)
|
|
' Gestione stato FastGrid
|
|
m_MainWindow.m_CadCutPageUC.m_FastGridSlabManager.OnPostNewProject()
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Friend Function ChooseTable() As Integer
|
|
Dim nTabInd As Integer = 0
|
|
Select Case GetTableCount()
|
|
Case 3
|
|
' Tavolo da usare ?
|
|
Dim TableToUse As New EgtMsgBox(m_MainWindow, "", EgtMsg(91111), EgtMsgBox.Buttons.ONE_TWO_THREE, EgtMsgBox.Icons.NULL)
|
|
Select Case TableToUse.m_nPressedBtn
|
|
Case 1 ' 1
|
|
nTabInd = 1
|
|
Case 2 ' 2
|
|
nTabInd = 2
|
|
Case 0 ' 3
|
|
nTabInd = 3
|
|
End Select
|
|
Case 2
|
|
' Tavolo da usare ?
|
|
Dim TableToUse As New EgtMsgBox(m_MainWindow, "", EgtMsg(91111), EgtMsgBox.Buttons.ONE_TWO, EgtMsgBox.Icons.NULL)
|
|
Select Case TableToUse.m_nPressedBtn
|
|
Case 1 ' 1
|
|
nTabInd = 1
|
|
Case 0 ' 2
|
|
nTabInd = 2
|
|
End Select
|
|
Case Else
|
|
nTabInd = 1
|
|
End Select
|
|
Return nTabInd
|
|
End Function
|
|
|
|
Private Sub LoadBtn_Click(sender As Object, e As RoutedEventArgs) Handles LoadBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False
|
|
' Cancello eventuali messaggi
|
|
m_CurrProjPage.ClearMessage()
|
|
' Se progetto modificato, chiedo se salvarlo
|
|
If EgtGetModified() Then
|
|
Dim SaveCurrProj As New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 1), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL)
|
|
Select Case SaveCurrProj.m_nPressedBtn
|
|
Case 0 ' Annulla
|
|
Return
|
|
Case 1 ' Si
|
|
m_CurrProjPage.SaveNamedProject()
|
|
m_CurrProjPage.SaveProject()
|
|
Case 2 ' No
|
|
' Non devo fare alcunchè
|
|
End Select
|
|
End If
|
|
' Imposto la pagina attualmente attiva come Previous
|
|
m_MainWindow.m_PrevActivePage = m_MainWindow.m_ActivePage
|
|
' Passo alla pagina di apertura con preview
|
|
m_MainWindow.MainWindowGrid.Children.Remove(m_MainWindow.m_CurrentProjectPageUC)
|
|
m_MainWindow.MainWindowGrid.Children.Add(m_MainWindow.m_OpenPage)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.Open
|
|
End Sub
|
|
|
|
Friend Sub PostLoad(ByVal sCurrDir As String, sCurrFile As String)
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
If Not m_CurrProjPage.LoadProject(sCurrDir & "\" & sCurrFile) Then
|
|
m_CurrProjPage.NewProject()
|
|
Else
|
|
' Verifico se file salvato con nome guardando il nome della cartella in cui si trova
|
|
Dim sSaveNameDir As String = String.Empty
|
|
GetPrivateProfileString(S_GENERAL, K_SAVENAMEDIR, "", sSaveNameDir, m_MainWindow.GetIniFile())
|
|
If sCurrDir = sSaveNameDir Then
|
|
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, sCurrFile.Substring(0, sCurrFile.Length - 4), m_MainWindow.GetIniFile())
|
|
' Salvo equivalente con indice
|
|
m_CurrProjPage.SetNextProjectIndex()
|
|
m_CurrProjPage.SaveProject()
|
|
Else
|
|
WritePrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, String.Empty, m_MainWindow.GetIniFile())
|
|
End If
|
|
' Salvo path di carico del progetto
|
|
If sCurrDir <> m_MainWindow.GetSaveDir() And sCurrDir <> sSaveNameDir Then
|
|
m_CurrProjPage.SetLoadPath(sCurrDir & "\" & sCurrFile)
|
|
End If
|
|
End If
|
|
' Verifico se andare nel CadCut o nel FrameCut
|
|
Dim nPrjType As Integer = m_CurrProjPage.GetCurrentProjectType()
|
|
If nPrjType = CurrentProjectPageUC.PRJ_TYPE.FLATS And
|
|
m_MainWindow.m_PrevActivePage <> MainWindow.Pages.CadCut Then
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_FrameCutPageUC)
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_CadCutPageUC)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.CadCut
|
|
m_MainWindow.FrameCutBtn.IsChecked = False
|
|
m_MainWindow.CadCutBtn.IsChecked = True
|
|
ElseIf nPrjType = CurrentProjectPageUC.PRJ_TYPE.FRAMES And
|
|
m_MainWindow.m_PrevActivePage <> MainWindow.Pages.FrameCut Then
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC)
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_FrameCutPageUC)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.FrameCut
|
|
m_MainWindow.CadCutBtn.IsChecked = False
|
|
m_MainWindow.FrameCutBtn.IsChecked = True
|
|
Else
|
|
m_MainWindow.m_ActivePage = m_MainWindow.m_PrevActivePage
|
|
End If
|
|
EgtZoom(ZM.ALL)
|
|
End Sub
|
|
|
|
Private Sub SaveBtn_Click(sender As Object, e As RoutedEventArgs) Handles SaveBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' Salvataggio con nome (solo se nome definito)
|
|
m_CurrProjPage.SaveNamedProject()
|
|
' Salvataggio con numero ciclico
|
|
m_CurrProjPage.SaveProject()
|
|
' Se cornici, ripristino visualizzazione lavorazioni
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.FrameCut Then
|
|
ShowAllCurrPhaseMachinings()
|
|
End If
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub SaveNameBtn_Click(sender As Object, e As RoutedEventArgs) Handles SaveNameBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
Dim MySaveNameWD As New SaveNameWD(m_MainWindow)
|
|
MySaveNameWD.ShowDialog()
|
|
End Sub
|
|
|
|
Private Sub CSVBtn_Click(sender As Object, e As RoutedEventArgs) Handles CSVBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC.m_NestPage)
|
|
m_MainWindow.m_CadCutPageUC.CadCutPageGrid.Children.Add(m_MainWindow.m_CadCutPageUC.m_CSVPage)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.CSV
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.CadCut
|
|
End Sub
|
|
|
|
Private Sub ResetCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles ResetCutBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' Cancello eventuali messaggi
|
|
m_CurrProjPage.ClearMessage()
|
|
' Ricalcolo tutte le lavorazioni
|
|
Dim nWarn As Integer = 0
|
|
ResetAllMachinings(nWarn)
|
|
If nWarn = 1 Then m_CurrProjPage.SetWarningMessage(EgtMsg(MSG_SPLITPAGEUC + 11)) ' Lama troppo grande per utilizzo ventosa
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub SimulateBtn_Click(sender As Object, e As RoutedEventArgs) Handles SimulateBtn.Click
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False
|
|
m_CurrProjPage.CurrProjGrid.Visibility = Windows.Visibility.Hidden
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.CadCut Then
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_CadCutPageUC)
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.CadCut
|
|
Else
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Remove(m_MainWindow.m_FrameCutPageUC)
|
|
m_MainWindow.m_PrevActivePage = MainWindow.Pages.FrameCut
|
|
End If
|
|
m_CurrProjPage.CurrentProjectPageGrid.Children.Add(m_MainWindow.m_SimulationPage)
|
|
m_MainWindow.m_ActivePage = MainWindow.Pages.Simulation
|
|
End Sub
|
|
|
|
Private Sub WorkBtn_Click(sender As Object, e As RoutedEventArgs) Handles WorkBtn.Click
|
|
#If TRIAL Then
|
|
m_CurrProjPage.SetWarningMessage("Trial Version")
|
|
#Else
|
|
Dim bOk As Boolean = True
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' Verifico l'attrezzaggio degli utensili utilizzati
|
|
Dim sMissingTools As String = String.Empty
|
|
If Not VerifySetup(sMissingTools) Then
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(90322) & " " & sMissingTools) 'Mancano gli utensili : ...
|
|
Return
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Aggiorno flag per lavaggio
|
|
m_CurrProjPage.UpdateWashingFlag()
|
|
' Aggiorno flag per tastatura per tagli con angolo di fianco
|
|
m_CurrProjPage.UpdateSideAngCutProbeFlag()
|
|
' Se pezzi piani e non c'è ordine delle lavorazioni, ricalcolo tutto e ne faccio uno automatico
|
|
Dim nPrjType As Integer = m_CurrProjPage.GetCurrentProjectType()
|
|
Dim bDirectCut As Boolean = (GetDirectCutPart() <> GDB_ID.NULL)
|
|
If nPrjType = CurrentProjectPageUC.PRJ_TYPE.FLATS And
|
|
Not bDirectCut And
|
|
Not m_CurrProjPage.GetOrderMachiningFlag() Then
|
|
If m_MainWindow.m_CurrentMachine.WaterJettingActive Then
|
|
ResetAllMachinings()
|
|
Else
|
|
RemoveFinalEmptyPhases()
|
|
End If
|
|
bOk = SortAllMachinings()
|
|
If bOk Then
|
|
m_CurrProjPage.SetOrderMachiningFlag()
|
|
Dim bModif As Boolean = TestAllMachiningsForStrict()
|
|
If bModif Then
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90321)) 'Ridotte alcune lavorazioni per evitare interferenze
|
|
EgtDraw()
|
|
End If
|
|
End If
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Disabilito impostazione modificato
|
|
EgtDisableModified()
|
|
' Aggiorno le lavorazioni
|
|
bOk = UpdateAllMachiningsToolpaths() And bOk
|
|
' Aggiorno posizionamento ventose sui pezzi per eventuali tagli da sotto con lama
|
|
bOk = UpdateVacuumsForDrip() And bOk
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Inserisco indice di progetto
|
|
m_CurrProjPage.SetProjectIndexFlag()
|
|
' Inserisco il materiale
|
|
m_CurrProjPage.SetProjectMaterial()
|
|
' Salvo il progetto con le lavorazioni
|
|
Dim sMchPath As String = m_MainWindow.GetTempDir() & "\MachProj.nge"
|
|
m_CurrProjPage.SaveFile(sMchPath)
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Se presente ripartenza, ne chiedo conferma
|
|
Dim nPhaseRestart As Integer = m_CurrProjPage.GetProjectNcRestart()
|
|
If nPhaseRestart <> 0 Then
|
|
' Confermi ripartenza dalla fase NNN ?
|
|
Dim AskNcRestart As New EgtMsgBox(m_MainWindow, "", String.Format(EgtMsg(90326), nPhaseRestart),
|
|
EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL, 2)
|
|
Select Case AskNcRestart.m_nPressedBtn
|
|
Case 1 ' YES
|
|
Case 2 ' NO
|
|
EgtEnableModified()
|
|
m_CurrProjPage.ResetProjectNcRestart()
|
|
EgtDisableModified()
|
|
Case Else ' CANCEL
|
|
Return
|
|
End Select
|
|
End If
|
|
' Genero file CNC (lancio anche se errore in precedenza)
|
|
Dim sCncPath As String = m_MainWindow.GetCncDir() & "\CadCut" & m_CurrMachine.sIsoFileExt
|
|
bOk = EgtGenerate(sCncPath, "OmagCut ver." & m_MainWindow.GetVersion()) And bOk
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Ripristino come fase corrente quella iniziale
|
|
EgtSetCurrPhase(1)
|
|
' Se nesting di pezzi piani, nascondo tutte le lavorazioni
|
|
If m_MainWindow.m_ActivePage = MainWindow.Pages.CadCut Then
|
|
HideAllMachinings()
|
|
Else
|
|
ShowAllCurrPhaseMachinings()
|
|
End If
|
|
' Abilito impostazione modificato
|
|
EgtEnableModified()
|
|
' Se errore in generazione, segnalo l'errore ed esco
|
|
If Not bOk Then
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(90314)) 'Errore nella generazione del programma CN
|
|
Return
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Se macchina normale
|
|
If Not m_CurrMachine.bProdLine Then
|
|
' Download programma (eventuali errori sono segnalati dalla funzione)
|
|
If m_CurrNcComm.SendProgram(sCncPath, 900) Then
|
|
' copio il progetto corrente come progetto in lavorazione
|
|
Dim sWrkPath As String = m_MainWindow.GetTempDir() & "\" & "WorkProj.nge"
|
|
My.Computer.FileSystem.CopyFile(sMchPath, sWrkPath, True)
|
|
' lancio eventuale lua post-trasmissione
|
|
ExecSentProgScript()
|
|
End If
|
|
' Altrimenti linea di produzione
|
|
Else
|
|
' Se non collegato alla macchina
|
|
If Not m_MainWindow.m_bNCLink Then
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90316)) 'Non connesso alla macchina
|
|
' copio il progetto corrente come progetto in lavorazione
|
|
Dim sWrkPath As String = m_MainWindow.GetTempDir() & "\" & "WorkProj.nge"
|
|
My.Computer.FileSystem.CopyFile(sMchPath, sWrkPath, True)
|
|
' Dichiaro part program inviato
|
|
m_CurrProjPage.SetProjectNcProgSent(1)
|
|
' Salvo il progetto
|
|
m_CurrProjPage.SaveProject()
|
|
' lancio eventuale lua post-trasmissione
|
|
ExecSentProgScript()
|
|
Return
|
|
End If
|
|
' Verifico non sia già stato trasmesso
|
|
If m_CurrProjPage.GetProjectNcProgSent() <> 0 Then
|
|
' Programma già trasmesso, vuoi ritrasmetterlo ?
|
|
Dim AskTransm As New EgtMsgBox(m_MainWindow, "", EgtMsg(90319),
|
|
EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL, 2)
|
|
If AskTransm.m_nPressedBtn <> 1 Then Return
|
|
End If
|
|
' Leggo variabile relativa al programma 1 (standard E80021)
|
|
m_CurrNcComm.m_CN.n_DReadELS_handle = 0
|
|
m_CurrNcComm.m_CN.ReadEls_Add_Parameter(m_CurrMachine.sVarProg1, 1)
|
|
Dim nVarProg1 As Integer = 99
|
|
For I = 0 To 10
|
|
System.Threading.Thread.Sleep(50)
|
|
If m_CurrNcComm.m_CN.n_DReadELS_handle = 1 Then
|
|
nVarProg1 = CInt(m_CurrNcComm.m_CN.d_DReadELS_value)
|
|
Exit For
|
|
End If
|
|
Next
|
|
' Leggo variabile relativa al programma 2 (standard E80022)
|
|
m_CurrNcComm.m_CN.n_DReadELS_handle = 0
|
|
m_CurrNcComm.m_CN.ReadEls_Add_Parameter(m_CurrMachine.sVarProg2, 1)
|
|
Dim nVarProg2 As Integer = 99
|
|
For I = 0 To 10
|
|
System.Threading.Thread.Sleep(50)
|
|
If m_CurrNcComm.m_CN.n_DReadELS_handle = 1 Then
|
|
nVarProg2 = CInt(m_CurrNcComm.m_CN.d_DReadELS_value)
|
|
Exit For
|
|
End If
|
|
Next
|
|
' Leggo eventuale variabile per lavorazione con 2 tavole in parallelo (standard E80027)
|
|
Dim nVarProgTwins As Integer = 1
|
|
If Not String.IsNullOrWhiteSpace(m_CurrMachine.sVarProgTwins) Then
|
|
m_CurrNcComm.m_CN.n_DReadELS_handle = 0
|
|
m_CurrNcComm.m_CN.ReadEls_Add_Parameter(m_CurrMachine.sVarProgTwins, 1)
|
|
For I = 0 To 10
|
|
System.Threading.Thread.Sleep(50)
|
|
If m_CurrNcComm.m_CN.n_DReadELS_handle = 1 Then
|
|
nVarProgTwins = CInt(m_CurrNcComm.m_CN.d_DReadELS_value)
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
' Verifico se posso scrivere nell'area 1
|
|
If nVarProg1 = 0 And (nVarProg2 <> 1 Or nVarProgTwins = 2) Then
|
|
m_CurrNcComm.SetProgramMainOrSub(False)
|
|
If m_CurrNcComm.SendProgram(sCncPath, m_CurrMachine.nProg1, False) Then
|
|
' Dichiaro part program inviato
|
|
m_CurrProjPage.SetProjectNcProgSent(1)
|
|
' Copio il progetto corrente come progetto in lavorazione
|
|
Dim sWrkPath As String = m_MainWindow.GetTempDir() & "\" & "WorkProj1.nge"
|
|
My.Computer.FileSystem.CopyFile(sMchPath, sWrkPath, True)
|
|
' Salvo il progetto
|
|
m_CurrProjPage.SaveProject()
|
|
' Dichiaro programma inviato
|
|
m_CurrNcComm.m_CN.DVariables_WriteVariables2(m_CurrMachine.sVarProg1, "1")
|
|
' lancio eventuale lua post-trasmissione
|
|
ExecSentProgScript()
|
|
End If
|
|
m_CurrNcComm.SetProgramMainOrSub(True)
|
|
' Altrimenti verifico se posso scrivere nell'area 2
|
|
ElseIf nVarProg2 = 0 And (nVarProg1 <> 1 Or nVarProgTwins = 2) Then
|
|
m_CurrNcComm.SetProgramMainOrSub(False)
|
|
If m_CurrNcComm.SendProgram(sCncPath, m_CurrMachine.nProg2, False) Then
|
|
' Dichiaro part program inviato
|
|
m_CurrProjPage.SetProjectNcProgSent(2)
|
|
' Copio il progetto corrente come progetto in lavorazione
|
|
Dim sWrkPath As String = m_MainWindow.GetTempDir() & "\" & "WorkProj2.nge"
|
|
My.Computer.FileSystem.CopyFile(sMchPath, sWrkPath, True)
|
|
' Salvo il progetto
|
|
m_CurrProjPage.SaveProject()
|
|
' Dichiaro programma inviato
|
|
m_CurrNcComm.m_CN.DVariables_WriteVariables2(m_CurrMachine.sVarProg2, "1")
|
|
' lancio eventuale lua post-trasmissione
|
|
ExecSentProgScript()
|
|
End If
|
|
m_CurrNcComm.SetProgramMainOrSub(True)
|
|
' Altrimenti aree di memoria non disponibili
|
|
Else
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(90318)) 'La macchina non accetta il programma CN
|
|
End If
|
|
End If
|
|
#End If
|
|
End Sub
|
|
|
|
Private Sub VeinMatchingBtn_Click(sender As Object, e As RoutedEventArgs) Handles VeinMatchingBtn.Click
|
|
If VeinMatchingBtn.IsChecked Then
|
|
VeinMatchingShow()
|
|
Else
|
|
VeinMatchingHide()
|
|
End If
|
|
End Sub
|
|
|
|
Friend Function GetVeinMatchingContext() As Integer
|
|
If IsNothing(m_VeinMatchingWnd) Then Return 0
|
|
Return m_VeinMatchingWnd.VeinMatchingScene.GetCtx()
|
|
End Function
|
|
|
|
Friend Sub VeinMatchingShow()
|
|
' Se non già creata, non devo fare alcunchè
|
|
If IsNothing(m_VeinMatchingWnd) Then Return
|
|
' Esecuzione
|
|
m_VeinMatchingWnd.Show()
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
VeinMatchingBtn.IsChecked = True
|
|
End Sub
|
|
|
|
Friend Sub VeinMatchingHide()
|
|
' Se non già creata, non devo fare alcunchè
|
|
If IsNothing(m_VeinMatchingWnd) Then Return
|
|
' Esecuzione
|
|
m_VeinMatchingWnd.Hide()
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
VeinMatchingBtn.IsChecked = False
|
|
End Sub
|
|
|
|
Private Sub RegisterBtn_Checked(sender As Object, e As RoutedEventArgs) Handles RegisterBtn.Checked
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False
|
|
' Nascondo bottoni ProjectMgrUC
|
|
NewBtn.Visibility = Windows.Visibility.Hidden
|
|
LoadBtn.Visibility = Windows.Visibility.Hidden
|
|
SaveBtn.Visibility = Windows.Visibility.Hidden
|
|
SaveNameBtn.Visibility = Windows.Visibility.Hidden
|
|
CSVBtn.Visibility = Windows.Visibility.Hidden
|
|
VeinMatchingBtn.Visibility = Windows.Visibility.Hidden
|
|
ResetCutBtn.Visibility = Windows.Visibility.Hidden
|
|
SimulateBtn.Visibility = Windows.Visibility.Hidden
|
|
WorkBtn.Visibility = Windows.Visibility.Hidden
|
|
' Nascondo bottoni CadCutPageUC
|
|
m_MainWindow.m_CadCutPageUC.PhotoBtn.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_CadCutPageUC.RawPartBtn.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_CadCutPageUC.DrawBtn.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_CadCutPageUC.ImportBtn.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_CadCutPageUC.SplitBtn.Visibility = Windows.Visibility.Hidden
|
|
' Nascondo bottoni nesting
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.m_bRegister = True
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.MaximizeMoveBtn.IsEnabled = False
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.MagneticPiecesBtn.IsEnabled = False
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.InsertPartBtn.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.StorePartBtn.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.RemovePartBtn.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.SelectAllBtn.Visibility = Windows.Visibility.Hidden
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.DeselectAllBtn.Visibility = Windows.Visibility.Hidden
|
|
' Deseleziono tutto
|
|
EgtDeselectAll()
|
|
' Se c'è la foto devo sistemare
|
|
If m_CurrProjPage.GetPhoto() <> GDB_ID.NULL Then
|
|
' Salvo il riferimento della texture originale di ogni grezzo
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
Dim nSolidId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_RAW_SOLID)
|
|
' Recupero il riferimento originale e lo salvo nelle info
|
|
Dim refTxr As New Frame3d
|
|
EgtGetTextureFrame(nSolidId, GDB_ID.ROOT, refTxr)
|
|
EgtSetInfo(nSolidId, "OriTxrRef", refTxr)
|
|
' Passo al successivo
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
' Modifiche sull'unico grezzo della prima fase
|
|
Dim nSolId = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, NAME_RAW_SOLID)
|
|
' Disabilito la texture sul grezzo
|
|
EgtRemoveTextureData(nSolId)
|
|
' Sistemo il colore
|
|
Dim Col As Color3d
|
|
EgtGetCalcColor(nSolId, Col)
|
|
Col.A = 20
|
|
EgtSetColor(nSolId, Col, True)
|
|
' Visualizzo la foto
|
|
m_MainWindow.m_CurrentProjectPageUC.ShowPhoto(True)
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End If
|
|
' Visualizzo step adatti alla scelta fatta
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.UpdateStepsOnUI()
|
|
' Cancello eventuali messaggi di errore/avvertimento
|
|
m_CurrProjPage.ClearMessage()
|
|
End Sub
|
|
|
|
Private Sub RegisterBtn_Unchecked(sender As Object, e As RoutedEventArgs) Handles RegisterBtn.Unchecked
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
m_CurrProjPage.m_SceneButtons.MeasureBtn.IsChecked = False
|
|
' Visualizzo bottoni ProjectMgrUC
|
|
NewBtn.Visibility = Windows.Visibility.Visible
|
|
LoadBtn.Visibility = Windows.Visibility.Visible
|
|
SaveBtn.Visibility = Windows.Visibility.Visible
|
|
SaveNameBtn.Visibility = Windows.Visibility.Visible
|
|
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.AUTO_NESTING) Or
|
|
m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.CSV_SIMPLE) Then
|
|
CSVBtn.Visibility = Windows.Visibility.Visible
|
|
End If
|
|
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.MAN_PHOTO) And
|
|
GetPrivateProfileInt(S_VEINMATCHING, K_VEINMA_ENABLE, 0, m_MainWindow.GetIniFile()) <> 0 Then
|
|
VeinMatchingBtn.Visibility = Windows.Visibility.Visible
|
|
End If
|
|
ResetCutBtn.Visibility = Windows.Visibility.Visible
|
|
SimulateBtn.Visibility = Windows.Visibility.Visible
|
|
WorkBtn.Visibility = Windows.Visibility.Visible
|
|
' Visualizzo bottoni CadCutPageUC
|
|
m_MainWindow.m_CadCutPageUC.PhotoBtn.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_CadCutPageUC.RawPartBtn.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_CadCutPageUC.DrawBtn.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_CadCutPageUC.ImportBtn.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_CadCutPageUC.SplitBtn.Visibility = Windows.Visibility.Visible
|
|
' Visualizzo bottoni nesting
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.m_bRegister = False
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.MaximizeMoveBtn.IsEnabled = True
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.MagneticPiecesBtn.IsEnabled = True
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.InsertPartBtn.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.StorePartBtn.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.RemovePartBtn.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.SelectAllBtn.Visibility = Windows.Visibility.Visible
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.DeselectAllBtn.Visibility = Windows.Visibility.Visible
|
|
' Se c'è la foto devo sistemare
|
|
If m_CurrProjPage.GetPhoto() <> GDB_ID.NULL Then
|
|
' Recupero il riferimento originale del primo grezzo
|
|
Dim nSolId = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, NAME_RAW_SOLID)
|
|
Dim refOri1Txr As New Frame3d
|
|
EgtGetInfo(nSolId, "OriTxrRef", refOri1Txr)
|
|
' Recupero il nome della texture dalla foto
|
|
Dim sTxrName As String = String.Empty
|
|
EgtGetTextureName(m_CurrProjPage.GetPhoto(), sTxrName)
|
|
' Recupero il riferimento della texture dalla foto
|
|
Dim refPhTxr As New Frame3d
|
|
m_CurrProjPage.GetPhotoTextureRef(refPhTxr)
|
|
' Inserisco la texture su tutti i grezzi
|
|
Dim nRawId As Integer = EgtGetFirstRawPart()
|
|
While nRawId <> GDB_ID.NULL
|
|
Dim nSolidId = EgtGetFirstNameInGroup(nRawId, NAME_RAW_SOLID)
|
|
' Recupero il riferimento della texture originale
|
|
Dim refOriTxr As New Frame3d
|
|
EgtGetInfo(nSolidId, "OriTxrRef", refOriTxr)
|
|
Dim vtMove As Vector3d = refOriTxr.Orig() - refOri1Txr.Orig()
|
|
' Carico la texture della foto sul grezzo
|
|
EgtSetTextureName(nSolidId, sTxrName)
|
|
' Carico il nuovo riferimento della texture della foto sul grezzo
|
|
Dim refTxr As New Frame3d(refPhTxr)
|
|
refTxr.Move(vtMove)
|
|
EgtSetTextureFrame(nSolidId, refTxr, GDB_RT.GLOB)
|
|
' Passo al successivo
|
|
nRawId = EgtGetNextRawPart(nRawId)
|
|
End While
|
|
' Modifiche sull'unico grezzo della prima fase
|
|
' Sistemo il colore
|
|
Dim colWhite As New Color3d(255, 255, 255, 100)
|
|
EgtSetColor(nSolId, colWhite)
|
|
' Anche per il contorno
|
|
Dim nOutlineId = EgtGetFirstNameInGroup(m_CurrProjPage.m_nRawId, NAME_RAW_OUTLINE)
|
|
EgtSetColor(nOutlineId, colWhite)
|
|
EgtSetStatus(nOutlineId, GDB_ST.OFF)
|
|
' Nascondo la foto
|
|
m_MainWindow.m_CurrentProjectPageUC.ShowPhoto(False)
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End If
|
|
' Visualizzo step adatti alla scelta fatta
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.UpdateStepsOnUI()
|
|
' Cancello eventuali messaggi di errore/avvertimento
|
|
m_CurrProjPage.ClearMessage()
|
|
End Sub
|
|
|
|
Private Function ExecSentProgScript() As Boolean
|
|
' Verifico esistenza script
|
|
Dim sLuaPath As String = m_MainWindow.m_CurrentMachine.sMachDir() & "\Scripts\SentProg.lua"
|
|
If Not My.Computer.FileSystem.FileExists(sLuaPath) Then Return True
|
|
' Definizione variabili
|
|
EgtLuaCreateGlobTable("SPS")
|
|
EgtLuaSetGlobBoolVar("SPS.NCLINK", m_MainWindow.m_bNCLink)
|
|
EgtLuaSetGlobBoolVar("SPS.PRODLINE", m_CurrMachine.bProdLine)
|
|
' Esecuzione
|
|
Dim nErr As Integer = 999
|
|
If EgtLuaExecFile(sLuaPath) AndAlso
|
|
EgtLuaCallFunction("SPS.Exec") Then
|
|
' Verifica stato di errore
|
|
EgtLuaGetGlobIntVar("SPS.ERR", nErr)
|
|
End If
|
|
EgtLuaResetGlobVar("SPS")
|
|
If nErr <> 0 Then
|
|
EgtOutLog("Error in SentProg : " & nErr.ToString())
|
|
m_CurrProjPage.SetErrorMessage(EgtMsg(90325)) 'Errore nel salvataggio delle statistiche
|
|
End If
|
|
Return (nErr = 0)
|
|
End Function
|
|
|
|
End Class
|