(
actor: ActorState,
letter: string,
input: AgentsViewInput,
index: PlacementIndex,
byId: Map<number, GraphNode>,
)
| 249 | } |
| 250 | |
| 251 | function viewOf( |
| 252 | actor: ActorState, |
| 253 | letter: string, |
| 254 | input: AgentsViewInput, |
| 255 | index: PlacementIndex, |
| 256 | byId: Map<number, GraphNode>, |
| 257 | ): ActorView { |
| 258 | const placement = placeEvent(actor.last, actor.kind, index); |
| 259 | const strip = activityStrip(actor.events, input.now, STRIP_SECONDS); |
| 260 | const sinceMs = Math.max(0, input.now - actor.lastTs); |
| 261 | const idle = sinceMs > IDLE_MS; |
| 262 | /* |
| 263 | * Der Puls kommt aus der GEZAEHLTEN Zahl der Ereignisse im Fenster, und ein |
| 264 | * ruhiger Akteur bekommt gar keinen. Damit ist der Puls selbst eine |
| 265 | * Auskunft: er hoert auf, wenn die Arbeit aufhoert. Ein Herzschlag, der im |
| 266 | * Leerlauf weiterschlaegt, waere die Behauptung einer Arbeit, die nicht |
| 267 | * stattfindet. |
| 268 | */ |
| 269 | const recentEvents = idle ? 0 : eventsInWindow(actor, input.now, PULSE_WINDOW_MS); |
| 270 | return { |
| 271 | id: actor.id, |
| 272 | name: actor.name, |
| 273 | you: actor.you, |
| 274 | color: agentColor(actor.id), |
| 275 | letter, |
| 276 | kind: actor.kind, |
| 277 | kindLetter: WORK_KIND_LETTERS[actor.kind], |
| 278 | placement, |
| 279 | node: placement.nodeId === undefined ? undefined : byId.get(placement.nodeId), |
| 280 | testedNode: placement.testedNodeId === undefined |
| 281 | ? undefined |
| 282 | : byId.get(placement.testedNodeId), |
| 283 | ghostNodes: placement.ghostIds |
| 284 | .map((id) => byId.get(id)) |
| 285 | .filter((node): node is GraphNode => node !== undefined), |
| 286 | last: actor.last, |
| 287 | lastTs: actor.lastTs, |
| 288 | hereMs: timeAtPlace(actor, input.now), |
| 289 | count: actor.count, |
| 290 | missed: actor.missed, |
| 291 | strip, |
| 292 | stripTotal: strip.reduce((sum, value) => sum + value, 0), |
| 293 | intent: actor.last.intent ?? '', |
| 294 | paths: recentPaths(actor, input.now, input.trailWindowMs), |
| 295 | sinceMs, |
| 296 | idle, |
| 297 | recentEvents, |
| 298 | pulse: pulseOf(recentEvents), |
| 299 | trail: trailOf(actor, input.now, input.trailWindowMs, index, byId), |
| 300 | waves: idle ? [] : currentBursts(burstsOf(actor, index), actor.lastTs), |
| 301 | drawn: true, |
| 302 | }; |
| 303 | } |
| 304 | |
| 305 | /** |
| 306 | * Die Sicht bauen. |
no test coverage detected