Changeset 11980 for trunk/FACT++


Ignore:
Timestamp:
09/06/11 09:36:59 (13 years ago)
Author:
tbretz
Message:
Added PrintInfo and a counter for the recived answers; fixed OverCurrentReset (the reset after the first command was missing).
File:
1 edited

Legend:

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

    r11973 r11980  
    6161    bool fWaitingForAnswer;
    6262
     63    vector<uint64_t> fCounter;
     64
    6365protected:
    6466    vector<uint16_t> fVolt;        // Current voltage in DAC units (12bit = 90V)
     
    320322            // Cancel sending of the next 0
    321323            fSyncTimer.cancel();
     324            fCounter[0]++;
    322325
    323326            // Start continous reading of all channels
     
    335338
    336339
    337         // Take action depending on what is going on
    338         if (command==kCmdReset)
    339             Message("Reset command successfully answered.");
    340 
     340        // Check if new values have been received
    341341        if (cmd==kCmdRead || cmd==kCmdChannelSet || cmd==kExpertChannelSet)
    342342        {
     
    345345        }
    346346
    347         if (cmd==kCmdReset || command==kResetChannels)
    348         {
     347        // ----- Take action depending on what is going on -----
     348
     349        if (command==kCmdReset)
     350        {
     351            Message("Reset command successfully answered... restarting automatic readout.");
     352
     353            fCounter[1]++;
     354
    349355            // Re-start cyclic reading of values after a short time
    350             // to allow the currents to become stable
     356            // to allow the currents to become stable. This ensures that
     357            // we get an update soon but wait long enough to get reasonable
     358            // values
    351359            fUpdateTimer.cancel();
    352360            ScheduleUpdate(100);
    353361        }
    354362
     363        if (command==kResetChannels)
     364        {
     365            ExpertReset(false);
     366            fCounter[5]++;
     367        }
     368
    355369        if (command==kUpdate)
     370        {
    356371            ScheduleUpdate(fUpdateTime);
     372            fCounter[2]++;
     373        }
    357374
    358375        // If we are ramping, schedule a new ramp step
     
    360377        {
    361378            ScheduleRampStep();
    362             return;
    363         }
     379            fCounter[3]++;
     380        }
     381
     382        if (command==kCmdRead)
     383            fCounter[4]++;
     384
     385        if ((command&0xff)==kExpertChannelSet)
     386            fCounter[6]++;
     387
     388        if (command==kCmdGlobalSet)
     389            fCounter[7]++;
     390
    364391    }
    365392
     
    424451        case kResetChannels:
    425452        case kCmdRead:
     453            fWaitingForAnswer = false;
    426454            HandleReceivedData(fBuffer, bytes_received, command, send_counter);
    427             fWaitingForAnswer = false;
    428455            return;
    429456
     
    687714        fIsRamping(false),
    688715        fWaitingForAnswer(false),
     716        fCounter(8),
    689717        fVolt(kNumChannels),
    690718        fVoltRef(kNumChannels),
     
    806834            if (fVoltRef[ch]+dac[ch]>kMaxDac)
    807835            {
    808                 ostringstream msg;
    809                 msg << "AddDac - New voltage reference of " << fVoltRef[ch]*90./4096 << "V + " << dac[ch]*90./4096. << "V for channel " << ch << " out of range.";
    810                 Error(msg);
     836                Error("AddDac - New voltage reference out of range.");
    811837                return false;
    812838            }
     
    916942            if (fVoltGapd[ch]+dac>kMaxDac)
    917943            {
    918                 ostringstream msg;
    919                 msg << "SetGapdVoltage - New voltage reference of " << fVoltGapd[ch] << "V + " << dac << "V for channel " << ch << " out of range.";
    920                 Error(msg);
     944                Error("SetGapdVoltage - New voltage reference out of range.");
    921945                return false;
    922946            }
     
    9911015    // -------------------------------------------------------------------
    9921016
    993     void ExpertReset()
     1017    void ExpertReset(bool expert_mode=true)
    9941018    {
    9951019        if (fWaitingForAnswer)
     
    9991023        }
    10001024
    1001         Warn("EXPERT MODE: Sending reset.");
     1025        if (expert_mode)
     1026            Warn("EXPERT MODE: Sending reset.");
     1027
    10021028        PostMessage(GetCmd(kCmdReset));
    10031029        AsyncRead(ba::buffer(fBuffer, 3), kCmdReset, ++fSendCounter);
     
    10751101    {
    10761102        fIsVerbose = b;
     1103    }
     1104
     1105    void PrintInfo()
     1106    {
     1107        Out() << endl << kBold << dec << '\n';
     1108        Out() << "fWrapCounter    = " << fWrapCounter << '\n';
     1109        Out() << "fSendCounter    = " << fSendCounter%8 << " (" << fSendCounter << ")" << '\n';
     1110        Out() << "fIsInitializing = " << fIsInitializing << '\n';
     1111        Out() << "fIsRamping      = " << fIsRamping << '\n';
     1112        Out() << "Answer counter:" << '\n';
     1113        Out() << " - Synchronization: " << fCounter[0] << '\n';
     1114        Out() << " - Reset:           " << fCounter[1] << '\n';
     1115        Out() << " - Request update:  " << fCounter[2] << '\n';
     1116        Out() << " - Ramp step:       " << fCounter[3] << '\n';
     1117        Out() << " - Read:            " << fCounter[4] << '\n';
     1118        Out() << " - Reset channels:  " << fCounter[5] << '\n';
     1119        Out() << " - Global set:      " << fCounter[7] << '\n';
     1120        Out() << " - Channel set:     " << fCounter[6] << '\n' << endl;
    10771121    }
    10781122
     
    17111755
    17121756
     1757        T::AddEvent("PRINT_INFO")
     1758            (Wrapper(bind(&ConnectionBias::PrintInfo, &fBias)))
     1759            ("Print a table with all current read back with the last request operation");
    17131760        T::AddEvent("PRINT_CURRENTS")
    17141761            (Wrapper(bind(&ConnectionBias::PrintA, &fBias)))
     
    17271774
    17281775        T::AddEvent("EXPERT_RESET", kExpertMode)
    1729             (Wrapper(bind(&ConnectionBias::ExpertReset, &fBias)))
     1776            (Wrapper(bind(&ConnectionBias::ExpertReset, &fBias, true)))
    17301777            ("Send the RESET command (note that this is possibly harmfull command)");
    17311778
Note: See TracChangeset for help on using the changeset viewer.