OmagCUT 2.7h3 :
- aggiunta gestione SpecialSend per macchine multitavola (Mega5) con controllo FANUC.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
Public Const S_NUMERICALCONTROL As String = "NumericalControl"
|
||||
Public Const K_TYPE As String = "Type"
|
||||
Public Const K_SPECIALSEND As String = "SpecialSend"
|
||||
|
||||
Public Const S_PARTPROGRAM As String = "PartProgram"
|
||||
Public Const K_EXTENSION As String = "Extension"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="7.5*"/>
|
||||
<ColumnDefinition Width="1.5*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
<ColumnDefinition Width="5*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -103,7 +103,7 @@
|
||||
|
||||
<GroupBox Name="PartProgTransferGpBx"
|
||||
Style="{DynamicResource OmagCut_GroupBox}" Grid.Row="2"
|
||||
Grid.ColumnSpan="3">
|
||||
Grid.ColumnSpan="2">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
@@ -127,9 +127,16 @@
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Name="SpecialSendGpBx" Style="{DynamicResource OmagCut_GroupBox}" Grid.Row="2"
|
||||
Grid.Column="2" Grid.ColumnSpan="1" Margin="5,0,5,0">
|
||||
<CheckBox Name="SpecialSendChBx"
|
||||
Style="{DynamicResource OmagCut_CheckBox_Single}"
|
||||
HorizontalAlignment="Center" Margin="0,0,0,0"/>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Name="PowerGpBx" Style="{DynamicResource OmagCut_GroupBox}" Grid.Row="2"
|
||||
Grid.Column="3" Grid.ColumnSpan="3" Margin="5,0,0,0">
|
||||
<Grid>
|
||||
Grid.Column="3" Grid.ColumnSpan="1" Margin="5,0,0,0">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
|
||||
@@ -37,6 +37,16 @@ Public Class MachineCNPageUC
|
||||
PartProgTransferGpBx.Visibility = Windows.Visibility.Hidden
|
||||
End If
|
||||
|
||||
' Se prevista, scelta invio speciale part program
|
||||
Dim nSpecialSend As Integer = GetPrivateProfileInt(S_NUMERICALCONTROL, K_SPECIALSEND, -1, m_MainWindow.GetMachIniFile())
|
||||
If nSpecialSend <> -1 Then
|
||||
SpecialSendChBx.IsChecked() = (nSpecialSend = 1)
|
||||
SpecialSendGpBx.Header = "Special Send"
|
||||
SpecialSendGpBx.Visibility = Visibility.Visible
|
||||
else
|
||||
SpecialSendGpBx.Visibility = Visibility.Collapsed
|
||||
End If
|
||||
|
||||
' nuovi pulsanti
|
||||
If GetPrivateProfileInt(S_NCDATA, K_NEWCONSOLE, 0, m_MainWindow.GetMachIniFile()) = 1 Then
|
||||
PowerONBtn.Content = "ON"
|
||||
@@ -85,7 +95,7 @@ Public Class MachineCNPageUC
|
||||
Dim m_nCount As Integer = 1
|
||||
Dim bFoundBtn As Boolean = True
|
||||
Dim sTestVal As String = String.Empty
|
||||
' se non trovo il primo pulsante della lista allora nascondo l'elenco dei pulasnti per accensione
|
||||
' se non trovo il primo pulsante della lista allora nascondo l'elenco dei pulsanti per accensione
|
||||
If GetPrivateProfileString("MachineButtons", K_BUTTON & "1", "", sTestVal, m_MainWindow.GetMachIniFile()) = 0 Then
|
||||
PowerGpBx.Visibility = Visibility.Collapsed
|
||||
Return
|
||||
@@ -323,6 +333,10 @@ Public Class MachineCNPageUC
|
||||
MDITxBx.Background = Brushes.LightGray
|
||||
End Sub
|
||||
|
||||
Private Sub SpecialSend_Click(sender As Object, e As RoutedEventArgs) Handles SpecialSendChBx.Click
|
||||
m_MainWindow.m_CNCommunication.SpecialSend() = If( SpecialSendChBx.IsChecked(), 1, 0)
|
||||
End Sub
|
||||
|
||||
Private Sub PowerON_Click(sender As Object, e As RoutedEventArgs) Handles PowerONBtn.Click
|
||||
Dim PowerOnButton As MachineButton = m_ButtonPower(0)
|
||||
' eseguo lo script lua associato
|
||||
|
||||
@@ -62,5 +62,5 @@ Imports System.Windows
|
||||
' by using the '*' as shown below:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("2.7.9.2")>
|
||||
<Assembly: AssemblyFileVersion("2.7.9.2")>
|
||||
<Assembly: AssemblyVersion("2.7.9.3")>
|
||||
<Assembly: AssemblyFileVersion("2.7.9.3")>
|
||||
|
||||
+107
-33
@@ -20,6 +20,21 @@ Public Class CNCommunication
|
||||
' Variabile per tipologia CN
|
||||
Friend m_nNCType As Integer
|
||||
|
||||
' Modalità speciale invio programmi (attualmente solo per Fanuc, fino a 4 programmi)
|
||||
Private m_nSpecialSend As Integer = -1
|
||||
Friend Property SpecialSend As Integer
|
||||
Get
|
||||
Return m_nSpecialSend
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
value = Math.Max( Math.Min( value, 1), -1)
|
||||
If value <> m_nSpecialSend Then
|
||||
m_nSpecialSend = value
|
||||
WritePrivateProfileString( S_NUMERICALCONTROL, K_SPECIALSEND, value.ToString(), m_MainWindow.GetMachIniFile())
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
' Variabile che indica il Mode corrente
|
||||
Private m_nCurrMode As Integer = -1
|
||||
|
||||
@@ -98,6 +113,10 @@ Public Class CNCommunication
|
||||
|
||||
EgtOutLog("NcLink=" & m_MainWindow.m_bNCLink.ToString & " type=" & m_nNCType)
|
||||
|
||||
' 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)
|
||||
|
||||
' Se CN Siemens leggo dati programma intermedio di comunicazione
|
||||
If m_nNCType = 3 Then
|
||||
Dim sExeName As String = String.Empty
|
||||
@@ -1183,7 +1202,7 @@ Public Class CNCommunication
|
||||
'Laser = 16384
|
||||
End Enum
|
||||
|
||||
#Region "MASCHERA per conttrollo Bit a Bit"
|
||||
#Region "MASCHERA per controllo Bit a Bit"
|
||||
<Flags()>
|
||||
Public Enum Mask As Integer
|
||||
bit_Err = -1
|
||||
@@ -1568,10 +1587,6 @@ Public Class CNCommunication
|
||||
Optional bActivate As Boolean = True) As Boolean
|
||||
Dim bOk As Boolean = True
|
||||
|
||||
' !!!!!!!!!!!!!!!!!! FORZO IL PROGRAMMA !!!!!!!!!!!!!!!!!!
|
||||
' m_nNCType = 2
|
||||
' !!!!!!!!!!!!!!!!!! FORZO IL PROGRAMMA !!!!!!!!!!!!!!!!!!
|
||||
|
||||
' Download programma
|
||||
If m_MainWindow.m_bNCLink Then
|
||||
bOk = (m_nNCType > 0)
|
||||
@@ -1582,6 +1597,10 @@ Public Class CNCommunication
|
||||
Else
|
||||
sNumProg = nNumProg.ToString()
|
||||
End If
|
||||
' Se Fanuc con trasmissione speciale, disabilito attivazione
|
||||
If m_nNCType = 4 AndAlso m_nSpecialSend = 1 Then
|
||||
bActivate = False
|
||||
End If
|
||||
' Se richiesta successiva attivazione, faccio reset
|
||||
If bActivate Then
|
||||
EgtOutLog("Call function: DGeneralFunctions_Reset")
|
||||
@@ -1600,42 +1619,47 @@ Public Class CNCommunication
|
||||
' Attesa opportuna
|
||||
System.Threading.Thread.Sleep(100)
|
||||
ElseIf m_nNCType = 4 Then
|
||||
' FANUC: imposto modalità EDIT
|
||||
bOk = bOk AndAlso (m_CN.DGeneralFunctions_WriteCncMode(1) = 0)
|
||||
' Attesa opportuna
|
||||
System.Threading.Thread.Sleep(m_MainWindow.m_CurrentMachine.nThreadSleep)
|
||||
' FANUC: imposto modalità EDIT se non special send
|
||||
If m_nSpecialSend <> 1 Then
|
||||
bOk = bOk AndAlso (m_CN.DGeneralFunctions_WriteCncMode(1) = 0)
|
||||
' Attesa opportuna
|
||||
System.Threading.Thread.Sleep(m_MainWindow.m_CurrentMachine.nThreadSleep)
|
||||
End If
|
||||
End If
|
||||
EgtOutLog("Download_NC_prog(" & sCncPath & ", " & sNumProg.ToString & ")")
|
||||
' -------------- START DOWNLOAD --------------
|
||||
TimeSpanInit()
|
||||
bOk = bOk AndAlso (m_CN.Download_NC_prog(sCncPath, sNumProg) = 0)
|
||||
' Attesa opportuna
|
||||
System.Threading.Thread.Sleep(100)
|
||||
' FANUC: genero un file 901 vuoto da aspedire, attivare; poi rispedisco il file 900
|
||||
If m_nNCType = 4 And Not bOk Then
|
||||
bOk = True
|
||||
Dim sCncPath1 As String = m_MainWindow.GetCncDir() & "\PlaceHolder" & m_MainWindow.m_CurrentMachine.sIsoFileExt
|
||||
Dim fs As FileStream = File.Create(sCncPath1)
|
||||
' Add text to the file.
|
||||
Dim info As Byte() = New UTF8Encoding(True).GetBytes(vbLf & "(PlaceHolder)")
|
||||
fs.Write(info, 0, info.Length)
|
||||
fs.Close()
|
||||
bOk = bOk AndAlso (m_CN.Download_NC_prog(sCncPath1, "901") = 0)
|
||||
If m_nNCType = 4 AndAlso m_nSpecialSend = 1 Then
|
||||
bOk = bOk AndAlso SpecialSendProgram(sCncPath, sNumProg)
|
||||
Else
|
||||
bOk = bOk AndAlso (m_CN.Download_NC_prog(sCncPath, sNumProg) = 0)
|
||||
' Attesa opportuna
|
||||
System.Threading.Thread.Sleep(m_MainWindow.m_CurrentMachine.nThreadSleep)
|
||||
If bActivate Then
|
||||
bOk = bOk AndAlso (m_CN.ActivateProgram("901") = 0)
|
||||
System.Threading.Thread.Sleep(100)
|
||||
' FANUC: genero un file 901 vuoto da spedire, attivare; poi rispedisco il file 900
|
||||
If m_nNCType = 4 And Not bOk Then
|
||||
bOk = True
|
||||
Dim sCncPath1 As String = m_MainWindow.GetCncDir() & "\PlaceHolder" & m_MainWindow.m_CurrentMachine.sIsoFileExt
|
||||
Dim fs As FileStream = File.Create(sCncPath1)
|
||||
' Add text to the file.
|
||||
Dim info As Byte() = New UTF8Encoding(True).GetBytes(vbLf & "(PlaceHolder)")
|
||||
fs.Write(info, 0, info.Length)
|
||||
fs.Close()
|
||||
bOk = bOk AndAlso (m_CN.Download_NC_prog(sCncPath1, "901") = 0)
|
||||
' Attesa opportuna
|
||||
System.Threading.Thread.Sleep(m_MainWindow.m_CurrentMachine.nThreadSleep)
|
||||
If bActivate Then
|
||||
bOk = bOk AndAlso (m_CN.ActivateProgram("901") = 0)
|
||||
' Attesa opportuna
|
||||
System.Threading.Thread.Sleep(m_MainWindow.m_CurrentMachine.nThreadSleep)
|
||||
End If
|
||||
' riprovo ad eseguire il programma 900
|
||||
bOk = True
|
||||
bOk = bOk AndAlso (m_CN.Download_NC_prog(sCncPath, sNumProg) = 0)
|
||||
' Attesa opportuna
|
||||
System.Threading.Thread.Sleep(m_MainWindow.m_CurrentMachine.nThreadSleep)
|
||||
End If
|
||||
' riprovo ad eseguire il programma 900
|
||||
bOk = True
|
||||
bOk = bOk AndAlso (m_CN.Download_NC_prog(sCncPath, sNumProg) = 0)
|
||||
' Attesa opportuna
|
||||
System.Threading.Thread.Sleep(m_MainWindow.m_CurrentMachine.nThreadSleep)
|
||||
End If
|
||||
EgtOutLog("Nc Type : " & m_nNCType.ToString)
|
||||
' AXIUM (NUM OLD): se DripFeed non esegluo attivazione programma)
|
||||
' AXIUM (NUM OLD): se DripFeed non eseguo attivazione programma)
|
||||
If m_nNCType = 1 AndAlso m_CN.bIsDripFeed Then
|
||||
' eventauli cambi di stato sono trattati all'interno della funzione DownLoad_NC_prog
|
||||
Return True
|
||||
@@ -1652,7 +1676,7 @@ Public Class CNCommunication
|
||||
EgtOutLog(TimeSpanEnd())
|
||||
' Attesa opportuna
|
||||
System.Threading.Thread.Sleep(100)
|
||||
' Attivo la modalità AUTO prima per preparar il cyclo start
|
||||
' 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)
|
||||
@@ -1675,6 +1699,56 @@ Public Class CNCommunication
|
||||
Return bOk
|
||||
End Function
|
||||
|
||||
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 4 aree consecutive (901, 902, 903 e 904)
|
||||
For I As Integer = 1 To 4
|
||||
' 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
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Private Sub GetSpecialCAxes()
|
||||
If m_CN.bCPos Then
|
||||
m_CN.d_axis_position(m_nA4) = m_CN.dCPos
|
||||
|
||||
+5
-1
@@ -1372,7 +1372,11 @@ Module M_Fanuc
|
||||
FileOpen(nFilew, szFileProgramma, OpenMode.Output)
|
||||
|
||||
' PrintLine(nFilew, "%" & vbLf & "<" & NomeSend & ">") ' !!!!!!!! da spostare
|
||||
PrintLine(nFilew, vbLf & "<" & NomeSend & ">") ' !!
|
||||
If NomeSend.StartsWith( "O") Then
|
||||
PrintLine(nFilew, vbLf & NomeSend) ' !!
|
||||
Else
|
||||
PrintLine(nFilew, vbLf & "<" & NomeSend & ">") ' !!
|
||||
End If
|
||||
|
||||
'trascrivo file tranne prima linea
|
||||
While (Not EOF(nFiler))
|
||||
|
||||
@@ -766,7 +766,8 @@ Public Class ProjectMgrUC
|
||||
End If
|
||||
|
||||
'------------------- INIZIO Avvio il Ciclo-Start-------------------------
|
||||
If GetPrivateProfileInt(S_GENERAL, K_STARTPROGRAM, 0, m_MainWindow.GetIniFile()) <> 0 Then
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user