When running the board interactively, if you click on a non-live pad, you get a message like
#<Monitor for Pad(3,0)> is not live
If, on the other hand, you turn on the pad using the macro language:
(3,0): on
you get no such message, and the (black) square on the display gets a green border.
BinaryComponent has two attributes, can_toggle and live, but Pad only sets live to False if exists is False. If it also set can_toggle, this would, presumably, take care of the problem, as BinaryComponent's current_state setter takes this into account and refuses (with an error) if you try on a non-toggleable component.
I'm not exactly sure why I have both a non-final live and final can_toggle. (The latter was a later addition.) live never gets changed. I suspect that the easiest thing to do is either to get rid of live and only use can_toggle or else at least ensure that can_toggle is never True if live is False.
While this is being changed, the setter for current_state should probably take broken into account.
Thinking about it some more, it might make sense to have the passed-in can_toggle stashed in a private attribute and add a property with that name that takes into account both it and broken (and live if it's still there).
Migrated from internal repository. Originally created by @EvanKirshenbaum on Aug 22, 2022 at 3:02 PM PDT.
When running the board interactively, if you click on a non-live pad, you get a message like
If, on the other hand, you turn on the pad using the macro language:
you get no such message, and the (black) square on the display gets a green border.
BinaryComponent
has two attributes,can_toggle
andlive
, butPad
only setslive
toFalse
ifexists
isFalse
. If it also setcan_toggle
, this would, presumably, take care of the problem, asBinaryComponent
'scurrent_state
setter takes this into account and refuses (with an error) if you try on a non-toggleable component.I'm not exactly sure why I have both a non-final
live
and finalcan_toggle
. (The latter was a later addition.)live
never gets changed. I suspect that the easiest thing to do is either to get rid oflive
and only usecan_toggle
or else at least ensure thatcan_toggle
is neverTrue
iflive
isFalse
.While this is being changed, the setter for
current_state
should probably takebroken
into account.Thinking about it some more, it might make sense to have the passed-in
can_toggle
stashed in a private attribute and add a property with that name that takes into account both it andbroken
(andlive
if it's still there).Migrated from internal repository. Originally created by @EvanKirshenbaum on Aug 22, 2022 at 3:02 PM PDT.