Last active
June 25, 2021 06:45
-
-
Save jjmilburn/b89c71b06deec9baf483355d1c41abf6 to your computer and use it in GitHub Desktop.
PAYG Credit Resource Interaction with NXC Links
This file contains hidden or 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
PAYG Credit Resource Interaction with NXC Links | |
# Initial state - | |
# implies that link state should be initialized before PAYG credit initializes | |
NXC Linked?* | |
No links? -> No NXC links | |
Any linked accessory has PAYG credit resource? -> Credit Leading | |
Any linked controller has PAYG credit resource? -> Credit Following | |
No NXC links | |
link or unlink event -> NXC Linked? | |
am an accessory only device?* | |
yes -> am currently unlocked? | |
no -> maintain last PAYG credit | |
# only checked for accessories - controllers always preserve last PAYG credit on loss | |
# of all their links | |
am currently unlocked? | |
no -> independent zero credit | |
yes -> maintain last PAYG credit | |
independent zero credit | |
maintain last PAYG credit | |
1 or more NX Channel Links& | |
# NXC reset is the same as an 'unlink' event - it will trigger a series of unlink | |
# events (one for each link) | |
link or unlink event -> NXC Linked? | |
# Currently, we model 'leading' and 'following', and do not consider relaying in detail | |
# (although its technically the combination of leading and following). | |
Credit Mode | |
Credit Leading | |
credit update event -> POST credit update to accessories successfully? | |
Credit Following | |
Independently Control Credit | |
link event -> NXC Linked? | |
Remaining Credit | |
# this might be a tick (60 seconds) or new keycode entry - doesn't matter, same effect. | |
# we will loop through all accessories with PAYG credit resources and update them. | |
event indicates PAYG credit has updated? -> POST credit update to accessories successfully? | |
Initialize Credit* | |
am leading -> independent credit | |
am following -> mirror controller credit | |
POST credit update to accessories successfully? | |
no -> POST credit update to accessories successfully? | |
yes -> independent credit | |
0 credit | |
mirror controller credit | |
independent credit | |
This file contains hidden or 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