@adcops/autocore-react 3.0.1 → 3.0.4

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 (292) hide show
  1. package/dist/assets/BlocklyLogo.d.ts +3 -0
  2. package/dist/assets/BlocklyLogo.js +1 -0
  3. package/dist/assets/Distance.d.ts +3 -0
  4. package/dist/assets/Distance.js +1 -0
  5. package/dist/assets/JogLong.d.ts +3 -0
  6. package/dist/assets/JogLong.js +1 -0
  7. package/dist/assets/JogMedium.d.ts +3 -0
  8. package/dist/assets/JogMedium.js +1 -0
  9. package/dist/assets/JogShort.d.ts +3 -0
  10. package/dist/assets/JogShort.js +1 -0
  11. package/dist/assets/PythonLogo.d.ts +3 -0
  12. package/dist/assets/PythonLogo.js +1 -0
  13. package/dist/assets/Rotation3D.d.ts +3 -0
  14. package/dist/assets/Rotation3D.js +1 -0
  15. package/dist/assets/RotationCcw.d.ts +3 -0
  16. package/dist/assets/RotationCcw.js +1 -0
  17. package/dist/assets/RotationCcwA.d.ts +3 -0
  18. package/dist/assets/RotationCcwA.js +1 -0
  19. package/dist/assets/RotationCcwB.d.ts +3 -0
  20. package/dist/assets/RotationCcwB.js +1 -0
  21. package/dist/assets/RotationCcwC.d.ts +3 -0
  22. package/dist/assets/RotationCcwC.js +1 -0
  23. package/dist/assets/RotationCw.d.ts +3 -0
  24. package/dist/assets/RotationCw.js +1 -0
  25. package/dist/assets/RotationCwA.d.ts +3 -0
  26. package/dist/assets/RotationCwA.js +1 -0
  27. package/dist/assets/RotationCwB.d.ts +3 -0
  28. package/dist/assets/RotationCwB.js +1 -0
  29. package/dist/assets/RotationCwC.d.ts +3 -0
  30. package/dist/assets/RotationCwC.js +1 -0
  31. package/dist/assets/Run.d.ts +3 -0
  32. package/dist/assets/Run.js +1 -0
  33. package/dist/assets/Speed.d.ts +3 -0
  34. package/dist/assets/Speed.js +1 -0
  35. package/dist/assets/SpeedFast.d.ts +3 -0
  36. package/dist/assets/SpeedFast.js +1 -0
  37. package/dist/assets/SpeedMedium.d.ts +3 -0
  38. package/dist/assets/SpeedMedium.js +1 -0
  39. package/dist/assets/SpeedNone.d.ts +3 -0
  40. package/dist/assets/SpeedNone.js +1 -0
  41. package/dist/assets/SpeedSlow.d.ts +3 -0
  42. package/dist/assets/SpeedSlow.js +1 -0
  43. package/dist/assets/Walk.d.ts +3 -0
  44. package/dist/assets/Walk.js +1 -0
  45. package/dist/assets/index.d.ts +22 -0
  46. package/dist/assets/index.js +1 -0
  47. package/dist/assets/svg/blockly_logo.svg +82 -0
  48. package/dist/assets/svg/distance.svg +40 -0
  49. package/dist/assets/svg/jog_long.svg +1 -0
  50. package/dist/assets/svg/jog_medium.svg +1 -0
  51. package/dist/assets/svg/jog_short.svg +1 -0
  52. package/dist/assets/svg/python_logo.svg +246 -0
  53. package/dist/assets/svg/rotation_3d.svg +1 -0
  54. package/dist/assets/svg/rotation_ccw.svg +50 -0
  55. package/dist/assets/svg/rotation_ccw_a.svg +57 -0
  56. package/dist/assets/svg/rotation_ccw_b.svg +57 -0
  57. package/dist/assets/svg/rotation_ccw_c.svg +57 -0
  58. package/dist/assets/svg/rotation_cw.svg +49 -0
  59. package/dist/assets/svg/rotation_cw_a.svg +30 -0
  60. package/dist/assets/svg/rotation_cw_b.svg +30 -0
  61. package/dist/assets/svg/rotation_cw_c.svg +30 -0
  62. package/dist/assets/svg/run.svg +1 -0
  63. package/dist/assets/svg/speed.svg +39 -0
  64. package/dist/assets/svg/speed_fast.svg +1 -0
  65. package/dist/assets/svg/speed_medium.svg +1 -0
  66. package/dist/assets/svg/speed_none.svg +1 -0
  67. package/dist/assets/svg/speed_slow.svg +1 -0
  68. package/dist/assets/svg/walk.svg +1 -0
  69. package/dist/components/BlocklyEditor.css +25 -0
  70. package/dist/components/BlocklyEditor.d.ts +120 -0
  71. package/dist/components/BlocklyEditor.js +1 -0
  72. package/dist/components/CodeEditor.d.ts +76 -0
  73. package/dist/components/CodeEditor.js +1 -0
  74. package/dist/components/Indicator.d.ts +12 -27
  75. package/dist/components/Indicator.js +1 -1
  76. package/dist/components/IndicatorButton.d.ts +56 -37
  77. package/dist/components/IndicatorButton.js +1 -1
  78. package/dist/components/JogPanel.css +41 -0
  79. package/dist/components/JogPanel.d.ts +118 -0
  80. package/dist/components/JogPanel.js +1 -0
  81. package/dist/components/Lamp.d.ts +81 -0
  82. package/dist/components/Lamp.js +1 -0
  83. package/dist/components/ToggleGroup.d.ts +103 -0
  84. package/dist/components/ToggleGroup.js +1 -0
  85. package/dist/components/ValueInput.d.ts +109 -0
  86. package/dist/components/ValueInput.js +1 -0
  87. package/dist/core/ActionMode.d.ts +9 -0
  88. package/dist/core/ActionMode.js +1 -0
  89. package/dist/core/IndicatorButtonState.d.ts +21 -0
  90. package/dist/core/IndicatorButtonState.js +1 -0
  91. package/dist/core/MaskPatterns.d.ts +4 -0
  92. package/dist/core/MaskPatterns.js +1 -1
  93. package/docs/assets/highlight.css +25 -18
  94. package/docs/assets/navigation.js +1 -1
  95. package/docs/assets/search.js +1 -1
  96. package/docs/classes/components_BlocklyEditor.BlocklyEditor.html +124 -0
  97. package/docs/classes/components_CodeEditor.CodeEditor.html +128 -0
  98. package/docs/classes/components_Indicator.Indicator.html +8 -8
  99. package/docs/classes/components_IndicatorButton.IndicatorButton.html +17 -17
  100. package/docs/classes/components_JogPanel.JogPanel.html +138 -0
  101. package/docs/classes/components_Lamp.Lamp.html +105 -0
  102. package/docs/classes/components_OskDialog.OskDialog.html +5 -5
  103. package/docs/classes/components_ToggleGroup.ToggleGroup.html +118 -0
  104. package/docs/classes/components_ValueDisplay.ValueDisplay.html +4 -4
  105. package/docs/classes/components_ValueInput.ValueInput.html +115 -0
  106. package/docs/classes/core_ValueSimulator.ValueSimulator.html +2 -2
  107. package/docs/classes/hub_HubBase.HubBase.html +4 -4
  108. package/docs/classes/hub_HubSimulate.HubSimulate.html +2 -2
  109. package/docs/classes/hub_HubSocketIo.HubSocketIo.html +5 -5
  110. package/docs/classes/hub_HubTauri.HubTauri.html +5 -5
  111. package/docs/enums/components_JogPanel.JogDistanceAction.html +5 -0
  112. package/docs/enums/components_JogPanel.JogPanelAction.html +18 -0
  113. package/docs/enums/components_JogPanel.JogSpeedAction.html +5 -0
  114. package/docs/enums/core_ActionMode.ActionMode.html +6 -0
  115. package/docs/enums/core_IndicatorColor.IndicatorColor.html +23 -0
  116. package/docs/functions/assets_BlocklyLogo.default.html +1 -0
  117. package/docs/functions/assets_Distance.default.html +1 -0
  118. package/docs/functions/assets_JogLong.default.html +1 -0
  119. package/docs/functions/assets_JogMedium.default.html +1 -0
  120. package/docs/functions/assets_JogShort.default.html +1 -0
  121. package/docs/functions/assets_PythonLogo.default.html +1 -0
  122. package/docs/functions/assets_Rotation3D.default.html +1 -0
  123. package/docs/functions/assets_RotationCcw.default.html +1 -0
  124. package/docs/functions/assets_RotationCcwA.default.html +1 -0
  125. package/docs/functions/assets_RotationCcwB.default.html +1 -0
  126. package/docs/functions/assets_RotationCcwC.default.html +1 -0
  127. package/docs/functions/assets_RotationCw.default.html +1 -0
  128. package/docs/functions/assets_RotationCwA.default.html +1 -0
  129. package/docs/functions/assets_RotationCwB.default.html +1 -0
  130. package/docs/functions/assets_RotationCwC.default.html +1 -0
  131. package/docs/functions/assets_Run.default.html +1 -0
  132. package/docs/functions/assets_Speed.default.html +1 -0
  133. package/docs/functions/assets_SpeedFast.default.html +1 -0
  134. package/docs/functions/assets_SpeedMedium.default.html +1 -0
  135. package/docs/functions/assets_SpeedNone.default.html +1 -0
  136. package/docs/functions/assets_SpeedSlow.default.html +1 -0
  137. package/docs/functions/assets_Walk.default.html +1 -0
  138. package/docs/functions/components_BlocklyEditor.createCustomToolbox.html +6 -0
  139. package/docs/functions/components_Osk.Osk.html +2 -2
  140. package/docs/functions/core_EventEmitterContext.EventEmitterProvider.html +2 -2
  141. package/docs/functions/core_UniqueId.UniqueId.html +2 -2
  142. package/docs/functions/core_hoc.hocAddSubscription.html +2 -2
  143. package/docs/functions/hub.createHub.html +2 -2
  144. package/docs/hierarchy.html +1 -1
  145. package/docs/index.html +18 -2
  146. package/docs/interfaces/components_IndicatorButton.IndicatorButtonProps.html +160 -132
  147. package/docs/interfaces/components_JogPanel.JogPanelButtonDefinition.html +5 -0
  148. package/docs/interfaces/components_ToggleGroup.ToggleGroupProps.html +636 -0
  149. package/docs/interfaces/core_EventEmitterContext.Action.html +2 -2
  150. package/docs/interfaces/core_EventEmitterContext.EventEmitterContextType.html +2 -2
  151. package/docs/interfaces/core_EventEmitterContext.State.html +2 -2
  152. package/docs/interfaces/core_EventEmitterContext.Subscription.html +2 -2
  153. package/docs/interfaces/core_IndicatorButtonState.IndicatorButtonState.html +10 -0
  154. package/docs/interfaces/core_PositionContext.IPositionContext.html +2 -2
  155. package/docs/modules/assets.html +23 -0
  156. package/docs/modules/assets_BlocklyLogo.html +2 -0
  157. package/docs/modules/assets_Distance.html +2 -0
  158. package/docs/modules/assets_JogLong.html +2 -0
  159. package/docs/modules/assets_JogMedium.html +2 -0
  160. package/docs/modules/assets_JogShort.html +2 -0
  161. package/docs/modules/assets_PythonLogo.html +2 -0
  162. package/docs/modules/assets_Rotation3D.html +2 -0
  163. package/docs/modules/assets_RotationCcw.html +2 -0
  164. package/docs/modules/assets_RotationCcwA.html +2 -0
  165. package/docs/modules/assets_RotationCcwB.html +2 -0
  166. package/docs/modules/assets_RotationCcwC.html +2 -0
  167. package/docs/modules/assets_RotationCw.html +2 -0
  168. package/docs/modules/assets_RotationCwA.html +2 -0
  169. package/docs/modules/assets_RotationCwB.html +2 -0
  170. package/docs/modules/assets_RotationCwC.html +2 -0
  171. package/docs/modules/assets_Run.html +2 -0
  172. package/docs/modules/assets_Speed.html +2 -0
  173. package/docs/modules/assets_SpeedFast.html +2 -0
  174. package/docs/modules/assets_SpeedMedium.html +2 -0
  175. package/docs/modules/assets_SpeedNone.html +2 -0
  176. package/docs/modules/assets_SpeedSlow.html +2 -0
  177. package/docs/modules/assets_Walk.html +2 -0
  178. package/docs/modules/components_BlocklyEditor.html +5 -0
  179. package/docs/modules/components_CodeEditor.html +3 -0
  180. package/docs/modules/components_Indicator.html +2 -2
  181. package/docs/modules/components_IndicatorButton.html +4 -4
  182. package/docs/modules/components_JogPanel.html +9 -0
  183. package/docs/modules/components_Lamp.html +4 -0
  184. package/docs/modules/components_Osk.html +2 -2
  185. package/docs/modules/components_OskDialog.html +2 -2
  186. package/docs/modules/components_ToggleGroup.html +5 -0
  187. package/docs/modules/components_ValueDisplay.html +2 -2
  188. package/docs/modules/components_ValueInput.html +2 -0
  189. package/docs/modules/core_ActionMode.html +2 -0
  190. package/docs/modules/core_EventEmitterContext.html +2 -2
  191. package/docs/modules/{components_IndicatorColor.html → core_IndicatorButtonState.html} +2 -2
  192. package/docs/modules/core_IndicatorColor.html +2 -0
  193. package/docs/modules/core_MaskPatterns.html +2 -2
  194. package/docs/modules/core_NumerableTypes.html +2 -2
  195. package/docs/modules/core_PositionContext.html +2 -2
  196. package/docs/modules/core_UniqueId.html +2 -2
  197. package/docs/modules/core_ValueSimulator.html +2 -2
  198. package/docs/modules/core_hoc.html +2 -2
  199. package/docs/modules/hub.html +2 -2
  200. package/docs/modules/hub_HubBase.html +2 -2
  201. package/docs/modules/hub_HubSimulate.html +2 -2
  202. package/docs/modules/hub_HubSocketIo.html +2 -2
  203. package/docs/modules/hub_HubTauri.html +2 -2
  204. package/docs/types/components_IndicatorButton.IndicatorButtonOptionsType.html +1 -0
  205. package/docs/types/core_EventEmitterContext.EmitterDispatchFunction.html +2 -2
  206. package/docs/types/core_EventEmitterContext.EmitterSubscribeFunction.html +2 -2
  207. package/docs/types/core_EventEmitterContext.EmitterUnsubscribeFunction.html +2 -2
  208. package/docs/types/core_NumerableTypes.NumerableFormatOptions.html +2 -2
  209. package/docs/types/core_hoc.HocAddSubscriptionProps.html +2 -2
  210. package/docs/variables/components_BlocklyEditor.StandardToolbox.html +1 -0
  211. package/docs/variables/components_JogPanel.DefaultLinearJogButtons.html +2 -0
  212. package/docs/variables/components_JogPanel.DefaultRotationJogButtons.html +2 -0
  213. package/docs/variables/core_EventEmitterContext.EventEmitterContext.html +6 -6
  214. package/docs/variables/core_MaskPatterns.PrimeReactMaskPatterns.html +2 -2
  215. package/docs/variables/core_MaskPatterns.RegExMaskPatterns.html +3 -2
  216. package/docs/variables/core_PositionContext.DimensionsContext.html +2 -2
  217. package/package.json +8 -4
  218. package/readme.md +33 -0
  219. package/src/assets/BlocklyLogo.tsx +27 -0
  220. package/src/assets/Distance.tsx +18 -0
  221. package/src/assets/JogLong.tsx +13 -0
  222. package/src/assets/JogMedium.tsx +13 -0
  223. package/src/assets/JogShort.tsx +13 -0
  224. package/src/assets/PythonLogo.tsx +83 -0
  225. package/src/assets/Rotation3D.tsx +13 -0
  226. package/src/assets/RotationCcw.tsx +33 -0
  227. package/src/assets/RotationCcwA.tsx +45 -0
  228. package/src/assets/RotationCcwB.tsx +45 -0
  229. package/src/assets/RotationCcwC.tsx +45 -0
  230. package/src/assets/RotationCw.tsx +31 -0
  231. package/src/assets/RotationCwA.tsx +42 -0
  232. package/src/assets/RotationCwB.tsx +42 -0
  233. package/src/assets/RotationCwC.tsx +42 -0
  234. package/src/assets/Run.tsx +13 -0
  235. package/src/assets/Speed.tsx +18 -0
  236. package/src/assets/SpeedFast.tsx +13 -0
  237. package/src/assets/SpeedMedium.tsx +13 -0
  238. package/src/assets/SpeedNone.tsx +13 -0
  239. package/src/assets/SpeedSlow.tsx +13 -0
  240. package/src/assets/Walk.tsx +13 -0
  241. package/src/assets/index.ts +22 -0
  242. package/src/assets/svg/blockly_logo.svg +82 -0
  243. package/src/assets/svg/distance.svg +40 -0
  244. package/src/assets/svg/jog_long.svg +1 -0
  245. package/src/assets/svg/jog_medium.svg +1 -0
  246. package/src/assets/svg/jog_short.svg +1 -0
  247. package/src/assets/svg/python_logo.svg +246 -0
  248. package/src/assets/svg/rotation_3d.svg +1 -0
  249. package/src/assets/svg/rotation_ccw.svg +50 -0
  250. package/src/assets/svg/rotation_ccw_a.svg +57 -0
  251. package/src/assets/svg/rotation_ccw_b.svg +57 -0
  252. package/src/assets/svg/rotation_ccw_c.svg +57 -0
  253. package/src/assets/svg/rotation_cw.svg +49 -0
  254. package/src/assets/svg/rotation_cw_a.svg +30 -0
  255. package/src/assets/svg/rotation_cw_b.svg +30 -0
  256. package/src/assets/svg/rotation_cw_c.svg +30 -0
  257. package/src/assets/svg/run.svg +1 -0
  258. package/src/assets/svg/speed.svg +39 -0
  259. package/src/assets/svg/speed_fast.svg +1 -0
  260. package/src/assets/svg/speed_medium.svg +1 -0
  261. package/src/assets/svg/speed_none.svg +1 -0
  262. package/src/assets/svg/speed_slow.svg +1 -0
  263. package/src/assets/svg/walk.svg +1 -0
  264. package/src/components/BlocklyEditor.css +25 -0
  265. package/src/components/BlocklyEditor.tsx +598 -0
  266. package/src/components/CodeEditor.tsx +156 -0
  267. package/src/components/Indicator.tsx +63 -118
  268. package/src/components/IndicatorButton.tsx +104 -50
  269. package/src/components/JogPanel.css +41 -0
  270. package/src/components/JogPanel.tsx +461 -0
  271. package/src/components/Lamp.tsx +243 -0
  272. package/src/components/ToggleGroup.tsx +429 -0
  273. package/src/components/ValueInput.tsx +261 -0
  274. package/src/core/ActionMode.ts +20 -0
  275. package/src/core/IndicatorButtonState.ts +34 -0
  276. package/src/core/MaskPatterns.ts +7 -1
  277. package/tools/copy-distribution-files.cjs +3 -2
  278. package/dist/components/DPad.css +0 -522
  279. package/dist/components/DPad.d.ts +0 -34
  280. package/dist/components/DPad.js +0 -1
  281. package/docs/enums/components_DPad.VcJoyPadAction.html +0 -10
  282. package/docs/enums/components_DPad.VcJoyPadButtonId.html +0 -7
  283. package/docs/enums/components_IndicatorButton.ActionMode.html +0 -6
  284. package/docs/enums/components_IndicatorColor.IndicatorColor.html +0 -23
  285. package/docs/functions/components_DPad.VcDPad.html +0 -5
  286. package/docs/interfaces/components_IndicatorButton.IndicatorButtonState.html +0 -10
  287. package/docs/modules/components_DPad.html +0 -5
  288. package/src/components/DPad.css +0 -522
  289. package/src/components/DPad.tsx +0 -94
  290. /package/dist/{components → core}/IndicatorColor.d.ts +0 -0
  291. /package/dist/{components → core}/IndicatorColor.js +0 -0
  292. /package/src/{components → core}/IndicatorColor.ts +0 -0
@@ -0,0 +1,461 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
+ * Created Date: 2024-01-16 13:17:23
4
+ * -----
5
+ * Last Modified: 2024-03-20 13:16:29
6
+ * -----
7
+ *
8
+ */
9
+
10
+ import React from 'react';
11
+ import { Button } from "primereact/button";
12
+ import { SelectButton } from 'primereact/selectbutton';
13
+ import { Tooltip } from 'primereact/tooltip';
14
+
15
+ import './JogPanel.css';
16
+ //import _default from '@monaco-editor/react';
17
+
18
+ import { Distance, JogShort, JogMedium, JogLong } from '../assets';
19
+ import { Speed, SpeedSlow, SpeedMedium, SpeedFast } from '../assets';
20
+ import { RotationCcwA, RotationCcwB, RotationCcwC } from '../assets';
21
+ import { RotationCwA, RotationCwB, RotationCwC } from '../assets';
22
+
23
+ /**
24
+ * Enumerates the source button or action when an event occurs.
25
+ */
26
+ export enum JogPanelAction {
27
+ /** Invalid - Ignore this button */
28
+ Invalid = 0x00,
29
+ // Horizontal Right
30
+ xPositive = 0x01,
31
+ // Vertical left
32
+ xNegative = 0x02,
33
+ // Away, back
34
+ yPositive = 0x03,
35
+ // Towards, forward
36
+ yNegative = 0x04,
37
+ // Vertical UP
38
+ zPositive = 0x05,
39
+ // Vertical down
40
+ zNegative = 0x06,
41
+ // Rotate positive around the X axis
42
+ aPositive = 0x07,
43
+ // Rotate negative around the X axis
44
+ aNegative = 0x08,
45
+ // Rotate positive around the Y axis
46
+ bPositive = 0x09,
47
+ // Rotate negative around the Y axis
48
+ bNegative = 0x10,
49
+ // Rotate positive around the Z axis
50
+ cPositive = 0x11,
51
+ // Rotate negative around the Z axis
52
+ cNegative = 0x12,
53
+
54
+ /** Stop, clear or reset */
55
+ Stop = 0xFF,
56
+ }
57
+
58
+
59
+ /**
60
+ * Enumerates the selected jog distance.
61
+ */
62
+ export enum JogDistanceAction {
63
+ Short = 0x00,
64
+ Medium = 0x10,
65
+ Long = 0x20
66
+ }
67
+
68
+ /**
69
+ * Enumerates the selected jog distance.
70
+ */
71
+ export enum JogSpeedAction {
72
+ Slow = 0x00,
73
+ Medium = 0x10,
74
+ Fast = 0x20
75
+ }
76
+
77
+
78
+ /**
79
+ * Jog button definition type for defining the button in the JogPanel.
80
+ */
81
+ export interface JogPanelButtonDefinition {
82
+ icon: string;
83
+ alt: string;
84
+ action: JogPanelAction
85
+ }
86
+
87
+ /**
88
+ * Interface for the jog distance select button.
89
+ */
90
+ interface JogDistanceItem {
91
+ name: string;
92
+ value: JogDistanceAction;
93
+ }
94
+
95
+ /**
96
+ * Interface for the jog speed select button.
97
+ */
98
+ interface JogSpeedItem {
99
+ name: string;
100
+ value: JogSpeedAction;
101
+ }
102
+
103
+ /**
104
+ * Component properties of the directional pad.
105
+ */
106
+ interface JogPanelProps {
107
+ onClicked?: (action: JogPanelAction) => void;
108
+ onJogDistanceChanged?: (action: JogDistanceAction) => void;
109
+ onJogSpeedChanged?: (action: JogSpeedAction) => void;
110
+ buttonDefinitions: (JogPanelButtonDefinition | undefined)[][] | undefined;
111
+ defaultJogDistance : JogDistanceAction;
112
+ defaultJogSpeed : JogSpeedAction;
113
+ showDistanceControl : boolean;
114
+ showSpeedControl : boolean;
115
+ }
116
+
117
+
118
+ interface JogPanelState {
119
+ jogDistance : JogDistanceAction,
120
+ jogSpeed : JogSpeedAction
121
+ }
122
+
123
+
124
+ /**
125
+ * A default jog button configuration for linear 3D motion.
126
+ */
127
+ export const DefaultLinearJogButtons : (JogPanelButtonDefinition | undefined)[][] = [
128
+ [{ icon: "pi pi-arrow-up-left", action: JogPanelAction.yPositive, alt: "Y Positive" }, { icon: "pi pi-arrow-up", action: JogPanelAction.zPositive, alt: "Z Positive" }, undefined],
129
+ [{ icon: "pi pi-arrow-left", action: JogPanelAction.xNegative, alt: "X Negative" }, undefined, { icon: "pi pi-arrow-right", action: JogPanelAction.xPositive, alt: "X Positive" }],
130
+ [undefined, { icon: "pi pi-arrow-down", action: JogPanelAction.zNegative, alt: "Z Negative" }, { icon: "pi pi-arrow-down-right", action: JogPanelAction.yNegative, alt: "Y Negative" }],
131
+ ];
132
+
133
+ /**
134
+ * A default jog button configuration for rotational 3D motion.
135
+ */
136
+ export const DefaultRotationJogButtons : (JogPanelButtonDefinition | undefined)[][] = [
137
+ [{ icon: "pi", action: JogPanelAction.bPositive, alt: "Rot B Positive" }, { icon: "pi", action: JogPanelAction.cPositive, alt: "Rot C Positive" }, undefined],
138
+ [{ icon: "pi", action: JogPanelAction.aNegative, alt: "Rot A Negative" }, undefined, { icon: "pi", action: JogPanelAction.aPositive, alt: "Rot A Positive" }],
139
+ [undefined, { icon: "pi", action: JogPanelAction.cNegative, alt: "Rot C Negative" }, { icon: "pi ", action: JogPanelAction.bNegative, alt: "Rot B Negative" }],
140
+ ];
141
+
142
+ /**
143
+ * Jogging panel that supports 3D motion. In 3D:
144
+ * - Z is Up and Down,
145
+ * - Y is towards and away
146
+ * - X is left and right
147
+ *
148
+ * This Jog Panel is based upon a standard CNC mill and industrial standards.
149
+ *
150
+ * ## Parameters
151
+ * @param onClicked Callback any time a button is clicked. Includes argument for direction.
152
+ * @param buttonDefinitions A 3x3 matrix of (JogPanelButtonDefinition | undefined) that defines the button. If a button is undefined, it is disabled.
153
+ *
154
+ * ## Button definitions
155
+ *
156
+ * Example:
157
+ * ```
158
+ * export const kDefaultButtonDefinitions : (JogPanelButtonDefinition | undefined)[][] = [
159
+ * [{ icon: "pi pi-arrow-up-left", action: JogPanelAction.yPositive, alt: "Y Positive" }, { icon: "pi pi-arrow-up", action: JogPanelAction.zPositive, alt: "Z Positive" }, undefined],
160
+ * [{ icon: "pi pi-arrow-left", action: JogPanelAction.xNegative, alt: "X Negative" }, undefined, { icon: "pi pi-arrow-right", action: JogPanelAction.xPositive, alt: "X Positive" }],
161
+ * [undefined, { icon: "pi pi-arrow-down", action: JogPanelAction.zNegative, alt: "Z Negative" }, { icon: "pi pi-arrow-down-right", action: JogPanelAction.yNegative, alt: "Y Negative" }],
162
+ * ];
163
+ * ```
164
+ *
165
+ */
166
+ export class JogPanel extends React.Component<JogPanelProps, JogPanelState> {
167
+
168
+ static defaultProps : JogPanelProps = {
169
+ onClicked: undefined,
170
+ onJogDistanceChanged: undefined,
171
+ buttonDefinitions: DefaultLinearJogButtons,
172
+ defaultJogDistance : JogDistanceAction.Short,
173
+ defaultJogSpeed : JogSpeedAction.Medium,
174
+ showDistanceControl : true,
175
+ showSpeedControl : true
176
+ };
177
+
178
+
179
+ private jogDistanceItems: JogDistanceItem[] = [
180
+ {name: 'S', value: JogDistanceAction.Short},
181
+ {name: 'M', value: JogDistanceAction.Medium},
182
+ {name: 'L', value: JogDistanceAction.Long}
183
+ ];
184
+
185
+ private jogSpeedItems: JogSpeedItem[] = [
186
+ {name: 'S', value: JogSpeedAction.Slow},
187
+ {name: 'M', value: JogSpeedAction.Medium},
188
+ {name: 'F', value: JogSpeedAction.Fast}
189
+ ];
190
+
191
+
192
+ constructor(props: JogPanelProps) {
193
+ super(props);
194
+
195
+ this.state = {
196
+ jogDistance : props.defaultJogDistance,
197
+ jogSpeed : props.defaultJogSpeed
198
+ }
199
+ }
200
+
201
+
202
+ /**
203
+ * Handle a user action on the DirectionalPad
204
+ * @param action DirectionalPadAction
205
+ */
206
+ private handleClicked(action: JogPanelAction | undefined) {
207
+
208
+ if (action === undefined || action === null)
209
+ return;
210
+
211
+ if (this.props.onClicked) {
212
+ this.props.onClicked(action);
213
+ }
214
+
215
+ };
216
+
217
+ /**
218
+ * The user has selected a different jog distance.
219
+ * @param {JogDistanceAction} action The newly-selected distance.
220
+ */
221
+ private handleDistanceChanged(action : JogDistanceAction) {
222
+ this.setState({jogDistance: action});
223
+ if (this.props.onJogDistanceChanged) {
224
+ this.props.onJogDistanceChanged(action);
225
+ }
226
+ }
227
+
228
+ private handleSpeedChanged(action : JogSpeedAction) {
229
+ this.setState({jogSpeed: action});
230
+ if (this.props.onJogSpeedChanged) {
231
+ this.props.onJogSpeedChanged(action);
232
+ }
233
+ }
234
+
235
+
236
+ emptyRow() {
237
+ return <div className="grid-row">
238
+ <div className="button-item empty-slot" />
239
+ <div className="button-item empty-slot" />
240
+ <div className="button-item empty-slot" />
241
+ </div>
242
+ }
243
+
244
+ private actionToIcon(action : JogPanelAction | undefined) {
245
+ if (action == JogPanelAction.Invalid) {
246
+ return <i/>
247
+ }
248
+ else if (action == JogPanelAction.Stop) {
249
+ return <i/>
250
+ }
251
+ else if (action == JogPanelAction.xNegative) {
252
+ return <i className="pi pi-arrow-left" />
253
+ }
254
+ else if (action == JogPanelAction.xPositive) {
255
+ return <i className="pi pi-arrow-right" />
256
+ }
257
+ else if (action == JogPanelAction.yNegative) {
258
+ return <i className="pi pi-arrow-up-left" />
259
+ }
260
+ else if (action == JogPanelAction.yPositive) {
261
+ return <i className="pi pi-arrow-down-right" />
262
+ }
263
+ else if (action == JogPanelAction.zNegative) {
264
+ return <i className="pi pi-up" />
265
+ }
266
+ else if (action == JogPanelAction.zPositive) {
267
+ return <i className="pi pi-down" />
268
+ }
269
+ else if (action == JogPanelAction.aNegative) {
270
+ return <RotationCcwA />
271
+ }
272
+ else if (action == JogPanelAction.aPositive) {
273
+ return <RotationCwA />
274
+ }
275
+ else if (action == JogPanelAction.bNegative) {
276
+ return <RotationCcwB />
277
+ }
278
+ else if (action == JogPanelAction.bPositive) {
279
+ return <RotationCwB />
280
+ }
281
+ else if (action == JogPanelAction.cNegative) {
282
+ return <RotationCcwC />
283
+ }
284
+ else if (action == JogPanelAction.cPositive) {
285
+ return <RotationCwC />
286
+ }
287
+ else {
288
+ return <i />
289
+ }
290
+
291
+ }
292
+
293
+ standardButton(row : number, col : number) {
294
+
295
+ if (this.props.buttonDefinitions !== undefined
296
+ && this.props.buttonDefinitions[row] !== undefined
297
+ && this.props.buttonDefinitions[row][col] !== undefined
298
+ && this.props.buttonDefinitions[row][col]?.action !== undefined ) {
299
+
300
+ const action = this.props.buttonDefinitions[row][col]?.action;
301
+
302
+ if (action !== undefined && action < JogPanelAction.aPositive ) {
303
+ return <Button
304
+ key={`${row}-${col}`}
305
+ icon={this.props.buttonDefinitions[row][col]?.icon}
306
+ tooltip={this.props.buttonDefinitions[row][col]?.alt}
307
+ onClick={() => this.handleClicked(action)}
308
+ className="button-item"
309
+ />
310
+ }
311
+ else {
312
+ return <Button
313
+ key={`${row}-${col}`}
314
+ tooltip={this.props.buttonDefinitions[row][col]?.alt}
315
+ onClick={() => this.handleClicked(action)}
316
+ className="button-item"
317
+ icon={() => this.actionToIcon(action)}/>
318
+ }
319
+
320
+ }
321
+ else {
322
+ return <Button icon="pi" key={`${row}-${col}`} disabled={true} className="button-item empty-slot" />
323
+ }
324
+
325
+
326
+ }
327
+
328
+ render() {
329
+
330
+
331
+ const distanceButtonTemplate = (option: JogDistanceItem) => {
332
+ if (option.value == JogDistanceAction.Short) {
333
+ return <JogShort className="distance-selector-button" width={16} height={16}
334
+ data-pr-tooltip="Short Distance"
335
+ data-pr-position="bottom"
336
+ fill="white"
337
+ />
338
+ }
339
+ else if (option.value == JogDistanceAction.Medium) {
340
+ return <JogMedium className="distance-selector-button" width={16} height={16}
341
+ data-pr-tooltip="Medium Distance"
342
+ data-pr-position="bottom"
343
+ fill="white"
344
+ />;
345
+ }
346
+ else {
347
+ return <JogLong className="distance-selector-button" width={16} height={16}
348
+ data-pr-tooltip="Long Distance"
349
+ data-pr-position="bottom"
350
+ fill="white"
351
+ />;
352
+ }
353
+
354
+ }
355
+
356
+
357
+ const speedButtonTemplate = (option: JogSpeedItem) => {
358
+ if (option.value == JogSpeedAction.Slow) {
359
+ return <SpeedSlow className="distance-selector-button" width={16} height={16}
360
+ data-pr-tooltip="Slow Speed"
361
+ data-pr-position="bottom"
362
+ fill="white"
363
+ />
364
+ }
365
+ else if (option.value == JogSpeedAction.Medium) {
366
+ return <SpeedMedium className="distance-selector-button" width={16} height={16}
367
+ data-pr-tooltip="Medium Speed"
368
+ data-pr-position="bottom"
369
+ fill="white"
370
+ />;
371
+ }
372
+ else {
373
+ return <SpeedFast className="distance-selector-button" width={16} height={16}
374
+ data-pr-tooltip="Fast Speed"
375
+ data-pr-position="bottom"
376
+ fill="white"
377
+ />;
378
+ }
379
+
380
+ }
381
+
382
+ // const jogButtonTemplate = (option: JogDistanceItem) => {
383
+ // if (option.value == JogDistanceAction.Short) {
384
+ // return <svg xmlns="http://www.w3.org/2000/svg" height="16" viewBox="0 -960 960 960" width="24" fill="white">
385
+ // <path d="M800-80v-800h80v800h-80ZM560-280v-400h120v400H560Zm-240 0"/>
386
+ // </svg>;
387
+ // }
388
+ // else if (option.value == JogDistanceAction.Medium) {
389
+ // return <svg xmlns="http://www.w3.org/2000/svg" height="16" viewBox="0 -960 960 960" width="24" fill="white">
390
+ // <path d="M800-80v-800h80v800h-80ZM560-280v-400h120v400H560Zm-240 0v-400h120v400H320Z"/>
391
+ // </svg>;
392
+ // }
393
+ // else {
394
+ // return <svg xmlns="http://www.w3.org/2000/svg" height="16" viewBox="0 -960 960 960" width="24" fill="white">
395
+ // <path d="M800-80v-800h80v800h-80ZM560-280v-400h120v400H560Zm-240 0v-400h120v400H320Zm-240 0v-400h120v400H320Z"/>
396
+ // </svg>;
397
+ // }
398
+ // }
399
+
400
+ return (
401
+ <div className="jogpanel-container">
402
+ <Tooltip target=".distance-selector-button" />
403
+
404
+ <div className="grid-container">
405
+ <div key="0" className="grid-row">
406
+ {this.standardButton(0,0)}
407
+ {this.standardButton(0,1)}
408
+ {this.standardButton(0,2)}
409
+ </div>
410
+ <div key="1" className="grid-row">
411
+ {this.standardButton(1,0)}
412
+ {this.standardButton(1,1)}
413
+ {this.standardButton(1,2)}
414
+ </div>
415
+ <div key="2" className="grid-row">
416
+ {this.standardButton(2,0)}
417
+ {this.standardButton(2,1)}
418
+ {this.standardButton(2,2)}
419
+ </div>
420
+ </div>
421
+
422
+ { this.props.showDistanceControl &&
423
+ <div className="distance-selector p-inputgroup flex-1">
424
+ <span className="p-inputgroup-addon">
425
+ <Distance width={16} height={16} fill="white" />
426
+ </span>
427
+ <SelectButton
428
+ value={this.state.jogDistance}
429
+ onChange={(e) => this.handleDistanceChanged(e.value)}
430
+ optionLabel="name"
431
+ options={this.jogDistanceItems}
432
+ allowEmpty={false}
433
+ itemTemplate={distanceButtonTemplate}
434
+ />
435
+ </div>
436
+ }
437
+
438
+ {this.props.showSpeedControl &&
439
+ <div className="distance-selector p-inputgroup flex-1">
440
+ <span className="p-inputgroup-addon">
441
+ <Speed width={16} height={16} fill="white" />
442
+ </span>
443
+ <SelectButton
444
+ value={this.state.jogSpeed}
445
+ onChange={(e) => this.handleSpeedChanged(e.value)}
446
+ optionLabel="name"
447
+ options={this.jogSpeedItems}
448
+ allowEmpty={false}
449
+ itemTemplate={speedButtonTemplate}
450
+ />
451
+ </div>
452
+ }
453
+
454
+ </div>
455
+ );
456
+ }
457
+ };
458
+
459
+ export default JogPanel;
460
+
461
+
@@ -0,0 +1,243 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
+ * Created Date: 2024-01-16 14:39:41
4
+ * -----
5
+ * Last Modified: 2024-03-12 21:12:29
6
+ * -----
7
+ *
8
+ */
9
+
10
+
11
+
12
+ // import { useContext } from 'react';
13
+ // import clsx from 'clsx';
14
+
15
+ // import DimensionsContext from '../core/DimensionsContext';
16
+
17
+
18
+
19
+ // /**
20
+ // * Displays boolean values<br/>
21
+ // * Supports 3 states: **on**, **off** and **invalid/not available**:
22
+ // */
23
+ // const Indicator = ({
24
+ // value: value,
25
+ // x,
26
+ // y,
27
+ // width = 22,
28
+ // height = width,
29
+ // className,
30
+ // onColor: onColor = IndicatorGreen,
31
+ // offColor: offColor = IndicatorOff,
32
+ // invalidColor: invalidColor = IndicatorInvalid,
33
+ // useAbsolutePositioning = false, // Default to false
34
+ // }: Props): JSX.Element => {
35
+ // const { scale, xOffset, yOffset } = useContext(DimensionsContext);
36
+
37
+ // let color;
38
+ // switch (value) {
39
+ // case true:
40
+ // color = onColor;
41
+ // break;
42
+ // case false:
43
+ // color = offColor;
44
+ // break;
45
+ // default:
46
+ // color = invalidColor;
47
+ // break;
48
+ // }
49
+
50
+ // return (
51
+ // <div
52
+ // className={clsx(className)}
53
+ // style={{
54
+ // position: useAbsolutePositioning ? 'absolute' : 'relative',
55
+ // display: useAbsolutePositioning ? "": "inline-block",
56
+ // verticalAlign: 'middle',
57
+ // top: useAbsolutePositioning && y ? `${yOffset + scale * y}px` : undefined,
58
+ // left: useAbsolutePositioning && x? `${xOffset + scale * x}px` : undefined,
59
+ // width: width ? `${width * scale}px` : undefined,
60
+ // height: height ? `${height * scale}px` : undefined,
61
+ // lineHeight: height ? `${height * scale}px` : undefined,
62
+ // backgroundColor: color,
63
+ // borderRadius: "20px"
64
+ // }}
65
+ // />
66
+ // );
67
+ // };
68
+
69
+ // export { Indicator };
70
+
71
+
72
+
73
+
74
+ import React, { Component } from 'react';
75
+ import clsx from 'clsx';
76
+ import { EventEmitterContext, EventEmitterContextType } from '../core/EventEmitterContext';
77
+ import { IPositionContext } from '../core/PositionContext';
78
+ import {IndicatorColor} from "../core/IndicatorColor";
79
+ export {IndicatorColor}
80
+
81
+
82
+
83
+
84
+ interface LampProps {
85
+ /**
86
+ * State to be displayed<br/>
87
+ *
88
+ * Available states: **on**, **off** and **not available**:
89
+ *
90
+ * * `true` is treated as **on**
91
+ * * `false` is treated as **off**
92
+ * * `undefined` is treated as **not available**
93
+ */
94
+ value?: boolean | undefined;
95
+ /**
96
+ * X position (in pixels)
97
+ */
98
+ x?: number;
99
+ /**
100
+ * Y position (in pixels)
101
+ */
102
+ y?: number;
103
+ /**
104
+ * Width (in pixels)
105
+ */
106
+ width?: number;
107
+ /**
108
+ * Height (in pixels)<br/>
109
+ * @default width
110
+ */
111
+ height?: number;
112
+ /**
113
+ * CSS color for **enabled** state
114
+ */
115
+ onColor?: string;
116
+ /**
117
+ * CSS color for **disabled** state
118
+ */
119
+ offColor?: string;
120
+ /**
121
+ * CSS color for **not available** state
122
+ */
123
+ invalidColor?: string;
124
+ /**
125
+ * Custom class name to be attached
126
+ */
127
+ className?: string;
128
+
129
+
130
+ /**
131
+ * Enable absolute positioning for the component, allowing it to be
132
+ * placed on a specific position of its parent. This is useful when
133
+ * laying components over an image or wireframe.
134
+ */
135
+ useAbsolutePositioning?: boolean;
136
+
137
+ /**
138
+ * The topic to monitor to display. Optional.
139
+ */
140
+ topic?: string;
141
+ }
142
+
143
+
144
+ interface LampState {
145
+ subscribedValue?: boolean | null;
146
+ fontSize?: string;
147
+ }
148
+
149
+
150
+ export class Lamp extends Component<LampProps, LampState> {
151
+ static contextType = EventEmitterContext;
152
+ protected unsubscribeTopicId: number | null = null;
153
+
154
+ // Define default properties
155
+ static defaultProps = {
156
+ width: 22,
157
+ height: 22,
158
+ onColor: "green",
159
+ offColor: "gray",
160
+ invalidColor: "black",
161
+ useAbsolutePositioning: false
162
+ };
163
+
164
+ constructor(props: LampProps) {
165
+ super(props);
166
+ this.state = {
167
+ subscribedValue: props.value,
168
+ fontSize: "100%"
169
+ };
170
+ }
171
+
172
+ componentDidMount() {
173
+ const { topic } = this.props;
174
+ if (topic && this.unsubscribeTopicId === null) {
175
+ const { subscribe } = this.context as EventEmitterContextType;
176
+ this.unsubscribeTopicId = subscribe(topic, (value: any) => {
177
+ this.setState({ subscribedValue: value });
178
+ });
179
+ }
180
+ }
181
+
182
+ componentDidUpdate(prevProps: LampProps) {
183
+ if (prevProps.value !== this.props.value) {
184
+ this.setState({ subscribedValue: this.props.value });
185
+ }
186
+ }
187
+
188
+ componentWillUnmount() {
189
+ if (this.unsubscribeTopicId !== null) {
190
+ const { unsubscribe } = this.context as EventEmitterContextType;
191
+ unsubscribe(this.unsubscribeTopicId);
192
+ this.unsubscribeTopicId = null;
193
+ }
194
+ }
195
+
196
+ render() {
197
+ const { x, y, width, height, className, onColor, offColor, invalidColor, useAbsolutePositioning } = this.props;
198
+ const { scale, xOffset, yOffset } = this.context as IPositionContext;
199
+ const { subscribedValue } = this.state;
200
+
201
+ let adjWidth = width || 10;
202
+ if (adjWidth < 10)
203
+ adjWidth = 10;
204
+ let adjHeight = height || 10;
205
+ if (adjHeight < 10)
206
+ adjHeight = 10;
207
+ let adjScale = scale || 1;
208
+ if (adjScale === 0)
209
+ adjScale = 1;
210
+
211
+ let color;
212
+ switch (subscribedValue) {
213
+ case true:
214
+ color = onColor;
215
+ break;
216
+ case false:
217
+ color = offColor;
218
+ break;
219
+ default:
220
+ color = invalidColor;
221
+ break;
222
+ }
223
+
224
+ const style: React.CSSProperties = {
225
+ position: useAbsolutePositioning ? 'absolute' : 'relative',
226
+ display: useAbsolutePositioning ? "" : "inline-block",
227
+ verticalAlign: 'middle',
228
+ top: useAbsolutePositioning && y ? `${yOffset + adjScale * y}px` : undefined,
229
+ left: useAbsolutePositioning && x ? `${xOffset + adjScale * x}px` : undefined,
230
+ width: adjWidth ? `${adjWidth * adjScale}px` : undefined,
231
+ height: adjHeight ? `${adjHeight * adjScale}px` : undefined,
232
+ lineHeight: adjHeight ? `${adjHeight * adjScale}px` : undefined,
233
+ backgroundColor: color,
234
+ borderRadius: "20px"
235
+ };
236
+
237
+ return (
238
+ <div className={clsx(className)} style={style} />
239
+ );
240
+ }
241
+ }
242
+
243
+ export default Lamp;