lsh
2026-04-21 7443e8040d9a7669a8117c8a6937dbd4bd792709
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
//MapCanvas.js 里废弃的函数,暂时保留在这里,方便后续如有需要再恢复
 
// function getMappingInfo(point) {
//   let angle, path, vector, x, y;
//   this.allSmoothList.find((smoothList) => {
//     const smoothLength = smoothList.length;
//     const existPath = smoothList.find((currentPath, i) => {
//       const prevPath = smoothList[(i - 1 + smoothLength) % smoothLength];
//       if (currentPath.type === "line") {
//         const prevPathEndPoint =
//           prevPath.type === "arc"
//             ? {
//               x: prevPath.arcEndX,
//               y: prevPath.arcEndY,
//             }
//             : prevPath;
//         return this.isPointOnSegment(point, prevPathEndPoint, currentPath);
//       } else {
//         const start = {
//           x: currentPath.arcStartX,
//           y: currentPath.arcStartY,
//         };
//         const middle = {
//           x: currentPath.arcMiddleX,
//           y: currentPath.arcMiddleY,
//         };
//         const end = { x: currentPath.arcEndX, y: currentPath.arcEndY };
//         return (
//           this.isPointOnSegment(point, start, middle) ||
//           this.isPointOnSegment(point, middle, end)
//         );
//       }
//     });
//     if (!existPath) {
//       return false;
//     }
//     path = existPath;
//     vector = this.normalizeVector(existPath, point);
//     if (existPath.type === "arc") {
//       x = existPath.x + vector.x * existPath.radius;
//       y = existPath.y + vector.y * existPath.radius;
//       angle = Math.atan2(vector.y, vector.x);
//     } else {
//       x = point.x;
//       y = point.y;
//       angle = null;
//     }
//     return true;
//   });
//   return {
//     angle,
//     path,
//     x,
//     y,
//     vector,
//   };
// }
 
// setDeviceInfo(type, res) {
//   const deviceTypeInfo = this.DEVICE_MAP[type];
//   let devices = Array.isArray(res) ? res : res && res.code === 200 ? res.data : null;
//   if (!devices) {
//     return;
//   }
//   for (var i = 0; i < devices.length; i++) {
//     const device = devices[i];
//     const id = parseInt(device[deviceTypeInfo.idName]);
//     const sprite = deviceTypeInfo.pixiMap.get(id);
//     if (!sprite) {
//       continue;
//     }
//     // 找到sprite了就更新颜色和文字
//     const taskNo = device.taskNo;
//     if (taskNo != null && taskNo > 0) {
//       sprite.textObj.text = id + '(' + taskNo + ')';
//     } else {
//       sprite.textObj.text = String(id);
//     }
//     this.applyEditorLikeTrackDeviceTextStyle(sprite.textObj);
//     const status = device[deviceTypeInfo.statusInfo.name];
//     const statusColor = deviceTypeInfo.statusInfo.getStatus(status);
//     deviceTypeInfo.statusInfo.updateTextureColor(sprite, statusColor);
 
