@adcops/autocore-react 3.0.40 → 3.3.2

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 (296) hide show
  1. package/additional-docs/AutoCoreTagContext.md +441 -0
  2. package/additional-docs/react_performance_notes.md +94 -0
  3. package/dist/assets/BlocklyLogo.d.ts +1 -0
  4. package/dist/assets/BlocklyLogo.d.ts.map +1 -0
  5. package/dist/assets/Distance.d.ts +1 -0
  6. package/dist/assets/Distance.d.ts.map +1 -0
  7. package/dist/assets/JogLong.d.ts +1 -0
  8. package/dist/assets/JogLong.d.ts.map +1 -0
  9. package/dist/assets/JogMedium.d.ts +1 -0
  10. package/dist/assets/JogMedium.d.ts.map +1 -0
  11. package/dist/assets/JogShort.d.ts +1 -0
  12. package/dist/assets/JogShort.d.ts.map +1 -0
  13. package/dist/assets/PythonLogo.d.ts +1 -0
  14. package/dist/assets/PythonLogo.d.ts.map +1 -0
  15. package/dist/assets/Rotation3D.d.ts +1 -0
  16. package/dist/assets/Rotation3D.d.ts.map +1 -0
  17. package/dist/assets/RotationCcw.d.ts +1 -0
  18. package/dist/assets/RotationCcw.d.ts.map +1 -0
  19. package/dist/assets/RotationCcwA.d.ts +1 -0
  20. package/dist/assets/RotationCcwA.d.ts.map +1 -0
  21. package/dist/assets/RotationCcwB.d.ts +1 -0
  22. package/dist/assets/RotationCcwB.d.ts.map +1 -0
  23. package/dist/assets/RotationCcwC.d.ts +1 -0
  24. package/dist/assets/RotationCcwC.d.ts.map +1 -0
  25. package/dist/assets/RotationCw.d.ts +1 -0
  26. package/dist/assets/RotationCw.d.ts.map +1 -0
  27. package/dist/assets/RotationCwA.d.ts +1 -0
  28. package/dist/assets/RotationCwA.d.ts.map +1 -0
  29. package/dist/assets/RotationCwB.d.ts +1 -0
  30. package/dist/assets/RotationCwB.d.ts.map +1 -0
  31. package/dist/assets/RotationCwC.d.ts +1 -0
  32. package/dist/assets/RotationCwC.d.ts.map +1 -0
  33. package/dist/assets/Run.d.ts +1 -0
  34. package/dist/assets/Run.d.ts.map +1 -0
  35. package/dist/assets/Speed.d.ts +1 -0
  36. package/dist/assets/Speed.d.ts.map +1 -0
  37. package/dist/assets/SpeedFast.d.ts +1 -0
  38. package/dist/assets/SpeedFast.d.ts.map +1 -0
  39. package/dist/assets/SpeedMedium.d.ts +1 -0
  40. package/dist/assets/SpeedMedium.d.ts.map +1 -0
  41. package/dist/assets/SpeedNone.d.ts +1 -0
  42. package/dist/assets/SpeedNone.d.ts.map +1 -0
  43. package/dist/assets/SpeedSlow.d.ts +1 -0
  44. package/dist/assets/SpeedSlow.d.ts.map +1 -0
  45. package/dist/assets/Walk.d.ts +1 -0
  46. package/dist/assets/Walk.d.ts.map +1 -0
  47. package/dist/assets/index.d.ts +1 -0
  48. package/dist/assets/index.d.ts.map +1 -0
  49. package/dist/components/AutoCoreDevPanel.d.ts +144 -0
  50. package/dist/components/AutoCoreDevPanel.d.ts.map +1 -0
  51. package/dist/components/AutoCoreDevPanel.js +1 -0
  52. package/dist/components/BlocklyEditor.d.ts +1 -0
  53. package/dist/components/BlocklyEditor.d.ts.map +1 -0
  54. package/dist/components/BlocklyEditor.js +1 -1
  55. package/dist/components/CodeEditor.d.ts +2 -1
  56. package/dist/components/CodeEditor.d.ts.map +1 -0
  57. package/dist/components/CodeEditor.js +1 -1
  58. package/dist/components/FileList.d.ts +1 -0
  59. package/dist/components/FileList.d.ts.map +1 -0
  60. package/dist/components/FileList.js +1 -1
  61. package/dist/components/FileSelect.d.ts +1 -0
  62. package/dist/components/FileSelect.d.ts.map +1 -0
  63. package/dist/components/FileSelect.js +1 -1
  64. package/dist/components/FitText.d.ts +1 -0
  65. package/dist/components/FitText.d.ts.map +1 -0
  66. package/dist/components/FitText.js +1 -1
  67. package/dist/components/Indicator.d.ts +2 -1
  68. package/dist/components/Indicator.d.ts.map +1 -0
  69. package/dist/components/Indicator.js +1 -1
  70. package/dist/components/IndicatorButton.d.ts +2 -1
  71. package/dist/components/IndicatorButton.d.ts.map +1 -0
  72. package/dist/components/IndicatorButton.js +1 -1
  73. package/dist/components/IndicatorRect.d.ts +2 -1
  74. package/dist/components/IndicatorRect.d.ts.map +1 -0
  75. package/dist/components/JogPanel.d.ts +1 -0
  76. package/dist/components/JogPanel.d.ts.map +1 -0
  77. package/dist/components/Lamp.d.ts +2 -1
  78. package/dist/components/Lamp.d.ts.map +1 -0
  79. package/dist/components/Lamp.js +1 -1
  80. package/dist/components/Osk.d.ts +1 -0
  81. package/dist/components/Osk.d.ts.map +1 -0
  82. package/dist/components/Osk.js +1 -1
  83. package/dist/components/OskDialog.d.ts +1 -0
  84. package/dist/components/OskDialog.d.ts.map +1 -0
  85. package/dist/components/ProgressBarWithValue.d.ts +1 -0
  86. package/dist/components/ProgressBarWithValue.d.ts.map +1 -0
  87. package/dist/components/ProgressBarWithValue.js +1 -1
  88. package/dist/components/TextInput.d.ts +62 -103
  89. package/dist/components/TextInput.d.ts.map +1 -0
  90. package/dist/components/TextInput.js +1 -1
  91. package/dist/components/ToggleGroup.d.ts +2 -1
  92. package/dist/components/ToggleGroup.d.ts.map +1 -0
  93. package/dist/components/ToggleGroup.js +1 -1
  94. package/dist/components/ValueDisplay.d.ts +3 -2
  95. package/dist/components/ValueDisplay.d.ts.map +1 -0
  96. package/dist/components/ValueDisplay.js +1 -1
  97. package/dist/components/ValueIndicator.d.ts +2 -1
  98. package/dist/components/ValueIndicator.d.ts.map +1 -0
  99. package/dist/components/ValueIndicator.js +1 -1
  100. package/dist/components/ValueInput.d.ts +2 -1
  101. package/dist/components/ValueInput.d.ts.map +1 -0
  102. package/dist/components/ValueInput.js +1 -1
  103. package/dist/core/ActionMode.d.ts +1 -0
  104. package/dist/core/ActionMode.d.ts.map +1 -0
  105. package/dist/core/AutoCoreTagContext.d.ts +98 -0
  106. package/dist/core/AutoCoreTagContext.d.ts.map +1 -0
  107. package/dist/core/AutoCoreTagContext.js +1 -0
  108. package/dist/core/AutoCoreTagTypes.d.ts +283 -0
  109. package/dist/core/AutoCoreTagTypes.d.ts.map +1 -0
  110. package/dist/core/AutoCoreTagTypes.js +1 -0
  111. package/dist/core/CoreStreamTypes.d.ts +345 -0
  112. package/dist/core/CoreStreamTypes.d.ts.map +1 -0
  113. package/dist/core/CoreStreamTypes.js +1 -0
  114. package/dist/core/EventEmitterContext.d.ts +113 -202
  115. package/dist/core/EventEmitterContext.d.ts.map +1 -0
  116. package/dist/core/EventEmitterContext.js +1 -1
  117. package/dist/core/IndicatorButtonState.d.ts +1 -0
  118. package/dist/core/IndicatorButtonState.d.ts.map +1 -0
  119. package/dist/core/IndicatorColor.d.ts +1 -0
  120. package/dist/core/IndicatorColor.d.ts.map +1 -0
  121. package/dist/core/MaskPatterns.d.ts +1 -0
  122. package/dist/core/MaskPatterns.d.ts.map +1 -0
  123. package/dist/core/NumerableTypes.d.ts +1 -0
  124. package/dist/core/NumerableTypes.d.ts.map +1 -0
  125. package/dist/core/NumerableTypes.js +1 -1
  126. package/dist/core/PositionContext.d.ts +1 -1
  127. package/dist/core/PositionContext.d.ts.map +1 -0
  128. package/dist/core/UniqueId.d.ts +1 -0
  129. package/dist/core/UniqueId.d.ts.map +1 -0
  130. package/dist/core/ValueSimulator.d.ts +2 -1
  131. package/dist/core/ValueSimulator.d.ts.map +1 -0
  132. package/dist/core/ValueSimulator.js +1 -1
  133. package/dist/core/hoc.d.ts +1 -0
  134. package/dist/core/hoc.d.ts.map +1 -0
  135. package/dist/core/hoc.js +1 -1
  136. package/dist/hooks/adsHooks.d.ts +1 -0
  137. package/dist/hooks/adsHooks.d.ts.map +1 -0
  138. package/dist/hooks/adsHooks.js +1 -1
  139. package/dist/hooks/commandHooks.d.ts +4 -3
  140. package/dist/hooks/commandHooks.d.ts.map +1 -0
  141. package/dist/hooks/commandHooks.js +1 -1
  142. package/dist/hooks/index.d.ts +1 -0
  143. package/dist/hooks/index.d.ts.map +1 -0
  144. package/dist/hooks/useAutoCoreTag.d.ts +26 -0
  145. package/dist/hooks/useAutoCoreTag.d.ts.map +1 -0
  146. package/dist/hooks/useAutoCoreTag.js +1 -0
  147. package/dist/hooks/useScaledValue.d.ts +1 -0
  148. package/dist/hooks/useScaledValue.d.ts.map +1 -0
  149. package/dist/hooks/useScaledValue.js +1 -1
  150. package/dist/hub/CommandMessage.d.ts +19 -9
  151. package/dist/hub/CommandMessage.d.ts.map +1 -0
  152. package/dist/hub/CommandMessage.js +1 -1
  153. package/dist/hub/DebugPanel.d.ts +31 -0
  154. package/dist/hub/DebugPanel.d.ts.map +1 -0
  155. package/dist/hub/DebugPanel.js +1 -0
  156. package/dist/hub/HubBase.d.ts +85 -130
  157. package/dist/hub/HubBase.d.ts.map +1 -0
  158. package/dist/hub/HubBase.js +1 -1
  159. package/dist/hub/HubSimulate.d.ts +42 -8
  160. package/dist/hub/HubSimulate.d.ts.map +1 -0
  161. package/dist/hub/HubSimulate.js +1 -1
  162. package/dist/hub/HubTauri.d.ts +25 -60
  163. package/dist/hub/HubTauri.d.ts.map +1 -0
  164. package/dist/hub/HubTauri.js +1 -1
  165. package/dist/hub/HubWebSocket.d.ts +34 -17
  166. package/dist/hub/HubWebSocket.d.ts.map +1 -0
  167. package/dist/hub/HubWebSocket.js +1 -1
  168. package/dist/hub/debug.d.ts +23 -0
  169. package/dist/hub/debug.d.ts.map +1 -0
  170. package/dist/hub/debug.js +1 -0
  171. package/dist/hub/index.d.ts +20 -4
  172. package/dist/hub/index.d.ts.map +1 -0
  173. package/dist/hub/index.js +1 -1
  174. package/package.json +32 -27
  175. package/readme.md +193 -22
  176. package/src/components/AutoCoreDevPanel.tsx +414 -0
  177. package/src/components/CodeEditor.tsx +2 -2
  178. package/src/components/FileList.tsx +7 -6
  179. package/src/components/FileSelect.tsx +2 -1
  180. package/src/components/Indicator.tsx +2 -2
  181. package/src/components/IndicatorButton.tsx +2 -2
  182. package/src/components/IndicatorRect.tsx +2 -2
  183. package/src/components/Lamp.tsx +3 -3
  184. package/src/components/TextInput.tsx +159 -240
  185. package/src/components/ToggleGroup.tsx +3 -3
  186. package/src/components/ValueDisplay.tsx +4 -4
  187. package/src/components/ValueIndicator.tsx +2 -2
  188. package/src/components/ValueInput.tsx +2 -2
  189. package/src/core/ActionMode.ts +1 -1
  190. package/src/core/AutoCoreTagContext.tsx +615 -0
  191. package/src/core/AutoCoreTagTypes.ts +334 -0
  192. package/src/core/CoreStreamTypes.ts +512 -0
  193. package/src/core/EventEmitterContext.tsx +257 -281
  194. package/src/core/IndicatorButtonState.ts +1 -1
  195. package/src/core/ValueSimulator.ts +2 -2
  196. package/src/core/hoc.tsx +1 -1
  197. package/src/hooks/adsHooks.tsx +21 -22
  198. package/src/hooks/commandHooks.tsx +23 -19
  199. package/src/hooks/index.ts +1 -1
  200. package/src/hooks/useAutoCoreTag.ts +103 -0
  201. package/src/hooks/useScaledValue.tsx +1 -1
  202. package/src/hub/CommandMessage.ts +71 -19
  203. package/src/hub/DebugPanel.ts +280 -0
  204. package/src/hub/HubBase.ts +147 -223
  205. package/src/hub/HubSimulate.ts +93 -24
  206. package/src/hub/HubTauri.ts +87 -96
  207. package/src/hub/HubWebSocket.ts +133 -158
  208. package/src/hub/debug.ts +211 -0
  209. package/src/hub/index.ts +49 -39
  210. package/tsconfig.json +43 -28
  211. package/docs/classes/components_BlocklyEditor.BlocklyEditor.html +0 -124
  212. package/docs/classes/components_CodeEditor.CodeEditor.html +0 -128
  213. package/docs/classes/components_JogPanel.JogPanel.html +0 -138
  214. package/docs/classes/components_Lamp.Lamp.html +0 -105
  215. package/docs/classes/components_TextInput.TextInput.html +0 -115
  216. package/docs/classes/components_ValueIndicator.ValueIndicator.html +0 -119
  217. package/docs/classes/components_ValueInput.ValueInput.html +0 -113
  218. package/docs/classes/hub_HubWebSocket.HubWebSocket.html +0 -106
  219. package/docs/enums/components_JogPanel.JogDistanceAction.html +0 -5
  220. package/docs/enums/components_JogPanel.JogPanelAction.html +0 -18
  221. package/docs/enums/components_JogPanel.JogSpeedAction.html +0 -5
  222. package/docs/enums/core_ActionMode.ActionMode.html +0 -6
  223. package/docs/enums/core_IndicatorColor.IndicatorColor.html +0 -23
  224. package/docs/functions/assets_BlocklyLogo.default.html +0 -1
  225. package/docs/functions/assets_Distance.default.html +0 -1
  226. package/docs/functions/assets_JogLong.default.html +0 -1
  227. package/docs/functions/assets_JogMedium.default.html +0 -1
  228. package/docs/functions/assets_JogShort.default.html +0 -1
  229. package/docs/functions/assets_PythonLogo.default.html +0 -1
  230. package/docs/functions/assets_Rotation3D.default.html +0 -1
  231. package/docs/functions/assets_RotationCcw.default.html +0 -1
  232. package/docs/functions/assets_RotationCcwA.default.html +0 -1
  233. package/docs/functions/assets_RotationCcwB.default.html +0 -1
  234. package/docs/functions/assets_RotationCcwC.default.html +0 -1
  235. package/docs/functions/assets_RotationCw.default.html +0 -1
  236. package/docs/functions/assets_RotationCwA.default.html +0 -1
  237. package/docs/functions/assets_RotationCwB.default.html +0 -1
  238. package/docs/functions/assets_RotationCwC.default.html +0 -1
  239. package/docs/functions/assets_Run.default.html +0 -1
  240. package/docs/functions/assets_Speed.default.html +0 -1
  241. package/docs/functions/assets_SpeedFast.default.html +0 -1
  242. package/docs/functions/assets_SpeedMedium.default.html +0 -1
  243. package/docs/functions/assets_SpeedNone.default.html +0 -1
  244. package/docs/functions/assets_SpeedSlow.default.html +0 -1
  245. package/docs/functions/assets_Walk.default.html +0 -1
  246. package/docs/functions/components_BlocklyEditor.createCustomToolbox.html +0 -6
  247. package/docs/functions/components_FileList.FileList.html +0 -21
  248. package/docs/functions/components_FitText.FitText.html +0 -8
  249. package/docs/functions/components_ToggleGroup.ToggleGroup.html +0 -5
  250. package/docs/interfaces/components_JogPanel.JogPanelButtonDefinition.html +0 -5
  251. package/docs/interfaces/components_ToggleGroup.ToggleGroupProps.html +0 -618
  252. package/docs/interfaces/core_IndicatorButtonState.IndicatorButtonState.html +0 -10
  253. package/docs/interfaces/hub_CommandMessage.CommandMessage.html +0 -6
  254. package/docs/interfaces/hub_CommandMessage.CommandMessageResult.html +0 -4
  255. package/docs/modules/assets.html +0 -23
  256. package/docs/modules/assets_BlocklyLogo.html +0 -2
  257. package/docs/modules/assets_Distance.html +0 -2
  258. package/docs/modules/assets_JogLong.html +0 -2
  259. package/docs/modules/assets_JogMedium.html +0 -2
  260. package/docs/modules/assets_JogShort.html +0 -2
  261. package/docs/modules/assets_PythonLogo.html +0 -2
  262. package/docs/modules/assets_Rotation3D.html +0 -2
  263. package/docs/modules/assets_RotationCcw.html +0 -2
  264. package/docs/modules/assets_RotationCcwA.html +0 -2
  265. package/docs/modules/assets_RotationCcwB.html +0 -2
  266. package/docs/modules/assets_RotationCcwC.html +0 -2
  267. package/docs/modules/assets_RotationCw.html +0 -2
  268. package/docs/modules/assets_RotationCwA.html +0 -2
  269. package/docs/modules/assets_RotationCwB.html +0 -2
  270. package/docs/modules/assets_RotationCwC.html +0 -2
  271. package/docs/modules/assets_Run.html +0 -2
  272. package/docs/modules/assets_Speed.html +0 -2
  273. package/docs/modules/assets_SpeedFast.html +0 -2
  274. package/docs/modules/assets_SpeedMedium.html +0 -2
  275. package/docs/modules/assets_SpeedNone.html +0 -2
  276. package/docs/modules/assets_SpeedSlow.html +0 -2
  277. package/docs/modules/assets_Walk.html +0 -2
  278. package/docs/modules/components_BlocklyEditor.html +0 -5
  279. package/docs/modules/components_CodeEditor.html +0 -3
  280. package/docs/modules/components_FileList.html +0 -3
  281. package/docs/modules/components_FitText.html +0 -3
  282. package/docs/modules/components_JogPanel.html +0 -9
  283. package/docs/modules/components_Lamp.html +0 -4
  284. package/docs/modules/components_TextInput.html +0 -2
  285. package/docs/modules/components_ToggleGroup.html +0 -6
  286. package/docs/modules/components_ValueIndicator.html +0 -4
  287. package/docs/modules/components_ValueInput.html +0 -2
  288. package/docs/modules/core_ActionMode.html +0 -2
  289. package/docs/modules/core_IndicatorButtonState.html +0 -2
  290. package/docs/modules/core_IndicatorColor.html +0 -2
  291. package/docs/modules/hub_CommandMessage.html +0 -3
  292. package/docs/modules/hub_HubWebSocket.html +0 -2
  293. package/docs/types/components_IndicatorButton.IndicatorButtonOptionsType.html +0 -1
  294. package/docs/variables/components_BlocklyEditor.StandardToolbox.html +0 -1
  295. package/docs/variables/components_JogPanel.DefaultLinearJogButtons.html +0 -2
  296. package/docs/variables/components_JogPanel.DefaultRotationJogButtons.html +0 -2
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
3
  * Created Date: 2024-03-12 11:08:29
