dfbcfa435a
- modificata finestra ProjectTypeWnd - spostato strategit sotto tab Macchina - aggiunta in strategie gestione Beam o Wall
675 lines
25 KiB
VB.net
675 lines
25 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class MachinePanelVM
|
|
Inherits EgtWPFLib5.MachinePanelVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Radice del direttorio delle macchine
|
|
Private m_sMachinesRoot As String
|
|
|
|
' Macchina correntemente selezionata e quindi attiva
|
|
Private m_SelectedMachine As Machine = Nothing
|
|
Public Overrides Property SelectedMachine As Machine
|
|
Get
|
|
Return m_SelectedMachine
|
|
End Get
|
|
Set(value As Machine)
|
|
If value IsNot m_SelectedMachine Then
|
|
' imposto macchina in DbGeometrico
|
|
If Not IsNothing(value) AndAlso EgtSetCurrMachine(value.Name) OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then
|
|
m_SelectedMachine = value
|
|
End If
|
|
' Salvo impostazione macchina corrente
|
|
SaveCurrentMachine()
|
|
NotifyPropertyChanged(NameOf(SelectedMachine))
|
|
' inizializzo la macchina selezionata come macchina corrente
|
|
Dim nMachType As MachineType = DirectCast(m_SelectedMachine, MyMachine).nType
|
|
SectionXMaterial.SetType(nMachType)
|
|
If Not IsNothing(value) Then
|
|
InitCurrentMachine(Map.refMainWindowVM.MainWindowM.sMachinesRoot, value.Name, nMachType)
|
|
Else
|
|
InitCurrentMachine(Map.refMainWindowVM.MainWindowM.sMachinesRoot, m_SelectedMachine.Name, nMachType)
|
|
End If
|
|
' mostro bottone tabella beam o wall a seconda del tipo
|
|
m_BeamTable_Visibility = If(nMachType = MachineType.BEAM OrElse nMachType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed)
|
|
m_WallTable_Visibility = If(nMachType = MachineType.WALL OrElse nMachType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged(NameOf(BeamTable_Visibility))
|
|
NotifyPropertyChanged(NameOf(WallTable_Visibility))
|
|
' carico i Parametri Q da mostrare (Beam, Wall o entrambi) in base al tipo di macchina selezionata
|
|
If Not IsNothing(Map.refConfigurationPageVM) Then
|
|
' carico i parametri Q dei Process letti dall'ini
|
|
Map.refConfigurationPageVM.GetQParamsList()
|
|
' carico la lista di tutti i parametri Q ciclando su ogni Process di PRCList
|
|
If Not IsNothing(Map.refConfigurationPageVM.QBTLParamVMList) Then
|
|
Map.refConfigurationPageVM.QBTLParamVMList.Clear()
|
|
End If
|
|
For Each PRCItem In Map.refConfigurationPageVM.PRCList
|
|
For Each QBTLParam In PRCItem.QBTLParamVMList
|
|
Map.refConfigurationPageVM.QBTLParamVMList.Add(QBTLParam)
|
|
Next
|
|
Next
|
|
NotifyPropertyChanged(NameOf(Map.refConfigurationPageVM.QBTLParamVMList))
|
|
End If
|
|
' aggiorno nome macchina in statusbar
|
|
Map.refMyStatusBarVM.RefreshMachName()
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property ConfigMachTableList As ObservableCollection(Of MachTable)
|
|
Get
|
|
Return CurrentMachine.MachTableList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_MachPanel_IsEnabled As Boolean = True
|
|
Public Property MachPanel_IsEnabled As Boolean
|
|
Get
|
|
Return m_MachPanel_IsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_MachPanel_IsEnabled = value
|
|
NotifyPropertyChanged(NameOf(MachPanel_IsEnabled))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_BeamTable_Visibility As Visibility
|
|
Public ReadOnly Property BeamTable_Visibility As Visibility
|
|
Get
|
|
Return m_BeamTable_Visibility
|
|
End Get
|
|
End Property
|
|
|
|
Private m_WallTable_Visibility As Visibility
|
|
Public ReadOnly Property WallTable_Visibility As Visibility
|
|
Get
|
|
Return m_WallTable_Visibility
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SetUp_Visibility As Visibility
|
|
Get
|
|
Return If(Map.refMainWindowVM.MainWindowM.bModifySetup, Visibility.Visible, Visibility.Collapsed)
|
|
End Get
|
|
End Property
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property ToolDBMsg As String
|
|
Get
|
|
Return EgtMsg(90706)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property MachiningDbMsg As String
|
|
Get
|
|
Return EgtMsg(90707)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property SetUpMsg As String
|
|
Get
|
|
Return EgtMsg(90933)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property ParameterMachineMsg As String
|
|
Get
|
|
Return EgtMsg(61778)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#Region "ToolTip"
|
|
|
|
Public ReadOnly Property ToolDBToolTip As String
|
|
Get
|
|
Return EgtMsg(5003)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property MachiningDbToolTip As String
|
|
Get
|
|
Return EgtMsg(5004)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property SetUpToolTip As String
|
|
Get
|
|
Return EgtMsg(31501)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' ToolTip
|
|
|
|
' Definizione comandi
|
|
Private m_cmdBeamTable As ICommand
|
|
Private m_cmdWallTable As ICommand
|
|
Private m_cmdParameterMachine As ICommand
|
|
|
|
#End Region 'FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in Map
|
|
Map.SetRefMachinePanelVM(Me)
|
|
' recupero cartella radice delle macchine
|
|
m_sMachinesRoot = Map.refMainWindowVM.MainWindowM.sMachinesRoot
|
|
' Carica macchine da cartella delle macchine
|
|
MyMachine.MachineListInit(m_sMachinesRoot, MachineList)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub LoadCurrentMachine()
|
|
If MachineList.Count = 0 Then Return
|
|
Dim CurrMachine As Machine = Nothing
|
|
Dim CurrMachineName As String = String.Empty
|
|
GetMainPrivateProfileString(S_MACH, K_CURRMACH, String.Empty, CurrMachineName)
|
|
Dim bFound As Boolean = False
|
|
If Not String.IsNullOrEmpty(CurrMachineName) Then
|
|
For Each Mach In MachineList
|
|
If Mach.Name = CurrMachineName Then
|
|
bFound = True
|
|
CurrMachine = Mach
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
If Not bFound And MachineList.Count > 0 Then
|
|
CurrMachine = MachineList(0)
|
|
End If
|
|
If Not IsNothing(CurrMachine) Then
|
|
If EgtSetCurrMachine(CurrMachine.Name) Then
|
|
SelectedMachine = CurrMachine
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub SaveCurrentMachine()
|
|
If IsNothing(m_SelectedMachine) Then Return
|
|
WriteMainPrivateProfileString(S_MACH, K_CURRMACH, SelectedMachine.Name)
|
|
End Sub
|
|
|
|
Friend Sub UpdateCurrentMachine()
|
|
Dim sMachName As String = String.Empty
|
|
If EgtGetCurrMachineName(sMachName) Then
|
|
For Each Mach In MachineList
|
|
If Mach.Name = sMachName Then
|
|
SelectedMachine = Mach
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
Friend Function BeamMachDb() As Boolean
|
|
' Assegno le path
|
|
Dim sBaseDir As String = m_sMachinesRoot & "\" & m_SelectedMachine.Name & "\" & "Beam"
|
|
' verifico se ci sono i file ini
|
|
Dim sMachTypePath As String = sBaseDir & "\MachiningTypes.ini"
|
|
Dim sTabTemplPath As String = sBaseDir & "\BeamTableTemplate.ini"
|
|
If File.Exists(sMachTypePath) AndAlso File.Exists(sTabTemplPath) Then
|
|
' apro finestra di gestione lavorazioni travi
|
|
Dim sTitle = EgtMsg(9000) 'Tabelle delle lavorazioni delle travi
|
|
Dim BeamMchsWinVM As New MyBeamMachiningsWindowVM(sTitle, sBaseDir, sMachTypePath, sTabTemplPath)
|
|
Dim BeamMchsWinV As Object = Nothing
|
|
If bOnlyProd Then
|
|
BeamMchsWinV = New OnlyProdBeamMachiningsWindowV(Application.Current.MainWindow, BeamMchsWinVM)
|
|
Else
|
|
BeamMchsWinV = New BeamMachiningsWindowV(Application.Current.MainWindow, BeamMchsWinVM)
|
|
End If
|
|
BeamMchsWinV.ShowDialog()
|
|
Else
|
|
' Impossibile aprire l'Editor delle lavorazioni delle travi.<br/>Mancano i file di configurazione. - Errore
|
|
MessageBox.Show(EgtMsg(9009), EgtMsg(9008), MessageBoxButton.OK, MessageBoxImage.Stop)
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function WallMachDb() As Boolean
|
|
' Assegno le path
|
|
Dim sBaseDir As String = m_sMachinesRoot & "\" & m_SelectedMachine.Name & "\" & "Wall"
|
|
' verifico se ci sono i file ini
|
|
Dim sMachTypePath As String = sBaseDir & "\MachiningTypes.ini"
|
|
Dim sTabTemplPath As String = sBaseDir & "\WallTableTemplate.ini"
|
|
If File.Exists(sMachTypePath) AndAlso File.Exists(sTabTemplPath) Then
|
|
' apro finestra di gestione lavorazioni pareti
|
|
Dim sTitle = EgtMsg(9010) 'Tabelle delle lavorazioni delle pareti
|
|
Dim WallMchsWinVM As New MyBeamMachiningsWindowVM(sTitle, sBaseDir, sMachTypePath, sTabTemplPath, False)
|
|
Dim WallMchsWinV As Object = Nothing
|
|
If bOnlyProd Then
|
|
WallMchsWinV = New OnlyProdBeamMachiningsWindowV(Application.Current.MainWindow, WallMchsWinVM)
|
|
Else
|
|
WallMchsWinV = New BeamMachiningsWindowV(Application.Current.MainWindow, WallMchsWinVM)
|
|
End If
|
|
WallMchsWinV.ShowDialog()
|
|
Else
|
|
' Impossibile aprire l'Editor delle lavorazioni delle pareti.<br/>Mancano i file di configurazione. - Errore
|
|
MessageBox.Show(EgtMsg(9011), EgtMsg(9008), MessageBoxButton.OK, MessageBoxImage.Stop)
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Public Overrides Sub ToolDb(ByVal param As Object)
|
|
If Not VerifyMachinesDir(m_sMachinesRoot) Then Return
|
|
' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa)
|
|
If Not EgtTdbReload() Then
|
|
EgtOutLog("Impossible reloading tool Db")
|
|
MessageBox.Show(EgtMsg(MSG_TOOLDBERRORS + 30), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
|
|
Dim ToolDbWindowVM As New MyToolDbWindowVM(CurrentMachine.sMachDir, CurrentMachine.sMachIniFile, Map.refSceneHostVM.MainScene.GetCtx(), "Beam")
|
|
Dim ToolDbWindowV = New ToolDbWindowV(Application.Current.MainWindow, ToolDbWindowVM)
|
|
|
|
If ToolDbWindowVM.MatType <> 0 Then
|
|
ToolDbWindowV.Height = 640
|
|
ToolDbWindowV.Width = 1024
|
|
ToolDbWindowV.ShowDialog()
|
|
Else
|
|
Exit Sub
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Sub MachDb(ByVal param As Object)
|
|
If Not VerifyMachinesDir(m_sMachinesRoot) Then Return
|
|
' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa)
|
|
If Not EgtMdbReload() Then
|
|
EgtOutLog("Impossible reloading machining Db")
|
|
MessageBox.Show(EgtMsg(MSG_MACHININGDBERRORS + 8), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
Dim MachDbWindowVM As New EgtWPFLib5.MachiningDbWindowVM(CurrentMachine.sMachIniFile, Map.refSceneHostVM.MainScene.GetCtx(), "Stone")
|
|
Dim MachDbWindowV = New EgtWPFLib5.MachiningDbWindowV(Application.Current.MainWindow, MachDbWindowVM)
|
|
|
|
If EgtWPFLib5.MachiningTreeViewItem.m_MatType <> 0 Then
|
|
MachDbWindowV.Height = 768
|
|
MachDbWindowV.Width = 1024
|
|
MachDbWindowV.ShowDialog()
|
|
Else
|
|
Exit Sub
|
|
End If
|
|
End Sub
|
|
|
|
Public Overrides Sub SetUp(ByVal param As Object)
|
|
' verifico che il file di configurazione attrezzaggio (lua) della macchina esista
|
|
If Not File.Exists(CurrentMachine.sMachDir & "\Scripts\" & SETUP_LUA) Then
|
|
EgtOutLog("SetUp error: SetUp configuration file doesn't exist ")
|
|
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 7), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
' carico Lua che contiene le funzioni per ottenere le posizioni valide dell'utensile selezionato,
|
|
' e testa e uscita dell'utensile attrezzato
|
|
EgtLuaExecFile(CurrentMachine.sMachDir & "\Scripts\" & SETUP_LUA)
|
|
' verifico che le teste riportate in configurazione esistano
|
|
Dim Index As Integer = 1
|
|
Dim nErr As Integer = 0
|
|
While nErr = 0
|
|
Dim sHead As String = String.Empty
|
|
nErr = 999
|
|
EgtLuaSetGlobIntVar("STU.INDEX", Index)
|
|
EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos")
|
|
' Leggo variabili
|
|
EgtLuaGetGlobStringVar("STU.HEAD", sHead)
|
|
EgtLuaGetGlobIntVar("STU.ERR", nErr)
|
|
If nErr = 0 Then
|
|
If EgtGetHeadExitCount(sHead) = 0 Then
|
|
MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 8), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
Return
|
|
End If
|
|
End If
|
|
Index += 1
|
|
End While
|
|
' Reset lua
|
|
EgtLuaResetGlobVar("STU")
|
|
|
|
Dim SetUpWindow As New SetUpWindowV(Application.Current.MainWindow, New SetUpWindowVM(CurrentMachine.sMachDir, CurrentMachine.sMachineName)) With {
|
|
.Height = 614,
|
|
.Width = 1024
|
|
}
|
|
|
|
SetUpWindow.ShowDialog()
|
|
End Sub
|
|
|
|
' funzione che scrive i parametri modificati sul file INI
|
|
Public Sub WriteMachParams()
|
|
If String.IsNullOrWhiteSpace(CurrentMachine.sMachParamIniFile) OrElse Not File.Exists(CurrentMachine.sMachParamIniFile) Then
|
|
EgtOutLog("Impossible loading Mach parameters: MachData.ini file not found or not readable")
|
|
Return
|
|
End If
|
|
For Each MachTableItem In ConfigMachTableList
|
|
For Each MachParamItem In MachTableItem.MachParamList
|
|
If MachParamItem.IsModified Then
|
|
Dim sMachParamType As String = String.Empty
|
|
Select Case MachParamItem.nType
|
|
Case MachParamType.DOUBLE_
|
|
sMachParamType = "d"
|
|
Case MachParamType.STRING_
|
|
sMachParamType = "s"
|
|
Case MachParamType.LENGTH
|
|
sMachParamType = "l"
|
|
End Select
|
|
Dim MachParamString As String = sMachParamType & "," & MachParamItem.sName & "," & MachParamItem.sValue & "," & MachParamItem.sDescription
|
|
Dim bOk = WriteMachPrivateProfileString(MachParamItem.nParentTable, MachParamItem.nParamIndex, MachParamString)
|
|
If Not bOk Then
|
|
MessageBox.Show(EgtMsg(61859), EgtMsg(30007))
|
|
Return
|
|
End If
|
|
MachParamItem.IsModifiedReset()
|
|
End If
|
|
Next
|
|
Next
|
|
' se macchina di tipo BOTH copio il file appena scritto nella cartella Beam nella cartella Wall o viceversa
|
|
If CurrentMachine.nType = MachineType.BOTH Then
|
|
If CurrentMachine.sMachParamIniFile.Contains("\" & K_BEAM & "\") Then
|
|
File.Copy(CurrentMachine.sMachParamIniFile, CurrentMachine.sMachParamIniFile.Replace("\" & K_BEAM & "\", "\" & K_WALL & "\"), True)
|
|
Else
|
|
File.Copy(CurrentMachine.sMachParamIniFile, CurrentMachine.sMachParamIniFile.Replace("\" & K_WALL & "\", "\" & K_BEAM & "\"), True)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
' funzione che scrive i parametri modificati sul file LUA
|
|
Private Function WriteMachParamsLua() As Boolean
|
|
If String.IsNullOrWhiteSpace(CurrentMachine.sMachParamIniFile) OrElse Not File.Exists(CurrentMachine.sMachParamIniFile) Then
|
|
EgtOutLog("Impossible loading Mach parameters: MachData.ini file not found or not readable")
|
|
Return False
|
|
End If
|
|
' inizio routine di scrittura
|
|
Dim NewTs3DataFileContent = New List(Of String)
|
|
Dim sMachineStr As String = String.Empty
|
|
For Each MachTableItem In ConfigMachTableList
|
|
NewTs3DataFileContent.Add("local " & MachTableItem.sName & " = {")
|
|
sMachineStr &= " " & MachTableItem.sName & "=" & MachTableItem.sName & ","
|
|
For Each MachParamItem In MachTableItem.MachParamList
|
|
NewTs3DataFileContent.Add(" " & MachParamItem.sName & "=" & MachParamItem.sValue & ",")
|
|
Next
|
|
NewTs3DataFileContent.Last().TrimEnd(",")
|
|
NewTs3DataFileContent.Add("}")
|
|
NewTs3DataFileContent.Add("")
|
|
Next
|
|
NewTs3DataFileContent.Add("local Machine = {" & sMachineStr.TrimEnd(",") & "}")
|
|
NewTs3DataFileContent.Add("return Machine")
|
|
Dim FilePath As String
|
|
If Map.refMainWindowVM.MainWindowM.bMachConfig Then
|
|
FilePath = CurrentMachine.sMachDir & "\" & If(CurrentMachine.nType = MachineType.BEAM, BEAM_DIR, WALL_DIR) & "\" & EBWDATA_FILE
|
|
Else
|
|
FilePath = CurrentMachine.sMachDir & "\" & If(CurrentMachine.nType = MachineType.BEAM, BEAM_DIR, WALL_DIR) & "\" & TS3DATA_FILE
|
|
End If
|
|
Dim sBakFilePath As String = Path.ChangeExtension(FilePath, ".bak")
|
|
If File.Exists(sBakFilePath) Then File.Delete(sBakFilePath)
|
|
If File.Exists(FilePath) Then File.Move(FilePath, sBakFilePath)
|
|
File.WriteAllLines(FilePath, NewTs3DataFileContent, Text.Encoding.UTF8)
|
|
' se macchina di tipo BOTH copio il file appena scritto nella cartella Wall nella cartella Beam
|
|
If CurrentMachine.nType = MachineType.BOTH Then
|
|
Dim DestinationFilePath As String
|
|
If Map.refMainWindowVM.MainWindowM.bMachConfig Then
|
|
DestinationFilePath = CurrentMachine.sMachDir & "\" & BEAM_DIR & "\" & EBWDATA_FILE
|
|
Else
|
|
DestinationFilePath = CurrentMachine.sMachDir & "\" & BEAM_DIR & "\" & TS3DATA_FILE
|
|
End If
|
|
sBakFilePath = Path.ChangeExtension(DestinationFilePath, ".bak")
|
|
If File.Exists(sBakFilePath) Then File.Delete(sBakFilePath)
|
|
File.Move(DestinationFilePath, Path.ChangeExtension(DestinationFilePath, ".bak"))
|
|
File.Copy(FilePath, DestinationFilePath, True)
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
' funzione che verifica la modifica dei valori in Configurazione e ne chiede il salvataggio
|
|
Friend Sub VerifyConfigPageModification()
|
|
Dim bExitFor = False
|
|
' ciclo sui parametri Macchina
|
|
For Each MachTableItem In ConfigMachTableList
|
|
For Each MachParamItem In MachTableItem.MachParamList
|
|
If MachParamItem.IsModified Then
|
|
If MessageBox.Show(EgtMsg(61860), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then
|
|
' scrivo i parametri Macchina
|
|
WriteMachParams()
|
|
WriteMachParamsLua()
|
|
Else
|
|
' se da non salvare li resetto ed esco dai For
|
|
CreateMachParams()
|
|
bExitFor = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
If bExitFor Then Exit For
|
|
Next
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "ParameterMachine"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Exec.
|
|
''' </summary>
|
|
Public ReadOnly Property ParameterMachine_Command As ICommand
|
|
Get
|
|
If m_cmdParameterMachine Is Nothing Then
|
|
m_cmdParameterMachine = New Command(AddressOf ParameterMachineVisibility)
|
|
End If
|
|
Return m_cmdParameterMachine
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ParameterMachineVisibility()
|
|
If Map.refConfigurationPageVM.m_MachineParameter_Visibility Then
|
|
Map.refConfigurationPageVM.SetMachineParameter_Visibility(Visibility.Visible)
|
|
Map.refConfigurationPageVM.SetMachine_Visibility(Visibility.Visible)
|
|
Else
|
|
Map.refConfigurationPageVM.SetMachineParameter_Visibility(Visibility.Collapsed)
|
|
Map.refConfigurationPageVM.SetMachine_Visibility(Visibility.Collapsed)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' ParameterMachine
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|
|
|
|
Public Class MachParam
|
|
Inherits VMBase
|
|
|
|
' table a cui appartiene il parametro
|
|
Private m_nParentTable As Integer
|
|
Friend ReadOnly Property nParentTable As Integer
|
|
Get
|
|
Return m_nParentTable
|
|
End Get
|
|
End Property
|
|
|
|
' indice del parametro
|
|
Private m_nParamIndex As Integer
|
|
Friend ReadOnly Property nParamIndex As Integer
|
|
Get
|
|
Return m_nParamIndex
|
|
End Get
|
|
End Property
|
|
|
|
' tipo della variabile
|
|
Private m_nType As MachParamType
|
|
Friend ReadOnly Property nType As MachParamType
|
|
Get
|
|
Return m_nType
|
|
End Get
|
|
End Property
|
|
|
|
' parametri da struttura
|
|
Private m_sName As String
|
|
Public Property sName As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
End Set
|
|
End Property
|
|
|
|
' parametri da geometria
|
|
Private m_IsModifiedValue As Boolean = False
|
|
Private m_dValue As Double
|
|
Private m_sValue As String
|
|
Public Property sValue As String
|
|
Get
|
|
Select Case nType
|
|
Case MachParamType.DOUBLE_
|
|
Return DoubleToString(m_dValue, 3)
|
|
Case MachParamType.LENGTH
|
|
Return LenToString(m_dValue, 3)
|
|
Case Else ' stringhe
|
|
Return m_sValue
|
|
End Select
|
|
Return If(nType = MachParamType.LENGTH, LenToString(m_dValue, 3), DoubleToString(m_dValue, 3))
|
|
End Get
|
|
Set(value As String)
|
|
Dim dNewValue As Double
|
|
' verifico se valore immesso è diverso dall'originale
|
|
If nParentTable > 0 Then
|
|
' trasformo valori
|
|
Select Case nType
|
|
Case MachParamType.DOUBLE_
|
|
StringToDoubleAdv(value, dNewValue, True)
|
|
m_IsModifiedValue = Math.Abs(dNewValue - m_dValue) > EPS_SMALL
|
|
Case MachParamType.LENGTH
|
|
StringToLenAdv(value, dNewValue, True)
|
|
m_IsModifiedValue = Math.Abs(dNewValue - m_dValue) > EPS_SMALL
|
|
Case Else
|
|
m_IsModifiedValue = String.Compare(value, m_sValue) <> 0
|
|
End Select
|
|
End If
|
|
' se valore immesso è diverso e password non inserita
|
|
If m_IsModifiedValue AndAlso Not Map.refConfigurationPageVM.bModifyMachParam Then
|
|
Map.refConfigurationPageVM.bModifyMachParam = Map.refConfigurationPageVM.VerifyConfigPagePassword()
|
|
If Not Map.refConfigurationPageVM.bModifyMachParam Then
|
|
NotifyPropertyChanged(NameOf(sValue))
|
|
m_IsModifiedValue = False
|
|
Return
|
|
End If
|
|
End If
|
|
|
|
Select Case nType
|
|
Case MachParamType.DOUBLE_, MachParamType.LENGTH
|
|
UpdateParamValue(dNewValue, "")
|
|
Case Else
|
|
UpdateParamValue(0, value)
|
|
End Select
|
|
|
|
If Map.refConfigurationPageVM.bModifyMachParam Then Map.refConfigurationPageVM.VerifyConfigPageModification()
|
|
End Set
|
|
End Property
|
|
Public Property dValue As Double
|
|
Get
|
|
Return m_dValue
|
|
End Get
|
|
Set(value As Double)
|
|
m_dValue = value
|
|
NotifyPropertyChanged(NameOf(sValue))
|
|
End Set
|
|
End Property
|
|
|
|
' descrizione del parametro
|
|
Private m_sDescription As String
|
|
Public Property sDescription As String
|
|
Get
|
|
Return m_sDescription
|
|
End Get
|
|
Set(value As String)
|
|
m_sDescription = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Sub StdInit(nParentTable As Integer, nParamIndex As Integer, Type As MachParamType, sName As String, sDescription As String)
|
|
m_nParentTable = nParentTable
|
|
m_nParamIndex = nParamIndex
|
|
m_nType = Type
|
|
m_sName = sName
|
|
m_sDescription = MsgToString(sDescription)
|
|
End Sub
|
|
|
|
' new per double e length
|
|
Sub New(nParentTable As Integer, nParamIndex As Integer, nType As MachParamType, sParamName As String, dValue As Double, sDescription As String)
|
|
StdInit(nParentTable, nParamIndex, nType, sParamName, sDescription)
|
|
m_dValue = dValue 'sValue = DoubleToString(dValue, 3)
|
|
End Sub
|
|
|
|
' new per stringhe
|
|
Sub New(nParentTable As Integer, nParamIndex As Integer, nType As MachParamType, sParamName As String, sDescription As String)
|
|
StdInit(nParentTable, nParamIndex, nType, sParamName, sDescription)
|
|
End Sub
|
|
|
|
' new per parametro vuoto
|
|
Sub New(nType As MachParamType, nParamIndex As Integer, sParamName As String)
|
|
StdInit(Nothing, nParamIndex, nType, sParamName, "")
|
|
End Sub
|
|
|
|
Friend Sub UpdateParamValue(dNewValue As Double, sNewValue As String, Optional bDraw As Boolean = True)
|
|
Select Case nType
|
|
Case MachParamType.DOUBLE_, MachParamType.LENGTH
|
|
m_dValue = dNewValue
|
|
Case MachParamType.STRING_
|
|
m_sValue = sNewValue
|
|
End Select
|
|
End Sub
|
|
|
|
Public ReadOnly Property IsModified() As Boolean
|
|
Get
|
|
Return m_IsModifiedValue
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub IsModifiedReset()
|
|
m_IsModifiedValue = False
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class MachTable
|
|
Inherits VMBase
|
|
|
|
' nome della table
|
|
Private m_sName As String
|
|
Public Property sName As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_MachParamList As New ObservableCollection(Of MachParam)
|
|
Public Property MachParamList As ObservableCollection(Of MachParam)
|
|
Get
|
|
Return m_MachParamList
|
|
End Get
|
|
Set(value As ObservableCollection(Of MachParam))
|
|
m_MachParamList = value
|
|
End Set
|
|
End Property
|
|
|
|
Sub New(Name As String, ParamList As ObservableCollection(Of MachParam))
|
|
sName = Name
|
|
MachParamList = ParamList
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
' Tipo parametro nel file di configurazione Macchina
|
|
Public Enum MachParamType As Integer
|
|
DOUBLE_ = 1
|
|
STRING_ = 2
|
|
COMBO = 3
|
|
LENGTH = 4
|
|
CHECKBOX = 5
|
|
End Enum |