@aryacode/dsh-engineering 0.4.7 → 0.4.20

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 (160) hide show
  1. package/CHANGELOG.md +178 -0
  2. package/README.md +34 -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/l5x/studio-bridge/NuGet.Config +1 -1
  12. package/vendor/mwi/README.md +39 -18
  13. package/vendor/mwi/SKILL.md +26 -20
  14. package/vendor/mwi/bridge/mw_bridge.ps1 +2763 -2763
  15. package/vendor/mwi/bridge/sdk-interop-importer.cs +30 -30
  16. package/vendor/mwi/bridge/sdk-variable-reader.cs +22 -22
  17. package/vendor/mwi/code/engine/motionworks_iec_mcp/build.py +339 -339
  18. package/vendor/mwi/code/engine/motionworks_iec_mcp/cfb.py +765 -765
  19. package/vendor/mwi/code/engine/motionworks_iec_mcp/declarations.py +399 -399
  20. package/vendor/mwi/code/engine/motionworks_iec_mcp/ide.py +313 -313
  21. package/vendor/mwi/code/engine/motionworks_iec_mcp/manuals.py +520 -520
  22. package/vendor/mwi/code/engine/motionworks_iec_mcp/mwt_bind.py +133 -133
  23. package/vendor/mwi/code/engine/motionworks_iec_mcp/reference_data/catalog.json +672 -672
  24. package/vendor/mwi/code/engine/motionworks_iec_mcp/reference_data/patterns.json +86 -86
  25. package/vendor/mwi/code/engine/motionworks_iec_mcp/restore.py +208 -208
  26. package/vendor/mwi/code/engine/motionworks_iec_mcp/staging.py +128 -128
  27. package/vendor/mwi/code/engine/motionworks_iec_mcp/stlint.py +673 -673
  28. package/vendor/mwi/code/engine/motionworks_iec_mcp/tree_writer.py +790 -790
  29. package/vendor/mwi/code/engine/motionworks_iec_mcp/writer.py +642 -642
  30. package/vendor/mwi/lib/core/code-engine.d.ts +13 -0
  31. package/vendor/mwi/lib/core/code-engine.js +18 -1
  32. package/vendor/mwi/lib/edit.d.ts +1 -1
  33. package/vendor/mwi/lib/edit.js +1 -1
  34. package/vendor/mwi/lib/read/service.js +8 -1
  35. package/vendor/mwi/lib/session/backup.d.ts +55 -0
  36. package/vendor/mwi/lib/session/backup.js +232 -0
  37. package/vendor/mwi/lib/session/project.d.ts +4 -1
  38. package/vendor/mwi/lib/session/project.js +13 -2
  39. package/vendor/mwi/lib/session/service.d.ts +13 -6
  40. package/vendor/mwi/lib/session/service.js +127 -36
  41. package/vendor/mwi/lib/session/workspace.d.ts +10 -0
  42. package/vendor/mwi/lib/session/workspace.js +53 -3
  43. package/vendor/mwi/lib/skill.d.ts +2 -2
  44. package/vendor/mwi/lib/skill.js +2 -2
  45. package/vendor/mwi/lib/tools/edit.d.ts +3 -3
  46. package/vendor/mwi/lib/tools/edit.js +14 -15
  47. package/vendor/mwi/lib/tools/read.js +1 -1
  48. package/vendor/mwi/lib/tools/session.js +13 -9
  49. package/vendor/optix/templates/arya-optix-ipc/project/AryaNewHMIProject_IPC.optix +81 -81
  50. package/vendor/optix/templates/arya-optix-ipc/project/AryaNewHMIProject_IPC.optix.design +38 -38
  51. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Alarms/Alarms.yaml +3 -3
  52. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/AryaNewHMIProject_IPC.yaml +67 -67
  53. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/CommDrivers/CommDrivers.yaml +2 -2
  54. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Converters/Converters.yaml +2 -2
  55. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/DataStores/DataStores.yaml +2 -2
  56. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Loggers/Loggers.yaml +2 -2
  57. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/MQTT/MQTT.yaml +2 -2
  58. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Model/Model.yaml +2 -2
  59. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/NetLogic/NetLogic.yaml +26 -26
  60. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/OPC-UA/OPC-UA.yaml +2 -2
  61. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Recipes/Recipes.yaml +2 -2
  62. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Reports/Reports.yaml +2 -2
  63. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Retentivity/Retentivity.yaml +57 -57
  64. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Groups/Groups.yaml +3 -3
  65. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Roles/Roles.yaml +3 -3
  66. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Security.yaml +7 -7
  67. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Security/Users/Users.yaml +3 -3
  68. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/System/System.yaml +2 -2
  69. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/Translations/Translations.yaml +16 -16
  70. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/UI/Keyboards/Keyboards.yaml +2 -2
  71. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/UI/Screens/Screens.yaml +2 -2
  72. package/vendor/optix/templates/arya-optix-ipc/project/Nodes/UI/UI.yaml +250 -250
  73. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/.vscode/launch.json +18 -18
  74. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.code-workspace +9 -9
  75. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.csproj +19 -19
  76. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.references +172 -172
  77. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/AryaNewHMIProject_IPC.sln +21 -21
  78. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/Private/TypeConstants.cs +20 -20
  79. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/Private/UITypeDefinitions.cs +11 -11
  80. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/NetSolution/StudioMCPBridge.cs +4340 -4340
  81. package/vendor/optix/templates/arya-optix-ipc/project/ProjectFiles/UserDefinedModule.xml +26 -26
  82. package/vendor/optix/templates/arya-optix-panel/project/AryaNewHMIProject_OptixPanel.optix +97 -97
  83. package/vendor/optix/templates/arya-optix-panel/project/AryaNewHMIProject_OptixPanel.optix.design +38 -38
  84. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Alarms/Alarms.yaml +3 -3
  85. package/vendor/optix/templates/arya-optix-panel/project/Nodes/AryaNewHMIProject_OptixPanel.yaml +67 -67
  86. package/vendor/optix/templates/arya-optix-panel/project/Nodes/CommDrivers/CommDrivers.yaml +2 -2
  87. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Converters/Converters.yaml +2 -2
  88. package/vendor/optix/templates/arya-optix-panel/project/Nodes/DataStores/DataStores.yaml +2 -2
  89. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Loggers/Loggers.yaml +2 -2
  90. package/vendor/optix/templates/arya-optix-panel/project/Nodes/MQTT/MQTT.yaml +2 -2
  91. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Model/Model.yaml +2 -2
  92. package/vendor/optix/templates/arya-optix-panel/project/Nodes/NetLogic/NetLogic.yaml +26 -26
  93. package/vendor/optix/templates/arya-optix-panel/project/Nodes/OPC-UA/OPC-UA.yaml +2 -2
  94. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Recipes/Recipes.yaml +2 -2
  95. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Reports/Reports.yaml +2 -2
  96. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Retentivity/Retentivity.yaml +57 -57
  97. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Groups/Groups.yaml +3 -3
  98. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Roles/Roles.yaml +3 -3
  99. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Security.yaml +7 -7
  100. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Security/Users/Users.yaml +3 -3
  101. package/vendor/optix/templates/arya-optix-panel/project/Nodes/System/System.yaml +444 -444
  102. package/vendor/optix/templates/arya-optix-panel/project/Nodes/Translations/Translations.yaml +81 -81
  103. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/Keyboards/Keyboards.yaml +2 -2
  104. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/Screens/Screens.yaml +2 -2
  105. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/DeviceSettingsWidget/DeviceSettingsWidget.yaml +163 -163
  106. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/DeviceSettingsWidget/DeviceSettingsWidgetComponents/DeviceSettingsWidgetComponents.yaml +1663 -1663
  107. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/FactoryTalkRemoteAccessWidget/FTRemoteAccessWidgetComponents/FTRemoteAccessWidgetComponents.yaml +2471 -2471
  108. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/FactoryTalkRemoteAccessWidget/FactoryTalkRemoteAccessWidget.yaml +218 -218
  109. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/NetworkSettingsWidget/NetworkSettingsWidget.yaml +524 -524
  110. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/NetworkSettingsWidget/NetworkSettingsWidgetComponents/NetworkSettingsWidgetComponents.yaml +690 -690
  111. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/SettingsWidgets/SettingsWidgets.yaml +1265 -1265
  112. package/vendor/optix/templates/arya-optix-panel/project/Nodes/UI/UI.yaml +252 -252
  113. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/.vscode/launch.json +18 -18
  114. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/ApplicationNameLogic.cs +19 -19
  115. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.code-workspace +9 -9
  116. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.csproj +19 -19
  117. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.references +172 -172
  118. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/AryaNewHMIProject_OptixPanel.sln +21 -21
  119. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/ConnectionSwitchLogic.cs +74 -74
  120. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/DateAndTimeWidgetLogic.cs +420 -420
  121. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/DeviceSettingsWidgetLogic.cs +34 -34
  122. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/FTOptixStudioVersionLogic.cs +47 -47
  123. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/FTRemoteAccessWidgetSetupLogic.cs +153 -153
  124. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/IncomingConnectionApprovalLogic.cs +118 -118
  125. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/IncomingConnectionReceiverLogic.cs +166 -166
  126. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkConfiguratorEditModelsLogic.cs +56 -56
  127. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkInterfaceLogic.cs +138 -138
  128. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkInterfacesEditModelReaderLogic.cs +87 -87
  129. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkInterfacesEditModelToSystemWriterLogic.cs +139 -139
  130. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/NetworkSettingsLogic.cs +168 -168
  131. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/Private/FTRemoteAccessWidgetDataObject.cs +106 -106
  132. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/Private/TypeConstants.cs +37 -37
  133. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/Private/UITypeDefinitions.cs +91 -91
  134. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/RequestAssistanceSwitchLogic.cs +93 -93
  135. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/StudioMCPBridge.cs +4340 -4340
  136. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/NetSolution/SystemToNetworkInterfacesEditModelWriterLogic.cs +77 -77
  137. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/UserDefinedModule.xml +111 -111
  138. package/vendor/optix/templates/arya-optix-panel/project/ProjectFiles/WarningIcon.svg +4 -4
  139. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/__init__.cpython-312.pyc +0 -0
  140. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/block_interfaces.cpython-312.pyc +0 -0
  141. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/cfb.cpython-312.pyc +0 -0
  142. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/datatypes.cpython-312.pyc +0 -0
  143. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/declarations.cpython-312.pyc +0 -0
  144. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/errors.cpython-312.pyc +0 -0
  145. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/graphical_listing.cpython-312.pyc +0 -0
  146. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/grid.cpython-312.pyc +0 -0
  147. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/knowledge.cpython-312.pyc +0 -0
  148. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/mwt_bind.cpython-312.pyc +0 -0
  149. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/navigation.cpython-312.pyc +0 -0
  150. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/program_checks.cpython-312.pyc +0 -0
  151. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/project.cpython-312.pyc +0 -0
  152. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/staging.cpython-312.pyc +0 -0
  153. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/structure.cpython-312.pyc +0 -0
  154. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/task_bindings.cpython-312.pyc +0 -0
  155. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/tasks.cpython-312.pyc +0 -0
  156. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/tree.cpython-312.pyc +0 -0
  157. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/validation.cpython-312.pyc +0 -0
  158. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/variable_edit.cpython-312.pyc +0 -0
  159. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/variables.cpython-312.pyc +0 -0
  160. package/vendor/mwi/code/engine/motionworks_iec_mcp/__pycache__/workflow.cpython-312.pyc +0 -0
