Files
egtbeamwall/EgtBEAMWALL.Supervisor/VariablesList/VariablesListVM.vb
T
2021-11-04 18:01:43 +01:00

96 lines
3.3 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.Windows.Threading
Imports EgtWPFLib5
Imports EgtBEAMWALL.Core
Public Class VariablesListVM
Private m_VariablesList As New ObservableCollection(Of Variable)
Public ReadOnly Property VariablesList As ObservableCollection(Of Variable)
Get
Return m_VariablesList
End Get
End Property
Sub New()
' inizializzo tutte le variabili
Dim Index As Integer = 1
Dim CommVariable As CommVar = MachManaging.InitVar(S_VARIABLES, Index)
While Not IsNothing(CommVariable)
m_VariablesList.Add(New Variable(CommVariable))
Index += 1
CommVariable = MachManaging.InitVar(S_VARIABLES, Index)
End While
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 1)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 2)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 3)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 4)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 5)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 6)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 7)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 8)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 9)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 10)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 11)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 12)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(S_VARIABLES, 13)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(14)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(15)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(16)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(17)))
'm_VariablesList.Add(New Variable(MachManaging.InitVar(18)))
'm_VariablesList.Add(New Variable(RWVariableManager.InitVar(19)))
End Sub
End Class
Public Class Variable
Inherits VMBase
Private m_CommVar As CommVar
Public ReadOnly Property CommVar As CommVar
Get
Return m_CommVar
End Get
End Property
Public Property sName As String
Get
Return CommVar.sName
End Get
Set(value As String)
CommVar.sName = value
End Set
End Property
Public Property sAddress As String
Get
Return CommVar.sAddress
End Get
Set(value As String)
CommVar.sAddress = value
End Set
End Property
Public Property sValue As String
Get
Return CommVar.sValue
End Get
Set(value As String)
MachManaging.CommandList.Add(ThreadCommand.CreateCommand(CommandTypes.WRITE, {CommVar.nType}, Nothing, {CommVar.sName, value}))
NotifyPropertyChanged(NameOf(sValue))
End Set
End Property
Sub New(CommVar As CommVar)
m_CommVar = CommVar
AddHandler CommVar.NewValue, AddressOf CommVar_NewValue
End Sub
Private Sub CommVar_NewValue(sender As Object, e As NewValueEventArgs)
NotifyPropertyChanged(NameOf(sValue))
End Sub
End Class