4
4
  * -----
5
- * Last Modified: 2024-03-12 11:08:41
5
+ * Last Modified: 2026-01-29 09:32:28
6
6
  * -----
7
7
  *
8
8
  */
@@ -3,13 +3,13 @@
3
3
  * Created Date: 2024-01-18 12:49:58
4
4
  * Author: Thomas C. Bitsky Jr.
5
5
  * -----
6
- * Last Modified: 2024-03-08 09:33:45
6
+ * Last Modified: 2025-09-05 14:50:12
7
7
  * Modified By: ADC
8
8
  * -----
9
9
  *
10
10
  */
11
11
 
12
- import { EmitterDispatchFunction } from "./EventEmitterContext";
12
+ import type { EmitterDispatchFunction } from "./EventEmitterContext";
13
13
 
14
14
 
15
15
  /**
package/src/core/hoc.tsx CHANGED
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
3
  * Created Date: 2024-01-18 16:14:20
4
4
  * -----
5
- * Last Modified: 2024-03-08 09:27:12
5
+ * Last Modified: 2026-01-29 09:32:17
6
6
  * Modified By: ADC
7
7
  * -----
8
8
  */
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
3
  * Created Date: 2024-04-26 09:04:40
4
4
  * -----
5
- * Last Modified: 2024-05-17 10:47:22
5
+ * Last Modified: 2026-01-29 09:33:22
6
6
  * -----
