Files
egtbeamwall/EgtBEAMWALL.ViewerOptimizer/Utility/CurrentMachine.vb
T
2021-09-10 10:01:53 +02:00

135 lines
4.1 KiB
VB.net

Imports System.Collections.ObjectModel
Imports EgtBEAMWALL.Core
Imports EgtUILib
Public Module CurrentMachine
' Nome macchina corrente
Private m_sMachineName As String = String.Empty
' Direttorio macchina corrente
Private m_sMachDir As String = String.Empty
' File ini della macchina
Private m_sMachIniFile As String = String.Empty
' File ini dei parametri macchina
Private m_sMachParamIniFile As String = String.Empty
' Cartella degli script
Private m_sMachScriptDir As String = String.Empty
' Cartella dei setup
Private m_sMachSetupDir As String = String.Empty
' Tipo macchina
Private m_nType As MachineType
#Region "Proprietà che leggono e scrivono i valori anche da o su file ini"
Friend ReadOnly Property sMachineName As String
Get
Return m_sMachineName
End Get
End Property
Friend ReadOnly Property sMachDir As String
Get
Return m_sMachDir
End Get
End Property
Friend ReadOnly Property sMachIniFile As String
Get
Return m_sMachIniFile
End Get
End Property
Friend ReadOnly Property sMachParamIniFile As String
Get
Return m_sMachParamIniFile
End Get
End Property
Friend ReadOnly Property sMachScriptDir As String
Get
Return m_sMachScriptDir
End Get
End Property
Friend ReadOnly Property sMachSetupDir As String
Get
Return m_sMachSetupDir
End Get
End Property
#End Region
Friend ReadOnly Property nType As MachineType
Get
Return m_nType
End Get
End Property
Private m_MachTableList As New ObservableCollection(Of MachTable)
Public Property MachTableList As ObservableCollection(Of MachTable)
Get
Return m_MachTableList
End Get
Set(value As ObservableCollection(Of MachTable))
m_MachTableList = value
End Set
End Property
#Region "Init"
Sub InitCurrentMachine(sMachinesRootDir As String, sMachineName As String, nMachineType As MachineType)
' Nome macchina corrente
m_sMachineName = sMachineName
' Impostazione direttorio macchina
m_sMachDir = sMachinesRootDir & "\" & sMachineName
' Impostazione path MachIni file
m_sMachIniFile = sMachinesRootDir & "\" & sMachineName & "\" & sMachineName & ".ini"
' Impostazione tipo macchina
m_nType = nMachineType
' Impostazione path MachParamIni file
If nType = MachineType.BEAM Then
m_sMachParamIniFile = sMachinesRootDir & "\" & sMachineName & "\" & K_BEAM & "\" & MACH_INI_FILE_NAME
ElseIf nType = MachineType.WALL Then
m_sMachParamIniFile = sMachinesRootDir & "\" & sMachineName & "\" & K_WALL & "\" & MACH_INI_FILE_NAME
End If
' Impostazione path Script dir
m_sMachScriptDir = sMachinesRootDir & "\" & sMachineName & "\" & K_SCRIPT
' Impostazione path Setup dir
m_sMachSetupDir = sMachinesRootDir & "\" & sMachineName & "\" & K_SETUP
' crea l'elenco dei parametri della macchina corrente
CreateMachParams()
End Sub
#End Region 'Init
#Region "Methods"
' funzione che crea l'elenco dei parametri Macchina
Friend Sub CreateMachParams()
MachTableList.Clear()
Dim NewMachParam As MachParam = Nothing
Dim MachParamList As New ObservableCollection(Of MachParam)
Dim TableIndex = 1
Dim ParamIndex As Integer = 1
Dim TableName As String = String.Empty
' verifico che ci sia una table con l'indice designato e ne leggo il nome
While GetMachPrivateProfileString(TableIndex, K_NAME, "", TableName)
' leggo tutti i parametri della table
While MachParamIniFile.GetMachPrivateProfileParam(TableIndex, ParamIndex, NewMachParam)
MachParamList.Add(NewMachParam)
ParamIndex += 1
End While
MachTableList.Add(New MachTable(TableName, MachParamList))
' aggiorno indici e resetto lista per lettura dell'eventuale table successiva
TableIndex += 1
ParamIndex = 1
MachParamList = New ObservableCollection(Of MachParam)
End While
End Sub
#End Region 'Methods
End Module