EgtCAM5 :
- Automatismo attrezzaggio. - Migliorie attrezzaggio.
This commit is contained in:
+196
-23
@@ -6,6 +6,7 @@ Imports EgtUILib
|
||||
Namespace EgtCAM5
|
||||
|
||||
Public Class SetUpViewModel
|
||||
Implements INotifyPropertyChanged
|
||||
|
||||
Private Const INVALIDPOS As String = ""
|
||||
|
||||
@@ -38,6 +39,14 @@ Namespace EgtCAM5
|
||||
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
|
||||
@@ -77,6 +86,11 @@ Namespace EgtCAM5
|
||||
Return EgtMsg(MSG_SETUP + 4)
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property AutomaticMsg As String
|
||||
Get
|
||||
Return EgtMsg(MSG_SETUP + 5)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
#End Region
|
||||
|
||||
@@ -84,6 +98,7 @@ Namespace EgtCAM5
|
||||
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
|
||||
|
||||
@@ -95,6 +110,8 @@ Namespace EgtCAM5
|
||||
' 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
|
||||
' '' 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)
|
||||
@@ -325,10 +342,13 @@ Namespace EgtCAM5
|
||||
If bFound Then
|
||||
' 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
|
||||
Dim CurrExitToolAss As ExitToolAssociation = m_PositionGroupList(nGroup - 1).PositionList(m_PositionGroupList(nGroup - 1).PositionList.Count - 1).ExitToolAssociationList(ExitIndex)
|
||||
If CurrExitToolAss.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
|
||||
CurrExitToolAss.Tool = TempTool
|
||||
CurrExitToolAss.IsOccupied = True
|
||||
' lo metto anche come utensile originale
|
||||
CurrExitToolAss.OrigTool = TempTool
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
@@ -382,6 +402,27 @@ Namespace EgtCAM5
|
||||
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("IsEnabledApplyBtn")
|
||||
End Sub
|
||||
|
||||
#Region "COMMANDS"
|
||||
|
||||
#Region "ApplyCommand"
|
||||
@@ -401,7 +442,7 @@ Namespace EgtCAM5
|
||||
''' <summary>
|
||||
''' Execute the Exec. This method is invoked by the ExecCommand.
|
||||
''' </summary>
|
||||
Public Sub Apply(param As Object)
|
||||
Public Sub Apply()
|
||||
' ricavo il gruppo in cui mettere l'attrezzaggio
|
||||
Dim nSetUpGroup As Integer = EgtGetCurrSetup()
|
||||
For GroupIndex = 0 To m_PositionGroupList.Count - 1
|
||||
@@ -410,11 +451,13 @@ Namespace EgtCAM5
|
||||
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)
|
||||
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
|
||||
@@ -426,6 +469,8 @@ Namespace EgtCAM5
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
m_IsEnabledApplyBtn = False
|
||||
NotifyPropertyChanged("IsEnabledApplyBtn")
|
||||
End Sub
|
||||
|
||||
#End Region ' ApplyCommand
|
||||
@@ -557,6 +602,74 @@ Namespace EgtCAM5
|
||||
|
||||
#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(MSG_SETUPERRORS + 6) & Environment.NewLine
|
||||
For ErrorIndex = 0 To ErrorList.Count - 1
|
||||
sError &= "- " & ErrorList(ErrorIndex) & Environment.NewLine
|
||||
Next
|
||||
MessageBox.Show(sError, EgtMsg(MSG_SETUPERRORS + 2), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region ' AutomaticCommand
|
||||
|
||||
#Region "CloseSetUpCommand"
|
||||
|
||||
''' <summary>
|
||||
@@ -575,6 +688,18 @@ Namespace EgtCAM5
|
||||
''' 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(MSG_SETUP + 6), EgtMsg(MSG_SETUP + 2), MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then
|
||||
' lo salvo
|
||||
Apply()
|
||||
End If
|
||||
End If
|
||||
|
||||
' Resetto tutti i delegate usati
|
||||
ExitToolAssociation.m_delIsEnabledBtns = Nothing
|
||||
' Reset lua
|
||||
EgtLuaResetGlobVar("STU")
|
||||
|
||||
@@ -609,21 +734,34 @@ Namespace EgtCAM5
|
||||
Public Sub ToolDoubleClick(ByVal param As Object)
|
||||
If TypeOf param Is ToolItem Then
|
||||
Dim SelTool As ToolItem = DirectCast(param, ToolItem)
|
||||
' 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
|
||||
AutoSetUpTool(SelTool, CurrPosition)
|
||||
Return
|
||||
End If
|
||||
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(MSG_SETUPERRORS + 6) & Environment.NewLine
|
||||
For ErrorIndex = 0 To ErrorList.Count - 1
|
||||
sError &= "- " & ErrorList(ErrorIndex) & Environment.NewLine
|
||||
Next
|
||||
Next
|
||||
|
||||
MessageBox.Show(sError, EgtMsg(MSG_SETUPERRORS + 2), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function AutoSetUpTool(SelTool As ToolItem, Position As Position) As Boolean
|
||||
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)
|
||||
@@ -678,12 +816,14 @@ Namespace EgtCAM5
|
||||
SetToolInPos(SelTool, Position, nExit)
|
||||
' altrimenti restituisco falso
|
||||
Else
|
||||
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 6), EgtMsg(MSG_SETUPERRORS + 2), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
||||
ErrorList.Add(SelTool.Name)
|
||||
'MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 9) & " " & SelTool.Name & " " & EgtMsg(MSG_SETUPERRORS + 6), EgtMsg(MSG_SETUPERRORS + 2), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
||||
Return False
|
||||
End If
|
||||
' altrimenti restituisco falso
|
||||
Else
|
||||
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 6), EgtMsg(MSG_SETUPERRORS + 2), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
||||
ErrorList.Add(SelTool.Name)
|
||||
'MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 9) & " " & SelTool.Name & " " & EgtMsg(MSG_SETUPERRORS + 6), EgtMsg(MSG_SETUPERRORS + 2), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
||||
Return False
|
||||
End If
|
||||
Return True
|
||||
@@ -718,6 +858,12 @@ Namespace EgtCAM5
|
||||
|
||||
#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
|
||||
|
||||
End Namespace
|
||||
@@ -919,6 +1065,9 @@ Public Class ExitToolAssociation
|
||||
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
|
||||
|
||||
@@ -995,6 +1144,17 @@ Public Class ExitToolAssociation
|
||||
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
|
||||
@@ -1005,6 +1165,7 @@ Public Class ExitToolAssociation
|
||||
End Get
|
||||
Set(value As ToolItem)
|
||||
m_Tool = value
|
||||
m_IsModifiedTool = m_Tool IsNot m_OrigTool
|
||||
NotifyPropertyChanged("Tool")
|
||||
End Set
|
||||
End Property
|
||||
@@ -1110,6 +1271,8 @@ Public Class ExitToolAssociation
|
||||
Dim sToolName As String = String.Empty
|
||||
EgtTdbGetToolFromUUID(SelTool.Uuid, sToolName)
|
||||
EgtOutLog("Error in setup! Tool:" & sToolName & " TcPos: " & m_MyPos.TcPos)
|
||||
m_IsOccupied = False
|
||||
NotifyPropertyChanged("IsOccupied")
|
||||
Return
|
||||
End If
|
||||
' se la testa restituita non coincide con quella della posizione
|
||||
@@ -1152,7 +1315,7 @@ Public Class ExitToolAssociation
|
||||
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
|
||||
' espando la famiglia in cui l'ho messo
|
||||
sh_ToolsList(Index).IsExpanded = True
|
||||
Exit For
|
||||
End If
|
||||
@@ -1165,10 +1328,15 @@ Public Class ExitToolAssociation
|
||||
Next
|
||||
Next
|
||||
|
||||
' seleziono utensile rimesso in lista
|
||||
m_Tool.IsSelected = True
|
||||
Tool.NotifyPropertyChanged("IsSelected")
|
||||
' e lo tolgo dalla posizione di attrezzaggio
|
||||
Tool = Nothing
|
||||
IsOccupied = False
|
||||
|
||||
End If
|
||||
m_delIsEnabledBtns()
|
||||
End Sub
|
||||
|
||||
#End Region ' SetUpToolCommand
|
||||
@@ -1219,6 +1387,11 @@ Public Class FamilyToolItem
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user