feat: a signal switched off switches its dependent math channels off too
A derived channel cannot be computed from a signal nobody acquires: `Source` resolves to a
*channel*, and a disabled signal has none -- so a channel that reads one silently computed
nothing, which is what "all math signals depending on it do not compute anymore" looked like
from outside.
Rather than leave it enabled and blank, the channels that read the signal follow it off:
`disable_dependent_math_channels()` walks the graphs to a **fixpoint**, because one math
channel may name another, and the switch goes through the same path the pane's own toggle
uses -- `MathChannel::enabled` then `apply_math_channels()`, the single writer -- so the
pane's switches follow. Their traces leave the plots with the signal's, and the notice says
both halves.
The channels that do *not* read it are untouched, which is the assertion's other half:
[enable-all-probe] switched 'sine' off: traces_left=0 (want 0)
math_off=[math x2,math3] math_on=[math lp]
notice=''sine' is off: 1 trace left the plots; math off: math x2 and 1 more'
`math x2` and `math3` both source `sine`; `math lp` sources `noise` and stays on. The probe's
switch step now runs late enough that a math probe armed behind it has installed its graphs,
which is why the earlier reading was empty -- `app.math` had nothing in it yet, not
"no dependants".
Re-enabling the signal does not switch them back on, for the same reason it does not restore
the traces: that is the user's decision, and the rule is written down in
invariants-math-channels.md.
This commit is contained in:
1 parent
5eb20f3cdb
commit
b02419dee3
6 files changed
+92
-9
No files matched your search
+22
-4
@@ -1873,8 +1873,9 @@ gboolean enable_all_probe(gpointer user) {
|
||||
a->model->channel_count());
|
||||
std::fflush(stderr);
|
||||
// Then switch one off through its own switch in the signal list: a disabled signal must leave the plots,
|
||||
// not sit there drawing nothing in a slot a live one could take.
|
||||
g_timeout_add(250, +[](gpointer u) -> gboolean {
|
||||
// not sit there drawing nothing in a slot a live one could take. Late enough that a math probe armed behind
|
||||
// this one has had its graphs installed -- the dependants are the point of the second line.
|
||||
g_timeout_add(2000, +[](gpointer u) -> gboolean {
|
||||
App* app = static_cast<App*>(u);
|
||||
if (app->model->channels().empty() || app->signal_list == nullptr) return G_SOURCE_REMOVE;
|
||||
const std::size_t signal = app->model->channels().front().signal;
|
||||
@@ -1907,8 +1908,25 @@ gboolean enable_all_probe(gpointer user) {
|
||||
if (app->rows->row(r).signal_name[static_cast<std::size_t>(s)] == name) ++left;
|
||||
}
|
||||
}
|
||||
std::fprintf(stderr, "[enable-all-probe] switched '%s' off: traces_left=%d (want 0) notice='%s'\n",
|
||||
name.c_str(), left, app->notice.c_str());
|
||||
// Which *math* channels the disabled signal took with it: a derived channel cannot be computed from a
|
||||
// signal nobody acquires, so the ones that read it follow it off -- and their traces go too.
|
||||
std::string off_list;
|
||||
for (const MathChannel& m : app->math) {
|
||||
if (m.enabled) continue;
|
||||
if (!off_list.empty()) off_list += ",";
|
||||
off_list += m.name;
|
||||
}
|
||||
// Both halves: the channels that read it went off, and the ones that do not are still on.
|
||||
std::string on_list;
|
||||
for (const MathChannel& m : app->math) {
|
||||
if (!m.enabled) continue;
|
||||
if (!on_list.empty()) on_list += ",";
|
||||
on_list += m.name;
|
||||
}
|
||||
std::fprintf(stderr,
|
||||
"[enable-all-probe] switched '%s' off: traces_left=%d (want 0) math_off=[%s] "
|
||||
"math_on=[%s] notice='%s'\n",
|
||||
name.c_str(), left, off_list.c_str(), on_list.c_str(), app->notice.c_str());
|
||||
std::fflush(stderr);
|
||||
return G_SOURCE_REMOVE;
|
||||
}, a);
|
||||
|
||||
Reference in new issue
Block a user