@duet3d/objectmodel 3.7.0-beta.1 → 3.7.0-beta.11
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.
- package/README.md +1 -7
- package/dist/ModelCollection.d.ts +8 -2
- package/dist/ModelCollection.js +25 -12
- package/dist/ModelDictionary.d.ts +4 -2
- package/dist/ModelDictionary.js +8 -6
- package/dist/ModelObject.d.ts +13 -2
- package/dist/ModelObject.js +50 -5
- package/dist/ObjectModel.d.ts +5 -0
- package/dist/ObjectModel.js +7 -2
- package/dist/boards/directDisplay/DirectDisplayScreen.d.ts +1 -1
- package/dist/boards/directDisplay/DirectDisplayScreen.js +3 -3
- package/dist/boards/directDisplay/DirectDisplayScreenST7567.d.ts +1 -1
- package/dist/boards/directDisplay/DirectDisplayScreenST7567.js +3 -3
- package/dist/boards/index.d.ts +23 -9
- package/dist/boards/index.js +33 -13
- package/dist/documentation.json +66 -18
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -10
- package/dist/move/index.d.ts +1 -0
- package/dist/move/index.js +1 -0
- package/dist/move/kinematics/CoreKinematics.d.ts +1 -1
- package/dist/move/kinematics/CoreKinematics.js +3 -3
- package/dist/move/kinematics/DeltaKinematics.d.ts +1 -1
- package/dist/move/kinematics/DeltaKinematics.js +3 -3
- package/dist/move/kinematics/HangprinterKinematics.d.ts +1 -1
- package/dist/move/kinematics/HangprinterKinematics.js +3 -3
- package/dist/move/kinematics/PolarKinematics.d.ts +1 -1
- package/dist/move/kinematics/PolarKinematics.js +3 -3
- package/dist/move/kinematics/ScaraKinematics.d.ts +1 -1
- package/dist/move/kinematics/ScaraKinematics.js +3 -3
- package/dist/move/kinematics/index.d.ts +1 -1
- package/dist/move/kinematics/index.js +3 -3
- package/dist/plugins/PluginManifest.d.ts +1 -1
- package/dist/plugins/PluginManifest.js +2 -2
- package/dist/sbc/Upgrade.d.ts +6 -0
- package/dist/sbc/Upgrade.js +9 -0
- package/dist/sbc/index.d.ts +4 -0
- package/dist/sbc/index.js +5 -1
- package/dist/sensors/FilamentMonitors/FilamentMonitorBase.d.ts +1 -0
- package/dist/sensors/FilamentMonitors/FilamentMonitorBase.js +1 -0
- package/dist/sensors/FilamentMonitors/LaserFilamentMonitor.d.ts +1 -1
- package/dist/sensors/FilamentMonitors/LaserFilamentMonitor.js +3 -3
- package/dist/sensors/FilamentMonitors/PulsedFilamentMonitor.d.ts +1 -1
- package/dist/sensors/FilamentMonitors/PulsedFilamentMonitor.js +3 -3
- package/dist/sensors/FilamentMonitors/RotatingMagnetFilamentMonitor.d.ts +2 -1
- package/dist/sensors/FilamentMonitors/RotatingMagnetFilamentMonitor.js +4 -3
- package/dist/sensors/FilamentMonitors/index.d.ts +1 -1
- package/dist/sensors/FilamentMonitors/index.js +3 -3
- package/dist/state/MessageBox.d.ts +1 -1
- package/dist/state/MessageBox.js +2 -2
- package/dist/state/RestorePoint.js +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -4,13 +4,7 @@ TypeScript implementation of the Duet3D Object Model.
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
Install via `npm install @duet3d/objectmodel`.
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
globalThis._duetModelSetArray = (array, index, value) => Vue.set(array, index, value);
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
This is required to make sure that change events for arrays are correctly fired.
|
|
7
|
+
Install via `npm install @duet3d/objectmodel`.
|
|
14
8
|
|
|
15
9
|
## Bug reports
|
|
16
10
|
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { IModelObject } from "./ModelObject";
|
|
2
|
+
/**
|
|
3
|
+
* Factory creating the item for a given index
|
|
4
|
+
*/
|
|
5
|
+
export type ItemFactory<T> = (index: number) => T;
|
|
2
6
|
/**
|
|
3
7
|
* Class for storing model object items in an array
|
|
4
8
|
*/
|
|
@@ -6,10 +10,11 @@ export declare class ModelCollection<T extends IModelObject | null> extends Arra
|
|
|
6
10
|
/**
|
|
7
11
|
* Constructor of this class
|
|
8
12
|
* @param itemConstructor Item constructor type that items must derive from
|
|
13
|
+
* @param itemFactory Factory to use for collections whose item class depends on the position, e.g. boards
|
|
9
14
|
*/
|
|
10
15
|
constructor(itemConstructor: {
|
|
11
16
|
new (): T;
|
|
12
|
-
});
|
|
17
|
+
}, itemFactory?: ItemFactory<T> | null);
|
|
13
18
|
/**
|
|
14
19
|
* Overridden push method to perform better type checks
|
|
15
20
|
* @param items Items to add
|
|
@@ -18,9 +23,10 @@ export declare class ModelCollection<T extends IModelObject | null> extends Arra
|
|
|
18
23
|
/**
|
|
19
24
|
* Update this instance from the given data
|
|
20
25
|
* @param jsonElement JSON data to upgrade this instance from
|
|
26
|
+
* @param authoritative Whether the given data is a complete snapshot of the items and everything below them
|
|
21
27
|
* @returns Updated instance
|
|
22
28
|
*/
|
|
23
|
-
update(jsonElement: any): IModelObject | null;
|
|
29
|
+
update(jsonElement: any, authoritative?: boolean): IModelObject | null;
|
|
24
30
|
}
|
|
25
31
|
export default ModelCollection;
|
|
26
32
|
/**
|
package/dist/ModelCollection.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { isModelObject } from "./ModelObject";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Create the item for a given index. This is deliberately not a method of the collection because
|
|
4
|
+
* a non-public member would make the class nominally typed, which breaks assignability of the
|
|
5
|
+
* reactive proxies consumers wrap the object model in
|
|
6
|
+
* @param collection Collection the item is created for
|
|
7
|
+
* @param index Index the new item is going to be stored at
|
|
8
|
+
* @returns New item
|
|
9
|
+
*/
|
|
10
|
+
function createItem(collection, index) {
|
|
11
|
+
return (collection.$itemFactory !== null) ? collection.$itemFactory(index) : new collection.$itemConstructor();
|
|
12
|
+
}
|
|
3
13
|
/**
|
|
4
14
|
* Class for storing model object items in an array
|
|
5
15
|
*/
|
|
@@ -7,11 +17,13 @@ export class ModelCollection extends Array {
|
|
|
7
17
|
/**
|
|
8
18
|
* Constructor of this class
|
|
9
19
|
* @param itemConstructor Item constructor type that items must derive from
|
|
20
|
+
* @param itemFactory Factory to use for collections whose item class depends on the position, e.g. boards
|
|
10
21
|
*/
|
|
11
|
-
constructor(itemConstructor) {
|
|
22
|
+
constructor(itemConstructor, itemFactory = null) {
|
|
12
23
|
super();
|
|
13
24
|
Object.setPrototypeOf(this, ModelCollection.prototype);
|
|
14
25
|
Object.defineProperty(this, "$itemConstructor", { enumerable: false, value: itemConstructor });
|
|
26
|
+
Object.defineProperty(this, "$itemFactory", { enumerable: false, value: itemFactory });
|
|
15
27
|
}
|
|
16
28
|
// Unfortunately it isn't possible to override index operators in JS/TS
|
|
17
29
|
/**
|
|
@@ -25,7 +37,7 @@ export class ModelCollection extends Array {
|
|
|
25
37
|
super.push(item);
|
|
26
38
|
}
|
|
27
39
|
else {
|
|
28
|
-
const newItem =
|
|
40
|
+
const newItem = createItem(that, this.length);
|
|
29
41
|
super.push(newItem.update(item));
|
|
30
42
|
}
|
|
31
43
|
}
|
|
@@ -34,9 +46,10 @@ export class ModelCollection extends Array {
|
|
|
34
46
|
/**
|
|
35
47
|
* Update this instance from the given data
|
|
36
48
|
* @param jsonElement JSON data to upgrade this instance from
|
|
49
|
+
* @param authoritative Whether the given data is a complete snapshot of the items and everything below them
|
|
37
50
|
* @returns Updated instance
|
|
38
51
|
*/
|
|
39
|
-
update(jsonElement) {
|
|
52
|
+
update(jsonElement, authoritative = false) {
|
|
40
53
|
if (jsonElement === null) {
|
|
41
54
|
return null;
|
|
42
55
|
}
|
|
@@ -52,23 +65,23 @@ export class ModelCollection extends Array {
|
|
|
52
65
|
if (currentItem === null) {
|
|
53
66
|
const newItem = jsonElement[i];
|
|
54
67
|
if (newItem instanceof that.$itemConstructor) {
|
|
55
|
-
|
|
68
|
+
this[i] = jsonElement[i];
|
|
56
69
|
}
|
|
57
70
|
else {
|
|
58
|
-
const refItem =
|
|
59
|
-
|
|
71
|
+
const refItem = createItem(that, i);
|
|
72
|
+
this[i] = refItem.update(newItem, authoritative);
|
|
60
73
|
}
|
|
61
74
|
}
|
|
62
75
|
else if (isModelObject(currentItem)) {
|
|
63
|
-
const newItem = currentItem.update(jsonElement[i]);
|
|
76
|
+
const newItem = currentItem.update(jsonElement[i], authoritative);
|
|
64
77
|
if (currentItem !== newItem) {
|
|
65
|
-
|
|
78
|
+
this[i] = newItem;
|
|
66
79
|
}
|
|
67
80
|
}
|
|
68
81
|
else {
|
|
69
82
|
const newItem = jsonElement[i];
|
|
70
83
|
if (currentItem !== newItem) {
|
|
71
|
-
|
|
84
|
+
this[i] = newItem;
|
|
72
85
|
}
|
|
73
86
|
}
|
|
74
87
|
}
|
|
@@ -79,8 +92,8 @@ export class ModelCollection extends Array {
|
|
|
79
92
|
super.push(itemToAdd);
|
|
80
93
|
}
|
|
81
94
|
else {
|
|
82
|
-
const newItem =
|
|
83
|
-
super.push(newItem.update(itemToAdd));
|
|
95
|
+
const newItem = createItem(that, i);
|
|
96
|
+
super.push(newItem.update(itemToAdd, authoritative));
|
|
84
97
|
}
|
|
85
98
|
}
|
|
86
99
|
return this;
|
|
@@ -15,14 +15,16 @@ export declare class ModelDictionary<T> extends Map<string, T | null> implements
|
|
|
15
15
|
* Overridden set method to perform type-checks and update
|
|
16
16
|
* @param key Key to set
|
|
17
17
|
* @param value Value to set
|
|
18
|
+
* @param authoritative Whether the given value is a complete snapshot of the item and everything below it
|
|
18
19
|
*/
|
|
19
|
-
set(key: string, value: T | null): this;
|
|
20
|
+
set(key: string, value: T | null, authoritative?: boolean): this;
|
|
20
21
|
/**
|
|
21
22
|
* Update this instance from the given data
|
|
22
23
|
* @param jsonElement JSON data to upgrade this instance from
|
|
24
|
+
* @param authoritative Whether the given data is a complete snapshot of the items and everything below them
|
|
23
25
|
* @returns Updated instance
|
|
24
26
|
*/
|
|
25
|
-
update(jsonElement: any): IModelObject | null;
|
|
27
|
+
update(jsonElement: any, authoritative?: boolean): IModelObject | null;
|
|
26
28
|
/**
|
|
27
29
|
* Convert this object to JSON
|
|
28
30
|
* @returns JSON object
|
package/dist/ModelDictionary.js
CHANGED
|
@@ -18,8 +18,9 @@ export class ModelDictionary extends Map {
|
|
|
18
18
|
* Overridden set method to perform type-checks and update
|
|
19
19
|
* @param key Key to set
|
|
20
20
|
* @param value Value to set
|
|
21
|
+
* @param authoritative Whether the given value is a complete snapshot of the item and everything below it
|
|
21
22
|
*/
|
|
22
|
-
set(key, value) {
|
|
23
|
+
set(key, value, authoritative = false) {
|
|
23
24
|
const that = this;
|
|
24
25
|
if (value === null) {
|
|
25
26
|
if (that.$nullDeletesKeys) {
|
|
@@ -33,13 +34,13 @@ export class ModelDictionary extends Map {
|
|
|
33
34
|
if (that.$itemConstructor !== null && !(value instanceof that.$itemConstructor)) {
|
|
34
35
|
const newItem = new that.$itemConstructor();
|
|
35
36
|
if (isModelObject(newItem)) {
|
|
36
|
-
const updatedItem = newItem.update(value);
|
|
37
|
+
const updatedItem = newItem.update(value, authoritative);
|
|
37
38
|
return super.set(key, updatedItem);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
else if (isModelObject(currentItem)) {
|
|
42
|
-
const newItem = currentItem.update(value);
|
|
43
|
+
const newItem = currentItem.update(value, authoritative);
|
|
43
44
|
if (currentItem !== newItem) {
|
|
44
45
|
return super.set(key, value);
|
|
45
46
|
}
|
|
@@ -50,20 +51,21 @@ export class ModelDictionary extends Map {
|
|
|
50
51
|
/**
|
|
51
52
|
* Update this instance from the given data
|
|
52
53
|
* @param jsonElement JSON data to upgrade this instance from
|
|
54
|
+
* @param authoritative Whether the given data is a complete snapshot of the items and everything below them
|
|
53
55
|
* @returns Updated instance
|
|
54
56
|
*/
|
|
55
|
-
update(jsonElement) {
|
|
57
|
+
update(jsonElement, authoritative = false) {
|
|
56
58
|
if (jsonElement === null) {
|
|
57
59
|
this.clear();
|
|
58
60
|
}
|
|
59
61
|
else if (jsonElement instanceof Map) {
|
|
60
62
|
for (const [key, value] of jsonElement.entries()) {
|
|
61
|
-
this.set(key, value);
|
|
63
|
+
this.set(key, value, authoritative);
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
else {
|
|
65
67
|
for (const [key, value] of Object.entries(jsonElement)) {
|
|
66
|
-
this.set(key, value);
|
|
68
|
+
this.set(key, value, authoritative);
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
return this;
|
package/dist/ModelObject.d.ts
CHANGED
|
@@ -5,9 +5,12 @@ export interface IModelObject {
|
|
|
5
5
|
/**
|
|
6
6
|
* Update this instance from the given data
|
|
7
7
|
* @param jsonElement JSON data to upgrade this instance from
|
|
8
|
+
* @param authoritative Whether the given data is a complete snapshot of this instance and everything below it,
|
|
9
|
+
* so that properties missing from it are known to be null. Set this only for responses that were not filtered
|
|
10
|
+
* by the sender, i.e. full object model key queries but never live/patch updates
|
|
8
11
|
* @returns Updated instance (may not equal the original instance)
|
|
9
12
|
*/
|
|
10
|
-
update(jsonElement: any): IModelObject | null;
|
|
13
|
+
update(jsonElement: any, authoritative?: boolean): IModelObject | null;
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* Check whether a given value provides model update functionality
|
|
@@ -18,12 +21,20 @@ export declare function isModelObject(value: any): value is IModelObject;
|
|
|
18
21
|
* Base class for object model classes
|
|
19
22
|
*/
|
|
20
23
|
export declare abstract class ModelObject implements IModelObject {
|
|
24
|
+
/**
|
|
25
|
+
* Whether an authoritative update may reset the properties of this class that are missing from it.
|
|
26
|
+
* Set to false where an instance never receives a complete snapshot of itself. Deliberately static
|
|
27
|
+
* because an instance member would become part of the structural type and break consumers that hold
|
|
28
|
+
* a mapped version of the model, such as a Pinia store
|
|
29
|
+
*/
|
|
30
|
+
static readonly resetsMissingProperties: boolean;
|
|
21
31
|
/**
|
|
22
32
|
* Update this instance from the given data
|
|
23
33
|
* @param jsonElement JSON data to upgrade this instance from
|
|
34
|
+
* @param authoritative Whether the given data is a complete snapshot of this instance and everything below it
|
|
24
35
|
* @returns Updated instance (may not equal the original instance)
|
|
25
36
|
*/
|
|
26
|
-
update(jsonElement: any): IModelObject | null;
|
|
37
|
+
update(jsonElement: any, authoritative?: boolean): IModelObject | null;
|
|
27
38
|
/**
|
|
28
39
|
* Wrap a nullable model object property so that type checks can be performed
|
|
29
40
|
* @param key Property key of the derived class
|
package/dist/ModelObject.js
CHANGED
|
@@ -1,4 +1,34 @@
|
|
|
1
|
-
import { ModelCollection
|
|
1
|
+
import { ModelCollection } from "./index";
|
|
2
|
+
/**
|
|
3
|
+
* Names of the properties that default to null, per model object class. Queried from a pristine instance because
|
|
4
|
+
* TS types are gone at runtime, so a null default is the only remaining evidence that a property may hold null
|
|
5
|
+
*/
|
|
6
|
+
const nullableProperties = new WeakMap();
|
|
7
|
+
/**
|
|
8
|
+
* Get the names of the properties of the given instance's class that may hold null
|
|
9
|
+
* @param instance Instance to inspect the class of
|
|
10
|
+
*/
|
|
11
|
+
function getNullableProperties(instance) {
|
|
12
|
+
let result = nullableProperties.get(instance.constructor);
|
|
13
|
+
if (result === undefined) {
|
|
14
|
+
result = new Set();
|
|
15
|
+
try {
|
|
16
|
+
for (const [key, value] of Object.entries(new instance.constructor())) {
|
|
17
|
+
if (value === null) {
|
|
18
|
+
result.add(key);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
// A class that cannot be constructed without arguments simply opts out of null reconstruction
|
|
24
|
+
if (process.env.NODE_ENV !== "production") {
|
|
25
|
+
console.warn(`Failed to determine nullable properties of ${instance.constructor.name}`, e);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
nullableProperties.set(instance.constructor, result);
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
2
32
|
/**
|
|
3
33
|
* Check whether a given value provides model update functionality
|
|
4
34
|
* @param value Value to check
|
|
@@ -13,19 +43,27 @@ export class ModelObject {
|
|
|
13
43
|
/**
|
|
14
44
|
* Update this instance from the given data
|
|
15
45
|
* @param jsonElement JSON data to upgrade this instance from
|
|
46
|
+
* @param authoritative Whether the given data is a complete snapshot of this instance and everything below it
|
|
16
47
|
* @returns Updated instance (may not equal the original instance)
|
|
17
48
|
*/
|
|
18
|
-
update(jsonElement) {
|
|
49
|
+
update(jsonElement, authoritative = false) {
|
|
19
50
|
if (jsonElement === null) {
|
|
20
51
|
return null;
|
|
21
52
|
}
|
|
53
|
+
if (authoritative && this.constructor.resetsMissingProperties) {
|
|
54
|
+
for (const key of getNullableProperties(this)) {
|
|
55
|
+
if (!(key in jsonElement)) {
|
|
56
|
+
this[key] = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
22
60
|
for (const [key, value] of Object.entries(jsonElement)) {
|
|
23
61
|
if (key in this) {
|
|
24
62
|
const ownKey = key;
|
|
25
63
|
const prop = this[ownKey];
|
|
26
64
|
if (isModelObject(prop)) {
|
|
27
65
|
// Update model objects
|
|
28
|
-
const updatedObject = prop.update(value);
|
|
66
|
+
const updatedObject = prop.update(value, authoritative);
|
|
29
67
|
if (prop !== updatedObject) {
|
|
30
68
|
const propDescriptor = Object.getOwnPropertyDescriptor(this, key);
|
|
31
69
|
if (propDescriptor !== undefined) {
|
|
@@ -49,12 +87,12 @@ export class ModelObject {
|
|
|
49
87
|
for (let i = 0; i < Math.min(prop.length, value.length); i++) {
|
|
50
88
|
const propItem = prop[i];
|
|
51
89
|
if (propItem === null) {
|
|
52
|
-
|
|
90
|
+
prop[i] = value[i];
|
|
53
91
|
}
|
|
54
92
|
else {
|
|
55
93
|
const newItem = value[i];
|
|
56
94
|
if (propItem !== newItem) {
|
|
57
|
-
|
|
95
|
+
prop[i] = newItem;
|
|
58
96
|
}
|
|
59
97
|
}
|
|
60
98
|
}
|
|
@@ -219,6 +257,13 @@ export class ModelObject {
|
|
|
219
257
|
});
|
|
220
258
|
}
|
|
221
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Whether an authoritative update may reset the properties of this class that are missing from it.
|
|
262
|
+
* Set to false where an instance never receives a complete snapshot of itself. Deliberately static
|
|
263
|
+
* because an instance member would become part of the structural type and break consumers that hold
|
|
264
|
+
* a mapped version of the model, such as a Pinia store
|
|
265
|
+
*/
|
|
266
|
+
ModelObject.resetsMissingProperties = true;
|
|
222
267
|
export default ModelObject;
|
|
223
268
|
/**
|
|
224
269
|
* Initialize a model object from the given data
|
package/dist/ObjectModel.d.ts
CHANGED
|
@@ -24,6 +24,11 @@ import LedStrip from "./ledStrips";
|
|
|
24
24
|
*/
|
|
25
25
|
export declare class ObjectModel extends ModelObject {
|
|
26
26
|
constructor();
|
|
27
|
+
/**
|
|
28
|
+
* A payload handed to the root always covers a subset of the top-level keys rather than the whole model,
|
|
29
|
+
* so authoritative reconstruction has to start one level below it
|
|
30
|
+
*/
|
|
31
|
+
static readonly resetsMissingProperties: boolean;
|
|
27
32
|
readonly boards: ModelCollection<Board>;
|
|
28
33
|
readonly directories: Directories;
|
|
29
34
|
readonly fans: ModelCollection<Fan | null>;
|
package/dist/ObjectModel.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ModelCollection from "./ModelCollection";
|
|
2
2
|
import ModelDictionary from "./ModelDictionary";
|
|
3
3
|
import ModelObject from "./ModelObject";
|
|
4
|
-
import Board from "./boards";
|
|
4
|
+
import Board, { getBoard } from "./boards";
|
|
5
5
|
import Directories from "./directories";
|
|
6
6
|
import Fan from "./fans";
|
|
7
7
|
import Heat from "./heat";
|
|
@@ -25,7 +25,7 @@ import LedStrip from "./ledStrips";
|
|
|
25
25
|
export class ObjectModel extends ModelObject {
|
|
26
26
|
constructor() {
|
|
27
27
|
super();
|
|
28
|
-
this.boards = new ModelCollection(Board);
|
|
28
|
+
this.boards = new ModelCollection(Board, getBoard);
|
|
29
29
|
this.directories = new Directories();
|
|
30
30
|
this.fans = new ModelCollection(Fan);
|
|
31
31
|
this.global = new ModelDictionary(false);
|
|
@@ -47,4 +47,9 @@ export class ObjectModel extends ModelObject {
|
|
|
47
47
|
ModelObject.wrapModelProperty(this, "sbc", SBC);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* A payload handed to the root always covers a subset of the top-level keys rather than the whole model,
|
|
52
|
+
* so authoritative reconstruction has to start one level below it
|
|
53
|
+
*/
|
|
54
|
+
ObjectModel.resetsMissingProperties = false;
|
|
50
55
|
export default ObjectModel;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IModelObject } from "../../ModelObject";
|
|
2
2
|
import DirectDisplayScreenBase from "./DirectDisplayScreenBase";
|
|
3
3
|
export declare class DirectDisplayScreen extends DirectDisplayScreenBase {
|
|
4
|
-
update(jsonElement: any): IModelObject | null;
|
|
4
|
+
update(jsonElement: any, authoritative?: boolean): IModelObject | null;
|
|
5
5
|
}
|
|
6
6
|
export default DirectDisplayScreen;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { getDirectDisplayScreen } from ".";
|
|
2
2
|
import DirectDisplayScreenBase from "./DirectDisplayScreenBase";
|
|
3
3
|
export class DirectDisplayScreen extends DirectDisplayScreenBase {
|
|
4
|
-
update(jsonElement) {
|
|
4
|
+
update(jsonElement, authoritative = false) {
|
|
5
5
|
if (jsonElement === null) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
8
|
if (typeof jsonElement.controller === "string" && jsonElement.controller !== this.controller) {
|
|
9
|
-
return getDirectDisplayScreen(jsonElement.controller).update(jsonElement);
|
|
9
|
+
return getDirectDisplayScreen(jsonElement.controller).update(jsonElement, authoritative);
|
|
10
10
|
}
|
|
11
|
-
return super.update(jsonElement);
|
|
11
|
+
return super.update(jsonElement, authoritative);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
export default DirectDisplayScreen;
|
|
@@ -4,6 +4,6 @@ export declare class DirectDisplayScreenST7567 extends DirectDisplayScreenBase {
|
|
|
4
4
|
constructor();
|
|
5
5
|
contrast: number;
|
|
6
6
|
resistorRatio: number;
|
|
7
|
-
update(jsonElement: any): IModelObject | null;
|
|
7
|
+
update(jsonElement: any, authoritative?: boolean): IModelObject | null;
|
|
8
8
|
}
|
|
9
9
|
export default DirectDisplayScreenST7567;
|
|
@@ -6,14 +6,14 @@ export class DirectDisplayScreenST7567 extends DirectDisplayScreenBase {
|
|
|
6
6
|
this.contrast = 30;
|
|
7
7
|
this.resistorRatio = 6;
|
|
8
8
|
}
|
|
9
|
-
update(jsonElement) {
|
|
9
|
+
update(jsonElement, authoritative = false) {
|
|
10
10
|
if (jsonElement === null) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
13
13
|
if (typeof jsonElement.controller === "string" && jsonElement.controller !== this.controller) {
|
|
14
|
-
return getDirectDisplayScreen(jsonElement.controller).update(jsonElement);
|
|
14
|
+
return getDirectDisplayScreen(jsonElement.controller).update(jsonElement, authoritative);
|
|
15
15
|
}
|
|
16
|
-
return super.update(jsonElement);
|
|
16
|
+
return super.update(jsonElement, authoritative);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
export default DirectDisplayScreenST7567;
|
package/dist/boards/index.d.ts
CHANGED
|
@@ -30,29 +30,43 @@ export declare class Board extends ModelObject {
|
|
|
30
30
|
constructor();
|
|
31
31
|
accelerometer: Accelerometer | null;
|
|
32
32
|
canAddress: number | null;
|
|
33
|
-
closedLoop: BoardClosedLoop | null;
|
|
34
|
-
directDisplay: DirectDisplay | null;
|
|
35
33
|
drivers: ModelCollection<Driver> | null;
|
|
36
34
|
firmwareDate: string;
|
|
37
35
|
firmwareFileName: string;
|
|
38
|
-
firmwareName: string;
|
|
39
36
|
firmwareVersion: string;
|
|
40
37
|
freeRam: number | null;
|
|
41
|
-
iapFileNameSBC: string | null;
|
|
42
|
-
iapFileNameSD: string | null;
|
|
43
|
-
inductiveSensor: InductiveSensor | null;
|
|
44
|
-
maxHeaters: number;
|
|
45
38
|
maxMotors: number;
|
|
46
39
|
mcuTemp: MinMaxCurrent | null;
|
|
47
40
|
name: string;
|
|
48
41
|
shortName: string;
|
|
49
|
-
state: BoardState;
|
|
50
|
-
supportsDirectDisplay: boolean;
|
|
51
42
|
uniqueId: string | null;
|
|
52
43
|
v12: MinMaxCurrent | null;
|
|
53
44
|
vIn: MinMaxCurrent | null;
|
|
45
|
+
}
|
|
46
|
+
export declare class MainBoard extends Board {
|
|
47
|
+
constructor();
|
|
48
|
+
directDisplay: DirectDisplay | null;
|
|
49
|
+
firmwareName: string;
|
|
50
|
+
iapFileNameSBC: string | null;
|
|
51
|
+
iapFileNameSD: string | null;
|
|
52
|
+
maxHeaters: number;
|
|
53
|
+
supportsDirectDisplay: boolean;
|
|
54
54
|
wifiFirmwareFileName: string | null;
|
|
55
55
|
}
|
|
56
|
+
export declare class ExpansionBoard extends Board {
|
|
57
|
+
constructor();
|
|
58
|
+
closedLoop: BoardClosedLoop | null;
|
|
59
|
+
inductiveSensor: InductiveSensor | null;
|
|
60
|
+
state: BoardState;
|
|
61
|
+
timeout: number;
|
|
62
|
+
}
|
|
56
63
|
export default Board;
|
|
64
|
+
/**
|
|
65
|
+
* Create the board instance for a given index. The first item is always the mainboard,
|
|
66
|
+
* every other item is an expansion board connected over CAN
|
|
67
|
+
* @param index Index in the boards array
|
|
68
|
+
* @returns New board instance
|
|
69
|
+
*/
|
|
70
|
+
export declare function getBoard(index: number): Board;
|
|
57
71
|
export * from "./directDisplay";
|
|
58
72
|
export * from "./Driver";
|
package/dist/boards/index.js
CHANGED
|
@@ -41,38 +41,58 @@ export class Board extends ModelObject {
|
|
|
41
41
|
super();
|
|
42
42
|
this.accelerometer = null;
|
|
43
43
|
this.canAddress = null;
|
|
44
|
-
this.closedLoop = null;
|
|
45
|
-
this.directDisplay = null;
|
|
46
44
|
this.drivers = null;
|
|
47
45
|
this.firmwareDate = "";
|
|
48
46
|
this.firmwareFileName = "";
|
|
49
|
-
this.firmwareName = "";
|
|
50
47
|
this.firmwareVersion = "";
|
|
51
48
|
this.freeRam = null;
|
|
52
|
-
this.iapFileNameSBC = null;
|
|
53
|
-
this.iapFileNameSD = null;
|
|
54
|
-
this.inductiveSensor = null;
|
|
55
|
-
this.maxHeaters = 0;
|
|
56
49
|
this.maxMotors = 0;
|
|
57
50
|
this.mcuTemp = null;
|
|
58
51
|
this.name = "";
|
|
59
52
|
this.shortName = "";
|
|
60
|
-
this.state = BoardState.unknown;
|
|
61
|
-
this.supportsDirectDisplay = false;
|
|
62
53
|
this.uniqueId = null;
|
|
63
54
|
this.v12 = null;
|
|
64
55
|
this.vIn = null;
|
|
65
|
-
this.wifiFirmwareFileName = null;
|
|
66
56
|
ModelObject.wrapModelProperty(this, "accelerometer", Accelerometer);
|
|
67
|
-
ModelObject.wrapModelProperty(this, "closedLoop", BoardClosedLoop);
|
|
68
|
-
ModelObject.wrapModelProperty(this, "directDisplay", DirectDisplay);
|
|
69
57
|
ModelObject.wrapModelCollectionProperty(this, "drivers", Driver);
|
|
70
|
-
ModelObject.wrapModelProperty(this, "inductiveSensor", InductiveSensor);
|
|
71
58
|
ModelObject.wrapModelProperty(this, "mcuTemp", MinMaxCurrent);
|
|
72
59
|
ModelObject.wrapModelProperty(this, "v12", MinMaxCurrent);
|
|
73
60
|
ModelObject.wrapModelProperty(this, "vIn", MinMaxCurrent);
|
|
74
61
|
}
|
|
75
62
|
}
|
|
63
|
+
export class MainBoard extends Board {
|
|
64
|
+
constructor() {
|
|
65
|
+
super();
|
|
66
|
+
this.directDisplay = null;
|
|
67
|
+
this.firmwareName = "";
|
|
68
|
+
this.iapFileNameSBC = null;
|
|
69
|
+
this.iapFileNameSD = null;
|
|
70
|
+
this.maxHeaters = 0;
|
|
71
|
+
this.supportsDirectDisplay = false;
|
|
72
|
+
this.wifiFirmwareFileName = null;
|
|
73
|
+
ModelObject.wrapModelProperty(this, "directDisplay", DirectDisplay);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export class ExpansionBoard extends Board {
|
|
77
|
+
constructor() {
|
|
78
|
+
super();
|
|
79
|
+
this.closedLoop = null;
|
|
80
|
+
this.inductiveSensor = null;
|
|
81
|
+
this.state = BoardState.unknown;
|
|
82
|
+
this.timeout = 10;
|
|
83
|
+
ModelObject.wrapModelProperty(this, "closedLoop", BoardClosedLoop);
|
|
84
|
+
ModelObject.wrapModelProperty(this, "inductiveSensor", InductiveSensor);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
76
87
|
export default Board;
|
|
88
|
+
/**
|
|
89
|
+
* Create the board instance for a given index. The first item is always the mainboard,
|
|
90
|
+
* every other item is an expansion board connected over CAN
|
|
91
|
+
* @param index Index in the boards array
|
|
92
|
+
* @returns New board instance
|
|
93
|
+
*/
|
|
94
|
+
export function getBoard(index) {
|
|
95
|
+
return (index === 0) ? new MainBoard() : new ExpansionBoard();
|
|
96
|
+
}
|
|
77
97
|
export * from "./directDisplay";
|
|
78
98
|
export * from "./Driver";
|