digint / tinyfsm

A simple C++ finite state machine library
https://digint.ch/tinyfsm
MIT License
931 stars 173 forks source link

is it possible to instantiate multiple Elevators classes, using the same elevator.hpp and .cpp? #35

Closed husnaini798 closed 2 years ago

husnaini798 commented 2 years ago

is it possible to instantiate multiple Elevators classes, using the same elevator.hpp and .cpp? if so, how?

Thanks

digint commented 2 years ago

duplicate of #3

husnaini798 commented 2 years ago

Hi Alex, Thanks for your reply. The multiple switches make sense at compile time.

But how do I declare all those 'defectiveswitches' at runtime?

FSM_INITIAL_STATE(DefectiveSwitch<2>, Off<2> )

I would like to use this for a warning system (and based on the user input the warnings will move to different states). However, at the start I wouldn't know how many warnings would I recieve. I could recieve 1000s or more warnings as the system runs/continues or none at all.

Appreciate your help with this.

Thanks.

Kind regards, Husnain Malik

On Tuesday, July 5, 2022, Axel Burri @.***> wrote:

Closed #35 https://github.com/digint/tinyfsm/issues/35 as completed.

— Reply to this email directly, view it on GitHub https://github.com/digint/tinyfsm/issues/35#event-6929849458, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU4QRYFJR3LXKQSVTOPIUYLVSM3NHANCNFSM52SGZDXQ . You are receiving this because you authored the thread.Message ID: @.***>

husnaini798 commented 2 years ago

Or, If somehow I wrap the state machine's struct/class (i.e. warning), struct warning : tinyfsm::fsm , in another class 'like MyWarning'

And then create multiple instances of MyWarning class. Would that create multiple MyWarnings, each containing a seperate tinyfsm's 'warning state machine'?

Or since everything is static, multiple Mywarning instances would all be using one tinyfsm's warning state machine?

Thanks

On Tuesday, July 5, 2022, Husnain Malik @.***> wrote:

Hi Alex, Thanks for your reply. The multiple switches make sense at compile time.

But how do I declare all those 'defectiveswitches' at runtime?

FSM_INITIAL_STATE(DefectiveSwitch<2>, Off<2> )

I would like to use this for a warning system (and based on the user input the warnings will move to different states). However, at the start I wouldn't know how many warnings would I recieve. I could recieve 1000s or more warnings as the system runs/continues or none at all.

Appreciate your help with this.

Thanks.

Kind regards, Husnain Malik

On Tuesday, July 5, 2022, Axel Burri @.***> wrote:

Closed #35 https://github.com/digint/tinyfsm/issues/35 as completed.

— Reply to this email directly, view it on GitHub https://github.com/digint/tinyfsm/issues/35#event-6929849458, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU4QRYFJR3LXKQSVTOPIUYLVSM3NHANCNFSM52SGZDXQ . You are receiving this because you authored the thread.Message ID: @.***>