diff --git a/DirectCuts/ControlsMachineButtonUC.xaml.vb b/DirectCuts/ControlsMachineButtonUC.xaml.vb index fd34cee..bdb3a09 100644 --- a/DirectCuts/ControlsMachineButtonUC.xaml.vb +++ b/DirectCuts/ControlsMachineButtonUC.xaml.vb @@ -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 diff --git a/DirectCuts/DirectCutPageUC.xaml.vb b/DirectCuts/DirectCutPageUC.xaml.vb index d7c8c65..58115af 100644 --- a/DirectCuts/DirectCutPageUC.xaml.vb +++ b/DirectCuts/DirectCutPageUC.xaml.vb @@ -267,7 +267,7 @@ Public Class DirectCutPageUC Next If IsNothing(XYJogButton) Then Return ' 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 End Sub @@ -299,7 +299,7 @@ Public Class DirectCutPageUC Next If IsNothing(ZJogButton) Then Return ' eseguo lo script lua associato - ZJogButton.ExecuteMDICommand(ZJogButton.TLuaScriptName) + VarMdiCommand.ExecuteMDICommand(ZJogButton.TLuaScriptName) End Sub Friend Sub ZCJogChanged(bZAxes As Boolean) @@ -329,7 +329,7 @@ Public Class DirectCutPageUC Next If IsNothing(ZBJogButton) Then Return ' eseguo lo script lua associato - ZBJogButton.ExecuteMDICommand(ZBJogButton.TLuaScriptName) + VarMdiCommand.ExecuteMDICommand(ZBJogButton.TLuaScriptName) End Sub Friend Sub ZBJogChanged(bBCAxes As Boolean) @@ -366,7 +366,7 @@ Public Class DirectCutPageUC Else sLuaFileName = RemoteButton.FLuaScriptName End If - RemoteButton.ExecuteMDICommand(sLuaFileName) + VarMdiCommand.ExecuteMDICommand(sLuaFileName) End Sub Friend Sub RemoteChanged(bRemote As Boolean) @@ -403,7 +403,7 @@ Public Class DirectCutPageUC Else sLuaFileName = ParkingButton.FLuaScriptName End If - ParkingButton.ExecuteMDICommand(sLuaFileName) + VarMdiCommand.ExecuteMDICommand(sLuaFileName) End Sub Friend Sub ParkingStateChanged(bParkingState As Boolean) diff --git a/DirectCuts/MachineButtonsUC.xaml.vb b/DirectCuts/MachineButtonsUC.xaml.vb index 905aa90..0d69e81 100644 --- a/DirectCuts/MachineButtonsUC.xaml.vb +++ b/DirectCuts/MachineButtonsUC.xaml.vb @@ -154,46 +154,39 @@ Public Class MachineButtonsUC ' recupero l'inidce del bottone selezionato 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 nIndex = Array.IndexOf(StateFlagArray, BTN_STATE_DOOR_CLOSED) Then - Dim sTLuaFile As String = sBaseDir & CommandArrayY(nIndex) - Dim sFLuaFile As String = sBaseDir & CommandArrayN(nIndex) - ExecuteMDICommand(CurrentBtn, sTLuaFile) - ExecuteMDICommand(CurrentBtn, sFLuaFile) + VarMdiCommand.ExecuteMDICommand(CommandArrayY(nIndex)) + VarMdiCommand.ExecuteMDICommand(CommandArrayN(nIndex)) CurrentBtn.IsChecked = False Return 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 - Dim sTLuaFile As String = sBaseDir & CommandArrayY(nIndex) - Dim sFLuaFile As String = sBaseDir & CommandArrayN(nIndex) If m_CN.nEnablePc = 1 Then - ExecuteMDICommand(CurrentBtn, sTLuaFile) + VarMdiCommand.ExecuteMDICommand(CommandArrayY(nIndex)) ElseIf m_CN.nEnablePc = 2 Then - ExecuteMDICommand(CurrentBtn, sFLuaFile) + VarMdiCommand.ExecuteMDICommand(CommandArrayN(nIndex)) End If Return End If + Dim sLuaFileName As String = "" If CurrentBtn.IsChecked() Then - 'EgtLuaExecFile(sBaseDir & CommandArrayY(nIndex)) - sLuaFileName = sBaseDir & CommandArrayY(nIndex) + sLuaFileName = CommandArrayY(nIndex) Else If Not (StateFlagArray(nIndex) = BTN_STATE_THREEAXIS Or StateFlagArray(nIndex) = BTN_STATE_FIVEAXIS) Then - 'EgtLuaExecFile(sBaseDir & CommandArrayN(nIndex)) - sLuaFileName = sBaseDir & CommandArrayN(nIndex) + sLuaFileName = CommandArrayN(nIndex) Else Return End If End If - ExecuteMDICommand(CurrentBtn, sLuaFileName) + VarMdiCommand.ExecuteMDICommand(sLuaFileName) ' se non ha stato e quindi è un bottone normale, tolgo il check If StateFlagArray(nIndex) = BTN_STATE_NOTHING Then @@ -202,241 +195,6 @@ Public Class MachineButtonsUC 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" Friend Sub SpindleStateChanged(SpindleState As Boolean) diff --git a/DrawImport/DrawPageUC.xaml.vb b/DrawImport/DrawPageUC.xaml.vb index b989a7b..c91f818 100644 --- a/DrawImport/DrawPageUC.xaml.vb +++ b/DrawImport/DrawPageUC.xaml.vb @@ -1188,7 +1188,7 @@ Public Class DrawPageUC ActivateParkIndZero() Dim bExitPage As Boolean = GetPrivateProfileInt(S_GENERAL, K_QUITDRAWPAGE, 1, m_MainWindow.GetIniFile) <> 0 ' Se Shift premuto eseguo il contrario - If Keyboard.Modifiers And ModifierKeys.Shift Then + If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 Then bExitPage = Not bExitPage End If If bExitPage Then diff --git a/Machine/MachineCNPageUC.xaml.vb b/Machine/MachineCNPageUC.xaml.vb index 3653305..ab828e3 100644 --- a/Machine/MachineCNPageUC.xaml.vb +++ b/Machine/MachineCNPageUC.xaml.vb @@ -340,14 +340,14 @@ Public Class MachineCNPageUC 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 - 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 End Sub Private Sub PowerOFF_Click(sender As Object, e As RoutedEventArgs) Handles PowerOFFBtn.Click Dim PowerOffButton As MachineButton = m_ButtonPower(1) ' 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 End Sub diff --git a/MainWindow.xaml.vb b/MainWindow.xaml.vb index 58671bf..bbe76fc 100644 --- a/MainWindow.xaml.vb +++ b/MainWindow.xaml.vb @@ -1084,7 +1084,7 @@ Class MainWindow If m_CurrentProjectPageUC.OutMessageBrd.IsMouseOver Then m_CurrentProjectPageUC.ClearMessage() ' 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) Dim sTemoDirect As String = GetTempDir() & "\OmagCUTLog.txt" Try diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 145168a..7f09c2b 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -62,5 +62,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/NcComm/M_Fanuc_hi.vb b/NcComm/M_Fanuc_hi.vb index 4519169..a8281b0 100644 --- a/NcComm/M_Fanuc_hi.vb +++ b/NcComm/M_Fanuc_hi.vb @@ -106,32 +106,23 @@ Namespace Fanuc End Function 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 - - Case 0 ' Auto - n_mode = 1 ' NUM dice 2 per Auto - - Case 1 ' EDIT - n_mode = 3 ' NUM dice .. ? - - Case 2 ' MDI - n_mode = 0 ' NUM dice 2 per MDI - - Case 7 ' JOG-Manual - n_mode = 5 ' NUM dice 2 per Manual - + Case 0 ' Auto + n_mode = 1 + Case 1 ' EDIT + n_mode = 3 + Case 2 ' MDI + n_mode = 0 + Case 7 ' JOG-Manual + n_mode = 5 Case Else n_mode = -99 - End Select 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 EgtOutLog("Error in set_NC_mode(" & n_mode.ToString() & ")") Else @@ -140,28 +131,19 @@ Namespace Fanuc 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 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 - 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 ' START CYCLE-2 - n_ret = F_cycle_start() + Dim n_ret As Short = F_cycle_start() If b_ret Then Return 0 diff --git a/OmagCUT.vbproj b/OmagCUT.vbproj index 6a5d8d2..4108703 100644 --- a/OmagCUT.vbproj +++ b/OmagCUT.vbproj @@ -211,6 +211,7 @@ SquaringUC.xaml + AlzFrontUC.xaml diff --git a/RawPhoto/Camera.vb b/RawPhoto/Camera.vb index 17cb0ed..c7f4b49 100644 --- a/RawPhoto/Camera.vb +++ b/RawPhoto/Camera.vb @@ -367,9 +367,8 @@ Public Class Camera Else EgtOutLog("Direct command for positionig head: " & sDirectCmdFile) End If - GoHome = New TwoStateButton("", sDirectCmdFile, "", "", "") ' eseguo lo script lua associato - GoHome.ExecuteMDICommand(GoHome.TLuaScriptName) + VarMdiCommand.ExecuteMDICommand(sDirectCmdFile) ' Leggo nome variabile posizione home raggiunta Dim CameraStateNameVar As String = String.Empty GetPrivateProfileString(S_PHOTO, K_CAMERA_STATE_VAR, "", CameraStateNameVar, m_MainWindow.GetMachIniFile()) @@ -380,8 +379,7 @@ Public Class Camera Else EgtOutLog("Variable for read status of positioning head: " & CameraStateNameVar) End If - ' 91144=Going home - m_MainWindow.m_CurrentProjectPageUC.SetInfoMessage(EgtMsg(91144)) + m_MainWindow.m_CurrentProjectPageUC.SetInfoMessage(EgtMsg(91144)) ' Going home UpdateUI() ' Eseguo reset variabile posizione home raggiunta m_MainWindow.m_CNCommunication.m_CN.DVariables_WriteVariables2(CameraStateNameVar, "0") @@ -414,7 +412,7 @@ Public Class Camera Return bPositionOk 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 ' Stati del processo m_bIsRunnigProc = False diff --git a/Simulation/SimulationPageUC.xaml.vb b/Simulation/SimulationPageUC.xaml.vb index 8028862..be7f50d 100644 --- a/Simulation/SimulationPageUC.xaml.vb +++ b/Simulation/SimulationPageUC.xaml.vb @@ -578,9 +578,9 @@ Public Class SimulationPageUC End Sub 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 - If Keyboard.Modifiers And ModifierKeys.Shift Then IsPressedShiftKey = True + If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 Then IsPressedShiftKey = True ' Eventualmente fermo la simulazione m_nStatus = MCH_SIM_ST.UI_STOP