#38 State Machines Part-4: State Tables and Entry/Exit Actions

Поделиться
HTML-код
  • Опубликовано: 14 июн 2021
  • This lesson continues on the subject of STATE MACHINES, whereas today's subject is "State Tables and Entry/Exit Actions". You'll learn about state tables and you will see how to implement state tables in C. Later you'll see how to extend this implementation to add state entry and exit actions.
    The lesson starts with showing types of state tables (a.k.a., state-transition tables). And then you see an example of constructing a state table for the Time-Bomb state machine that you already used and coded in lesson 36.
    Next, you see how to implement that state machine in C, using two-dimensional arrays of pointers to functions (actions functions in this case).
    Later the lesson introduces entry and exit actions to states and shows how they can help to avoid repetitions of actions on transitions. You'll also see that entry/exit actions correspond to Moore machines, while actions on transitions to Mealy machines. While software state machines have typically both the Mealy and Moore characteristics, the general recommendation is to strive for Moore-type state machines with most actions executed in entry/exit to states.
    The project for this lesson is based on the Time Bomb state machine and the uC/AO active object framework used in lesson 36. The project shows a state table with entry/exit actions as well as the QM model of the TimeBomb state machine.
    -------
    Resources:
    Companion web page for this video course:
    www.state-machine.com/quickstart
    GitHub repository for projects for this video course:
    github.com/QuantumLeaps/moder...
    Transcript of this lesson:
    www.state-machine.com/course/...
    Music credits:
    The background music comes from:
    www.bensound.com/royalty-free...
  • НаукаНаука

Комментарии • 18

  • @StateMachineCOM
    @StateMachineCOM  Год назад +2

    NOTE: The source code, as presented in the video, might cause compilation errors with the newer MDK-ARM / uVision toolsets. This is because the underlying compiler in MDK-ARM has been changed to "Compiler-6", while the older "Compiler-5" is considered now obsolete. The updated code that compiles cleanly with "Compiler-6" is available from the companion website at:
    www.state-machine.com/video-course
    and from GitHub:
    github.com/QuantumLeaps/modern-embedded-programming-course

  • @jesset-p9225
    @jesset-p9225 3 года назад +8

    Brilliant explanation of state tables and how to implement them. I've used this method a few times and find that it works well. You've shown me a different way to implement entry and exit conditions, thank you. You are doing the embedded world a great service with this video series. I look forward to the next video, and having a go at implementing it.

  • @zhitailiu3876
    @zhitailiu3876 3 года назад +3

    I can imagine that next episode will be the most sparkling one in this series!
    Thank you so much, Miro!

    • @StateMachineCOM
      @StateMachineCOM  3 года назад +10

      Yes, I'll show what I consider the "optimal" state machine implementation in C and I will provide arguments why I think so. But this will be still about the traditional, non-hierarchical state machines. I will introduce the modern, hierarchical state machines (HSMs) later in the segment about state machines. Stay tuned!

  • @ManikantaRaju
    @ManikantaRaju 3 года назад +5

    Been waiting for your video since a long time 😁

  • @alaouchicheabdellah4986
    @alaouchicheabdellah4986 3 года назад +1

    An Incredible presentation.

  • @ashrafkamel1287
    @ashrafkamel1287 2 года назад +1

    Entry/Exit Actions 13:04

  • @anonymous102592
    @anonymous102592 3 года назад +1

    thank you, you saved me

  • @damianjozwiak6972
    @damianjozwiak6972 3 года назад +1

    Thanks!

  • @LuisReyes-zg7mq
    @LuisReyes-zg7mq Год назад

    Hello professor Miro, thanks for such an amazing course. This is by far the best embedded course that I've ever taken. I would like to know if there is any special material or books that you recommend for embedded topics in general. Thanks!

    • @StateMachineCOM
      @StateMachineCOM  Год назад

      You check out my book "Practical UML Statecharts in C/C++, 2nd Edition", which is available in free PDF from: www.state-machine.com/psicc2

  • @konstantingrudnev8374
    @konstantingrudnev8374 3 года назад +1

    I would recommend to read the classics to all who is interested in this topic
    Object Life Cycles: Modeling the World in States by Stephen J Mellor (Author), Sally Shlaer

  • @vladkostiushko7972
    @vladkostiushko7972 3 года назад

    Hi! Great tutorial! Could you tell please, which software do you use on 1:40?

    • @StateMachineCOM
      @StateMachineCOM  3 года назад +1

      The screen shot at 1:40 is from the Astah modeling tool.

  • @Soraform1
    @Soraform1 8 месяцев назад +1

    What are the rules to decide states' entry and exit actions? For example on 15:56 , is it valid to input arming on time event as exit action from blink? I think it should not change the behaviour. I can see why it is logical to include that as entry action to pause though.

    • @StateMachineCOM
      @StateMachineCOM  8 месяцев назад +2

      I don't think there are hard rules for entry/exit actions. However, there are some widely applied heuristics. For example, entry actions determine the purpose of a state, such as the state "boom" which is defined by the fact that every transition leading to that state should cause an explosion. Therefore entry action to "boom" is the best place for the explosion-action. Regarding the timeouts, they are customarily counted from the time of entering the state (in fact the after(n) specification in the UML means "after n milliseconds since entering the state"). Finally, if an entry action is an initialization of a state context, exit is the cleanup. Therefore it is a good practice that exit reverses the actions performed in the entry. For example, if the entry action turns something on (e.g., LED, a motor, a heater, whatever). the exit should turn it off. I hope you get the general idea... --MMS

    • @Soraform1
      @Soraform1 8 месяцев назад +1

      @StateMachineCOM Thanks for the clarificatio. I think for simple example, It is not so apparent the significance of entry action, but when we got multiple guard conditions and state transitions to a state then defining entry and exit actions carefully can help in achieving DRY principle.

  • @technoviq8196
    @technoviq8196 3 года назад +1

    Thanks for the detailed explanation. Kindly increase the speed of uploading the videos.