OmagCUT 3.1b2 :

- razionalizzazione e correzioni a gestione comandi diretti tramite script lua.
This commit is contained in:
Dario Sassi
2026-02-28 19:24:10 +01:00
parent fadb601732
commit 3c2c0a48ff
11 changed files with 40 additions and 551 deletions
+1 -251
View File
@@ -551,256 +551,6 @@ Public MustInherit Class MachineButton
m_StateFlag = StateFlag
End Sub
#Region "METHODS"
Friend Sub ExecuteMDICommand(sLuaFileName As String)
If String.IsNullOrWhiteSpace(sLuaFileName) Then Return
Dim CmdString As String = String.Empty
Dim b2Start As Boolean = False
Dim EActive As Boolean = False
Dim ENumber As String = String.Empty
Dim EValue As String = String.Empty
Dim EType As String = 0
Dim ENumber2 As String = String.Empty
Dim EValue2 As String = String.Empty
Dim EType2 As String = 0
' eseguo la lettura del file .lua associato al comando
ExecuteDirectCmdLua(sLuaFileName, CmdString, b2Start, EActive, ENumber, EValue, EType, ENumber2, EValue2, EType2)
'--------------------------------------------------------- PLC ---------------------------------------------------------
If EActive Then
Select Case m_MainWindow.m_CNCommunication.m_nNCType
Case 1, 2
' se scrittura delle varibili PLC
If m_CN.m_NewVariable And m_MainWindow.m_CNCommunication.m_nNCType = 2 Then
' solo per Flexium
m_CN.DPlcVariables_WriteVariables(ENumber, EValue)
If Not String.IsNullOrEmpty(ENumber2) And Not String.IsNullOrEmpty(EValue2) Then
m_CN.DPlcVariables_WriteVariables(ENumber2, EValue2)
End If
' altrimenti scrittura delle variabili E
Else
m_CN.DVariables_WriteVariables2(ENumber, EValue)
End If
Return
Case 3
' scrivo prima variabile
Select Case CShort(EType)
Case 1
m_CN.DVariables_WriteVariables3(ENumber, CShort(EType), CInt(EValue), 0, 0, "")
EgtOutLog("ENumber= " & ENumber & "EType= " & CShort(EType) & "EValue= " & CInt(EValue))
Case 2
m_CN.DVariables_WriteVariables3(ENumber, CShort(EType), 0, CLng(EValue), 0, "")
EgtOutLog("ENumber= " & ENumber & "EType= " & CShort(EType) & "EValue= " & CLng(EValue))
Case 3
Dim d As Double = 0
StringToDouble(EValue, d)
m_CN.DVariables_WriteVariables3(ENumber, CShort(EType), 0, 0, d, "")
EgtOutLog("ENumber= " & ENumber & "EType= " & CShort(EType) & "EValue= " & d)
Case 4
m_CN.DVariables_WriteVariables3(ENumber, CShort(EType), 0, 0, 0, EValue)
EgtOutLog("ENumber= " & ENumber & "EType= " & CShort(EType) & "EValue= " & EValue)
End Select
EgtOutLog("dopo scrittura prima variabile")
If Not IsNothing(EType2) AndAlso CShort(EType) > 0 Then
System.Threading.Thread.Sleep(100)
' scrivo seconda variabile
Select Case CShort(EType2)
Case 1
m_CN.DVariables_WriteVariables3(ENumber2, CShort(EType2), CInt(EValue2), 0, 0, "")
EgtOutLog("ENumber2= " & ENumber2 & "EType2= " & CShort(EType2) & "EValue2= " & CInt(EValue2))
Case 2
m_CN.DVariables_WriteVariables3(ENumber2, CShort(EType2), 0, CLng(EValue2), 0, "")
EgtOutLog("ENumber2= " & ENumber2 & "EType2= " & CShort(EType2) & "EValue2= " & CLng(EValue2))
Case 3
Dim d As Double = 0
StringToDouble(EValue2, d)
m_CN.DVariables_WriteVariables3(ENumber2, CShort(EType2), 0, 0, d, "")
EgtOutLog("ENumber2= " & ENumber2 & "EType2= " & CShort(EType2) & "EValue2= " & d)
Case 4
m_CN.DVariables_WriteVariables3(ENumber2, CShort(EType2), 0, 0, 0, EValue2)
EgtOutLog("ENumber2= " & ENumber2 & "EType2= " & CShort(EType2) & "EValue2= " & EValue2)
End Select
EgtOutLog("dopo scrittura seconda variabile")
End If
Return
Case 4
' ------------------------------------ FANUC ------------------------------------
' eventuale scrittura di linea di comando MDI
If Not String.IsNullOrEmpty(CmdString) Then
' attivo mpdalità MDI
m_CN.DGeneralFunctions_WriteCncMode(2)
System.Threading.Thread.Sleep(100)
' salvo la stringa di comando ricevuta dal file lua
m_CN.sz_ManualDataInput = CmdString
' esguo la funzione che ha il compito di scrivere il comando MDI
m_CN.MDI_command()
End If
' attivo modalità AUTO
m_CN.DGeneralFunctions_WriteCncMode(7)
System.Threading.Thread.Sleep(100)
If String.IsNullOrEmpty(EValue) Then
' EActive: impulsivo "D#####"
m_CN.NC_pulse_bit(ENumber)
EgtOutLog("Fanuc_DNumber= " & ENumber)
Else
' EActive + EValue: scrittura comando invariabile Short oppure Bit
If ENumber.Contains(".") Then
' D#####.#
Dim bEValue As Boolean
If EValue.Trim = "1" Then bEValue = True
m_CN.NC_write_var_bit(ENumber, CBool(EValue))
Else
' D#####
m_CN.NC_write_var_short(ENumber, CShort(EValue))
End If
EgtOutLog("Fanuc_DNumber= " & ENumber & " DValue= " & EValue)
End If
' eventale caricamento seconda variabile
If String.IsNullOrEmpty(EValue2) Then
' EActive: impulsivo "D#####"
m_CN.NC_pulse_bit(ENumber2)
EgtOutLog("Fanuc_DNumber= " & ENumber2)
Else
' EActive + EValue: scrittura comando invariabile Short oppure Bit
If ENumber2.Contains(".") Then
' D#####.#
Dim bEValue2 As Boolean
If EValue2.Trim = "1" Then bEValue2 = True
m_CN.NC_write_var_bit(ENumber2, CBool(EValue2))
Else
' D#####
m_CN.NC_write_var_short(ENumber2, CShort(EValue2))
End If
EgtOutLog("Fanuc_DNumber2= " & ENumber2 & " DValue2= " & EValue2)
End If
Return
End Select
End If
'--------------------------------------------------------- MDI ---------------------------------------------------------
Dim nResult As Short
' assegno la modalità di funzionamento
Select Case m_MainWindow.m_CNCommunication.m_nNCType
Case 1, 2, 4
nResult = m_CN.DGeneralFunctions_WriteCncMode(2) ' Modalità MDI per controlli num
Case 3
'Per il siemens non devo fare nulla
End Select
' salvo la stringa di comando ricevuta dal file lua
m_CN.sz_ManualDataInput = CmdString
' esguo la funzione che ha il compito di scrivere il comando MDI
m_CN.MDI_command()
' avvio l'esecuzione del comando
Select Case m_MainWindow.m_CNCommunication.m_nNCType
Case 1, 2
System.Threading.Thread.Sleep(500)
m_CN.DGeneralFunctions_CycleStart()
Case 3
'Per il siemens non devo fare nulla
End Select
' se richiesto ripeto l'operazione
If b2Start Then
EgtOutLog("Avvio secondo cliclo start")
System.Threading.Thread.Sleep(800)
m_CN.DGeneralFunctions_CycleStart()
End If
System.Threading.Thread.Sleep(300)
' ripristino la modalità manuale..?? siucuri ??
nResult = m_CN.DGeneralFunctions_WriteCncMode(7) ' Modalità manuale
End Sub
' lettura delle variavili scritte nel file Lua
Friend Sub ExecuteDirectCmdLua(LuaFileName As String, ByRef CmdString As String, ByRef b2Start As Boolean, ByRef EActive As Boolean, ByRef ENumber As String, ByRef EValue As String, ByRef EType As String, ByRef ENumber2 As String, ByRef EValue2 As String, ByRef EType2 As String)
Dim sBaseDir As String = m_MainWindow.m_CurrentMachine.sMachDir & "\DirectCmd\"
If EgtLuaExecFile(sBaseDir & LuaFileName) Then
EgtOutLog("Lua " & sBaseDir & LuaFileName & " eseguito")
Else
EgtOutLog("Lua " & sBaseDir & LuaFileName & " non eseguito")
End If
Dim dFeed As Double = 0
If Not String.IsNullOrWhiteSpace(m_DirectCutPage.m_ManualAxesMove.FeedTxBx.Text) Then
StringToLen(m_DirectCutPage.m_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(m_DirectCutPage.m_ManualAxesMove.SpeedTxBx.Text) Then
StringToDouble(m_DirectCutPage.m_ManualAxesMove.SpeedTxBx.Text, dSpeed)
Else
EgtTdbSetCurrTool(m_MainWindow.m_CurrentProjectPageUC.ToolTxBx.Text)
EgtTdbGetCurrToolParam(MCH_TP.SPEED, dSpeed)
End If
EgtLuaSetGlobNumVar("CMD.S", dSpeed)
' versione 2.5e1
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())
' versione 2.6h1
Dim sCurrTable As String = String.Empty
Dim nCuttTable As Integer = 1
EgtGetTableName(sCurrTable)
If sCurrTable <> "MainTab" Then nCuttTable = 2
EgtLuaSetGlobIntVar("CMD.TABLE", nCuttTable)
EgtLuaCallFunction("CmdString")
' Leggo variabili da file Lua
CmdString = String.Empty
EgtLuaGetGlobStringVar("CMD.CMDSTRING", CmdString)
b2Start = False
EgtLuaGetGlobBoolVar("CMD.DOUBLESTART", b2Start)
EActive = False
EgtLuaGetGlobBoolVar("CMD.EACTIVE", EActive)
ENumber = String.Empty
EgtLuaGetGlobStringVar("CMD.ENUMBER", ENumber)
EValue = String.Empty
EgtLuaGetGlobStringVar("CMD.EVALUE", EValue)
EType = String.Empty
EgtLuaGetGlobStringVar("CMD.ETYPE", EType)
EgtOutLog("ENUMBER: " & ENumber & " EVALUE: " & EValue & " ETYPE: " & EType)
ENumber2 = String.Empty
EgtLuaGetGlobStringVar("CMD.ENUMBER2", ENumber2)
EValue2 = String.Empty
EgtLuaGetGlobStringVar("CMD.EVALUE2", EValue2)
EType2 = String.Empty
EgtLuaGetGlobStringVar("CMD.ETYPE2", EType2)
EgtOutLog("ENUMBER2: " & ENumber2 & " EVALUE2: " & EValue2 & " ETYPE2: " & EType2)
' Reset lua
EgtLuaResetGlobVar("CmdString")
EgtLuaResetGlobVar("CMD")
' Log del comando
EgtOutLog("CmdString=" & If(Not String.IsNullOrEmpty(CmdString), CmdString, "") &
" b2Start=" & b2Start.ToString() &
" EActive=" & EActive.ToString &
" ENumber=" & If(Not String.IsNullOrEmpty(ENumber), ENumber, "") &
" EValue=" & If(Not String.IsNullOrEmpty(EValue), EValue, "") &
" EType=" & If(Not String.IsNullOrEmpty(EType), CInt(EType).ToString, "") &
" ENumber2=" & If(Not String.IsNullOrEmpty(ENumber2), ENumber2, "") &
" EValue2=" & If(Not String.IsNullOrEmpty(EValue2), EValue2, "") &
" EType2=" & If(Not String.IsNullOrEmpty(EType2), CInt(EType2).ToString, ""))
End Sub
#End Region ' METHODS
Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
@@ -831,7 +581,7 @@ Public Class TwoStateButton
End If
Dim IsPressedShiftKey As Boolean = False
If Keyboard.Modifiers And ModifierKeys.Shift And
If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 And
GetPrivateProfileInt(S_GENERAL, K_DEBUG, 0, m_MainWindow.GetIniFile()) > 4 Then IsPressedShiftKey = True
' procedo all'apertura del file CadCut1 appena generato (solo se generazione corretta)
If IsPressedShiftKey Then