Changeset 11045


Ignore:
Timestamp:
06/16/11 21:27:59 (13 years ago)
Author:
tbretz
Message:
Added possibility to block execution until the state machine has reached a given state.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/LocalControl.h

    r10870 r11045  
    5757        lout << " " << kUnderline << "Specific commands:" << endl;
    5858        lout << kBold << "   st,states    " << kReset << "Display a list of the available states with description." << endl;
     59        lout << kBold << "   .s           " << kReset << "Wait for the state-machine to change to the given state." << endl;
     60        lout <<          "                "              "     .s <state> [<timeout>]" << endl;
     61        lout <<          "                "              "<state>   The state id (see 'states') for which to wait (e.g. 3)" << endl;
     62        lout <<          "                "              "<imeout>  A timeout in millisenconds how long to wait (e.g. 500)" << endl;
    5963        lout << endl;
    6064        return true;
     
    8387            if (fStateMachine)
    8488                fStateMachine->PrintListOfStates(lout);
     89            return true;
     90        }
     91
     92        if (str.substr(0, 3)==".s ")
     93        {
     94            istringstream in(str.substr(3));
     95
     96            int state=-100, ms=0;
     97            in >> state >> ms;
     98
     99            if (state==-100)
     100                return true;
     101
     102            const Time timeout = Time()+boost::posix_time::millisec(ms);
     103
     104            const int target = atoi(str.c_str()+3);
     105            while (fStateMachine->GetCurrentState()!=target && timeout>Time())
     106                usleep(1);
    85107            return true;
    86108        }
  • trunk/FACT++/src/RemoteControl.h

    r10494 r11045  
    130130        lout << kBold << "   svc,services " << kReset << "List all services in the network." << endl;
    131131        lout << kBold << "   st,states    " << kReset << "List all states in the network." << endl;
     132        lout << kBold << "   .s           " << kReset << "Wait for the state-machine to change to the given state." << endl;
     133        lout <<          "                "              "     .s <server> <state> [<timeout>]" << endl;
     134        lout <<          "                "              "<server>  The server for which state to wait (e.g. FTM_CONTROL)" << endl;
     135        lout <<          "                "              "<state>   The state id (see 'states') for which to wait (e.g. 3)" << endl;
     136        lout <<          "                "              "<imeout>  A timeout in millisenconds how long to wait (e.g. 500)" << endl;
    132137        lout << endl;
    133138        return true;
     
    168173        }
    169174
     175        if (str.substr(0, 3)==".s ")
     176        {
     177            istringstream in(str.substr(3));
     178
     179            int state=-100, ms=0;
     180            string server;
     181
     182            in >> server >> state >> ms;
     183            if (state==-100)
     184                return true;
     185
     186            const ClientList::const_iterator l = fClientList.find(server);
     187            if (l==fClientList.end())
     188                return true;
     189
     190            const Time timeout = Time()+boost::posix_time::millisec(ms);
     191
     192            while (l->second->GetState()!=state && timeout>Time())
     193                usleep(1);
     194
     195            return true;
     196        }
     197
    170198        if (ReadlineColor::Process(lout, str))
    171199            return true;
Note: See TracChangeset for help on using the changeset viewer.