@@ -1,139 +1,139 @@
1
- #region Using directives
2
- using UAManagedCore;
3
- using FTOptix.System;
4
- using FTOptix.NetLogic;
5
- using System.Collections.Generic;
6
- using System.Text.RegularExpressions;
7
- using FTOptix.UI;
8
- using FTOptix.SerialPort;
9
- #endregion
10
-
11
- public class NetworkInterfacesEditModelToSystemWriterLogic : BaseNetLogic
12
- {
13
- public NetworkInterfacesEditModelToSystemWriterLogic(IUAObject editModelNetworkInterfacesObject)
14
- {
15
- editModelNetworkInterfacesReader = new NetworkInterfacesEditModelReaderLogic(editModelNetworkInterfacesObject);
16
- }
17
-
18
- public NetworkInterfacesEditModelToSystemWriterLogic() {}
19
-
20
- public void WriteEditModelToSystemModel(List<NetworkInterface> networkInterfaces)
21
- {
22
- foreach (NetworkInterface networkInterface in networkInterfaces)
23
- {
24
- string interfaceName = networkInterface.BrowseName;
25
- if (string.IsNullOrEmpty(interfaceName))
26
- continue;
27
-
28
- var dhcpEditModel = editModelNetworkInterfacesReader.GetDhcpVariable(interfaceName).Value;
29
- if (dhcpEditModel)
30
- {
31
- networkInterface.DHCPClientEnabled = dhcpEditModel;
32
- Log.Info(NetworkSettingsLogic.LOGGING_CATEGORY, $"DHCP is enabled for network interface {interfaceName}. The rest of the configuration will be ignored.");
33
- continue;
34
- }
35
-
36
- var ipAddressVariable = editModelNetworkInterfacesReader.GetIPAddressVariable(interfaceName);
37
- var maskVariable = editModelNetworkInterfacesReader.GetMaskVariable(interfaceName);
38
- var dns1Variable = editModelNetworkInterfacesReader.GetDNS1Variable(interfaceName);
39
- var dns2Variable = editModelNetworkInterfacesReader.GetDNS2Variable(interfaceName);
40
- var defaultGatewayVariable = editModelNetworkInterfacesReader.GetDefaultGatewayVariable(interfaceName);
41
-
42
- EditModelNetworkInterface editModelNetworkInterface = new()
43
- {
44
- interfaceName = interfaceName,
45
- dhcpEnabled = false,
46
- ipAddress = ipAddressVariable.Value,
47
- mask = maskVariable.Value,
48
- dns1 = dns1Variable.Value,
49
- dns2 = dns2Variable.Value,
50
- defaultGateway = defaultGatewayVariable.Value
51
- };
52
-
53
- if (!WriteStandardPropertiesIntoSystemModel(editModelNetworkInterface, networkInterface))
54
- continue;
55
- }
56
- }
57
-
58
- private static bool WriteStandardPropertiesIntoSystemModel(EditModelNetworkInterface editModelNetworkInterface, NetworkInterface networkInterface)
59
- {
60
- var isStandardConfigurationValid = IPAddressValidator.IsStandardConfigurationValid(editModelNetworkInterface);
61
- if (!isStandardConfigurationValid)
62
- {
63
- Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"Configuration for network interface {editModelNetworkInterface.interfaceName} is not valid. The last valid configuration will be used.");
64
- return false;
65
- }
66
-
67
- networkInterface.DHCPClientEnabled = editModelNetworkInterface.dhcpEnabled;
68
- networkInterface.IPAddress = editModelNetworkInterface.ipAddress;
69
- networkInterface.IPAddressVariable.Mask = editModelNetworkInterface.mask;
70
- networkInterface.DNS1 = editModelNetworkInterface.dns1;
71
- networkInterface.DNS2 = editModelNetworkInterface.dns2;
72
- networkInterface.DefaultGateway = editModelNetworkInterface.defaultGateway;
73
-
74
- return true;
75
- }
76
-
77
- private struct EditModelNetworkInterface
78
- {
79
- public string interfaceName;
80
- public bool dhcpEnabled;
81
- public string ipAddress;
82
- public string mask;
83
- public string dns1;
84
- public string dns2;
85
- public string defaultGateway;
86
- };
87
-
88
- readonly private NetworkInterfacesEditModelReaderLogic editModelNetworkInterfacesReader;
89
-
90
- private class IPAddressValidator
91
- {
92
- public static bool IsStandardConfigurationValid(EditModelNetworkInterface editModelNetworkInterface)
93
- {
94
- bool isValid = true;
95
- var interfaceName = editModelNetworkInterface.interfaceName;
96
- var ipAddressString = editModelNetworkInterface.ipAddress;
97
- if (!IsValidIPAddress(ipAddressString))
98
- {
99
- Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"IP address {ipAddressString} for network interface {interfaceName} is invalid.");
100
- isValid = false;
101
- }
102
-
103
- var maskString = editModelNetworkInterface.mask;
104
- if (!IsValidIPAddress(maskString))
105
- {
106
- Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"Mask {maskString} for network interface {interfaceName} is invalid.");
107
- isValid = false;
108
- }
109
-
110
- var dns1String = editModelNetworkInterface.dns1;
111
- if (!string.IsNullOrEmpty(dns1String) && !IsValidIPAddress(dns1String))
112
- {
113
- Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"DNS1 {dns1String} for network interface {interfaceName} is invalid.");
114
- isValid = false;
115
- }
116
-
117
- var dns2String = editModelNetworkInterface.dns2;
118
- if (!string.IsNullOrEmpty(dns2String) && !IsValidIPAddress(dns2String))
119
- {
120
- Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"DNS2 {dns2String} for network interface {interfaceName} is invalid.");
121
- isValid = false;
122
- }
123
-
124
- var defaultGatewayString = editModelNetworkInterface.defaultGateway;
125
- if (!string.IsNullOrEmpty(defaultGatewayString) && !IsValidIPAddress(defaultGatewayString))
126
- {
127
- Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"DefaultGateway {defaultGatewayString} for network interface {interfaceName} is invalid.");
128
- isValid = false;
129
- }
130
-
131
- return isValid;
132
- }
133
-
134
- private static bool IsValidIPAddress(string ipAddress)
135
- {
136
- return Regex.IsMatch(ipAddress, "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
137
- }
138
- }
139
- }
1
+ #region Using directives
2
+ using UAManagedCore;
3
+ using FTOptix.System;
4
+ using FTOptix.NetLogic;
5
+ using System.Collections.Generic;
6
+ using System.Text.RegularExpressions;
7
+ using FTOptix.UI;
8
+ using FTOptix.SerialPort;
9
+ #endregion
10
+
11
+ public class NetworkInterfacesEditModelToSystemWriterLogic : BaseNetLogic
12
+ {
13
+ public NetworkInterfacesEditModelToSystemWriterLogic(IUAObject editModelNetworkInterfacesObject)
14
+ {
15
+ editModelNetworkInterfacesReader = new NetworkInterfacesEditModelReaderLogic(editModelNetworkInterfacesObject);
16
+ }
17
+
18
+ public NetworkInterfacesEditModelToSystemWriterLogic() {}
19
+
20
+ public void WriteEditModelToSystemModel(List<NetworkInterface> networkInterfaces)
21
+ {
22
+ foreach (NetworkInterface networkInterface in networkInterfaces)
23
+ {
24
+ string interfaceName = networkInterface.BrowseName;
25
+ if (string.IsNullOrEmpty(interfaceName))
26
+ continue;
27
+
28
+ var dhcpEditModel = editModelNetworkInterfacesReader.GetDhcpVariable(interfaceName).Value;
29
+ if (dhcpEditModel)
30
+ {
31
+ networkInterface.DHCPClientEnabled = dhcpEditModel;
32
+ Log.Info(NetworkSettingsLogic.LOGGING_CATEGORY, $"DHCP is enabled for network interface {interfaceName}. The rest of the configuration will be ignored.");
33
+ continue;
34
+ }
35
+
36
+ var ipAddressVariable = editModelNetworkInterfacesReader.GetIPAddressVariable(interfaceName);
37
+ var maskVariable = editModelNetworkInterfacesReader.GetMaskVariable(interfaceName);
38
+ var dns1Variable = editModelNetworkInterfacesReader.GetDNS1Variable(interfaceName);
39
+ var dns2Variable = editModelNetworkInterfacesReader.GetDNS2Variable(interfaceName);
40
+ var defaultGatewayVariable = editModelNetworkInterfacesReader.GetDefaultGatewayVariable(interfaceName);
41
+
42
+ EditModelNetworkInterface editModelNetworkInterface = new()
43
+ {
44
+ interfaceName = interfaceName,
45
+ dhcpEnabled = false,
46
+ ipAddress = ipAddressVariable.Value,
47
+ mask = maskVariable.Value,
48
+ dns1 = dns1Variable.Value,
49
+ dns2 = dns2Variable.Value,
50
+ defaultGateway = defaultGatewayVariable.Value
51
+ };
52
+
53
+ if (!WriteStandardPropertiesIntoSystemModel(editModelNetworkInterface, networkInterface))
54
+ continue;
55
+ }
56
+ }
57
+
58
+ private static bool WriteStandardPropertiesIntoSystemModel(EditModelNetworkInterface editModelNetworkInterface, NetworkInterface networkInterface)
59
+ {
60
+ var isStandardConfigurationValid = IPAddressValidator.IsStandardConfigurationValid(editModelNetworkInterface);
61
+ if (!isStandardConfigurationValid)
62
+ {
63
+ Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"Configuration for network interface {editModelNetworkInterface.interfaceName} is not valid. The last valid configuration will be used.");
64
+ return false;
65
+ }
66
+
67
+ networkInterface.DHCPClientEnabled = editModelNetworkInterface.dhcpEnabled;
68
+ networkInterface.IPAddress = editModelNetworkInterface.ipAddress;
69
+ networkInterface.IPAddressVariable.Mask = editModelNetworkInterface.mask;
70
+ networkInterface.DNS1 = editModelNetworkInterface.dns1;
71
+ networkInterface.DNS2 = editModelNetworkInterface.dns2;
72
+ networkInterface.DefaultGateway = editModelNetworkInterface.defaultGateway;
73
+
74
+ return true;
75
+ }
76
+
77
+ private struct EditModelNetworkInterface
78
+ {
79
+ public string interfaceName;
80
+ public bool dhcpEnabled;
81
+ public string ipAddress;
82
+ public string mask;
83
+ public string dns1;
84
+ public string dns2;
85
+ public string defaultGateway;
86
+ };
87
+
88
+ readonly private NetworkInterfacesEditModelReaderLogic editModelNetworkInterfacesReader;
89
+
90
+ private class IPAddressValidator
91
+ {
92
+ public static bool IsStandardConfigurationValid(EditModelNetworkInterface editModelNetworkInterface)
93
+ {
94
+ bool isValid = true;
95
+ var interfaceName = editModelNetworkInterface.interfaceName;
96
+ var ipAddressString = editModelNetworkInterface.ipAddress;
97
+ if (!IsValidIPAddress(ipAddressString))
98
+ {
99
+ Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"IP address {ipAddressString} for network interface {interfaceName} is invalid.");
100
+ isValid = false;
101
+ }
102
+
103
+ var maskString = editModelNetworkInterface.mask;
104
+ if (!IsValidIPAddress(maskString))
105
+ {
106
+ Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"Mask {maskString} for network interface {interfaceName} is invalid.");
107
+ isValid = false;
108
+ }
109
+
110
+ var dns1String = editModelNetworkInterface.dns1;
111
+ if (!string.IsNullOrEmpty(dns1String) && !IsValidIPAddress(dns1String))
112
+ {
113
+ Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"DNS1 {dns1String} for network interface {interfaceName} is invalid.");
114
+ isValid = false;
115
+ }
116
+
117
+ var dns2String = editModelNetworkInterface.dns2;
118
+ if (!string.IsNullOrEmpty(dns2String) && !IsValidIPAddress(dns2String))
119
+ {
120
+ Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"DNS2 {dns2String} for network interface {interfaceName} is invalid.");
121
+ isValid = false;
122
+ }
123
+
124
+ var defaultGatewayString = editModelNetworkInterface.defaultGateway;
125
+ if (!string.IsNullOrEmpty(defaultGatewayString) && !IsValidIPAddress(defaultGatewayString))
126
+ {
127
+ Log.Error(NetworkSettingsLogic.LOGGING_CATEGORY, $"DefaultGateway {defaultGatewayString} for network interface {interfaceName} is invalid.");
128
+ isValid = false;
129
+ }
130
+
131
+ return isValid;
132
+ }
133
+
134
+ private static bool IsValidIPAddress(string ipAddress)
135
+ {
136
+ return Regex.IsMatch(ipAddress, "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
137
+ }
138
+ }
139
+ }
@@ -1,168 +1,168 @@
1
- #region Using directives
2
- using System;
3
- using UAManagedCore;
4
- using FTOptix.HMIProject;
5
- using FTOptix.NetLogic;
6
- using FTOptix.UI;
7
- using System.Linq;
8
- using FTOptix.SerialPort;
9
- #endregion
10
-
11
- public class NetworkSettingsLogic : BaseNetLogic
12
- {
13
- public const string LOGGING_CATEGORY = nameof(NetworkSettingsLogic);
14
-
15
- public override void Start()
16
- {
17
- IUAVariable systemNodePointer = Owner.GetVariable("SystemNode");
18
- if (systemNodePointer == null)
19
- {
20
- HandleInvalidConfiguration();
21
- Log.Error(LOGGING_CATEGORY, "SystemNode NodePointer not found.");
22
- return;
23
- }
24
-
25
- NodeId systemNodeId = (NodeId)systemNodePointer.Value;
26
- if (systemNodeId == null || systemNodeId == NodeId.Empty)
27
- {
28
- HandleInvalidConfiguration();
29
- Log.Error(LOGGING_CATEGORY, "SystemNode is not defined.");
30
- return;
31
- }
32
-
33
- systemNode = InformationModel.Get(systemNodeId) as FTOptix.System.System;
34
-
35
- if (systemNode == null || systemNode.NetworkInterfaces.Count < 1)
36
- HandleInvalidConfiguration();
37
-
38
- if (systemNode == null)
39
- {
40
- Log.Error(LOGGING_CATEGORY, "SystemNode not found.");
41
- return;
42
- }
43
-
44
- networkConfiguratorEditModels = Owner.GetObject("NetworkConfiguratorEditModels");
45
- if (networkConfiguratorEditModels == null)
46
- throw new CoreConfigurationException("NetworkConfiguratorEditModels object not found");
47
-
48
- NetworkConfiguratorEditModelsLogic.CreateEditModels(systemNode, networkConfiguratorEditModels);
49
- var editModelNetworkInterfaces = NetworkConfiguratorEditModelsLogic.GetNetworkInterfacesEditModel(networkConfiguratorEditModels);
50
-
51
- networkInterfacesEditModelToSystemWriter = new NetworkInterfacesEditModelToSystemWriterLogic(editModelNetworkInterfaces);
52
-
53
- navPanel = Owner.Get<NavigationPanel>("NavigationPanel1");
54
- if (navPanel == null)
55
- throw new CoreConfigurationException("NavigationPanel1 object not found");
56
-
57
- systemNode.RebootRequiredVariable.VariableChange += RebootRequiredVariable_VariableChange;
58
- EnableControlsForRebootRequired(systemNode.RebootRequired);
59
-
60
- navPanel.CurrentPanelVariable.VariableChange += CurrentPanelVariable_VariableChange;
61
-
62
- NodeId nodeId = (NodeId)navPanel.CurrentPanel;
63
- if (nodeId != null && nodeId != NodeId.Empty)
64
- HandleNetworkInterfacePanel(nodeId);
65
- }
66
-
67
- public override void Stop()
68
- {
69
- if (networkConfiguratorEditModels != null)
70
- NetworkConfiguratorEditModelsLogic.DeleteEditModels(networkConfiguratorEditModels);
71
-
72
- if (systemNode != null)
73
- systemNode.RebootRequiredVariable.VariableChange -= RebootRequiredVariable_VariableChange;
74
-
75
- if (navPanel != null)
76
- navPanel.CurrentPanelVariable.VariableChange -= CurrentPanelVariable_VariableChange;
77
-
78
- systemNode = null;
79
- networkConfiguratorEditModels = null;
80
- networkInterfacesEditModelToSystemWriter = null;
81
- networkInterfaceLogic = null;
82
- navPanel = null;
83
- }
84
-
85
- [ExportMethod]
86
- public void ApplyNetworkConfiguration()
87
- {
88
- try
89
- {
90
- networkInterfacesEditModelToSystemWriter.WriteEditModelToSystemModel(systemNode.NetworkInterfaces.ToList());
91
- }
92
- catch (Exception ex)
93
- {
94
- Log.Error(LOGGING_CATEGORY, $"Failed to apply network configuration: {ex.Message}");
95
- }
96
- }
97
-
98
- [ExportMethod]
99
- public void Reboot()
100
- {
101
- if (systemNode == null)
102
- {
103
- Log.Error(LOGGING_CATEGORY, "SystemNode reference not defined. Reboot failed.");
104
- return;
105
- }
106
-
107
- systemNode.Reboot();
108
- }
109
-
110
- private void CurrentPanelVariable_VariableChange(object sender, VariableChangeEventArgs e)
111
- {
112
- HandleNetworkInterfacePanel((NodeId)e.NewValue.Value);
113
- }
114
-
115
- private void RebootRequiredVariable_VariableChange(object sender, VariableChangeEventArgs e)
116
- {
117
- EnableControlsForRebootRequired((bool)e.NewValue.Value);
118
- }
119
-
120
- private void HandleNetworkInterfacePanel(NodeId nodeId)
121
- {
122
- if (nodeId == null || nodeId == NodeId.Empty)
123
- return;
124
-
125
- IUANode node = InformationModel.Get(nodeId);
126
-
127
- networkInterfaceLogic = new NetworkInterfaceLogic();
128
- networkInterfaceLogic.SetMembers(systemNode, node.BrowseName, networkConfiguratorEditModels, node);
129
- }
130
-
131
- private void EnableControlsForRebootRequired(bool rebootRequired)
132
- {
133
- Button rebootButton = Owner.Get<Button>("BottomBar/RebootButton");
134
- if (rebootButton == null)
135
- throw new CoreConfigurationException("BottomBar/RebootButton object not found");
136
-
137
- rebootButton.Enabled = rebootRequired;
138
-
139
- Image warningIcon = Owner.Get<Image>("BottomBar/WarningImage");
140
- if (warningIcon == null)
141
- throw new CoreConfigurationException("BottomBar/WarningImage object not found");
142
-
143
- warningIcon.Visible = rebootRequired;
144
-
145
- Label messageLabel = Owner.Get<Label>("BottomBar/MessageLabel");
146
- if (messageLabel == null)
147
- throw new CoreConfigurationException("BottomBar/MessageLabel object not found");
148
-
149
- messageLabel.Visible = rebootRequired;
150
- }
151
-
152
- private void HandleInvalidConfiguration()
153
- {
154
- Button applyButton = Owner.Get<Button>("BottomBar/ApplyButton");
155
- if (applyButton != null)
156
- applyButton.Enabled = false;
157
-
158
- EnableControlsForRebootRequired(false);
159
- }
160
-
161
- private FTOptix.System.System systemNode;
162
-
163
- private IUAObject networkConfiguratorEditModels;
164
- private NetworkInterfacesEditModelToSystemWriterLogic networkInterfacesEditModelToSystemWriter;
165
-
166
- private NetworkInterfaceLogic networkInterfaceLogic;
167
- private NavigationPanel navPanel;
168
- }
1
+ #region Using directives
2
+ using System;
3
+ using UAManagedCore;
4
+ using FTOptix.HMIProject;
5
+ using FTOptix.NetLogic;
6
+ using FTOptix.UI;
7
+ using System.Linq;
8
+ using FTOptix.SerialPort;
9
+ #endregion
10
+
11
+ public class NetworkSettingsLogic : BaseNetLogic
12
+ {
13
+ public const string LOGGING_CATEGORY = nameof(NetworkSettingsLogic);
14
+
15
+ public override void Start()
16
+ {
17
+ IUAVariable systemNodePointer = Owner.GetVariable("SystemNode");
18
+ if (systemNodePointer == null)
19
+ {
20
+ HandleInvalidConfiguration();
21
+ Log.Error(LOGGING_CATEGORY, "SystemNode NodePointer not found.");
22
+ return;
23
+ }
24
+
25
+ NodeId systemNodeId = (NodeId)systemNodePointer.Value;
26
+ if (systemNodeId == null || systemNodeId == NodeId.Empty)
27
+ {
28
+ HandleInvalidConfiguration();
29
+ Log.Error(LOGGING_CATEGORY, "SystemNode is not defined.");
30
+ return;
31
+ }
32
+
33
+ systemNode = InformationModel.Get(systemNodeId) as FTOptix.System.System;
34
+
35
+ if (systemNode == null || systemNode.NetworkInterfaces.Count < 1)
36
+ HandleInvalidConfiguration();
37
+
38
+ if (systemNode == null)
39
+ {
40
+ Log.Error(LOGGING_CATEGORY, "SystemNode not found.");
41
+ return;
42
+ }
43
+
44
+ networkConfiguratorEditModels = Owner.GetObject("NetworkConfiguratorEditModels");
45
+ if (networkConfiguratorEditModels == null)
46
+ throw new CoreConfigurationException("NetworkConfiguratorEditModels object not found");
47
+
48
+ NetworkConfiguratorEditModelsLogic.CreateEditModels(systemNode, networkConfiguratorEditModels);
49
+ var editModelNetworkInterfaces = NetworkConfiguratorEditModelsLogic.GetNetworkInterfacesEditModel(networkConfiguratorEditModels);
50
+
51
+ networkInterfacesEditModelToSystemWriter = new NetworkInterfacesEditModelToSystemWriterLogic(editModelNetworkInterfaces);
52
+
53
+ navPanel = Owner.Get<NavigationPanel>("NavigationPanel1");
54
+ if (navPanel == null)
55
+ throw new CoreConfigurationException("NavigationPanel1 object not found");
56
+
57
+ systemNode.RebootRequiredVariable.VariableChange += RebootRequiredVariable_VariableChange;
58
+ EnableControlsForRebootRequired(systemNode.RebootRequired);
59
+
60
+ navPanel.CurrentPanelVariable.VariableChange += CurrentPanelVariable_VariableChange;
61
+
62
+ NodeId nodeId = (NodeId)navPanel.CurrentPanel;
63
+ if (nodeId != null && nodeId != NodeId.Empty)
64
+ HandleNetworkInterfacePanel(nodeId);
65
+ }
66
+
67
+ public override void Stop()
68
+ {
69
+ if (networkConfiguratorEditModels != null)
70
+ NetworkConfiguratorEditModelsLogic.DeleteEditModels(networkConfiguratorEditModels);
71
+
72
+ if (systemNode != null)
73
+ systemNode.RebootRequiredVariable.VariableChange -= RebootRequiredVariable_VariableChange;
74
+
75
+ if (navPanel != null)
76
+ navPanel.CurrentPanelVariable.VariableChange -= CurrentPanelVariable_VariableChange;
77
+
78
+ systemNode = null;
79
+ networkConfiguratorEditModels = null;
80
+ networkInterfacesEditModelToSystemWriter = null;
81
+ networkInterfaceLogic = null;
82
+ navPanel = null;
83
+ }
84
+
85
+ [ExportMethod]
86
+ public void ApplyNetworkConfiguration()
87
+ {
88
+ try
89
+ {
90
+ networkInterfacesEditModelToSystemWriter.WriteEditModelToSystemModel(systemNode.NetworkInterfaces.ToList());
91
+ }
92
+ catch (Exception ex)
93
+ {
94
+ Log.Error(LOGGING_CATEGORY, $"Failed to apply network configuration: {ex.Message}");
95
+ }
96
+ }
97
+
98
+ [ExportMethod]
99
+ public void Reboot()
100
+ {
101
+ if (systemNode == null)
102
+ {
103
+ Log.Error(LOGGING_CATEGORY, "SystemNode reference not defined. Reboot failed.");
104
+ return;
105
+ }
106
+
107
+ systemNode.Reboot();
108
+ }
109
+
110
+ private void CurrentPanelVariable_VariableChange(object sender, VariableChangeEventArgs e)
111
+ {
112
+ HandleNetworkInterfacePanel((NodeId)e.NewValue.Value);
113
+ }
114
+
115
+ private void RebootRequiredVariable_VariableChange(object sender, VariableChangeEventArgs e)
116
+ {
117
+ EnableControlsForRebootRequired((bool)e.NewValue.Value);
118
+ }
119
+
120
+ private void HandleNetworkInterfacePanel(NodeId nodeId)
121
+ {
122
+ if (nodeId == null || nodeId == NodeId.Empty)
123
+ return;
124
+
125
+ IUANode node = InformationModel.Get(nodeId);
126
+
127
+ networkInterfaceLogic = new NetworkInterfaceLogic();
128
+ networkInterfaceLogic.SetMembers(systemNode, node.BrowseName, networkConfiguratorEditModels, node);
129
+ }
130
+
131
+ private void EnableControlsForRebootRequired(bool rebootRequired)
132
+ {
133
+ Button rebootButton = Owner.Get<Button>("BottomBar/RebootButton");
134
+ if (rebootButton == null)
135
+ throw new CoreConfigurationException("BottomBar/RebootButton object not found");
136
+
137
+ rebootButton.Enabled = rebootRequired;
138
+
139
+ Image warningIcon = Owner.Get<Image>("BottomBar/WarningImage");
140
+ if (warningIcon == null)
141
+ throw new CoreConfigurationException("BottomBar/WarningImage object not found");
142
+
143
+ warningIcon.Visible = rebootRequired;
144
+
145
+ Label messageLabel = Owner.Get<Label>("BottomBar/MessageLabel");
146
+ if (messageLabel == null)
147
+ throw new CoreConfigurationException("BottomBar/MessageLabel object not found");
148
+
149
+ messageLabel.Visible = rebootRequired;
150
+ }
151
+
152
+ private void HandleInvalidConfiguration()
153
+ {
154
+ Button applyButton = Owner.Get<Button>("BottomBar/ApplyButton");
155
+ if (applyButton != null)
156
+ applyButton.Enabled = false;
157
+
158
+ EnableControlsForRebootRequired(false);
159
+ }
160
+
161
+ private FTOptix.System.System systemNode;
162
+
163
+ private IUAObject networkConfiguratorEditModels;
164
+ private NetworkInterfacesEditModelToSystemWriterLogic networkInterfacesEditModelToSystemWriter;
165
+
166
+ private NetworkInterfaceLogic networkInterfaceLogic;
167
+ private NavigationPanel navPanel;
168
+ }