Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Best way to interchange state machines?
Forum Updated to NodeBB v4.3 + New Features

Best way to interchange state machines?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 666 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    ggwolf
    wrote on last edited by
    #1

    I have an interface that I want my back end to react differently based on the state machine.

    basically, state machine detects button presses, and transitions based on how it was configured. Is there an easy way to reset the transitions and remake them?

    My UI has 6 buttons and sets a device with up to 8 modes. I want the state machine to have three distinct operating modes:

    6 button on/off: device plays mode specific sound on loop until a different mode is selected or the same mode is selected, toggling the sound off.

    4 button on/off with volume buttons: device has 4 mode buttons, and two that raise or lower the volume.

    4 button on/off with volume buttons: device has 4 mode buttons which rotate between two modes and the off state, allowing the device to have 8 modes total, and two volume buttons.

    I understand the logic in the state machine behind implementing each of these, but I need a clean way to change between each of these separate state machines. Here are my options:

    Option 1: 1 state machine to rule them all: create a single giant state machine with 3 different parent states.

    Option 2: create three separate state machines objects, perhaps all inheriting from one parent which contains virtual methods.

    Option 3: create a single smaller object, with slots that allow it to set/reset the transitions between states when the mode changes.

    Is there a better idea from a design/architect standpoint or which would you recommend of the above?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      This isn't really a Qt question.

      I would personally go with Option 2 though.

      You would probably get better results on a C++ based message board, maybe "stackoverflow.com":www.stackoverflow.com...

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved