@aryacode/dsh-engineering 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/cordis.patch.yml +3 -2
- package/package.json +3 -2
- package/vendor/optix/bridge/LICENSE +35 -0
- package/vendor/optix/bridge/StudioMCPBridge.cs +7022 -0
- package/vendor/optix/bridge/source.json +10 -0
- package/vendor/optix/icon.svg +13 -0
- package/vendor/optix/lib/index.js +1531 -0
- package/vendor/optix/lib/types/bridge.d.ts +77 -0
- package/vendor/optix/lib/types/index.d.ts +52 -0
- package/vendor/optix/lib/types/ocr.d.ts +46 -0
- package/vendor/optix/lib/types/operations.d.ts +42 -0
- package/vendor/optix/lib/types/preview.d.ts +33 -0
- package/vendor/optix/lib/types/templates.d.ts +18 -0
- package/vendor/optix/locale/en.json +6 -0
- package/vendor/optix/locale/zh.json +6 -0
- package/vendor/optix/templates/arya-optix-ipc/manifest.json +260 -0
- package/vendor/optix/templates/arya-optix-ipc/project/AryaNewHMIProject_IPC.optix +81 -0
- package/vendor/optix/templates/arya-optix-ipc/project/AryaNewHMIProject_IPC.optix.design +38 -0
- package/vendor/optix/templates/arya-optix-ipc/project/IDEVersion.txt +1 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Alarms/Alarms.yaml +3 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/AryaNewHMIProject_IPC.yaml +67 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/CommDrivers/CommDrivers.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Converters/Converters.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/DataStores/DataStores.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Loggers/Loggers.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/MQTT/MQTT.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Model/Model.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/NetLogic/NetLogic.yaml +28 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/OPC-UA/OPC-UA.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Recipes/Recipes.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Reports/Reports.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Retentivity/Retentivity.yaml +57 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Groups/Groups.yaml +3 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Roles/Roles.yaml +3 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Security.yaml +7 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Users/Users.yaml +3 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/System/System.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Translations/Translations.yaml +16 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/UI/Keyboards/Keyboards.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/UI/Screens/Screens.yaml +2 -0
- package/vendor/optix/templates/arya-optix-ipc/project/Nodes/UI/UI.yaml +306 -0
- package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/.vscode/launch.json +19 -0
- package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.code-workspace +10 -0
- package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.csproj +19 -0
- package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.references +172 -0
- package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.sln +21 -0
- package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/Private/TypeConstants.cs +20 -0
- package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/Private/UITypeDefinitions.cs +11 -0
- package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/StudioMCPBridge.cs +4555 -0
- package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/UserDefinedModule.xml +26 -0
- package/vendor/optix/templates/arya-optix-panel/manifest.json +411 -0
- package/vendor/optix/templates/arya-optix-panel/project/AryaNewHMIProject_OptixPanel.optix +97 -0
- package/vendor/optix/templates/arya-optix-panel/project/AryaNewHMIProject_OptixPanel.optix.design +38 -0
- package/vendor/optix/templates/arya-optix-panel/project/IDEVersion.txt +1 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Alarms/Alarms.yaml +3 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/AryaNewHMIProject_OptixPanel.yaml +67 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/CommDrivers/CommDrivers.yaml +2 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Converters/Converters.yaml +2 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/DataStores/DataStores.yaml +2 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Loggers/Loggers.yaml +2 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/MQTT/MQTT.yaml +2 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Model/Model.yaml +2 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/NetLogic/NetLogic.yaml +28 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/OPC-UA/OPC-UA.yaml +2 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Recipes/Recipes.yaml +2 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Reports/Reports.yaml +2 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Retentivity/Retentivity.yaml +57 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Groups/Groups.yaml +3 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Roles/Roles.yaml +3 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Security.yaml +7 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Users/Users.yaml +3 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/System/System.yaml +444 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/Translations/Translations.yaml +81 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/Keyboards/Keyboards.yaml +2 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/Screens/Screens.yaml +2 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/DeviceSettingsWidget/DeviceSettingsWidget.yaml +163 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/DeviceSettingsWidget/DeviceSettingsWidgetComponents/DeviceSettingsWidgetComponents.yaml +1663 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/FactoryTalkRemoteAccessWidget/FTRemoteAccessWidgetComponents/FTRemoteAccessWidgetComponents.yaml +2471 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/FactoryTalkRemoteAccessWidget/FactoryTalkRemoteAccessWidget.yaml +218 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/NetworkSettingsWidget/NetworkSettingsWidget.yaml +524 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/NetworkSettingsWidget/NetworkSettingsWidgetComponents/NetworkSettingsWidgetComponents.yaml +690 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/SettingsWidgets.yaml +1265 -0
- package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/UI.yaml +308 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/.vscode/launch.json +19 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/ApplicationNameLogic.cs +19 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.code-workspace +10 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.csproj +19 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.references +172 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.sln +21 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/ConnectionSwitchLogic.cs +74 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/DateAndTimeWidgetLogic.cs +420 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/DeviceSettingsWidgetLogic.cs +34 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/FTOptixStudioVersionLogic.cs +47 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/FTRemoteAccessWidgetSetupLogic.cs +153 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/IncomingConnectionApprovalLogic.cs +118 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/IncomingConnectionReceiverLogic.cs +166 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkConfiguratorEditModelsLogic.cs +56 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkInterfaceLogic.cs +138 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkInterfacesEditModelReaderLogic.cs +87 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkInterfacesEditModelToSystemWriterLogic.cs +139 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkSettingsLogic.cs +168 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/Private/FTRemoteAccessWidgetDataObject.cs +106 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/Private/TypeConstants.cs +37 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/Private/UITypeDefinitions.cs +91 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/RequestAssistanceSwitchLogic.cs +93 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/StudioMCPBridge.cs +4555 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/SystemToNetworkInterfacesEditModelWriterLogic.cs +77 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/UserDefinedModule.xml +111 -0
- package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/WarningIcon.svg +4 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
#region Using directives
|
|
2
|
+
using FTOptix.CoreBase;
|
|
3
|
+
using FTOptix.HMIProject;
|
|
4
|
+
using FTOptix.NetLogic;
|
|
5
|
+
using FTOptix.System;
|
|
6
|
+
using FTOptix.UI;
|
|
7
|
+
using System;
|
|
8
|
+
using System.Collections.Generic;
|
|
9
|
+
using UAManagedCore;
|
|
10
|
+
#endregion
|
|
11
|
+
|
|
12
|
+
public class DateAndTimeWidgetLogic : BaseNetLogic
|
|
13
|
+
{
|
|
14
|
+
private const string LOGGING_CATEGORY = nameof(DateAndTimeWidgetLogic);
|
|
15
|
+
|
|
16
|
+
public override void Start()
|
|
17
|
+
{
|
|
18
|
+
#region SystemNode reference
|
|
19
|
+
IUAVariable systemNodePointer = Owner.GetVariable("SystemNode");
|
|
20
|
+
if (systemNodePointer == null)
|
|
21
|
+
{
|
|
22
|
+
Log.Error(LOGGING_CATEGORY, "SystemNode NodePointer not found.");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
NodeId systemNodeId = (NodeId)systemNodePointer.Value;
|
|
27
|
+
if (systemNodeId == null || systemNodeId == NodeId.Empty)
|
|
28
|
+
{
|
|
29
|
+
Log.Error(LOGGING_CATEGORY, "SystemNode is not defined.");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
systemNode = InformationModel.Get(systemNodeId) as FTOptix.System.System;
|
|
34
|
+
if (systemNode == null)
|
|
35
|
+
{
|
|
36
|
+
Log.Error(LOGGING_CATEGORY, "SystemNode not found.");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
#endregion
|
|
40
|
+
|
|
41
|
+
InitializeSynchronizationModeRadioButtons();
|
|
42
|
+
|
|
43
|
+
InitializeTimeZoneComboBoxBindings();
|
|
44
|
+
|
|
45
|
+
InitializeLocalNTPServerInterfacesCheckBoxes();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public override void Stop()
|
|
49
|
+
{
|
|
50
|
+
// destruct class objects
|
|
51
|
+
systemNode = null;
|
|
52
|
+
timeZonesEnumerationObject = null;
|
|
53
|
+
synchAutoModeOption = null;
|
|
54
|
+
lanCheckBox = null;
|
|
55
|
+
wanCheckBox = null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#region Time Synchronization Mode
|
|
59
|
+
private void InitializeSynchronizationModeRadioButtons()
|
|
60
|
+
{
|
|
61
|
+
RowLayout modesLayout = Owner.Get<RowLayout>("ModesLayout");
|
|
62
|
+
if (modesLayout == null)
|
|
63
|
+
{
|
|
64
|
+
Log.Error(LOGGING_CATEGORY, "ModesLayout for radio button not found.");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
synchAutoModeOption = modesLayout.Get<RadioButton>("SynchronizationAutoMode");
|
|
69
|
+
if (synchAutoModeOption == null)
|
|
70
|
+
{
|
|
71
|
+
Log.Error(LOGGING_CATEGORY, "SynchronizationAutoMode radio button not found.");
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
RadioButton synchManualModeOrPLCOption = modesLayout.Get<RadioButton>("SynchronizationManualorPLCMode");
|
|
76
|
+
if (synchManualModeOrPLCOption == null)
|
|
77
|
+
{
|
|
78
|
+
Log.Error(LOGGING_CATEGORY, "SynchronizationManualMode radio button not found.");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
synchAutoModeOption.Checked = false;
|
|
83
|
+
synchManualModeOrPLCOption.Checked = false;
|
|
84
|
+
|
|
85
|
+
if (systemNode.DateAndTime.SynchronizationMode == TimeSynchronizationMode.Auto)
|
|
86
|
+
synchAutoModeOption.Checked = true;
|
|
87
|
+
else if (systemNode.DateAndTime.SynchronizationMode == TimeSynchronizationMode.Manual || systemNode.DateAndTime.SynchronizationMode == TimeSynchronizationMode.PLC)
|
|
88
|
+
synchManualModeOrPLCOption.Checked = true;
|
|
89
|
+
}
|
|
90
|
+
#endregion
|
|
91
|
+
|
|
92
|
+
#region TimeZone Setup
|
|
93
|
+
private void InitializeTimeZoneComboBoxBindings()
|
|
94
|
+
{
|
|
95
|
+
var timeZoneComboBox = Owner.Get<ComboBox>("TimeZoneComboBox");
|
|
96
|
+
if (timeZoneComboBox == null)
|
|
97
|
+
{
|
|
98
|
+
Log.Error(LOGGING_CATEGORY, "TimeZoneComboBox not found.");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
var startingTimeZone = systemNode.DateAndTime.TimeZone;
|
|
102
|
+
|
|
103
|
+
var representativeTimeZone = GetCurrentTimeZone(startingTimeZone);
|
|
104
|
+
if (string.IsNullOrEmpty(representativeTimeZone))
|
|
105
|
+
{
|
|
106
|
+
Log.Error(LOGGING_CATEGORY, $"Time zone {startingTimeZone} is not recognized as a valid time zone.");
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
InitializeTimeZonesObject();
|
|
111
|
+
|
|
112
|
+
timeZoneComboBox.SelectedValueVariable.ResetDynamicLink();
|
|
113
|
+
timeZoneComboBox.SelectedValueVariable.SetDynamicLink(systemNode.DateAndTime.TimeZoneVariable, DynamicLinkMode.ReadWrite);
|
|
114
|
+
}
|
|
115
|
+
private void InitializeTimeZonesObject()
|
|
116
|
+
{
|
|
117
|
+
timeZonesEnumerationObject = Owner.GetObject("TimeZonesEnumeration");
|
|
118
|
+
if (timeZonesEnumerationObject == null)
|
|
119
|
+
Log.Error(LOGGING_CATEGORY, "TimeZonesEnumeration object not found.");
|
|
120
|
+
|
|
121
|
+
int cnt = 0;
|
|
122
|
+
foreach (var timeZonePair in timeZonesMap)
|
|
123
|
+
AddTimeZone(timeZonePair.Key, timeZonePair.Value, cnt++);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private void AddTimeZone(List<string> value, string displayName, int index)
|
|
127
|
+
{
|
|
128
|
+
var timeZoneVariable = InformationModel.MakeVariable("TimeZone" + index, UAManagedCore.OpcUa.DataTypes.String);
|
|
129
|
+
timeZoneVariable.Value = value[0]; // take first item as value
|
|
130
|
+
|
|
131
|
+
var localeId = Session.User.LocaleId;
|
|
132
|
+
if (String.IsNullOrEmpty(localeId))
|
|
133
|
+
Log.Error(LOGGING_CATEGORY, "No locale found for the current user.");
|
|
134
|
+
|
|
135
|
+
timeZoneVariable.DisplayName = new LocalizedText("TimeZone" + index + "DisplayName", displayName, localeId);
|
|
136
|
+
|
|
137
|
+
timeZonesEnumerationObject.Add(timeZoneVariable);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
private static string GetCurrentTimeZone(string timeZone)
|
|
141
|
+
{
|
|
142
|
+
// Get the representative timeZone for each group (by default the first element of the group)
|
|
143
|
+
foreach (var timeZonePair in timeZonesMap)
|
|
144
|
+
{
|
|
145
|
+
var currentTimeZone = timeZonePair.Key;
|
|
146
|
+
if (currentTimeZone.Contains(timeZone))
|
|
147
|
+
return currentTimeZone[0];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return string.Empty;
|
|
151
|
+
}
|
|
152
|
+
#endregion
|
|
153
|
+
|
|
154
|
+
#region Local NTP server interfaces
|
|
155
|
+
private void InitializeLocalNTPServerInterfacesCheckBoxes()
|
|
156
|
+
{
|
|
157
|
+
lanCheckBox = Owner.Get<CheckBox>("LocalNTPServerLANCheckbox");
|
|
158
|
+
if (lanCheckBox == null)
|
|
159
|
+
{
|
|
160
|
+
Log.Error(LOGGING_CATEGORY, "LocalNTPServerLANCheckbox not found.");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
wanCheckBox = Owner.Get<CheckBox>("LocalNTPServerWANCheckbox");
|
|
165
|
+
if (wanCheckBox == null)
|
|
166
|
+
{
|
|
167
|
+
Log.Error(LOGGING_CATEGORY, "LocalNTPServerWANCheckbox not found.");
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
lanCheckBox.Checked = false;
|
|
172
|
+
wanCheckBox.Checked = false;
|
|
173
|
+
|
|
174
|
+
foreach (string localNTPServerInterface in (Array)systemNode.DateAndTime.LocalNTPServerInterfaces)
|
|
175
|
+
{
|
|
176
|
+
if (localNTPServerInterface == LAN_INTERFACE_NAME)
|
|
177
|
+
lanCheckBox.Checked = true;
|
|
178
|
+
else if (localNTPServerInterface == WAN_INTERFACE_NAME)
|
|
179
|
+
wanCheckBox.Checked = true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
#endregion
|
|
183
|
+
|
|
184
|
+
private bool IsSynchronizationModeAvailable(TimeSynchronizationMode synchMode)
|
|
185
|
+
{
|
|
186
|
+
if (Array.IndexOf((Array)systemNode.DateAndTime.AvailableSynchronizationModes, synchMode) != -1)
|
|
187
|
+
return true;
|
|
188
|
+
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
[ExportMethod]
|
|
193
|
+
public void Reboot_Device()
|
|
194
|
+
{
|
|
195
|
+
if (systemNode == null)
|
|
196
|
+
{
|
|
197
|
+
Log.Error(LOGGING_CATEGORY, "SystemNode reference not defined. Reboot failed.");
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// reboot the device
|
|
202
|
+
systemNode.Reboot();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
[ExportMethod]
|
|
206
|
+
public void SynchronizationModeChanged()
|
|
207
|
+
{
|
|
208
|
+
if (synchAutoModeOption == null)
|
|
209
|
+
{
|
|
210
|
+
Log.Error(LOGGING_CATEGORY, "SynchronizationAutoMode radio button not found.");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (systemNode == null)
|
|
215
|
+
{
|
|
216
|
+
Log.Error(LOGGING_CATEGORY, "SystemNode reference not defined. SynchronizationMode update failed.");
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (synchAutoModeOption.Checked)
|
|
221
|
+
{
|
|
222
|
+
systemNode.DateAndTime.SynchronizationMode = TimeSynchronizationMode.Auto;
|
|
223
|
+
}
|
|
224
|
+
else
|
|
225
|
+
{
|
|
226
|
+
if (IsSynchronizationModeAvailable(TimeSynchronizationMode.PLC))
|
|
227
|
+
{
|
|
228
|
+
systemNode.DateAndTime.SynchronizationMode = TimeSynchronizationMode.PLC;
|
|
229
|
+
}
|
|
230
|
+
else if (IsSynchronizationModeAvailable(TimeSynchronizationMode.Manual))
|
|
231
|
+
{
|
|
232
|
+
systemNode.DateAndTime.SynchronizationMode = TimeSynchronizationMode.Manual;
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
else
|
|
236
|
+
{
|
|
237
|
+
// Invalid Time Synchronization Mode
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
[ExportMethod]
|
|
243
|
+
public void LocalNTPServerOptionsChanged()
|
|
244
|
+
{
|
|
245
|
+
if (lanCheckBox == null)
|
|
246
|
+
{
|
|
247
|
+
Log.Error(LOGGING_CATEGORY, "LocalNTPServerLANCheckbox not found.");
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (wanCheckBox == null)
|
|
252
|
+
{
|
|
253
|
+
Log.Error(LOGGING_CATEGORY, "LocalNTPServerWANCheckbox not found.");
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (systemNode == null)
|
|
258
|
+
{
|
|
259
|
+
Log.Error(LOGGING_CATEGORY, "SystemNode reference not defined. LocalNTPServer update failed.");
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
List<string> listOfEnabledLocalNTPServerInterfaces = new();
|
|
264
|
+
if (lanCheckBox.Checked)
|
|
265
|
+
listOfEnabledLocalNTPServerInterfaces.Add(LAN_INTERFACE_NAME);
|
|
266
|
+
else
|
|
267
|
+
listOfEnabledLocalNTPServerInterfaces.Add(""); // Add empty array items to keep same array size for variable value
|
|
268
|
+
if (wanCheckBox.Checked)
|
|
269
|
+
listOfEnabledLocalNTPServerInterfaces.Add(WAN_INTERFACE_NAME);
|
|
270
|
+
else if (wanCheckBox.Enabled)
|
|
271
|
+
listOfEnabledLocalNTPServerInterfaces.Add(""); // Add empty array items to keep same array size for variable value
|
|
272
|
+
systemNode.DateAndTime.LocalNTPServerInterfaces = listOfEnabledLocalNTPServerInterfaces.ToArray();
|
|
273
|
+
listOfEnabledLocalNTPServerInterfaces.Clear();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private FTOptix.System.System systemNode;
|
|
277
|
+
|
|
278
|
+
private IUAObject timeZonesEnumerationObject;
|
|
279
|
+
|
|
280
|
+
private RadioButton synchAutoModeOption;
|
|
281
|
+
private CheckBox lanCheckBox;
|
|
282
|
+
private CheckBox wanCheckBox;
|
|
283
|
+
|
|
284
|
+
private const string LAN_INTERFACE_NAME = "LAN";
|
|
285
|
+
private const string WAN_INTERFACE_NAME = "WAN";
|
|
286
|
+
|
|
287
|
+
#region TimeZonesMap
|
|
288
|
+
private static readonly Dictionary<List<string>, string> timeZonesMap = new()
|
|
289
|
+
{
|
|
290
|
+
{ new List<string>(){"UTC" } , "(UTC) Coordinated Universal Time"},
|
|
291
|
+
{ new List<string>(){"Africa/Casablanca" } , "(UTC+00:00) Casablanca"},
|
|
292
|
+
{ new List<string>(){"Europe/London", "Europe/Dublin", "Europe/Lisbon", "GMT" } , "(UTC+00:00) Dublin, Edinburgh, Lisbon, London"},
|
|
293
|
+
{ new List<string>(){"Africa/Monrovia", "Atlantic/Reykjavik" } , "(UTC+00:00) Monrovia, Reykjavik"},
|
|
294
|
+
{ new List<string>(){"CET", "Europe/Amsterdam", "Europe/Berlin", "Europe/Rome", "Europe/Stockholm", "Europe/Vienna" } , "(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"},
|
|
295
|
+
{ new List<string>(){"Europe/Budapest", "Europe/Belgrade", "Europe/Bratislava", "Europe/Ljubljana", "Europe/Prague" } , "(UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague"},
|
|
296
|
+
{ new List<string>(){"Europe/Brussels", "Europe/Copenhagen", "Europe/Madrid", "Europe/Paris" } , "(UTC+01:00) Brussels, Copenhagen, Madrid, Paris"},
|
|
297
|
+
{ new List<string>(){"Europe/Belgrade", "Europe/Sarajevo", "Europe/Skopje", "Europe/Warsaw", "Europe/Zagreb" } , "(UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb"},
|
|
298
|
+
{ new List<string>(){"Africa/Lagos" } , "(UTC+01:00) West Central Africa"},
|
|
299
|
+
{ new List<string>(){"Africa/Windhoek" } , "(UTC+01:00) Windhoek"},
|
|
300
|
+
{ new List<string>(){"Asia/Amman" } , "(UTC+02:00) Amman"},
|
|
301
|
+
{ new List<string>(){"Europe/Athens", "Europe/Bucharest" } , "(UTC+02:00) Athens, Bucharest"},
|
|
302
|
+
{ new List<string>(){"Asia/Beirut" } , "(UTC+02:00) Beirut"},
|
|
303
|
+
{ new List<string>(){"Africa/Cairo" } , "(UTC+02:00) Cairo"},
|
|
304
|
+
{ new List<string>(){"Europe/Chisinau" } , "(UTC+02:00) Chisinau"},
|
|
305
|
+
{ new List<string>(){"Asia/Damascus" } , "(UTC+02:00) Damascus"},
|
|
306
|
+
{ new List<string>(){"Asia/Gaza", "Asia/Hebron" } , "(UTC+02:00) Gaza, Hebron"},
|
|
307
|
+
{ new List<string>(){"Africa/Harare" } , "(UTC+02:00) Harare, Pretoria"},
|
|
308
|
+
{ new List<string>(){"Europe/Helsinki", "Europe/Kyiv", "Europe/Riga", "Europe/Sofia", "Europe/Tallinn", "Europe/Vilnius" } , "(UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius"},
|
|
309
|
+
{ new List<string>(){"Asia/Jerusalem" } , "(UTC+02:00) Jerusalem"},
|
|
310
|
+
{ new List<string>(){"Europe/Kalining" } , "(UTC+02:00) Kaliningrad"},
|
|
311
|
+
{ new List<string>(){"Africa/Tripoli" } , "(UTC+02:00) Tripoli"},
|
|
312
|
+
{ new List<string>(){"Asia/Baghdad" } , "(UTC+03:00) Baghdad"},
|
|
313
|
+
{ new List<string>(){"Europe/Istanbul" } , "(UTC+03:00) Istanbul"},
|
|
314
|
+
{ new List<string>(){"Asia/Riyadh", "Asia/Kuwait" } , "(UTC+03:00) Kuwait, Riyadh"},
|
|
315
|
+
{ new List<string>(){"Europe/Minsk" } , "(UTC+03:00) Minsk"},
|
|
316
|
+
{ new List<string>(){"Europe/Moscow", "Europe/Volgogra" } , "(UTC+03:00) Moscow, St. Petersburg, Volgograd"},
|
|
317
|
+
{ new List<string>(){"Africa/Nairobi" } , "(UTC+03:00) Nairobi"},
|
|
318
|
+
{ new List<string>(){"Asia/Tehran" } , "(UTC+03:30) Tehran"},
|
|
319
|
+
{ new List<string>(){"Asia/Dubai" } , "(UTC+04:00) Abu Dhabi, Muscat"},
|
|
320
|
+
{ new List<string>(){"Europe/Astrakhan", "Europe/Ulyanovsk" } , "(UTC+04:00) Astrakhan, Ulyanovsk"},
|
|
321
|
+
{ new List<string>(){"Asia/Baku" } , "(UTC+04:00) Baku"},
|
|
322
|
+
{ new List<string>(){"Europe/Samara" } , "(UTC+04:00) Izhevsk, Samara"},
|
|
323
|
+
{ new List<string>(){"Indian/Mauritius" } , "(UTC+04:00) Port Louis"},
|
|
324
|
+
{ new List<string>(){"Asia/Tbilisi" } , "(UTC+04:00) Tbilisi"},
|
|
325
|
+
{ new List<string>(){"Asia/Yerevan" } , "(UTC+04:00) Yerevan"},
|
|
326
|
+
{ new List<string>(){"Asia/Kabul" } , "(UTC+04:30) Kabul"},
|
|
327
|
+
{ new List<string>(){"Asia/Ashgabat", "Asia/Tashkent" } , "(UTC+05:00) Ashgabat, Tashkent"},
|
|
328
|
+
{ new List<string>(){"Asia/Yekaterinburg" } , "(UTC+05:00) Ekaterinburg"},
|
|
329
|
+
{ new List<string>(){"Asia/Karachi" } , "(UTC+05:00) Islamabad, Karachi"},
|
|
330
|
+
{ new List<string>(){"Asia/Kolkata" } , "(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi"},
|
|
331
|
+
{ new List<string>(){"Asia/Colombo" } , "(UTC+05:30) Sri Jayawardenepura"},
|
|
332
|
+
{ new List<string>(){"Asia/Kathmandu" } , "(UTC+05:45) Kathmandu"},
|
|
333
|
+
{ new List<string>(){"Asia/Almaty" } , "(UTC+06:00) Astana"},
|
|
334
|
+
{ new List<string>(){"Asia/Dhaka" } , "(UTC+06:00) Dhaka"},
|
|
335
|
+
{ new List<string>(){"Asia/Omsk" } , "(UTC+06:00) Omsk"},
|
|
336
|
+
{ new List<string>(){"Asia/Yangon", "Asia/Rangoon" } , "(UTC+06:30) Yangon (Rangoon)"},
|
|
337
|
+
{ new List<string>(){"Asia/Bangkok", "Asia/Jakarta" } , "(UTC+07:00) Bangkok, Hanoi, Jakarta"},
|
|
338
|
+
{ new List<string>(){"Asia/Barnaul" } , "(UTC+07:00) Barnaul, Gorno-Altaysk"},
|
|
339
|
+
{ new List<string>(){"Asia/Hovd" } , "(UTC+07:00) Hovd"},
|
|
340
|
+
{ new List<string>(){"Asia/Krasnoyarsk" } , "(UTC+07:00) Krasnoyarsk"},
|
|
341
|
+
{ new List<string>(){"Asia/Novosibirsk" } , "(UTC+07:00) Novosibirsk"},
|
|
342
|
+
{ new List<string>(){"Asia/Tomsk" } , "(UTC+07:00) Tomsk"},
|
|
343
|
+
{ new List<string>(){"Asia/Hong_Kong", "Asia/Chongqing", "Asia/Urumqi" } , "(UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi"},
|
|
344
|
+
{ new List<string>(){"Asia/Irkutsk" } , "(UTC+08:00) Irkutsk"},
|
|
345
|
+
{ new List<string>(){"Asia/Singapore", "Asia/Kuala_Lumpur" } , "(UTC+08:00) Kuala Lumpur, Singapore"},
|
|
346
|
+
{ new List<string>(){"Australia/Perth" } , "(UTC+08:00) Perth"},
|
|
347
|
+
{ new List<string>(){"Asia/Taipei" } , "(UTC+08:00) Taipei"},
|
|
348
|
+
{ new List<string>(){"Asia/Ulaanbaatar" } , "(UTC+08:00) Ulaanbaatar"},
|
|
349
|
+
{ new List<string>(){"Asia/Pyongyang" } , "(UTC+08:30) Pyongyang"},
|
|
350
|
+
{ new List<string>(){"Australia/Eucla" } , "(UTC+08:45) Eucla"},
|
|
351
|
+
{ new List<string>(){"Asia/Chita" } , "(UTC+09:00) Chita"},
|
|
352
|
+
{ new List<string>(){"Asia/Tokyo" } , "(UTC+09:00) Osaka, Sapporo, Tokyo"},
|
|
353
|
+
{ new List<string>(){"Asia/Seoul" } , "(UTC+09:00) Seoul"},
|
|
354
|
+
{ new List<string>(){"Asia/Yakutsk" } , "(UTC+09:00) Yakutsk"},
|
|
355
|
+
{ new List<string>(){"Australia/Adelaide" } , "(UTC+09:30) Adelaide"},
|
|
356
|
+
{ new List<string>(){"Australia/Darwin" } , "(UTC+09:30) Darwin"},
|
|
357
|
+
{ new List<string>(){"Australia/Brisbane" } , "(UTC+10:00) Brisbane"},
|
|
358
|
+
{ new List<string>(){"Australia/Sydney", "Australia/Canberra", "Australia/Melbourne" } , "(UTC+10:00) Canberra, Melbourne, Sydney"},
|
|
359
|
+
{ new List<string>(){"Pacific/Guam", "Pacific/Port_Moresby" } , "(UTC+10:00) Guam, Port Moresby"},
|
|
360
|
+
{ new List<string>(){"Australia/Hobart" } , "(UTC+10:00) Hobart"},
|
|
361
|
+
{ new List<string>(){"Asia/Vladivostok" } , "(UTC+10:00) Vladivostok"},
|
|
362
|
+
{ new List<string>(){"Australia/Lord_Howe" } , "(UTC+10:30) Lord Howe Island"},
|
|
363
|
+
{ new List<string>(){"Pacific/Bougainville" } , "(UTC+11:00) Bougainville Island"},
|
|
364
|
+
{ new List<string>(){"Asia/Srednekolymsk" } , "(UTC+11:00) Chokurdakh"},
|
|
365
|
+
{ new List<string>(){"Asia/Magadan" } , "(UTC+11:00) Magadan"},
|
|
366
|
+
{ new List<string>(){"Pacific/Norfolk" } , "(UTC+11:00) Norfolk Island"},
|
|
367
|
+
{ new List<string>(){"Asia/Sakhalin" } , "(UTC+11:00) Sakhalin"},
|
|
368
|
+
{ new List<string>(){"Pacific/Noumea" } , "(UTC+11:00) Solomon Is., New Caledonia"},
|
|
369
|
+
{ new List<string>(){"Asia/Anadyr" } , "(UTC+12:00) Anadyr, Petropavlovsk-Kamchatsky"},
|
|
370
|
+
{ new List<string>(){"Pacific/Auckland" } , "(UTC+12:00) Auckland, Wellington"},
|
|
371
|
+
{ new List<string>(){"Pacific/Funafuti" } , "(UTC+12:00) Coordinated Universal Time +12"},
|
|
372
|
+
{ new List<string>(){"Pacific/Fiji" } , "(UTC+12:00) Fiji"},
|
|
373
|
+
{ new List<string>(){"Pacific/Chatham" } , "(UTC+12:45) Chatham Islands"},
|
|
374
|
+
{ new List<string>(){"Pacific/Tongatapu" } , "(UTC+13:00) Nuku'alofa"},
|
|
375
|
+
{ new List<string>(){"Pacific/Apia" } , "(UTC+13:00) Samoa"},
|
|
376
|
+
{ new List<string>(){"Pacific/Kiritimati" } , "(UTC+14:00) Kiritimati Island"},
|
|
377
|
+
{ new List<string>(){"Atlantic/Azores" } , "(UTC-01:00) Azores"},
|
|
378
|
+
{ new List<string>(){"Atlantic/Cape_Verde" } , "(UTC-01:00) Cabo Verde Is."},
|
|
379
|
+
{ new List<string>(){"America/Noronha" } , "(UTC-02:00) Coordinated Universal Time -02"},
|
|
380
|
+
{ new List<string>(){"America/Araguaina" } , "(UTC-03:00) Araguaina"},
|
|
381
|
+
{ new List<string>(){"America/Sao_Paulo" } , "(UTC-03:00) Brasilia"},
|
|
382
|
+
{ new List<string>(){"America/Buenos_Aires", "America/Argentina/Buenos_Aires" } , "(UTC-03:00) Buenos Aires"},
|
|
383
|
+
{ new List<string>(){"America/Cayenne", "America/Fortaleza" } , "(UTC-03:00) Cayenne, Fortaleza"},
|
|
384
|
+
{ new List<string>(){"America/Montevideo" } , "(UTC-03:00) Montevideo"},
|
|
385
|
+
{ new List<string>(){"America/Miquelon" } , "(UTC-03:00) Saint Pierre and Miquelon"},
|
|
386
|
+
{ new List<string>(){"America/St_Johns" } , "(UTC-03:30) Newfoundland"},
|
|
387
|
+
{ new List<string>(){"America/Asuncion" } , "(UTC-04:00) Asuncion"},
|
|
388
|
+
{ new List<string>(){"America/Halifax" } , "(UTC-04:00) Atlantic Time (Canada)"},
|
|
389
|
+
{ new List<string>(){"America/Caracas" } , "(UTC-04:00) Caracas"},
|
|
390
|
+
{ new List<string>(){"America/Cuiaba" } , "(UTC-04:00) Cuiaba"},
|
|
391
|
+
{ new List<string>(){"America/Manaus", "America/Argentina/San_Juan" } , "(UTC-04:00) Georgetown, La Paz, Manaus, San Juan"},
|
|
392
|
+
{ new List<string>(){"America/Godthab" } , "(UTC-03:00) Greenland"},
|
|
393
|
+
{ new List<string>(){"America/Santiago" } , "(UTC-04:00) Santiago"},
|
|
394
|
+
{ new List<string>(){"America/Grand_Turk" } , "(UTC-04:00) Turks and Caicos"},
|
|
395
|
+
{ new List<string>(){"America/Bogota", "America/Lima", "America/Rio_Branco" } , "(UTC-05:00) Bogota, Lima, Quito, Rio Branco"},
|
|
396
|
+
{ new List<string>(){"America/Cancun" } , "(UTC-05:00) Chetumal"},
|
|
397
|
+
{ new List<string>(){"Canada/Eastern" } , "(UTC-05:00) Eastern Time (US & Canada)"},
|
|
398
|
+
{ new List<string>(){"America/Port-au-Prince" } , "(UTC-05:00) Haiti"},
|
|
399
|
+
{ new List<string>(){"America/Havana" } , "(UTC-05:00) Havana"},
|
|
400
|
+
{ new List<string>(){"America/Indiana/Indianapolis" } , "(UTC-05:00) Indiana (East)"},
|
|
401
|
+
{ new List<string>(){"America/Chicago" } , "(UTC-06:00) Central America"},
|
|
402
|
+
{ new List<string>(){"America/Winnipeg" } , "(UTC-06:00) Central Time (US & Canada)"},
|
|
403
|
+
{ new List<string>(){"Pacific/Easter" } , "(UTC-06:00) Easter Island"},
|
|
404
|
+
{ new List<string>(){"America/Mexico_City" } , "(UTC-06:00) Guadalajara, Mexico City, Monterrey"},
|
|
405
|
+
{ new List<string>(){"America/Regina" } , "(UTC-06:00) Saskatchewan"},
|
|
406
|
+
{ new List<string>(){"America/Phoenix" } , "(UTC-07:00) Arizona"},
|
|
407
|
+
{ new List<string>(){"America/Chihuahua", "America/Mazatlan" } , "(UTC-07:00) Chihuahua, La Paz, Mazatlan"},
|
|
408
|
+
{ new List<string>(){"America/Edmonton" } , "(UTC-07:00) Mountain Time (US & Canada)"},
|
|
409
|
+
{ new List<string>(){"America/Tijuana" } , "(UTC-08:00) Baja California"},
|
|
410
|
+
{ new List<string>(){"Pacific/Pitcairn" } , "(UTC-08:00) Coordinated Universal Time-08"},
|
|
411
|
+
{ new List<string>(){"America/Vancouver" } , "(UTC-08:00) Pacific Time (US & Canada)"},
|
|
412
|
+
{ new List<string>(){"America/Anchorage" } , "(UTC-09:00) Alaska"},
|
|
413
|
+
{ new List<string>(){"Pacific/Gambier" } , "(UTC-09:00) Coordinated Universal Time-09"},
|
|
414
|
+
{ new List<string>(){"Pacific/Marquesas" } , "(UTC-09:30) Marquesas Islands"},
|
|
415
|
+
{ new List<string>(){"America/Adak" } , "(UTC-10:00) Aleutian Islands"},
|
|
416
|
+
{ new List<string>(){"Pacific/Honolulu" } , "(UTC-10:00) Hawaii"},
|
|
417
|
+
{ new List<string>(){"Pacific/Pago_Pago" } , "(UTC-11:00) Coordinated Universal Time -11"}
|
|
418
|
+
};
|
|
419
|
+
#endregion
|
|
420
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#region Using directives
|
|
2
|
+
using UAManagedCore;
|
|
3
|
+
using FTOptix.HMIProject;
|
|
4
|
+
using FTOptix.NetLogic;
|
|
5
|
+
#endregion
|
|
6
|
+
|
|
7
|
+
public class DeviceSettingsWidgetLogic : BaseNetLogic
|
|
8
|
+
{
|
|
9
|
+
private const string LOGGING_CATEGORY = nameof(DeviceSettingsWidgetLogic);
|
|
10
|
+
|
|
11
|
+
public override void Start()
|
|
12
|
+
{
|
|
13
|
+
IUAVariable systemNodePointer = Owner.GetVariable("SystemNode");
|
|
14
|
+
if (systemNodePointer == null)
|
|
15
|
+
{
|
|
16
|
+
Log.Error(LOGGING_CATEGORY, "SystemNode NodePointer not found.");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
NodeId systemNodeId = (NodeId)systemNodePointer.Value;
|
|
21
|
+
if (systemNodeId == null || systemNodeId == NodeId.Empty)
|
|
22
|
+
{
|
|
23
|
+
Log.Error(LOGGING_CATEGORY, "SystemNode is not defined.");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (InformationModel.Get(systemNodeId) is not FTOptix.System.System)
|
|
28
|
+
Log.Error(LOGGING_CATEGORY, "SystemNode not found.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public override void Stop()
|
|
32
|
+
{
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#region Using directives
|
|
2
|
+
using System.IO;
|
|
3
|
+
using FTOptix.NetLogic;
|
|
4
|
+
using FTOptix.UI;
|
|
5
|
+
using FTOptix.SerialPort;
|
|
6
|
+
#endregion
|
|
7
|
+
|
|
8
|
+
public class FTOptixStudioVersionLogic : BaseNetLogic
|
|
9
|
+
{
|
|
10
|
+
public override void Start()
|
|
11
|
+
{
|
|
12
|
+
string strExeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
|
13
|
+
string strWorkPath = Path.GetDirectoryName(strExeFilePath);
|
|
14
|
+
string versionFile = strWorkPath + Path.DirectorySeparatorChar
|
|
15
|
+
+ ".." + Path.DirectorySeparatorChar
|
|
16
|
+
+ ".." + Path.DirectorySeparatorChar
|
|
17
|
+
+ ".." + Path.DirectorySeparatorChar
|
|
18
|
+
+ "IDEVersion.txt";
|
|
19
|
+
|
|
20
|
+
var fileStream = new FileStream(versionFile, FileMode.Open, FileAccess.Read);
|
|
21
|
+
// Read the source file into a byte array.
|
|
22
|
+
byte[] bytes = new byte[fileStream.Length];
|
|
23
|
+
int numBytesToRead = (int)fileStream.Length;
|
|
24
|
+
int numBytesRead = 0;
|
|
25
|
+
while (numBytesToRead > 0)
|
|
26
|
+
{
|
|
27
|
+
// Read may return anything from 0 to numBytesToRead.
|
|
28
|
+
var n = fileStream.Read(bytes, numBytesRead, numBytesToRead);
|
|
29
|
+
|
|
30
|
+
// Break when the end of the file is reached.
|
|
31
|
+
if (n == 0)
|
|
32
|
+
break;
|
|
33
|
+
|
|
34
|
+
numBytesRead += n;
|
|
35
|
+
numBytesToRead -= n;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var versionString = System.Text.Encoding.UTF8.GetString(bytes, 0, bytes.Length);
|
|
39
|
+
|
|
40
|
+
Label label = Owner as Label;
|
|
41
|
+
label.Text = versionString;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public override void Stop()
|
|
45
|
+
{
|
|
46
|
+
}
|
|
47
|
+
}
|