Changeset 13918


Ignore:
Timestamp:
05/26/12 14:57:36 (13 years ago)
Author:
tbretz
Message:
Moved state definitions to own header and namespace
Location:
trunk/FACT++/src
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/ratescan.cc

    r13893 r13918  
    1616
    1717#include "HeadersFTM.h"
     18#include "HeadersRateScan.h"
    1819
    1920namespace ba = boost::asio;
     
    3233{
    3334private:
    34     enum states_t
    35     {
    36         kStateDimNetworkNA = 1,
    37         kStateDisconnected,
    38         kStateConnecting,
    39         kStateConnected,
    40         kStateConfiguring,
    41         kStateInProgress,
    42     };
    43 
    4435    DimVersion fDim;
    4536    DimState   fDimFTM;
     
    10495            return GetCurrentState();
    10596
    106         if (GetCurrentState()!=kStateInProgress)
     97        if (GetCurrentState()!=RateScan::State::kInProgress)
    10798            return GetCurrentState();
    10899
     
    193184        {
    194185            Message("Rate scan stopped due to timeout.");
    195             return kStateConnected;
     186            return RateScan::State::kConnected;
    196187        }
    197188
     
    199190        {
    200191            Message("Rate scan finished.");
    201             return kStateConnected;
     192            return RateScan::State::kConnected;
    202193        }
    203194
     
    252243        Message("Configuration for ratescan started.");
    253244
    254         return kStateConfiguring;
     245        return RateScan::State::kConfiguring;
    255246    }
    256247
    257248    int HandleFtmStateChange(/*const EventImp &evt*/)
    258249    {
    259         if (GetCurrentState()!=kStateConfiguring)
    260             return GetCurrentState();
    261 
    262         if (fDimFTM.state()!=FTM::kConfigured)
     250        if (GetCurrentState()!=RateScan::State::kConfiguring)
     251            return GetCurrentState();
     252
     253        if (fDimFTM.state()!=FTM::State::kConfigured)
    263254            return GetCurrentState();
    264255
     
    292283        Message(msg);
    293284
    294         return kStateInProgress;
     285        return RateScan::State::kInProgress;
    295286    }
    296287
    297288    int StopRateScan()
    298289    {
    299         if (GetCurrentState()!=kStateConfiguring && GetCurrentState()!=kStateInProgress)
     290        if (GetCurrentState()!=RateScan::State::kConfiguring && GetCurrentState()!=RateScan::State::kInProgress)
    300291            return GetCurrentState();
    301292
    302293        Message("Rate scan manually stopped.");
    303294
    304         return kStateConnected;
     295        return RateScan::State::kConnected;
    305296    }
    306297
     
    375366    {
    376367        if (!fDim.online())
    377             return kStateDimNetworkNA;
     368            return RateScan::State::kDimNetworkNA;
    378369
    379370        // All subsystems are not connected
    380         if (fDimFTM.state()<FTM::kConnected)
    381             return kStateDisconnected;
     371        if (fDimFTM.state()<FTM::State::kConnected)
     372            return RateScan::State::kDisconnected;
    382373
    383374        return GetCurrentState();
     
    417408
    418409        // State names
    419         AddStateName(kStateDimNetworkNA, "DimNetworkNotAvailable",
     410        AddStateName(RateScan::State::kDimNetworkNA, "DimNetworkNotAvailable",
    420411                     "The Dim DNS is not reachable.");
    421412
    422         AddStateName(kStateDisconnected, "Disconnected",
     413        AddStateName(RateScan::State::kDisconnected, "Disconnected",
    423414                     "The Dim DNS is reachable, but the required subsystems are not available.");
    424415
    425         AddStateName(kStateConnected, "Connected",
     416        AddStateName(RateScan::State::kConnected, "Connected",
    426417                     "All needed subsystems are connected to their hardware, no action is performed.");
    427418
    428         AddStateName(kStateInProgress, "InProgress",
     419        AddStateName(RateScan::State::kInProgress, "InProgress",
    429420                     "Rate scan in progress.");
    430421
    431         AddEvent("START_THRESHOLD_SCAN", "I:3", kStateConnected)
     422        AddEvent("START_THRESHOLD_SCAN", "I:3", RateScan::State::kConnected)
    432423            (bind(&StateMachineRateScan::StartRateScan, this, placeholders::_1, "SET_THRESHOLD"))
    433424            ("Start rate scan for the threshold in the defined range"
     
    436427             "|step[int]:Single step in DAC counts");
    437428
    438         AddEvent("START_N_OUT_OF_4_SCAN", "I:3", kStateConnected)
     429        AddEvent("START_N_OUT_OF_4_SCAN", "I:3", RateScan::State::kConnected)
    439430            (bind(&StateMachineRateScan::StartRateScan, this, placeholders::_1, "SET_N_OUT_OF_4"))
    440431            ("Start rate scan for N-out-of-4 in the defined range"
     
    443434             "|step[int]:Single step in DAC counts");
    444435
    445         AddEvent("CHANGE_STEP_SIZE", "I:1", kStateInProgress)
     436        AddEvent("CHANGE_STEP_SIZE", "I:1", RateScan::State::kInProgress)
    446437            (bind(&StateMachineRateScan::ChangeStepSize, this, placeholders::_1))
    447438            ("Change the step size during a ratescan in progress"
    448439             "|step[int]:Single step in DAC counts");
    449440
    450         AddEvent("CHANGE_MAXIMUM", "I:1", kStateInProgress)
     441        AddEvent("CHANGE_MAXIMUM", "I:1", RateScan::State::kInProgress)
    451442            (bind(&StateMachineRateScan::ChangeMaximum, this, placeholders::_1))
    452443            ("Change the maximum limit during a ratescan in progress"
    453444             "|max[int]:Limiting value in DAC counts");
    454445
    455         AddEvent("STOP", kStateConfiguring, kStateInProgress)
     446        AddEvent("STOP", RateScan::State::kConfiguring, RateScan::State::kInProgress)
    456447            (bind(&StateMachineRateScan::StopRateScan, this))
    457448            ("Stop a ratescan in progress");
    458449
    459         AddEvent("SET_REFERENCE_CAMERA", kStateDimNetworkNA, kStateDisconnected, kStateConnected)
     450        AddEvent("SET_REFERENCE_CAMERA", RateScan::State::kDimNetworkNA, RateScan::State::kDisconnected, RateScan::State::kConnected)
    460451            (bind(&StateMachineRateScan::SetReferenceCamera, this))
    461452            ("Use the camera trigger rate as reference for the reolution");
    462         AddEvent("SET_REFERENCE_BOARD", "I:1", kStateDimNetworkNA, kStateDisconnected, kStateConnected)
     453        AddEvent("SET_REFERENCE_BOARD", "I:1", RateScan::State::kDimNetworkNA, RateScan::State::kDisconnected, RateScan::State::kConnected)
    463454            (bind(&StateMachineRateScan::SetReferenceBoard, this, placeholders::_1))
    464455            ("Use the given board trigger-rate as reference for the reolution"
    465456             "|board[idx]:Index of the board (4*crate+board)");
    466         AddEvent("SET_REFERENCE_PATCH", "I:1", kStateDimNetworkNA, kStateDisconnected, kStateConnected)
     457        AddEvent("SET_REFERENCE_PATCH", "I:1", RateScan::State::kDimNetworkNA, RateScan::State::kDisconnected, RateScan::State::kConnected)
    467458            (bind(&StateMachineRateScan::SetReferenceBoard, this, placeholders::_1))
    468459            ("Use the given patch trigger-rate as reference for the reolution"
    469              "|patch[idx]:Index of the patch (360*crate+36*board+patch)"            );
     460             "|patch[idx]:Index of the patch (360*crate+36*board+patch)");
    470461
    471462        AddEvent("PRINT")
Note: See TracChangeset for help on using the changeset viewer.