BusDiagram GitHub Download

Examples

#Telegram events

on("telegram", …) receives every telegram, including commands and automatic status feedback. This page builds a simple event log beside the diagram.

<bus-diagram
  id="telegram-sim"
  scenario="#telegram-json"
  monitor="false"
  toolbar="compact"
  description="false"></bus-diagram>
<ol
  id="telegram-log"
  style="font-family:monospace;font-size:13px;max-height:180px;overflow:auto"></ol>
<script>
  document.getElementById("telegram-sim").on("telegram", (t) => {
    const li = document.createElement("li");
    li.textContent = `${(t.timeMs / 1000).toFixed(1)} s  ${t.source} → ${t.destination} = ${t.value}  (${t.kind === "state" ? "status feedback" : "command"})`;
    document.getElementById("telegram-log").append(li);
  });
</script>