|
|
|
@@ -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
|
|
|
|
|