70dca8e466
- aggiornamenti per conservazione pezzi nestati in modifica grezzo - aggiunta gestione materiale per ogni gruppo di lavoro - CsvM trasformato in modulo.
427 lines
16 KiB
VB.net
427 lines
16 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class CurrMachWindowVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Private m_CurrSawingList As New List(Of String)
|
|
Public Property CurrSawingList As List(Of String)
|
|
Get
|
|
Return m_CurrSawingList
|
|
End Get
|
|
Set(value As List(Of String))
|
|
m_CurrSawingList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelCurrSawing As String = String.Empty
|
|
Public Property SelCurrSawing As String
|
|
Get
|
|
Return m_SelCurrSawing
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_SelCurrSawing Then
|
|
m_SelCurrSawing = value
|
|
End If
|
|
CurrentMachine.sCurrSawing = m_SelCurrSawing
|
|
End Set
|
|
End Property
|
|
|
|
Private m_AuxMachTypeList As New List(Of StringIdCmBx)
|
|
Public Property AuxMachTypeList As List(Of StringIdCmBx)
|
|
Get
|
|
Return m_AuxMachTypeList
|
|
End Get
|
|
Set(value As List(Of StringIdCmBx))
|
|
m_AuxMachTypeList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelAuxMachType As StringIdCmBx
|
|
Public Property SelAuxMachType As StringIdCmBx
|
|
Get
|
|
Return m_SelAuxMachType
|
|
End Get
|
|
Set(value As StringIdCmBx)
|
|
If value IsNot m_SelAuxMachType Then
|
|
m_SelAuxMachType = value
|
|
Select Case m_SelAuxMachType.nId
|
|
Case 0
|
|
CurrentMachine.sCurrDrilling = String.Empty
|
|
CurrentMachine.sCurrMilling = String.Empty
|
|
CurrDrilling_Visibility = Visibility.Collapsed
|
|
CurrMilling_Visibility = Visibility.Collapsed
|
|
Case 1
|
|
If Not String.IsNullOrWhiteSpace(CurrentMachine.sCurrDrilling) Then
|
|
SelCurrDrilling = CurrentMachine.sCurrDrilling
|
|
End If
|
|
CurrentMachine.sCurrMilling = String.Empty
|
|
CurrDrilling_Visibility = Visibility.Visible
|
|
CurrMilling_Visibility = Visibility.Collapsed
|
|
Case 2
|
|
If Not String.IsNullOrWhiteSpace(CurrentMachine.sCurrMilling) Then
|
|
SelCurrMilling = CurrentMachine.sCurrMilling
|
|
End If
|
|
CurrentMachine.sCurrDrilling = String.Empty
|
|
CurrDrilling_Visibility = Visibility.Collapsed
|
|
CurrMilling_Visibility = Visibility.Visible
|
|
Case 3
|
|
If Not String.IsNullOrWhiteSpace(CurrentMachine.sCurrDrilling) Then
|
|
SelCurrDrilling = CurrentMachine.sCurrDrilling
|
|
End If
|
|
If Not String.IsNullOrWhiteSpace(CurrentMachine.sCurrMilling) Then
|
|
SelCurrMilling = CurrentMachine.sCurrMilling
|
|
End If
|
|
CurrDrilling_Visibility = Visibility.Visible
|
|
CurrMilling_Visibility = Visibility.Visible
|
|
End Select
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_AuxMachType_Visibility As Visibility
|
|
Public Property AuxMachType_Visibility As Visibility
|
|
Get
|
|
Return m_AuxMachType_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_AuxMachType_Visibility = value
|
|
NotifyPropertyChanged("AuxiliaryMach_Visibility")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CurrDrillingList As New List(Of String)
|
|
Public Property CurrDrillingList As List(Of String)
|
|
Get
|
|
Return m_CurrDrillingList
|
|
End Get
|
|
Set(value As List(Of String))
|
|
m_CurrDrillingList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelCurrDrilling As String
|
|
Public Property SelCurrDrilling As String
|
|
Get
|
|
Return m_SelCurrDrilling
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_SelCurrDrilling Then
|
|
m_SelCurrDrilling = value
|
|
CurrentMachine.sCurrDrilling = m_SelCurrDrilling
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CurrDrilling_Visibility As Visibility
|
|
Public Property CurrDrilling_Visibility As Visibility
|
|
Get
|
|
Return m_CurrDrilling_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_CurrDrilling_Visibility = value
|
|
NotifyPropertyChanged("CurrDrilling_Visibility")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CurrMillingList As New List(Of String)
|
|
Public Property CurrMillingList As List(Of String)
|
|
Get
|
|
Return m_CurrMillingList
|
|
End Get
|
|
Set(value As List(Of String))
|
|
m_CurrMillingList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SelCurrMilling As String
|
|
Public Property SelCurrMilling As String
|
|
Get
|
|
Return m_SelCurrMilling
|
|
End Get
|
|
Set(value As String)
|
|
If value <> m_SelCurrMilling Then
|
|
m_SelCurrMilling = value
|
|
CurrentMachine.sCurrMilling = m_SelCurrMilling
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CurrMilling_Visibility As Visibility
|
|
Public Property CurrMilling_Visibility As Visibility
|
|
Get
|
|
Return m_CurrMilling_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_CurrMilling_Visibility = value
|
|
NotifyPropertyChanged("CurrMilling_Visibility")
|
|
End Set
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property TitleMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 9)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property CurrSawingMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 1)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property AuxMachTypeMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 2)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property CurrDrillingMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 3)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property CurrMillingMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 4)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property OkMsg As String
|
|
Get
|
|
Return "Ok"
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ExitMsg As String
|
|
Get
|
|
Return "Exit"
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
InitializeMachiningLists()
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Private Sub InitializeMachiningLists()
|
|
|
|
'Creo lista lavorazioni di lama
|
|
CreateMachiningList(MCH_MY.SAWING, CurrentMachine.sCurrSaw, m_CurrSawingList)
|
|
|
|
' Verifico la configurazione della macchina per creare i combobox
|
|
Select Case CurrentMachine.MountedToolConfig
|
|
Case CurrentMachine.MountedToolConfigs.SAW
|
|
AuxMachType_Visibility = Visibility.Collapsed
|
|
Case CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL, CurrentMachine.MountedToolConfigs.MANUALTOOLCHANGER, CurrentMachine.MountedToolConfigs.TOOLCHANGER
|
|
'Creo lista lavorazioni foretto e fresa
|
|
If CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL Then
|
|
CreateMachiningList(MCH_MY.DRILLING, CurrentMachine.sCurrDrill, m_CurrDrillingList)
|
|
' Se la lista è vuota cancello la lavorazione corrente di questo tipo
|
|
If m_CurrDrillingList.Count = 0 Then
|
|
CurrentMachine.sCurrDrilling = String.Empty
|
|
End If
|
|
CreateMachiningList(MCH_MY.MILLING, CurrentMachine.sCurrMill, m_CurrMillingList)
|
|
' Se la lista è vuota cancello la lavorazione corrente di questo tipo
|
|
If m_CurrMillingList.Count = 0 Then
|
|
CurrentMachine.sCurrMilling = String.Empty
|
|
End If
|
|
ElseIf CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.MANUALTOOLCHANGER Or
|
|
CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.TOOLCHANGER Then
|
|
CreateMachiningList(MCH_MY.DRILLING, m_CurrDrillingList)
|
|
' Se la lista è vuota cancello la lavorazione corrente di questo tipo
|
|
If m_CurrDrillingList.Count = 0 Then
|
|
CurrentMachine.sCurrDrilling = String.Empty
|
|
End If
|
|
CreateMachiningList(MCH_MY.MILLING, m_CurrMillingList)
|
|
' Se la lista è vuota cancello la lavorazione corrente di questo tipo
|
|
If m_CurrMillingList.Count = 0 Then
|
|
CurrentMachine.sCurrMilling = String.Empty
|
|
End If
|
|
End If
|
|
' Definizione di due righe della tabella con la giusta altezza
|
|
AuxMachType_Visibility = Visibility.Visible
|
|
End Select
|
|
If m_CurrSawingList.Count > 0 Then
|
|
SelCurrSawing = m_CurrSawingList(0)
|
|
Else
|
|
CurrentMachine.sCurrSawing = String.Empty
|
|
End If
|
|
|
|
If Not CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.SAW Then
|
|
If CurrentMachine.bDrilling Then
|
|
m_AuxMachTypeList.Add(New StringIdCmBx(1, EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 6)))
|
|
If CurrentMachine.bMilling Then
|
|
m_AuxMachTypeList.Add(New StringIdCmBx(2, EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 7)))
|
|
If CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.MANUALTOOLCHANGER Or
|
|
CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.TOOLCHANGER Then
|
|
m_AuxMachTypeList.Add(New StringIdCmBx(3, EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 8)))
|
|
End If
|
|
End If
|
|
Else
|
|
If CurrentMachine.bMilling Then
|
|
m_AuxMachTypeList.Add(New StringIdCmBx(2, EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 7)))
|
|
End If
|
|
End If
|
|
' Aggiungo nessuna come ultimo elemento della lista
|
|
m_AuxMachTypeList.Add(New StringIdCmBx(0, EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 5)))
|
|
|
|
If CurrentMachine.sCurrDrilling <> String.Empty Then
|
|
If CurrentMachine.sCurrMilling <> String.Empty Then
|
|
SelAuxMachType = StringIdCmBx.FromIdToStringIdCmBx(3, m_AuxMachTypeList)
|
|
Else
|
|
SelAuxMachType = StringIdCmBx.FromIdToStringIdCmBx(1, m_AuxMachTypeList)
|
|
End If
|
|
Else
|
|
If CurrentMachine.sCurrMilling <> String.Empty Then
|
|
SelAuxMachType = StringIdCmBx.FromIdToStringIdCmBx(2, m_AuxMachTypeList)
|
|
Else
|
|
SelAuxMachType = StringIdCmBx.FromIdToStringIdCmBx(0, m_AuxMachTypeList)
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CreateMachiningList(MachiningType As Integer, CurrTool As String, MachiningList As List(Of String))
|
|
' Recupero UUID dell'utensile
|
|
Dim sTuuid As String = String.Empty
|
|
EgtTdbSetCurrTool(CurrTool)
|
|
EgtTdbGetCurrToolParam(MCH_TP.UUID, sTuuid)
|
|
' Cerco tutte le lavorazioni che utilizzano l'utensile corrente e le aggiungo alla lista
|
|
Dim MachiningName As String = String.Empty
|
|
Dim bOk As Boolean = EgtMdbGetFirstMachining(MachiningType, MachiningName)
|
|
While bOk
|
|
EgtMdbSetCurrMachining(MachiningName)
|
|
Dim sMachTuuid As String = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sMachTuuid)
|
|
If sMachTuuid = sTuuid And VerifyMatThickCompatibility() Then
|
|
MachiningList.Add(MachiningName)
|
|
End If
|
|
bOk = EgtMdbGetNextMachining(MachiningType, MachiningName)
|
|
End While
|
|
' Aggiungo lavorazione nulla
|
|
MachiningList.Add(String.Empty)
|
|
End Sub
|
|
|
|
' Funzione che data la stringa di materiali e spessori della lavorazione, e i dati del grezzo corrente, restituisce se la lavorazione è valida oppure no
|
|
Friend Shared Function VerifyMatThickCompatibility() As Boolean
|
|
If Not IsNothing(CurrentMachine.CurrMat) Then
|
|
Dim SysNotes As String = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.SYSNOTES, SysNotes)
|
|
If SysNotes <> String.Empty Then
|
|
Dim MachiningMaterials() = SysNotes.Split(";".ToCharArray)
|
|
SysNotes = String.Empty
|
|
For Each Material In MachiningMaterials
|
|
Dim Param() As String = Material.Split(",".ToCharArray)
|
|
If Param(0) = CurrentMachine.CurrMat.nId.ToString() Then
|
|
Dim dRawHeight As Double = -1
|
|
StringToDouble(OmagOFFICEMap.refRawPartTabVM.Height, dRawHeight)
|
|
Dim MatMinH As Double = 0
|
|
StringToDouble(Param(1), MatMinH)
|
|
Dim MatMaxH As Double = 0
|
|
StringToDouble(Param(2), MatMaxH)
|
|
If dRawHeight > MatMinH - EPS_SMALL And dRawHeight < MatMaxH + EPS_SMALL Then
|
|
Return True
|
|
End If
|
|
End If
|
|
Next
|
|
Return False
|
|
Else
|
|
Return True
|
|
End If
|
|
Else
|
|
Return True
|
|
End If
|
|
End Function
|
|
|
|
Private Sub CreateMachiningList(MachiningType As Integer, MachiningList As List(Of String))
|
|
' Recupero UUID di tutti gli utensili attrezzati (nel ToolChanger e nel ManualToolChanger)
|
|
Dim TuuidList As New List(Of String)
|
|
For Each ToolChangerPos In CurrentMachine.ToolChanger
|
|
Dim sTuuid As String = String.Empty
|
|
EgtTdbSetCurrTool(ToolChangerPos.sTool)
|
|
EgtTdbGetCurrToolParam(MCH_TP.UUID, sTuuid)
|
|
TuuidList.Add(sTuuid)
|
|
Next
|
|
For Each ToolChangerPos In CurrentMachine.ManualToolChanger
|
|
Dim sTuuid As String = String.Empty
|
|
EgtTdbSetCurrTool(ToolChangerPos.sTool)
|
|
EgtTdbGetCurrToolParam(MCH_TP.UUID, sTuuid)
|
|
TuuidList.Add(sTuuid)
|
|
Next
|
|
' Cerco tutte le lavorazioni che utilizzano un utensile presente e le aggiungo alla lista
|
|
Dim MachiningName As String = String.Empty
|
|
Dim bOk As Boolean = EgtMdbGetFirstMachining(MachiningType, MachiningName)
|
|
While bOk
|
|
' Recupero UUID dell'utensile richiamato dalla lavorazione
|
|
EgtMdbSetCurrMachining(MachiningName)
|
|
Dim sMachTuuid As String = String.Empty
|
|
EgtMdbGetCurrMachiningParam(MCH_MP.TUUID, sMachTuuid)
|
|
' Cerco UUID nella lista degli attrezzati
|
|
For Each Tuuid In TuuidList
|
|
If sMachTuuid = Tuuid Then
|
|
If VerifyMatThickCompatibility() Then
|
|
MachiningList.Add(MachiningName)
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
' Passo alla lavorazione successiva
|
|
bOk = EgtMdbGetNextMachining(MachiningType, MachiningName)
|
|
End While
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class
|
|
|
|
Public Class StringIdCmBx
|
|
|
|
Private m_nId As Integer
|
|
Private m_sName As String
|
|
|
|
Friend ReadOnly Property nId As Integer
|
|
Get
|
|
Return m_nId
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property sName As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(Id As Integer, sName As String)
|
|
m_nId = Id
|
|
m_sName = sName
|
|
End Sub
|
|
|
|
Friend Overloads Shared Function FromIdToStringIdCmBx(nId As Integer, List As List(Of StringIdCmBx)) As StringIdCmBx
|
|
For Each Item In List
|
|
If Item.nId = nId Then
|
|
Return Item
|
|
End If
|
|
Next
|
|
Return Nothing
|
|
End Function
|
|
|
|
Friend Overloads Shared Function FromIdToStringIdCmBx(nId As Integer, List As ObservableCollection(Of StringIdCmBx)) As StringIdCmBx
|
|
For Each Item In List
|
|
If Item.nId = nId Then
|
|
Return Item
|
|
End If
|
|
Next
|
|
Return Nothing
|
|
End Function
|
|
|
|
End Class |