Files
EgtCAM5/ToolsDbWindow/MyToolDbWindowVM.vb
T
Renzo Lanza fe58578e65 EgtCAM5 :
- eliminati tutti gli Application.Msn.Register/NotifyColleagues e la classe Messenger. Ora tutto ciò che eseguivano è in funzioni/sub Friend chiamate tramite i riferimenti in Map.
2020-10-28 14:09:17 +00:00

109 lines
4.2 KiB
VB.net

Imports System.Windows.Forms.Integration
Imports System.Collections.ObjectModel
Imports System.Reflection
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class MyToolDbWindowVM
Inherits ToolDbWindowVM
Private Const SETUP_FILEEXTENSION As String = ".stu"
#Region "CONSTRUCTOR"
Sub New(sMachineDirPath As String, sMachineIniPath As String, ProjectSceneContext As Integer, Optional sMatType As String = "Wood")
MyBase.New(sMachineDirPath, sMachineIniPath, ProjectSceneContext, sMatType)
End Sub
#End Region ' Constructor
#Region "METHODS"
' Funzione che aggiorna setup default con tool che hanno parametro Active
Public Overrides Function UpdateDefSetup() As Boolean
InitSetupFile()
' Creo Setup
Dim DefSetup As New SetUpVM
' inizializzo ambiente setup
DefSetup.InitSetUp()
' resetto lista utensili e posizioni
DefSetup.ToolsList.Clear()
DefSetup.ClearAllPos()
DefSetup.LoadMachineTools()
' ciclo sugli utensili del db
For Each ToolFamily In ToolsList
For Each Tool In ToolFamily.Items
Dim ToolItem As EgtWPFLib5.ToolTreeViewItem = DirectCast(Tool, EgtWPFLib5.ToolTreeViewItem)
' verifico se Active
If ToolItem.Active Then
For Each TF In DefSetup.ToolsList
For TIndex = TF.Items.Count - 1 To 0 Step -1
Dim T As ToolItem = DirectCast(TF.Items(TIndex), ToolItem)
If ToolItem.Name = T.Name Then
DefSetup.ToolDoubleClick(T)
End If
Next
Next
End If
Next
Next
Dim DefSetupPath As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\SetUp"
Dim DefSetupName As String = String.Empty
EgtUILib.GetPrivateProfileString(S_SETUP, K_DEFAULT, "", DefSetupName, IniFile.m_sCurrMachIniFilePath)
DefSetupPath += "\" & DefSetupName & SETUP_FILEEXTENSION
If Not DefSetup.Save(DefSetupPath) Then EgtOutLog("Impossible to save default setup.")
Return True
End Function
' Inizializzo file Setup
Private Sub InitSetupFile()
' verifico che il file di configurazione attrezzaggio (lua) della macchina esista
If Not File.Exists(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA) Then
EgtOutLog("SetUp error: SetUp configuration file doesn't exist ")
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 7), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error)
Return
End If
' carico Lua che contiene le funzioni per ottenere le posizioni valide dell'utensile selezionato,
' e testa e uscita dell'utensile attrezzato
EgtLuaExecFile(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA)
' verifico che le teste riportate in configurazione esistano
Dim Index As Integer = 1
Dim nErr As Integer = 0
While nErr = 0
Dim sHead As String = String.Empty
nErr = 999
EgtLuaSetGlobIntVar("STU.INDEX", Index)
EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos")
' Leggo variabili
EgtLuaGetGlobStringVar("STU.HEAD", sHead)
EgtLuaGetGlobIntVar("STU.ERR", nErr)
If nErr = 0 Then
If EgtGetHeadExitCount(sHead) = 0 Then
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 8), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error)
Return
End If
End If
Index += 1
End While
' Verifico esistenza direttorio per attrezzaggi
Dim sDir As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\SetUp"
If Not Directory.Exists(sDir) Then
Try
Directory.CreateDirectory(sDir)
Catch ex As Exception
EgtOutLog("Error in SetupDir creation " & ex.ToString())
Return
End Try
End If
End Sub
Public Overrides Sub OnCursorPos(ByVal sender As Object, ByVal sCursorPos As String) 'Handles m_ToolScene.OnCursorPos
Map.refStatusBarVM.NotifyCurrPos(sCursorPos)
End Sub
#End Region ' Methods
End Class