7
7
  *
8
8
  */
@@ -11,6 +11,7 @@
11
11
 
12
12
  import { useContext, useRef, useEffect, useCallback } from 'react';
13
13
  import { EventEmitterContext } from '../core/EventEmitterContext';
14
+ import { MessageType } from '../hub/CommandMessage';
14
15
 
15
16
 
16
17
  /**
@@ -70,8 +71,8 @@ export const useAdsRegisterSymbols = (
70
71
  const registerAndSubscribe = async () => {
71
72
  for (const [key, symbolName] of Object.entries(symbols)) {
72
73
  try {
73
- const invokeOptions = options[key] ? { symbol_name: symbolName, options : options[key] } : { symbol_name: symbolName };
74
- await invoke("ADS", "register_symbol", invokeOptions);
74
+ const invokeOptions = options[key] ? { symbol_name: symbolName, options: options[key] } : { symbol_name: symbolName };
75
+ await invoke("ADS.register_symbol", MessageType.Request, invokeOptions);
75
76
 
76
77
  //console.log(`Subscribe... ADS/${symbolName}`);
77
78
  const subscriptionId = subscribe(`ADS/${symbolName}`, (data) => {
@@ -87,7 +88,7 @@ export const useAdsRegisterSymbols = (
87
88
  console.error(`Failed to register symbol ${symbolName}: ${err}`);
88
89
  }
89
90
  }
90
- await invoke("ADS", "refresh", {});
91
+ await invoke("ADS.refresh", MessageType.Request, {});
91
92
  };
92
93
 
93
94
  if (!isConnected() ) {
@@ -152,14 +153,13 @@ export const useAdsRegisterSymbols = (
152
153
  * };
153
154
  */
