Last active
June 22, 2021 04:22
-
-
Save ricehornet/6eb9092fda2e3e00c7fd4c80148329ad to your computer and use it in GitHub Desktop.
# In the previous model, we used Credit Leading/Following to capture PAYG credit behaviors. Credit Leading basically meant "use your local credit and POST to accessories"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In the previous model, we used Credit Leading/Following to capture PAYG credit behaviors. Credit Leading basically meant "use your local credit and POST to accessories" | |
# and Credit Following meant "be POSTed to by a Leader". The addition of "unlocked" complicated the model due to scenarios where accessories would need to use local credit | |
# but had no accessories of their own. The concept of a "credit origin" can handle this case, where Leading and Following are now specific cases. When the Credit Origin | |
# Self, it means "use your local credit"; when it is "External" it means "be POSTed to by an external source". | |
PAYG Credit Resource Behavior with NXC Links and Credit Origin | |
# Initial state | |
Credit origin is Self* | |
# 'local credit' is what the 'nxp' interface reports for PAYG credit (what it was last updated to by a Nexus message, either keycode or channel) | |
new link made -> Change credit origin? | |
# let lower layers handle whether or not commanded devices exist (controller, no linked accessories case) / can exist (accessory case) | |
any other link event -> Use local credit and update commanded devices | |
Change credit origin? | |
In controller role for new link? -> Credit origin is Self | |
In accessory role for new link? -> Credit origin is External | |
Credit origin is External | |
No links -> 0 credit | |
Has links but none new -> Use commanded credit | |
Unlink -> 0 credit | |
New link -> Use commanded credit | |
Use local credit and update commanded devices | |
Link event -> Credit origin is Self | |
0 credit | |
Use commanded credit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function render(model){ | |
let current_state_name = model.active_states[0].name; | |
return $("h1", | |
{style: {color: "darkBlue"}}, | |
`The current state is: ${current_state_name}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment