EgtCAM5 :
- Aggiornamento attrezzaggio con lettura nuovi Lua.
This commit is contained in:
+350
-139
@@ -36,16 +36,38 @@ Namespace EgtCAM5
|
||||
End Set
|
||||
End Property
|
||||
|
||||
'' 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
|
||||
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
|
||||
@@ -54,16 +76,25 @@ Namespace EgtCAM5
|
||||
Private m_cmdCloseSetUp As ICommand
|
||||
|
||||
Sub New()
|
||||
ExitToolAssociation.sh_ToolsList = m_ToolsList
|
||||
LoadMachineTools()
|
||||
LoadMachinePositions()
|
||||
' rendo accessibile la lista posizioni agliutensili per poterle attivare e disattivare
|
||||
' 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>
|
||||
@@ -123,12 +154,6 @@ Namespace EgtCAM5
|
||||
End While
|
||||
End If
|
||||
Next
|
||||
' 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>
|
||||
@@ -173,24 +198,42 @@ Namespace EgtCAM5
|
||||
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 nGroup As Integer = 0
|
||||
Dim Index = 1
|
||||
While GetPrivateProfileSetUpPosition(S_SETUP, K_POS & Index, sTcPos, sHead, nGroup)
|
||||
' se l'indice del gruppo è valido
|
||||
If VerifyIndexValidity(nGroup) Then
|
||||
m_PositionGroupList(nGroup - 1).PositionList.Add(New Position(sTcPos, sHead, EgtGetHeadExitCount(sHead)))
|
||||
End If
|
||||
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
|
||||
@@ -285,43 +328,42 @@ Namespace EgtCAM5
|
||||
End If
|
||||
' non è presente la H, quindi la recupero dal modello delle posizioni nel file MachIni
|
||||
Else
|
||||
Dim nFakeGroup As Integer
|
||||
GetPrivateProfileSetUpPosition(S_SETUP, K_POS & nIndex, sTcPos, sHead, nFakeGroup)
|
||||
EgtGetHeadExitCount(sHead)
|
||||
m_PositionGroupList(nGroup - 1).PositionList.Add(New Position(sTcPos, sHead, EgtGetHeadExitCount(sHead)))
|
||||
CreateStdPosFromPosIndex(nIndex)
|
||||
End If
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
' Funzione che data una T restituisce il gruppo a cui appartiene
|
||||
Private Function GetGroupFromTcPos(TcPos As String, ByRef nPositionGroup As Integer) As Boolean
|
||||
Dim sTcPos As String = String.Empty
|
||||
Dim sHead As String = String.Empty
|
||||
Dim nGroup As Integer = 0
|
||||
Dim Index = 1
|
||||
While GetPrivateProfileSetUpPosition(S_SETUP, K_POS & Index, sTcPos, sHead, nGroup)
|
||||
If sTcPos = TcPos Then
|
||||
nPositionGroup = nGroup
|
||||
Return True
|
||||
End If
|
||||
Index += 1
|
||||
End While
|
||||
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(TcPos As String, ByRef nPosition As Integer) As Boolean
|
||||
Dim sTcPos As String = String.Empty
|
||||
Dim sHead As String = String.Empty
|
||||
Dim nGroup As Integer = -1
|
||||
Dim Index = 1
|
||||
While GetPrivateProfileSetUpPosition(S_SETUP, K_POS & Index, sTcPos, sHead, nGroup)
|
||||
If sTcPos = TcPos Then
|
||||
nPosition = Index
|
||||
Return True
|
||||
End If
|
||||
Index += 1
|
||||
End While
|
||||
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
|
||||
|
||||
@@ -475,7 +517,23 @@ Namespace EgtCAM5
|
||||
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
|
||||
@@ -542,6 +600,8 @@ End Class
|
||||
|
||||
Public Class Position
|
||||
|
||||
Private Const INVALIDPOS As String = ""
|
||||
|
||||
Private m_TcPos As String
|
||||
Public Property TcPos As String
|
||||
Get
|
||||
@@ -578,11 +638,130 @@ Public Class Position
|
||||
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))
|
||||
ExitToolAssociationList.Add(New ExitToolAssociation(ExitIndex.ToString, Me))
|
||||
Next
|
||||
End Sub
|
||||
|
||||
@@ -591,7 +770,12 @@ 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>
|
||||
@@ -609,22 +793,48 @@ Public Class ExitToolAssociation
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_IsValidPosition As Boolean
|
||||
Private m_IsEnabledPos As Boolean
|
||||
''' <summary>
|
||||
''' Property that read and write to the tool's database the Exit
|
||||
''' </summary>
|
||||
Public Property IsValidPosition As Boolean
|
||||
Public Property IsEnabledPos As Boolean
|
||||
Get
|
||||
Return m_IsValidPosition
|
||||
Return m_IsEnabledPos
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
If value <> m_IsValidPosition Then
|
||||
m_IsValidPosition = value
|
||||
NotifyPropertyChanged("IsValidPosition")
|
||||
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
|
||||
@@ -659,8 +869,9 @@ Public Class ExitToolAssociation
|
||||
|
||||
#Region "CONSTRUCTORS"
|
||||
|
||||
Sub New(ExitPar As String)
|
||||
Sub New(ExitPar As String, MyPos As Position)
|
||||
Me.ExitPar = ExitPar
|
||||
m_MyPos = MyPos
|
||||
End Sub
|
||||
|
||||
#End Region ' Constructors
|
||||
@@ -693,6 +904,37 @@ Public Class ExitToolAssociation
|
||||
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
|
||||
@@ -707,10 +949,33 @@ Public Class ExitToolAssociation
|
||||
' lo rimetto nella lista utensili
|
||||
For Index = 0 To sh_ToolsList.Count - 1
|
||||
If (Tool.Type And sh_ToolsList(Index).Type) > 0 Then
|
||||
sh_ToolsList(Index).Items.Add(Tool)
|
||||
' 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
|
||||
@@ -732,6 +997,9 @@ 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
|
||||
@@ -739,6 +1007,14 @@ Public Class FamilyToolItem
|
||||
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
|
||||
@@ -789,11 +1065,9 @@ End Class
|
||||
Public Class ToolItem
|
||||
Inherits InheritableTreeViewItem
|
||||
|
||||
' riferimento alle posizioni
|
||||
' riferimento alla lista posizioni
|
||||
Friend Shared m_PositionGroupList As ObservableCollection(Of PositionGroup)
|
||||
|
||||
Private Const INVALIDPOS As String = ""
|
||||
|
||||
Public Overrides Property IsSelected As Boolean
|
||||
Get
|
||||
Return m_IsSelected
|
||||
@@ -801,77 +1075,14 @@ Public Class ToolItem
|
||||
Set(value As Boolean)
|
||||
If (value <> m_IsSelected) Then
|
||||
m_IsSelected = value
|
||||
|
||||
For GroupIndex = 0 To m_PositionGroupList.Count - 1
|
||||
For PosIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1
|
||||
EgtLuaSetGlobStringVar("STU.TUUID", Uuid)
|
||||
EgtLuaSetGlobStringVar("STU.TCPOS", m_PositionGroupList(GroupIndex).PositionList(PosIndex).TcPos)
|
||||
EgtLuaCallFunction("STU.GetPosHeadExit")
|
||||
' Leggo variabili
|
||||
Dim sHead As String = String.Empty
|
||||
EgtLuaGetGlobStringVar("STU.HEAD", sHead)
|
||||
Dim nExit As Double = 0
|
||||
EgtLuaGetGlobNumVar("STU.EXIT", nExit)
|
||||
' verifico se la posizione è libera o c'è un utensile attrezzato
|
||||
Dim PosIsOccupied As Boolean = False
|
||||
For ExitIndex = 0 To m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList.Count - 1
|
||||
If m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(ExitIndex).IsOccupied Then
|
||||
PosIsOccupied = True
|
||||
Exit For
|
||||
End If
|
||||
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
|
||||
' se la posizione non è valida, disattivo tutte le uscite tranne quelle attrezzate
|
||||
If sHead = INVALIDPOS Then
|
||||
For ExitIndex = 0 To m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList.Count - 1
|
||||
If Not m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(ExitIndex).IsOccupied Then
|
||||
m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(ExitIndex).IsValidPosition = False
|
||||
End If
|
||||
Next
|
||||
' altrimenti, se la posizione nell'attrezzaggio è vuota
|
||||
ElseIf Not PosIsOccupied Then
|
||||
' se l'uscita restituita esiste
|
||||
If m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList.Count >= nExit Then
|
||||
' disattivo tutte le uscite tranne quella restituita
|
||||
For ExitIndex = 0 To m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList.Count - 1
|
||||
If ExitIndex + 1 = nExit Then
|
||||
m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(ExitIndex).IsValidPosition = True
|
||||
Else
|
||||
m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(ExitIndex).IsValidPosition = False
|
||||
End If
|
||||
Next
|
||||
' altrimenti lascio attiva solo la prima uscita
|
||||
Else
|
||||
m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(0).IsValidPosition = True
|
||||
For ExitIndex = 1 To m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList.Count - 1
|
||||
m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(ExitIndex).IsValidPosition = False
|
||||
Next
|
||||
End If
|
||||
' altrimenti, se le teste coincidono
|
||||
ElseIf sHead = m_PositionGroupList(GroupIndex).PositionList(PosIndex).Head Then
|
||||
' se l'uscita restituita è libera la attivo e disattivo tutte le altre
|
||||
If Not m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(nExit - 1).IsOccupied Then
|
||||
For ExitIndex = 1 To m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList.Count - 1
|
||||
If ExitIndex = nExit - 1 Then
|
||||
m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(ExitIndex).IsValidPosition = True
|
||||
Else
|
||||
m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(ExitIndex).IsValidPosition = False
|
||||
End If
|
||||
Next
|
||||
' altrimenti le disattivo tutte
|
||||
Else
|
||||
For ExitIndex = 1 To m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList.Count - 1
|
||||
m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(ExitIndex).IsValidPosition = False
|
||||
Next
|
||||
End If
|
||||
' altrimenti le disattivo tutte
|
||||
Else
|
||||
For ExitIndex = 1 To m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList.Count - 1
|
||||
m_PositionGroupList(GroupIndex).PositionList(PosIndex).ExitToolAssociationList(ExitIndex).IsValidPosition = False
|
||||
Next
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
|
||||
End If
|
||||
End If
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Reference in New Issue
Block a user