154
155
  export function useAdsWriteValue(symbolName: string) {
155
- const { invoke } = useContext(EventEmitterContext);
156
- const domain = "ADS";
157
- const fname = "write_value";
156
+ const { write } = useContext(EventEmitterContext);
158
157
 
159
158
  // Return a function that takes a value and sends it to the backend
160
- return async (value: object | boolean | number | string ) => {
159
+ return async (value: object | boolean | number | string) => {
161
160
  try {
162
- await invoke(domain, fname, { symbol_name: symbolName, value });
161
+ // Use FQDN topic: ADS.symbolName
162
+ await write(`ADS.${symbolName}`, value);
163
163
  } catch (err) {
164
164
  console.error(`Error writing tag ${symbolName}: ${err}`);
165
165
  }
@@ -220,23 +220,22 @@ export function useAdsWriteValue(symbolName: string) {
220
220
  * dynamically if needed, for instance, based on user selection or other external configurations.
221
221
  */
222
222
  export function useAdsWriteScaledValue(symbolName: string, scale: number, offset: number) {
223
- const { invoke } = useContext(EventEmitterContext);
224
- const domain = "ADS";
225
- const fname = "write_value";
226
-
223
+ const { write } = useContext(EventEmitterContext);
224
+
227
225
  return useCallback(async (value: number) => {
228
226
 
229
- // In autocore-react, we multiple to scale incoming values,
227
+ // In autocore-react, we multiply to scale incoming values,
230
228
  // divide to scale outgoing values.
231
229
  // This is an OUTGOING value, so we divide.
232
230
 
233
- const scaledValue = (value - offset) / scale;
231
+ const scaledValue = (value - offset) / scale;
234
232
  try {
235
- await invoke(domain, fname, { symbol_name: symbolName, value: scaledValue });
233
+ // Use FQDN topic: ADS.symbolName
234
+ await write(`ADS.${symbolName}`, scaledValue);
236
235
  } catch (err) {
237
236
  console.error(`Error writing scaled value to tag ${symbolName}: ${err}`);
238
237
  }
239
- }, [symbolName, scale, offset, invoke]);
238
+ }, [symbolName, scale, offset, write]);
240
239
  }
241
240
 
242
241
 
@@ -271,15 +270,15 @@ export function useAdsWriteScaledValue(symbolName: string, scale: number, offset
271
270
  * ```
272
271
  */
273
272
  export function useAdsTapValue(symbolName: string): () => Promise<void> {
274
- const { invoke } = useContext(EventEmitterContext);
275
- const domain = "ADS";
276
- const fname = "write_value";
273
+ const { write } = useContext(EventEmitterContext);
277
274
 
278
275
  return async () => {
279
276
  try {
280
- await invoke(domain, fname, { symbol_name: symbolName, value: true });
277
+ // Use FQDN topic: ADS.symbolName
278
+ const topic = `ADS.${symbolName}`;
279
+ await write(topic, true);
281
280
  await sleep(300); // Sleep for 300ms before writing false
282
- await invoke(domain, fname, { symbol_name: symbolName, value: false });
281
+ await write(topic, false);
283
282
  } catch (err) {
284
283
  console.error(`Error handling tap action for ${symbolName}: ${err}`);
285
284
  }
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2025 Automated Design Corp. All Rights Reserved.
3
3
  * Created Date: 2025-03-31 06:38:50
4
4
  * -----
5
- * Last Modified: 2025-04-28 10:37:20
5
+ * Last Modified: 2026-01-29 09:33:28
6
6
  * -----
7
7
  *
8
8
  */
@@ -14,6 +14,7 @@
14
14
 
15
15
  import { useContext, useRef, useEffect, useCallback } from 'react';
16
16
  import { EventEmitterContext } from '../core/EventEmitterContext';
17
+ import { MessageType } from '../hub/CommandMessage';
17
18
 
18
19
 
19
20
  /**
@@ -90,9 +91,8 @@ export const useRegisterSymbols = (
90
91
  subscriptions.current.push(subscriptionId);
91
92
 
92
93
  // Refresh on a topic is the same as a read_value, except the response is broadcasted.
93
- // Because there currently isn't a centralized tag system, the topic name should not
94
- // contain the domain name.
95
- await invoke(domain, "refresh", {'topic' : `${symbolName}`});
94
+ // Use FQDN topic: domain.symbolName
95
+ await invoke(`${domain}.${symbolName}`, MessageType.Request, { action: "refresh" });
96
96
 
97
97
  } catch (err) {
98
98
  console.error(`Failed to register symbol ${symbolName}: ${err}`);
@@ -165,13 +165,14 @@ export const useRegisterSymbols = (
165
165
  * );
166
166
  * };
167
167
  */
168
- export function useWriteValue(domain : string, symbolName: string, fname : string = "write_value") {
169
- const { invoke } = useContext(EventEmitterContext);
168
+ export function useWriteValue(domain: string, symbolName: string) {
169
+ const { write } = useContext(EventEmitterContext);
170
170
 
171
171
  // Return a function that takes a value and sends it to the backend
172
- return async (value: object | boolean | number | string ) => {
172
+ return async (value: object | boolean | number | string) => {
173
173
  try {
174
- await invoke(domain, fname, { "topic" : symbolName, "value" : value });
174
+ // Use FQDN topic: domain.symbolName
175
+ await write(`${domain}.${symbolName}`, value);
175
176
  } catch (err) {
176
177
  console.error(`Error writing tag ${symbolName}: ${err}`);
177
178
  }
@@ -231,22 +232,23 @@ export function useWriteValue(domain : string, symbolName: string, fname : strin
231
232
  * converts it to millimeters using the current `scale`, and writes the result to a backend symbol. The `scale` and `offset` can be adjusted
232
233
  * dynamically if needed, for instance, based on user selection or other external configurations.
233
234
  */
234
- export function useWriteScaledValue(domain : string, symbolName: string, scale: number, offset: number, fname : string = "write_value") {
235
- const { invoke } = useContext(EventEmitterContext);
236
-
235
+ export function useWriteScaledValue(domain: string, symbolName: string, scale: number, offset: number) {
236
+ const { write } = useContext(EventEmitterContext);
237
+
237
238
  return useCallback(async (value: number) => {
238
239
 
239
- // In autocore-react, we multiple to scale incoming values,
240
+ // In autocore-react, we multiply to scale incoming values,
240
241
  // divide to scale outgoing values.
241
242
  // This is an OUTGOING value, so we divide.
242
243
 
243
- const scaledValue = (value - offset) / scale;
244
+ const scaledValue = (value - offset) / scale;
244
245
  try {
245
- await invoke(domain, fname, { symbol_name: symbolName, value: scaledValue });
246
+ // Use FQDN topic: domain.symbolName
247
+ await write(`${domain}.${symbolName}`, scaledValue);
246
248
  } catch (err) {
247
249
  console.error(`Error writing scaled value to tag ${symbolName}: ${err}`);
248
250
  }
249
- }, [symbolName, scale, offset, invoke]);
251
+ }, [domain, symbolName, scale, offset, write]);
250
252
  }
251
253
 
252
254
 
@@ -280,14 +282,16 @@ export function useWriteScaledValue(domain : string, symbolName: string, scale:
280
282
  * };
281
283
  * ```
282
284
  */
283
- export function useTapValue(domain : string, symbolName: string, fname : string = "write_value"): () => Promise<void> {
284
- const { invoke } = useContext(EventEmitterContext);
285
+ export function useTapValue(domain: string, symbolName: string): () => Promise<void> {
286
+ const { write } = useContext(EventEmitterContext);
285
287
 
286
288
  return async () => {
287
289
  try {
288
- await invoke(domain, fname, { symbol_name: symbolName, value: true });
290
+ // Use FQDN topic: domain.symbolName
291
+ const topic = `${domain}.${symbolName}`;
292
+ await write(topic, true);
289
293
  await sleep(300); // Sleep for 300ms before writing false
290
- await invoke(domain, fname, { symbol_name: symbolName, value: false });
294
+ await write(topic, false);
291
295
  } catch (err) {
292
296
  console.error(`Error handling tap action for ${symbolName}: ${err}`);
293
297
  }
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
3
  * Created Date: 2024-04-30 12:14:43
4
4
  * -----
5
- * Last Modified: 2024-04-30 12:15:46
5
+ * Last Modified: 2026-01-29 09:33:34
6
6
  * -----
7
7
  *
8
8
  */
@@ -0,0 +1,103 @@
1
+ /*
2
+ * Copyright (C) 2025 Automated Design Corp.. All Rights Reserved.
3
+ * Created Date: 2025-09-05 08:03:32
4
+ * -----
5
+ * Last Modified: 2026-01-29 09:33:40
6
+ * -----
7
+ *
8
+ */
9
+
10
+ /**
11
+ * @module hooks/useAutoCoreTag.ts
12
+ *
13
+ * Factory for generating strongly-typed React hooks to consume AutoCoreTagContext.
14
+ */
15
+
16
+ import { useCallback, useContext, useMemo } from "react";
17
+ import type { BaseContextValue, TagConfig, TagValueMap } from "../core/AutoCoreTagTypes";
18
+
19
+ export function makeAutoCoreTagHooks<Spec extends readonly TagConfig[]>(
20
+ Context: React.Context<BaseContextValue<TagValueMap<Spec>>>,
21
+ tags: Spec
22
+ ) {
23
+ type VMap = TagValueMap<Spec>;
24
+ type TagNames = keyof VMap & string;
25
+
26
+ const findCfg = (tagName: string) =>
27
+ tags.find(t => t.fqdn === tagName) as (Spec[number] | undefined);
28
+
29
+ /**
30
+ * Access a single tag by name.
31
+ * Returns current value, raw value, direct server writer, and tap helper.
32
+ */
33
+ const useAutoCoreTag = <K extends TagNames>(tagName: K) => {
34
+ const { values, rawValues, isLoading, write: ctxWrite, tap: ctxTap } = useContext(Context);
35
+
36
+ const cfg = findCfg(tagName as string);
37
+ if (!cfg) throw new Error(`useAutoCoreTag: unknown tagName '${String(tagName)}'`);
38
+
39
+ const write = useCallback(
40
+ (displayValue: VMap[K]) => ctxWrite(tagName, displayValue),
41
+ [ctxWrite, tagName]
42
+ );
43
+
44
+ const tap = useCallback(() => ctxTap?.(tagName), [ctxTap, tagName]);
45
+
46
+ return {
47
+ value: values[tagName] as VMap[K],
48
+ rawValue: rawValues[tagName as string],
49
+ write,
50
+ tap,
51
+ isLoading,
52
+ } as const;
53
+ };
54
+
55
+ /**
56
+ * Access multiple tags at once with a bulk writer.
57
+ */
58
+ const useAutoCoreTags = <K extends TagNames>(tagNames: readonly K[]) => {
59
+ const { values, rawValues, isLoading, write: ctxWrite } = useContext(Context);
60
+
61
+ const subset = useMemo(
62
+ () =>
63
+ Object.fromEntries(
64
+ tagNames.map(k => [k, values[k] as VMap[K]])
65
+ ) as { [P in K]: VMap[P] },
66
+ [values, tagNames]
67
+ );
68
+
69
+ const rawSubset = useMemo(
70
+ () =>
71
+ Object.fromEntries(
72
+ tagNames.map(k => [k, rawValues[k as string]])
73
+ ) as { [P in K]: unknown },
74
+ [rawValues, tagNames]
75
+ );
76
+
77
+ const write = useCallback(async (tagName: K, value: VMap[K]) => {
78
+ await ctxWrite(tagName, value);
79
+ }, [ctxWrite]);
80
+
81
+ return { values: subset, rawValues: rawSubset, write, isLoading } as const;
82
+ };
83
+
84
+ /**
85
+ * Compute a derived value from the full tag state.
86
+ */
87
+ const useAutoCoreSelect = <R>(selector: (all: Readonly<Partial<VMap>>) => R, deps: any[] = []) => {
88
+ const { values, isLoading } = useContext(Context);
89
+ const selected = useMemo(() => selector(values), [values, ...deps]);
90
+ return { selected, isLoading } as const;
91
+ };
92
+
93
+ /**
94
+ * Access scale configurations and update functions.
95
+ */
96
+ const useScales = () => {
97
+ const { scales, updateScale } = useContext(Context);
98
+ const getScale = useCallback((scaleName: string) => scales[scaleName], [scales]);
99
+ return { scales, updateScale, getScale } as const;
100
+ };
101
+
102
+ return { useAutoCoreTag, useAutoCoreTags, useAutoCoreSelect, useScales } as const;
103
+ }
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
3
  * Created Date: 2024-04-30 11:41:59
4
4
  * -----
5
- * Last Modified: 2024-05-21 19:58:23
5
+ * Last Modified: 2026-01-29 09:33:46
6
6
  * -----
7
7
  *
8
8
  */
@@ -2,36 +2,88 @@
2
2
  * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
3
  * Created Date: 2024-04-24 11:47:13
4
4
  * -----
5
- * Last Modified: 2024-04-24 11:48:08
5
+ * Last Modified: 2026-01-29 09:33:54
6
6
  * -----
7
7
  *
8
8
  */
9
9
 
10
10
 
11
+ // Replaced by a flattened CommandMessage
12
+ // /// The result portion of a CommandMessage. The server will
13
+ // /// place the result of a command in this portion of the message.
14
+ // export interface CommandMessageResult {
15
+ // /// The JSON object of the result.
16
+ // data: any;
17
+ // /// If true, the command was processed successfully.
18
+ // success : boolean,
19
+ // /// If success is false, this should contain a corresponding error message.
20
+ // error_message: string;
21
+ // }
11
22
 
12
- /// The result portion of a CommandMessage. The server will
13
- /// place the result of a command in this portion of the message.
14
- export interface CommandMessageResult {
15
- /// The JSON object of the result.
16
- data: any;
17
- /// If true, the command was processed successfully.
18
- success : boolean,
19
- /// If success is false, this should contain a corresponding error message.
20
- error_message: string;
23
+
24
+ export enum MessageType {
25
+ /// Invalid or no operation. Used for keepalive/ping.
26
+ NoOp = 0,
27
+
28
+ /// Response to a previous request.
29
+ Response = 1,
30
+
31
+ /// Read request - module should return data for the specified topic.
32
+ Read = 2,
33
+
34
+ /// Write request - module should store the provided data.
35
+ Write = 3,
36
+
37
+ /// Subscribe to updates on a topic.
38
+ Subscribe = 4,
39
+
40
+ /// Unsubscribe from a topic.
41
+ Unsubscribe = 5,
42
+
43
+ /// Broadcast message (unsolicited push from module to server or vice versa).
44
+ Broadcast = 6,
45
+
46
+ /// Heartbeat/keepalive message.
47
+ Heartbeat = 7,
48
+
49
+ /// Control message (initialize, finalize, configuration).
50
+ Control = 8,
51
+
52
+ /// Generic request - module parses topic to determine action.
53
+ Request = 10,
21
54
  }
22
55
 
56
+
57
+
23
58
  /// CommandMessage is the object passed between the client and server for making requests and
24
59
  /// responses.
25
60
  export interface CommandMessage {
26
61
  /// An id to identify the request. The request ID is managed by the client and will be reflected back.
27
62
  /// The server will never change the request ID.
28
- request_id: number;
29
- /// The command domain/servelet in which this command/function to invoke belongs.
30
- domain: string;
31
- /// The name of the function to invoke.
32
- fname: string;
33
- /// A JSON object of the arguments to the function.
34
- args?: any;
35
- /// The result of the command, reflected back from the server
36
- result?: CommandMessageResult;
63
+ transaction_id: number;
64
+
65
+ /// Timestamp in milliseconds since UNIX epoch.
66
+ /// Set automatically on message creation.
67
+ timecode: number,
68
+
69
+
70
+ /// Fully-qualified topic name (FQDN).
71
+ /// Format: "domain.subtopic.path" e.g., "ads.plc1.GM.stData"
72
+ topic: string;
73
+
74
+ /// The type/purpose of this message.
75
+ message_type: MessageType,
76
+
77
+ /// The payload data.
78
+ /// - For requests: arguments/parameters
79
+ /// - For responses: result data
80
+ data?: any;
81
+
82
+
83
+ /// Whether the operation was successful (for responses).
84
+ success: boolean,
85
+
86
+ /// Error message if the operation failed (for responses).
87
+ error_message: string,
88
+
37
89
  }