Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Core State #190

Closed
dostuffthatmatters opened this issue Oct 24, 2023 · 0 comments
Closed

Simplify Core State #190

dostuffthatmatters opened this issue Oct 24, 2023 · 0 comments
Assignees
Labels
status:implemented has been implemented in some dev branch

Comments

@dostuffthatmatters
Copy link
Member

Right now, we have two states (the persistent one and the temporary one). It would be way cleaner to just have one state and null everything temporary on the startup of the core.

Additionally, the way how partial updates are done is very complicated. We can use a contextmanager:

# old way:

def apply_state_update(state: types.PyraCoreState ) -> types.PyraCoreState:
    state.enclosure_pc_readings.actors.current_angle = new_cover_angle
    state.enclosure_pc_readings.state. cover_closed = new_cover_angle == 0
    return state

interfaces.StateInterface.update_state(apply_state_update)


# new way:

with interfaces.StateInterface-update_state_in_context) as state:
    state.plc_state.cover_angle = new_cover_ angle
    state.plc_state. cover_closed = new_cover_angle == 0
dostuffthatmatters added a commit that referenced this issue Oct 24, 2023
Rename and combine type files for plc and os state
dostuffthatmatters added a commit that referenced this issue Oct 24, 2023
Remove old state types
dostuffthatmatters added a commit that referenced this issue Oct 24, 2023
Rewrite state class that combines the two states
dostuffthatmatters added a commit that referenced this issue Oct 24, 2023
Add upload property to state
dostuffthatmatters added a commit that referenced this issue Oct 24, 2023
Add contextmanager to update state partially
dostuffthatmatters added a commit that referenced this issue Oct 24, 2023
Use new state everywhere
dostuffthatmatters added a commit that referenced this issue Oct 24, 2023
Move types of state to correct locations
Add TODOs
Update docstrings
@dostuffthatmatters dostuffthatmatters self-assigned this Oct 24, 2023
@dostuffthatmatters dostuffthatmatters added the status:implemented has been implemented in some dev branch label Oct 24, 2023
dostuffthatmatters added a commit that referenced this issue Oct 30, 2023
Parse new state using ZOD and connect it to the dashboard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:implemented has been implemented in some dev branch
Projects
None yet
Development

No branches or pull requests

1 participant