EgtCAM5 :
- aggiunto check Active nel Db utensili. - aggiunta creazione SetUp di default in base agli utensili Active nel Db. - aggiunta prima gestione movimento barre di ventose e ventose magnetiche.
This commit is contained in:
@@ -8,6 +8,8 @@ Imports EgtWPFLib5
|
||||
Public Class ToolsDbVM
|
||||
Inherits TabViewModel
|
||||
|
||||
Private Const SETUP_FILEEXTENSION As String = ".stu"
|
||||
|
||||
Friend Shared m_bActive As Boolean = False
|
||||
|
||||
Private m_Title As String
|
||||
@@ -73,6 +75,14 @@ Public Class ToolsDbVM
|
||||
End Get
|
||||
End Property
|
||||
|
||||
' visibilità parametro Active
|
||||
Private m_Active_Visibility As Boolean
|
||||
Public ReadOnly Property Active_Visibility As Visibility
|
||||
Get
|
||||
Return If(m_Active_Visibility, Visibility.Visible, Visibility.Collapsed)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private Sub OnCursorPos(ByVal sender As Object, ByVal sCursorPos As String) Handles m_ToolScene.OnCursorPos
|
||||
Application.Msn.NotifyColleagues(Application.NOTIFYCURRPOS, sCursorPos)
|
||||
End Sub
|
||||
@@ -265,6 +275,8 @@ Public Class ToolsDbVM
|
||||
' Passo all'item della lista il delegato alla funzuione che permette di disattivare la lista delle lavorazioni
|
||||
ToolTreeViewItem.m_delIsEnabledBtns = AddressOf IsEnabledBtns
|
||||
FamilyToolTreeViewItem.m_delIsEnabledBtns = AddressOf IsEnabledBtns
|
||||
' Passo all'item della lista il delegato alla funzuione che restituisce l'utensile selezionato
|
||||
ToolTreeViewItem.m_delGetSelectedTool = AddressOf GetSelectedTool
|
||||
|
||||
LoadSelectedMachineTools()
|
||||
|
||||
@@ -317,6 +329,8 @@ Public Class ToolsDbVM
|
||||
EgtOutLog("Error: SetUp configuration file not found!")
|
||||
End If
|
||||
|
||||
' leggo da ini se parametro Active è attivo
|
||||
m_Active_Visibility = (EgtUILib.GetPrivateProfileInt(S_TOOLS, K_ACTIVE, 0, IniFile.m_sCurrMachIniFilePath) <> 0)
|
||||
End Sub
|
||||
|
||||
#End Region ' Constructor
|
||||
@@ -365,6 +379,96 @@ Public Class ToolsDbVM
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function GetSelectedTool() As ToolTreeViewItem
|
||||
For Each ToolFamily In m_ToolsList
|
||||
For Each Tool In ToolFamily.Items
|
||||
If Tool.m_IsSelected Then
|
||||
Return DirectCast(Tool, ToolTreeViewItem)
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
Return Nothing
|
||||
End Function
|
||||
|
||||
' Funzione che aggiorna setup default con tool che hanno patametro Active
|
||||
Private 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 m_ToolsList
|
||||
For Each Tool In ToolFamily.Items
|
||||
Dim ToolItem As ToolTreeViewItem = DirectCast(Tool, 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
|
||||
|
||||
#End Region ' Methods
|
||||
|
||||
#Region "COMMANDS"
|
||||
@@ -616,6 +720,11 @@ Public Class ToolsDbVM
|
||||
EgtTdbSave()
|
||||
' Reset lua
|
||||
EgtLuaResetGlobVar("STU")
|
||||
' Se c'è il parametro Active sugli utensili
|
||||
If m_Active_Visibility Then
|
||||
' aggiorno setup di default
|
||||
UpdateDefSetup()
|
||||
End If
|
||||
' Chiusura finestra
|
||||
ToolTreeViewItem.m_delRemoveTool = Nothing
|
||||
ToolTreeViewItem.m_delErrorOnTool = Nothing
|
||||
|
||||
Reference in New Issue
Block a user