ezeio2:scriptref:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
ezeio2:scriptref:start [2019-09-02 21:27] – S andrehezeio2:scriptref:start [2019-09-02 21:32] andreh
Line 65: Line 65:
 === State machines === === State machines ===
  
-A common programming pattern in control applications is to use state machines. PAWN and the ezeio implements strong support for state machines. The following is a typical pattern:+A common programming pattern in control applications is to use state machines. PAWN and the ezeio implements strong support for state machines. The following is a typical pattern showing the startup sequence of an engine. Note that there are three @Tick handlers; one for each state. Also note the "entry" and "exit" functions. For more detail, refer to the PAWN language guide.
  
-<code>+<code javascript>
  
   new count = 0;   new count = 0;
Line 73: Line 73:
   main()   main()
   {   {
-    SetTickInterval(500);   // set tick interval to 500ms (0.5s)+    SetTickInterval(100);   // set tick interval to 100ms (0.1s)
     state WAITING;          // start in the waiting mode     state WAITING;          // start in the waiting mode
   }   }
Line 96: Line 96:
         state RUNNING;        // yes - we're running         state RUNNING;        // yes - we're running
  
-     if(count++ > 5+     if(count++ > 50
-        state WAITING;        // didn't start in 2.5s? Give up and go back to waiting.+        state WAITING;        // didn't start in 5s? Give up and go back to waiting.
   }   }
      
Line 109: Line 109:
   @Tick(uptime) <RUNNING>   @Tick(uptime) <RUNNING>
   {   {
-     if( GetField(2) < 100 ) +     if( GetField(2) < 100 )  // Check if the engine stopped 
-        state WAITING;+        state WAITING;        // ..go back to waiting
   }   }
      
 </code> </code>
  
  • ezeio2/scriptref/start.txt
  • Last modified: 2024-03-01 17:24
  • by andreh