diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj
index 64e2bd8..ee494ca 100644
--- a/EgtCAM5.vbproj
+++ b/EgtCAM5.vbproj
@@ -308,6 +308,7 @@
ToolsDbView.xaml
+
TopCommandBarView.xaml
diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb
index 41bd247..e767986 100644
--- a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb
+++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderViewModel.vb
@@ -701,9 +701,9 @@ Namespace EgtCAM5
Application.Current.MainWindow.Cursor = Cursors.Wait
' Eseguo ricalcolo
Dim sErr As String = String.Empty
- Dim bOk As Boolean = EgtApplyAllMachinings(False, sErr)
+ Dim bOk As Boolean = EgtApplyAllMachinings(True, False, sErr)
EgtSetModified()
- ' Aggiorno visualizzazione e rritorno a cursore standard
+ ' Aggiorno visualizzazione e ritorno a cursore standard
EgtDraw()
Application.Current.MainWindow.ForceCursor = False
Application.Current.MainWindow.Cursor = Cursors.Arrow
diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb
index 0bf1fb4..a1563bc 100644
--- a/ProjectPage/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb
+++ b/ProjectPage/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb
@@ -417,6 +417,11 @@ Namespace EgtCAM5
Public Sub Generate(ByVal param As Object)
' Recupero la fase corrente
Dim nPhase As Integer = EgtGetCurrPhase()
+ ' Aggiorno le lavorazioni
+ If Not UpdateAllMachinings() Then
+ EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True)
+ Return
+ End If
' Eseguo
Dim sCurrFilePath As String = String.Empty
EgtGetCurrFilePath(sCurrFilePath)
@@ -446,11 +451,7 @@ Namespace EgtCAM5
Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(MSG_SIMULATION + 32))
End If
' Torno alla fase originale (o alla prima se non definita)
- If nPhase = 0 Then
- EgtSetCurrPhase(1, True)
- Else
- EgtSetCurrPhase(nPhase, True)
- End If
+ EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True)
End Sub
#End Region ' GenerateCommand
@@ -459,7 +460,31 @@ Namespace EgtCAM5
#Region "METHODS"
+ Private Function UpdateAllMachinings() As Boolean
+ ' Eseguo ricalcolo
+ Dim bModified As Boolean = EgtGetModified()
+ Dim sErr As String = String.Empty
+ Dim bOk As Boolean = EgtApplyAllMachinings(False, False, sErr)
+ ' In caso di errori, li segnalo
+ If Not bOk Then
+ If Not String.IsNullOrEmpty(sErr) Then
+ MessageBox.Show(sErr, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Exclamation)
+ Else
+ MessageBox.Show(EgtMsg(MSG_SIMULATION + 6), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Error)
+ End If
+ End If
+ If Not bModified Then EgtResetModified()
+ Return bOk
+ End Function
+
Private Sub InitializeSimulation()
+ ' Recupero la fase corrente
+ Dim nPhase As Integer = EgtGetCurrPhase()
+ ' Aggiorno le lavorazioni
+ If Not UpdateAllMachinings() Then
+ EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True)
+ Return
+ End If
' Costringo ad aggiornare UI
UpdateUI()
' Imposto stato corrente
diff --git a/ProjectPage/ProjectViewModel.vb b/ProjectPage/ProjectViewModel.vb
index a1eca6a..dfe556f 100644
--- a/ProjectPage/ProjectViewModel.vb
+++ b/ProjectPage/ProjectViewModel.vb
@@ -250,7 +250,7 @@ Namespace EgtCAM5
If Not m_Controller.SetCommandLog(bLuaReg, m_sTempDir, sCmdLogFile) Then
EgtOutLog("Command log not started")
If Environment.GetCommandLineArgs.Count() <= 1 Then
- MessageBox.Show("Command log not started", "TestEIn Warning",
+ MessageBox.Show("Command log not started", "EgtCAM5 Warning",
MessageBoxButton.OK, MessageBoxImage.Warning)
End If
End If
@@ -300,48 +300,58 @@ Namespace EgtCAM5
End Sub
Private Sub ProcessCommandLine()
- ' Recupero eventuali parametri da linea di comando
- Dim bOpen As Boolean = False
- If Environment.GetCommandLineArgs.Count() > 1 Then
- Dim sFile As String = Environment.GetCommandLineArgs(1)
- If Not String.IsNullOrWhiteSpace(sFile) Then
- Dim nFileType As Integer = EgtGetFileType(sFile)
- Select Case nFileType
- Case FT.NGE, FT.NFE
- m_Controller.OpenProject(sFile, False)
- bOpen = True
- Case FT.DXF, FT.STL, FT.CNC, FT.CSF, FT.BTL
- m_Controller.ImportProject(sFile, False)
- bOpen = True
- Case FT.TSC, FT.LUA
- m_Controller.Exec(sFile, False)
- bOpen = True
- End Select
- If IO.Path.GetExtension(sFile).ToLower() = ".ddf" Then
- ' Se manca direttorio uso quello di default
- If String.IsNullOrWhiteSpace(IO.Path.GetDirectoryName(sFile)) Then
- Dim sDefDir As String = String.Empty
- GetPrivateProfileString(S_DOORS, K_DDFDEFAULTDIR, "", sDefDir)
- sFile = sDefDir & "\" & sFile
- End If
- ' Ricoscimento flag
- Dim nPar2 As Integer = 0
- If Environment.GetCommandLineArgs.Count() > 2 Then
- nPar2 = CInt(Environment.GetCommandLineArgs(2))
- End If
- Dim bNcGen As Boolean = (nPar2 >= 1)
- Dim bExit As Boolean = (nPar2 >= 2)
- ' Esecuzione
- CreateDoors(sFile, bNcGen, bExit)
- EgtZoom(ZM.ALL)
- Application.Msn.NotifyColleagues(Application.EMITTITLE)
- ' Se richiesta uscita immediata
- If bExit Then
- Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATIONCOMMAND)
- End If
- End If
+ ' Se non ci sono parametri su linea di comando, esco
+ If Environment.GetCommandLineArgs.Count() <= 1 Then Return
+ ' Recupero il primo vero parametro che dovrebbe essere il nome con estensione di un file
+ Dim sFile As String = Environment.GetCommandLineArgs(1)
+ Dim sExt As String = Path.GetExtension(sFile).ToLower()
+ If String.IsNullOrWhiteSpace(sFile) OrElse String.IsNullOrWhiteSpace(sExt) Then Return
+ ' Se file ddf, gestione creazione porta con Doors
+ If sExt = ".ddf" Then
+ ' Se manca direttorio uso quello di default
+ If String.IsNullOrWhiteSpace(IO.Path.GetDirectoryName(sFile)) Then
+ Dim sDefDir As String = String.Empty
+ GetPrivateProfileString(S_DOORS, K_DDFDEFAULTDIR, "", sDefDir)
+ sFile = sDefDir & "\" & sFile
End If
+ ' Ricoscimento flag
+ Dim nFlag As Integer = 0
+ If Environment.GetCommandLineArgs.Count() > 2 Then Int32.TryParse(Environment.GetCommandLineArgs(2), nFlag)
+ Dim bNcGen As Boolean = (nFlag >= 1)
+ Dim bExit As Boolean = (nFlag >= 2)
+ ' Esecuzione
+ CreateDoors(sFile, bNcGen, bExit)
+ EgtZoom(ZM.ALL)
+ Application.Msn.NotifyColleagues(Application.EMITTITLE)
+ ' Se richiesta uscita immediata
+ If bExit Then Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATIONCOMMAND)
+ Return
End If
+ ' Se file tol, gestione aggiornamento dei dati degli utensili
+ If sExt = ".tol" Then
+ ' Recupero nome macchina
+ Dim sMachine As String = String.Empty
+ If Environment.GetCommandLineArgs.Count() > 2 Then sMachine = Environment.GetCommandLineArgs(2)
+ ' Recupero flag
+ Dim nFlag As Integer = 0
+ If Environment.GetCommandLineArgs.Count() > 3 Then Int32.TryParse(Environment.GetCommandLineArgs(3), nFlag)
+ Dim bTest As Boolean = (nFlag = 0)
+ ' Esecuzione
+ UpdateTools(sFile, sMachine, bTest)
+ ' Uscita immediata
+ Application.Msn.NotifyColleagues(Application.CLOSEAPPLICATIONCOMMAND)
+ Return
+ End If
+ ' Altrimenti gestione file standard
+ Dim nFileType As Integer = EgtGetFileType(sFile)
+ Select Case nFileType
+ Case FT.NGE, FT.NFE
+ m_Controller.OpenProject(sFile, False)
+ Case FT.DXF, FT.STL, FT.CNC, FT.CSF, FT.BTL
+ m_Controller.ImportProject(sFile, False)
+ Case FT.TSC, FT.LUA
+ m_Controller.Exec(sFile, False)
+ End Select
End Sub
Private Sub EmitTitle()
diff --git a/ToolsDbWindow/ToolsUpdate.vb b/ToolsDbWindow/ToolsUpdate.vb
new file mode 100644
index 0000000..2ea6c07
--- /dev/null
+++ b/ToolsDbWindow/ToolsUpdate.vb
@@ -0,0 +1,210 @@
+Imports System.IO
+Imports System.Globalization
+Imports EgtUILib
+
+Module ToolsUpdate
+
+ ' Classe CLD (correttore, lunghezza, diametro) di un utensile
+ Class CldTool
+ ' Membri
+ Friend nCorr As Integer
+ Friend dLen As Double
+ Friend dDiam As Double
+ ' Costruttori
+ Sub New()
+ nCorr = 0
+ dLen = 0
+ dDiam = 0
+ End Sub
+ Sub New(nC As Integer, dL As Double, dD As Double)
+ nCorr = nC
+ dLen = dL
+ dDiam = dD
+ End Sub
+ End Class
+
+ ' Classe di confronto tra utensili basata sul numero di correttore
+ Class CldToolComparer
+ Implements IComparer(Of CldTool)
+ ' Funzione di confronto
+ Friend Function Compare(x As CldTool, y As CldTool) As Integer Implements IComparer(Of CldTool).Compare
+ If x.nCorr > y.nCorr Then Return 1
+ If x.nCorr < y.nCorr Then Return -1
+ Return 0
+ End Function
+ End Class
+
+ Friend Function UpdateTools(sFile As String, sMachine As String, bTest As Boolean) As Boolean
+ EgtOutLog("-- Start UpdateTools --")
+ ' Inizializzo stato senza errori
+ Dim nErr As Integer = 0
+ Dim sErrFile As String = Path.ChangeExtension(sFile, ".txt")
+ Try
+ My.Computer.FileSystem.DeleteFile(sErrFile)
+ Catch ex As Exception
+ End Try
+ ' Vettore di Cld degli utensili
+ Dim vCldTool As New List(Of CldTool)(256)
+ ' Lettura file utensili
+ If Not LoadTools(sFile, vCldTool) Then
+ WriteErrorFile(sErrFile, 1, Nothing)
+ Return False
+ End If
+ ' Imposto la macchina corrente
+ If Not EgtSetCurrMachine(sMachine) Then
+ WriteErrorFile(sErrFile, 2, Nothing)
+ Return False
+ End If
+ ' Eseguo aggiornamento
+ Dim sInfo As String = String.Empty
+ If Not ExecUpdate(vCldTool, bTest, sInfo) Then
+ WriteErrorFile(sErrFile, 3, sInfo)
+ Return False
+ End If
+ ' Salvo informazioni
+ WriteErrorFile(sErrFile, 0, sInfo)
+ Return True
+ End Function
+
+ Private Function LoadTools(sFile As String, ByRef vCldTool As List(Of CldTool)) As Boolean
+ ' Classe di confronto
+ Dim ToolComp As New CldToolComparer
+ ' Leggo i dati degli utensili dal file
+ Try
+ Dim sr As StreamReader = New StreamReader(sFile)
+ Do While sr.Peek() > -1
+ ' Leggo la linea
+ Dim sLine As String = sr.ReadLine()
+ ' La divido usando come separatore ';'
+ Dim sItems() As String = sLine.Split(";".ToCharArray)
+ ' Ci devono essere almeno tre parti
+ If sItems.Count() < 3 Then Continue Do
+ ' Leggo i valori
+ Dim OneCldT As New CldTool
+ If Not Integer.TryParse(sItems(0), OneCldT.nCorr) OrElse OneCldT.nCorr = 0 Then Continue Do
+ If Not Double.TryParse(sItems(1), NumberStyles.Float, CultureInfo.InvariantCulture, OneCldT.dLen) Then Continue Do
+ If Not Double.TryParse(sItems(2), NumberStyles.Float, CultureInfo.InvariantCulture, OneCldT.dDiam) Then Continue Do
+ ' Se non c'è già un record con lo stesso correttore, lo inserisco
+ Dim nI As Integer = vCldTool.BinarySearch(OneCldT, ToolComp)
+ If nI < 0 Then
+ Dim nNextI = Not nI
+ vCldTool.Insert(nNextI, OneCldT)
+ End If
+ Loop
+ sr.Close()
+ Return True
+ Catch ex As Exception
+ Return False
+ End Try
+ End Function
+
+ Private Function ExecUpdate(ByRef vCldTool As List(Of CldTool), bTest As Boolean, ByRef sInfo As String) As Boolean
+ ' Classe di confronto
+ Dim ToolComp As New CldToolComparer
+ ' Ciclo su tutti gli utensili nel DB
+ Const ALL_TOOLS As Integer = MCH_TF.DRILLBIT + MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE + MCH_TF.CHISEL + MCH_TF.COMPO
+ Dim sName As String = String.Empty
+ Dim nType As Integer = 0
+ Dim bNext As Boolean = EgtTdbGetFirstTool(ALL_TOOLS, sName, nType)
+ While bNext
+ EgtTdbSetCurrTool(sName)
+ Dim nCorr As Integer = 0
+ EgtTdbGetCurrToolParam(MCH_TP.CORR, nCorr)
+ If nCorr > 0 Then
+ Dim nI As Integer = vCldTool.BinarySearch(New CldTool(nCorr, 0, 0), ToolComp)
+ If nI >= 0 Then
+ ' Recupero i dati dell'utensile nel DB
+ Dim dLen As Double = 0
+ EgtTdbGetCurrToolParam(MCH_TP.LEN, dLen)
+ Dim dTotLen As Double = 0
+ EgtTdbGetCurrToolParam(MCH_TP.TOTLEN, dTotLen)
+ Dim dDiam As Double = 0
+ EgtTdbGetCurrToolParam(MCH_TP.DIAM, dDiam)
+ Dim dTotDiam As Double = 0
+ EgtTdbGetCurrToolParam(MCH_TP.TOTDIAM, dTotDiam)
+ Dim dMaxMat As Double = 0
+ EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dMaxMat)
+ ' Modifiche della lunghezza
+ Dim dDeltaL As Double = 0
+ If vCldTool(nI).dLen > EPS_SMALL Then
+ dDeltaL = vCldTool(nI).dLen - dLen
+ EgtTdbSetCurrToolParam(MCH_TP.LEN, vCldTool(nI).dLen)
+ EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dTotLen + dDeltaL)
+ End If
+ ' Modifiche del diametro
+ Dim dDeltaD As Double = 0
+ If vCldTool(nI).dDiam > EPS_SMALL And
+ (nType = MCH_TY.SAW_STD Or nType = MCH_TY.SAW_FLAT Or nType = MCH_TY.MILL_STD Or nType = MCH_TY.MILL_NOTIP) Then
+ dDeltaD = vCldTool(nI).dDiam - dDiam
+ EgtTdbSetCurrToolParam(MCH_TP.DIAM, vCldTool(nI).dDiam)
+ EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dTotDiam + dDeltaD)
+ End If
+ ' Aggiornamento del massimo materiale lavorabile
+ If nType = MCH_TY.SAW_STD Or nType = MCH_TY.SAW_FLAT Then
+ EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dMaxMat + dDeltaD / 2)
+ Else
+ EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dMaxMat + dDeltaL)
+ End If
+ ' Se non è test salvo modifiche utensile
+ If Not bTest Then EgtTdbSaveCurrTool()
+ ' informazioni
+ Dim sOut As String = sName & " (" & ToolTypeToString(nType) & ")" & " C=" & nCorr.ToString() &
+ " L=" & dLen.ToString("F3", CultureInfo.InvariantCulture) &
+ " D=" & dDiam.ToString("F3", CultureInfo.InvariantCulture) &
+ " NewL=" & vCldTool(nI).dLen.ToString("F3", CultureInfo.InvariantCulture) &
+ " NewD=" & vCldTool(nI).dDiam.ToString("F3", CultureInfo.InvariantCulture)
+ sInfo &= sOut & vbCrLf
+ EgtOutLog(sOut)
+ Else
+ Dim sOut As String = sName & " (" & ToolTypeToString(nType) & ")" & " C=" & nCorr.ToString() & " not found"
+ sInfo &= sOut & vbCrLf
+ EgtOutLog(sOut)
+ End If
+ Else
+ Dim sOut As String = sName & " (" & ToolTypeToString(nType) & ")" & " without corrector"
+ sInfo &= sOut & vbCrLf
+ EgtOutLog(sOut)
+ End If
+ bNext = EgtTdbGetNextTool(ALL_TOOLS, sName, nType)
+ End While
+ ' Se non è test, salvo il DB utensili modificato
+ If Not bTest Then EgtTdbSave()
+ Return True
+ End Function
+
+ Private Function ToolTypeToString(nType As Integer) As String
+ Select Case nType
+ Case MCH_TY.DRILL_STD
+ Return "Drill"
+ Case MCH_TY.DRILL_LONG
+ Return "LongDrill"
+ Case MCH_TY.SAW_STD
+ Return "Saw"
+ Case MCH_TY.SAW_FLAT
+ Return "FlatSaw"
+ Case MCH_TY.MILL_STD
+ Return "Mill"
+ Case MCH_TY.MILL_NOTIP
+ Return "NoTipMill"
+ Case MCH_TY.CHISEL_STD
+ Return "Chisel"
+ Case MCH_TY.COMPO
+ Return "Compo"
+ Case Else
+ Return "Unknown"
+ End Select
+ End Function
+
+ Private Function WriteErrorFile(sErrFile As String, nErr As Integer, sInfo As String) As Boolean
+ Try
+ Dim sw As StreamWriter = New StreamWriter(sErrFile)
+ sw.WriteLine("Err=" & nErr.ToString())
+ If Not IsNothing(sInfo) Then sw.WriteLine(sInfo)
+ sw.Close()
+ Return True
+ Catch ex As Exception
+ Return False
+ End Try
+ End Function
+
+End Module