@duet3d/objectmodel 3.6.0-beta.6 → 3.6.0-beta.8

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.
@@ -3,9 +3,6 @@ import { IModelObject } from "./ModelObject";
3
3
  * Class for storing model object items in an array
4
4
  */
5
5
  export declare class ModelCollection<T extends IModelObject | null> extends Array<T> implements IModelObject {
6
- readonly itemConstructor: {
7
- new (): T;
8
- };
9
6
  /**
10
7
  * Constructor of this class
11
8
  * @param itemConstructor Item constructor type that items must derive from
@@ -14,8 +14,8 @@ class ModelCollection extends Array {
14
14
  */
15
15
  constructor(itemConstructor) {
16
16
  super();
17
- this.itemConstructor = itemConstructor;
18
17
  Object.setPrototypeOf(this, ModelCollection.prototype);
18
+ Object.defineProperty(this, "$itemConstructor", { enumerable: false, value: itemConstructor });
19
19
  }
20
20
  // Unfortunately it isn't possible to override index operators in JS/TS
21
21
  /**
@@ -23,12 +23,13 @@ class ModelCollection extends Array {
23
23
  * @param items Items to add
24
24
  */
25
25
  push(...items) {
26
+ const that = this;
26
27
  for (const item of items) {
27
- if (item === null || item instanceof this.itemConstructor) {
28
+ if (item === null || item instanceof that.$itemConstructor) {
28
29
  super.push(item);
29
30
  }
30
31
  else {
31
- const newItem = new this.itemConstructor();
32
+ const newItem = new that.$itemConstructor();
32
33
  super.push(newItem.update(item));
33
34
  }
34
35
  }
@@ -46,6 +47,7 @@ class ModelCollection extends Array {
46
47
  if (!(jsonElement instanceof Array)) {
47
48
  throw new Error(`Invalid JSON element type for model collection ${typeof jsonElement}`);
48
49
  }
50
+ const that = this;
49
51
  // Remove deleted items
50
52
  this.splice(jsonElement.length);
51
53
  // Update existing items
@@ -53,11 +55,11 @@ class ModelCollection extends Array {
53
55
  const currentItem = this[i];
54
56
  if (currentItem === null) {
55
57
  const newItem = jsonElement[i];
56
- if (newItem instanceof this.itemConstructor) {
58
+ if (newItem instanceof that.$itemConstructor) {
57
59
  (0, index_1.setArrayItem)(this, i, jsonElement[i]);
58
60
  }
59
61
  else {
60
- const refItem = new this.itemConstructor();
62
+ const refItem = new that.$itemConstructor();
61
63
  (0, index_1.setArrayItem)(this, i, refItem.update(newItem));
62
64
  }
63
65
  }
@@ -81,7 +83,7 @@ class ModelCollection extends Array {
81
83
  super.push(itemToAdd);
82
84
  }
83
85
  else {
84
- const newItem = new this.itemConstructor();
86
+ const newItem = new that.$itemConstructor();
85
87
  super.push(newItem.update(itemToAdd));
86
88
  }
87
89
  }
@@ -3,10 +3,6 @@ import { IModelObject } from "./ModelObject";
3
3
  * Dictionary class to map object model data
4
4
  */
5
5
  export declare class ModelDictionary<T> extends Map<string, T | null> implements IModelObject {
6
- readonly nullDeletesKeys: boolean;
7
- readonly itemConstructor: {
8
- new (): T;
9
- } | null;
10
6
  /**
11
7
  * Constructor of this class
12
8
  * @param nullDeletesKeys Whether setting null to items effectively deletes them
@@ -14,9 +14,9 @@ class ModelDictionary extends Map {
14
14
  */
15
15
  constructor(nullDeletesKeys, itemConstructor = null) {
16
16
  super();
17
- this.nullDeletesKeys = nullDeletesKeys;
18
- this.itemConstructor = itemConstructor;
19
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
20
  }
21
21
  /**
22
22
  * Overridden set method to perform type-checks and update
@@ -24,8 +24,9 @@ class ModelDictionary extends Map {
24
24
  * @param value Value to set
25
25
  */
26
26
  set(key, value) {
27
+ const that = this;
27
28
  if (value === null) {
28
- if (this.nullDeletesKeys) {
29
+ if (that.$nullDeletesKeys) {
29
30
  this.delete(key);
30
31
  return this;
31
32
  }
@@ -33,8 +34,8 @@ class ModelDictionary extends Map {
33
34
  }
34
35
  const currentItem = this.get(key);
35
36
  if (currentItem == null) {
36
- if (this.itemConstructor !== null && !(value instanceof this.itemConstructor)) {
37
- const newItem = new this.itemConstructor();
37
+ if (that.$itemConstructor !== null && !(value instanceof that.$itemConstructor)) {
38
+ const newItem = new that.$itemConstructor();
38
39
  if ((0, ModelObject_1.isModelObject)(newItem)) {
39
40
  const updatedItem = newItem.update(value);
40
41
  return super.set(key, updatedItem);
@@ -2,6 +2,11 @@ import { IModelObject } from "../../ModelObject";
2
2
  import KinematicsBase from "./KinematicsBase";
3
3
  export declare class PolarKinematics extends KinematicsBase {
4
4
  constructor();
5
+ radiusHomed: number;
6
+ radiusMax: number;
7
+ radiusMin: number;
8
+ ttAccMax: number;
9
+ ttSpeedMax: number;
5
10
  update(jsonElement: any): IModelObject | null;
6
11
  }
7
12
  export default PolarKinematics;
@@ -6,6 +6,11 @@ const index_1 = require("./index");
6
6
  class PolarKinematics extends KinematicsBase_1.default {
7
7
  constructor() {
8
8
  super(KinematicsBase_1.KinematicsName.polar);
9
+ this.radiusHomed = 0;
10
+ this.radiusMax = 0;
11
+ this.radiusMin = 0;
12
+ this.ttAccMax = 0;
13
+ this.ttSpeedMax = 0;
9
14
  }
10
15
  update(jsonElement) {
11
16
  if (jsonElement === null) {
@@ -1,6 +1,14 @@
1
1
  import { IModelObject } from "../../ModelObject";
2
2
  import { ZLeadscrewKinematics } from "./KinematicsBase";
3
3
  export declare class ScaraKinematics extends ZLeadscrewKinematics {
4
+ crosstalk: number[];
5
+ distalLength: number;
6
+ minRadius: number;
7
+ proximalLength: number;
8
+ psiLimits: number[];
9
+ thetaLimits: number[];
10
+ xOffset: number;
11
+ yOffset: number;
4
12
  update(jsonElement: any): IModelObject | null;
5
13
  }
6
14
  export default ScaraKinematics;
@@ -4,6 +4,17 @@ exports.ScaraKinematics = void 0;
4
4
  const KinematicsBase_1 = require("./KinematicsBase");
5
5
  const index_1 = require("./index");
6
6
  class ScaraKinematics extends KinematicsBase_1.ZLeadscrewKinematics {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.crosstalk = [0, 0, 0];
10
+ this.distalLength = 0;
11
+ this.minRadius = 0;
12
+ this.proximalLength = 0;
13
+ this.psiLimits = [0, 0];
14
+ this.thetaLimits = [0, 0];
15
+ this.xOffset = 0;
16
+ this.yOffset = 0;
17
+ }
7
18
  update(jsonElement) {
8
19
  if (jsonElement === null) {
9
20
  throw new Error("Kinematics must not be null");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duet3d/objectmodel",
3
- "version": "3.6.0-beta.6",
3
+ "version": "3.6.0-beta.8",
4
4
  "description": "TypeScript implementation of the Duet3D Object Model",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,19 +0,0 @@
1
- import ModelObject from "../ModelObject";
2
- export declare enum HttpEndpointType {
3
- GET = "GET",
4
- POST = "POST",
5
- PUT = "PUT",
6
- PATCH = "PATCH",
7
- TRACE = "TRACE",
8
- DELETE = "DELETE",
9
- OPTIONS = "OPTIONS",
10
- WebSocket = "WebSocket"
11
- }
12
- export declare class HttpEndpoint extends ModelObject {
13
- endpointType: HttpEndpointType;
14
- namespace: string;
15
- path: string;
16
- isUploadRequest: boolean;
17
- unixSocket: string;
18
- }
19
- export default HttpEndpoint;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpEndpoint = exports.HttpEndpointType = void 0;
4
- const ModelObject_1 = require("../ModelObject");
5
- var HttpEndpointType;
6
- (function (HttpEndpointType) {
7
- HttpEndpointType["GET"] = "GET";
8
- HttpEndpointType["POST"] = "POST";
9
- HttpEndpointType["PUT"] = "PUT";
10
- HttpEndpointType["PATCH"] = "PATCH";
11
- HttpEndpointType["TRACE"] = "TRACE";
12
- HttpEndpointType["DELETE"] = "DELETE";
13
- HttpEndpointType["OPTIONS"] = "OPTIONS";
14
- HttpEndpointType["WebSocket"] = "WebSocket";
15
- })(HttpEndpointType = exports.HttpEndpointType || (exports.HttpEndpointType = {}));
16
- class HttpEndpoint extends ModelObject_1.default {
17
- constructor() {
18
- super(...arguments);
19
- this.endpointType = HttpEndpointType.GET;
20
- this.namespace = "";
21
- this.path = "";
22
- this.isUploadRequest = false;
23
- this.unixSocket = "";
24
- }
25
- }
26
- exports.HttpEndpoint = HttpEndpoint;
27
- exports.default = HttpEndpoint;
@@ -1,18 +0,0 @@
1
- import ModelObject from "../ModelObject";
2
- export declare enum AccessLevel {
3
- readOnly = "readOnly",
4
- readWrite = "readWrite"
5
- }
6
- export declare enum SessionType {
7
- local = "local",
8
- http = "http",
9
- telnet = "telnet"
10
- }
11
- export declare class UserSession extends ModelObject {
12
- accessLevel: AccessLevel;
13
- id: number;
14
- origin: string | null;
15
- originId: number;
16
- sessionType: SessionType;
17
- }
18
- export default UserSession;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserSession = exports.SessionType = exports.AccessLevel = void 0;
4
- const ModelObject_1 = require("../ModelObject");
5
- var AccessLevel;
6
- (function (AccessLevel) {
7
- AccessLevel["readOnly"] = "readOnly";
8
- AccessLevel["readWrite"] = "readWrite";
9
- })(AccessLevel = exports.AccessLevel || (exports.AccessLevel = {}));
10
- var SessionType;
11
- (function (SessionType) {
12
- SessionType["local"] = "local";
13
- SessionType["http"] = "http";
14
- SessionType["telnet"] = "telnet";
15
- })(SessionType = exports.SessionType || (exports.SessionType = {}));
16
- class UserSession extends ModelObject_1.default {
17
- constructor() {
18
- super(...arguments);
19
- this.accessLevel = AccessLevel.readOnly;
20
- this.id = 0;
21
- this.origin = null;
22
- this.originId = -1;
23
- this.sessionType = SessionType.local;
24
- }
25
- }
26
- exports.UserSession = UserSession;
27
- exports.default = UserSession;