Code Monkey home page Code Monkey logo

Comments (2)

pabloinigoblasco avatar pabloinigoblasco commented on June 11, 2024 1

Hello.
We already talked about that idea two years ago. And that is not hard to implement.
Personally, I like the proposal and follows the UML state machine standard.

The main argument why we did not implemented that is because it overlaps the functionality and responsibility of the StateReactors that potentially can receive events and generate other events. The suggested way to do that at the moment is to make a state reactor or use the conditional state reactor.

The good point of state reactors is that they are reusable pieces of code (against inline transition guards).

Nonetheless I think we could find a way to integrate this feature.

from smacc2.

MrBlenny avatar MrBlenny commented on June 11, 2024

Very fair. I'm currently working with the SrConditional approach. The main downsides are:

  • The SMACC RTA display does not work. From memory, it shows something like internal_event with no lines from the state reactor inputs. Better RTA support for State Reactors or Guards would help.

  • Verbosity. Here is a rather minimal example... I'm not sure if there is a better way to write this. I've had to write others where the state reactors depend on events from other state reactors - at this point, the code gets pretty tricky to follow.

// TRANSITION TABLE
typedef mpl::list<
    Transition<EvSomeInputEventWithGuard, StGuardedState, GUARDED_STATE>
> reactions;
   
...

void runtimeConfigure()
  {
    auto guard = [ = ](auto * ev) {
        (void)ev;
        
        // as an example, a behavior which contains some state used as a guard
        auto cbSomeBehaviorWithState =
          this->getOrthogonal<OrSomeOrthogonal>()->getClientBehavior<CbSomeBehavior>();
          
        // this is used to publish notifications of transitions onto a ros topic
        auto cbPublisher =
          this->getOrthogonal<OrSomePublisher>()->getClientBehavior<CbSomePublisher>();
          
        // guard checks
        if (!cbSomeBehaviorWithState->value) {
          cbPublisher->publish("Cannot transition because the state stored in CbSomeBehavior says so");
          return false;
        }
      
        return true;
      };

    this->createStateReactor<
      SrConditional<EvSomeInputEvent>,
      EvSomeInputEventWithGuard,
      mpl::list<EvSomeInputEvent>
    >(guard);
 }
  • doing things like cbPublisher->publish (using the SmaccPublisherClient) does not work reliably - I'm not sure why.

from smacc2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.