Automato de Controle
From TheUbberCannon
Conteúdo |
Very first Attempt
In this model, each state was expected to be a thread.
Second try
In this a bit better detailed, we can see that if we have to use threads, it will be if necessary, only in the case of to missing calculations/rssi data loss.
Use Case
A Successfull target and shoot
Mica Receives RSSIData from IPS, then send to Control that passes to Target Location. Target Location try to solve the position for the target (In this case it can) and send that position back to the Control. Control send that position to the Cannon Controler. If the position is valid to shoot Control send a Fire command to Cannon Controler.
Variations:
- If Target location cannot aquire a valid target position neighter Position nor Fire is sended to Cannon Controler.
- If Target location has not suficient accuracy to shoot Fire command does not is issued.
Implementation
This piece of pseudo-code reflex the second attempt.
boolean hit; int main() { Display display; hit = false; int attempt = 0; while(!hit) { PDU = receive _ mica (); // Block ! Target t = TargetSys . update ( PDU ); if ( t . fire ) { cout << "#" << attempt++ << " - Fire at [" << t. position . X << ", " << t . position . Y << "]\ n "; Cannon . position ( p . position ); // Non - Block Cannon .fire(); // Non - Block } } return 0; }
No threads, a blocking waiting for data via UART, then the remaining calculation for the system. Syntax will change, acording to other groups works.