@duet3d/objectmodel 3.7.0-alpha.7 → 3.7.0-alpha.9

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 (244) hide show
  1. package/dist/ModelCollection.d.ts +1 -1
  2. package/dist/ModelCollection.js +10 -15
  3. package/dist/ModelDictionary.d.ts +1 -1
  4. package/dist/ModelDictionary.js +7 -12
  5. package/dist/ModelObject.js +8 -14
  6. package/dist/ModelSet.js +2 -6
  7. package/dist/ObjectModel.js +42 -49
  8. package/dist/boards/Driver.js +6 -13
  9. package/dist/boards/directDisplay/DirectDisplayScreen.d.ts +1 -1
  10. package/dist/boards/directDisplay/DirectDisplayScreen.js +5 -12
  11. package/dist/boards/directDisplay/DirectDisplayScreenBase.js +4 -10
  12. package/dist/boards/directDisplay/DirectDisplayScreenST7567.d.ts +1 -1
  13. package/dist/boards/directDisplay/DirectDisplayScreenST7567.js +6 -13
  14. package/dist/boards/directDisplay/index.js +16 -38
  15. package/dist/boards/index.js +22 -46
  16. package/dist/directories/index.js +3 -10
  17. package/dist/fans/index.js +4 -12
  18. package/dist/heat/Heater.js +10 -17
  19. package/dist/heat/HeaterModel.js +4 -12
  20. package/dist/heat/HeaterMonitor.js +7 -14
  21. package/dist/heat/index.js +9 -30
  22. package/dist/index.js +26 -46
  23. package/dist/inputs/CodeChannel.js +3 -6
  24. package/dist/inputs/Compatibility.js +3 -6
  25. package/dist/inputs/InputChannel.js +9 -16
  26. package/dist/inputs/index.js +3 -19
  27. package/dist/job/Build.js +6 -14
  28. package/dist/job/GCodeFileInfo.js +8 -15
  29. package/dist/job/ThumbnailInfo.js +5 -9
  30. package/dist/job/index.js +15 -38
  31. package/dist/ledStrips/index.js +5 -12
  32. package/dist/limits/index.js +3 -10
  33. package/dist/messages/index.js +5 -12
  34. package/dist/move/Axis.js +10 -17
  35. package/dist/move/DriverId.d.ts +2 -1
  36. package/dist/move/DriverId.js +4 -12
  37. package/dist/move/Extruder.js +9 -18
  38. package/dist/move/InputShaping.js +5 -12
  39. package/dist/move/KeepoutZone.js +5 -10
  40. package/dist/move/Microstepping.js +3 -10
  41. package/dist/move/MotionSystem.js +9 -16
  42. package/dist/move/MoveCalibration.js +4 -12
  43. package/dist/move/MoveCompensation.js +10 -19
  44. package/dist/move/index.js +35 -60
  45. package/dist/move/kinematics/CoreKinematics.d.ts +1 -1
  46. package/dist/move/kinematics/CoreKinematics.js +5 -9
  47. package/dist/move/kinematics/DeltaKinematics.d.ts +2 -1
  48. package/dist/move/kinematics/DeltaKinematics.js +9 -17
  49. package/dist/move/kinematics/HangprinterKinematics.d.ts +1 -1
  50. package/dist/move/kinematics/HangprinterKinematics.js +6 -43
  51. package/dist/move/kinematics/KinematicsBase.js +8 -18
  52. package/dist/move/kinematics/PolarKinematics.d.ts +1 -1
  53. package/dist/move/kinematics/PolarKinematics.js +6 -43
  54. package/dist/move/kinematics/ScaraKinematics.d.ts +1 -1
  55. package/dist/move/kinematics/ScaraKinematics.js +5 -9
  56. package/dist/move/kinematics/index.d.ts +1 -1
  57. package/dist/move/kinematics/index.js +35 -79
  58. package/dist/network/NetworkInterface.js +11 -18
  59. package/dist/network/index.js +12 -33
  60. package/dist/plugins/PluginManifest.d.ts +2 -1
  61. package/dist/plugins/PluginManifest.js +7 -14
  62. package/dist/plugins/index.js +4 -25
  63. package/dist/sbc/CPU.js +3 -10
  64. package/dist/sbc/Memory.js +3 -10
  65. package/dist/sbc/dsf/HttpEndpoint.js +5 -12
  66. package/dist/sbc/dsf/UserSession.js +7 -14
  67. package/dist/sbc/dsf/index.js +9 -30
  68. package/dist/sbc/index.js +12 -33
  69. package/dist/sensors/AnalogSensor.js +7 -14
  70. package/dist/sensors/Endstop.js +5 -12
  71. package/dist/sensors/FilamentMonitors/Duet3DFilamentMonitor.js +4 -8
  72. package/dist/sensors/FilamentMonitors/FilamentMonitorBase.js +9 -16
  73. package/dist/sensors/FilamentMonitors/LaserFilamentMonitor.d.ts +2 -1
  74. package/dist/sensors/FilamentMonitors/LaserFilamentMonitor.js +11 -20
  75. package/dist/sensors/FilamentMonitors/PulsedFilamentMonitor.d.ts +2 -1
  76. package/dist/sensors/FilamentMonitors/PulsedFilamentMonitor.js +10 -52
  77. package/dist/sensors/FilamentMonitors/RotatingMagnetFilamentMonitor.d.ts +2 -1
  78. package/dist/sensors/FilamentMonitors/RotatingMagnetFilamentMonitor.js +11 -20
  79. package/dist/sensors/FilamentMonitors/index.d.ts +1 -1
  80. package/dist/sensors/FilamentMonitors/index.js +18 -62
  81. package/dist/sensors/Probe.js +7 -15
  82. package/dist/sensors/index.js +18 -40
  83. package/dist/spindles/index.js +7 -14
  84. package/dist/state/MachineStatus.js +3 -6
  85. package/dist/state/MessageBox.d.ts +2 -1
  86. package/dist/state/MessageBox.js +5 -12
  87. package/dist/state/RestorePoint.js +3 -10
  88. package/dist/state/index.js +23 -47
  89. package/dist/tools/ToolRetraction.js +3 -10
  90. package/dist/tools/index.js +7 -14
  91. package/dist/volumes/index.js +3 -10
  92. package/package.json +12 -3
  93. package/dist/httpEndpoints/index.d.ts +0 -19
  94. package/dist/httpEndpoints/index.js +0 -27
  95. package/dist/src/ModelCollection.d.ts +0 -36
  96. package/dist/src/ModelCollection.js +0 -108
  97. package/dist/src/ModelDictionary.d.ts +0 -44
  98. package/dist/src/ModelDictionary.js +0 -109
  99. package/dist/src/ModelObject.d.ts +0 -55
  100. package/dist/src/ModelObject.js +0 -237
  101. package/dist/src/ModelSet.d.ts +0 -11
  102. package/dist/src/ModelSet.js +0 -15
  103. package/dist/src/ObjectModel.d.ts +0 -47
  104. package/dist/src/ObjectModel.js +0 -57
  105. package/dist/src/boards/Driver.d.ts +0 -18
  106. package/dist/src/boards/Driver.js +0 -37
  107. package/dist/src/boards/directDisplay/DirectDisplayScreen.d.ts +0 -6
  108. package/dist/src/boards/directDisplay/DirectDisplayScreen.js +0 -21
  109. package/dist/src/boards/directDisplay/DirectDisplayScreenBase.d.ts +0 -11
  110. package/dist/src/boards/directDisplay/DirectDisplayScreenBase.js +0 -19
  111. package/dist/src/boards/directDisplay/DirectDisplayScreenST7567.d.ts +0 -9
  112. package/dist/src/boards/directDisplay/DirectDisplayScreenST7567.js +0 -26
  113. package/dist/src/boards/directDisplay/index.d.ts +0 -20
  114. package/dist/src/boards/directDisplay/index.js +0 -59
  115. package/dist/src/boards/index.d.ts +0 -59
  116. package/dist/src/boards/index.js +0 -103
  117. package/dist/src/directories/index.d.ts +0 -11
  118. package/dist/src/directories/index.js +0 -21
  119. package/dist/src/fans/index.d.ts +0 -19
  120. package/dist/src/fans/index.js +0 -33
  121. package/dist/src/heat/Heater.d.ts +0 -30
  122. package/dist/src/heat/Heater.js +0 -41
  123. package/dist/src/heat/HeaterModel.d.ts +0 -21
  124. package/dist/src/heat/HeaterModel.js +0 -35
  125. package/dist/src/heat/HeaterMonitor.d.ts +0 -19
  126. package/dist/src/heat/HeaterMonitor.js +0 -31
  127. package/dist/src/heat/index.d.ts +0 -22
  128. package/dist/src/heat/index.js +0 -46
  129. package/dist/src/index.d.ts +0 -26
  130. package/dist/src/index.js +0 -57
  131. package/dist/src/inputs/CodeChannel.d.ts +0 -18
  132. package/dist/src/inputs/CodeChannel.js +0 -22
  133. package/dist/src/inputs/Compatibility.d.ts +0 -10
  134. package/dist/src/inputs/Compatibility.js +0 -14
  135. package/dist/src/inputs/InputChannel.d.ts +0 -32
  136. package/dist/src/inputs/InputChannel.js +0 -44
  137. package/dist/src/inputs/index.d.ts +0 -3
  138. package/dist/src/inputs/index.js +0 -19
  139. package/dist/src/job/Build.d.ts +0 -15
  140. package/dist/src/job/Build.js +0 -29
  141. package/dist/src/job/GCodeFileInfo.d.ts +0 -19
  142. package/dist/src/job/GCodeFileInfo.js +0 -29
  143. package/dist/src/job/ThumbnailInfo.d.ts +0 -15
  144. package/dist/src/job/ThumbnailInfo.js +0 -23
  145. package/dist/src/job/index.d.ts +0 -45
  146. package/dist/src/job/index.js +0 -78
  147. package/dist/src/ledStrips/index.d.ts +0 -13
  148. package/dist/src/ledStrips/index.js +0 -24
  149. package/dist/src/limits/index.d.ts +0 -32
  150. package/dist/src/limits/index.js +0 -42
  151. package/dist/src/messages/index.d.ts +0 -13
  152. package/dist/src/messages/index.js +0 -30
  153. package/dist/src/move/Axis.d.ts +0 -71
  154. package/dist/src/move/Axis.js +0 -82
  155. package/dist/src/move/DriverId.d.ts +0 -10
  156. package/dist/src/move/DriverId.js +0 -52
  157. package/dist/src/move/Extruder.d.ts +0 -39
  158. package/dist/src/move/Extruder.js +0 -57
  159. package/dist/src/move/InputShaping.d.ts +0 -19
  160. package/dist/src/move/InputShaping.js +0 -30
  161. package/dist/src/move/KeepoutZone.d.ts +0 -10
  162. package/dist/src/move/KeepoutZone.js +0 -21
  163. package/dist/src/move/Microstepping.d.ts +0 -6
  164. package/dist/src/move/Microstepping.js +0 -16
  165. package/dist/src/move/MotionSystem.d.ts +0 -20
  166. package/dist/src/move/MotionSystem.js +0 -30
  167. package/dist/src/move/MoveCalibration.d.ts +0 -11
  168. package/dist/src/move/MoveCalibration.js +0 -25
  169. package/dist/src/move/MoveCompensation.d.ts +0 -30
  170. package/dist/src/move/MoveCompensation.js +0 -50
  171. package/dist/src/move/index.d.ts +0 -80
  172. package/dist/src/move/index.js +0 -120
  173. package/dist/src/move/kinematics/CoreKinematics.d.ts +0 -9
  174. package/dist/src/move/kinematics/CoreKinematics.js +0 -31
  175. package/dist/src/move/kinematics/DeltaKinematics.d.ts +0 -20
  176. package/dist/src/move/kinematics/DeltaKinematics.js +0 -43
  177. package/dist/src/move/kinematics/HangprinterKinematics.d.ts +0 -9
  178. package/dist/src/move/kinematics/HangprinterKinematics.js +0 -61
  179. package/dist/src/move/kinematics/KinematicsBase.d.ts +0 -37
  180. package/dist/src/move/kinematics/KinematicsBase.js +0 -59
  181. package/dist/src/move/kinematics/PolarKinematics.d.ts +0 -12
  182. package/dist/src/move/kinematics/PolarKinematics.js +0 -59
  183. package/dist/src/move/kinematics/ScaraKinematics.d.ts +0 -14
  184. package/dist/src/move/kinematics/ScaraKinematics.js +0 -29
  185. package/dist/src/move/kinematics/index.d.ts +0 -14
  186. package/dist/src/move/kinematics/index.js +0 -98
  187. package/dist/src/network/NetworkInterface.d.ts +0 -46
  188. package/dist/src/network/NetworkInterface.js +0 -59
  189. package/dist/src/network/index.d.ts +0 -14
  190. package/dist/src/network/index.js +0 -38
  191. package/dist/src/plugins/PluginManifest.d.ts +0 -67
  192. package/dist/src/plugins/PluginManifest.js +0 -128
  193. package/dist/src/plugins/index.d.ts +0 -9
  194. package/dist/src/plugins/index.js +0 -33
  195. package/dist/src/sbc/CPU.d.ts +0 -8
  196. package/dist/src/sbc/CPU.js +0 -18
  197. package/dist/src/sbc/Memory.d.ts +0 -6
  198. package/dist/src/sbc/Memory.js +0 -16
  199. package/dist/src/sbc/dsf/HttpEndpoint.d.ts +0 -19
  200. package/dist/src/sbc/dsf/HttpEndpoint.js +0 -30
  201. package/dist/src/sbc/dsf/UserSession.d.ts +0 -18
  202. package/dist/src/sbc/dsf/UserSession.js +0 -30
  203. package/dist/src/sbc/dsf/index.d.ts +0 -15
  204. package/dist/src/sbc/dsf/index.js +0 -39
  205. package/dist/src/sbc/index.d.ts +0 -19
  206. package/dist/src/sbc/index.js +0 -43
  207. package/dist/src/sensors/AnalogSensor.d.ts +0 -59
  208. package/dist/src/sensors/AnalogSensor.js +0 -71
  209. package/dist/src/sensors/Endstop.d.ts +0 -15
  210. package/dist/src/sensors/Endstop.js +0 -26
  211. package/dist/src/sensors/FilamentMonitors/Duet3DFilamentMonitor.d.ts +0 -11
  212. package/dist/src/sensors/FilamentMonitors/Duet3DFilamentMonitor.js +0 -17
  213. package/dist/src/sensors/FilamentMonitors/FilamentMonitorBase.d.ts +0 -33
  214. package/dist/src/sensors/FilamentMonitors/FilamentMonitorBase.js +0 -45
  215. package/dist/src/sensors/FilamentMonitors/LaserFilamentMonitor.d.ts +0 -22
  216. package/dist/src/sensors/FilamentMonitors/LaserFilamentMonitor.js +0 -50
  217. package/dist/src/sensors/FilamentMonitors/PulsedFilamentMonitor.d.ts +0 -22
  218. package/dist/src/sensors/FilamentMonitors/PulsedFilamentMonitor.js +0 -82
  219. package/dist/src/sensors/FilamentMonitors/RotatingMagnetFilamentMonitor.d.ts +0 -22
  220. package/dist/src/sensors/FilamentMonitors/RotatingMagnetFilamentMonitor.js +0 -50
  221. package/dist/src/sensors/FilamentMonitors/index.d.ts +0 -12
  222. package/dist/src/sensors/FilamentMonitors/index.js +0 -77
  223. package/dist/src/sensors/Probe.d.ts +0 -51
  224. package/dist/src/sensors/Probe.js +0 -66
  225. package/dist/src/sensors/index.d.ts +0 -21
  226. package/dist/src/sensors/index.js +0 -49
  227. package/dist/src/spindles/index.d.ts +0 -25
  228. package/dist/src/spindles/index.js +0 -37
  229. package/dist/src/state/MachineStatus.d.ts +0 -17
  230. package/dist/src/state/MachineStatus.js +0 -21
  231. package/dist/src/state/MessageBox.d.ts +0 -26
  232. package/dist/src/state/MessageBox.js +0 -42
  233. package/dist/src/state/RestorePoint.d.ts +0 -11
  234. package/dist/src/state/RestorePoint.js +0 -21
  235. package/dist/src/state/index.d.ts +0 -69
  236. package/dist/src/state/index.js +0 -109
  237. package/dist/src/tools/ToolRetraction.d.ts +0 -9
  238. package/dist/src/tools/ToolRetraction.js +0 -19
  239. package/dist/src/tools/index.d.ts +0 -32
  240. package/dist/src/tools/index.js +0 -43
  241. package/dist/src/volumes/index.d.ts +0 -11
  242. package/dist/src/volumes/index.js +0 -21
  243. package/dist/userSessions/index.d.ts +0 -18
  244. package/dist/userSessions/index.js +0 -27
@@ -1,44 +0,0 @@
1
- import { IModelObject } from "./ModelObject";
2
- /**
3
- * Dictionary class to map object model data
4
- */
5
- export declare class ModelDictionary<T> extends Map<string, T | null> implements IModelObject {
6
- /**
7
- * Constructor of this class
8
- * @param nullDeletesKeys Whether setting null to items effectively deletes them
9
- * @param itemConstructor Item constructor type to use for type-checking
10
- */
11
- constructor(nullDeletesKeys: boolean, itemConstructor?: {
12
- new (): T;
13
- } | null);
14
- /**
15
- * Overridden set method to perform type-checks and update
16
- * @param key Key to set
17
- * @param value Value to set
18
- */
19
- set(key: string, value: T | null): this;
20
- /**
21
- * Update this instance from the given data
22
- * @param jsonElement JSON data to upgrade this instance from
23
- * @returns Updated instance
24
- */
25
- update(jsonElement: any): IModelObject | null;
26
- /**
27
- * Convert this object to JSON
28
- * @returns JSON object
29
- */
30
- toJSON(): Record<string, T | null>;
31
- }
32
- export default ModelDictionary;
33
- /**
34
- * Initialize a model dictionary from the given data
35
- * @param nullDeletesKeys Defines whether setting values to null deletes the corresponding key
36
- * @param itemConstructor Item constructor
37
- * @param data Data to assign
38
- * @returns Initialized model dictionary
39
- */
40
- export declare function initDictionary<T>(nullDeletesKeys: boolean, itemConstructor: {
41
- new (): T;
42
- }, data: Record<string, {
43
- [Property in keyof T]?: T[Property];
44
- }>): ModelDictionary<T>;
@@ -1,109 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModelDictionary = void 0;
4
- exports.initDictionary = initDictionary;
5
- const ModelObject_1 = require("./ModelObject");
6
- /**
7
- * Dictionary class to map object model data
8
- */
9
- class ModelDictionary extends Map {
10
- /**
11
- * Constructor of this class
12
- * @param nullDeletesKeys Whether setting null to items effectively deletes them
13
- * @param itemConstructor Item constructor type to use for type-checking
14
- */
15
- constructor(nullDeletesKeys, itemConstructor = null) {
16
- super();
17
- Object.setPrototypeOf(this, ModelDictionary.prototype);
18
- Object.defineProperty(this, "$nullDeletesKeys", { enumerable: false, value: nullDeletesKeys });
19
- Object.defineProperty(this, "$itemConstructor", { enumerable: false, value: itemConstructor });
20
- }
21
- /**
22
- * Overridden set method to perform type-checks and update
23
- * @param key Key to set
24
- * @param value Value to set
25
- */
26
- set(key, value) {
27
- const that = this;
28
- if (value === null) {
29
- if (that.$nullDeletesKeys) {
30
- this.delete(key);
31
- return this;
32
- }
33
- return super.set(key, value);
34
- }
35
- const currentItem = this.get(key);
36
- if (currentItem == null) {
37
- if (that.$itemConstructor !== null && !(value instanceof that.$itemConstructor)) {
38
- const newItem = new that.$itemConstructor();
39
- if ((0, ModelObject_1.isModelObject)(newItem)) {
40
- const updatedItem = newItem.update(value);
41
- return super.set(key, updatedItem);
42
- }
43
- }
44
- }
45
- else if ((0, ModelObject_1.isModelObject)(currentItem)) {
46
- const newItem = currentItem.update(value);
47
- if (currentItem !== newItem) {
48
- return super.set(key, value);
49
- }
50
- return this;
51
- }
52
- return super.set(key, value);
53
- }
54
- /**
55
- * Update this instance from the given data
56
- * @param jsonElement JSON data to upgrade this instance from
57
- * @returns Updated instance
58
- */
59
- update(jsonElement) {
60
- if (jsonElement === null) {
61
- this.clear();
62
- }
63
- else if (jsonElement instanceof Map) {
64
- for (const [key, value] of jsonElement.entries()) {
65
- this.set(key, value);
66
- }
67
- }
68
- else {
69
- for (const [key, value] of Object.entries(jsonElement)) {
70
- this.set(key, value);
71
- }
72
- }
73
- return this;
74
- }
75
- /**
76
- * Convert this object to JSON
77
- * @returns JSON object
78
- */
79
- toJSON() {
80
- const json = {};
81
- for (const [key, value] of this) {
82
- json[key] = value;
83
- }
84
- return json;
85
- }
86
- }
87
- exports.ModelDictionary = ModelDictionary;
88
- exports.default = ModelDictionary;
89
- /**
90
- * Initialize a model dictionary from the given data
91
- * @param nullDeletesKeys Defines whether setting values to null deletes the corresponding key
92
- * @param itemConstructor Item constructor
93
- * @param data Data to assign
94
- * @returns Initialized model dictionary
95
- */
96
- function initDictionary(nullDeletesKeys, itemConstructor, data) {
97
- const result = new ModelDictionary(nullDeletesKeys, itemConstructor);
98
- for (let key in data) {
99
- const item = new itemConstructor();
100
- if ((0, ModelObject_1.isModelObject)(item)) {
101
- item.update(data[key]);
102
- result.set(key, item);
103
- }
104
- else {
105
- result.set(key, data[key]);
106
- }
107
- }
108
- return result;
109
- }
@@ -1,55 +0,0 @@
1
- /**
2
- * Interface for updating model objects using JSON data
3
- */
4
- export interface IModelObject {
5
- /**
6
- * Update this instance from the given data
7
- * @param jsonElement JSON data to upgrade this instance from
8
- * @returns Updated instance (may not equal the original instance)
9
- */
10
- update(jsonElement: any): IModelObject | null;
11
- }
12
- /**
13
- * Check whether a given value provides model update functionality
14
- * @param value Value to check
15
- */
16
- export declare function isModelObject(value: any): value is IModelObject;
17
- /**
18
- * Base class for object model classes
19
- */
20
- export declare abstract class ModelObject implements IModelObject {
21
- /**
22
- * Update this instance from the given data
23
- * @param jsonElement JSON data to upgrade this instance from
24
- * @returns Updated instance (may not equal the original instance)
25
- */
26
- update(jsonElement: any): IModelObject | null;
27
- /**
28
- * Wrap a nullable model object property so that type checks can be performed
29
- * @param key Property key of the derived class
30
- * @param constructor Constructor for creating new elements
31
- */
32
- static wrapModelCollectionProperty<S extends IModelObject, K extends keyof S, T extends IModelObject | null>(self: S, key: K, itemConstructor: {
33
- new (): T;
34
- }): void;
35
- /**
36
- * Wrap a nullable model object property so that type checks can be performed
37
- * @param key Property key of the derived class
38
- * @param constructor Constructor for creating new elements
39
- */
40
- static wrapModelProperty<S extends IModelObject, K extends keyof S, T extends IModelObject>(self: S, key: K, constructor: {
41
- new (): T;
42
- }): void;
43
- }
44
- export default ModelObject;
45
- /**
46
- * Initialize a model object from the given data
47
- * @param itemType Model type to create
48
- * @param data Data to assign
49
- * @returns Initialized model instance
50
- */
51
- export declare function initObject<T>(itemType: {
52
- new (): T;
53
- }, data: {
54
- [Property in keyof T]?: T[Property];
55
- }): T;
@@ -1,237 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModelObject = void 0;
4
- exports.isModelObject = isModelObject;
5
- exports.initObject = initObject;
6
- const index_1 = require("./index");
7
- /**
8
- * Check whether a given value provides model update functionality
9
- * @param value Value to check
10
- */
11
- function isModelObject(value) {
12
- return (value instanceof Object) && value.update !== undefined;
13
- }
14
- /**
15
- * Base class for object model classes
16
- */
17
- class ModelObject {
18
- /**
19
- * Update this instance from the given data
20
- * @param jsonElement JSON data to upgrade this instance from
21
- * @returns Updated instance (may not equal the original instance)
22
- */
23
- update(jsonElement) {
24
- if (jsonElement === null) {
25
- return null;
26
- }
27
- for (const [key, value] of Object.entries(jsonElement)) {
28
- if (key in this) {
29
- const ownKey = key;
30
- const prop = this[ownKey];
31
- if (isModelObject(prop)) {
32
- // Update model objects
33
- const updatedObject = prop.update(value);
34
- if (prop !== updatedObject) {
35
- const propDescriptor = Object.getOwnPropertyDescriptor(this, key);
36
- if (propDescriptor !== undefined) {
37
- if (propDescriptor.writable || propDescriptor.set !== undefined) {
38
- this[ownKey] = updatedObject;
39
- }
40
- else if (process.env.NODE_ENV !== "production") {
41
- console.warn(`Model object ${key} changed but it could not be set due to missing setter`);
42
- }
43
- }
44
- else if (process.env.NODE_ENV !== "production") {
45
- console.warn(`Model object ${key} changed but it lacks the property descriptor`);
46
- }
47
- }
48
- }
49
- else if (prop instanceof Array) {
50
- if (value instanceof Array) {
51
- // Remove deleted items
52
- prop.splice(value.length);
53
- // Update existing items
54
- for (let i = 0; i < Math.min(prop.length, value.length); i++) {
55
- const propItem = prop[i];
56
- if (propItem === null) {
57
- (0, index_1.setArrayItem)(prop, i, value[i]);
58
- }
59
- else {
60
- const newItem = value[i];
61
- if (propItem !== newItem) {
62
- (0, index_1.setArrayItem)(prop, i, newItem);
63
- }
64
- }
65
- }
66
- // Add new items
67
- for (let i = prop.length; i < value.length; i++) {
68
- prop.push(value[i]);
69
- }
70
- }
71
- else if (value === null) {
72
- // Arrays may be assignable to null
73
- this[ownKey] = value;
74
- }
75
- else if (process.env.NODE_ENV !== "production") {
76
- console.warn(`Model array ${key} could not be changed because the target type ${typeof value} is invalid`);
77
- }
78
- }
79
- else if (prop instanceof Set) {
80
- if (value instanceof Array || value instanceof Set) {
81
- // Remove deleted items
82
- for (let item of new Set(prop)) {
83
- if (!prop.has(item)) {
84
- prop.delete(item);
85
- }
86
- }
87
- // Add new items
88
- for (let item of value) {
89
- if (!prop.has(item)) {
90
- prop.add(item);
91
- }
92
- }
93
- }
94
- else if (value === null) {
95
- // Sets may be assignable to null
96
- this[ownKey] = value;
97
- }
98
- else if (process.env.NODE_ENV !== "production") {
99
- console.warn(`Model set ${key} could not be changed because the target type ${typeof value} is invalid`);
100
- }
101
- }
102
- else if (prop === null || value === null) {
103
- // Unfortunately we cannot do type checks during runtime without excessive extra work and possibly
104
- // third-party libraries, so skip them for null values until there is a better solution.
105
- // FWIW, we would just need "typeof prop" but TS does not seem to be capable of providing this.
106
- this[ownKey] = value;
107
- }
108
- else {
109
- const propType = typeof prop;
110
- if (propType === "boolean") {
111
- if (typeof value === "boolean") {
112
- this[ownKey] = value;
113
- }
114
- else if (typeof value === "number") {
115
- // RRF used to report booleans as integers so convert them if necessary
116
- this[ownKey] = Boolean(value);
117
- }
118
- else if (process.env.NODE_ENV !== "production") {
119
- console.warn(`Incompatible bool target type ${typeof value} for property ${key}`);
120
- }
121
- }
122
- else if (propType === "number") {
123
- if (typeof value === "number" || typeof value === "bigint") {
124
- this[ownKey] = value;
125
- }
126
- else if (process.env.NODE_ENV !== "production") {
127
- console.warn(`Incompatible number target type ${typeof value} for property ${key}`);
128
- }
129
- }
130
- else if (propType === "bigint") {
131
- if (typeof value === "number" || typeof value === "bigint") {
132
- this[ownKey] = value;
133
- }
134
- else if (process.env.NODE_ENV !== "production") {
135
- console.warn(`Incompatible bigint target type ${typeof value} for property ${key}`);
136
- }
137
- }
138
- else if (propType === "string") {
139
- if (typeof value === "string") {
140
- this[ownKey] = value;
141
- }
142
- else if (process.env.NODE_ENV !== "production") {
143
- console.warn(`Incompatible string target type ${typeof value} for property ${key}`);
144
- }
145
- }
146
- else if (propType === "function") {
147
- if (typeof value === "function") {
148
- this[ownKey] = value;
149
- }
150
- else if (process.env.NODE_ENV !== "production") {
151
- console.warn(`Incompatible function target type ${typeof value} for property ${key}`);
152
- }
153
- }
154
- else if (propType === "object") {
155
- if (typeof value === "object") {
156
- this[ownKey] = value;
157
- }
158
- else if (process.env.NODE_ENV !== "production") {
159
- console.warn(`Incompatible object target type ${typeof value} for property ${key}`);
160
- }
161
- }
162
- else if (process.env.NODE_ENV !== "production") {
163
- console.warn(`Incompatible type ${propType} for property ${key} (${typeof value})`);
164
- }
165
- }
166
- }
167
- }
168
- return this;
169
- }
170
- /**
171
- * Wrap a nullable model object property so that type checks can be performed
172
- * @param key Property key of the derived class
173
- * @param constructor Constructor for creating new elements
174
- */
175
- static wrapModelCollectionProperty(self, key, itemConstructor) {
176
- let propertyValue = self[key];
177
- Object.defineProperty(self, key, {
178
- get() { return propertyValue; },
179
- set(newValue) {
180
- if (newValue === null) {
181
- propertyValue = null;
182
- }
183
- else if (propertyValue !== null) {
184
- const newModel = propertyValue.update(newValue);
185
- if (propertyValue !== newModel) {
186
- propertyValue = newModel;
187
- }
188
- }
189
- else {
190
- const newModel = new index_1.ModelCollection(itemConstructor);
191
- propertyValue = newModel.update(newValue);
192
- }
193
- },
194
- configurable: true,
195
- enumerable: true
196
- });
197
- }
198
- /**
199
- * Wrap a nullable model object property so that type checks can be performed
200
- * @param key Property key of the derived class
201
- * @param constructor Constructor for creating new elements
202
- */
203
- static wrapModelProperty(self, key, constructor) {
204
- let propertyValue = self[key];
205
- Object.defineProperty(self, key, {
206
- get() { return propertyValue; },
207
- set(newValue) {
208
- if (newValue === null) {
209
- propertyValue = null;
210
- }
211
- else if (propertyValue !== null) {
212
- const newModel = propertyValue.update(newValue);
213
- if (propertyValue !== newModel) {
214
- propertyValue = newModel;
215
- }
216
- }
217
- else {
218
- const newModel = new constructor();
219
- propertyValue = newModel.update(newValue);
220
- }
221
- },
222
- configurable: true,
223
- enumerable: true
224
- });
225
- }
226
- }
227
- exports.ModelObject = ModelObject;
228
- exports.default = ModelObject;
229
- /**
230
- * Initialize a model object from the given data
231
- * @param itemType Model type to create
232
- * @param data Data to assign
233
- * @returns Initialized model instance
234
- */
235
- function initObject(itemType, data) {
236
- return new itemType().update(data);
237
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Wrapper around a standard set to make sure it serializes to an array
3
- */
4
- export declare class ModelSet<T> extends Set<T> {
5
- /**
6
- * Convert this object to JSON
7
- * @returns JSON object
8
- */
9
- toJSON(): T[];
10
- }
11
- export default ModelSet;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModelSet = void 0;
4
- /**
5
- * Wrapper around a standard set to make sure it serializes to an array
6
- */
7
- class ModelSet extends Set {
8
- /**
9
- * Convert this object to JSON
10
- * @returns JSON object
11
- */
12
- toJSON() { return Array.from(this); }
13
- }
14
- exports.ModelSet = ModelSet;
15
- exports.default = ModelSet;
@@ -1,47 +0,0 @@
1
- import ModelCollection from "./ModelCollection";
2
- import ModelDictionary from "./ModelDictionary";
3
- import ModelObject from "./ModelObject";
4
- import Board from "./boards";
5
- import Directories from "./directories";
6
- import Fan from "./fans";
7
- import Heat from "./heat";
8
- import InputChannel from "./inputs/InputChannel";
9
- import Job from "./job";
10
- import Limits from "./limits";
11
- import Message from "./messages";
12
- import Move from "./move";
13
- import Network from "./network";
14
- import Plugin from "./plugins";
15
- import SBC from "./sbc";
16
- import Sensors from "./sensors";
17
- import Spindle from "./spindles";
18
- import State from "./state";
19
- import Tool from "./tools";
20
- import Volume from "./volumes";
21
- import LedStrip from "./ledStrips";
22
- /**
23
- * Refer to the DSF/RRF documentation for descriptions of the object model fields
24
- */
25
- export declare class ObjectModel extends ModelObject {
26
- constructor();
27
- readonly boards: ModelCollection<Board>;
28
- readonly directories: Directories;
29
- readonly fans: ModelCollection<Fan | null>;
30
- readonly global: ModelDictionary<any>;
31
- readonly heat: Heat;
32
- readonly inputs: ModelCollection<InputChannel | null>;
33
- readonly job: Job;
34
- readonly ledStrips: ModelCollection<LedStrip>;
35
- readonly limits: Limits;
36
- readonly messages: ModelCollection<Message>;
37
- readonly move: Move;
38
- readonly network: Network;
39
- readonly plugins: ModelDictionary<Plugin>;
40
- sbc: SBC | null;
41
- readonly sensors: Sensors;
42
- readonly spindles: ModelCollection<Spindle | null>;
43
- readonly state: State;
44
- readonly tools: ModelCollection<Tool | null>;
45
- readonly volumes: ModelCollection<Volume>;
46
- }
47
- export default ObjectModel;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ObjectModel = void 0;
7
- const ModelCollection_1 = __importDefault(require("./ModelCollection"));
8
- const ModelDictionary_1 = __importDefault(require("./ModelDictionary"));
9
- const ModelObject_1 = __importDefault(require("./ModelObject"));
10
- const boards_1 = __importDefault(require("./boards"));
11
- const directories_1 = __importDefault(require("./directories"));
12
- const fans_1 = __importDefault(require("./fans"));
13
- const heat_1 = __importDefault(require("./heat"));
14
- const InputChannel_1 = __importDefault(require("./inputs/InputChannel"));
15
- const job_1 = __importDefault(require("./job"));
16
- const limits_1 = __importDefault(require("./limits"));
17
- const messages_1 = __importDefault(require("./messages"));
18
- const move_1 = __importDefault(require("./move"));
19
- const network_1 = __importDefault(require("./network"));
20
- const plugins_1 = __importDefault(require("./plugins"));
21
- const sbc_1 = __importDefault(require("./sbc"));
22
- const sensors_1 = __importDefault(require("./sensors"));
23
- const spindles_1 = __importDefault(require("./spindles"));
24
- const state_1 = __importDefault(require("./state"));
25
- const tools_1 = __importDefault(require("./tools"));
26
- const volumes_1 = __importDefault(require("./volumes"));
27
- const ledStrips_1 = __importDefault(require("./ledStrips"));
28
- /**
29
- * Refer to the DSF/RRF documentation for descriptions of the object model fields
30
- */
31
- class ObjectModel extends ModelObject_1.default {
32
- constructor() {
33
- super();
34
- this.boards = new ModelCollection_1.default(boards_1.default);
35
- this.directories = new directories_1.default();
36
- this.fans = new ModelCollection_1.default(fans_1.default);
37
- this.global = new ModelDictionary_1.default(false);
38
- this.heat = new heat_1.default();
39
- this.inputs = new ModelCollection_1.default(InputChannel_1.default);
40
- this.job = new job_1.default();
41
- this.ledStrips = new ModelCollection_1.default(ledStrips_1.default);
42
- this.limits = new limits_1.default();
43
- this.messages = new ModelCollection_1.default(messages_1.default); // must be manually cleared after updates
44
- this.move = new move_1.default();
45
- this.network = new network_1.default();
46
- this.plugins = new ModelDictionary_1.default(true, plugins_1.default);
47
- this.sbc = null;
48
- this.sensors = new sensors_1.default();
49
- this.spindles = new ModelCollection_1.default(spindles_1.default);
50
- this.state = new state_1.default();
51
- this.tools = new ModelCollection_1.default(tools_1.default);
52
- this.volumes = new ModelCollection_1.default(volumes_1.default);
53
- ModelObject_1.default.wrapModelProperty(this, "sbc", sbc_1.default);
54
- }
55
- }
56
- exports.ObjectModel = ObjectModel;
57
- exports.default = ObjectModel;
@@ -1,18 +0,0 @@
1
- import { ModelObject } from "..";
2
- export declare class BoardClosedLoopCurrentFraction extends ModelObject {
3
- avg: number;
4
- max: number;
5
- }
6
- export declare class BoardClosedLoopPositionError extends ModelObject {
7
- max: number;
8
- rms: number;
9
- }
10
- export declare class DriverClosedLoop extends ModelObject {
11
- readonly currentFraction: BoardClosedLoopCurrentFraction;
12
- readonly positionError: BoardClosedLoopPositionError;
13
- }
14
- export default class Driver extends ModelObject {
15
- constructor();
16
- closedLoop: DriverClosedLoop | null;
17
- status: number;
18
- }
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DriverClosedLoop = exports.BoardClosedLoopPositionError = exports.BoardClosedLoopCurrentFraction = void 0;
4
- const __1 = require("..");
5
- class BoardClosedLoopCurrentFraction extends __1.ModelObject {
6
- constructor() {
7
- super(...arguments);
8
- this.avg = 0;
9
- this.max = 0;
10
- }
11
- }
12
- exports.BoardClosedLoopCurrentFraction = BoardClosedLoopCurrentFraction;
13
- class BoardClosedLoopPositionError extends __1.ModelObject {
14
- constructor() {
15
- super(...arguments);
16
- this.max = 0;
17
- this.rms = 0;
18
- }
19
- }
20
- exports.BoardClosedLoopPositionError = BoardClosedLoopPositionError;
21
- class DriverClosedLoop extends __1.ModelObject {
22
- constructor() {
23
- super(...arguments);
24
- this.currentFraction = new BoardClosedLoopCurrentFraction();
25
- this.positionError = new BoardClosedLoopPositionError();
26
- }
27
- }
28
- exports.DriverClosedLoop = DriverClosedLoop;
29
- class Driver extends __1.ModelObject {
30
- constructor() {
31
- super();
32
- this.closedLoop = null;
33
- this.status = 0;
34
- __1.ModelObject.wrapModelProperty(this, "closedLoop", DriverClosedLoop);
35
- }
36
- }
37
- exports.default = Driver;
@@ -1,6 +0,0 @@
1
- import { IModelObject } from "../../ModelObject";
2
- import DirectDisplayScreenBase from "./DirectDisplayScreenBase";
3
- export declare class DirectDisplayScreen extends DirectDisplayScreenBase {
4
- update(jsonElement: any): IModelObject | null;
5
- }
6
- export default DirectDisplayScreen;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DirectDisplayScreen = void 0;
7
- const _1 = require(".");
8
- const DirectDisplayScreenBase_1 = __importDefault(require("./DirectDisplayScreenBase"));
9
- class DirectDisplayScreen extends DirectDisplayScreenBase_1.default {
10
- update(jsonElement) {
11
- if (jsonElement === null) {
12
- return null;
13
- }
14
- if (typeof jsonElement.controller === "string" && jsonElement.controller !== this.controller) {
15
- return (0, _1.getDirectDisplayScreen)(jsonElement.controller).update(jsonElement);
16
- }
17
- return super.update(jsonElement);
18
- }
19
- }
20
- exports.DirectDisplayScreen = DirectDisplayScreen;
21
- exports.default = DirectDisplayScreen;
@@ -1,11 +0,0 @@
1
- import ModelObject from "../../ModelObject";
2
- import { DirectDisplayController } from ".";
3
- export declare class DirectDisplayScreenBase extends ModelObject {
4
- constructor(type: DirectDisplayController);
5
- colourBits: number;
6
- controller: DirectDisplayController;
7
- height: number;
8
- spiFreq: number;
9
- width: number;
10
- }
11
- export default DirectDisplayScreenBase;