OmagCUT :
- aggiungo file dimenticato.
This commit is contained in:
@@ -0,0 +1,287 @@
|
||||
Imports EgtUILib.EgtInterface
|
||||
|
||||
Module VarMdiCommand
|
||||
|
||||
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
||||
|
||||
Public Sub ExecuteMDICommand(sLuaFileName As String)
|
||||
|
||||
' Verifica esistenza pagina DirectCut e ne recupero CN corrente
|
||||
If IsNothing( m_MainWindow.m_DirectCutPageUC) Then Return
|
||||
Dim CurrCN As CN_generico = m_MainWindow.m_DirectCutPageUC.m_CN
|
||||
|
||||
' Verifico esistenza nome script lua
|
||||
If String.IsNullOrWhiteSpace(sLuaFileName) Then Return
|
||||
|
||||
' Eseguo script
|
||||
Dim CmdString As String = String.Empty
|
||||
Dim b2Start As Boolean = False
|
||||
Dim bEActive As Boolean = False
|
||||
Dim sENumber As String = String.Empty
|
||||
Dim sEValue As String = String.Empty
|
||||
Dim sEType As String = 0
|
||||
Dim sENumber2 As String = String.Empty
|
||||
Dim sEValue2 As String = String.Empty
|
||||
Dim sEType2 As String = 0
|
||||
If Not ExecDirectCmdLua(sLuaFileName, CmdString, b2Start, bEActive, sENumber, sEValue, sEType, sENumber2, sEValue2, sEType2) Then
|
||||
Return
|
||||
End If
|
||||
|
||||
' Se richiesta scrittura variabili
|
||||
If bEActive Then
|
||||
Select Case m_MainWindow.m_CNCommunication.m_nNCType
|
||||
Case 1, 2 ' Num Axium e Flexium
|
||||
' se Flexium e abilitata scrittura variabili PLC
|
||||
If m_MainWindow.m_CNCommunication.m_nNCType = 2 And CurrCN.m_NewVariable Then
|
||||
CurrCN.DPlcVariables_WriteVariables(sENumber, sEValue)
|
||||
If Not String.IsNullOrWhiteSpace(sENumber2) AndAlso Not String.IsNullOrWhiteSpace(sEValue2) Then
|
||||
CurrCN.DPlcVariables_WriteVariables(sENumber2, sEValue2)
|
||||
End If
|
||||
' altrimenti scrittura della variabile E
|
||||
Else
|
||||
CurrCN.DVariables_WriteVariables2(sENumber, sEValue)
|
||||
End If
|
||||
Return
|
||||
Case 3 ' Siemens
|
||||
' Scrivo prima variabile
|
||||
Dim nEType As Integer = 0
|
||||
StringToInt( sEType, nEType)
|
||||
Select Case nEType
|
||||
Case 1
|
||||
Dim nEvalue As Integer = 0
|
||||
StringToInt( sEvalue, nEvalue)
|
||||
CurrCN.DVariables_WriteVariables3(sENumber, 1, nEValue, 0, 0, "")
|
||||
EgtOutLog("ENumber=" & sENumber & " EType=1 " & " EValue=" & nEValue.ToString())
|
||||
Case 2
|
||||
Dim lEvalue As Long = 0
|
||||
Long.TryParse(sEValue, lEvalue)
|
||||
CurrCN.DVariables_WriteVariables3(sENumber, 2, 0, lEvalue, 0, "")
|
||||
EgtOutLog("ENumber=" & sENumber & " EType=2 " & " EValue=" & lEvalue.ToString())
|
||||
Case 3
|
||||
Dim dEValue As Double = 0
|
||||
StringToDouble(sEValue, dEValue)
|
||||
CurrCN.DVariables_WriteVariables3(sENumber, 3, 0, 0, dEValue, "")
|
||||
EgtOutLog("ENumber=" & sENumber & " EType=3 " & " EValue=" & dEValue.ToString())
|
||||
Case 4
|
||||
CurrCN.DVariables_WriteVariables3(sENumber, 4, 0, 0, 0, sEValue)
|
||||
EgtOutLog("ENumber=" & sENumber & " EType=4 " & " EValue=" & sEValue)
|
||||
Case Else
|
||||
EgtOutLog("EType wrong : ENumber=" & sENumber & " EType=" & sEType & " EValue= " & sEValue)
|
||||
End Select
|
||||
If Not String.IsNullOrWhiteSpace(sEType2) AndAlso sEType2 <> "0" Then
|
||||
' Pausa
|
||||
System.Threading.Thread.Sleep(100)
|
||||
' Scrivo seconda variabile
|
||||
Dim nEType2 As Integer = 0
|
||||
StringToInt( sEType2, nEType2)
|
||||
Select Case nEType2
|
||||
Case 1
|
||||
Dim nEvalue2 As Integer = 0
|
||||
StringToInt( sEvalue2, nEvalue2)
|
||||
CurrCN.DVariables_WriteVariables3(sENumber2, 1, nEValue2, 0, 0, "")
|
||||
EgtOutLog("ENumber2=" & sENumber2 & " EType2=1" & " EValue2=" & nEValue2.ToString())
|
||||
Case 2
|
||||
Dim lEvalue2 As Long = 0
|
||||
Long.TryParse(sEValue2, lEvalue2)
|
||||
CurrCN.DVariables_WriteVariables3(sENumber2, 2, 0, lEValue2, 0, "")
|
||||
EgtOutLog("ENumber2=" & sENumber2 & " EType2=2" & " EValue2=" & lEValue2.ToString())
|
||||
Case 3
|
||||
Dim dEValue2 As Double = 0
|
||||
StringToDouble(sEValue2, dEValue2)
|
||||
CurrCN.DVariables_WriteVariables3(sENumber2, 3, 0, 0, dEValue2, "")
|
||||
EgtOutLog("ENumber2=" & sENumber2 & " EType2=3" & " EValue2=" & dEValue2.ToString())
|
||||
Case 4
|
||||
CurrCN.DVariables_WriteVariables3(sENumber2, 4, 0, 0, 0, sEValue2)
|
||||
EgtOutLog("ENumber2=" & sENumber2 & " EType2=4" & " EValue2=" & sEValue2)
|
||||
Case Else
|
||||
EgtOutLog("EType2 wrong : ENumber2=" & sENumber2 & " EType2=" & sEType2 & " EValue2=" & sEValue2)
|
||||
End Select
|
||||
End If
|
||||
Return
|
||||
Case 4 ' Fanuc
|
||||
' eventuale scrittura di linea di comando MDI
|
||||
If Not String.IsNullOrWhiteSpace(CmdString) Then
|
||||
' attivo mpdalità MDI
|
||||
CurrCN.DGeneralFunctions_WriteCncMode(2)
|
||||
System.Threading.Thread.Sleep(100)
|
||||
' salvo la stringa di comando ricevuta dal file lua
|
||||
CurrCN.sz_ManualDataInput = CmdString
|
||||
' esguo la funzione che ha il compito di scrivere il comando MDI
|
||||
CurrCN.MDI_command()
|
||||
End If
|
||||
' attivo modalità Manuale
|
||||
CurrCN.DGeneralFunctions_WriteCncMode(7)
|
||||
System.Threading.Thread.Sleep(100)
|
||||
If String.IsNullOrWhiteSpace(sEValue) Then
|
||||
' EActive: impulsivo "D#####"
|
||||
CurrCN.NC_pulse_bit(sENumber)
|
||||
EgtOutLog("Fanuc : DNumber=" & sENumber)
|
||||
Else
|
||||
' EActive + EValue: scrittura comando invariabile Short oppure Bit
|
||||
If sENumber.Contains(".") Then
|
||||
' D#####.#
|
||||
Dim bEValue As Boolean
|
||||
If sEValue.Trim = "0" Then bEValue = False
|
||||
CurrCN.NC_write_var_bit(sENumber, bEValue)
|
||||
Else
|
||||
' D#####
|
||||
CurrCN.NC_write_var_short(sENumber, CShort(sEValue))
|
||||
End If
|
||||
EgtOutLog("Fanuc : DNumber=" & sENumber & " DValue=" & sEValue)
|
||||
End If
|
||||
' eventale caricamento seconda variabile
|
||||
If String.IsNullOrWhiteSpace(sEValue2) Then
|
||||
' EActive: impulsivo "D#####"
|
||||
CurrCN.NC_pulse_bit(sENumber2)
|
||||
EgtOutLog("Fanuc : DNumber2=" & sENumber2)
|
||||
Else
|
||||
' EActive + EValue: scrittura comando invariabile Short oppure Bit
|
||||
If sENumber2.Contains(".") Then
|
||||
' D#####.#
|
||||
Dim bEValue2 As Boolean
|
||||
If sEValue2.Trim = "0" Then bEValue2 = False
|
||||
CurrCN.NC_write_var_bit(sENumber2, bEValue2)
|
||||
Else
|
||||
' D#####
|
||||
CurrCN.NC_write_var_short(sENumber2, CShort(sEValue2))
|
||||
End If
|
||||
EgtOutLog("Fanuc : DNumber2=" & sENumber2 & " DValue2=" & sEValue2)
|
||||
End If
|
||||
Return
|
||||
Case Else ' Demo
|
||||
EgtOutLog("Demo : ENumber=" & sENumber & " EType=" & sEType & " EValue=" & sEValue)
|
||||
EgtOutLog("Demo : ENumber2=" & sENumber2 & " EType2=" & sEType2 & " EValue2=" & sEValue2)
|
||||
Return
|
||||
End Select
|
||||
End If
|
||||
|
||||
' Esecuzione comando MDI
|
||||
Dim nResult As Short
|
||||
' assegno la modalità di funzionamento
|
||||
Select Case m_MainWindow.m_CNCommunication.m_nNCType
|
||||
Case 1, 2, 4
|
||||
nResult = CurrCN.DGeneralFunctions_WriteCncMode(2) ' Modalità MDI per controlli num
|
||||
Case 3
|
||||
'Per Siemens non devo fare nulla
|
||||
End Select
|
||||
' salvo la stringa di comando ricevuta dal file lua
|
||||
CurrCN.sz_ManualDataInput = CmdString
|
||||
' esguo la funzione che ha il compito di scrivere il comando MDI
|
||||
CurrCN.MDI_command()
|
||||
' avvio l'esecuzione del comando
|
||||
Select Case m_MainWindow.m_CNCommunication.m_nNCType
|
||||
Case 1, 2
|
||||
System.Threading.Thread.Sleep(500)
|
||||
CurrCN.DGeneralFunctions_CycleStart()
|
||||
Case 3, 4
|
||||
'Per Siemens e Fanuc non devo fare nulla
|
||||
End Select
|
||||
' se richiesto ripeto l'operazione
|
||||
If b2Start Then
|
||||
EgtOutLog("Avvio secondo cliclo start")
|
||||
System.Threading.Thread.Sleep(800)
|
||||
CurrCN.DGeneralFunctions_CycleStart()
|
||||
End If
|
||||
System.Threading.Thread.Sleep(300)
|
||||
' ripristino la modalità Manuale
|
||||
nResult = CurrCN.DGeneralFunctions_WriteCncMode(7)
|
||||
End Sub
|
||||
|
||||
' Esecuzione dello script lua per impostazione dati del comando diretto
|
||||
Private Function ExecDirectCmdLua(sLuaFileName As String,
|
||||
ByRef CmdString As String, ByRef b2Start As Boolean, ByRef bEActive As Boolean,
|
||||
ByRef sENumber As String, ByRef sEValue As String, ByRef sEType As String,
|
||||
ByRef sENumber2 As String, ByRef sEValue2 As String, ByRef sEType2 As String) As Boolean
|
||||
' Esecuzione script
|
||||
Dim sLuaPath As String = m_MainWindow.m_CurrentMachine.sMachDir & "\DirectCmd\" & sLuaFileName
|
||||
Dim bOk As Boolean = EgtLuaExecFile(sLuaPath)
|
||||
EgtOutLog("DirectCmd Script " & sLuaPath & If(bOk, " completed", " stopped with errors"))
|
||||
If Not bOk Then Return False
|
||||
|
||||
' Assegnazione valori a variabili lua
|
||||
Dim ManualAxesMove As ManualAxesMoveUC = m_MainWindow.m_DirectCutPageUC.m_ManualAxesMove
|
||||
|
||||
Dim dFeed As Double = 0
|
||||
If Not String.IsNullOrWhiteSpace(ManualAxesMove.FeedTxBx.Text) Then
|
||||
StringToLen(ManualAxesMove.FeedTxBx.Text, dFeed)
|
||||
Else
|
||||
EgtTdbSetCurrTool(m_MainWindow.m_CurrentProjectPageUC.ToolTxBx.Text)
|
||||
EgtTdbGetCurrToolParam(MCH_TP.FEED, dFeed)
|
||||
End If
|
||||
EgtLuaSetGlobNumVar("CMD.F", dFeed)
|
||||
|
||||
Dim dSpeed As Double = 0
|
||||
If Not String.IsNullOrWhiteSpace(ManualAxesMove.SpeedTxBx.Text) Then
|
||||
StringToDouble(ManualAxesMove.SpeedTxBx.Text, dSpeed)
|
||||
Else
|
||||
EgtTdbSetCurrTool(m_MainWindow.m_CurrentProjectPageUC.ToolTxBx.Text)
|
||||
EgtTdbGetCurrToolParam(MCH_TP.SPEED, dSpeed)
|
||||
End If
|
||||
EgtLuaSetGlobNumVar("CMD.S", dSpeed)
|
||||
|
||||
EgtTdbSetCurrTool(m_MainWindow.m_CurrentProjectPageUC.ToolTxBx.Text)
|
||||
Dim sToolPos As String = String.Empty
|
||||
If EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sToolPos) Then
|
||||
EgtLuaGetGlobStringVar("CMD.TCPOS", sToolPos)
|
||||
End If
|
||||
Dim dToolDiam As Double = 0
|
||||
If EgtTdbGetCurrToolParam(MCH_TP.DIAM, dToolDiam) Then
|
||||
EgtLuaSetGlobNumVar("CMD.DIAM", dToolDiam * 1000)
|
||||
End If
|
||||
|
||||
Dim dL1, dL2, dL3, dR1, dR2 As Double
|
||||
m_MainWindow.m_CNCommunication.GetAxesPositions(dL1, dL2, dL3, dR1, dR2)
|
||||
EgtLuaSetGlobNumVar("CMD.L1", dL1)
|
||||
EgtLuaSetGlobNumVar("CMD.L2", dL2)
|
||||
EgtLuaSetGlobNumVar("CMD.L3", dL3)
|
||||
EgtLuaSetGlobNumVar("CMD.R1", dR1)
|
||||
EgtLuaSetGlobNumVar("CMD.R2", dR2)
|
||||
EgtLuaSetGlobBoolVar("CMD.INCHES", m_MainWindow.m_CNCommunication.GetMachineInInches())
|
||||
|
||||
Dim sCurrTable As String = String.Empty
|
||||
Dim nCurrTable As Integer = 1
|
||||
EgtGetTableName(sCurrTable)
|
||||
If sCurrTable <> "MainTab" Then nCurrTable = 2
|
||||
EgtLuaSetGlobIntVar("CMD.TABLE", nCurrTable)
|
||||
|
||||
' Esecuzione funzione
|
||||
bOk = EgtLuaCallFunction("CmdString")
|
||||
EgtOutLog(" CmdString function" & If(bOk, " completed", " stopped with errors"))
|
||||
If Not bOk Then Return False
|
||||
|
||||
' Leggo variabili da file Lua
|
||||
CmdString = String.Empty
|
||||
EgtLuaGetGlobStringVar("CMD.CMDSTRING", CmdString)
|
||||
b2Start = False
|
||||
EgtLuaGetGlobBoolVar("CMD.DOUBLESTART", b2Start)
|
||||
bEActive = False
|
||||
EgtLuaGetGlobBoolVar("CMD.EACTIVE", bEActive)
|
||||
sENumber = String.Empty
|
||||
EgtLuaGetGlobStringVar("CMD.ENUMBER", sENumber)
|
||||
sEValue = String.Empty
|
||||
EgtLuaGetGlobStringVar("CMD.EVALUE", sEValue)
|
||||
sEType = String.Empty
|
||||
EgtLuaGetGlobStringVar("CMD.ETYPE", sEType)
|
||||
sENumber2 = String.Empty
|
||||
EgtLuaGetGlobStringVar("CMD.ENUMBER2", sENumber2)
|
||||
sEValue2 = String.Empty
|
||||
EgtLuaGetGlobStringVar("CMD.EVALUE2", sEValue2)
|
||||
sEType2 = String.Empty
|
||||
EgtLuaGetGlobStringVar("CMD.ETYPE2", sEType2)
|
||||
' Reset variabili lua
|
||||
EgtLuaResetGlobVar("CmdString")
|
||||
EgtLuaResetGlobVar("CMD")
|
||||
' Log del comando
|
||||
EgtOutLog(" CmdString=" & If(Not String.IsNullOrEmpty(CmdString), CmdString, "") &
|
||||
" DOUBLESTART=" & b2Start.ToString() &
|
||||
" EActive=" & bEActive.ToString() &
|
||||
" ENumber=" & If(Not String.IsNullOrEmpty(sENumber), sENumber, "") &
|
||||
" EValue=" & If(Not String.IsNullOrEmpty(sEValue), sEValue, "") &
|
||||
" EType=" & If(Not String.IsNullOrEmpty(sEType), sEType, "") &
|
||||
" ENumber2=" & If(Not String.IsNullOrEmpty(sENumber2), sENumber2, "") &
|
||||
" EValue2=" & If(Not String.IsNullOrEmpty(sEValue2), sEValue2, "") &
|
||||
" EType2=" & If(Not String.IsNullOrEmpty(sEType2), sEType2, ""))
|
||||
Return True
|
||||
End Function
|
||||
|
||||
End Module
|
||||
Reference in New Issue
Block a user