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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
import { Record } from "../fable_modules/fable-library-js.4.24.0/Types.js";
import { bool_type, option_type, class_type, enum_type, array_type, string_type, int32_type, record_type, float64_type } from "../fable_modules/fable-library-js.4.24.0/Reflection.js";
import { item, collect } from "../fable_modules/fable-library-js.4.24.0/Array.js";
import { singleton, append, collect as collect_1, delay, toArray } from "../fable_modules/fable-library-js.4.24.0/Seq.js";
import { rangeDouble } from "../fable_modules/fable-library-js.4.24.0/Range.js";
import { op_Subtraction } from "../fable_modules/fable-library-js.4.24.0/DateOffset.js";
export class Vector3 extends Record {
constructor(X, Y, Z) {
super();
this.X = X;
this.Y = Y;
this.Z = Z;
}
}
export function Vector3_$reflection() {
return record_type("SomhairlesDream.Shared.Vector3", [], Vector3, () => [["X", float64_type], ["Y", float64_type], ["Z", float64_type]]);
}
export class MeshSnapshot extends Record {
constructor(Version, Label, Vertices, Faces) {
super();
this.Version = (Version | 0);
this.Label = Label;
this.Vertices = Vertices;
this.Faces = Faces;
}
}
export function MeshSnapshot_$reflection() {
return record_type("SomhairlesDream.Shared.MeshSnapshot", [], MeshSnapshot, () => [["Version", int32_type], ["Label", string_type], ["Vertices", array_type(Vector3_$reflection())], ["Faces", array_type(array_type(int32_type))]]);
}
export class LiveSnapshot extends Record {
constructor(ProjectId, RunId, Status, CurrentVersion, TargetVersion, HeartbeatAt, UpdatedAt, Message, Mesh, NextDesignRunScheduled) {
super();
this.ProjectId = ProjectId;
this.RunId = RunId;
this.Status = (Status | 0);
this.CurrentVersion = (CurrentVersion | 0);
this.TargetVersion = (TargetVersion | 0);
this.HeartbeatAt = HeartbeatAt;
this.UpdatedAt = UpdatedAt;
this.Message = Message;
this.Mesh = Mesh;
this.NextDesignRunScheduled = NextDesignRunScheduled;
}
}
export function LiveSnapshot_$reflection() {
return record_type("SomhairlesDream.Shared.LiveSnapshot", [], LiveSnapshot, () => [["ProjectId", string_type], ["RunId", string_type], ["Status", enum_type("SomhairlesDream.Shared.RunStatus", int32_type, [["Idle", 0], ["Queued", 1], ["Running", 2], ["Succeeded", 3], ["Failed", 4], ["Stale", 5]])], ["CurrentVersion", int32_type], ["TargetVersion", int32_type], ["HeartbeatAt", option_type(class_type("System.DateTimeOffset"))], ["UpdatedAt", class_type("System.DateTimeOffset")], ["Message", string_type], ["Mesh", option_type(MeshSnapshot_$reflection())], ["NextDesignRunScheduled", bool_type]]);
}
export function MeshData_positionData(mesh) {
return collect((vertex) => (new Float64Array([vertex.X, vertex.Y, vertex.Z])), mesh.Vertices, Float64Array);
}
export function MeshData_triangleIndices(mesh) {
return collect((face) => {
if (face.length < 3) {
return new Int32Array([]);
}
else {
return toArray(delay(() => collect_1((index) => append(singleton(item(0, face)), delay(() => append(singleton(item(index, face)), delay(() => singleton(item(index + 1, face)))))), rangeDouble(1, 1, face.length - 2))));
}
}, mesh.Faces, Int32Array);
}
export function RunState_initial(projectId, runId, now) {
return new LiveSnapshot(projectId, runId, 0, 0, 0, undefined, now, "等待设计运行", undefined, false);
}
export function RunState_start(now, state) {
const targetVersion = (state.TargetVersion + 1) | 0;
return new LiveSnapshot(state.ProjectId, state.RunId, 2, state.CurrentVersion, targetVersion, now, now, `正在生成第 ${targetVersion} 版几何`, state.Mesh, false);
}
export function RunState_heartbeat(now, state) {
if (state.Status === 2) {
return new LiveSnapshot(state.ProjectId, state.RunId, state.Status, state.CurrentVersion, state.TargetVersion, now, now, state.Message, state.Mesh, state.NextDesignRunScheduled);
}
else {
return state;
}
}
export function RunState_statusAt(timeout, now, state) {
const matchValue = state.HeartbeatAt;
let matchResult, heartbeatAt_1;
if (matchValue != null) {
if ((state.Status === 2) && (op_Subtraction(now, matchValue) > timeout)) {
matchResult = 0;
heartbeatAt_1 = matchValue;
}
else {
matchResult = 1;
}
}
else {
matchResult = 1;
}
switch (matchResult) {
case 0:
return new LiveSnapshot(state.ProjectId, state.RunId, 5, state.CurrentVersion, state.TargetVersion, state.HeartbeatAt, now, "心跳超时,等待重连", state.Mesh, state.NextDesignRunScheduled);
default:
return state;
}
}
export function RunState_publish(now, mesh, state) {
return new LiveSnapshot(state.ProjectId, state.RunId, 3, mesh.Version, state.TargetVersion, now, now, `已发布${mesh.Label}`, mesh, false);
}
|