//     const oldSprite = {
//       ...sprite,
//       x: sprite.x,
//       y: sprite.y,
//       mappingInfo: { ...sprite.mappingInfo }
//     };
//     // 后端传过来的是左上角的点,这里取中心点
//     device.width = sprite.width;
//     device.height = sprite.height;
//     const sourcePoint = {
//       x: device.x + device.width / 2,
//       y: device.y + device.height / 2
//     };
//     const mappingInfo = this.getMappingInfo({ ...device, ...sourcePoint });
//     sprite.mappingInfo = mappingInfo;
//     sprite.time = Date.now();
//     if (!oldSprite.time) {
//       sprite.x = sprite.mappingInfo.x;
//       sprite.y = sprite.mappingInfo.y;
//       sprite.rotation = sprite.mappingInfo.rotate;
//       sprite.path = sprite.mappingInfo.path;
//       sprite.vector = sprite.mappingInfo.vector;
//       continue;
//     }
//     // const curveDistance = this.getCurveDistance(
//     //   oldSprite.mappingInfo,sprite.mappingInfo,
//     //   oldSprite.mappingInfo.path,sprite.mappingInfo.path,
//     //   oldSprite.mappingInfo.angle,sprite.mappingInfo.angle
//     // );
//     const curveDistance = G.calcDistance(oldSprite.mappingInfo, sprite.mappingInfo);
//     const deltaTime = (sprite.time - oldSprite.time) / 1000 || 0;
//     if (deltaTime > 0 && deltaTime <= 10 && curveDistance > 0) {
//       // 保存本次帧间隔,供 ticker 判断数据新鲜度
//       sprite.lastDeltaTime = deltaTime;
//       // 用指数移动平均(α=0.35)代替窗口均值,对速度变化响应更快
//       const v = curveDistance / deltaTime;
//       const alpha = 0.35;
//       sprite.maV =
//         typeof sprite.maV === 'number' && isFinite(sprite.maV)
//           ? sprite.maV * (1 - alpha) + v * alpha
//           : v;
//     }
//     if (curveDistance < EPSILON) {
//       // 已无剩余路程或新数据与当前目标一致:必须收尾并移除 ticker,否则会一直跑
//       this.finishDeviceMotion(sprite);
//     } else {
//       sprite.isFinish = false;
//       if (sprite.ticker) {
//         // 已有插值回调:mappingInfo 已在上方更新,继续追新目标;勿 return(会中断其它设备)
//         continue;
//       }
//       const Gm = window.BasMapTrackGeometry;
//       const trackElForMove =
//         this.map2 && sprite.pathId != null
//           ? this.map2.find((item) => item && item.id === sprite.pathId)
//           : null;
//       const pathListForMove =
//         trackElForMove &&
//         trackElForMove.pathList &&
//         trackElForMove.pathList.length
//           ? trackElForMove.pathList
//           : null;
//       if (!pathListForMove || !Gm) {
//         this.finishDeviceMotion(sprite);
//         continue;
//       }
//       const fn = () => {
//         if (sprite.isFinish) {
//           return;
//         }
//         const restDistance = G.calcDistance(sprite, sprite.mappingInfo);
//         if (restDistance <= EPSILON) {
//           this.finishDeviceMotion(sprite);
//           return;
//         }
//         const dtMs =
//           this.pixiApp && this.pixiApp.ticker && typeof this.pixiApp.ticker.deltaMS === 'number'
//             ? this.pixiApp.ticker.deltaMS
//             : 16.667;
//         const dt = Math.max(0, dtMs) / 1000;
//         if (dt <= 0) {
//           return;
//         }
//         const baseV =
//           typeof sprite.maV === 'number' && isFinite(sprite.maV) && sprite.maV > 0
//             ? sprite.maV
//             : Math.max(sprite.width * 2, 20);
//         // 数据新鲜度判断:
//         // 服务器帧间隔内有新数据到来 → 全速追目标(不减速,避免下一帧"追赶抖动")
//         // 数据停止推送 → 线性减速收敛到终点
//         const msSinceUpdate = sprite.time ? Date.now() - sprite.time : 0;
//         const typicalIntervalMs = (sprite.lastDeltaTime || 1) * 1000;
//         const isStale = msSinceUpdate > typicalIntervalMs * 1.5;
//         const easing = isStale ? Math.min(1.0, restDistance / Math.max(sprite.width, 1)) : 1.0;
//         const smoothDistance = Math.min(restDistance, dt * baseV * easing);
//         const path = sprite.path;
//         const movePoint =
//           trackElForMove &&
//           trackElForMove.type === 'annulus' &&
//           Gm.snapToAnnulusOuterPath
//             ? Gm.snapToAnnulusOuterPath(sprite.x, sprite.y, path)
//             : sprite;
//         const angle = Math.atan2(sprite.y - path.y, sprite.x - path.x);
//         const p = Gm.getPositionAfterMove({
//           point: movePoint,
//           pathList: pathListForMove,
//           path,
//           deltaDistance: smoothDistance,
//           angle
//         });
//         let px = p.x;
//         let py = p.y;
//         if (
//           trackElForMove &&
//           trackElForMove.type === 'annulus' &&
//           Gm.centerAnnulusBandPoint
//         ) {
//           const c = Gm.centerAnnulusBandPoint(trackElForMove, p.x, p.y, p.path);
//           px = c.x;
//           py = c.y;
//         }
//         sprite.path = p.path;
//         sprite.x = px;
//         sprite.y = py;
//         sprite.rotation = this.getRotate(p, p.path);
//         const restDistanceAfter = G.calcDistance(
//           { x: sprite.x, y: sprite.y },
//           sprite.mappingInfo
//         );
//         if (restDistanceAfter <= EPSILON || smoothDistance >= restDistance) {
//           this.finishDeviceMotion(sprite);
//           return;
//         }
//       };
//       sprite.ticker = fn;
//       this.pixiApp.ticker.add(sprite.ticker);
//     }
//   }
//   this.scheduleAdjustLabels();
// },
 
// const list = [{
//   x: 853.92,
//   y: 457
// }, {
//   x: 953.92,
//   y: 457
// }, {
//   x: 1053.92,
//   y: 457
// }, {
//   x: 1153.92,
//   y: 457
// }, {
//   x: 1253.92,
//   y: 457
// }, {
//   x: 1353.92,
//   y: 457
// }, {
//   x: 1453.92,
//   y: 457
// }, {
//   x: 1553.92,
//   y: 457
// }, {
//   x: 1653.92,
//   y: 457
// }];
// const raw = {
//   crnStatus: 'machine-auto',
//   offset: 1,
//   crnId: 15,
//   pathId: 'el_1775197504724'
// };