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

Build state machines from type definition #771

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

SanobLuj
Copy link

To simplify the creation of a state machine I added an initial implementation to build a state machine based on its type definition. Currently an existing node of a state machine type needs to be passed to the constructor. The StateMachineClass will then browse the type definition of this node to add the states, transitions, and causes defined by the type.

For executing a state, each State object provides an on_entry and on_exit method. These are executed on each state change for the current state and the next one. These methods can be overwritten to execute a certain behaviour.

Base classes for the ProgramStateMachine, FileTransferStateMachine, and ExclusiveLimitStateMachine have been added. However, none of these are fully implemented. The ProgramStateMachine is missing some functionality as it is described by the specification but can be used in a simple form (see example). About the FileTransferStateMachine and the ExclusiveLimitStateMachine I'm not sure how these are intenden to be used. At least there are some references missing, I guess coming from the TemporaryFileTransferType and a ConditoinAlarmType.

In addition to the state machine a ParameterSet implementation has been added. A parameter set is a flat list of parameters/variables. These are used e.g. within the device specification to organize the parameters of a device. Optionally the values of the parameters in the set can be subscribed.

There is the example server_typed_state_machine.py using a custom nodeset with several predefined state machines and parameter sets.

grafik

There is still some more work needed. However, would be glad if you guys can tell me what you think.

@SanobLuj SanobLuj marked this pull request as draft January 17, 2022 11:02
@oroulet
Copy link
Member

oroulet commented Jan 26, 2022

I have no ideas what that stuff is about. @AndreasHeine isn'it the kind of things you are working on?

s += '\n-----------------------------------------------------'
print(s)

print()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty print?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better not? It's just for prettier prtinting ^^

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f-string would be better!

@AndreasHeine
Copy link
Member

@oroulet sure i implemented them as far as i needed them ... the rest i left open for reference! @SanobLuj is probably the first one using it else then me ^^

on the first look it appearance fine, the only thing i am not sure about is that internal/serverside subscription

@SanobLuj
Copy link
Author

The original intention was to use this for implementing skills. Here are a few references describing the skill concept:

However, I thought it could be helpful for implementing all kinds of state machines that are defined by its type. I will make additional changes and give some more explanation soon.

@AndreasHeine the parameter set class could be used with a server or a client (source). That is why I have used the subscription there. Probably not the best idea to be used with the server ^^

@AndreasHeine
Copy link
Member

@oroulet after a while and recap what i did ^^ the FiniteStatmachineType is abstract... so it should not be possible to instantiate it only subtypes... maybe we need to add a check for that in instantiate-method!? some refactoring is required as well...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants