893dda5b6a
- Aggiornamento attrezzaggio con lettura nuovi Lua.
1192 lines
46 KiB
VB.net
1192 lines
46 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
|
|
Namespace EgtCAM5
|
|
|
|
Public Class SetUpViewModel
|
|
|
|
Private m_Title As String
|
|
Public ReadOnly Property Title As String
|
|
Get
|
|
Return EgtMsg(MSG_SETUP + 1)
|
|
End Get
|
|
End Property
|
|
|
|
' Lista degli utensili
|
|
Private m_ToolsList As New ObservableCollection(Of FamilyToolItem)
|
|
Public Property ToolsList As ObservableCollection(Of FamilyToolItem)
|
|
Get
|
|
Return m_ToolsList
|
|
End Get
|
|
Set(value As ObservableCollection(Of FamilyToolItem))
|
|
m_ToolsList = value
|
|
End Set
|
|
End Property
|
|
|
|
' Lista dei gruppi di posizioni
|
|
Private m_PositionGroupList As New ObservableCollection(Of PositionGroup)
|
|
Public Property PositionGroupList As ObservableCollection(Of PositionGroup)
|
|
Get
|
|
Return m_PositionGroupList
|
|
End Get
|
|
Set(value As ObservableCollection(Of PositionGroup))
|
|
m_PositionGroupList = value
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property TcPosImage As String
|
|
Get
|
|
Dim sImagePath As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\SetUp\TcPosImage.png"
|
|
Return If(File.Exists(sImagePath), sImagePath, String.Empty)
|
|
End Get
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property TitleMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SETUP + 1)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ApplyMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SETUP + 2)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ArchiveMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SETUP + 3)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property RetrievesMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SETUP + 4)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
' Definizione comandi
|
|
Private m_cmdApply As ICommand
|
|
Private m_cmdArchive As ICommand
|
|
Private m_cmdRetrieves As ICommand
|
|
Private m_cmdCloseSetUp As ICommand
|
|
|
|
Sub New()
|
|
' rendo accessibile la lista posizioni a famiglie ed utensili per poterle attivare e disattivare
|
|
' (probabilmente da cambiare passandogli il riferimento alla creazione dell'utensile per non avere parametro shared)
|
|
FamilyToolItem.m_PositionGroupList = m_PositionGroupList
|
|
ToolItem.m_PositionGroupList = m_PositionGroupList
|
|
' rendo accessibile le liste utensili e posizioni alle uscite
|
|
ExitToolAssociation.sh_ToolsList = m_ToolsList
|
|
ExitToolAssociation.sh_PositionGroupList = m_PositionGroupList
|
|
' 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)
|
|
' carico lista utensili
|
|
LoadMachineTools()
|
|
' carico lista posizioni
|
|
LoadMachinePositions()
|
|
' Se esiste almeno una famiglia di utensili, la seleziono
|
|
If ToolsList.Count > 0 Then
|
|
ToolsList(0).IsSelected = True
|
|
ToolsList(0).NotifyPropertyChanged("IsSelected")
|
|
End If
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Method that search tools for the currently selected Machine and add it to the ToolsList.
|
|
''' </summary>
|
|
Private Sub LoadMachineTools()
|
|
' Creo lista utensili utilizzati dal gruppo di lavorazione corrente
|
|
Dim UsedToolList As New List(Of String)
|
|
Dim Machining As Integer = EgtGetFirstOperation()
|
|
While Machining <> GDB_ID.NULL
|
|
If EgtGetOperationType(Machining) >= MCH_OY.SAWING Then
|
|
EgtSetCurrMachining(Machining)
|
|
Dim Tuuid As String = String.Empty
|
|
EgtGetMachiningParam(MCH_MP.TUUID, Tuuid)
|
|
UsedToolList.Add(Tuuid)
|
|
End If
|
|
Machining = EgtGetNextOperation(Machining)
|
|
End While
|
|
' Creo lista utensili per grafica
|
|
Dim ActiveToolsFamilies() As ToolsFamily = ReadActiveToolsFamilies()
|
|
For Index = 0 To ActiveToolsFamilies.Count - 1
|
|
Dim FamilyToolItem As New FamilyToolItem(ActiveToolsFamilies(Index).FamilyName, ActiveToolsFamilies(Index).FamilyId)
|
|
m_ToolsList.Add(FamilyToolItem)
|
|
Dim nType As Integer = 0
|
|
Dim ToolName As String = String.Empty
|
|
Dim nValue As Integer = 0
|
|
Dim sValue As String = String.Empty
|
|
Dim ExitPar As String = String.Empty
|
|
Dim Head As String = String.Empty
|
|
Dim TcPos As String = String.Empty
|
|
Dim Uuid As String = String.Empty
|
|
Dim IsInCurrMachGroup As Boolean = False
|
|
If EgtTdbGetFirstTool(ActiveToolsFamilies(Index).FamilyId, ToolName, nType) Then
|
|
EgtTdbSetCurrTool(ToolName)
|
|
EgtTdbGetCurrToolParam(MCH_TP.EXIT_, nValue)
|
|
ExitPar = nValue.ToString()
|
|
EgtTdbGetCurrToolParam(MCH_TP.HEAD, sValue)
|
|
Head = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sValue)
|
|
TcPos = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.UUID, sValue)
|
|
Uuid = sValue
|
|
IsInCurrMachGroup = If(UsedToolList.Contains(Uuid), True, False)
|
|
FamilyToolItem.Items.Add(New ToolItem(ToolName, ExitPar, nType, Head, TcPos, Uuid, IsInCurrMachGroup))
|
|
While EgtTdbGetNextTool(ActiveToolsFamilies(Index).FamilyId, ToolName, nType)
|
|
EgtTdbSetCurrTool(ToolName)
|
|
EgtTdbGetCurrToolParam(MCH_TP.EXIT_, nValue)
|
|
ExitPar = nValue.ToString()
|
|
EgtTdbGetCurrToolParam(MCH_TP.HEAD, sValue)
|
|
Head = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sValue)
|
|
TcPos = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.UUID, sValue)
|
|
Uuid = sValue
|
|
IsInCurrMachGroup = If(UsedToolList.Contains(Uuid), True, False)
|
|
FamilyToolItem.Items.Add(New ToolItem(ToolName, ExitPar, nType, Head, TcPos, Uuid, IsInCurrMachGroup))
|
|
End While
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Method that search the machines in the correct folder and add to the MachinesList those valid.
|
|
''' </summary>
|
|
Private Function ReadActiveToolsFamilies() As ToolsFamily()
|
|
Dim ActiveToolsFamiliesList As New List(Of ToolsFamily)
|
|
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_DRILLBIT, 0, m_sCurrMachIniFilePath) <> 0 Then
|
|
ActiveToolsFamiliesList.Add(New ToolsFamily With {.FamilyId = MCH_TF.DRILLBIT, .FamilyName = EgtMsg(MSG_TOOLSDBPAGE + 1)})
|
|
End If
|
|
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_SAWBLADE, 0, m_sCurrMachIniFilePath) <> 0 Then
|
|
ActiveToolsFamiliesList.Add(New ToolsFamily With {.FamilyId = MCH_TF.SAWBLADE, .FamilyName = EgtMsg(MSG_TOOLSDBPAGE + 2)})
|
|
End If
|
|
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_MILL, 0, m_sCurrMachIniFilePath) <> 0 Then
|
|
ActiveToolsFamiliesList.Add(New ToolsFamily With {.FamilyId = MCH_TF.MILL, .FamilyName = EgtMsg(MSG_TOOLSDBPAGE + 3)})
|
|
End If
|
|
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_MORTISE, 0, m_sCurrMachIniFilePath) <> 0 Then
|
|
ActiveToolsFamiliesList.Add(New ToolsFamily With {.FamilyId = MCH_TF.MORTISE, .FamilyName = EgtMsg(MSG_TOOLSDBPAGE + 4)})
|
|
End If
|
|
If EgtUILib.GetPrivateProfileInt(S_TOOLS, K_COMPO, 0, m_sCurrMachIniFilePath) <> 0 Then
|
|
ActiveToolsFamiliesList.Add(New ToolsFamily With {.FamilyId = MCH_TF.COMPO, .FamilyName = EgtMsg(MSG_TOOLSDBPAGE + 5)})
|
|
End If
|
|
Return ActiveToolsFamiliesList.ToArray
|
|
End Function
|
|
|
|
Private Sub LoadMachinePositions()
|
|
' recupero il gruppo del setup
|
|
Dim nSetUpGroup As Integer = EgtGetCurrSetup()
|
|
' leggo l'attrezzaggio del progetto
|
|
Dim sPosition As String = String.Empty
|
|
Dim IniIndex As Integer = 1
|
|
' recupero stringa di ogni posizione
|
|
While EgtGetInfo(nSetUpGroup, K_POS & IniIndex, sPosition)
|
|
ReadPositionString(IniIndex, sPosition)
|
|
IniIndex += 1
|
|
End While
|
|
' altrimenti
|
|
Dim bFound As Boolean = False
|
|
For GroupIndex = 0 To m_PositionGroupList.Count - 1
|
|
If m_PositionGroupList(GroupIndex).PositionList.Count > 0 Then
|
|
bFound = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If Not bFound Then
|
|
' ne genero uno nuovo dalla configurazione nel file ini della macchina
|
|
Dim sTcPos As String = String.Empty
|
|
Dim sHead As String = String.Empty
|
|
Dim sGroup As String = String.Empty
|
|
Dim nErr As Double = 0
|
|
Dim Index As Integer = 1
|
|
While CreateStdPosFromPosIndex(Index)
|
|
Index += 1
|
|
End While
|
|
End If
|
|
|
|
End Sub
|
|
|
|
' Funzione che dato l'indice di una posizione, la crea secondo il modello standard presente nello script Lua
|
|
Private Function CreateStdPosFromPosIndex(Index As Integer) As Boolean
|
|
Dim sTcPos As String = String.Empty
|
|
Dim sHead As String = String.Empty
|
|
Dim sGroup As String = String.Empty
|
|
Dim nErr As Double = 0
|
|
EgtLuaSetGlobNumVar("STU.INDEX", Index)
|
|
EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos")
|
|
' Leggo variabili
|
|
EgtLuaGetGlobStringVar("STU.TCPOS", sTcPos)
|
|
EgtLuaGetGlobStringVar("STU.HEAD", sHead)
|
|
EgtLuaGetGlobStringVar("STU.GROUP", sGroup)
|
|
EgtLuaGetGlobNumVar("STU.ERR", nErr)
|
|
' se l'indice del gruppo è valido
|
|
Dim nGroup As Integer = If(Integer.TryParse(sGroup.Trim("G"c), nGroup), nGroup, 0)
|
|
If VerifyIndexValidity(CInt(nGroup)) Then
|
|
m_PositionGroupList(CInt(nGroup) - 1).PositionList.Add(New Position(sTcPos, sHead, EgtGetHeadExitCount(sHead)))
|
|
End If
|
|
If nErr = 0 Then Return True
|
|
Return False
|
|
End Function
|
|
|
|
' Funzione che verifica che l'indice del gruppo sia valido, esista, e nel caso non esistesse aggiunge i gruppi necessari
|
|
Private Function VerifyIndexValidity(nGroupIndex As Integer) As Boolean
|
|
' verifico che l'indice del gruppo sia valido
|
|
If nGroupIndex >= 1 Then
|
|
' verifico che l'indice del gruppo sia compreso nel range di quelli esistenti
|
|
If nGroupIndex <= m_PositionGroupList.Count Then
|
|
Return True
|
|
' se l'indice è maggiore di quelli presenti nella lista dei gruppi
|
|
Else
|
|
' aggiungo i gruppi che mancano fino all'indice del mio
|
|
For GroupIndex = m_PositionGroupList.Count To nGroupIndex - 1
|
|
m_PositionGroupList.Add(New PositionGroup)
|
|
Next
|
|
Return True
|
|
End If
|
|
' altrimenti
|
|
Else
|
|
' mi assicuro che esista il primo gruppo
|
|
VerifyIndexValidity(1)
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
' Funzione che dati l'indice della posizione e la sua stringa di attrezzaggio, carica l'attrezzaggio descritto
|
|
Private Sub ReadPositionString(nIndex As Integer, sPosition As String)
|
|
Dim sTcPos As String = String.Empty
|
|
Dim sHead As String = String.Empty
|
|
Dim sExitList As New List(Of String)
|
|
Dim sToolList As New List(Of String)
|
|
' la spezzo sui ;
|
|
Dim sItems() As String = sPosition.Split(";".ToCharArray)
|
|
' se c'è almeno un elemento sono sicuro che ci sia la T
|
|
If sItems.Count() >= 1 Then
|
|
Dim nGroup As Integer = 0
|
|
sTcPos = sItems(0)
|
|
' recupero il suo gruppo
|
|
If Not GetGroupFromTcPos(sTcPos, nGroup) Then
|
|
' se non lo trovo lo metto nel primo
|
|
nGroup = 1
|
|
End If
|
|
If Not VerifyIndexValidity(nGroup) Then
|
|
' se mi viene passato un indice non valido, lo metto nel primo
|
|
nGroup = 1
|
|
End If
|
|
' se ci sono almeno due elementi sono sicuro che ci sia la H
|
|
If sItems.Count >= 2 Then
|
|
sHead = sItems(1)
|
|
m_PositionGroupList(nGroup - 1).PositionList.Add(New Position(sTcPos, sHead, EgtGetHeadExitCount(sHead)))
|
|
' se ci sono almeno tre elementi sono sicuro che ci sia almeno un'uscita attrezzata
|
|
If sItems.Count >= 3 Then
|
|
' separo le uscite divise dalla ,
|
|
Dim sExitToolAssList() As String = sItems(2).Split(",".ToCharArray)
|
|
sExitList.Clear()
|
|
sToolList.Clear()
|
|
' creo le liste di uscite e utensili attrezzati ricavati
|
|
For AssIndex = 0 To sExitToolAssList.Count() - 1
|
|
Dim sExitToolAssItem() As String = sExitToolAssList(AssIndex).Split("/".ToCharArray)
|
|
If sExitToolAssItem.Count > 1 Then
|
|
sExitList.Add(sExitToolAssItem(0))
|
|
sToolList.Add(sExitToolAssItem(1))
|
|
End If
|
|
Next
|
|
' analizzo la lista di utensili attrezzati
|
|
For ToolIndex = 0 To sToolList.Count - 1
|
|
If Not String.IsNullOrEmpty(sToolList(ToolIndex)) Then
|
|
Dim TempTool As ToolItem = Nothing
|
|
Dim bFound As Boolean = False
|
|
' cerco l'utensile attrezzato nella lista utensili
|
|
For FamilyListIndex = 0 To m_ToolsList.Count - 1
|
|
For ToolListIndex = 0 To m_ToolsList(FamilyListIndex).Items.Count - 1
|
|
If m_ToolsList(FamilyListIndex).Items(ToolListIndex).Name = sToolList(ToolIndex) Then
|
|
' lo salvo in una variabile temporanea e lo tolgo dalla lista
|
|
TempTool = DirectCast(m_ToolsList(FamilyListIndex).Items(ToolListIndex), ToolItem)
|
|
m_ToolsList(FamilyListIndex).Items.Remove(m_ToolsList(FamilyListIndex).Items(ToolListIndex))
|
|
bFound = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If bFound Then Exit For
|
|
Next
|
|
' cerco la relativa uscita
|
|
For ExitIndex = 0 To m_PositionGroupList(nGroup - 1).PositionList(m_PositionGroupList(nGroup - 1).PositionList.Count - 1).ExitToolAssociationList.Count - 1
|
|
If m_PositionGroupList(nGroup - 1).PositionList(m_PositionGroupList(nGroup - 1).PositionList.Count - 1).ExitToolAssociationList(ExitIndex).ExitPar = sExitList(ToolIndex) Then
|
|
' vi metto l'utensile e segno l'uscita come occupata
|
|
m_PositionGroupList(nGroup - 1).PositionList(m_PositionGroupList(nGroup - 1).PositionList.Count - 1).ExitToolAssociationList(ExitIndex).Tool = TempTool
|
|
m_PositionGroupList(nGroup - 1).PositionList(m_PositionGroupList(nGroup - 1).PositionList.Count - 1).ExitToolAssociationList(ExitIndex).IsOccupied = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
Next
|
|
End If
|
|
' non è presente la H, quindi la recupero dal modello delle posizioni nel file MachIni
|
|
Else
|
|
CreateStdPosFromPosIndex(nIndex)
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
' Funzione che data una T restituisce il gruppo a cui appartiene
|
|
Private Function GetGroupFromTcPos(sTcPos As String, ByRef nGroup As Integer) As Boolean
|
|
Dim sGroup As String = String.Empty
|
|
Dim nErr As Double = 0
|
|
EgtLuaSetGlobStringVar("STU.TCPOS", sTcPos)
|
|
EgtLuaCallFunction("STU.GetGroupFromTcPos")
|
|
' Leggo variabili
|
|
EgtLuaGetGlobStringVar("STU.GROUP", sGroup)
|
|
EgtLuaGetGlobNumVar("STU.ERR", nErr)
|
|
If nErr = 0 Then
|
|
nGroup = If(Integer.TryParse(sGroup.Trim("G"c), nGroup), nGroup, 0)
|
|
Return True
|
|
End If
|
|
nGroup = 0
|
|
Return False
|
|
End Function
|
|
|
|
Private Function GetPositionFromTcPos(sTcPos As String, ByRef nPosIndex As Integer) As Boolean
|
|
Dim sPosition As String = String.Empty
|
|
Dim nErr As Double = 0
|
|
EgtLuaSetGlobStringVar("STU.TCPOS", sTcPos)
|
|
EgtLuaCallFunction("STU.GetPosFromTcPos")
|
|
' Leggo variabili
|
|
EgtLuaGetGlobStringVar("STU.POS", sPosition)
|
|
EgtLuaGetGlobNumVar("STU.ERR", nErr)
|
|
If nErr = 0 Then
|
|
nPosIndex = If(Integer.TryParse(sPosition.Replace("Pos", ""), nPosIndex), nPosIndex, -1)
|
|
Return If(nPosIndex >= 0, True, False)
|
|
End If
|
|
nPosIndex = -1
|
|
Return False
|
|
End Function
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "ApplyCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Exec.
|
|
''' </summary>
|
|
Public ReadOnly Property ApplyCommand As ICommand
|
|
Get
|
|
If m_cmdApply Is Nothing Then
|
|
m_cmdApply = New Command(AddressOf Apply)
|
|
End If
|
|
Return m_cmdApply
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Exec. This method is invoked by the ExecCommand.
|
|
''' </summary>
|
|
Public Sub Apply(param As Object)
|
|
' ricavo il gruppo in cui mettere l'attrezzaggio
|
|
Dim nSetUpGroup As Integer = EgtGetCurrSetup()
|
|
For GroupIndex = 0 To m_PositionGroupList.Count - 1
|
|
For PositionIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1
|
|
Dim sPosition As String = String.Empty
|
|
sPosition = m_PositionGroupList(GroupIndex).PositionList(PositionIndex).TcPos
|
|
Dim sExitToolAssociation As String = String.Empty
|
|
For AssIndex = 0 To m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList.Count - 1
|
|
sExitToolAssociation &= If(m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(AssIndex).IsOccupied, _
|
|
m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(AssIndex).ExitPar & "/" & _
|
|
m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(AssIndex).Tool.Name & ",", String.Empty)
|
|
Next
|
|
sExitToolAssociation = sExitToolAssociation.Trim(","c)
|
|
If Not String.IsNullOrEmpty(sExitToolAssociation) Then
|
|
sPosition &= ";" & m_PositionGroupList(GroupIndex).PositionList(PositionIndex).Head & ";" & sExitToolAssociation
|
|
End If
|
|
Dim nPosition As Integer
|
|
If GetPositionFromTcPos(m_PositionGroupList(GroupIndex).PositionList(PositionIndex).TcPos, nPosition) Then
|
|
EgtSetInfo(nSetUpGroup, K_POS & nPosition, sPosition)
|
|
End If
|
|
Next
|
|
Next
|
|
End Sub
|
|
|
|
#End Region ' ApplyCommand
|
|
|
|
#Region "ArchiveCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Exec.
|
|
''' </summary>
|
|
Public ReadOnly Property ArchiveCommand As ICommand
|
|
Get
|
|
If m_cmdArchive Is Nothing Then
|
|
m_cmdArchive = New Command(AddressOf Archive)
|
|
End If
|
|
Return m_cmdArchive
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Exec. This method is invoked by the ExecCommand.
|
|
''' </summary>
|
|
Public Sub Archive(param As Object)
|
|
' Direttorio per attrezzaggi
|
|
Dim sDir As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\SetUp"
|
|
Dim sPath As String = String.Empty
|
|
' Apertura dialogo di salvataggio
|
|
Dim SaveFileDialogView As New EgtWPFLib5.EgtSaveFileDialog
|
|
SaveFileDialogView.Title = EgtMsg(MSG_SETUP + 5)
|
|
SaveFileDialogView.Extension = ".stu"
|
|
SaveFileDialogView.Directory = sDir
|
|
SaveFileDialogView.FileName = String.Empty
|
|
If Not SaveFileDialogView.ShowDialog Then
|
|
Return
|
|
End If
|
|
sPath = SaveFileDialogView.FileName
|
|
|
|
' creo il file con il solo commento come prima linea
|
|
File.WriteAllLines(sPath, {"; Commento per evitare BOM con UTF-8"}, Text.Encoding.UTF8)
|
|
|
|
For GroupIndex = 0 To m_PositionGroupList.Count - 1
|
|
For PositionIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1
|
|
Dim sPosition As String = String.Empty
|
|
sPosition = m_PositionGroupList(GroupIndex).PositionList(PositionIndex).TcPos
|
|
Dim sExitToolAssociation As String = String.Empty
|
|
For AssIndex = 0 To m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList.Count - 1
|
|
sExitToolAssociation &= If(m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(AssIndex).IsOccupied, _
|
|
m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(AssIndex).ExitPar & "/" & _
|
|
m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(AssIndex).Tool.Name & ",", String.Empty)
|
|
Next
|
|
sExitToolAssociation = sExitToolAssociation.Trim(","c)
|
|
If Not String.IsNullOrEmpty(sExitToolAssociation) Then
|
|
sPosition &= ";" & m_PositionGroupList(GroupIndex).PositionList(PositionIndex).Head & ";" & sExitToolAssociation
|
|
End If
|
|
Dim nPosition As Integer
|
|
If GetPositionFromTcPos(m_PositionGroupList(GroupIndex).PositionList(PositionIndex).TcPos, nPosition) Then
|
|
EgtUILib.WritePrivateProfileString(S_GENERAL, K_POS & nPosition, sPosition, sPath)
|
|
End If
|
|
Next
|
|
Next
|
|
End Sub
|
|
|
|
#End Region ' ArchiveCommand
|
|
|
|
#Region "RetrievesCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Exec.
|
|
''' </summary>
|
|
Public ReadOnly Property RetrievesCommand As ICommand
|
|
Get
|
|
If m_cmdRetrieves Is Nothing Then
|
|
m_cmdRetrieves = New Command(AddressOf Retrieves)
|
|
End If
|
|
Return m_cmdRetrieves
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Exec. This method is invoked by the ExecCommand.
|
|
''' </summary>
|
|
Public Sub Retrieves(param As Object)
|
|
' Direttorio per attrezzaggi
|
|
Dim sDir As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\SetUp"
|
|
Dim sPath As String = String.Empty
|
|
' Apertura dialogo di salvataggio
|
|
Dim OpenFileDialogView As New EgtWPFLib5.EgtOpenFileDialog
|
|
OpenFileDialogView.Title = EgtMsg(MSG_SETUP + 5)
|
|
OpenFileDialogView.Filter = "*.stu"
|
|
OpenFileDialogView.Directory = sDir
|
|
OpenFileDialogView.FileName = String.Empty
|
|
If Not OpenFileDialogView.ShowDialog Then
|
|
Return
|
|
End If
|
|
sPath = OpenFileDialogView.FileName
|
|
|
|
' resetto lista utensili e posizioni
|
|
m_ToolsList.Clear()
|
|
m_PositionGroupList.Clear()
|
|
'ricarico lista utensili
|
|
LoadMachineTools()
|
|
' leggo l'attrezzaggio dal file scelto
|
|
Dim sPosition As String = String.Empty
|
|
Dim IniIndex As Integer = 1
|
|
' recupero stringa di ogni posizione
|
|
While EgtUILib.GetPrivateProfileString(S_GENERAL, K_POS & IniIndex, String.Empty, sPosition, sPath) > 0
|
|
ReadPositionString(IniIndex, sPosition)
|
|
IniIndex += 1
|
|
End While
|
|
' verifico se disabilitare questa posizione in base all'utensile correntemente selezionato
|
|
If Not TypeOf param Is ToolItem Then
|
|
' disabilito tutte le uscite tranne quelle occupate
|
|
For GroupIndex = 0 To m_PositionGroupList.Count - 1
|
|
For PosIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1
|
|
m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetNotValidPos()
|
|
Next
|
|
Next
|
|
Else
|
|
Dim SelTool As ToolItem = DirectCast(param, ToolItem)
|
|
' abilito e disabilito tutte le uscite in base all'utensile selezionato
|
|
For GroupIndex = 0 To m_PositionGroupList.Count - 1
|
|
For PosIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1
|
|
m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetIsValidPosFromTool(SelTool.Uuid)
|
|
Next
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' RetrievesCommand
|
|
|
|
#Region "CloseSetUpCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that remove the current selected machining.
|
|
''' </summary>
|
|
Public ReadOnly Property CloseSetUpCommand() As ICommand
|
|
Get
|
|
If m_cmdCloseSetUp Is Nothing Then
|
|
m_cmdCloseSetUp = New RelayCommand(AddressOf CloseSetUp)
|
|
End If
|
|
Return m_cmdCloseSetUp
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
|
|
''' </summary>
|
|
Public Sub CloseSetUp()
|
|
' Reset lua
|
|
EgtLuaResetGlobVar("STU")
|
|
|
|
' Chiusura finestra
|
|
For Each Window In Application.Current.Windows
|
|
If TypeOf Window Is SetUpView Then
|
|
Dim SetUpWindow As SetUpView = DirectCast(Window, SetUpView)
|
|
SetUpWindow.Close()
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
#End Region ' CloseSetUpCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class
|
|
|
|
End Namespace
|
|
|
|
Public Class PositionGroup
|
|
|
|
' Lista delle posizioni
|
|
Private m_PositionList As New ObservableCollection(Of Position)
|
|
Public Property PositionList As ObservableCollection(Of Position)
|
|
Get
|
|
Return m_PositionList
|
|
End Get
|
|
Set(value As ObservableCollection(Of Position))
|
|
m_PositionList = value
|
|
End Set
|
|
End Property
|
|
|
|
Sub New()
|
|
End Sub
|
|
|
|
Sub New(PositionList As ObservableCollection(Of Position))
|
|
m_PositionList = PositionList
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class Position
|
|
|
|
Private Const INVALIDPOS As String = ""
|
|
|
|
Private m_TcPos As String
|
|
Public Property TcPos As String
|
|
Get
|
|
Return m_TcPos
|
|
End Get
|
|
Set(value As String)
|
|
m_TcPos = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Head As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Head
|
|
''' </summary>
|
|
Friend Property Head As String
|
|
Get
|
|
Return m_Head
|
|
End Get
|
|
Set(value As String)
|
|
If value = String.Empty Or value <> m_Head Then
|
|
m_Head = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
' Lista delle uscite con relativi utensili associati
|
|
Private m_ExitToolAssociationList As New ObservableCollection(Of ExitToolAssociation)
|
|
Public Property ExitToolAssociationList As ObservableCollection(Of ExitToolAssociation)
|
|
Get
|
|
Return m_ExitToolAssociationList
|
|
End Get
|
|
Set(value As ObservableCollection(Of ExitToolAssociation))
|
|
m_ExitToolAssociationList = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub SetIsValidPosFromTool(TUuid As String)
|
|
EgtLuaSetGlobStringVar("STU.TUUID", TUuid)
|
|
EgtLuaSetGlobStringVar("STU.TCPOS", m_TcPos)
|
|
EgtLuaCallFunction("STU.GetValidHeadExitForPos")
|
|
' Leggo variabili
|
|
Dim sHead As String = String.Empty
|
|
EgtLuaGetGlobStringVar("STU.HEAD", sHead)
|
|
Dim nExit As Double = 0
|
|
EgtLuaGetGlobNumVar("STU.EXIT", nExit)
|
|
Dim nErr As Double = 0
|
|
EgtLuaGetGlobNumVar("STU.ERR", nErr)
|
|
If nErr <> 0 Then
|
|
' disattivo tutte le uscite tranne quelle attrezzate
|
|
For ExitIndex = 0 To ExitToolAssociationList.Count - 1
|
|
If ExitToolAssociationList(ExitIndex).IsOccupied Then
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = True
|
|
ExitToolAssociationList(ExitIndex).IsValidPos = False
|
|
Else
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = False
|
|
End If
|
|
Next
|
|
Dim sToolName As String = String.Empty
|
|
EgtTdbGetToolFromUUID(TUuid, sToolName)
|
|
EgtOutLog("Error in setup! Tool:" & sToolName & " TcPos: " & m_TcPos)
|
|
Return
|
|
End If
|
|
' verifico se la posizione è libera o c'è un utensile attrezzato
|
|
Dim PosIsOccupied As Boolean = False
|
|
For ExitIndex = 0 To ExitToolAssociationList.Count - 1
|
|
If ExitToolAssociationList(ExitIndex).IsOccupied Then
|
|
PosIsOccupied = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
' se la posizione non è valida, disattivo tutte le uscite tranne quelle attrezzate
|
|
If sHead = INVALIDPOS Then
|
|
For ExitIndex = 0 To ExitToolAssociationList.Count - 1
|
|
If ExitToolAssociationList(ExitIndex).IsOccupied Then
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = True
|
|
ExitToolAssociationList(ExitIndex).IsValidPos = False
|
|
Else
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = False
|
|
End If
|
|
Next
|
|
' altrimenti, se la posizione nell'attrezzaggio è vuota
|
|
ElseIf Not PosIsOccupied Then
|
|
' se l'uscita restituita esiste
|
|
If ExitToolAssociationList.Count >= nExit Then
|
|
' disattivo tutte le uscite tranne quella restituita
|
|
For ExitIndex = 0 To ExitToolAssociationList.Count - 1
|
|
If ExitIndex + 1 = nExit Then
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = True
|
|
ExitToolAssociationList(ExitIndex).IsValidPos = True
|
|
Else
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = False
|
|
End If
|
|
Next
|
|
' altrimenti lascio attiva solo la prima uscita
|
|
Else
|
|
ExitToolAssociationList(0).IsEnabledPos = True
|
|
For ExitIndex = 1 To ExitToolAssociationList.Count - 1
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = False
|
|
Next
|
|
End If
|
|
' altrimenti, se le teste coincidono
|
|
ElseIf sHead = Head Then
|
|
' se l'uscita restituita è libera la attivo e disattivo tutte le altre non occupate
|
|
If Not ExitToolAssociationList(CInt(nExit) - 1).IsOccupied Then
|
|
For ExitIndex = 0 To ExitToolAssociationList.Count - 1
|
|
If ExitIndex = nExit - 1 Then
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = True
|
|
ExitToolAssociationList(ExitIndex).IsValidPos = True
|
|
ElseIf ExitToolAssociationList(ExitIndex).IsOccupied Then
|
|
ExitToolAssociationList(ExitIndex).IsValidPos = False
|
|
Else
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = False
|
|
End If
|
|
Next
|
|
' altrimenti le disattivo tutte tranne quelle occupate
|
|
Else
|
|
For ExitIndex = 0 To ExitToolAssociationList.Count - 1
|
|
If ExitToolAssociationList(ExitIndex).IsOccupied Then
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = True
|
|
If ExitIndex = CInt(nExit) - 1 Then
|
|
ExitToolAssociationList(ExitIndex).IsValidPos = True
|
|
Else
|
|
ExitToolAssociationList(ExitIndex).IsValidPos = False
|
|
End If
|
|
Else
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = False
|
|
End If
|
|
Next
|
|
End If
|
|
' altrimenti le disattivo tutte
|
|
Else
|
|
For ExitIndex = 0 To ExitToolAssociationList.Count - 1
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = False
|
|
Next
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Friend Sub SetNotValidPos()
|
|
' le disattivo tutte tranne quelle occupate
|
|
For ExitIndex = 0 To ExitToolAssociationList.Count - 1
|
|
If ExitToolAssociationList(ExitIndex).IsOccupied Then
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = True
|
|
ExitToolAssociationList(ExitIndex).IsValidPos = Nothing
|
|
Else
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = False
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
|
|
#End Region ' Methods
|
|
|
|
Sub New(TcPos As String, Head As String, ExitNum As Integer)
|
|
Me.TcPos = TcPos
|
|
Me.Head = Head
|
|
For ExitIndex = 1 To ExitNum
|
|
ExitToolAssociationList.Add(New ExitToolAssociation(ExitIndex.ToString, Me))
|
|
Next
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class ExitToolAssociation
|
|
Implements INotifyPropertyChanged
|
|
|
|
' Riferimento alla lista utensili
|
|
Friend Shared sh_ToolsList As ObservableCollection(Of FamilyToolItem)
|
|
' riferimento alla lista posizioni
|
|
Friend Shared sh_PositionGroupList As ObservableCollection(Of PositionGroup)
|
|
' Riferimento alla posizione di questa uscita
|
|
Private m_MyPos As Position
|
|
|
|
Private m_IsOccupied As Boolean
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Exit
|
|
''' </summary>
|
|
Public Property IsOccupied As Boolean
|
|
Get
|
|
Return m_IsOccupied
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_IsOccupied Then
|
|
m_IsOccupied = value
|
|
NotifyPropertyChanged("IsOccupied")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsEnabledPos As Boolean
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Exit
|
|
''' </summary>
|
|
Public Property IsEnabledPos As Boolean
|
|
Get
|
|
Return m_IsEnabledPos
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_IsEnabledPos Then
|
|
m_IsEnabledPos = value
|
|
NotifyPropertyChanged("IsEnabledPos")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsValidPos As Boolean?
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Exit
|
|
''' </summary>
|
|
Public Property IsValidPos As Boolean?
|
|
Get
|
|
Return m_IsValidPos
|
|
End Get
|
|
Set(value As Boolean?)
|
|
m_IsValidPos = value
|
|
NotifyPropertyChanged("ExitBtnBackgroundCol")
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property ExitBtnBackgroundCol As SolidColorBrush
|
|
Get
|
|
If IsNothing(m_IsValidPos) Then
|
|
Return New SolidColorBrush(Color.FromArgb(255, 221, 221, 221))
|
|
ElseIf m_IsValidPos Then
|
|
Return EgaltechGreen
|
|
Else
|
|
Return EgaltechYellow
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Private m_Exit As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Exit
|
|
''' </summary>
|
|
Public Property ExitPar As String
|
|
Get
|
|
Return m_Exit
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_Exit Then
|
|
m_Exit = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Tool As ToolItem
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Uuid
|
|
''' </summary>
|
|
Public Property Tool As ToolItem
|
|
Get
|
|
Return m_Tool
|
|
End Get
|
|
Set(value As ToolItem)
|
|
m_Tool = value
|
|
NotifyPropertyChanged("Tool")
|
|
End Set
|
|
End Property
|
|
|
|
' Definizione comandi
|
|
Private m_cmdSetUpTool As ICommand
|
|
|
|
#Region "CONSTRUCTORS"
|
|
|
|
Sub New(ExitPar As String, MyPos As Position)
|
|
Me.ExitPar = ExitPar
|
|
m_MyPos = MyPos
|
|
End Sub
|
|
|
|
#End Region ' Constructors
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "SetUpToolCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Exec.
|
|
''' </summary>
|
|
Public ReadOnly Property SetUpToolCommand As ICommand
|
|
Get
|
|
If m_cmdSetUpTool Is Nothing Then
|
|
m_cmdSetUpTool = New Command(AddressOf SetUpTool)
|
|
End If
|
|
Return m_cmdSetUpTool
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Exec. This method is invoked by the ExecCommand.
|
|
''' </summary>
|
|
Public Sub SetUpTool(param As Object)
|
|
If m_IsOccupied Then
|
|
' se quello selezionato nella lista non è un utensile esco
|
|
If Not TypeOf param Is ToolItem Then
|
|
m_IsOccupied = False
|
|
NotifyPropertyChanged("IsOccupied")
|
|
Return
|
|
End If
|
|
Dim SelTool As ToolItem = DirectCast(param, ToolItem)
|
|
' verifico se devo cambiare la testa
|
|
|
|
|
|
|
|
|
|
EgtLuaSetGlobStringVar("STU.TUUID", SelTool.Uuid)
|
|
EgtLuaSetGlobStringVar("STU.TCPOS", m_MyPos.TcPos)
|
|
EgtLuaCallFunction("STU.GetValidHeadExitForPos")
|
|
' Leggo variabili
|
|
Dim sHead As String = String.Empty
|
|
EgtLuaGetGlobStringVar("STU.HEAD", sHead)
|
|
Dim nExit As Double = 0
|
|
EgtLuaGetGlobNumVar("STU.EXIT", nExit)
|
|
Dim nErr As Double = 0
|
|
EgtLuaGetGlobNumVar("STU.ERR", nErr)
|
|
If nErr <> 0 Then
|
|
Dim sToolName As String = String.Empty
|
|
EgtTdbGetToolFromUUID(SelTool.Uuid, sToolName)
|
|
EgtOutLog("Error in setup! Tool:" & sToolName & " TcPos: " & m_MyPos.TcPos)
|
|
Return
|
|
End If
|
|
' se la testa restituita coincide con quella della posizione
|
|
If Not m_MyPos.Head = sHead Then
|
|
m_MyPos.Head = sHead
|
|
For ExitIndex = m_MyPos.ExitToolAssociationList.Count To EgtGetHeadExitCount(sHead)
|
|
m_MyPos.ExitToolAssociationList.Add(New ExitToolAssociation(ExitIndex.ToString, m_MyPos))
|
|
Next
|
|
For ExitIndex = EgtGetHeadExitCount(sHead) To m_MyPos.ExitToolAssociationList.Count
|
|
m_MyPos.ExitToolAssociationList.RemoveAt(ExitIndex - 1)
|
|
Next
|
|
End If
|
|
' lo aggiungo alla posizione di attrezzaggio
|
|
Tool = SelTool
|
|
IsOccupied = True
|
|
' e lo tolgo dalla lista
|
|
For Index = 0 To sh_ToolsList.Count - 1
|
|
If (SelTool.Type And sh_ToolsList(Index).Type) > 0 Then
|
|
sh_ToolsList(Index).Items.Remove(SelTool)
|
|
Exit For
|
|
End If
|
|
Next
|
|
Else
|
|
' lo rimetto nella lista utensili
|
|
For Index = 0 To sh_ToolsList.Count - 1
|
|
If (Tool.Type And sh_ToolsList(Index).Type) > 0 Then
|
|
' creo una copia della lista di utensili della famiglia
|
|
Dim TempList As New List(Of String)
|
|
Dim ToolIndex As Integer
|
|
For ToolIndex = 0 To sh_ToolsList(Index).Items.Count - 1
|
|
TempList.Add(sh_ToolsList(Index).Items(ToolIndex).Name)
|
|
Next
|
|
' aggiungo l'utensile da inserire
|
|
TempList.Add(Tool.Name)
|
|
' riordino la lista
|
|
TempList.Sort()
|
|
' ricavo l'indice dell'utensile inserito
|
|
ToolIndex = TempList.IndexOf(Tool.Name)
|
|
' lo inserisco nel posto giusto
|
|
sh_ToolsList(Index).Items.Insert(ToolIndex, Tool)
|
|
' espando la famiglia in cui l'ho mezzo
|
|
sh_ToolsList(Index).IsExpanded = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
' abilito e disabilito tutte le uscite in base all'utensile selezionato
|
|
For GroupIndex = 0 To sh_PositionGroupList.Count - 1
|
|
For PosIndex = 0 To sh_PositionGroupList(GroupIndex).PositionList.Count - 1
|
|
sh_PositionGroupList(GroupIndex).PositionList(PosIndex).SetIsValidPosFromTool(Tool.Uuid)
|
|
Next
|
|
Next
|
|
|
|
' e lo tolgo dalla posizione di attrezzaggio
|
|
Tool = Nothing
|
|
IsOccupied = False
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' SetUpToolCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
|
|
|
|
Public Sub NotifyPropertyChanged(propName As String)
|
|
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class FamilyToolItem
|
|
Inherits InheritableTreeViewItem
|
|
|
|
' riferimento alla lista posizioni
|
|
Friend Shared m_PositionGroupList As ObservableCollection(Of PositionGroup)
|
|
|
|
Public Overrides Property IsSelected As Boolean
|
|
Get
|
|
Return m_IsSelected
|
|
End Get
|
|
Set(value As Boolean)
|
|
If (value <> m_IsSelected) Then
|
|
m_IsSelected = value
|
|
If value Then
|
|
' disabilito tutte le uscite tranne quelle occupate
|
|
For GroupIndex = 0 To m_PositionGroupList.Count - 1
|
|
For PosIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1
|
|
m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetNotValidPos()
|
|
Next
|
|
Next
|
|
End If
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property FamilyColor As SolidColorBrush
|
|
Get
|
|
If m_HaveToolsInCurrMachGroup Then
|
|
Return Brushes.Red
|
|
Else
|
|
Return Brushes.Transparent
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Private m_HaveToolsInCurrMachGroup As Boolean
|
|
|
|
Private m_Type As MCH_TF
|
|
''' <summary>
|
|
''' Property that determines the tool type of the family
|
|
''' </summary>
|
|
Public ReadOnly Property Type As MCH_TF
|
|
Get
|
|
Return m_Type
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(Name As String, Type As MCH_TF)
|
|
MyBase.New(Name)
|
|
Me.PictureString = "/Resources/TreeView/Folder.png"
|
|
m_Type = Type
|
|
' Aggiungo il gestore d'evento di modifica lista degli item per poter mettere e togliere il pallino che indica se ci sono utensili da attrezzare
|
|
AddHandler Items.CollectionChanged, AddressOf ManageObservableCollection
|
|
End Sub
|
|
|
|
Private Sub ManageObservableCollection(sender As Object, e As System.Collections.Specialized.NotifyCollectionChangedEventArgs)
|
|
m_HaveToolsInCurrMachGroup = False
|
|
For Index = 0 To Items.Count - 1
|
|
Dim ToolItem As ToolItem = DirectCast(Items(Index), ToolItem)
|
|
If ToolItem.m_IsInCurrMachGroup Then
|
|
m_HaveToolsInCurrMachGroup = True
|
|
End If
|
|
Next
|
|
NotifyPropertyChanged("FamilyColor")
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class ToolItem
|
|
Inherits InheritableTreeViewItem
|
|
|
|
' riferimento alla lista posizioni
|
|
Friend Shared m_PositionGroupList As ObservableCollection(Of PositionGroup)
|
|
|
|
Public Overrides Property IsSelected As Boolean
|
|
Get
|
|
Return m_IsSelected
|
|
End Get
|
|
Set(value As Boolean)
|
|
If (value <> m_IsSelected) Then
|
|
m_IsSelected = value
|
|
If value Then
|
|
' abilito e disabilito tutte le uscite in base all'utensile selezionato
|
|
For GroupIndex = 0 To m_PositionGroupList.Count - 1
|
|
For PosIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1
|
|
m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetIsValidPosFromTool(Uuid)
|
|
Next
|
|
Next
|
|
End If
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property ToolColor As SolidColorBrush
|
|
Get
|
|
If m_IsInCurrMachGroup Then
|
|
Return Brushes.Red
|
|
Else
|
|
Return Brushes.Transparent
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Friend m_IsInCurrMachGroup As Boolean
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Exit
|
|
''' </summary>
|
|
Public Property IsInCurrMachGroup As Boolean
|
|
Get
|
|
Return m_IsInCurrMachGroup
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_IsInCurrMachGroup Then
|
|
m_IsInCurrMachGroup = value
|
|
'NotifyPropertyChanged("IsInCurrMachGroup")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Exit As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Exit
|
|
''' </summary>
|
|
Friend Property ExitPar As String
|
|
Get
|
|
Return m_Exit
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_Exit Then
|
|
m_Exit = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Type As MCH_TY
|
|
''' <summary>
|
|
''' Property that determines the tool type of the family
|
|
''' </summary>
|
|
Public ReadOnly Property Type As MCH_TY
|
|
Get
|
|
Return m_Type
|
|
End Get
|
|
End Property
|
|
|
|
Private m_Head As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Head
|
|
''' </summary>
|
|
Friend Property Head As String
|
|
Get
|
|
Return m_Head
|
|
End Get
|
|
Set(value As String)
|
|
If value = String.Empty Or value <> m_Head Then
|
|
m_Head = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TcPos As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Tc Pos
|
|
''' </summary>
|
|
Friend Property TcPos As String
|
|
Get
|
|
Return m_TcPos
|
|
End Get
|
|
Set(value As String)
|
|
If value = String.Empty Or value <> m_TcPos Then
|
|
m_TcPos = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Uuid As String
|
|
''' <summary>
|
|
''' Property that read and write to the tool's database the Uuid
|
|
''' </summary>
|
|
Friend ReadOnly Property Uuid As String
|
|
Get
|
|
Return m_Uuid
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(Name As String, ExitPar As String, Type As Integer, Head As String, TcPos As String, Uuid As String, IsInCurrMachGroup As Boolean)
|
|
MyBase.New(Name)
|
|
m_Exit = ExitPar
|
|
m_Type = DirectCast(Type, MCH_TY)
|
|
m_Head = Head
|
|
m_TcPos = TcPos
|
|
m_Uuid = Uuid
|
|
m_IsInCurrMachGroup = IsInCurrMachGroup
|
|
End Sub
|
|
|
|
End Class
|