-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathVc2OpcUaPanelViewModel.cs
104 lines (82 loc) · 2.54 KB
/
Vc2OpcUaPanelViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Diagnostics;
using Caliburn.Micro;
using System.ComponentModel.Composition;
using VisualComponents.Create3D;
using VisualComponents.UX.Shared;
namespace vc2opcua
{
[Export(typeof(IDockableScreen))]
class Vc2OpcUaPanelViewModel : DockableScreen
{
VcUtils _vcutils = new VcUtils();
Server _server;
Thread _serverthread;
public Vc2OpcUaPanelViewModel()
{
this.DisplayName = "VC2OPCUA Panel";
this.IsPinned = true;
this.PaneLocation = DesiredPaneLocation.DockedRight;
}
#region Properties
public Collection<ISimComponent> Components { get; set; } = new Collection<ISimComponent>();
public string Text1 { get; set; } = "";
public string Text2 { get; set; } = "";
public string Text3 { get; set; } = "";
#endregion
#region Methods
// Add methods for listener to execute when component is added or removed
protected override void OnActivate()
{
}
protected override void OnDeactivate(bool close)
{
base.OnDeactivate(close);
}
public void Start()
{
// Start Server
_server = new Server(false, 0);
_serverthread = new Thread(new ThreadStart(_server.Run));
_serverthread.Start();
CanStart = false;
CanStop = true;
_vcutils.VcWriteWarningMsg("OPCUA server started");
}
public void Stop()
{
_server.Stop();
_serverthread.Abort();
CanStart = true;
CanStop = false;
_vcutils.VcWriteWarningMsg("OPCUA server stopped");
}
private bool _canstart = true;
public bool CanStart
{
get { return _canstart; }
private set
{
_canstart = value;
NotifyOfPropertyChange(() => CanStart);
}
}
private bool _canstop = false;
public bool CanStop
{
get { return _canstop; }
private set
{
_canstop = value;
NotifyOfPropertyChange(() => CanStop);
}
}
#endregion
}
}