Changeset 13897 for trunk/FACT++/src


Ignore:
Timestamp:
05/25/12 23:07:11 (12 years ago)
Author:
tbretz
Message:
Updated the handling of labels and how a script is stopped.
Location:
trunk/FACT++/src
Files:
4 edited

Legend:

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

    r13715 r13897  
    121121
    122122            const int target = stoi(str.substr(3));
    123             while (fStateMachine->GetCurrentState()!=target && timeout>Time())
     123            while (fStateMachine->GetCurrentState()!=target && timeout>Time() && !T::IsScriptStopped())
    124124                usleep(1);
    125125
    126             if (fStateMachine->GetCurrentState()!=target)
     126            if (fStateMachine->GetCurrentState()==target)
     127                return true;
     128
     129            int label = -1;
     130            in >> label;
     131            if (in.fail() && !in.eof())
    127132            {
    128                 int label = -1;
    129                 in >> label;
    130                 T::SetLabel(label);
     133                lout << kRed << "Invalid label in '" << str.substr(3) << "'" << endl;
     134                T::StopScript();
     135                return true;
    131136            }
     137            T::SetLabel(label);
     138
    132139            return true;
    133140        }
  • trunk/FACT++/src/Readline.cc

    r13771 r13897  
    7171
    7272Readline   *Readline::This   =  0;
    73 int         Readline::fLabel = -3;
     73bool        Readline::fStopScript = false;
    7474std::string Readline::fScript;
    7575
     
    9898//
    9999Readline::Readline(const char *prgname) :
    100     fMaxLines(500), fLine(0), fCompletion(0)
     100    fMaxLines(500), fLine(0), fScriptDepth(0), fCompletion(0)
    101101{
    102102    if (This)
     
    10111011        try
    10121012        {
    1013             const int section = stoi(str.substr(1));
    1014             SetSection(section);
    1015 
    1016             if (fLabel!=section)
     1013            fSection = stoi(str.substr(1));
     1014            SetSection(fSection);
     1015
     1016            if (fLabel!=fSection)
    10171017                return true;
    10181018        }
     
    10731073        }
    10741074
     1075        const int save = fSection;
    10751076        Execute(opt, data);
     1077        fSection = save;
     1078        SetSection(save);
     1079
    10761080        return true;
    10771081    }
     
    13351339    fScript = name;
    13361340
     1341    fSection = -2;
    13371342    SetSection(-2);
    13381343    fLabel = -1;
     
    13481353    if (!fin)
    13491354    {
     1355        fSection = -3;
    13501356        SetSection(-3);
    13511357        return -1;
     
    13571363    fCommandLog << ")" << endl;
    13581364
     1365    if (fScriptDepth++==0)
     1366        fStopScript = false;
     1367
     1368    fSection = -1;
    13591369    SetSection(-1);
    13601370
     
    13621372
    13631373    string buffer;
    1364     while (getline(fin, buffer, '\n') && fLabel>-2)
     1374    while (getline(fin, buffer, '\n') && !fStopScript)
    13651375    {
    13661376        buffer = Tools::Trim(buffer);
     
    13891399
    13901400    fLabel = -1;
     1401    fSection = -3;
    13911402    SetSection(-3);
     1403
     1404    if (--fScriptDepth==0)
     1405        fStopScript = false;
    13921406
    13931407    fCommandLog << "# " << Time() << " - " << name << " (FINISHED)" << endl;
  • trunk/FACT++/src/RemoteControl.h

    r13838 r13897  
    222222            T::GetStreamOut().SetBacklog(false);
    223223            T::GetStreamOut().SetNullOutput(false);
    224             while (l->second->GetState()!=state && timeout>Time() && T::GetLabel()!=-2)
     224            while (l->second->GetState()!=state && timeout>Time() && !T::IsScriptStopped())
    225225                usleep(1);
    226226            T::GetStreamOut().SetNullOutput(true);
    227227            T::GetStreamOut().SetBacklog(true);
    228228
    229             if (T::GetLabel()!=-2 && l->second->GetState()!=state)
    230             {
    231                 int label = -1;
    232                 in >> label;
    233                 if (in.fail() && !in.eof())
    234                 {
    235                     lout << kRed << "Invalid label in '" << str.substr(3) << "'" << endl;
    236                     label = -2;
    237                 }
    238                 else
    239                     T::SetLabel(label);
    240             }
     229            if (l->second->GetState()==state)
     230                return true;
     231
     232            int label = -1;
     233            in >> label;
     234            if (in.fail() && !in.eof())
     235            {
     236                lout << kRed << "Invalid label in '" << str.substr(3) << "'" << endl;
     237                T::StopScript();
     238                return true;
     239            }
     240            T::SetLabel(label);
    241241
    242242            return true;
  • trunk/FACT++/src/dimctrl.cc

    r13874 r13897  
    107107
    108108            Debug(msg);
    109             Readline::SetLabel(-2);
     109            Readline::StopScript();
    110110        }
    111111
     
    256256    }
    257257
    258     void Stop(int stop=0) { fStop = stop; Readline::SetLabel(0); }
     258    void Stop(int stop=0) { fStop = stop; Readline::StopScript(); }
    259259    int Run(bool)
    260260    {
Note: See TracChangeset for help on using the changeset viewer.