-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscratchpad.js
48 lines (39 loc) · 1.64 KB
/
scratchpad.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
/* Rules of thumb */
const $machine, $material, $model;
let materialMustMatchMachine = $(material).addListener('select', () => {
let acceptableMaterials = $(machine).metrics.acceptableMaterials;
if (acceptableMaterials && acceptableMaterials.includes(material)) {
throw Error(`${$(machine)} cannot work with ${$(material).name}.`);
};
});
let modelMustFitInEnvelope = $(model).addListener('placeAt', (x, y, z) => {
let we = $(machine).getMetrics().workEnvelopeDimensions;
if (we && $(model).width > we.width
|| $(model).height > we.height
|| $(model).length > we.length) {
throw Error(`${$(model).name} is too large for this machine.`);
}
});
let machineMustHandleTallFeatures = $(machine).onLoad(() => {
/* We say a machine can handle tall features if
* - it does not use a platform that moves on the XZ plane
* - it uses a gantry style mechanism for its XZ movements, which
* is represented in the Description as "mechanismType" : "cross" */
let hasXZPlatform = $(machine).metrics.hasXZPlatform;
let maybeXZGantry = $(machine).mechanisms.find((mechanism) => {
let isGantry = mechanism.mechanismType === 'cross';
let onXZPlane = mechanism.actuationAxes.includes('x')
&& mechanism.actuationAxes.includes('z');
return isGantry && onXZPlane;
});
if (hasXZPlatform) {
throw Error('XZ platforms cause too much wobbling for tall features.');
}
if (!maybeXZGantry) {
throw Error('We need an XZ gantry to handle tall features.');
}
});
/* Metric spec */
let calculateRigidityScores = () => {
};