- spostamento parametri macchina in MyMachine

- divisione tra macchina del progetto e di configurazione
This commit is contained in:
Emmanuele Sassi
2025-09-08 10:48:51 +02:00
parent 6fd4184732
commit b6a68f06a3
9 changed files with 490 additions and 545 deletions
@@ -70,15 +70,15 @@ Public Class ConfigurationPageVM
End Get
End Property
Private m_ConfigMachTableList As New ObservableCollection(Of MachTable)
Public Property ConfigMachTableList As ObservableCollection(Of MachTable)
Get
Return m_ConfigMachTableList
End Get
Set(value As ObservableCollection(Of MachTable))
m_ConfigMachTableList = value
End Set
End Property
'Private m_ConfigMachTableList As New ObservableCollection(Of MachTable)
'Public Property ConfigMachTableList As ObservableCollection(Of MachTable)
' Get
' Return m_ConfigMachTableList
' End Get
' Set(value As ObservableCollection(Of MachTable))
' m_ConfigMachTableList = value
' End Set
'End Property
Public ReadOnly Property Custom_Visibility As Visibility
Get
@@ -602,8 +602,8 @@ Public Class ConfigurationPageVM
GetMainPrivateProfileString(S_NEST, K_SECTIONTIME, "", SectionTime)
GetMainPrivateProfileString(S_NEST, K_PARTTIME, "", PartTime)
m_bPrintLabel_IsChecked = (GetMainPrivateProfileInt(S_PRINTER, K_ENABLE, 0) <> 0)
' assegno le liste dei parametri della macchina corrente alla ConfigMachTableList alla pagina di Configurazione
ConfigMachTableList = CurrentMachine.MachTableList
'' assegno le liste dei parametri della macchina corrente alla ConfigMachTableList alla pagina di Configurazione
'ConfigMachTableList = CurrentMachine.MachTableList
' carico i parametri Q dei Process letti dall'ini
GetQParamsList()
' carico la lista di tutti i parametri Q ciclando su ogni Process di PRCList
@@ -651,7 +651,7 @@ Public Class ConfigurationPageVM
WriteMainPrivateProfileString(S_NEST, K_PARTTIME, DoubleToString(m_PartTime, 5))
WriteMainPrivateProfileString(S_PRINTER, K_ENABLE, If(m_bPrintLabel_IsChecked, 1, 0))
Case ConfigSubPages.MACHINE
Map.refMachinePanelVM.VerifyConfigPageModification()
' Map.refMachinePanelVM.VerifyConfigPageModification()
End Select
End Sub
@@ -295,6 +295,7 @@
<Compile Include="Utility\MachParamIniFile.vb" />
<Compile Include="Utility\Map.vb" />
<Compile Include="Utility\MapV.vb" />
<Compile Include="Utility\MyMachine.vb" />
<Compile Include="Utility\PartsObservableCollection.vb" />
<Compile Include="Utility\SectionXMaterialToBeAdded.vb" />
<Compile Include="Utility\Statistic_Messages.vb" />
@@ -1,5 +1,4 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports System.IO
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5
@@ -24,47 +23,21 @@ Public Class MachinePanelVM
If Not IsNothing(value) AndAlso EgtSetCurrMachine(value.Name) Then
m_SelectedMachine = value
End If
' crea l'elenco dei parametri della macchina corrente
DirectCast(value, MyMachine).CreateMachParams()
' Salvo impostazione macchina corrente
SaveCurrentMachine()
'NotifyPropertyChanged(NameOf(SelectedMachine))
' SaveCurrentMachine()
' 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))
'Dim nMachType As MachineType = DirectCast(m_SelectedMachine, MyMachine).nType
'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
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
@@ -334,113 +307,6 @@ Public Class MachinePanelVM
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
@@ -475,199 +341,3 @@ Public Class MachinePanelVM
#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
@@ -27,6 +27,7 @@
Foreground="{StaticResource BeamWall_Corduroy}"/>
<!--Combobox per selezionare la macchina corrente-->
<ComboBox Grid.Column="1"
x:Name="SelMachineCombo"
ItemsSource="{Binding Path=MachineList}" DisplayMemberPath="Name"
SelectedItem="{Binding Path=SelectedMachine}" SelectedValuePath="Name"
Style="{StaticResource OnlyProdCalcPanel_ComboBox}"/>
@@ -63,7 +64,7 @@
</TabItem>
<TabItem Header="PARAMETERS">
<StackPanel Grid.Row="1" Orientation="Horizontal">
<ItemsControl ItemsSource="{Binding ConfigMachTableList}">
<ItemsControl ItemsSource="{Binding SelectedItem.MachTableList, ElementName=SelMachineCombo}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel x:Name="GroupStackPanel" Orientation="Horizontal"/>
+3 -115
View File
@@ -183,6 +183,7 @@ Public Class MainMenuVM
End Sub
Private Function InitCONFIG() As Boolean
EgtSetCurrMachine(Map.refMachinePanelVM.SelectedMachine.Name)
Map.refMainWindowVM.NotifyPropertyChanged(NameOf(Map.refMainWindowVM.nSelTabPage))
Map.refMainMenuVM.NotifyPropertyChanged(NameOf(Map.refMainMenuVM.SendFeedbackIsEnabled))
Return True
@@ -203,115 +204,9 @@ Public Class MainMenuVM
End Function
Private Function InitONLYPRODPAGE() As Boolean
'' aggiorno lista possibili nesting
'Map.refOptimizePanelVM.UpdateOriginTypeList(EgtGetFirstNameInGroup(GDB_ID.ROOT, "RawParts") <> GDB_ID.NULL)
'' aggiorno visibilita' degli elementi grafici
'Map.refProjectVM.SetFeatureManager_Visibility(True)
'Map.refProjectVM.SetShowBeamPanel_Visibility(True)
'Map.refProjectVM.SetOnlyProdManager_Visibility(True)
'Map.refProjectVM.SetOnlyProdLeftPanel_Visibility(True)
'Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(True)
'Map.refProjectVM.NotifyAllPanelVisibility()
'Map.refCALCPanelVM.SetChooseMachineBtn_Visibility(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refMachinePanelVM.MachineList.Count > 1 AndAlso GetMainPrivateProfileInt(S_MACH, K_CHANGEMACH, 0) = 1)
'Map.refRawPartManagerVM.UpdateMovePartInRawPartVisibility()
'Map.refStatisticsTimePanelVM.SetStatisticsTimePanel_Visibility()
'For Each col In Map.refPartListVM.PartColumns
' col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed)
'Next
'For Each col In Map.refRawPartListVM.RawPartColumns
' col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed)
'Next
'For Each col In Map.refRawPartListVM.PartInRawPartColumns
' col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed)
'Next
'For Each col In Map.refFeatureInPartInRawPartListVM.FeatureInPartInRawPartColumns
' col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed)
'Next
'DimensionsIniFile.ReadGridDimensions(ConstDims.PROJECT_ONLYPROD, Map.refProjectVM.GridDims)
'' inizializzo gruppi di lavorazione
'If Not IsNothing(ProjectManagerVM.CurrProd) AndAlso Not IsNothing(ProjectManagerVM.CurrProd.nProdId) AndAlso ProjectManagerVM.CurrProd.nProdId > 0 Then
' If Not m_bOpenProject Then
' If File.Exists(ProjectManagerVM.CurrProd.sProdPath) Then
' ' apro progetto
' 'If ProjectManagerVM.CurrProd.bReloadProject Then
' 'LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROD, 2, EgtMsg(63005), 10, 50) ' Loading parts
' 'Map.refOnlyProdManagerVM.TempCurrProd = ProjectManagerVM.CurrProd
' 'If Map.refSceneHostVM.MainController.OpenProject(ProjectManagerVM.CurrProd.sProdPath, False) Then
' '' aggiorno le colonne in base al tipo progetto
' 'Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE)
' 'Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType)
' '' resetto modifica parametri Q default
' 'Map.refConfigurationPageVM.ResetQParametersModified()
' 'DbControllers.m_ProdController.LockByProdId(ProjectManagerVM.CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber())
' 'Map.refOnlyProdManagerVM.NotifyPropertyChanged(NameOf(Map.refOnlyProdManagerVM.MruFileNames))
' 'End If
' 'Else
' 'LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROD, 2, EgtMsg(63005), 10, 30) ' Loading parts
' '' mostro tutti i pezzi
' 'Map.refShowBeamPanelVM.ShowAll(False)
' '' verifico se il prod ha piu' proj
' 'If ProjectManagerVM.CurrProd.nProjIdList.Count > 1 Then
' ' ' se si rigenero BTLStructure
' ' Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(0))
' ' ' carico filtri di ricerca
' ' Map.refProjectVM.BTLStructureVM.LoadFilters()
' 'End If
' '' recupero indice di modifica progetto
' 'Dim CommIndex As Integer = -1
' 'Dim ActiveSessionList As List(Of StatusMapModel) = DbControllers.m_StatusMapController.GetProd(m_SupervisorId)
' 'For Each ActiveSession In ActiveSessionList
' ' If ActiveSession.ItemId = ProjectManagerVM.CurrProd.nProdId Then
' ' CommIndex = ActiveSession.Index
' ' End If
' 'Next
' 'LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROD, 3, EgtMsg(63002), 30, 100) ' Loading machining groups
' '' carico lista dei MachGroup
' 'Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList()))
' '' fisso indice sessione di comunicazione
' 'If CommIndex > -1 Then
' ' ProjectManagerVM.CurrProd.SetModificationIndex(CommIndex)
' 'End If
' 'ProjectManagerVM.CurrProd.SetReloadProject(True)
' 'End If
' '' se Warehouse di tipo Medium e piu' di un progetto collegato
' 'Dim nDefault As Integer = 2
' 'If GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) = WarehouseType.MEDIUM AndAlso ProjectManagerVM.CurrProd.nProjIdList.Count > 1 Then
' ' ' confronto le Sezioni del BTL importato con quelle in Warehouse
' ' WarehouseWndVM.UpdateSectionXMaterial()
' 'End If
' '' aggiorno titolo
' 'Map.refMainWindowVM.UpdateTitle()
' 'DbControllers.m_ProdController.LockByProdId(ProjectManagerVM.CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber())
' '' controllo se devo lanciare verifica perche' importato
' 'Dim bGetVerifyResult As Boolean = False
' 'Dim bVerifyMach As Boolean = False
' 'Dim nBTLInfoLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO)
' 'While nBTLInfoLayerId <> GDB_ID.NULL
' ' If EgtGetInfo(nBTLInfoLayerId, IMP_VERIFYMACHGROUP, bGetVerifyResult) AndAlso bGetVerifyResult Then
' ' If Not bVerifyMach Then bVerifyMach = True
' ' EgtSetInfo(nBTLInfoLayerId, IMP_VERIFYMACHGROUP, False)
' ' End If
' ' nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO)
' 'End While
' 'If bVerifyMach Then
' ' Map.refCALCPanelVM.VerifyAll()
' 'End If
' '' seleziono prima barra
' 'Map.refProjectVM.MachGroupPanelVM.SelFirstMachGroup()
' Else
' MessageBox.Show(EgtMsg(61871))
' End If
' End If
'Else
' Map.refSceneHostVM.MainController.NewProject()
' Map.refProjectVM.BTLStructureVM = Nothing
' Map.refProjectVM.MachGroupPanelVM = Nothing
'End If
' Gestione cambio pagina
If Not IsNothing(ProjectManagerVM.CurrProd) Then EgtSetCurrMachine(ProjectManagerVM.CurrProd.sMachine)
Map.refMainWindowVM.NotifyPropertyChanged(NameOf(Map.refMainWindowVM.nSelTabPage))
'Map.refMainMenuVM.NotifyPropertyChanged(NameOf(Map.refMainMenuVM.SendFeedbackIsEnabled))
Return True
End Function
@@ -322,14 +217,7 @@ Public Class MainMenuVM
Return False
End If
End If
'' resetto eventuale visualizzazione statistiche
'Map.refProjectVM.SetFeatureManager_Visibility(False)
'Map.refProjectVM.SetShowBeamPanel_Visibility(False)
'Map.refProjectVM.SetOnlyProdManager_Visibility(False)
'Map.refProjectVM.SetOnlyProdLeftPanel_Visibility(False)
'Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(False)
'Map.refCALCPanelVM.SetChooseMachine_Visibility(False)
EgtResetCurrMachGroup()
' EgtResetCurrMachGroup()
Return True
End Function
@@ -5,8 +5,6 @@ Imports EgtBEAMWALL.Core
Imports EgtBEAMWALL.DataLayer.DatabaseModels
Imports EgtUILib
Imports EgtWPFLib5
Imports Windows.UI.Xaml.Controls.Maps
Imports Windows.UI.Xaml.Documents
Public Class OnlyProdManagerVM
Inherits VMBase
@@ -413,14 +411,14 @@ Public Class OnlyProdManagerVM
Dim nProjId As Integer = 0
Dim sBTLFileName As String = ""
Dim nType As BWType = BWType.NULL
Dim sMachine As String = ""
Dim Machine As MyMachine = Nothing
If bFromImportBtl Then
If Not CreateNewProj(Nothing, nProjId, sBTLFileName, nType, sMachine) Then
If Not CreateNewProj(Nothing, nProjId, sBTLFileName, nType, Machine) Then
EgtOutLog("Errore! Creazione nuovo prod fallita!")
Return False
End If
Else
If Not CreateNewEmptyProj(nProjId, nType, sMachine) Then
If Not CreateNewEmptyProj(nProjId, nType, Machine) Then
EgtOutLog("Errore! Creazione nuovo prod vuoto fallita!")
Return False
End If
@@ -435,7 +433,7 @@ Public Class OnlyProdManagerVM
' setto il PType del Prod
DbControllers.m_ProdController.UpdatePType(nProdId, nType)
' setto la Macchina associata al Prod
DbControllers.m_ProdController.UpdateMachine(nProdId, sMachine)
DbControllers.m_ProdController.UpdateMachine(nProdId, Machine.Name)
' creo cartella per Proj
Dim sProjDirPath As String = sProdDir & "\Projs\" & nProjId.ToString("0000")
Try
@@ -531,7 +529,7 @@ Public Class OnlyProdManagerVM
Return True
End Function
Private Function CreateNewProj(ProdFileVM As ProdFileVM, Optional ByRef nProjId As Integer = 0, Optional ByRef sBTLFileName As String = "", Optional ByRef nType As BWType = BWType.NULL, Optional ByRef sMachine As String = "") As Boolean
Private Function CreateNewProj(ProdFileVM As ProdFileVM, Optional ByRef nProjId As Integer = 0, Optional ByRef sBTLFileName As String = "", Optional ByRef nType As BWType = BWType.NULL, Optional ByRef Machine As MyMachine = Nothing) As Boolean
'If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return
Dim sDir As String = String.Empty
GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir)
@@ -570,14 +568,13 @@ Public Class OnlyProdManagerVM
' se si ha una sola macchina disponibile (non BOTH) setto il progetto importato a quella macchina e al tipo progetto associato
' altrimenti apro il dialog per scegliere la macchina e il tipo progetto a cui settare il progetto importato
If Map.refMachinePanelVM.MachineList.Count = 1 AndAlso DirectCast(Map.refMachinePanelVM.MachineList(0), MyMachine).nType <> MachineType.BOTH Then
Dim Machine As MyMachine = DirectCast(Map.refMachinePanelVM.MachineList(0), MyMachine)
sMachine = Machine.Name
Machine = DirectCast(Map.refMachinePanelVM.MachineList(0), MyMachine)
nType = Machine.nType
Else
Dim ProjectTypeWndVM As New ProjectTypeWndVM()
Dim ProjectTypeWnd As New OnlyProdProjectTypeWndV(Application.Current.MainWindow, ProjectTypeWndVM)
If ProjectTypeWnd.ShowDialog() Then
sMachine = ProjectTypeWndVM.SelMachine.Name
Machine = ProjectTypeWndVM.SelMachine
nType = ProjectTypeWndVM.nSelType
Else
Return False
@@ -585,7 +582,7 @@ Public Class OnlyProdManagerVM
End If
'LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file
' creo progetto per file BTL
If Not CreateFirstBTLProj(sImportFilePath, nType, sMachine, nProjId, sProjDir) Then Return False
If Not CreateFirstBTLProj(sImportFilePath, nType, Machine, nProjId, sProjDir) Then Return False
Else
' creo progetto per file BTL
If Not AddNewBTLProj(sImportFilePath, ProdFileVM, nProjId, sProjDir) Then Return False
@@ -598,7 +595,7 @@ Public Class OnlyProdManagerVM
Return True
End Function
Private Function CreateFirstBTLProj(sImportFilePath As String, nType As BWType, sMachine As String, ByRef nProjId As Integer, ByRef sProjDir As String) As Boolean
Private Function CreateFirstBTLProj(sImportFilePath As String, nType As BWType, Machine As MyMachine, ByRef nProjId As Integer, ByRef sProjDir As String) As Boolean
'If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return False
'LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file
' copio file BTL
@@ -612,7 +609,7 @@ Public Class OnlyProdManagerVM
Return False
End Try
' inizializzo nuovo progetto
If Not InitNewProj(nProjId, sProjDir, nType, sMachine) Then
If Not InitNewProj(nProjId, sProjDir, nType, Machine.Name) Then
EgtOutLog("Errore! Impossibile creare indice nuovo progetto!")
' elimino file Btl copiato
Try
@@ -677,6 +674,8 @@ Public Class OnlyProdManagerVM
MessageBox.Show("Imported file is Empty!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning)
Return False
End If
' imposto CurrentMachine
InitCurrentMachine(Machine)
' imposto flag secondo tipo di progetto (travi o pareti)
EgtBeamSetFlag(nFlag)
' LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTBTL, 2, EgtMsg(63005), 50, 70) ' Loading parts
@@ -715,7 +714,7 @@ Public Class OnlyProdManagerVM
Dim sBTLFileName As String = Path.GetFileNameWithoutExtension(sImportFilePath)
DateTime.TryParse(Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPDATE & " " &
Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPTIME, ExportDate)
DbControllers.m_ProjController.UpdateInfo(nProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, sMachine)
DbControllers.m_ProjController.UpdateInfo(nProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, Machine.Name)
' se progetto pareti e vista ruotata
If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then
' ruoto le pareti di 180 per raddrizzarle rispetto alla vista
@@ -888,41 +887,38 @@ Public Class OnlyProdManagerVM
Return True
End Function
Private Function CreateNewEmptyProj(ByRef nProjId As Integer, ByRef nType As BWType, ByRef sMachine As String) As Boolean
Private Function CreateNewEmptyProj(ByRef nProjId As Integer, ByRef nType As BWType, ByRef Machine As MyMachine) As Boolean
'If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return
Dim sProjDir As String = ""
' se si ha una sola macchina disponibile (non BOTH) setto il progetto importato a quella macchina e al tipo progetto associato
' altrimenti apro il dialog per scegliere la macchina e il tipo progetto a cui settare il progetto importato
If Map.refMachinePanelVM.MachineList.Count = 1 AndAlso DirectCast(Map.refMachinePanelVM.MachineList(0), MyMachine).nType <> MachineType.BOTH Then
Dim Machine As MyMachine = DirectCast(Map.refMachinePanelVM.MachineList(0), MyMachine)
sMachine = Machine.Name
Machine = DirectCast(Map.refMachinePanelVM.MachineList(0), MyMachine)
nType = Machine.nType
Else
Dim ProjectTypeWndVM As New ProjectTypeWndVM()
Dim ProjectTypeWnd As New OnlyProdProjectTypeWndV(Application.Current.MainWindow, ProjectTypeWndVM)
If ProjectTypeWnd.ShowDialog() Then
sMachine = ProjectTypeWndVM.SelMachine.Name
Machine = ProjectTypeWndVM.SelMachine
nType = ProjectTypeWndVM.nSelType
Else
Return False
End If
End If
'LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file
' creo progetto per file BTL
If Not CreateFirstEmptyProj(nType, sMachine, nProjId, sProjDir) Then Return False
' creo progetto vuoto
If Not CreateFirstEmptyProj(nType, Machine, nProjId, sProjDir) Then Return False
' carico filtri di ricerca
Map.refProjectVM.BTLStructureVM.LoadFilters()
' gestisco log di importazione
ManageImportLog(nProjId, sProjDir)
'LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL)
Return True
End Function
Private Function CreateFirstEmptyProj(nType As BWType, sMachine As String, ByRef nProjId As Integer, ByRef sProjDir As String) As Boolean
Private Function CreateFirstEmptyProj(nType As BWType, Machine As MyMachine, ByRef nProjId As Integer, ByRef sProjDir As String) As Boolean
'If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return False
'LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file
' inizializzo nuovo progetto
If Not InitNewProj(nProjId, sProjDir, nType, sMachine) Then
If Not InitNewProj(nProjId, sProjDir, nType, Machine.Name) Then
EgtOutLog("Errore! Impossibile creare indice nuovo progetto!")
Return False
End If
@@ -937,6 +933,8 @@ Public Class OnlyProdManagerVM
EgtOutLog("Errore! Impossibile creare nuovo progetto!")
Return False
End If
' imposto CurrentMachine
InitCurrentMachine(Machine)
' imposto flag secondo tipo di progetto (travi o pareti)
Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR)
EgtBeamSetFlag(nFlag)
@@ -976,7 +974,7 @@ Public Class OnlyProdManagerVM
Dim sBTLFileName As String = " New - EgtBEAMWALL"
DateTime.TryParse(Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPDATE & " " &
Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPTIME, ExportDate)
DbControllers.m_ProjController.UpdateInfo(nProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, sMachine)
DbControllers.m_ProjController.UpdateInfo(nProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, Machine.Name)
' aggiungo primo pezzo
Map.refProjectVM.BTLStructureVM.AddPart(nProjId)
Return True
@@ -1185,7 +1183,8 @@ Public Class OnlyProdManagerVM
Return False
End If
' se la macchina del progetto in apertura non è tra le macchine disponibili lo segnalo ed esco
If IsNothing(Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = m_TempCurrProd.sMachine)) Then
Dim OpenProjectMachine As MyMachine = Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = m_TempCurrProd.sMachine)
If IsNothing(OpenProjectMachine) Then
' rimuovo il file in apertura dalla lista degli MRU
m_MruFiles.Remove(sFilePath)
MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error
@@ -1203,6 +1202,8 @@ Public Class OnlyProdManagerVM
EgtOutLog("Errore! Caricamento del progetto fallito!")
Return False
End If
' imposto CurrentMachine
InitCurrentMachine(OpenProjectMachine)
' Procedo a seconda del risultato
LoadingWndHelper.UpdateLoadingWnd(ActiveIds.OPENPROD, 2, EgtMsg(63005), 50, 70) ' Loading part list
' leggo struttura BTL
+15 -51
View File
@@ -3,6 +3,7 @@ Imports System.IO
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5
Imports Google.Protobuf.WellKnownTypes
Public Module CurrentMachine
@@ -147,18 +148,23 @@ Public Module CurrentMachine
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
'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(Machine As MyMachine)
EgtSetCurrMachine(Machine.Name)
InitCurrentMachine(Map.refMainWindowVM.MainWindowM.sMachinesRoot, Machine.Name, Machine.nType)
End Sub
Sub InitCurrentMachine(sMachinesRootDir As String, sMachineName As String, nMachineType As MachineType)
' Nome macchina corrente
m_sMachineName = sMachineName
@@ -196,9 +202,6 @@ Public Module CurrentMachine
' Impostazione path Setup dir
m_sMachSetupDir = sMachinesRootDir & "\" & sMachineName & "\" & K_SETUP
' crea l'elenco dei parametri della macchina corrente
CreateMachParams()
'' aggiorna strategie per macchina corrente
'Map.refStrategyManagerVM.Update()
@@ -340,45 +343,6 @@ Public Module CurrentMachine
#Region "Methods"
' funzione che crea l'elenco dei parametri Macchina
Friend Sub CreateMachParams()
MachTableList.Clear()
If String.IsNullOrWhiteSpace(m_sMachParamIniFile) OrElse Not File.Exists(m_sMachParamIniFile) Then
EgtOutLog("Impossible loading Mach parameters: MachData.ini file not found or not readable")
Return
End If
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
' carico lua ts3data
Dim bTs3DataLoaded As Boolean = False
EgtLuaCreateGlobTable("GTSD")
EgtLuaSetGlobStringVar("GTSD.TS3PATH", m_sTs3DataFile)
Dim sExecPath As String = m_sGetTs3DataFile
bTs3DataLoaded = File.Exists(m_sTs3DataFile) AndAlso EgtLuaExecFile(sExecPath)
If Not bTs3DataLoaded Then
EgtOutLog("Error executing Ts3Data file " & m_sTs3DataFile)
End If
' 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, TableName, bTs3DataLoaded)
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
' Cancello tavola globale
EgtLuaResetGlobVar("GTSD")
End Sub
#End Region 'Methods
End Module
@@ -1,4 +1,5 @@
Imports EgtUILib
Imports EgtBEAMWALL.Optimizer.MachParam
Imports EgtUILib
Imports EgtWPFLib5
Friend Module MachParamIniFile
+419
View File
@@ -0,0 +1,419 @@
Imports System.Collections.ObjectModel
Imports EgtBEAMWALL.Core
Imports EgtWPFLib5
Imports EgtUILib
Imports EgtBEAMWALL.Optimizer.MachParam
Imports System.IO
Public Class MyMachine
Inherits Core.MyMachine
' File ini dei parametri macchina
Private m_sMachParamIniFile As String = String.Empty
' File lettura Ts3Data
Private m_sGetTs3DataFile As String = String.Empty
' File Ts3Data
Private m_sTs3DataFile As String = String.Empty
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
Sub New(sDirPath As String, sIniPath As String)
MyBase.New(sDirPath, sIniPath)
End Sub
Public Shared Shadows Function MachineListInit(sMachinesRootDir As String, MachineList As IList(Of Machine)) As Boolean
' Se direttorio base macchine non definito o non esiste, ritorno
If String.IsNullOrWhiteSpace(sMachinesRootDir) OrElse
Not Directory.Exists(sMachinesRootDir) Then
MachineList = Nothing
Return False
End If
' Cerco le macchine
Dim Machines As String() = Directory.GetDirectories(sMachinesRootDir)
For i As Integer = 0 To Machines.Count - 1
Dim PathIni As String = Machines(i) & "\" & Path.GetFileName(Machines(i)) & ".ini"
Dim PathBeam As String = Machines(i) & "\" & "Beam"
Dim PathWall As String = Machines(i) & "\" & "Wall"
If File.Exists(PathIni) AndAlso (Directory.Exists(PathBeam) OrElse Directory.Exists(PathWall)) Then
MachineList.Add(New MyMachine(Machines(i), PathIni))
End If
Next
Return True
End Function
' 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 MachTableList
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 MachTableList
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 MachTableList
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
' funzione che crea l'elenco dei parametri Macchina
Friend Sub CreateMachParams()
' Impostazione path MachParamIni file
If nType = MachineType.BEAM Then
m_sMachParamIniFile = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_BEAM & "\" & MACH_INI_FILE_NAME
m_sGetTs3DataFile = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_BEAM & "\" & GETTS3DATA_FILE_NAME
m_sTs3DataFile = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_BEAM & "\" & TS3DATA_FILE
ElseIf nType = MachineType.WALL Then
m_sMachParamIniFile = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_WALL & "\" & MACH_INI_FILE_NAME
m_sGetTs3DataFile = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_WALL & "\" & GETTS3DATA_FILE_NAME
m_sTs3DataFile = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_WALL & "\" & TS3DATA_FILE
Else
' Se macchina di tipo BOTH prendo quello presente in Beam, se esiste, altrimenti prendo quello in Wall
Dim sBeamMachParamIniFile = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_BEAM & "\" & MACH_INI_FILE_NAME
Dim sWallMachParamIniFile = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_WALL & "\" & MACH_INI_FILE_NAME
Dim sBeamGetTs3File = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_BEAM & "\" & GETTS3DATA_FILE_NAME
Dim sWallGetTs3File = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_WALL & "\" & GETTS3DATA_FILE_NAME
Dim sBeamTs3DataFile = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_BEAM & "\" & TS3DATA_FILE
Dim sWallTs3DataFile = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & Me.Name & "\" & K_WALL & "\" & TS3DATA_FILE
If nType = MachineType.BOTH Then
m_sMachParamIniFile = If(File.Exists(sBeamMachParamIniFile), sBeamMachParamIniFile, sWallMachParamIniFile)
m_sGetTs3DataFile = If(File.Exists(sBeamGetTs3File), sBeamGetTs3File, sWallGetTs3File)
m_sTs3DataFile = If(File.Exists(sBeamTs3DataFile), sBeamTs3DataFile, sWallTs3DataFile)
End If
End If
MachTableList.Clear()
If String.IsNullOrWhiteSpace(m_sMachParamIniFile) OrElse Not File.Exists(m_sMachParamIniFile) Then
EgtOutLog("Impossible loading Mach parameters: MachData.ini file not found or not readable")
Return
End If
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
' carico lua ts3data
Dim bTs3DataLoaded As Boolean = False
EgtLuaCreateGlobTable("GTSD")
EgtLuaSetGlobStringVar("GTSD.TS3PATH", m_sTs3DataFile)
Dim sExecPath As String = m_sGetTs3DataFile
bTs3DataLoaded = File.Exists(m_sTs3DataFile) AndAlso EgtLuaExecFile(sExecPath)
If Not bTs3DataLoaded Then
EgtOutLog("Error executing Ts3Data file " & m_sTs3DataFile)
End If
' 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, TableName, bTs3DataLoaded)
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
' Cancello tavola globale
EgtLuaResetGlobVar("GTSD")
End Sub
End Class
Public Class MachParam
Inherits VMBase
' Tipo parametro nel file di configurazione Macchina
Public Enum MachParamType As Integer
DOUBLE_ = 1
STRING_ = 2
COMBO = 3
LENGTH = 4
CHECKBOX = 5
End Enum
' 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