From 45948e7004cf70313260214831e5193e8f0cf8bb Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 5 May 2026 19:14:33 +0200 Subject: [PATCH] =?UTF-8?q?OmagCUT=203.1e1=20:=20-=20aggiunta=20modalit?= =?UTF-8?q?=C3=A0=20trasmissione=20del=20programma=20CN=20a=20step=20per?= =?UTF-8?q?=20debug=20con=20Siemens=20One=20(in=20Ini=20di=20OmagCUT=20[Ge?= =?UTF-8?q?neral]=20StepByStepSend=3D1).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Constants/ConstIni.vb | 1 + MainWindow.xaml.vb | 4 +-- My Project/AssemblyInfo.vb | 4 +-- NcComm/CNCommunication.vb | 38 ++++++++++++++++++++++------ Project/CurrentProjectPageUC.xaml.vb | 4 +-- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/Constants/ConstIni.vb b/Constants/ConstIni.vb index 032c581..beedfb4 100644 --- a/Constants/ConstIni.vb +++ b/Constants/ConstIni.vb @@ -35,6 +35,7 @@ Module ConstIni Public Const K_IMAGEDIR As String = "ImageDir" Public Const K_CAMERALINK As String = "CameraLink" Public Const K_CNLINK As String = "CNLink" + Public Const K_STEPBYSTEPSEND As String = "StepByStepSend" Public Const K_TESTINGPAGE As String = "TestingPage" Public Const K_SHOWTIPAXES As String = "ShowTipAxes" Public Const K_LASTPROJFINISHED As String = "LastProjFinished" diff --git a/MainWindow.xaml.vb b/MainWindow.xaml.vb index f3b31c6..870f948 100644 --- a/MainWindow.xaml.vb +++ b/MainWindow.xaml.vb @@ -369,8 +369,8 @@ Class MainWindow ' Verifico abilitazione nesting automatico m_bAutoNest = Not String.IsNullOrWhiteSpace(sNestKey) ' Recupero opzioni della chiave - Dim bKey As Boolean = EgtGetKeyLevel(9423, 3104, 1, m_nKeyLevel) And - EgtGetKeyOptions(9423, 3104, 1, m_nKeyOptions) + Dim bKey As Boolean = EgtGetKeyLevel(9423, 3105, 1, m_nKeyLevel) And + EgtGetKeyOptions(9423, 3105, 1, m_nKeyOptions) ' Verifico abilitazione prodotto Dim bProd As Boolean = GetKeyOption(KEY_OPT.CUT_BASE) ' Impostazione per programma OnlyFrame: solo se CUT_BASE non attivo diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 1c463e3..dd16aca 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -62,5 +62,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/NcComm/CNCommunication.vb b/NcComm/CNCommunication.vb index 1c20787..9e402ef 100644 --- a/NcComm/CNCommunication.vb +++ b/NcComm/CNCommunication.vb @@ -21,6 +21,9 @@ Public Class CNCommunication ' Variabile per tipologia CN Friend m_nNCType As Integer + ' Modalità invio programmi step a step (attualmente solo per Siemens) + Private m_bStepByStepSend As Boolean = False + ' Modalità speciale invio programmi (attualmente solo per Fanuc, fino a 4 programmi) Private m_nSpecialSend As Integer = -1 Friend Property SpecialSend As Integer @@ -116,6 +119,9 @@ Public Class CNCommunication EgtOutLog("NcLink=" & m_MainWindow.m_bNCLink.ToString & " type=" & m_nNCType) + ' Leggo flag invio programma a step per debug (da Ini di OmagCUT) + m_bStepByStepSend = (GetPrivateProfileInt(S_GENERAL, K_STEPBYSTEPSEND, 0, m_MainWindow.GetIniFile()) = 1) + ' Leggo flag invio speciale programma di lavoro Dim nTemp As Integer = GetPrivateProfileInt(S_NUMERICALCONTROL, K_SPECIALSEND, -1, m_MainWindow.GetMachIniFile()) m_nSpecialSend = Math.Max( Math.Min( nTemp, 1), -1) @@ -128,9 +134,9 @@ Public Class CNCommunication ' Se CN Siemens leggo dati programma intermedio di comunicazione If m_nNCType = 3 Then Dim sExeName As String = String.Empty - GetPrivateProfileString(S_NCSIEMENS, K_COMM_NAME, "", sExeName, m_MainWindow.m_CurrentMachine.sMachIniFile) + GetPrivateProfileString(S_NCSIEMENS, K_COMM_NAME, "", sExeName, m_MainWindow.GetMachIniFile()) m_sCNSiemensPath = m_MainWindow.GetExeRootDir() & "\" & sExeName - GetPrivateProfileString(S_NCSIEMENS, K_PATH_HMI, "", m_sCNSiemensHMIPath, m_MainWindow.m_CurrentMachine.sMachIniFile) + GetPrivateProfileString(S_NCSIEMENS, K_PATH_HMI, "", m_sCNSiemensHMIPath, m_MainWindow.GetMachIniFile()) End If ' Inizializzo la connessione @@ -339,7 +345,7 @@ Public Class CNCommunication #End Region ' ver 2.7h2 nuova gestione - Private Sub KillSimensCom(sProcessName As String) + Private Sub KillSiemensCom(sProcessName As String) Dim sAppName As String = Path.GetFileNameWithoutExtension(sProcessName) Dim pList() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcesses For Each proc As System.Diagnostics.Process In pList @@ -555,7 +561,7 @@ Public Class CNCommunication ' !!!!!!!!!!!!!! FORZO LA SIMULAZIONE DELLA LETTURA DELLE VARIBILI E SIEMENS !!!!!!!!!!!!!! EgtOutLog("ProcessStart : " & """" & m_sCNSiemensHMIPath & """" & " " & sArg) - KillSimensCom(m_sCNSiemensHMIPath) + KillSiemensCom(m_sCNSiemensHMIPath) Process.Start(m_sCNSiemensHMIPath, sArg) ' !!!!!!!!!!!!!! FORZO LA SIMULAZIONE DELLA LETTURA DELLE VARIBILI E SIEMENS !!!!!!!!!!!!!! @@ -680,7 +686,7 @@ Public Class CNCommunication Next ' Attraverso la funzione "RefreshNoEvents" rileggo i dati caricati - ' Recupero il perocorso delle variabili PLC + ' Recupero il percorso delle variabili PLC GetPrivateProfileString(S_NCSIEMENS, K_DBVARPATH, "", m_CN.m_DbVarPath, m_MainWindow.GetMachIniFile) ElseIf m_CN.m_IsActiveModeSubscription Then @@ -1605,7 +1611,7 @@ Public Class CNCommunication Else sNumProg = nNumProg.ToString() End If - ' Se Fanuc con trasmissione speciale come copia + ' Se Fanuc con trasmissione speciale come copia in un direttorio opportuno If m_nNCType = 4 AndAlso m_nSpecialSend = 1 AndAlso m_nSpecialAreas = 0 Then bOk = SpecialSendCopyProgram(sCncPath) If bOk Then @@ -1628,6 +1634,10 @@ Public Class CNCommunication End If ' Attesa opportuna System.Threading.Thread.Sleep(m_MainWindow.m_CurrentMachine.nResetSendDelay) + ' Se modalità invio a step per debug di Siemens + If m_bStepByStepSend And m_nNCType = 3 Then + MessageBox.Show( "Reset Done, Press Ok to Continue", "Send Program Step by Step") + End If If m_nNCType = 1 Then ' Cancellazione eventuale file già presente con lo stesso nome (ignoro eventuale errore) EgtOutLog("Delete_NC_prog(sNumProg)") @@ -1653,6 +1663,10 @@ Public Class CNCommunication bOk = bOk AndAlso (m_CN.Download_NC_prog(sCncPath, sNumProg) = 0) ' Attesa opportuna System.Threading.Thread.Sleep(100) + ' Se modalità invio a step per debug di Siemens + If m_bStepByStepSend And m_nNCType = 3 Then + MessageBox.Show( "Download NC Prog Done, Press Ok to Continue", "Send Program Step by Step") + End If ' FANUC: genero un file 901 vuoto da spedire, attivare; poi rispedisco il file 900 If m_nNCType = 4 And Not bOk Then bOk = True @@ -1694,10 +1708,18 @@ Public Class CNCommunication EgtOutLog(TimeSpanEnd()) ' Attesa opportuna System.Threading.Thread.Sleep(100) + ' Se modalità invio a step per debug di Siemens + If m_bStepByStepSend And m_nNCType = 3 Then + MessageBox.Show( "ActivateProgram Done, Press Ok to Continue", "Send Program Step by Step") + End If ' Attivo la modalità AUTO prima per preparare il cyclo start bOk = bOk AndAlso (m_CN.DGeneralFunctions_WriteCncMode(0) = 0) ' Attesa opportuna System.Threading.Thread.Sleep(100) + ' Se modalità invio a step per debug di Siemens + If m_bStepByStepSend And m_nNCType = 3 Then + MessageBox.Show( "AUTO Mode Setting Done, Press Ok to Continue", "Send Program Step by Step") + End If ' Modalità automatica EgtOutLog("DGeneralFunctions_WriteCncMode(0)") TimeSpanInit() @@ -1790,9 +1812,9 @@ Public Class CNCommunication ' Solo per Fanuc If m_nNCType <> 4 Then Return False ' Creo path destinazione - Dim sDestProg As String = m_CurrProjPage.GetCurrentProjectTitle() - Dim sDestPath As String = m_sSpecialDest & "\" & sDestProg & ".cnc" Try + Dim sDestProg As String = m_CurrProjPage.GetCurrentProjectTitle() & ".cnc" + Dim sDestPath As String = My.Computer.FileSystem.CombinePath(m_sSpecialDest, sDestProg) My.Computer.FileSystem.CopyFile(sz_PC_filename, sDestPath, True) Catch ex As Exception Return False diff --git a/Project/CurrentProjectPageUC.xaml.vb b/Project/CurrentProjectPageUC.xaml.vb index abf0f55..99a2258 100644 --- a/Project/CurrentProjectPageUC.xaml.vb +++ b/Project/CurrentProjectPageUC.xaml.vb @@ -839,9 +839,9 @@ Public Class CurrentProjectPageUC End Function Friend Function GetCurrentProjectTitle() As String - Dim CurrProjName As String = String.Empty + Dim CurrProjName As String = "" GetPrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, "", CurrProjName, m_MainWindow.GetIniFile()) - If String.IsNullOrEmpty(CurrProjName) Then + If String.IsNullOrWhiteSpace(CurrProjName) Then CurrProjName = Math.Abs(m_nCurrProj).ToString("D4") End If Return CurrProjName