diff --git a/Constants/ConstMachIni.vb b/Constants/ConstMachIni.vb index 032f6d2..491e742 100644 --- a/Constants/ConstMachIni.vb +++ b/Constants/ConstMachIni.vb @@ -47,9 +47,7 @@ Public Const K_PHOTODELEY As String = "PhotoDeley" Public Const S_EXECLUA As String = "ExecLua" - Public Const K_DIRSCRIPT_LUA As String = "DirScript" Public Const K_FILESCRIPT_LUA As String = "FileScript" - Public Const K_CALLFUNCTION As String = "CallFunction" Public Const S_NCDATA As String = "NcData" Public Const K_NEWVARIABLE As String = "NewVariable" diff --git a/Machine/AlarmsPageUC.xaml.vb b/Machine/AlarmsPageUC.xaml.vb index 19cf6f7..70520fe 100644 --- a/Machine/AlarmsPageUC.xaml.vb +++ b/Machine/AlarmsPageUC.xaml.vb @@ -29,7 +29,7 @@ Public Class AlarmsPageUC Private Sub AlarmsPage_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized - 'Assegno liste a combobox + ' Assegno liste a combobox CurrSawCmBx.ItemsSource = m_SawList CurrDrillCmBx.ItemsSource = m_DrillList CurrMillCmBx.ItemsSource = m_MillList @@ -37,8 +37,11 @@ Public Class AlarmsPageUC CurrWJetCmBx.ItemsSource = m_WaterJetList AuxiliaryToolCmBx.ItemsSource = m_AuxToolTypeList + ' Variabile che accorcia il riferimento alla macchina corrente + m_CurrentMachine = m_MainWindow.m_CurrentMachine + ' Assegno lista ad elenco materiali - MaterialsLstBx.ItemsSource = m_MainWindow.m_CurrentMachine.Materials + MaterialsLstBx.ItemsSource = m_CurrentMachine.Materials ' Se non è impostato il controllo numerico, nascondo il bottone di tastatura lama If GetPrivateProfileInt(S_NUMERICALCONTROL, K_TYPE, 0, m_MainWindow.GetMachIniFile()) = 0 Then @@ -123,8 +126,6 @@ Public Class AlarmsPageUC Private Sub AlarmsPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded If m_bFirst Then - ' Variabile che accorcia il riferimento alla macchina corrente - m_CurrentMachine = m_MainWindow.m_CurrentMachine ' in assenza dell'uscita H1 nascondo i parametri lama If EgtGetHeadId("H1") = GDB_ID.NULL Then @@ -195,8 +196,8 @@ Public Class AlarmsPageUC m_bFirst = False End If - ' Aggiorno lista delle lame per pagina macchina in cui scegliere quella corrente - CreateToolList(MCH_TF.SAWBLADE, m_SawList) + ' Aggiorno lista delle lame per pagina macchina in cui scegliere quella corrente + CreateToolList(MCH_TF.SAWBLADE, m_SawList) ' Seleziono lama corrente CurrSawCmBx.SelectedItem = m_CurrentMachine.sCurrSaw @@ -350,7 +351,7 @@ Public Class AlarmsPageUC dVal = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_ENGRAVING_WIDTH, 0, m_MainWindow.GetMachIniFile()) TmWidthTxBx.Text = LenToString(dVal, 2) ' Flag per movimento in home alla fine dei tagli diretti - FinalHomeChBx.IsChecked = m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome + FinalHomeChBx.IsChecked = m_CurrentMachine.bDirectCutsFinalHome ' Leggo tagli ridotti per interferenza in nesting CompleteCutsChBx.IsChecked = (GetPrivateProfileInt(S_MACH_NEST, K_MACH_REDUCEDCUT, 0, m_MainWindow.GetMachIniFile()) = 0) @@ -372,7 +373,7 @@ Public Class AlarmsPageUC AdditionalTableTxBl.Text = EgtMsg(MSG_ALARMSPAGEUC + 36) & " " & GetCurrentTable().ToString() End If ' Leggo altezza sovratavola - dVal = m_MainWindow.m_CurrentMachine.dAdditionalTable + dVal = m_CurrentMachine.dAdditionalTable AdditionalTableTxBx.Text = LenToString(dVal, 2) ' Leggo soglia e tolleranza per contorno grezzo da foto ThresholdTxBx.Text = m_MainWindow.m_Camera.Threshold.ToString() @@ -446,7 +447,7 @@ Public Class AlarmsPageUC CurrWaterJettingTxBx.Text = m_CurrentMachine.sCurrWaterJetting CurrWaterJettingTxBl.Visibility = Windows.Visibility.Visible CurrWaterJettingTxBx.Visibility = Windows.Visibility.Visible - If m_MainWindow.m_CurrentMachine.bFromDBWaterJet Then + If m_CurrentMachine.bFromDBWaterJet Then CurrWaterJettingTxBx.SetValue(Grid.ColumnSpanProperty, 1) CurrWaterJettingTxBx.SetValue(MarginProperty, New Thickness(CurrWaterJettingTxBx.Margin.Left, CurrWaterJettingTxBx.Margin.Top, @@ -949,9 +950,9 @@ Public Class AlarmsPageUC Private Sub FinalHomeChBx_Click(sender As Object, e As RoutedEventArgs) Handles FinalHomeChBx.Click If FinalHomeChBx.IsChecked() Then - m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome = True + m_CurrentMachine.bDirectCutsFinalHome = True Else - m_MainWindow.m_CurrentMachine.bDirectCutsFinalHome = False + m_CurrentMachine.bDirectCutsFinalHome = False End If End Sub @@ -993,7 +994,7 @@ Public Class AlarmsPageUC Private Sub AdditionalTableTxBx_EgtClosed(sender As Object, e As EventArgs) Handles AdditionalTableTxBx.EgtClosed Dim dVal As Double = 0 StringToLen(AdditionalTableTxBx.Text, dVal) - m_MainWindow.m_CurrentMachine.dAdditionalTable = dVal + m_CurrentMachine.dAdditionalTable = dVal End Sub Private Sub NewMatBtn_Click(sender As Object, e As RoutedEventArgs) Handles NewMatBtn.Click @@ -1119,7 +1120,7 @@ Public Class AlarmsPageUC EgtOutLog("Impostata modalità automatica: esito " & nResult.ToString) End Select ' Recupero file LUA - EgtLuaExecFile(m_MainWindow.m_CurrentMachine.sMachDir() & "\DirectCmd\SawProbing.lua") + EgtLuaExecFile(m_CurrentMachine.sMachDir() & "\DirectCmd\SawProbing.lua") ' Recupero utensile da tastare Dim ToolForProbing As ToolPos = ChooseToolForProbing() If IsNothing(ToolForProbing) OrElse String.IsNullOrWhiteSpace(ToolForProbing.m_ToolName) Then Return @@ -1158,7 +1159,7 @@ Public Class AlarmsPageUC ' Modifico stringa per inserire i newline CmdString = CmdString.Replace("
", Environment.NewLine) ' Creo file... - Dim FilePath As String = m_MainWindow.GetCncDir() & "\SawProbing" & m_MainWindow.m_CurrentMachine.sIsoFileExt + Dim FilePath As String = m_MainWindow.GetCncDir() & "\SawProbing" & m_CurrentMachine.sIsoFileExt ' ...e ci scrivo Dim Writer As New IO.StreamWriter(FilePath, False) Writer.Write(CmdString) @@ -1286,9 +1287,9 @@ Public Class AlarmsPageUC End Sub Private Function ChooseToolForProbing() As ToolPos - Select Case m_MainWindow.m_CurrentMachine.MountedToolConfig + Select Case m_CurrentMachine.MountedToolConfig Case CurrentMachine.MountedToolConfigs.SAW - Return New ToolPos(m_MainWindow.m_CurrentMachine.sCurrSaw, "T100", True) + Return New ToolPos(m_CurrentMachine.sCurrSaw, "T100", True) Case CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL, CurrentMachine.MountedToolConfigs.MANUALTOOLCHANGER, CurrentMachine.MountedToolConfigs.TOOLCHANGER Dim ChooseTool As New ChooseToolWD(m_MainWindow) If ChooseTool.ShowDialog Then @@ -1336,53 +1337,34 @@ Public Class AlarmsPageUC Private Sub ExecLuaBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExecLuaBtn.Click Dim sExecFile As String = GetExecLuaFile() - Dim sCallFunction As String = GetCallFunction() - ' Recupero file LUA - Dim bExec As Boolean = EgtLuaExecFile(sExecFile) - ' Lancio l'esecuzione della funzione principale - bExec = bExec And EgtLuaCallFunction(sCallFunction) - ' Leggo variabili - Dim nErr As Integer = 0 - EgtLuaGetGlobIntVar("CMD.ERR", nErr) + ' Eseguo file LUA e recupero risultato + Dim nErr As Integer = 999 + EgtLuaExecFile(sExecFile) + EgtLuaGetGlobIntVar("ELS.ERR", nErr) ' Reset lua - EgtLuaResetGlobVar("CMD") + EgtLuaResetGlobVar("ELS") ' Verifico condizioni di errore - If nErr <> 0 And bExec Then - ' Errore in tastatura lama - EgtOutLog("Error in execution file: " & sExecFile & ", calling function: " & sCallFunction & ", CMD.ERR=" & nErr.ToString) - ' Error in executing file FILENAME - Dim MsgBoxError As New EgtMsgBox(m_MainWindow, "", 90259 & " '" & sExecFile & "'.", EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.NULL) + If nErr Then + ' Errore... + EgtOutLog("Error executing file: " & sExecFile & ", ELS.ERR=" & nErr.ToString) + ' Error executing script + Dim MsgBoxError As New EgtMsgBox(m_MainWindow, "", EgtMsg(90259), EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.NULL) Return End If End Sub ' Recupero il percorso del file lua da eseguire Private Function GetExecLuaFile() As String - Dim sDir As String = String.Empty Dim sFile As String = String.Empty - If GetPrivateProfileString(S_EXECLUA, K_DIRSCRIPT_LUA, "", sDir, m_MainWindow.GetMachIniFile()) <> 0 And - GetPrivateProfileString(S_EXECLUA, K_FILESCRIPT_LUA, "", sFile, m_MainWindow.GetMachIniFile()) <> 0 Then - ' Formatto le stringhe lette - sDir = sDir.Trim - sFile = sFile.Trim - If sDir.EndsWith("\"c) Then - sDir = sDir.Remove(sDir.LastIndexOf("\"c)) - End If - If Not sFile.EndsWith(".lua") Then - sFile = sFile & ".lua" - End If - If File.Exists(sDir & "\" & sFile) Then - Return sDir & "\" & sFile - End If + If GetPrivateProfileString(S_EXECLUA, K_FILESCRIPT_LUA, "", sFile, m_MainWindow.GetMachIniFile()) <> 0 Then + ' Sistemo nome file + sFile = sFile.Trim() + If Not sFile.EndsWith(".lua") Then sFile = sFile & ".lua" + ' Creo path + Dim sPath As String = m_CurrentMachine.sMachDir() & "\Scripts\" & sFile + If File.Exists(sPath) Then Return sPath End If Return String.Empty End Function - ' Recupera il nome della funzione che deve essere chiamata - Private Function GetCallFunction() As String - Dim sCallFunction As String = "CMD.CmdString" - GetPrivateProfileString(S_EXECLUA, K_CALLFUNCTION, sCallFunction, sCallFunction, m_MainWindow.GetMachIniFile()) - Return sCallFunction - End Function - End Class diff --git a/MainWindow.xaml.vb b/MainWindow.xaml.vb index 9a1bc32..e7e2416 100644 --- a/MainWindow.xaml.vb +++ b/MainWindow.xaml.vb @@ -303,7 +303,7 @@ Class MainWindow GetPrivateProfileString(S_MACH, K_CURRMACH, "", m_sCurrMachine, m_sIniFile) ' Impostazione path MachIni file m_sMachIniFile = m_sMachinesRoot & "\" & m_sCurrMachine & "\" & m_sCurrMachine & ".ini" - ' Impostazione path KitIni file + ' Impostazione path Kit file m_sKitsFile = m_sMachinesRoot & "\" & m_sCurrMachine & "\" & MACHININGS_DIR & "\" & KITS_FILE ' Imposto tipo di chiave #If TRIAL Then