ab283a3efa
- correzioni al polishing (oar si notifica che è un taglio diretto e si controlla meglio l'utensile) - varie migliorie nei tagli diretti.
1581 lines
73 KiB
VB.net
1581 lines
73 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib
|
|
|
|
Public Class ProjectMgrUC
|
|
' Creo una varibile statica per verificare di non stampare due volte lo stesso messaggio
|
|
Public Shared bFirstRun As Boolean = True
|
|
|
|
' 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
|
|
' usato per scrivere i comadi di movimento test lavorazione
|
|
Friend m_CN As CN_generico
|
|
|
|
' L'inizializzazine avviene 2 volte: una per i tagli CAD ed una per le cornici
|
|
Private Sub ProjectMgrUC_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
|
' Imposto i messaggi letti dal file dei messaggi
|
|
NewBtn.ToolTip = EgtMsg(90303) ' Nuovo
|
|
LoadBtn.ToolTip = EgtMsg(90304) ' Carica
|
|
SaveBtn.ToolTip = EgtMsg(90305) ' Salva
|
|
SaveNameBtn.ToolTip = EgtMsg(90306) ' Salva come
|
|
CSVBtn.ToolTip = EgtMsg(90308) ' CSV
|
|
VeinMatchingBtn.ToolTip = EgtMsg(90309) ' Vein Match
|
|
|
|
RegisterBtn.Content = "REG" ' Shape Registration
|
|
|
|
'ResetCutBtn.Content = EgtMsg(90336) ' Reset
|
|
'ResetCut2Btn.Content = EgtMsg(91024) ' Reset lavorazioni
|
|
'ResetCut1Btn.Content = EgtMsg(91025) ' Aggiorna feed/speed
|
|
PopulateListCmdReset()
|
|
|
|
SimulateBtn.ToolTip = EgtMsg(90301) ' Simulate - Simula
|
|
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.OFFICE_TYPE) Then
|
|
WorkBtn.ToolTip = EgtMsg(90310) ' Export - Esporta
|
|
Else
|
|
WorkBtn.ToolTip = EgtMsg(90302) ' Work - Lavora
|
|
End If
|
|
TestBtn.ToolTip = EgtMsg(90255) ' Test
|
|
ResetCutBtn.ToolTip = EgtMsg(91241) & vbCrLf & EgtMsg(91242) ' Reset Cuts - Other Reset (Shift)
|
|
End Sub
|
|
|
|
Private Sub ProjectMgrUC_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
' Impostazioni
|
|
SetReference()
|
|
|
|
' 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
|
|
|
|
Public Sub SetReference()
|
|
m_CurrProjPage = m_MainWindow.m_CurrentProjectPageUC
|
|
m_CurrMachine = m_MainWindow.m_CurrentMachine
|
|
m_CurrNcComm = m_MainWindow.m_CNCommunication
|
|
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(91101), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL) ' Salvare il progetto corrente?
|
|
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) ' Conservo i pezzi in parcheggio ?
|
|
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 una copia di tutte le immagini usata nella lista dei parcheggi
|
|
Dim ListParkInd As New List(Of ParkInd)
|
|
SelParkIndWD.LoadParkInd(ListParkInd)
|
|
' Creo nuovo progetto
|
|
m_CurrProjPage.NewProject(nTabInd, bRetainParkedParts)
|
|
|
|
|
|
' Gestione visulizzazione lista pezzi in parcheggio
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.ReloadListParkInd()
|
|
Dim sNewFileName As String = SelParkIndWD.GetPathCurrProj()
|
|
SelParkIndWD.CopyImgSvg(sNewFileName)
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.ReloadListParkInd()
|
|
|
|
|
|
' Gestione stato FastGrid
|
|
m_MainWindow.m_CadCutPageUC.m_FastGridSlabManager.OnPostNewProject()
|
|
End Sub
|
|
|
|
Friend Function ChooseTable() As Integer
|
|
Dim nTabInd As Integer = 0
|
|
Select Case GetTableCount()
|
|
Case 4, 3, 2
|
|
Dim SelTabWD As New SelectTableWD(m_MainWindow)
|
|
SelTabWD.ShowDialog()
|
|
nTabInd = SelTabWD.nSelectedTable
|
|
SelTabWD.Close()
|
|
Case Else
|
|
nTabInd = 1
|
|
End Select
|
|
Return nTabInd
|
|
End Function
|
|
|
|
Friend Function ChangeTable() As Integer
|
|
Dim nRes As Integer = 0
|
|
' se non abilitato esco dalla pagina
|
|
If GetPrivateProfileInt(S_TABLE, K_CHANGETABWD, 0, m_MainWindow.GetMachIniFile()) = 0 Then
|
|
Return nRes
|
|
End If
|
|
Dim nCountTable As Integer = GetTableCount()
|
|
Select Case nCountTable
|
|
Case 4, 3, 2
|
|
' visualizzo l'elenco dei bottoni associati alle tavole disponibili
|
|
Dim SelTabWD As New SelectTableWD(m_MainWindow)
|
|
SelTabWD.ShowDialog()
|
|
If SelTabWD.DialogResult Then
|
|
nRes = SelTabWD.nSelectedTable
|
|
End If
|
|
SelTabWD.Close()
|
|
Case Else
|
|
' non fare nulla
|
|
End Select
|
|
Return nRes
|
|
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(91101), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL) ' Salvare il progetto corrente?
|
|
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()
|
|
m_CurrProjPage.m_MruFiles.Remove(sCurrDir & "\" & sCurrFile)
|
|
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
|
|
m_CurrProjPage.m_MruFiles.Add(sCurrDir & "\" & sCurrFile)
|
|
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
|
|
|
|
'SelParkIndWD.UpdateViewOnParkInd(False)
|
|
|
|
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, SaveNameWD.SAVE_TYPE.PRJ_NAMED)
|
|
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
|
|
|
|
#Region "RESET"
|
|
|
|
Private Sub ResetCutBtn_Click(sender As Object, e As RoutedEventArgs) Handles ResetCutBtn.Click
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 Then
|
|
If ResetCutPopUp.IsOpen Then
|
|
ResetCutPopUp.IsOpen = False
|
|
Else
|
|
ResetCutPopUp.IsOpen = True
|
|
End If
|
|
Else
|
|
CallFunction(0)
|
|
End If
|
|
End Sub
|
|
|
|
' Reimposto le feed di tutte le lavorazioni
|
|
Private Sub ResetCut1Btn_Click(sender As Object, e As RoutedEventArgs) Handles ResetCut1Btn.Click
|
|
CallFunction(1)
|
|
End Sub
|
|
|
|
' Reimposto le lavorazioni di default e ripristino i parametri
|
|
Private Sub ResetCut2Btn_Click(sender As Object, e As RoutedEventArgs) Handles ResetCut2Btn.Click
|
|
CallFunction(2)
|
|
End Sub
|
|
|
|
' Reimposto le feed di tutte le lavorazioni
|
|
Private Sub FeedReset()
|
|
' eseguo il ricalcolo delle sole FEED di lavorazione
|
|
UpdateFeedAllMachining()
|
|
End Sub
|
|
|
|
' Reimposto le lavorazioni di default e ripristino i parametri
|
|
Private Sub HardReset()
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' Cancello eventuali messaggi
|
|
m_CurrProjPage.ClearMessage()
|
|
' cancello tutti i tagli di separazione (Waterjet)
|
|
ResetAllSplitCurv()
|
|
' cancello tutti i punti di inizio (Waterjet)
|
|
ResetAllStartCurv()
|
|
' cancello tutti i ponticelli disegnati
|
|
ResetAllBridges()
|
|
' cancella tutti i tagli di separazione inseriti in OFFICE
|
|
ResetAllSplitCut()
|
|
|
|
' assegno la lavorazione corrente per i tagli di lama inclinati (solo se specificato nella ComboBox della ChooseMachinig)
|
|
RestoreDef_Machinig(True)
|
|
' assegno la lavorazione corrente per i tagli verticali
|
|
RestoreDef_Machinig(False)
|
|
|
|
' Ricalcolo tutte le lavorazioni
|
|
Dim nWarn As Integer = 0
|
|
ResetAllMachinings(nWarn)
|
|
If nWarn = 1 Then m_CurrProjPage.SetWarningMessage(EgtMsg(90351)) ' Lama troppo grande per utilizzo ventosa
|
|
' Se esistono elimino i grezzi delle fasi che non contengono lavorazioni
|
|
ResetAllRawPart()
|
|
' Aggiorno Info C Home
|
|
Dim dCHome As Double
|
|
EgtGetAxisHomePos("C", dCHome)
|
|
EgtSetInfo(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_PROJMARK), INFO_CAXESHOME, DoubleToString(dCHome, 0))
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
' Resetta i valori dei parametri (ma non le lavorazioni)
|
|
Private Sub StandardReset()
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' Cancello eventuali messaggi
|
|
m_CurrProjPage.ClearMessage()
|
|
' cancello tutti i tagli di separazione (Waterjet)
|
|
ResetAllSplitCurv()
|
|
' cancello tutti i punti di inizio (Waterjet)
|
|
ResetAllStartCurv()
|
|
' cancello tutti i ponticelli disegnati
|
|
ResetAllBridges()
|
|
' cancella tutti i tagli di separazione inseriti in OFFICE
|
|
ResetAllSplitCut()
|
|
' Ricalcolo tutte le lavorazioni
|
|
Dim nWarn As Integer = 0
|
|
ResetAllMachinings(nWarn)
|
|
If nWarn = 1 Then m_CurrProjPage.SetWarningMessage(EgtMsg(90351)) ' Lama troppo grande per utilizzo ventosa
|
|
' Se esistono elimino i grezzi delle fasi che non contengono lavorazioni
|
|
ResetAllRawPart()
|
|
' Aggiorno Info C Home
|
|
Dim dCHome As Double
|
|
EgtGetAxisHomePos("C", dCHome)
|
|
EgtSetInfo(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_PROJMARK), INFO_CAXESHOME, DoubleToString(dCHome, 0))
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Const HARD_RESET As String = "HARD"
|
|
Private Const STANDARD_RESET As String = "STANDARD"
|
|
Private Const FEED_RESET As String = "FEED"
|
|
|
|
Private Enum RESET_TYPE
|
|
HARD
|
|
STANDARD
|
|
FEED
|
|
End Enum
|
|
|
|
Private m_ListCmdReset As New List(Of RESET_TYPE) From {RESET_TYPE.HARD, RESET_TYPE.STANDARD, RESET_TYPE.FEED}
|
|
|
|
Private Sub CallFunction(IndexListCmdReset As Integer)
|
|
Select Case m_ListCmdReset(IndexListCmdReset)
|
|
Case RESET_TYPE.STANDARD
|
|
EgtOutLog("STNADRD Reset")
|
|
StandardReset()
|
|
Case RESET_TYPE.HARD
|
|
EgtOutLog("HARD Reset")
|
|
HardReset()
|
|
Case RESET_TYPE.FEED
|
|
EgtOutLog("FEED Reset")
|
|
FeedReset()
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub SetBtnResetContent(IndexListCmdReset As Integer, Btn As Button)
|
|
Select Case m_ListCmdReset(IndexListCmdReset)
|
|
Case RESET_TYPE.STANDARD
|
|
Btn.Content = EgtMsg(90336) ' Reset
|
|
Case RESET_TYPE.HARD
|
|
Btn.Content = EgtMsg(91024) ' Reset lavorazioni
|
|
Case RESET_TYPE.FEED
|
|
Btn.Content = EgtMsg(91025) ' Aggiorna feed/speed
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub PopulateListCmdReset()
|
|
Dim sConfig As String = "HARD,STANDARD,FEED"
|
|
GetPrivateProfileString(S_GENERAL, "ResetCmd", sConfig, sConfig, m_MainWindow.GetIniFile())
|
|
Dim sItems As String() = sConfig.Split(",")
|
|
' VERIFICA della lettura configurazione
|
|
If sItems.Count <> 3 Then
|
|
If bFirstRun Then
|
|
EgtOutLog("WARNING configurazione: in Config.ini del programma nella sezione 'General/ResetCmd' " &
|
|
"non trovato una sequenza del tipo 'HARD,STANDARD,FEED'")
|
|
End If
|
|
Else
|
|
Dim bOk As Boolean = True
|
|
Dim sErrMsg As String = String.Empty
|
|
' popolo una lista di appoggio
|
|
Dim TempList As New List(Of RESET_TYPE) From {RESET_TYPE.STANDARD, RESET_TYPE.STANDARD, RESET_TYPE.STANDARD}
|
|
For Index As Integer = 0 To sItems.Count - 1
|
|
If sItems(Index).Trim = STANDARD_RESET Then
|
|
TempList(Index) = RESET_TYPE.STANDARD
|
|
ElseIf sItems(Index).Trim = HARD_RESET Then
|
|
TempList(Index) = RESET_TYPE.HARD
|
|
ElseIf sItems(Index).Trim = FEED_RESET Then
|
|
TempList(Index) = RESET_TYPE.FEED
|
|
Else
|
|
bOk = False
|
|
sErrMsg = sErrMsg & If(String.IsNullOrEmpty(sErrMsg), "", ",") & sItems(Index).Trim
|
|
End If
|
|
Next
|
|
' verifico che non ci siano elementi ripetuti nella lista
|
|
If Not bOk Then
|
|
If bFirstRun Then
|
|
EgtOutLog("WARNING configurazione: in Config.ini del programma nella sezione 'General/ResetCmd' " &
|
|
"non trovato una sequenza del tipo 'HARD,STANDARD,FEED' (i seguenti parametri non sono decodificati: " &
|
|
sErrMsg & " )")
|
|
End If
|
|
ElseIf TempList(0) = TempList(1) Or TempList(0) = TempList(2) Or TempList(1) = TempList(2) Then
|
|
If bFirstRun Then
|
|
EgtOutLog("WARNING configurazione: in Config.ini del programma nella sezione 'General/ResetCmd' " &
|
|
"non trovato una sequenza del tipo 'HARD,STANDARD,FEED' (due o più dati sono ripetuti)")
|
|
End If
|
|
Else
|
|
m_ListCmdReset = TempList
|
|
End If
|
|
End If
|
|
|
|
SetBtnResetContent(0, ResetCutBtn)
|
|
SetBtnResetContent(1, ResetCut1Btn)
|
|
SetBtnResetContent(2, ResetCut2Btn)
|
|
|
|
bFirstRun = False
|
|
End Sub
|
|
|
|
#End Region ' Reset
|
|
|
|
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
|
|
' Se sono in modalità Test Posizione lavorazione
|
|
If m_MainWindow.m_CadCutPageUC.m_NestPage.m_bSelectCurv Then
|
|
' Verifico non sia versione Ufficio
|
|
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.OFFICE_TYPE) Then
|
|
m_CurrProjPage.SetWarningMessage("Office Version")
|
|
Return
|
|
End If
|
|
|
|
'------------------- Ricavo punto medio di posizionamento ----------------------------
|
|
' Spessore grezzo
|
|
Dim m_ptRawMax, m_ptRawMin As Point3d
|
|
If Not GetRawBox(m_ptRawMin, m_ptRawMax) Then Return
|
|
Dim dRawHeight As Double = m_ptRawMax.z - m_ptRawMin.z
|
|
|
|
' Recupero spessore lama corrente
|
|
Dim TestToolWD As New ChooseTestToolWD(m_MainWindow)
|
|
TestToolWD.ShowDialog()
|
|
If Not TestToolWD.DialogResult Then Return
|
|
Dim CurrTestTool As TestTool = TestToolWD.GetSelectedTool
|
|
|
|
Dim dThick As Double = 0
|
|
Dim dHeight As Double = 0
|
|
If CurrTestTool.ToolIsSaw Then
|
|
' Spessore LAMA
|
|
EgtTdbGetCurrToolParam(MCH_TP.THICK, dThick)
|
|
' Diametro
|
|
EgtTdbGetCurrToolParam(MCH_TP.DIAM, dHeight)
|
|
' Raggio lama
|
|
dHeight = dHeight / 2
|
|
ElseIf CurrTestTool.ToolIsLaser Then
|
|
' Raggio
|
|
dThick = 0
|
|
dHeight = 0
|
|
Else
|
|
' Diametro FRESA/FORETTO (l'altezza non serve: posizione calcolata tiene conto del Tip Tool)
|
|
EgtTdbGetCurrToolParam(MCH_TP.DIAM, dThick)
|
|
' Raggio
|
|
dThick = dThick / 2
|
|
End If
|
|
|
|
' recupero il lato selezionato
|
|
Dim nIdSelected As Integer = m_MainWindow.m_CadCutPageUC.m_NestPage.m_CurrSelectedCurv
|
|
If nIdSelected = -1 Then Return
|
|
' recupero il vettore nel punto medio dell'entità
|
|
Dim vtDirLine As Vector3d
|
|
EgtMidVector(nIdSelected, GDB_ID.ROOT, vtDirLine)
|
|
|
|
' calcolo il versore della linea di taglio
|
|
Dim vtDirT As Vector3d = vtDirLine
|
|
vtDirT.Normalize()
|
|
' calcolo la direzione di offset da applicare all'utensile
|
|
Dim vtOffset As New Vector3d(vtDirT.x, vtDirT.y, vtDirT.z)
|
|
vtOffset.Rotate(Vector3d.Z_AX(), 90)
|
|
|
|
If CurrTestTool.ToolIsSaw Then
|
|
' calcolo il versore perpendicolare alla linea di taglio (diretto verso l'interno del pezzo)
|
|
vtDirT.Rotate(Vector3d.Z_AX(), 90)
|
|
Else
|
|
' direzione utensile sempre Z+
|
|
vtDirT = Vector3d.Z_AX()
|
|
End If
|
|
|
|
' Calcolo punto di posizionamemto (punto medio)
|
|
Dim ptMid, m_ptTabOri As Point3d
|
|
|
|
If Not EgtGetTableRef(1, m_ptTabOri) Then Return
|
|
' recupero il punto medio della curva
|
|
EgtMidPoint(nIdSelected, GDB_ID.ROOT, ptMid)
|
|
ptMid.z = m_ptTabOri.z + CamAuto.GetRawHeight() + dHeight + m_MainWindow.m_CurrentMachine.dAdditionalTable
|
|
' Offset dovuto allo spessore Utensile
|
|
ptMid -= vtOffset * dThick
|
|
|
|
'--------------------------- Imposto la posizione della macchina ----------------------------
|
|
' Recupero la posizione macchina
|
|
Dim dL1, dL2, dL3, dR1, dR2 As Double
|
|
If Not m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2) Then Return
|
|
|
|
' Imposto l'utensile corrente, preso dalla scelta precedente
|
|
If Not EgtSetCalcTool(CurrTestTool.ToolName, CurrTestTool.ToolHead, CurrTestTool.ToolExit) Then Return
|
|
Dim vsAxNames As String() = Nothing
|
|
EgtGetAllCurrAxesNames( vsAxNames)
|
|
Dim nRotAxCnt As Integer = vsAxNames.Count() - 3
|
|
|
|
' calcolo la posizione degli assi rotanti C, B
|
|
Dim nStat As Integer
|
|
Dim dC1, dB1, dC2, dB2 As Double
|
|
' Se utensile LAMA
|
|
If CurrTestTool.ToolIsSaw Then
|
|
EgtGetCalcAngles(vtDirT, Vector3d.Z_AX(), nStat, dC1, dB1, dC2, dB2)
|
|
' Se LASER
|
|
ElseIf CurrTestTool.ToolIsLaser Then
|
|
Dim dHomeC As Double = 90
|
|
EgtGetAxisHomePos("C", dHomeC)
|
|
Dim vtPrefAuxDir As Vector3d = -Vector3d.X_AX()
|
|
vtPrefAuxDir.Rotate(Vector3d.Z_AX, dHomeC)
|
|
EgtGetCalcAngles(vtDirT, vtPrefAuxDir, nStat, dC1, dB1, dC2, dB2)
|
|
' Se asse C non calcolato, imposto il valore di Home
|
|
If nRotAxCnt = 0 Or nStat < 0 Then
|
|
dC1 = dHomeC
|
|
dC2 = dHomeC
|
|
End If
|
|
' Forzo asse B a 90 (per le lame)
|
|
dB1 = 90
|
|
' Se FRESA o FORETTO
|
|
ElseIf CurrTestTool.ToolType = MCH_TY.MILL_STD Or CurrTestTool.ToolType = MCH_TY.DRILL_STD Then
|
|
Dim nStepRotC As Integer = GetPrivateProfileInt(S_NEST, K_MACH_DRILL_MILL_C90, 1, m_MainWindow.GetMachIniFile())
|
|
Dim vtPrefAuxDir As Vector3d = -Vector3d.X_AX()
|
|
vtPrefAuxDir.Rotate(Vector3d.Z_AX, 90 * nStepRotC)
|
|
EgtGetCalcAngles(vtDirT, vtPrefAuxDir, nStat, dC1, dB1, dC2, dB2)
|
|
' Se asse C non calcolato, imposto il valore preferenziale
|
|
If nStat < 0 Then
|
|
dC1 = nStepRotC
|
|
dC2 = nStepRotC
|
|
End If
|
|
' Se WATERJET
|
|
ElseIf CurrTestTool.ToolType = MCH_TY.WATERJET Then
|
|
Dim dHomeC As Double = 90
|
|
EgtGetAxisHomePos("C", dHomeC)
|
|
Dim vtPrefAuxDir As Vector3d = Vector3d.X_AX()
|
|
vtPrefAuxDir.Rotate(Vector3d.Z_AX, dHomeC)
|
|
EgtGetCalcAngles(vtDirT, vtPrefAuxDir, nStat, dC1, dB1, dC2, dB2)
|
|
' Se asse C non calcolato, imposto il valore di Home
|
|
If nStat < 0 Then
|
|
dC1 = dHomeC
|
|
dC2 = dHomeC
|
|
End If
|
|
End If
|
|
|
|
' calcolo la posizione degli assi lineari X, Y, Z
|
|
Dim dX, dY, dZ As Double
|
|
EgtGetCalcPositions(ptMid, dC1, dB1, nStat, dX, dY, dZ)
|
|
' Se laser, forzo la Z alla quota di Home
|
|
If CurrTestTool.ToolIsLaser Then
|
|
Dim dHomeZ As Double = 0
|
|
EgtGetAxisHomePos("Z", dHomeZ)
|
|
dZ = dHomeZ
|
|
End If
|
|
|
|
' verifica assi lineari
|
|
EgtVerifyOutstroke(dX, dY, dZ, dC1, dB1, nStat)
|
|
If nStat <> 0 Then
|
|
EgtOutLog("Out of stroke: " & nStat)
|
|
vtDirT = -vtDirT
|
|
ptMid -= vtDirT * dThick
|
|
' Se LAMA
|
|
If CurrTestTool.ToolIsSaw Then
|
|
EgtGetCalcAngles(vtDirT, Vector3d.Z_AX(), nStat, dC1, dB1, dC2, dB2)
|
|
' Se LASER
|
|
ElseIf CurrTestTool.ToolIsLaser Then
|
|
Dim dHomeC As Double = 90
|
|
EgtGetAxisHomePos("C", dHomeC)
|
|
Dim vtPrefAuxDir As Vector3d = -Vector3d.X_AX()
|
|
vtPrefAuxDir.Rotate(Vector3d.Z_AX, dHomeC)
|
|
EgtGetCalcAngles(vtDirT, vtPrefAuxDir, nStat, dC1, dB1, dC2, dB2)
|
|
' Se asse C non calcolato, imposto il valore di Home
|
|
If nRotAxCnt = 0 Or nStat < 0 Then
|
|
dC1 = dHomeC
|
|
dC2 = dHomeC
|
|
End If
|
|
' Forzo B90
|
|
dB1 = 90
|
|
' Se FRESA/FORETTO
|
|
ElseIf CurrTestTool.ToolType = MCH_TY.MILL_STD Or CurrTestTool.ToolType = MCH_TY.DRILL_STD Then
|
|
Dim nStepRotC As Integer = GetPrivateProfileInt(S_NEST, K_MACH_DRILL_MILL_C90, 1, m_MainWindow.GetMachIniFile())
|
|
Dim vtPrefAuxDir As Vector3d = -Vector3d.X_AX()
|
|
vtPrefAuxDir.Rotate(Vector3d.Z_AX, 90 * nStepRotC)
|
|
EgtGetCalcAngles(vtDirT, vtPrefAuxDir, nStat, dC1, dB1, dC2, dB2)
|
|
' Se asse C non calcolato, imposto il valore preferenziale
|
|
If nStat < 0 Then
|
|
dC1 = nStepRotC
|
|
dC2 = nStepRotC
|
|
End If
|
|
' Se WATERJET
|
|
ElseIf CurrTestTool.ToolType = MCH_TY.WATERJET Then
|
|
' Se WJ
|
|
Dim dHomeC As Double = 90
|
|
EgtGetAxisHomePos("C", dHomeC)
|
|
Dim vtPrefAuxDir As Vector3d = Vector3d.X_AX()
|
|
vtPrefAuxDir.Rotate(Vector3d.Z_AX, dHomeC)
|
|
EgtGetCalcAngles(vtDirT, vtPrefAuxDir, nStat, dC1, dB1, dC2, dB2)
|
|
' Se asse C non calcolato, imposto il valore di Home
|
|
If nStat < 0 Then
|
|
dC1 = dHomeC
|
|
dC2 = dHomeC
|
|
End If
|
|
End If
|
|
' calcolo la posizione degli assi lineari X, Y, Z
|
|
EgtGetCalcPositions(ptMid, dC1, dB1, nStat, dX, dY, dZ)
|
|
' Se laser, forzo la Z alla quota di Home
|
|
If CurrTestTool.ToolIsLaser Then
|
|
Dim dHomeZ As Double = 0
|
|
EgtGetAxisHomePos("Z", dHomeZ)
|
|
dZ = dHomeZ
|
|
End If
|
|
|
|
' verifica assi lineari
|
|
EgtVerifyOutstroke(dX, dY, dZ, dC1, dB1, nStat)
|
|
If nStat <> 0 Then
|
|
EgtOutLog("2nd attemp out of stroke: " & nStat)
|
|
End If
|
|
End If
|
|
|
|
'--------------------------- Comunico i movimenti in origine macchina al CN ----------------------------------------
|
|
ExecuteTestMoveCNC(New Point3d(dX, dY, dZ), dC1, dB1, CurrTestTool)
|
|
Return
|
|
End If
|
|
' ---------------------------- Fine modalità test posizione lavorazione --------------------------------------------
|
|
|
|
' Salvo eventuale nome del progetto
|
|
m_CurrProjPage.SetProjectName()
|
|
|
|
Dim bOk As Boolean = True
|
|
EgtSetCurrentContext(m_CurrProjPage.CurrentProjectScene.GetCtx())
|
|
' Elimino eventuale attrezzaggio da OmagOFFICE
|
|
EgtEraseCurrSetup()
|
|
' 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 = IsDirectCutOn()
|
|
If nPrjType = CurrentProjectPageUC.PRJ_TYPE.FLATS And
|
|
Not bDirectCut And
|
|
Not m_CurrProjPage.GetOrderMachiningFlag() Then
|
|
ResetAllMachinings()
|
|
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
|
|
Else
|
|
m_CurrProjPage.SetInfoMessage(EgtMsg(90399)) ' Aggiornate tutte le lavorazioni
|
|
End If
|
|
EgtDraw()
|
|
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.SetProjectIndex()
|
|
' 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 modalità Ufficio, copio il progetto ed esco
|
|
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.OFFICE_TYPE) Then
|
|
' Ripristino come fase corrente quella iniziale
|
|
EgtSetCurrPhase(1)
|
|
' Chiedo il nome del file esportato
|
|
Dim MySaveNameWD As New SaveNameWD(m_MainWindow, SaveNameWD.SAVE_TYPE.PRJ_COPY)
|
|
MySaveNameWD.ShowDialog()
|
|
Return
|
|
End If
|
|
' 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()
|
|
nPhaseRestart = 0
|
|
EgtDisableModified()
|
|
Case Else ' CANCEL
|
|
Return
|
|
End Select
|
|
End If
|
|
' Se abilitate, eseguo le stime
|
|
If GetPrivateProfileInt(S_MACH_ESTIMATIONS, K_ENABLEEST, 0, m_MainWindow.GetMachIniFile()) <> 0 Then
|
|
EgtEstimate(m_MainWindow.GetTempDir() & "\MachProj.html", "OmagCut ver." & m_MainWindow.GetVersion())
|
|
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 Or m_CurrMachine.bDemo) Then
|
|
' Download programma (eventuali errori sono segnalati dalla funzione)
|
|
If m_CurrNcComm.SendProgram(sCncPath, 900) Then
|
|
Dim sWrkPath As String = m_MainWindow.GetTempDir() & "\" & "WorkProj.nge"
|
|
My.Computer.FileSystem.CopyFile(sMchPath, sWrkPath, True)
|
|
' se abilitato e non è restart, lancio eventuale lua post-trasmissione
|
|
If m_MainWindow.GetKeyOption(MainWindow.KEY_OPT.SIMPLESTATISTICS) And nPhaseRestart = 0 Then
|
|
m_MainWindow.ExecSentProgScript(False)
|
|
End If
|
|
End If
|
|
|
|
'------------------- INIZIO Avvio il Ciclo-Start-------------------------
|
|
If GetPrivateProfileInt(S_GENERAL, K_STARTPROGRAM, 0, m_MainWindow.GetIniFile()) <> 0 AndAlso
|
|
( m_MainWindow.m_CNCommunication.m_nNCType <> 4 Or m_MainWindow.m_CNCommunication.SpecialSend <> 1) Then
|
|
Dim MyCicloStartWD As New CicloStartWD(m_MainWindow)
|
|
MyCicloStartWD.ShowDialog()
|
|
End If
|
|
'------------------- FINE Avvio il Ciclo-Start-------------------------
|
|
|
|
' ------------------ INIZIO gestione SCRAPS ---------------------------
|
|
Dim NewScrapsList As New List(Of Scrap)
|
|
' procedo all'aggiornamento della lista degli sfridi
|
|
UpDateScrapList(NewScrapsList)
|
|
|
|
' se esiste almeno uno sfrido da inserire come nuovo grezzo
|
|
If NewScrapsList.Count > 0 Then
|
|
' apro la finestra con l'elenco degli sfridi
|
|
Dim MyScrapsWD As New ScrapsWD(m_MainWindow, Me, NewScrapsList)
|
|
MyScrapsWD.ShowDialog()
|
|
End If
|
|
' ------------------ FINE gestione SCRAPS -----------------------------
|
|
|
|
' Altrimenti linea di produzione
|
|
Else
|
|
' Verifico non sia già stato trasmesso
|
|
Dim bAlreadySent As Boolean = (m_CurrProjPage.GetProjectNcProgSent() <> 0)
|
|
If bAlreadySent Then
|
|
' Gestione possibilità sia nuovo progetto
|
|
Dim bIsNew As Boolean = False
|
|
If m_CurrMachine.bAskNewOnResend Then
|
|
' Programma già trasmesso, è una nuova lastra ?
|
|
Dim AskNew As New EgtMsgBox(m_MainWindow, "", EgtMsg(90330),
|
|
EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL, 2)
|
|
' Se annullo
|
|
If AskNew.m_nPressedBtn = 0 Then
|
|
Return
|
|
' Se altrimenti nuovo progetto
|
|
ElseIf AskNew.m_nPressedBtn = 1 Then
|
|
' Incremento indice
|
|
m_CurrProjPage.SetNextProjectIndex()
|
|
' Rimuovo flag di progetto già scaricato
|
|
EgtRemoveInfo(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_PROJMARK), INFO_UNLOADSAVED)
|
|
' Rimuovo flag di Ok sui pezzi
|
|
Dim nRawId As Integer = CamAuto.GetCurrentRaw()
|
|
Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawId)
|
|
While nPartId <> GDB_ID.NULL
|
|
EgtRemoveInfo(nPartId, INFO_PARTOK)
|
|
Dim nRegId = EgtGetFirstNameInGroup(nPartId, NAME_REGION)
|
|
' Cerco prima regione nel layer
|
|
Dim nId As Integer = EgtGetFirstInGroup(nRegId)
|
|
While nId <> GDB_ID.NULL
|
|
If EgtGetType(nId) = GDB_TY.SRF_FRGN Then
|
|
EgtSetColor(nId, New Color3d(0, 255, 255, 25)) ' Aqua
|
|
Exit While
|
|
End If
|
|
nId = EgtGetNext(nId)
|
|
End While
|
|
nPartId = EgtGetNextPartInRawPart(nPartId)
|
|
End While
|
|
' Eventuale gestione dati lastra
|
|
Dim bSlabId As Boolean = (Not m_CurrMachine.bHasRawBarCodeReader And
|
|
GetPrivateProfileInt(S_RAWPART, K_SLABID, 0, m_MainWindow.GetIniFile()) <> 0)
|
|
If bSlabId Then
|
|
Dim sBlock As String = ""
|
|
GetPrivateProfileString(S_RAWPART, K_BLOCKNAME, "", sBlock, m_MainWindow.GetIniFile())
|
|
Dim nSlabNbr As Integer = GetPrivateProfileInt(S_RAWPART, K_SLABNBR, 0, m_MainWindow.GetIniFile())
|
|
nSlabNbr += 1
|
|
Dim sSlabNbr As String = nSlabNbr.ToString()
|
|
WritePrivateProfileString(S_RAWPART, K_SLABNBR, sSlabNbr, m_MainWindow.GetIniFile())
|
|
Utility.SetBlockAndSlabNbr(sBlock, sSlabNbr)
|
|
End If
|
|
' Salvo il progetto
|
|
m_CurrProjPage.SaveProject()
|
|
' Rigenero il file CNC
|
|
EgtGenerate(sCncPath, "OmagCut ver." & m_MainWindow.GetVersion())
|
|
EgtDisableModified()
|
|
' 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
|
|
EgtEnableModified()
|
|
EgtDraw()
|
|
' Dichiaro che il progetto è nuovo
|
|
bAlreadySent = False
|
|
' reimposto tutti gli sfridi come nuovi sfridi
|
|
Dim CurrScrapsList As New List(Of Scrap)
|
|
' procedo all'aggiornamento della lista degli sfridi
|
|
UpDateScrapList(CurrScrapsList)
|
|
For Each ItemScrap As Scrap In CurrScrapsList
|
|
ItemScrap.ResetState()
|
|
Next
|
|
End If
|
|
End If
|
|
If bAlreadySent 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
|
|
End If
|
|
|
|
' ------------------ INIZIO gestione SCRAPS ---------------------------
|
|
Dim NewScrapsList As New List(Of Scrap)
|
|
' procedo all'aggiornamento della lista degli sfridi
|
|
UpDateScrapList(NewScrapsList)
|
|
' se esiste almeno uno sfrido da inserire come nuovo grezzo
|
|
If NewScrapsList.Count > 0 Then
|
|
' apro la finestra con l'elenco degli sfridi
|
|
Dim MyScrapsWD As New ScrapsWD(m_MainWindow, Me, NewScrapsList)
|
|
MyScrapsWD.ShowDialog()
|
|
End If
|
|
' ------------------ FINE gestione SCRAPS -----------------------------
|
|
|
|
' Se non collegato alla macchina
|
|
If Not m_MainWindow.m_bNCLink Then
|
|
' salvo il progetto corrente incrementando il valore del progetto
|
|
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
|
|
m_MainWindow.ExecSentProgScript(False, bAlreadySent)
|
|
' se in versione demo (per linea di produzione) salvo il file corrente incrementando la numerazione
|
|
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 As Integer = 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 As Integer = 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 il nome della tavola da cui sto lanciando il progetto
|
|
Dim sTabeName As String = String.Empty
|
|
EgtGetTableName(sTabeName)
|
|
Dim bDoubleProg As Boolean = (GetPrivateProfileInt(S_PRODUCTIONLINE, "DoubleProg", 0, m_MainWindow.GetMachIniFile()) <> 0)
|
|
|
|
' 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 As Integer = 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
|
|
Dim bSendToAre1 As Boolean = (nVarProg1 = 0 And (nVarProg2 <> 1 Or nVarProgTwins = 2))
|
|
Dim bSendToAre2 As Boolean = (nVarProg2 = 0 And (nVarProg1 <> 1 Or nVarProgTwins = 2))
|
|
|
|
If bDoubleProg Then
|
|
If sTabeName = MAIN_TAB Then
|
|
' spedisco il programma da tavola 1 solo se CN ha terminato programma 901
|
|
bSendToAre1 = (nVarProg1 = 0)
|
|
bSendToAre2 = False
|
|
EgtOutLog(" Invio programma da tavola 1")
|
|
Else
|
|
' spedisco il programma da tavola 2 solo se CN ha terminato programma 902
|
|
bSendToAre1 = False
|
|
bSendToAre2 = (nVarProg2 = 0)
|
|
EgtOutLog(" Invio programma da tavola 2")
|
|
End If
|
|
End If
|
|
|
|
If bSendToAre1 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
|
|
m_MainWindow.ExecSentProgScript(False, bAlreadySent)
|
|
End If
|
|
m_CurrNcComm.SetProgramMainOrSub(True)
|
|
' Altrimenti verifico se posso scrivere nell'area 2
|
|
ElseIf bSendToAre2 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
|
|
m_MainWindow.ExecSentProgScript(False, bAlreadySent)
|
|
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
|
|
' avvio programma solo se DoubleProg
|
|
If (GetPrivateProfileInt(S_GENERAL, K_STARTPROGRAM, 0, m_MainWindow.GetIniFile()) <> 0 And bDoubleProg) And
|
|
(bSendToAre1 Or bSendToAre2) Then
|
|
Dim MyCicloStartWD As New CicloStartWD(m_MainWindow)
|
|
MyCicloStartWD.ShowDialog()
|
|
End If
|
|
|
|
End If
|
|
#End If
|
|
End Sub
|
|
|
|
' aggiorno la lista dei grezzi/sfridi
|
|
Public Sub UpDateScrapList(ByRef NewScrapsList As List(Of Scrap))
|
|
If IsNothing(NewScrapsList) Then
|
|
NewScrapsList = New List(Of Scrap)
|
|
Else
|
|
NewScrapsList.Clear()
|
|
End If
|
|
' procedo all'aggiornamento della lista degli sfridi
|
|
Dim CurrRawId As Integer = EgtGetFirstRawPart()
|
|
Dim IsNewScraps As Integer = 0
|
|
Dim nCountScrap As Integer = 1
|
|
While CurrRawId <> GDB_ID.NULL
|
|
If EgtGetInfo(CurrRawId, K_ISNEWSCRAPS, IsNewScraps) Then
|
|
If IsNewScraps = 1 Or IsNewScraps = 2 Then
|
|
' deve essere aggiunto nel DB delle lastre come nuovo grezzo (l'indice è utilizzato per definire il nome della lastra)
|
|
NewScrapsList.Add(New Scrap(CurrRawId, "Scrap_" & nCountScrap.ToString, IsNewScraps))
|
|
nCountScrap += 1
|
|
' è già stato aggiunto al DB delle lastre come nuovo grezzo
|
|
Else
|
|
' non è stato definito come nuovo grezzo
|
|
End If
|
|
End If
|
|
CurrRawId = EgtGetNextRawPart(CurrRawId)
|
|
End While
|
|
End Sub
|
|
|
|
Public Sub UpdateFeedAllMachining()
|
|
Dim SettedMachinig As String = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.NAME, SettedMachinig)
|
|
|
|
' Parametri della lavorazione letta da DB
|
|
Dim sMachiningName As String = String.Empty
|
|
Dim dFeed As Double = 0
|
|
Dim dFeedStarted As Double = 0
|
|
Dim dFeedEnded As Double = 0
|
|
Dim dFeedTipped As Double = 0
|
|
Dim dFeedBack As Double = 0
|
|
Dim dFeedSideAng As Double = 0
|
|
' Elenco delle lavorazioni
|
|
Dim MachiningList As New List(Of SplitMach)
|
|
|
|
' Recupero l'indice della fase corrente
|
|
Dim nCurrPhase As Integer = 1
|
|
' recupero in numero di fasi presenti nel progetto
|
|
Dim nCountPhase As Integer = EgtGetPhaseCount()
|
|
' Numero di lavorazioni del progetto (conteggiate nel ciclo for)
|
|
Dim nMach As Integer = 0
|
|
' Numero di lavorazioni aggiornate (conteggate nel ciclo for)
|
|
Dim nMachUpdated As Integer = 0
|
|
' Elenco dei nomi lavorazioni aggiorniate
|
|
Dim UpdateMachinigNameList As New List(Of String)
|
|
|
|
' ciclo su tutte le fasi di lavorazione
|
|
For IndexPhase As Integer = 1 To nCountPhase
|
|
' imposto la fase corrente
|
|
nCurrPhase = IndexPhase
|
|
' Preparo la lista delle lavorazioni
|
|
CalculateSplitMachList(nCurrPhase, MachiningList)
|
|
' per ogni lavorazione corrente procedo ad aggiornare la feed
|
|
For IndexMachining As Integer = 0 To MachiningList.Count - 1
|
|
nMach += 1
|
|
Dim nOperId As Integer = MachiningList(IndexMachining).m_nId
|
|
' setto la lavorazione come corrente
|
|
If EgtSetCurrMachining(nOperId) Then
|
|
Dim sCurrMachiningName As String = String.Empty
|
|
EgtGetMachiningParam(MCH_MP.NAME, sCurrMachiningName)
|
|
' Se la lavorazione corrente da DB è diversa da quella della lavorazione allora aggiorno i dati
|
|
If sCurrMachiningName <> sMachiningName Then
|
|
sMachiningName = sCurrMachiningName
|
|
' Recupero la lavorazione dell'operazione indicata
|
|
If Not EgtMdbSetCurrMachining(sMachiningName) Then
|
|
EgtOutLog("ERRORE: Machining '" & sMachiningName & "' does not exist in DB of machining.")
|
|
sMachiningName = String.Empty
|
|
Continue For
|
|
End If
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.FEED, dFeed)
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.STARTFEED, dFeedStarted)
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.ENDFEED, dFeedEnded)
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TIPFEED, dFeedTipped)
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.BACKFEED, dFeedBack)
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.SIDEANGFEED, dFeedSideAng)
|
|
Else
|
|
' verifico se è stata applicata una variazione delle Feed
|
|
If UpdateMachinigNameList.FindIndex(Function(x) x = sCurrMachiningName) = -1 Then
|
|
' La lavorazione corrente non ha nessun parametro nuovo
|
|
Continue For
|
|
End If
|
|
End If
|
|
|
|
Dim bUpdate As Boolean = False
|
|
' STANDARD
|
|
Dim dOrigFeed As Double
|
|
EgtGetMachiningParam(MCH_MP.FEED, dOrigFeed)
|
|
' imposto il valore di Feed solo se differente da quello nuovo
|
|
If Math.Abs(dOrigFeed - dFeed) > 0.1 Then
|
|
bUpdate = bUpdate Or EgtSetMachiningParam(MCH_MP.FEED, dFeed)
|
|
' aggiorno la lavorazione (senza il ricalcolo dell'intera lavorazione)
|
|
EgtApplyMachining(True)
|
|
End If
|
|
' STARTED
|
|
Dim dOrigFeedStarted As Double
|
|
EgtGetMachiningParam(MCH_MP.STARTFEED, dOrigFeedStarted)
|
|
' imposto il valore di Feed solo se differente da quello nuovo
|
|
If Math.Abs(dOrigFeedStarted - dFeedStarted) > 0.1 Then
|
|
bUpdate = bUpdate Or EgtSetMachiningParam(MCH_MP.STARTFEED, dFeedStarted)
|
|
' aggiorno la lavorazione (senza il ricalcolo dell'intera lavorazione)
|
|
EgtApplyMachining(True)
|
|
End If
|
|
' ENDED
|
|
Dim dOrigFeedEnded As Double
|
|
EgtGetMachiningParam(MCH_MP.ENDFEED, dOrigFeedEnded)
|
|
' imposto il valore di Feed solo se differente da quello nuovo
|
|
If Math.Abs(dOrigFeedEnded - dFeedEnded) > 0.1 Then
|
|
bUpdate = bUpdate Or EgtSetMachiningParam(MCH_MP.ENDFEED, dFeedEnded)
|
|
' aggiorno la lavorazione (senza il ricalcolo dell'intera lavorazione)
|
|
EgtApplyMachining(True)
|
|
End If
|
|
' TIPPED
|
|
Dim dOrigFeedTipped As Double
|
|
EgtGetMachiningParam(MCH_MP.TIPFEED, dOrigFeedTipped)
|
|
' imposto il valore di Feed solo se differente da quello nuovo
|
|
If Math.Abs(dOrigFeedTipped - dFeedTipped) > 0.1 Then
|
|
bUpdate = bUpdate Or EgtSetMachiningParam(MCH_MP.TIPFEED, dFeedTipped)
|
|
' aggiorno la lavorazione (senza il ricalcolo dell'intera lavorazione)
|
|
EgtApplyMachining(True)
|
|
End If
|
|
' BACK
|
|
Dim dOrigFeedBack As Double
|
|
EgtGetMachiningParam(MCH_MP.BACKFEED, dOrigFeedBack)
|
|
' imposto il valore di Feed solo se differente da quello nuovo
|
|
If Math.Abs(dOrigFeedBack - dFeedBack) > 0.1 Then
|
|
bUpdate = bUpdate Or EgtSetMachiningParam(MCH_MP.BACKFEED, dFeedBack)
|
|
' aggiorno la lavorazione (senza il ricalcolo dell'intera lavorazione)
|
|
EgtApplyMachining(True)
|
|
End If
|
|
' SIDEANG
|
|
Dim dOrigFeedSideAng As Double
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.SIDEANGFEED, dOrigFeedSideAng)
|
|
' imposto il valore di Feed solo se differente da quello nuovo
|
|
If Math.Abs(dOrigFeedBack - dFeedSideAng) > 0.1 Then
|
|
bUpdate = bUpdate Or EgtSetMachiningParam(MCH_MP.SIDEANGFEED, dFeedSideAng)
|
|
' aggiorno la lavorazione (senza il ricalcolo dell'intera lavorazione)
|
|
EgtApplyMachining(True)
|
|
End If
|
|
' conto il numero di lavorazioni aggiornate
|
|
If bUpdate Then
|
|
nMachUpdated += 1
|
|
If UpdateMachinigNameList.FindIndex(Function(x) x = sCurrMachiningName) = -1 Then
|
|
UpdateMachinigNameList.Add(sCurrMachiningName)
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
Next
|
|
|
|
If UpdateMachinigNameList.Count > 0 Then
|
|
Dim sMsg As String = String.Empty
|
|
For Each Item As String In UpdateMachinigNameList
|
|
sMsg = sMsg & If(String.IsNullOrEmpty(sMsg), "", ",") & Item
|
|
Next
|
|
EgtOutLog("Le lavorazioni aggiornate sono: " & sMsg)
|
|
Else
|
|
EgtOutLog("Nessuna lavorazione è stata aggiornata: Feed da DB uguali a quelle impostate nelle lavorazioni")
|
|
End If
|
|
|
|
m_MainWindow.m_CurrentProjectPageUC.SetInfoMessage(EgtMsg(91243) & nMachUpdated & "/ " & nMach) ' Lavorazione aggiornate:
|
|
End Sub
|
|
|
|
' ------------------------------------------------ GENERA COMANDI CNC MOVIMENTO ------------------------------------------------
|
|
Private Sub ExecuteTestMoveCNC(ptMid As Point3d, dAngC As Double, dAngB As Double, SelTestTool As TestTool)
|
|
|
|
Dim CmdString As String = String.Empty
|
|
If Not EgtLuaExecFile(m_MainWindow.m_CurrentMachine.sMachDir() & "\DirectCmd\TestWork.lua") Then
|
|
Return
|
|
End If
|
|
|
|
'----------- DATI MOVIMENTO -----------
|
|
' imposto avanzamneto in rapido (non deve essere impostata feed e speed)
|
|
EgtLuaSetGlobBoolVar("CMD.G0", True)
|
|
|
|
'----------- POSIZIONE MACCHINA -----------
|
|
' Leggo gli assi rispetto allo 0 macchina
|
|
m_CurrNcComm.m_CN.set_OP_OM(0)
|
|
|
|
System.Threading.Thread.Sleep(100)
|
|
Dim dL1o, dL2o, dL3o As Double
|
|
m_CurrNcComm.GetLinearAxesPositions(dL1o, dL2o, dL3o)
|
|
Dim dR1, dR2 As Double
|
|
m_CurrNcComm.GetRotaryAxesPositions(dR1, dR2)
|
|
EgtLuaSetGlobNumVar("CMD.L1o", dL1o)
|
|
EgtLuaSetGlobNumVar("CMD.L2o", dL2o)
|
|
EgtLuaSetGlobNumVar("CMD.L3o", dL3o)
|
|
EgtLuaSetGlobNumVar("CMD.R1", dR1)
|
|
EgtLuaSetGlobNumVar("CMD.R2", dR2)
|
|
|
|
EgtTdbSetCurrTool(SelTestTool.ToolName)
|
|
EgtLuaSetGlobStringVar("CMD.TLNAME", SelTestTool.ToolName)
|
|
EgtLuaSetGlobStringVar("CMD.TLALIAS", SelTestTool.ToolAlias)
|
|
Dim dThick As Double = 0
|
|
EgtTdbGetCurrToolParam(MCH_TP.THICK, dThick)
|
|
EgtLuaSetGlobNumVar("CMD.SAWTH", dThick)
|
|
Dim sTCPos As String = String.Empty
|
|
EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sTCPos)
|
|
EgtLuaSetGlobStringVar("CMD.TCPOS", sTCPos)
|
|
|
|
'----------- ASSEGNO POSIZIONE DI ARRIVO MACCHINA -----------
|
|
' Assegno valore ad ogni asse da muovere (in zero macchina)
|
|
EgtLuaSetGlobNumVar("CMD.X_AXISMOVE", ptMid.x)
|
|
EgtLuaSetGlobNumVar("CMD.Y_AXISMOVE", ptMid.y)
|
|
EgtLuaSetGlobNumVar("CMD.Z_AXISMOVE", ptMid.z)
|
|
' imposto gli angoli
|
|
EgtLuaSetGlobNumVar("CMD.C_ANGMOVE", dAngC)
|
|
EgtLuaSetGlobNumVar("CMD.B_ANGMOVE", dAngB)
|
|
|
|
' Calcolo stringa di comando risultante
|
|
EgtLuaCallFunction("CmdString")
|
|
EgtLuaGetGlobStringVar("CMD.CMDSTRING", CmdString)
|
|
|
|
' Reset lua
|
|
EgtLuaResetGlobVar("CmdString")
|
|
EgtLuaResetGlobVar("CMD")
|
|
' Log del comando
|
|
EgtOutLog("CmdString=" & CmdString)
|
|
|
|
' Modifico stringa per inserire i newline
|
|
CmdString = CmdString.Replace("<br/>", Environment.NewLine)
|
|
' Creo file...
|
|
Dim FilePath As String = m_MainWindow.GetCncDir() & "\TestWork" & m_MainWindow.m_CurrentMachine.sIsoFileExt
|
|
' ...e ci scrivo
|
|
Dim Writer As New IO.StreamWriter(FilePath, False)
|
|
Writer.Write(CmdString)
|
|
Writer.Close()
|
|
' Verifico se sono connesso alla macchina prima di continuare
|
|
If Not m_MainWindow.m_bNCLink Then
|
|
m_CurrProjPage.SetWarningMessage(EgtMsg(90316)) ' Non connesso alla macchina
|
|
Return
|
|
End If
|
|
' Mando file al CN
|
|
If Not m_MainWindow.m_CNCommunication.SendProgram(FilePath, 900) Then
|
|
Return
|
|
End If
|
|
m_MainWindow.m_CurrentProjectPageUC.ClearMessage()
|
|
EgtOutLog("TestWork : sent NC program")
|
|
' Aspetto e lo avvio
|
|
System.Threading.Thread.Sleep(300)
|
|
m_MainWindow.m_CNCommunication.m_CN.DGeneralFunctions_CycleStart()
|
|
|
|
End Sub
|
|
|
|
' ------------------------------------------------------------------------------------------------
|
|
Private Sub TestBtn_Click(sender As Object, e As RoutedEventArgs) Handles TestBtn.Click
|
|
If TestBtn.IsChecked Then
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.m_bSelectCurv = True
|
|
' deseleziono tutto
|
|
EgtDeselectAll()
|
|
Else
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.m_bSelectCurv = False
|
|
EgtDeselectObj(m_MainWindow.m_CadCutPageUC.m_NestPage.m_CurrSelectedCurv)
|
|
EgtResetMark(m_MainWindow.m_CadCutPageUC.m_NestPage.m_CurrSelectedSawCurv)
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.m_CurrToolFromSelectedSawCurv = String.Empty
|
|
End If
|
|
' aggiorno il disegno
|
|
EgtDraw()
|
|
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
|
|
If TestBtn.Visibility = Windows.Visibility.Visible Then TestBtn.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
|
|
' nuovi bottoni pagina di Nesting
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.DragRectangleBtn.Visibility = Windows.Visibility.Hidden
|
|
If m_MainWindow.m_CadCutPageUC.m_NestPage.SplitCurveWJBtn.Visibility = Windows.Visibility.Visible Then
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.SplitCurveWJBtn.Visibility = Windows.Visibility.Hidden
|
|
End If
|
|
' Nascondo bottoni rawpage
|
|
m_MainWindow.m_RawPartPage.OtherRefTabBtn.Visibility = Windows.Visibility.Hidden
|
|
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.LoadParams()
|
|
' Rendo visibili i bottoni per la definizione degli Spotreg
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.UG0_Reg.Visibility = Visibility.Visible
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.UG1_Reg.Visibility = Visibility.Visible
|
|
|
|
' 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()
|
|
|
|
' visualizzo i punti di SpotReg
|
|
EgtSetStatus(m_MainWindow.m_CadCutPageUC.m_NestPage.m_nRegGroupId, GDB_ST.ON_)
|
|
' eventualmente risistemo tutti i punti Spotreg in funzione dell'altezza del grezzo
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.UpdateSpotRegistration()
|
|
EgtDraw()
|
|
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.CSV_AUTO) 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
|
|
If TestBtn.Visibility = Windows.Visibility.Hidden Then TestBtn.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
|
|
' nuovi bottoni pagina di Nesting
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.DragRectangleBtn.Visibility = Windows.Visibility.Visible
|
|
If m_MainWindow.m_CadCutPageUC.m_NestPage.SplitCurveWJBtn.Visibility = Windows.Visibility.Hidden Then
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.SplitCurveWJBtn.Visibility = Windows.Visibility.Visible
|
|
End If
|
|
' disabilito i comandi per gestione SpotReg
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.PointRegCheckedOff()
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.UG0_Reg.Visibility = Visibility.Hidden
|
|
m_MainWindow.m_CadCutPageUC.m_NestPage.UG1_Reg.Visibility = Visibility.Hidden
|
|
|
|
' Nascondo bottoni rawpage
|
|
m_MainWindow.m_RawPartPage.OtherRefTabBtn.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()
|
|
|
|
' nascondi i punti di SpotReg
|
|
EgtSetStatus(m_MainWindow.m_CadCutPageUC.m_NestPage.m_nRegGroupId, GDB_ST.OFF)
|
|
EgtDraw()
|
|
|
|
' Cancello eventuali messaggi di errore/avvertimento
|
|
m_CurrProjPage.ClearMessage()
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class Scrap
|
|
|
|
Private m_iPictureID As Integer
|
|
Private m_sName As String
|
|
Private m_IdRaw As Integer
|
|
' nState=1 -> da inserire in DB, nState=2 -> già inserito in DB
|
|
Private m_nState As Integer
|
|
|
|
Public Property PictureID() As Integer
|
|
Get
|
|
Return m_iPictureID
|
|
End Get
|
|
Set(value As Integer)
|
|
m_iPictureID = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property Name() As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property IdRaw() As Integer
|
|
Get
|
|
Return m_IdRaw
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property nState As Integer
|
|
Get
|
|
Return m_nState
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ResetState(Optional nNewState As Integer = 1)
|
|
m_nState = nNewState
|
|
EgtSetInfo(m_IdRaw, K_ISNEWSCRAPS, nNewState)
|
|
EgtRemoveInfo(m_IdRaw, K_DATABASEID)
|
|
End Sub
|
|
|
|
Public ReadOnly Property PreviewState As System.Windows.Media.Imaging.BitmapImage
|
|
Get
|
|
Dim sPath As String = "/Resources/ImportPageListBoxImages/" & PictureID.ToString() & ".png"
|
|
Return New System.Windows.Media.Imaging.BitmapImage(New Uri(sPath, UriKind.Relative))
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(IdScrap As Integer, NameScrap As String, State As Integer)
|
|
m_IdRaw = IdScrap
|
|
m_sName = NameScrap
|
|
m_nState = State
|
|
' immagine del grezzo
|
|
If m_nState = 2 Then
|
|
m_iPictureID = 5
|
|
Else
|
|
m_iPictureID = 4
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|