Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. How to model endless-loop with states in UML-state-diagram

How to model endless-loop with states in UML-state-diagram

Scheduled Pinned Locked Moved Managed C++/CLI
questiontutorial
4 Posts 4 Posters 2 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.
  • F Offline
    F Offline
    Frygreen
    wrote on last edited by
    #1

    Dear readers, I have a endless loop, which has internal state. How can this be modelled with UML-State-Diagram?

    static int state = 0;
    void mySstateTest(void)
    {
    for(;;) {
    DoSomeImportantAction();

        if ( 0 == state ) {
            if ( 1 == ReadSomeData() ) {
                state = 1;
            }
        }
    
        if ( 1 == state) {
            if ( 0 == ReadSomeData() ) {
                state = 0;
            }
        }
    
    }
    

    }

    Is there a better place for asking this question Thank you

    L J S 3 Replies Last reply
    0
    • F Frygreen

      Dear readers, I have a endless loop, which has internal state. How can this be modelled with UML-State-Diagram?

      static int state = 0;
      void mySstateTest(void)
      {
      for(;;) {
      DoSomeImportantAction();

          if ( 0 == state ) {
              if ( 1 == ReadSomeData() ) {
                  state = 1;
              }
          }
      
          if ( 1 == state) {
              if ( 0 == ReadSomeData() ) {
                  state = 0;
              }
          }
      
      }
      

      }

      Is there a better place for asking this question Thank you

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Frygreen wrote:

      Is there a better place for asking this question

      We don't appear to have a forum dedicated to UML, so perhaps you could try the Quick Answers section.

      Veni, vidi, abiit domum

      1 Reply Last reply
      0
      • F Frygreen

        Dear readers, I have a endless loop, which has internal state. How can this be modelled with UML-State-Diagram?

        static int state = 0;
        void mySstateTest(void)
        {
        for(;;) {
        DoSomeImportantAction();

            if ( 0 == state ) {
                if ( 1 == ReadSomeData() ) {
                    state = 1;
                }
            }
        
            if ( 1 == state) {
                if ( 0 == ReadSomeData() ) {
                    state = 0;
                }
            }
        
        }
        

        }

        Is there a better place for asking this question Thank you

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        Frygreen wrote:

        How can this be modelled with UML-State-Diagram?

        State 1 points to state 0. State 0 points to state 1.

        1 Reply Last reply
        0
        • F Frygreen

          Dear readers, I have a endless loop, which has internal state. How can this be modelled with UML-State-Diagram?

          static int state = 0;
          void mySstateTest(void)
          {
          for(;;) {
          DoSomeImportantAction();

              if ( 0 == state ) {
                  if ( 1 == ReadSomeData() ) {
                      state = 1;
                  }
              }
          
              if ( 1 == state) {
                  if ( 0 == ReadSomeData() ) {
                      state = 0;
                  }
              }
          
          }
          

          }

          Is there a better place for asking this question Thank you

          S Offline
          S Offline
          Stefan_Lang
          wrote on last edited by
          #4

          A bit hard without the ability to embed an image, but I'll try:

          /*********\
          * *
          * state 0 *
          * *
          \*********/
          | ^ ^
          | | |
          v no| |yes
          / \ | |
          / \ | |
          R==1?>-+ |
          \ / ^
          \ / / \
          V / \
          | <R==0?>-+
          | \ / |
          |yes \ / no|
          | V |
          | ^ |
          | | |
          v | |
          /*********\ |
          * * |
          * state 1 *<--+
          * *
          \*********/

          Ok, the readability suffers a bit - sorry for the bleeding eyes ;)

          GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups