7ceb4aa92b
- modifica nome eventi chiusura finestre.
1791 lines
72 KiB
VB.net
1791 lines
72 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
|
|
Public Class SetUpWindowVM
|
|
Inherits VMBase
|
|
|
|
Private Const INVALIDPOS As String = ""
|
|
|
|
Public Event OnCloseWindow(bDialogResult As Boolean)
|
|
|
|
Private m_sMachineDir As String = String.Empty
|
|
Friend ReadOnly Property sMachineDir As String
|
|
Get
|
|
Return m_sMachineDir
|
|
End Get
|
|
End Property
|
|
|
|
Private m_sMachineName As String = String.Empty
|
|
Friend ReadOnly Property sMachineName As String
|
|
Get
|
|
Return m_sMachineName
|
|
End Get
|
|
End Property
|
|
|
|
Private m_sSetUpDirPath As String = String.Empty
|
|
Friend ReadOnly Property sSetUpDirPath As String
|
|
Get
|
|
Return m_sSetUpDirPath
|
|
End Get
|
|
End Property
|
|
|
|
Private m_Title As String
|
|
Public ReadOnly Property Title As String
|
|
Get
|
|
Return EgtMsg(31501) ' SetUp
|
|
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
|
|
|
|
Private m_IsEnabledApplyBtn As Boolean
|
|
Public ReadOnly Property IsEnabledApplyBtn As Boolean
|
|
Get
|
|
Return m_IsEnabledApplyBtn
|
|
End Get
|
|
End Property
|
|
|
|
' Immagine del porta utensili
|
|
Public ReadOnly Property SetUpImage As String
|
|
Get
|
|
' Cerco png
|
|
Dim sImagePath As String = sSetUpDirPath & "\SetupImage.png"
|
|
If File.Exists(sImagePath) Then Return sImagePath
|
|
' Cerco jpeg
|
|
sImagePath = sSetUpDirPath & "\SetupImage.jpg"
|
|
If File.Exists(sImagePath) Then Return sImagePath
|
|
' Cerco bmp
|
|
sImagePath = sSetUpDirPath & "\SetupImage.bmp"
|
|
If File.Exists(sImagePath) Then Return sImagePath
|
|
' Non trovato alcunché
|
|
Return String.Empty
|
|
End Get
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property TitleMsg As String
|
|
Get
|
|
Return EgtMsg(31501) ' SetUp
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ApplyMsg As String
|
|
Get
|
|
Return EgtMsg(31502) ' Applica
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ArchiveMsg As String
|
|
Get
|
|
Return EgtMsg(31503) ' Archivia
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property RetrievesMsg As String
|
|
Get
|
|
Return EgtMsg(31504) ' Recupera
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property AutomaticMsg As String
|
|
Get
|
|
Return EgtMsg(31505) ' Auto
|
|
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_cmdAutomatic As ICommand
|
|
Private m_cmdCloseSetUp As ICommand
|
|
Private m_cmdToolDoubleClick As ICommand
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(sMachineDir As String, sMachineName As String, Optional sMatType As String = "Wood")
|
|
' 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
|
|
' imposto il delegate che attiva e disattiva il bottone applica dall'uscita
|
|
ExitToolAssociation.m_delIsEnabledBtns = AddressOf IsEnabledBtns
|
|
' imposto riferimenti a cartelle macchina
|
|
m_sMachineDir = sMachineDir
|
|
m_sMachineName = sMachineName
|
|
m_sSetUpDirPath = sMachineDir & "\SetUp"
|
|
' Carico lua con configurazione macchina
|
|
EgtLuaExecFile(sMachineDir & "\Scripts\SetUp.lua")
|
|
|
|
EgtUILib.GetPrivateProfileString(S_GENERAL, K_MATERIAL, sMatType, sMatType, m_sMachineDir & "\" & m_sMachineName & ".ini")
|
|
Select Case sMatType
|
|
Case "Stone"
|
|
EgtWPFLib5.ToolDbWindowVM.m_MatType = MaterialType.STONE
|
|
Case "Wood"
|
|
EgtWPFLib5.ToolDbWindowVM.m_MatType = MaterialType.WOOD
|
|
Case "Beam"
|
|
EgtWPFLib5.ToolDbWindowVM.m_MatType = MaterialType.BEAM
|
|
Case "Additive"
|
|
EgtWPFLib5.ToolDbWindowVM.m_MatType = MaterialType.WOOD
|
|
Case Else
|
|
' Se il materiale spcificato nel file INI della macchina non corrisponde ai 3 sopracitati viene emesso un messaggio di errore
|
|
EgtWPFLib5.ToolDbWindowVM.m_MatType = Nothing
|
|
MsgBox(EgtMsg(31409), MsgBoxStyle.Exclamation, EgtMsg(31551))
|
|
'EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31409), EgtMsg(31551), MessageBoxButton.YesNo, MessageBoxImage.Exclamation) ' Materiale della macchina non riconosciuto - Errore
|
|
Exit Sub
|
|
End Select
|
|
|
|
' 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
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
''' <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)
|
|
CreateUsedToolList(UsedToolList)
|
|
' Creo lista utensili per grafica
|
|
Dim ActiveToolsFamilies() As ToolsFamily = MachineUtility.ReadToolFamilies(sMachineDir & "/" & sMachineName & ".ini")
|
|
For Index = 0 To ActiveToolsFamilies.Count - 1
|
|
Dim FamilyToolItem As New FamilyToolItem(ActiveToolsFamilies(Index).Name, ActiveToolsFamilies(Index).Id)
|
|
m_ToolsList.Add(FamilyToolItem)
|
|
Dim nType As Integer = 0
|
|
Dim nFamily As MCH_TF = ActiveToolsFamilies(Index).Id
|
|
Dim sFamilyName As String = ActiveToolsFamilies(Index).Name
|
|
Dim ToolName As String = String.Empty
|
|
Dim bFound As Boolean = EgtTdbGetFirstTool(nFamily, ToolName, nType)
|
|
|
|
If nFamily = MCH_TF.MILL And EgtWPFLib5.ToolDbWindowVM.m_MatType = MaterialType.STONE Then
|
|
While bFound
|
|
EgtTdbSetCurrTool(ToolName)
|
|
Dim nValue As Integer = 0
|
|
Dim sValue As String = String.Empty
|
|
EgtTdbGetCurrToolParam(MCH_TP.EXIT_, nValue)
|
|
Dim ExitPar As String = nValue.ToString()
|
|
EgtTdbGetCurrToolParam(MCH_TP.HEAD, sValue)
|
|
Dim Head As String = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sValue)
|
|
Dim TcPos As String = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.UUID, sValue)
|
|
Dim Uuid As String = sValue
|
|
Dim IsInCurrMachGroup As Boolean = If(UsedToolList.Contains(Uuid), True, False)
|
|
' distinuo il caso di "Mola da scasso", "Mola lucidante", "Fresa"
|
|
If sFamilyName = EgtMsg(90754) And nType = MCH_TY.MILL_NOTIP Then
|
|
' --- MOLA DA SCASSO ---
|
|
FamilyToolItem.Items.Add(New ToolItem(ToolName, ExitPar, nType, Head, TcPos, Uuid, IsInCurrMachGroup))
|
|
ElseIf sFamilyName = EgtMsg(90756) And nType = MCH_TY.MILL_POLISHING Then
|
|
' --- MOLA LUCIDANTE ---
|
|
FamilyToolItem.Items.Add(New ToolItem(ToolName, ExitPar, nType, Head, TcPos, Uuid, IsInCurrMachGroup))
|
|
ElseIf sFamilyName = EgtMsg(31103) And nType = MCH_TY.MILL_STD Then
|
|
' --- FRESA ---
|
|
FamilyToolItem.Items.Add(New ToolItem(ToolName, ExitPar, nType, Head, TcPos, Uuid, IsInCurrMachGroup))
|
|
End If
|
|
bFound = EgtTdbGetNextTool(ActiveToolsFamilies(Index).Id, ToolName, nType)
|
|
End While
|
|
|
|
Continue For
|
|
End If
|
|
|
|
' per tutti gli altri utensili (NON per il MARMO) che non sono di di tipo FRESA
|
|
While bFound
|
|
EgtTdbSetCurrTool(ToolName)
|
|
Dim nValue As Integer = 0
|
|
Dim sValue As String = String.Empty
|
|
EgtTdbGetCurrToolParam(MCH_TP.EXIT_, nValue)
|
|
Dim ExitPar As String = nValue.ToString()
|
|
EgtTdbGetCurrToolParam(MCH_TP.HEAD, sValue)
|
|
Dim Head As String = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sValue)
|
|
Dim TcPos As String = sValue
|
|
EgtTdbGetCurrToolParam(MCH_TP.UUID, sValue)
|
|
Dim Uuid As String = sValue
|
|
Dim IsInCurrMachGroup As Boolean = If(UsedToolList.Contains(Uuid), True, False)
|
|
FamilyToolItem.Items.Add(New ToolItem(ToolName, ExitPar, nType, Head, TcPos, Uuid, IsInCurrMachGroup))
|
|
bFound = EgtTdbGetNextTool(ActiveToolsFamilies(Index).Id, ToolName, nType)
|
|
End While
|
|
Next
|
|
End Sub
|
|
|
|
' Funzione che crea la lista di utensili utilizzati dal gruppo di lavorazione corrente
|
|
Public Overridable Sub CreateUsedToolList(UsedToolList As List(Of String))
|
|
Dim Machining As Integer = EgtGetFirstOperation()
|
|
While Machining <> GDB_ID.NULL
|
|
If EgtGetOperationType(Machining) <> MCH_OY.DISP Then
|
|
EgtSetCurrMachining(Machining)
|
|
Dim Tuuid As String = String.Empty
|
|
EgtGetMachiningParam(MCH_MP.TUUID, Tuuid)
|
|
UsedToolList.Add(Tuuid)
|
|
End If
|
|
Machining = EgtGetNextOperation(Machining)
|
|
End While
|
|
End Sub
|
|
|
|
Private Sub LoadMachinePositions()
|
|
' recupero il gruppo del setup
|
|
Dim nSetUpGroup As Integer = EgtGetCurrSetup()
|
|
' genero l'attrezzaggio dalla configurazione Lua
|
|
Dim Index As Integer = 1
|
|
While CreateStdPosFromPosIndex(Index)
|
|
Index += 1
|
|
End While
|
|
Index -= 1
|
|
|
|
' 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)
|
|
If IniIndex <= Index Then
|
|
ReadPositionString(IniIndex, sPosition, True)
|
|
Else
|
|
EgtRemoveInfo(nSetUpGroup, K_POS & IniIndex)
|
|
End If
|
|
IniIndex += 1
|
|
End While
|
|
|
|
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 Integer = 999
|
|
EgtLuaSetGlobIntVar("STU.INDEX", Index)
|
|
EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos")
|
|
' Leggo variabili
|
|
EgtLuaGetGlobStringVar("STU.TCPOS", sTcPos)
|
|
EgtLuaGetGlobStringVar("STU.HEAD", sHead)
|
|
EgtLuaGetGlobStringVar("STU.GROUP", sGroup)
|
|
EgtLuaGetGlobIntVar("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(nGroup) Then
|
|
m_PositionGroupList(nGroup - 1).PositionList.Add(New Position(sTcPos, sHead, EgtGetHeadExitCount(sHead)))
|
|
End If
|
|
Return (nErr = 0)
|
|
End Function
|
|
|
|
' funzione che mantiene le posizioni ma elimina tutti gli utensili attrezzati
|
|
Private Sub ClearAllPos()
|
|
For GroupIndex = 0 To m_PositionGroupList.Count - 1
|
|
For PositionIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1
|
|
For ExitIndex = 0 To m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList.Count - 1
|
|
Dim TempExit As ExitToolAssociation = m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(ExitIndex)
|
|
' e lo tolgo dalla posizione di attrezzaggio
|
|
TempExit.Tool = Nothing
|
|
TempExit.IsOccupied = False
|
|
Next
|
|
Next
|
|
Next
|
|
End Sub
|
|
|
|
' 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, bOriginal As Boolean)
|
|
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)
|
|
' 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 TempFamilyIndex As Integer = -1
|
|
Dim TempToolIndex As Integer = -1
|
|
Dim bToolFound 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
|
|
TempTool = DirectCast(m_ToolsList(FamilyListIndex).Items(ToolListIndex), ToolItem)
|
|
If TempTool.Uuid = sToolList(ToolIndex) Then
|
|
TempFamilyIndex = FamilyListIndex
|
|
TempToolIndex = ToolListIndex
|
|
bToolFound = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If bToolFound Then Exit For
|
|
Next
|
|
' se lo trovo
|
|
If bToolFound Then
|
|
' cerco la relativa uscita
|
|
Dim bFoundPos As Boolean = False
|
|
For PositionIndex = 0 To m_PositionGroupList(nGroup - 1).PositionList.Count - 1
|
|
Dim TempPosition As Position = m_PositionGroupList(nGroup - 1).PositionList(PositionIndex)
|
|
If TempPosition.TcPos = sTcPos Then
|
|
bFoundPos = True
|
|
' verifico se la testa è diversa
|
|
If TempPosition.Head <> sHead Then
|
|
' altrimenti la sovrascrivo
|
|
TempPosition.Head = sHead
|
|
' e verifico il numero di uscite
|
|
For ExitIndex = TempPosition.ExitToolAssociationList.Count + 1 To EgtGetHeadExitCount(sHead)
|
|
TempPosition.ExitToolAssociationList.Add(New ExitToolAssociation(ExitIndex.ToString, TempPosition))
|
|
Next
|
|
For ExitIndex = TempPosition.ExitToolAssociationList.Count - 1 To EgtGetHeadExitCount(sHead) Step -1
|
|
TempPosition.ExitToolAssociationList.RemoveAt(ExitIndex)
|
|
Next
|
|
End If
|
|
For ExitIndex = 0 To TempPosition.ExitToolAssociationList.Count - 1
|
|
Dim CurrExitToolAss As ExitToolAssociation = TempPosition.ExitToolAssociationList(ExitIndex)
|
|
If CurrExitToolAss.ExitPar = sExitList(ToolIndex) Then
|
|
' vi metto l'utensile e segno l'uscita come occupata
|
|
CurrExitToolAss.Tool = TempTool
|
|
CurrExitToolAss.IsOccupied = True
|
|
CurrExitToolAss.NotifyPropertyChanged("ToolTipMsg")
|
|
' lo metto anche come utensile originale
|
|
If bOriginal Then CurrExitToolAss.OrigTool = TempTool
|
|
Exit For
|
|
End If
|
|
Next
|
|
Exit For
|
|
End If
|
|
Next
|
|
' se posizione trovata, devo togliere l'utensile dalla lista utensili
|
|
If bFoundPos Then
|
|
m_ToolsList(TempFamilyIndex).Items.Remove(m_ToolsList(TempFamilyIndex).Items(TempToolIndex))
|
|
End If
|
|
' altrimenti, se non l'ho trovato
|
|
Else
|
|
Dim sSearchedTool As String = String.Empty
|
|
EgtTdbGetToolFromUUID(sToolList(ToolIndex), sSearchedTool)
|
|
If Not String.IsNullOrWhiteSpace(sSearchedTool) Then
|
|
' Impossibile trovare l'utensile xxx nel DB utensili
|
|
MessageBox.Show(EgtMsg(31553) & " " & sSearchedTool & " " & EgtMsg(31554), EgtMsg(31552), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
'EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31553) & " " & sSearchedTool & " " & EgtMsg(31554), EgtMsg(31552), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Else
|
|
' Impossibile trovare l'utensile nel DB utensili
|
|
MessageBox.Show(EgtMsg(31553) & " " & EgtMsg(31554), EgtMsg(31552), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
'EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31553) & " " & EgtMsg(31554), EgtMsg(31552), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
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 Integer = 999
|
|
EgtLuaSetGlobStringVar("STU.TCPOS", sTcPos)
|
|
EgtLuaCallFunction("STU.GetGroupFromTcPos")
|
|
' Leggo variabili
|
|
EgtLuaGetGlobStringVar("STU.GROUP", sGroup)
|
|
EgtLuaGetGlobIntVar("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 Integer = 999
|
|
EgtLuaSetGlobStringVar("STU.TCPOS", sTcPos)
|
|
EgtLuaCallFunction("STU.GetPosFromTcPos")
|
|
' Leggo variabili
|
|
EgtLuaGetGlobStringVar("STU.POS", sPosition)
|
|
EgtLuaGetGlobIntVar("STU.ERR", nErr)
|
|
If nErr = 0 Then
|
|
nPosIndex = If(Integer.TryParse(sPosition.Replace("Pos", ""), nPosIndex), nPosIndex, -1)
|
|
Return (nPosIndex >= 0)
|
|
End If
|
|
nPosIndex = -1
|
|
Return False
|
|
End Function
|
|
|
|
' Funzione che verifica se ci sono state modifiche all'attrezzaggio corrente
|
|
Private Function IsModifiedSetUp() As Boolean
|
|
For GroupIndex = 0 To PositionGroupList.Count - 1
|
|
For PositionIndex = 0 To PositionGroupList(GroupIndex).PositionList.Count - 1
|
|
For ExitIndex = 0 To PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList.Count - 1
|
|
Dim CurrExitToolAss As ExitToolAssociation = PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(ExitIndex)
|
|
If CurrExitToolAss.m_IsModifiedTool Then
|
|
Return True
|
|
End If
|
|
Next
|
|
Next
|
|
Next
|
|
Return False
|
|
End Function
|
|
|
|
' Funzione che verifica se ci sono state modifiche all'attrezzaggio corrente e permette di attivare e disattivare il bottone applica
|
|
Private Sub IsEnabledBtns()
|
|
m_IsEnabledApplyBtn = IsModifiedSetUp()
|
|
NotifyPropertyChanged(NameOf(IsEnabledApplyBtn))
|
|
End Sub
|
|
|
|
#Region "ToolDoubleClickCommand"
|
|
|
|
''' <summary>
|
|
''' Execute the TreeViewDoubleClick. This method is invoked by the TreeViewDoubleClickCommand.
|
|
''' </summary>
|
|
Public Sub ToolDoubleClick(SelTool As ToolItem)
|
|
Dim ErrorList As New List(Of String)
|
|
AutoSetUpTool(SelTool, ErrorList)
|
|
' verifico se ci sono errori
|
|
If ErrorList.Count > 0 Then
|
|
' li raccolgo tutti nello stesso messaggio
|
|
Dim sError As String = EgtMsg(31556) & Environment.NewLine ' La posizione predefinita dell'utensile è già occupata.
|
|
For ErrorIndex = 0 To ErrorList.Count - 1
|
|
sError &= "- " & ErrorList(ErrorIndex) & Environment.NewLine
|
|
Next
|
|
MessageBox.Show(sError, EgtMsg(31552), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
'EgtMessageBoxV.Show(Application.Current.MainWindow, sError, EgtMsg(31552), MessageBoxButton.OK, MessageBoxImage.Exclamation) ' Avviso
|
|
End If
|
|
IsEnabledBtns()
|
|
End Sub
|
|
|
|
Private Function AutoSetUpTool(SelTool As ToolItem, ByRef ErrorList As List(Of String)) As Boolean
|
|
' cerco il TcPos dell'utensile selezionato nella lista di posizioni
|
|
For GroupIndex = 0 To m_PositionGroupList.Count - 1
|
|
For PositionIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1
|
|
Dim CurrPosition As Position = m_PositionGroupList(GroupIndex).PositionList(PositionIndex)
|
|
If CurrPosition.TcPos = SelTool.TcPos Then
|
|
AutoSetUpToolFromPos(SelTool, CurrPosition, ErrorList)
|
|
End If
|
|
Next
|
|
Next
|
|
Return False
|
|
End Function
|
|
|
|
Private Function AutoSetUpToolFromPos(SelTool As ToolItem, Position As Position, ByRef ErrorList As List(Of String)) As Boolean
|
|
Dim ExitToolAssociationList As ObservableCollection(Of ExitToolAssociation) = Position.ExitToolAssociationList
|
|
EgtLuaSetGlobStringVar("STU.TUUID", SelTool.Uuid)
|
|
EgtLuaSetGlobStringVar("STU.TCPOS", Position.TcPos)
|
|
EgtLuaCallFunction("STU.GetValidHeadExitForPos")
|
|
' Leggo variabili
|
|
Dim sHead As String = String.Empty
|
|
EgtLuaGetGlobStringVar("STU.HEAD", sHead)
|
|
Dim nExit As Integer = 0
|
|
EgtLuaGetGlobIntVar("STU.EXIT", nExit)
|
|
Dim nErr As Integer = 999
|
|
EgtLuaGetGlobIntVar("STU.ERR", nErr)
|
|
If nErr <> 0 Then
|
|
Dim sToolName As String = String.Empty
|
|
EgtTdbGetToolFromUUID(SelTool.Uuid, sToolName)
|
|
EgtOutLog("Error in setup! Tool:" & sToolName & " TcPos: " & Position.TcPos)
|
|
Return False
|
|
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, restituisco errore
|
|
If sHead = INVALIDPOS Then
|
|
EgtOutLog("SetUp warning: try to set " & SelTool.Name & " on " & Position.TcPos)
|
|
MessageBox.Show(EgtMsg(31555), EgtMsg(31551), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
'EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31555), EgtMsg(31551), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return False
|
|
' altrimenti, se la posizione nell'attrezzaggio è vuota
|
|
ElseIf Not PosIsOccupied Then
|
|
' verifico se la testa è la stessa
|
|
If Not Position.Head = sHead Then
|
|
' altrimenti la sovrascrivo
|
|
Position.Head = sHead
|
|
' e verifico il numero di uscite
|
|
For ExitIndex = Position.ExitToolAssociationList.Count + 1 To EgtGetHeadExitCount(sHead)
|
|
Position.ExitToolAssociationList.Add(New ExitToolAssociation(ExitIndex.ToString, Position))
|
|
Next
|
|
For ExitIndex = Position.ExitToolAssociationList.Count - 1 To EgtGetHeadExitCount(sHead) Step -1
|
|
Position.ExitToolAssociationList.RemoveAt(ExitIndex)
|
|
Next
|
|
End If
|
|
' lo aggiungo alla posizione di attrezzaggio e lo tolgo dalla lista utensili
|
|
SetToolInPos(SelTool, Position, nExit)
|
|
' altrimenti, se le teste coincidono
|
|
ElseIf sHead = Position.Head Then
|
|
' se l'uscita restituita è libera
|
|
If Not ExitToolAssociationList(nExit - 1).IsOccupied Then
|
|
' lo aggiungo alla posizione di attrezzaggio e lo tolgo dalla lista utensili
|
|
SetToolInPos(SelTool, Position, nExit)
|
|
' altrimenti restituisco falso
|
|
Else
|
|
ErrorList.Add(SelTool.Name)
|
|
Return False
|
|
End If
|
|
' altrimenti restituisco falso
|
|
Else
|
|
ErrorList.Add(SelTool.Name)
|
|
Return False
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Private Function SetToolInPos(SelTool As ToolItem, Position As Position, nExit As Integer) As Boolean
|
|
Dim bOk As Boolean = False
|
|
' lo aggiungo alla posizione di attrezzaggio
|
|
For ExitIndex = 0 To Position.ExitToolAssociationList.Count - 1
|
|
If ExitIndex = nExit - 1 Then
|
|
Position.ExitToolAssociationList(ExitIndex).Tool = SelTool
|
|
Position.ExitToolAssociationList(ExitIndex).IsOccupied = True
|
|
Position.ExitToolAssociationList(ExitIndex).NotifyPropertyChanged("ToolTipMsg")
|
|
bOk = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
If Not bOk Then Return False
|
|
bOk = False
|
|
' e lo tolgo dalla lista utensili
|
|
For Index = 0 To m_ToolsList.Count - 1
|
|
If (SelTool.Type And m_ToolsList(Index).Type) > 0 Then
|
|
m_ToolsList(Index).Items.Remove(SelTool)
|
|
bOk = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
Return bOk
|
|
End Function
|
|
|
|
#End Region ' ToolDoubleClickCommand
|
|
|
|
Friend Sub Close(bDialogResult As Boolean)
|
|
RaiseEvent OnCloseWindow(bDialogResult)
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#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()
|
|
' 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 CurrPosition As Position = m_PositionGroupList(GroupIndex).PositionList(PositionIndex)
|
|
Dim sPosition As String = String.Empty
|
|
sPosition = CurrPosition.TcPos
|
|
Dim sExitToolAssociation As String = String.Empty
|
|
For ExitIndex = 0 To CurrPosition.ExitToolAssociationList.Count - 1
|
|
Dim CurrExitToolAss As ExitToolAssociation = CurrPosition.ExitToolAssociationList(ExitIndex)
|
|
sExitToolAssociation &= If(CurrExitToolAss.IsOccupied,
|
|
CurrExitToolAss.ExitPar & "/" &
|
|
CurrExitToolAss.Tool.Uuid & "/" &
|
|
CurrExitToolAss.Tool.Name & ",", String.Empty)
|
|
CurrExitToolAss.OrigTool = CurrExitToolAss.Tool
|
|
Next
|
|
sExitToolAssociation = sExitToolAssociation.Trim(","c)
|
|
If Not String.IsNullOrEmpty(sExitToolAssociation) Then
|
|
sPosition &= ";" & CurrPosition.Head & ";" & sExitToolAssociation
|
|
End If
|
|
Dim nPosition As Integer
|
|
If GetPositionFromTcPos(CurrPosition.TcPos, nPosition) Then
|
|
EgtSetInfo(nSetUpGroup, K_POS & nPosition, sPosition)
|
|
End If
|
|
Next
|
|
Next
|
|
m_IsEnabledApplyBtn = False
|
|
NotifyPropertyChanged(NameOf(IsEnabledApplyBtn))
|
|
' aggiorno le librerie sottostanti
|
|
EgtUpdateCurrSetup()
|
|
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 = sMachineDir & "\SetUp"
|
|
Dim sPath As String = String.Empty
|
|
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
|
|
' Apertura dialogo di salvataggio
|
|
Dim SaveFileDialogViewVM As New SaveFileDialogWithListVM With {
|
|
.Title = EgtMsg(31503) & " " & EgtMsg(31501), ' Archivia SetUp
|
|
.Extension = ".stu",
|
|
.Filter = "*.stu",
|
|
.Directory = sDir,
|
|
.FileName = String.Empty
|
|
}
|
|
Dim SaveFileDialogView As New EgtWPFLib5.SaveFileDialogWithListV(Application.Current.MainWindow, SaveFileDialogViewVM)
|
|
If Not SaveFileDialogView.ShowDialog() Then Return
|
|
sPath = SaveFileDialogViewVM.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 CurrPosition As Position = m_PositionGroupList(GroupIndex).PositionList(PositionIndex)
|
|
Dim sPosition As String = String.Empty
|
|
sPosition = CurrPosition.TcPos
|
|
Dim sExitToolAssociation As String = String.Empty
|
|
For AssIndex = 0 To CurrPosition.ExitToolAssociationList.Count - 1
|
|
sExitToolAssociation &= If(CurrPosition.ExitToolAssociationList(AssIndex).IsOccupied,
|
|
CurrPosition.ExitToolAssociationList(AssIndex).ExitPar & "/" &
|
|
CurrPosition.ExitToolAssociationList(AssIndex).Tool.Uuid & "/" &
|
|
CurrPosition.ExitToolAssociationList(AssIndex).Tool.Name & ",", String.Empty)
|
|
Next
|
|
sExitToolAssociation = sExitToolAssociation.Trim(","c)
|
|
If Not String.IsNullOrEmpty(sExitToolAssociation) Then
|
|
sPosition &= ";" & CurrPosition.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 = sMachineDir & "\SetUp"
|
|
Dim sPath As String = String.Empty
|
|
If Not Directory.Exists(sDir) Then
|
|
EgtOutLog("Error in SetupDir retrieve : directory not found")
|
|
Return
|
|
End If
|
|
' Apertura dialogo di salvataggio
|
|
Dim OpenFileDialogView As New EgtWPFLib5.EgtOpenFileDialog With {
|
|
.Title = EgtMsg(31504) & " " & EgtMsg(31501), ' Recupera SetUp
|
|
.Filter = "*.stu",
|
|
.Directory = sDir,
|
|
.FileName = String.Empty
|
|
}
|
|
If Not OpenFileDialogView.EgtShowDialog Then
|
|
Return
|
|
End If
|
|
sPath = OpenFileDialogView.FileName
|
|
|
|
' resetto lista utensili e posizioni
|
|
m_ToolsList.Clear()
|
|
ClearAllPos()
|
|
'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, False)
|
|
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
|
|
IsEnabledBtns()
|
|
End Sub
|
|
|
|
#End Region ' RetrievesCommand
|
|
|
|
#Region "AutomaticCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Exec.
|
|
''' </summary>
|
|
Public ReadOnly Property AutomaticCommand As ICommand
|
|
Get
|
|
If m_cmdAutomatic Is Nothing Then
|
|
m_cmdAutomatic = New Command(AddressOf Automatic)
|
|
End If
|
|
Return m_cmdAutomatic
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Exec. This method is invoked by the ExecCommand.
|
|
''' </summary>
|
|
Public Sub Automatic(param As Object)
|
|
' verifico il tipo di elemento selezionato
|
|
Dim bIsToolItem As Boolean = False
|
|
Dim SelTool As ToolItem = Nothing
|
|
If TypeOf param Is ToolItem Then
|
|
SelTool = DirectCast(param, ToolItem)
|
|
bIsToolItem = Not SelTool.IsInCurrMachGroup
|
|
End If
|
|
|
|
Dim ErrorList As New List(Of String)
|
|
' analizzo la lista degli utensili alla ricerca di quelli usati nel progetto corrente
|
|
For FamilyIndex = 0 To m_ToolsList.Count - 1
|
|
' verifico se nella famiglia c'è almeno un utensile usato nel progetto
|
|
If m_ToolsList(FamilyIndex).HaveToolsInCurrMachGroup Then
|
|
' analizzo gli utensili all'interno della famiglia
|
|
For ToolIndex = m_ToolsList(FamilyIndex).Items.Count - 1 To 0 Step -1
|
|
Dim CurrTool As ToolItem = DirectCast(m_ToolsList(FamilyIndex).Items(ToolIndex), ToolItem)
|
|
' se l'utensile è utilizzato
|
|
If CurrTool.IsInCurrMachGroup Then
|
|
' lo attrezzo al suo posto predefinito
|
|
AutoSetUpTool(CurrTool, ErrorList)
|
|
End If
|
|
Next
|
|
End If
|
|
Next
|
|
|
|
' verifico se ci sono errori
|
|
If ErrorList.Count > 0 Then
|
|
' li raccolgo tutti nello stesso messaggio
|
|
Dim sError As String = EgtMsg(31556) & Environment.NewLine ' La posizione predefinita dell'utensile è già occupata.
|
|
For ErrorIndex = 0 To ErrorList.Count - 1
|
|
sError &= "- " & ErrorList(ErrorIndex) & Environment.NewLine
|
|
Next
|
|
MessageBox.Show(sError, EgtMsg(31552), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
'EgtMessageBoxV.Show(Application.Current.MainWindow, sError, EgtMsg(31552), MessageBoxButton.OK, MessageBoxImage.Exclamation) ' Avviso
|
|
End If
|
|
|
|
' 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
|
|
If bIsToolItem Then
|
|
m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetIsValidPosFromTool(SelTool.Uuid)
|
|
Else
|
|
m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetNotValidPos()
|
|
End If
|
|
Next
|
|
Next
|
|
' aggiorno lo stato del bottone applica
|
|
IsEnabledBtns()
|
|
End Sub
|
|
|
|
#End Region ' AutomaticCommand
|
|
|
|
#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 Command(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()
|
|
|
|
' Verifico se l'attrezzaggio è stato modificato
|
|
If IsModifiedSetUp() Then
|
|
' se modificato chiedo se salvarlo prima di uscire
|
|
If MessageBox.Show(EgtMsg(31506), EgtMsg(31502), MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then
|
|
'If EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31506), EgtMsg(31502), MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then ' Applicare l'attrezzaggio corrente prima di uscire? - Applica
|
|
' lo salvo
|
|
Apply()
|
|
End If
|
|
End If
|
|
|
|
' Resetto tutti i delegate usati
|
|
ExitToolAssociation.m_delIsEnabledBtns = Nothing
|
|
' Reset lua
|
|
EgtLuaResetGlobVar("STU")
|
|
|
|
' Chiusura finestra
|
|
Close(True)
|
|
End Sub
|
|
|
|
#End Region ' CloseSetUpCommand
|
|
|
|
#End Region ' Commands
|
|
|
|
End Class
|
|
|
|
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 Integer = 0
|
|
EgtLuaGetGlobIntVar("STU.EXIT", nExit)
|
|
Dim nErr As Integer = 999
|
|
EgtLuaGetGlobIntVar("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(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 = 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
|
|
EgtLuaSetGlobStringVar("STU.HEAD1", sHead)
|
|
EgtLuaSetGlobStringVar("STU.HEAD2", Head)
|
|
EgtLuaCallFunction("STU.IsCompatibleHeads")
|
|
' Leggo variabili
|
|
Dim bIsValid As Boolean = False
|
|
EgtLuaGetGlobBoolVar("STU.ISVALID", bIsValid)
|
|
nErr = 999
|
|
EgtLuaGetGlobIntVar("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
|
|
If bIsValid Then
|
|
' se l'uscita restituita è libera la attivo e disattivo tutte le altre non occupate
|
|
If Not ExitToolAssociationList(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 = nExit - 1 Then
|
|
ExitToolAssociationList(ExitIndex).IsValidPos = True
|
|
Else
|
|
ExitToolAssociationList(ExitIndex).IsValidPos = False
|
|
End If
|
|
Else
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = False
|
|
End If
|
|
Next
|
|
End If
|
|
Else
|
|
For ExitIndex = 0 To ExitToolAssociationList.Count - 1
|
|
ExitToolAssociationList(ExitIndex).IsEnabledPos = False
|
|
Next
|
|
End If
|
|
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)
|
|
' Actions
|
|
Friend Shared m_delIsEnabledBtns As Action
|
|
|
|
' 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(NameOf(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(NameOf(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(NameOf(ExitBtnBackgroundCol))
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property ExitBtnBackgroundCol As Brush
|
|
Get
|
|
If IsNothing(m_IsValidPos) Then
|
|
Return New SolidColorBrush(Color.FromArgb(255, 221, 221, 221))
|
|
ElseIf m_IsValidPos Then
|
|
If m_IsOccupied Then
|
|
Return EgaltechYellow
|
|
Else
|
|
Return EgaltechGreen
|
|
End If
|
|
Else
|
|
Return New SolidColorBrush(Color.FromArgb(255, 221, 221, 221))
|
|
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
|
|
|
|
Friend m_IsModifiedTool As Boolean = False
|
|
Private m_OrigTool As ToolItem = Nothing
|
|
Friend Property OrigTool As ToolItem
|
|
Get
|
|
Return m_OrigTool
|
|
End Get
|
|
Set(value As ToolItem)
|
|
m_OrigTool = value
|
|
m_IsModifiedTool = False
|
|
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
|
|
m_IsModifiedTool = m_Tool IsNot m_OrigTool
|
|
NotifyPropertyChanged(NameOf(Tool))
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property ToolTipMsg As String
|
|
Get
|
|
If IsNothing(m_Tool) Then Return ""
|
|
EgtTdbSetCurrTool(m_Tool.Name)
|
|
Dim dValue As Double = 0
|
|
Dim nType As Integer
|
|
EgtTdbGetCurrToolParam(MCH_TP.TYPE, nType)
|
|
EgtTdbGetCurrToolParam(MCH_TP.DIAM, dValue)
|
|
Dim sDiam As String = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.LEN, dValue)
|
|
Dim sLen As String = LenToString(dValue, 4)
|
|
EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dValue)
|
|
Dim MaxMat As String = LenToString(dValue, 4)
|
|
Return (EgtMsg(31053) & ": " & ConvertToolTypeToString(nType) & Environment.NewLine & ' Tipo
|
|
EgtMsg(31056) & ": " & sDiam & Environment.NewLine & ' Diametro
|
|
EgtMsg(31062) & ": " & sLen & Environment.NewLine & ' Lunghezza
|
|
EgtMsg(31064) & ": " & MaxMat) ' Massimo Materiale
|
|
End Get
|
|
End Property
|
|
|
|
Private Function ConvertToolTypeToString(ToolType As Integer) As String
|
|
Select Case ToolType
|
|
Case MCH_TY.DRILL_STD
|
|
Return EgtMsg(31001) ' Punta
|
|
Case MCH_TY.DRILL_LONG
|
|
Return EgtMsg(31006) ' Punta lunga
|
|
Case MCH_TY.SAW_STD
|
|
Return EgtMsg(31002) ' Lama
|
|
Case MCH_TY.SAW_FLAT
|
|
Return EgtMsg(31007) ' Lama piatta
|
|
Case MCH_TY.MILL_STD
|
|
Return EgtMsg(31003) ' Fresa
|
|
Case MCH_TY.MILL_NOTIP
|
|
Return EgtMsg(31008) ' Fresa senza punta
|
|
Case MCH_TY.MORTISE_STD
|
|
Return EgtMsg(31004) ' Mortasatrice
|
|
Case MCH_TY.COMPO
|
|
Return EgtMsg(31005) ' Composito
|
|
Case Else
|
|
Return String.Empty
|
|
End Select
|
|
End Function
|
|
|
|
#End Region ' Messages
|
|
|
|
' 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(NameOf(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 Integer = 0
|
|
EgtLuaGetGlobIntVar("STU.EXIT", nExit)
|
|
Dim nErr As Integer = 999
|
|
EgtLuaGetGlobIntVar("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)
|
|
m_IsOccupied = False
|
|
NotifyPropertyChanged(NameOf(IsOccupied))
|
|
Return
|
|
End If
|
|
' se la testa restituita non coincide con quella della posizione
|
|
If m_MyPos.Head <> sHead Then
|
|
' aggiorno testa ed uscite
|
|
m_MyPos.Head = sHead
|
|
For ExitIndex = m_MyPos.ExitToolAssociationList.Count + 1 To EgtGetHeadExitCount(sHead)
|
|
m_MyPos.ExitToolAssociationList.Add(New ExitToolAssociation(ExitIndex.ToString, m_MyPos))
|
|
Next
|
|
For ExitIndex = m_MyPos.ExitToolAssociationList.Count - 1 To EgtGetHeadExitCount(sHead) Step -1
|
|
m_MyPos.ExitToolAssociationList.RemoveAt(ExitIndex)
|
|
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
|
|
|
|
' --- GESTIONE SEPARATA DEGLI UTENSILI fresa PER IL MARMO ---------------------------------------------------
|
|
If EgtWPFLib5.ToolDbWindowVM.m_MatType = MaterialType.STONE And sh_ToolsList(Index).Type = MCH_TF.MILL Then
|
|
If sh_ToolsList(Index).Name = EgtMsg(90754) And SelTool.Type = MCH_TY.MILL_NOTIP Then
|
|
' --- MOLA DA SCASSO ---
|
|
sh_ToolsList(Index).Items.Remove(SelTool)
|
|
ElseIf sh_ToolsList(Index).Name = EgtMsg(90756) And SelTool.Type = MCH_TY.MILL_POLISHING Then
|
|
' --- MOLA LUCIDANTE ---
|
|
sh_ToolsList(Index).Items.Remove(SelTool)
|
|
ElseIf sh_ToolsList(Index).Name = EgtMsg(31003) And SelTool.Type = MCH_TY.MILL_STD Then
|
|
' --- FRESA ---
|
|
sh_ToolsList(Index).Items.Remove(SelTool)
|
|
End If
|
|
Continue For
|
|
End If
|
|
' --- GESTIONE SEPARATA DEGLI UTENSILI fresa PER IL MARMO ---------------------------------------------------
|
|
|
|
If (SelTool.Type And sh_ToolsList(Index).Type) > 0 Then
|
|
sh_ToolsList(Index).Items.Remove(SelTool)
|
|
Exit For
|
|
End If
|
|
Next
|
|
NotifyPropertyChanged(NameOf(ToolTipMsg))
|
|
Else
|
|
' lo rimetto nella lista utensili
|
|
For Index = 0 To sh_ToolsList.Count - 1
|
|
|
|
' --- GESTIONE SEPARATA DEGLI UTENSILI fresa PER IL MARMO ---------------------------------------------------
|
|
If EgtWPFLib5.ToolDbWindowVM.m_MatType = MaterialType.STONE And sh_ToolsList(Index).Type = MCH_TF.MILL Then
|
|
If sh_ToolsList(Index).Name = EgtMsg(90754) And Tool.Type = MCH_TY.MILL_NOTIP Then
|
|
' --- MOLA DA SCASSO ---
|
|
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 messo
|
|
sh_ToolsList(Index).IsExpanded = True
|
|
Exit For
|
|
ElseIf sh_ToolsList(Index).Name = EgtMsg(90756) And Tool.Type = MCH_TY.MILL_POLISHING Then
|
|
' --- MOLA LUCIDANTE ---
|
|
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 messo
|
|
sh_ToolsList(Index).IsExpanded = True
|
|
Exit For
|
|
ElseIf sh_ToolsList(Index).Name = EgtMsg(31003) And Tool.Type = MCH_TY.MILL_STD Then
|
|
' --- FRESA ---
|
|
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 messo
|
|
sh_ToolsList(Index).IsExpanded = True
|
|
Exit For
|
|
End If
|
|
Continue For
|
|
End If
|
|
' --- GESTIONE SEPARATA DEGLI UTENSILI fresa PER IL MARMO ---------------------------------------------------
|
|
|
|
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 messo
|
|
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
|
|
|
|
' seleziono utensile rimesso in lista
|
|
m_Tool.IsSelected = True
|
|
Tool.NotifyPropertyChanged(NameOf(Tool.IsSelected))
|
|
' e lo tolgo dalla posizione di attrezzaggio
|
|
Tool = Nothing
|
|
IsOccupied = False
|
|
|
|
End If
|
|
m_delIsEnabledBtns()
|
|
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 Brush
|
|
Get
|
|
If m_HaveToolsInCurrMachGroup Then
|
|
Return Brushes.Red
|
|
Else
|
|
Return Brushes.Transparent
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Private m_HaveToolsInCurrMachGroup As Boolean
|
|
Friend ReadOnly Property HaveToolsInCurrMachGroup As Boolean
|
|
Get
|
|
Return m_HaveToolsInCurrMachGroup
|
|
End Get
|
|
End Property
|
|
|
|
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(NameOf(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 Brush
|
|
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
|
|
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
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property ToolTipMsg As String
|
|
Get
|
|
Return (EgtMsg(31075) & ": " & m_Name & Environment.NewLine & ' Nome
|
|
EgtMsg(31078) & ": " & m_TcPos & Environment.NewLine & ' Posizione
|
|
EgtMsg(31074) & ": " & m_Head & "." & m_Exit) ' Testa
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
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
|