OmagCUT :

- con Fanuc SpecialSend aggiunta possibilità di configurazione del direttorio destinazione da INI macchina.
This commit is contained in:
Dario Sassi
2025-10-29 12:23:09 +01:00
parent 8436250574
commit 908cc381db
6 changed files with 96 additions and 43 deletions
+1
View File
@@ -4,6 +4,7 @@
Public Const K_TYPE As String = "Type"
Public Const K_SPECIALSEND As String = "SpecialSend"
Public Const K_SPECIALAREAS As String = "SpecialAreas"
Public Const K_SPECIALDEST As String = "SpecialDest"
Public Const S_PARTPROGRAM As String = "PartProgram"
Public Const K_EXTENSION As String = "Extension"
+63 -41
View File
@@ -35,6 +35,7 @@ Public Class CNCommunication
End Set
End Property
Private m_nSpecialAreas As Integer = 4
Private m_sSpecialDest As String = ""
' Variabile che indica il Mode corrente
Private m_nCurrMode As Integer = -1
@@ -120,6 +121,8 @@ Public Class CNCommunication
' Leggo numero di aree per invio speciale
Dim nTemp2 As Integer = GetPrivateProfileInt(S_NUMERICALCONTROL, K_SPECIALAREAS, 4, m_MainWindow.GetMachIniFile())
m_nSpecialAreas = Math.Max( Math.Min( nTemp2, 16), 1)
' Leggo il direttorio di destinazione (se Fanuc data server è "//DATA_SV/PROGRAM_DS/")
GetPrivateProfileString(S_NUMERICALCONTROL, K_SPECIALDEST, "", m_sSpecialDest, m_MainWindow.GetMachIniFile())
' Se CN Siemens leggo dati programma intermedio di comunicazione
If m_nNCType = 3 Then
@@ -1706,51 +1709,70 @@ Public Class CNCommunication
Private Function SpecialSendProgram(sz_PC_filename As String, sz_NC_filename As String) As Boolean
' Solo per Fanuc
If m_nNCType <> 4 Then Return False
' Indice base
Dim nBase As Integer = 900
' Ho possibilità di trasmettere in più aree consecutive (901, 902, ...)
For I As Integer = 1 To m_nSpecialAreas
' Leggo la variabile semaforo dell'area I-esima
Dim nVal As Integer = -1
Dim sVar As String = "#" & (nBase + I).ToString()
EgtOutLog( "IndVar=" & sVar)
For J As Integer = 1 To 20
' Devo rileggere la variabile ad ogni ciclo
m_CN.ReadEls_Add_Parameter(sVar, 3)
' Nuova modalità con nome di programma come progetto
If Not String.IsNullOrEmpty( m_sSpecialDest) Then
Dim sDestProg As String = m_CurrProjPage.GetCurrentProjectTitle().ToUpperInvariant()
' Eseguo trasmissione
Dim bOk As Boolean = ( m_CN.Download2_NC_prog(sz_PC_filename, m_sSpecialDest, sDestProg) = 0)
System.Threading.Thread.Sleep(100)
EgtOutLog( "Send2Result=" & bOk.ToString())
' Se non riuscita riprovo
If Not bOk Then
bOk = ( m_CN.Download2_NC_prog(sz_PC_filename, m_sSpecialDest, sDestProg) = 0)
System.Threading.Thread.Sleep(100)
If m_CN.n_DReadELS_handle = 3 Then
nVal = CInt(m_MainWindow.m_CNCommunication.m_CN.d_DReadELS_value)
EgtOutLog( "Value=" & nVal.ToString())
If nVal <> -1 Then
Exit For
EgtOutLog( "SecondSend2Result=" & bOk.ToString())
End If
Return bOk
' Vecchia modalità con numero di programma
Else
' Indice base
Dim nBase As Integer = 900
' Ho possibilità di trasmettere in più aree consecutive (901, 902, ...)
For I As Integer = 1 To m_nSpecialAreas
' Leggo la variabile semaforo dell'area I-esima
Dim nVal As Integer = -1
Dim sVar As String = "#" & (nBase + I).ToString()
EgtOutLog( "IndVar=" & sVar)
For J As Integer = 1 To 20
' Devo rileggere la variabile ad ogni ciclo
m_CN.ReadEls_Add_Parameter(sVar, 3)
System.Threading.Thread.Sleep(100)
If m_CN.n_DReadELS_handle = 3 Then
nVal = CInt(m_MainWindow.m_CNCommunication.m_CN.d_DReadELS_value)
EgtOutLog( "Value=" & nVal.ToString())
If nVal <> -1 Then
Exit For
End If
End If
Next
' Se posso trasmettere
If nVal = 0 Then
' Assegno numero di programma
Dim sNumProg As String = "O0" & ( nBase + I).ToString()
EgtOutLog( "NumProg=" & sNumProg)
' Eseguo trasmissione
Dim bOk As Boolean = ( m_CN.Download_NC_prog(sz_PC_filename, sNumProg) = 0)
System.Threading.Thread.Sleep(100)
EgtOutLog( "SendResult=" & bOk.ToString())
' Se non riuscita riprovo
If Not bOk Then
bOk = ( m_CN.Download_NC_prog(sz_PC_filename, sNumProg) = 0)
System.Threading.Thread.Sleep(100)
EgtOutLog( "SecondSendResult=" & bOk.ToString())
End If
' Se andata a buon fine
If bOk Then
' Dichiaro programma trasmesso
m_MainWindow.m_CNCommunication.m_CN.DVariables_WriteVariables2(sVar, "1")
System.Threading.Thread.Sleep(100)
Return True
End If
End If
Next
' Se posso trasmettere
If nVal = 0 Then
' Assegno numero di programma
Dim sNumProg As String = "O0" & ( nBase + I).ToString()
EgtOutLog( "NumProg=" & sNumProg)
' Eseguo trasmissione
Dim bOk As Boolean = ( m_CN.Download_NC_prog(sz_PC_filename, sNumProg) = 0)
System.Threading.Thread.Sleep(100)
EgtOutLog( "SendResult=" & bOk.ToString())
' Se non riuscita riprovo
If Not bOk Then
bOk = ( m_CN.Download_NC_prog(sz_PC_filename, sNumProg) = 0)
System.Threading.Thread.Sleep(100)
EgtOutLog( "SecondSendResult=" & bOk.ToString())
End If
' Se andata a buon fine
If bOk Then
' Dichiaro programma trasmesso
m_MainWindow.m_CNCommunication.m_CN.DVariables_WriteVariables2(sVar, "1")
System.Threading.Thread.Sleep(100)
Return True
End If
End If
Next
Return False
Return False
End If
End Function
Private Sub GetSpecialCAxes()
+4
View File
@@ -327,6 +327,10 @@ Public MustInherit Class CN_generico
Public MustOverride Function Write_var_1(sz_par As String, lvalue As Long) As Int16
Public MustOverride Function Download_NC_prog(sz_PC_filename As String, sz_NC_filename As String) As Int16
Public Overridable Function Download2_NC_prog(sz_PC_filename As String, sz_NC_Dir As String, sz_NC_filename As String) As Int16
Return -1
End Function
Public MustOverride Function Upload_NC_prog(sz_PC_filename As String, sz_NC_filename As String) As Int16
+6 -2
View File
@@ -1018,7 +1018,7 @@ Module M_Fanuc
Function Send_file_to_nc(ByVal szFileToSend As String, ByVal szDirCn As String, ByVal szNameOnNc As String) As Boolean
Dim szNamePrgCopy As String
Dim szProgramDel As String = szDirCn & "\" & szNameOnNc
Dim szProgramDel As String
Dim b_ret As Boolean = False
If File.Exists(szFileToSend) Then
@@ -1026,7 +1026,11 @@ Module M_Fanuc
szNamePrgCopy = InserisciNome(szFileToSend, szNameOnNc) ' correct name inserting for Fanuc 30 series Dim szProgramDel As String = szDirCn & "\" & szNameOnNc
If szDirCn <> "" Then
szProgramDel = szDirCn & "\" & szNameOnNc
If szDirCn.EndsWith( "/") Then
szProgramDel = szDirCn & szNameOnNc
Else
szProgramDel = szDirCn & "/" & szNameOnNc
End If
Else
szProgramDel = szNameOnNc
End If
+14
View File
@@ -368,6 +368,20 @@ Namespace Fanuc
Return n_ret
End Function
'
' da PC a CN con la possibilita' di specificare il direttorio sul CN
'
Public Overrides Function Download2_NC_prog(sz_PC_filename As String, sz_NC_Dir As String, sz_NC_filename As String) As Int16
Dim b_ret As Boolean, n_ret As Short = -99
b_ret = M_Fanuc.Send_file_to_nc(sz_PC_filename, sz_NC_Dir, sz_NC_filename)
If b_ret Then Return 0
Return n_ret
End Function
'
' da CN a pc
+8
View File
@@ -835,6 +835,14 @@ Public Class CurrentProjectPageUC
Friend Function GetCurrentProject() As Integer
Return m_nCurrProj
End Function
Friend Function GetCurrentProjectTitle() As String
Dim CurrProjName As String = String.Empty
GetPrivateProfileString(S_GENERAL, K_LASTNAMEPROJ, "", CurrProjName, m_MainWindow.GetIniFile())
If String.IsNullOrEmpty(CurrProjName) Then
CurrProjName = Math.Abs(m_nCurrProj).ToString("D4")
End If
Return CurrProjName
End Function
Friend Function GetCurrentProjectName() As String
Dim CurrProjName As String = String.Empty