@aryacode/dsh-engineering 0.4.7 → 0.4.21

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.
Files changed (162) hide show
  1. package/CHANGELOG.md +202 -0
  2. package/README.md +40 -26
  3. package/cordis.patch.yml +7 -6
  4. package/entries/config.js +62 -0
  5. package/entries/ftview.js +5 -4
  6. package/entries/l5x.js +47 -15
  7. package/entries/mwi.js +26 -6
  8. package/entries/optix.js +105 -0
  9. package/lib/client.js +335 -6
  10. package/package.json +11 -10
  11. package/vendor/ftview/SKILL.md +17 -0
  12. package/vendor/l5x/SKILL.md +17 -0
  13. package/vendor/l5x/studio-bridge/NuGet.Config +1 -1
  14. package/vendor/mwi/README.md +41 -18
  15. package/vendor/mwi/SKILL.md +39 -20
  16. package/vendor/mwi/bridge/mw_bridge.ps1 +2768 -2763
  17. package/vendor/mwi/bridge/sdk-interop-importer.cs +30 -30
  18. package/vendor/mwi/bridge/sdk-variable-reader.cs +22 -22
  19. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/__init__.cpython-312.pyc +0 -0
  20. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/errors.cpython-312.pyc +0 -0
  21. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/staging.cpython-312.pyc +0 -0
  22. package/vendor/mwi/code/engine/motionworks_iec_mcp/build.py +339 -339
  23. package/vendor/mwi/code/engine/motionworks_iec_mcp/cfb.py +765 -765
  24. package/vendor/mwi/code/engine/motionworks_iec_mcp/declarations.py +399 -399
  25. package/vendor/mwi/code/engine/motionworks_iec_mcp/ide.py +313 -313
  26. package/vendor/mwi/code/engine/motionworks_iec_mcp/manuals.py +520 -520
  27. package/vendor/mwi/code/engine/motionworks_iec_mcp/mwt_bind.py +133 -133
  28. package/vendor/mwi/code/engine/motionworks_iec_mcp/reference_data/catalog.json +672 -672
  29. package/vendor/mwi/code/engine/motionworks_iec_mcp/reference_data/patterns.json +86 -86
  30. package/vendor/mwi/code/engine/motionworks_iec_mcp/restore.py +208 -208
  31. package/vendor/mwi/code/engine/motionworks_iec_mcp/staging.py +134 -130
  32. package/vendor/mwi/code/engine/motionworks_iec_mcp/stlint.py +673 -673
  33. package/vendor/mwi/code/engine/motionworks_iec_mcp/tree_writer.py +790 -790
  34. package/vendor/mwi/code/engine/motionworks_iec_mcp/writer.py +642 -642
  35. package/vendor/mwi/lib/core/code-engine.d.ts +13 -0
  36. package/vendor/mwi/lib/core/code-engine.js +18 -1
  37. package/vendor/mwi/lib/edit.d.ts +1 -1
  38. package/vendor/mwi/lib/edit.js +1 -1
  39. package/vendor/mwi/lib/read/service.js +8 -1
  40. package/vendor/mwi/lib/session/backup.d.ts +72 -0
  41. package/vendor/mwi/lib/session/backup.js +257 -0
  42. package/vendor/mwi/lib/session/project.d.ts +4 -1
  43. package/vendor/mwi/lib/session/project.js +13 -2
  44. package/vendor/mwi/lib/session/service.d.ts +13 -6
  45. package/vendor/mwi/lib/session/service.js +127 -36
  46. package/vendor/mwi/lib/session/workspace.d.ts +10 -0
  47. package/vendor/mwi/lib/session/workspace.js +53 -3
  48. package/vendor/mwi/lib/skill.d.ts +2 -2
  49. package/vendor/mwi/lib/skill.js +2 -2
  50. package/vendor/mwi/lib/tools/edit.d.ts +3 -3
  51. package/vendor/mwi/lib/tools/edit.js +14 -15
  52. package/vendor/mwi/lib/tools/read.js +1 -1
  53. package/vendor/mwi/lib/tools/session.js +13 -9
  54. package/vendor/optix/templates/arya-optix-ipc/project/AryaNewHMIProject_IPC.optix +81 -81
  55. package/vendor/optix/templates/arya-optix-ipc/project/AryaNewHMIProject_IPC.optix.design +38 -38
  56. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Alarms/Alarms.yaml +3 -3
  57. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/AryaNewHMIProject_IPC.yaml +67 -67
  58. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/CommDrivers/CommDrivers.yaml +2 -2
  59. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Converters/Converters.yaml +2 -2
  60. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/DataStores/DataStores.yaml +2 -2
  61. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Loggers/Loggers.yaml +2 -2
  62. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/MQTT/MQTT.yaml +2 -2
  63. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Model/Model.yaml +2 -2
  64. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/NetLogic/NetLogic.yaml +26 -26
  65. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/OPC-UA/OPC-UA.yaml +2 -2
  66. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Recipes/Recipes.yaml +2 -2
  67. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Reports/Reports.yaml +2 -2
  68. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Retentivity/Retentivity.yaml +57 -57
  69. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Groups/Groups.yaml +3 -3
  70. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Roles/Roles.yaml +3 -3
  71. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Security.yaml +7 -7
  72. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Users/Users.yaml +3 -3
  73. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/System/System.yaml +2 -2
  74. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Translations/Translations.yaml +16 -16
  75. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/UI/Keyboards/Keyboards.yaml +2 -2
  76. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/UI/Screens/Screens.yaml +2 -2
  77. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/UI/UI.yaml +250 -250
  78. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/.vscode/launch.json +18 -18
  79. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.code-workspace +9 -9
  80. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.csproj +19 -19
  81. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.references +172 -172
  82. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.sln +21 -21
  83. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/Private/TypeConstants.cs +20 -20
  84. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/Private/UITypeDefinitions.cs +11 -11
  85. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/StudioMCPBridge.cs +4340 -4340
  86. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/UserDefinedModule.xml +26 -26
  87. package/vendor/optix/templates/arya-optix-panel/project/AryaNewHMIProject_OptixPanel.optix +97 -97
  88. package/vendor/optix/templates/arya-optix-panel/project/AryaNewHMIProject_OptixPanel.optix.design +38 -38
  89. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Alarms/Alarms.yaml +3 -3
  90. package/vendor/optix/templates/arya-optix-panel/project/Nodes/AryaNewHMIProject_OptixPanel.yaml +67 -67
  91. package/vendor/optix/templates/arya-optix-panel/project/Nodes/CommDrivers/CommDrivers.yaml +2 -2
  92. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Converters/Converters.yaml +2 -2
  93. package/vendor/optix/templates/arya-optix-panel/project/Nodes/DataStores/DataStores.yaml +2 -2
  94. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Loggers/Loggers.yaml +2 -2
  95. package/vendor/optix/templates/arya-optix-panel/project/Nodes/MQTT/MQTT.yaml +2 -2
  96. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Model/Model.yaml +2 -2
  97. package/vendor/optix/templates/arya-optix-panel/project/Nodes/NetLogic/NetLogic.yaml +26 -26
  98. package/vendor/optix/templates/arya-optix-panel/project/Nodes/OPC-UA/OPC-UA.yaml +2 -2
  99. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Recipes/Recipes.yaml +2 -2
  100. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Reports/Reports.yaml +2 -2
  101. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Retentivity/Retentivity.yaml +57 -57
  102. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Groups/Groups.yaml +3 -3
  103. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Roles/Roles.yaml +3 -3
  104. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Security.yaml +7 -7
  105. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Users/Users.yaml +3 -3
  106. package/vendor/optix/templates/arya-optix-panel/project/Nodes/System/System.yaml +444 -444
  107. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Translations/Translations.yaml +81 -81
  108. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/Keyboards/Keyboards.yaml +2 -2
  109. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/Screens/Screens.yaml +2 -2
  110. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/DeviceSettingsWidget/DeviceSettingsWidget.yaml +163 -163
  111. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/DeviceSettingsWidget/DeviceSettingsWidgetComponents/DeviceSettingsWidgetComponents.yaml +1663 -1663
  112. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/FactoryTalkRemoteAccessWidget/FTRemoteAccessWidgetComponents/FTRemoteAccessWidgetComponents.yaml +2471 -2471
  113. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/FactoryTalkRemoteAccessWidget/FactoryTalkRemoteAccessWidget.yaml +218 -218
  114. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/NetworkSettingsWidget/NetworkSettingsWidget.yaml +524 -524
  115. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/NetworkSettingsWidget/NetworkSettingsWidgetComponents/NetworkSettingsWidgetComponents.yaml +690 -690
  116. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/SettingsWidgets.yaml +1265 -1265
  117. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/UI.yaml +252 -252
  118. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/.vscode/launch.json +18 -18
  119. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/ApplicationNameLogic.cs +19 -19
  120. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.code-workspace +9 -9
  121. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.csproj +19 -19
  122. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.references +172 -172
  123. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.sln +21 -21
  124. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/ConnectionSwitchLogic.cs +74 -74
  125. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/DateAndTimeWidgetLogic.cs +420 -420
  126. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/DeviceSettingsWidgetLogic.cs +34 -34
  127. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/FTOptixStudioVersionLogic.cs +47 -47
  128. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/FTRemoteAccessWidgetSetupLogic.cs +153 -153
  129. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/IncomingConnectionApprovalLogic.cs +118 -118
  130. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/IncomingConnectionReceiverLogic.cs +166 -166
  131. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkConfiguratorEditModelsLogic.cs +56 -56
  132. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkInterfaceLogic.cs +138 -138
  133. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkInterfacesEditModelReaderLogic.cs +87 -87
  134. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkInterfacesEditModelToSystemWriterLogic.cs +139 -139
  135. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkSettingsLogic.cs +168 -168
  136. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/Private/FTRemoteAccessWidgetDataObject.cs +106 -106
  137. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/Private/TypeConstants.cs +37 -37
  138. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/Private/UITypeDefinitions.cs +91 -91
  139. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/RequestAssistanceSwitchLogic.cs +93 -93
  140. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/StudioMCPBridge.cs +4340 -4340
  141. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/SystemToNetworkInterfacesEditModelWriterLogic.cs +77 -77
  142. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/UserDefinedModule.xml +111 -111
  143. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/WarningIcon.svg +4 -4
  144. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/block_interfaces.cpython-312.pyc +0 -0
  145. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/cfb.cpython-312.pyc +0 -0
  146. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/datatypes.cpython-312.pyc +0 -0
  147. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/declarations.cpython-312.pyc +0 -0
  148. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/graphical_listing.cpython-312.pyc +0 -0
  149. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/grid.cpython-312.pyc +0 -0
  150. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/knowledge.cpython-312.pyc +0 -0
  151. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/mwt_bind.cpython-312.pyc +0 -0
  152. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/navigation.cpython-312.pyc +0 -0
  153. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/program_checks.cpython-312.pyc +0 -0
  154. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/project.cpython-312.pyc +0 -0
  155. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/structure.cpython-312.pyc +0 -0
  156. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/task_bindings.cpython-312.pyc +0 -0
  157. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/tasks.cpython-312.pyc +0 -0
  158. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/tree.cpython-312.pyc +0 -0
  159. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/validation.cpython-312.pyc +0 -0
  160. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/variable_edit.cpython-312.pyc +0 -0
  161. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/variables.cpython-312.pyc +0 -0
  162. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/workflow.cpython-312.pyc +0 -0
@@ -1,420 +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
- }
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
+ }