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 m_StateFlag = StateFlag
End Sub 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 Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
@@ -831,7 +581,7 @@ Public Class TwoStateButton
End If End If
Dim IsPressedShiftKey As Boolean = False 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 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) ' procedo all'apertura del file CadCut1 appena generato (solo se generazione corretta)
If IsPressedShiftKey Then If IsPressedShiftKey Then
+5 -5
View File
@@ -267,7 +267,7 @@ Public Class DirectCutPageUC
Next Next
If IsNothing(XYJogButton) Then Return If IsNothing(XYJogButton) Then Return
' eseguo lo script lua associato ' eseguo lo script lua associato
XYJogButton.ExecuteMDICommand(XYJogButton.TLuaScriptName) VarMdiCommand.ExecuteMDICommand(XYJogButton.TLuaScriptName)
' che comunica al PLC di cambiare lo stato, la modifica dello stato è intercettata dalla funzione Refresh che avvia il metodo Changed ' che comunica al PLC di cambiare lo stato, la modifica dello stato è intercettata dalla funzione Refresh che avvia il metodo Changed
End Sub End Sub
@@ -299,7 +299,7 @@ Public Class DirectCutPageUC
Next Next
If IsNothing(ZJogButton) Then Return If IsNothing(ZJogButton) Then Return
' eseguo lo script lua associato ' eseguo lo script lua associato
ZJogButton.ExecuteMDICommand(ZJogButton.TLuaScriptName) VarMdiCommand.ExecuteMDICommand(ZJogButton.TLuaScriptName)
End Sub End Sub
Friend Sub ZCJogChanged(bZAxes As Boolean) Friend Sub ZCJogChanged(bZAxes As Boolean)
@@ -329,7 +329,7 @@ Public Class DirectCutPageUC
Next Next
If IsNothing(ZBJogButton) Then Return If IsNothing(ZBJogButton) Then Return
' eseguo lo script lua associato ' eseguo lo script lua associato
ZBJogButton.ExecuteMDICommand(ZBJogButton.TLuaScriptName) VarMdiCommand.ExecuteMDICommand(ZBJogButton.TLuaScriptName)
End Sub End Sub
Friend Sub ZBJogChanged(bBCAxes As Boolean) Friend Sub ZBJogChanged(bBCAxes As Boolean)
@@ -366,7 +366,7 @@ Public Class DirectCutPageUC
Else Else
sLuaFileName = RemoteButton.FLuaScriptName sLuaFileName = RemoteButton.FLuaScriptName
End If End If
RemoteButton.ExecuteMDICommand(sLuaFileName) VarMdiCommand.ExecuteMDICommand(sLuaFileName)
End Sub End Sub
Friend Sub RemoteChanged(bRemote As Boolean) Friend Sub RemoteChanged(bRemote As Boolean)
@@ -403,7 +403,7 @@ Public Class DirectCutPageUC
Else Else
sLuaFileName = ParkingButton.FLuaScriptName sLuaFileName = ParkingButton.FLuaScriptName
End If End If
ParkingButton.ExecuteMDICommand(sLuaFileName) VarMdiCommand.ExecuteMDICommand(sLuaFileName)
End Sub End Sub
Friend Sub ParkingStateChanged(bParkingState As Boolean) Friend Sub ParkingStateChanged(bParkingState As Boolean)
+10 -252
View File
@@ -154,46 +154,39 @@ Public Class MachineButtonsUC
' recupero l'inidce del bottone selezionato ' recupero l'inidce del bottone selezionato
Dim nIndex As Integer = GetToggleButtonIndex(CurrentBtn) - 1 Dim nIndex As Integer = GetToggleButtonIndex(CurrentBtn) - 1
Dim sBaseDir As String = m_MainWindow.m_CurrentMachine.sMachDir & "\DirectCmd\"
Dim sLuaFileName As String = String.Empty
' Se il bottone chiamantè quello delle porte allora devo eseguire due comandi MDI ' Se il bottone chiamante è quello delle porte allora devo eseguire due comandi MDI
If nIndex = Array.IndexOf(StateFlagArray, BTN_STATE_DOOR_OPENED) OrElse If nIndex = Array.IndexOf(StateFlagArray, BTN_STATE_DOOR_OPENED) OrElse
nIndex = Array.IndexOf(StateFlagArray, BTN_STATE_DOOR_CLOSED) Then nIndex = Array.IndexOf(StateFlagArray, BTN_STATE_DOOR_CLOSED) Then
Dim sTLuaFile As String = sBaseDir & CommandArrayY(nIndex) VarMdiCommand.ExecuteMDICommand(CommandArrayY(nIndex))
Dim sFLuaFile As String = sBaseDir & CommandArrayN(nIndex) VarMdiCommand.ExecuteMDICommand(CommandArrayN(nIndex))
ExecuteMDICommand(CurrentBtn, sTLuaFile)
ExecuteMDICommand(CurrentBtn, sFLuaFile)
CurrentBtn.IsChecked = False CurrentBtn.IsChecked = False
Return Return
End If End If
' Se il bottone chiamantè quello per la selezione del pannello di controllo ' Se il bottone chiamante è quello per la selezione del pannello di controllo
If nIndex = Array.IndexOf(StateFlagArray, BTN_ENABLE_PC) Then If nIndex = Array.IndexOf(StateFlagArray, BTN_ENABLE_PC) Then
Dim sTLuaFile As String = sBaseDir & CommandArrayY(nIndex)
Dim sFLuaFile As String = sBaseDir & CommandArrayN(nIndex)
If m_CN.nEnablePc = 1 Then If m_CN.nEnablePc = 1 Then
ExecuteMDICommand(CurrentBtn, sTLuaFile) VarMdiCommand.ExecuteMDICommand(CommandArrayY(nIndex))
ElseIf m_CN.nEnablePc = 2 Then ElseIf m_CN.nEnablePc = 2 Then
ExecuteMDICommand(CurrentBtn, sFLuaFile) VarMdiCommand.ExecuteMDICommand(CommandArrayN(nIndex))
End If End If
Return Return
End If End If
Dim sLuaFileName As String = ""
If CurrentBtn.IsChecked() Then If CurrentBtn.IsChecked() Then
'EgtLuaExecFile(sBaseDir & CommandArrayY(nIndex)) sLuaFileName = CommandArrayY(nIndex)
sLuaFileName = sBaseDir & CommandArrayY(nIndex)
Else Else
If Not (StateFlagArray(nIndex) = BTN_STATE_THREEAXIS Or If Not (StateFlagArray(nIndex) = BTN_STATE_THREEAXIS Or
StateFlagArray(nIndex) = BTN_STATE_FIVEAXIS) Then StateFlagArray(nIndex) = BTN_STATE_FIVEAXIS) Then
'EgtLuaExecFile(sBaseDir & CommandArrayN(nIndex)) sLuaFileName = CommandArrayN(nIndex)
sLuaFileName = sBaseDir & CommandArrayN(nIndex)
Else Else
Return Return
End If End If
End If End If
ExecuteMDICommand(CurrentBtn, sLuaFileName) VarMdiCommand.ExecuteMDICommand(sLuaFileName)
' se non ha stato e quindi è un bottone normale, tolgo il check ' se non ha stato e quindi è un bottone normale, tolgo il check
If StateFlagArray(nIndex) = BTN_STATE_NOTHING Then If StateFlagArray(nIndex) = BTN_STATE_NOTHING Then
@@ -202,241 +195,6 @@ Public Class MachineButtonsUC
End Sub End Sub
Friend Sub ExecuteMDICommand(CurrentBtn As Primitives.ToggleButton, 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)
' comunico i dati calcolati al PLC (quidni ignoro eventuali comandi MDI), scrivo messaggio MDI
If EActive Then
Select Case m_MainWindow.m_CNCommunication.m_nNCType
Case 1, 2
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 IsNothing(ENumber2) And Not IsNothing(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
If m_MainWindow.m_DirectCutPageUC.m_NewMachineButtonsType Then
' 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
End If
' CONTROLLO FANUC
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
Dim nResult As Short
' Imposto modalità MDI per controlli num
Select Case m_MainWindow.m_CNCommunication.m_nNCType
Case 1, 2
nResult = m_CN.DGeneralFunctions_WriteCncMode(2)
Case 3
'Per il siemens non devo fare nulla
End Select
m_CN.sz_ManualDataInput = CmdString
m_CN.MDI_command()
Select Case m_MainWindow.m_CNCommunication.m_nNCType
Case 1, 2
System.Threading.Thread.Sleep(300)
m_CN.DGeneralFunctions_CycleStart()
Case 3
'Per il siemens non devo fare nulla
Case 4
' Nicola: 27/03/2023 attivazione della funzione M# indicata?
End Select
If b2Start Then
System.Threading.Thread.Sleep(800)
m_CN.DGeneralFunctions_CycleStart()
End If
System.Threading.Thread.Sleep(300)
nResult = m_CN.DGeneralFunctions_WriteCncMode(7) ' Modalità manuale
End Sub
' questa è una copia della funzione presente nel codice ControlsMachineButtonUC.xaml.vb
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(LuaFileName) Then
EgtOutLog("Lua " & LuaFileName & " eseguito")
Else
EgtOutLog("Lua " & 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())
EgtLuaCallFunction("CmdString")
' Leggo variabili
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
#Region "STATE CHANGED" #Region "STATE CHANGED"
Friend Sub SpindleStateChanged(SpindleState As Boolean) Friend Sub SpindleStateChanged(SpindleState As Boolean)
+1 -1
View File
@@ -1188,7 +1188,7 @@ Public Class DrawPageUC
ActivateParkIndZero() ActivateParkIndZero()
Dim bExitPage As Boolean = GetPrivateProfileInt(S_GENERAL, K_QUITDRAWPAGE, 1, m_MainWindow.GetIniFile) <> 0 Dim bExitPage As Boolean = GetPrivateProfileInt(S_GENERAL, K_QUITDRAWPAGE, 1, m_MainWindow.GetIniFile) <> 0
' Se Shift premuto eseguo il contrario ' Se Shift premuto eseguo il contrario
If Keyboard.Modifiers And ModifierKeys.Shift Then If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 Then
bExitPage = Not bExitPage bExitPage = Not bExitPage
End If End If
If bExitPage Then If bExitPage Then
+2 -2
View File
@@ -340,14 +340,14 @@ Public Class MachineCNPageUC
Private Sub PowerON_Click(sender As Object, e As RoutedEventArgs) Handles PowerONBtn.Click Private Sub PowerON_Click(sender As Object, e As RoutedEventArgs) Handles PowerONBtn.Click
Dim PowerOnButton As MachineButton = m_ButtonPower(0) Dim PowerOnButton As MachineButton = m_ButtonPower(0)
' eseguo lo script lua associato ' eseguo lo script lua associato
PowerOnButton.ExecuteMDICommand(PowerOnButton.TLuaScriptName) VarMdiCommand.ExecuteMDICommand(PowerOnButton.TLuaScriptName)
' che comunica al PLC di cambiare lo stato, la modifica dello stato è intercettata dalla funzione Refresh che avvia il metodo Changed ' che comunica al PLC di cambiare lo stato, la modifica dello stato è intercettata dalla funzione Refresh che avvia il metodo Changed
End Sub End Sub
Private Sub PowerOFF_Click(sender As Object, e As RoutedEventArgs) Handles PowerOFFBtn.Click Private Sub PowerOFF_Click(sender As Object, e As RoutedEventArgs) Handles PowerOFFBtn.Click
Dim PowerOffButton As MachineButton = m_ButtonPower(1) Dim PowerOffButton As MachineButton = m_ButtonPower(1)
' eseguo lo script lua associato ' eseguo lo script lua associato
PowerOffButton.ExecuteMDICommand(PowerOffButton.TLuaScriptName) VarMdiCommand.ExecuteMDICommand(PowerOffButton.TLuaScriptName)
' che comunica al PLC di cambiare lo stato, la modifica dello stato è intercettata dalla funzione Refresh che avvia il metodo Changed ' che comunica al PLC di cambiare lo stato, la modifica dello stato è intercettata dalla funzione Refresh che avvia il metodo Changed
End Sub End Sub
+1 -1
View File
@@ -1084,7 +1084,7 @@ Class MainWindow
If m_CurrentProjectPageUC.OutMessageBrd.IsMouseOver Then If m_CurrentProjectPageUC.OutMessageBrd.IsMouseOver Then
m_CurrentProjectPageUC.ClearMessage() m_CurrentProjectPageUC.ClearMessage()
' se è premuto il pulsante Shift allora provvedo ad aprire il file di Log ' se è premuto il pulsante Shift allora provvedo ad aprire il file di Log
If Keyboard.Modifiers And ModifierKeys.Shift Then If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 Then
' Genero file CNC (lancio anche se errore in precedenza) ' Genero file CNC (lancio anche se errore in precedenza)
Dim sTemoDirect As String = GetTempDir() & "\OmagCUTLog.txt" Dim sTemoDirect As String = GetTempDir() & "\OmagCUTLog.txt"
Try Try
+2 -2
View File
@@ -62,5 +62,5 @@ Imports System.Windows
' by using the '*' as shown below: ' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("3.1.2.1")> <Assembly: AssemblyVersion("3.1.2.2")>
<Assembly: AssemblyFileVersion("3.1.2.1")> <Assembly: AssemblyFileVersion("3.1.2.2")>
+12 -30
View File
@@ -106,32 +106,23 @@ Namespace Fanuc
End Function End Function
Private Function set_NC_mode(n_mode As Integer) As Int16 Private Function set_NC_mode(n_mode As Integer) As Int16
Dim nret As Integer = -1
' Nicola: 29/03/2023
'
' trascodifica !!!!! da mettere anche nella SET MODE !!!!!
'
Select Case n_mode Select Case n_mode
Case 0 ' Auto
Case 0 ' Auto n_mode = 1
n_mode = 1 ' NUM dice 2 per Auto Case 1 ' EDIT
n_mode = 3
Case 1 ' EDIT Case 2 ' MDI
n_mode = 3 ' NUM dice .. ? n_mode = 0
Case 7 ' JOG-Manual
Case 2 ' MDI n_mode = 5
n_mode = 0 ' NUM dice 2 per MDI
Case 7 ' JOG-Manual
n_mode = 5 ' NUM dice 2 per Manual
Case Else Case Else
n_mode = -99 n_mode = -99
End Select End Select
Dim bret As Boolean = NC_write_var_short(s_addr_set_nc_mode, CShort(n_mode)) Dim bret As Boolean = NC_write_var_short(s_addr_set_nc_mode, CShort(n_mode))
Dim nret As Integer = -1
If Not bret Then If Not bret Then
EgtOutLog("Error in set_NC_mode(" & n_mode.ToString() & ")") EgtOutLog("Error in set_NC_mode(" & n_mode.ToString() & ")")
Else Else
@@ -140,28 +131,19 @@ Namespace Fanuc
Return nret Return nret
'nret = WriteObjectVarious2(n_portNC, Mode, n_mode) ' 0 AUTO 1 SEQUENZIALE 2 IMD 7 MANUALE
'If nret <> 0 Then
' EgtOutLog("Error in set_NC_mode(" & n_mode.ToString() & ") : " & nret.ToString())
'End If
End Function End Function
Private Function set_MDI_command(sz_command As String) As Int16 Private Function set_MDI_command(sz_command As String) As Int16
Dim b_ret As Boolean
Dim n_ret As Short
' !!!!! SET THE NC TO THE MDI MODE ' !!!!! SET THE NC TO THE MDI MODE
b_ret = F_MDI_write_program(sz_command) ' create the command Dim b_ret As Boolean = F_MDI_write_program(sz_command) ' create the command
If b_ret Then If b_ret Then
' START CYCLE-2 ' START CYCLE-2
n_ret = F_cycle_start() Dim n_ret As Short = F_cycle_start()
If b_ret Then If b_ret Then
Return 0 Return 0
+1
View File
@@ -211,6 +211,7 @@
<Compile Include="DirectCuts\SquaringUC.xaml.vb"> <Compile Include="DirectCuts\SquaringUC.xaml.vb">
<DependentUpon>SquaringUC.xaml</DependentUpon> <DependentUpon>SquaringUC.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="DirectCuts\VarMdiCommand.vb" />
<Compile Include="DrawImport\AlzFrontUC.xaml.vb"> <Compile Include="DrawImport\AlzFrontUC.xaml.vb">
<DependentUpon>AlzFrontUC.xaml</DependentUpon> <DependentUpon>AlzFrontUC.xaml</DependentUpon>
</Compile> </Compile>
+3 -5
View File
@@ -367,9 +367,8 @@ Public Class Camera
Else Else
EgtOutLog("Direct command for positionig head: " & sDirectCmdFile) EgtOutLog("Direct command for positionig head: " & sDirectCmdFile)
End If End If
GoHome = New TwoStateButton("", sDirectCmdFile, "", "", "")
' eseguo lo script lua associato ' eseguo lo script lua associato
GoHome.ExecuteMDICommand(GoHome.TLuaScriptName) VarMdiCommand.ExecuteMDICommand(sDirectCmdFile)
' Leggo nome variabile posizione home raggiunta ' Leggo nome variabile posizione home raggiunta
Dim CameraStateNameVar As String = String.Empty Dim CameraStateNameVar As String = String.Empty
GetPrivateProfileString(S_PHOTO, K_CAMERA_STATE_VAR, "", CameraStateNameVar, m_MainWindow.GetMachIniFile()) GetPrivateProfileString(S_PHOTO, K_CAMERA_STATE_VAR, "", CameraStateNameVar, m_MainWindow.GetMachIniFile())
@@ -380,8 +379,7 @@ Public Class Camera
Else Else
EgtOutLog("Variable for read status of positioning head: " & CameraStateNameVar) EgtOutLog("Variable for read status of positioning head: " & CameraStateNameVar)
End If End If
' 91144=Going home m_MainWindow.m_CurrentProjectPageUC.SetInfoMessage(EgtMsg(91144)) ' Going home
m_MainWindow.m_CurrentProjectPageUC.SetInfoMessage(EgtMsg(91144))
UpdateUI() UpdateUI()
' Eseguo reset variabile posizione home raggiunta ' Eseguo reset variabile posizione home raggiunta
m_MainWindow.m_CNCommunication.m_CN.DVariables_WriteVariables2(CameraStateNameVar, "0") m_MainWindow.m_CNCommunication.m_CN.DVariables_WriteVariables2(CameraStateNameVar, "0")
@@ -414,7 +412,7 @@ Public Class Camera
Return bPositionOk Return bPositionOk
End Function End Function
' OK: Ottengo l'indice del processo associato alla tavola e la configurazione del processo ' Ottengo l'indice del processo associato alla tavola e la configurazione del processo
Private Function PrepareCamera() As Integer Private Function PrepareCamera() As Integer
' Stati del processo ' Stati del processo
m_bIsRunnigProc = False m_bIsRunnigProc = False
+2 -2
View File
@@ -578,9 +578,9 @@ Public Class SimulationPageUC
End Sub End Sub
Private Sub GenerateCN_Click(sender As Object, e As RoutedEventArgs) Private Sub GenerateCN_Click(sender As Object, e As RoutedEventArgs)
' Se il bottone Shift è premuto apro il file CadCut1 nel programma NotePad ' Se il bottone Shift è premuto apriro' il file CadCut1 nel programma NotePad
Dim IsPressedShiftKey As Boolean = False Dim IsPressedShiftKey As Boolean = False
If Keyboard.Modifiers And ModifierKeys.Shift Then IsPressedShiftKey = True If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 Then IsPressedShiftKey = True
' Eventualmente fermo la simulazione ' Eventualmente fermo la simulazione
m_nStatus = MCH_SIM_ST.UI_STOP m_nStatus = MCH_SIM_ST.UI_STOP