Changeset 11937 for trunk


Ignore:
Timestamp:
09/01/11 17:47:19 (13 years ago)
Author:
tbretz
Message:
Added some more print commands and more states.
File:
1 edited

Legend:

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

    r11931 r11937  
    881881    }
    882882
    883     void PrintLine(int b, int ch)
     883    void PrintLineA(int b, int ch)
    884884    {
    885885        Out() << setw(2) << b << "|";
     
    898898    }
    899899
    900     void Print()
    901     {
    902         Out() << dec << setprecision(2) << fixed;
     900    void PrintA()
     901    {
     902        Out() << dec << setprecision(2) << fixed << setfill(' ');
    903903        for (int b=0; b<kNumBoards; b++)
    904904        {
     
    909909            }
    910910
    911             PrintLine(b,  0);
    912             PrintLine(b,  8);
    913             PrintLine(b, 16);
    914             PrintLine(b, 24);
     911            PrintLineA(b,  0);
     912            PrintLineA(b,  8);
     913            PrintLineA(b, 16);
     914            PrintLineA(b, 24);
     915        }
     916    }
     917
     918    void PrintLineV(int b, int ch)
     919    {
     920        Out() << setw(2) << b << "|";
     921
     922        for (int c=ch; c<ch+4; c++)
     923        {
     924            const int id = c+kNumChannelsPerBoard*b;
     925            Out() << " ";
     926            Out() << setw(5) << fVolt[id]*90/4096. << '/';
     927            Out() << setw(5) << fVoltRef[id]*90/4096.;
     928        }
     929        Out() << endl;
     930    }
     931
     932    void PrintV()
     933    {
     934        Out() << dec << setprecision(2) << fixed << setfill(' ');
     935        for (int b=0; b<kNumBoards; b++)
     936        {
     937            if (!fPresent[b])
     938            {
     939                Out() << setw(2) << b << "-" << endl;
     940                continue;
     941            }
     942
     943            PrintLineV(b,  0);
     944            PrintLineV(b,  4);
     945            PrintLineV(b,  8);
     946            PrintLineV(b, 12);
     947            PrintLineV(b, 16);
     948            PrintLineV(b, 20);
     949            PrintLineV(b, 24);
     950            PrintLineV(b, 28);
     951        }
     952    }
     953
     954    void PrintLineGapd(int b, int ch)
     955    {
     956        Out() << setw(2) << b << "|";
     957
     958        for (int c=ch; c<ch+8; c++)
     959        {
     960            const int id = c+kNumChannelsPerBoard*b;
     961            Out() << " " << setw(5) << fVoltGapd[id]*90/4096.;
     962        }
     963        Out() << endl;
     964    }
     965
     966    void PrintGapd()
     967    {
     968        Out() << dec << setprecision(2) << fixed << setfill(' ');
     969        for (int b=0; b<kNumBoards; b++)
     970        {
     971            if (!fPresent[b])
     972            {
     973                Out() << setw(2) << b << "-" << endl;
     974                continue;
     975            }
     976
     977            PrintLineGapd(b,  0);
     978            PrintLineGapd(b,  8);
     979            PrintLineGapd(b, 16);
     980            PrintLineGapd(b, 24);
    915981        }
    916982    }
     
    9531019        kConnected,
    9541020        kRamping,
     1021        kOverCurrent,
     1022        kAtReference,
    9551023        kExpertMode // 'forward' declaration to be used in StateMachineBias
    9561024    };
     
    9701038            return kRamping;
    9711039
    972         return kConnected;
     1040        for (int ch=0; ch<kNumChannels; ch++)
     1041            if (fPresent[ch/kNumChannelsPerBoard] && fCurrent[ch]<0)
     1042                return kOverCurrent;
     1043
     1044        for (int ch=0; ch<kNumChannels; ch++)
     1045            if (fPresent[ch/kNumChannelsPerBoard] && fVolt[ch]!=fVoltRef[ch])
     1046                return kConnected;
     1047
     1048        return kAtReference;
    9731049    }
    9741050};
     
    12311307                        "USB connection to bias-power supply established.");
    12321308
     1309        T::AddStateName(ConnectionBias::kAtReference, "Referenced",
     1310                        "Internal reference voltage matches last sent voltage.");
     1311
     1312        T::AddStateName(ConnectionBias::kOverCurrent, "OverCurrent",
     1313                        "At least one channel is in over current state.");
     1314
    12331315        T::AddStateName(ConnectionBias::kExpertMode, "ExpertMode",
    12341316                        "Special (risky!) mode to directly send command to the bias-power supply.");
     
    12441326
    12451327        // Conenction commands
    1246         T::AddEvent("DISCONNECT", ConnectionBias::kConnected)
     1328        T::AddEvent("DISCONNECT", ConnectionBias::kConnected, ConnectionBias::kAtReference)
    12471329            (bind(&StateMachineBias::Disconnect, this))
    12481330            ("disconnect from ethernet");
    12491331
    1250         T::AddEvent("RECONNECT", "O", ConnectionBias::kDisconnected, ConnectionBias::kConnected)
     1332        T::AddEvent("RECONNECT", "O", ConnectionBias::kDisconnected, ConnectionBias::kConnected, ConnectionBias::kAtReference)
    12511333            (bind(&StateMachineBias::Reconnect, this, placeholders::_1))
    12521334            ("(Re)connect ethernet connection to FTM, a new address can be given"
     
    12551337
    12561338
    1257         T::AddEvent("REQUEST_STATUS", ConnectionBias::kConnected, ConnectionBias::kRamping)
     1339        T::AddEvent("REQUEST_STATUS", ConnectionBias::kConnected, ConnectionBias::kAtReference, ConnectionBias::kOverCurrent)
    12581340            (Wrapper(bind(&ConnectionBias::ReadAllChannels, &fBias, false)))
    12591341            ("Asynchronously request the status (current) of all channels.");
    12601342
    1261         T::AddEvent("RESET_OVER_CURRENT_STATUS", ConnectionBias::kConnected)
     1343        T::AddEvent("RESET_OVER_CURRENT_STATUS", ConnectionBias::kOverCurrent)
    12621344            (Wrapper(bind(&ConnectionBias::OverCurrentReset, &fBias)))
    12631345            ("NOT YET TESTED");
     
    12651347
    12661348
    1267         T::AddEvent("SET_GLOBAL_VOLTAGE", "F:1", ConnectionBias::kConnected, ConnectionBias::kRamping)
     1349        T::AddEvent("SET_GLOBAL_VOLTAGE", "F:1", ConnectionBias::kConnected, ConnectionBias::kAtReference, ConnectionBias::kOverCurrent)
    12681350            (bind(&StateMachineBias::SetGlobalVolt, this, placeholders::_1))
    12691351            ("Set all channels to a new reference voltage. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)");
    12701352
    1271         T::AddEvent("SET_GLOBAL_DAC", "S:1", ConnectionBias::kConnected, ConnectionBias::kRamping)
     1353        T::AddEvent("SET_GLOBAL_DAC", "S:1", ConnectionBias::kConnected, ConnectionBias::kAtReference, ConnectionBias::kOverCurrent)
    12721354            (bind(&StateMachineBias::SetGlobalDac, this, placeholders::_1))
    12731355            ("Set all channels to a new DAC reference. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)");
    12741356
    1275         T::AddEvent("SET_CHANNEL_VOLTAGE", "S:1;F:1", ConnectionBias::kConnected, ConnectionBias::kRamping)
     1357        T::AddEvent("SET_CHANNEL_VOLTAGE", "S:1;F:1", ConnectionBias::kConnected, ConnectionBias::kAtReference, ConnectionBias::kOverCurrent)
    12761358            (bind(&StateMachineBias::SetChannelVolt, this, placeholders::_1))
    12771359            ("Set a single channel a new reference voltage. Starts ramping if necessary.");
    12781360
    1279         T::AddEvent("SET_CHANNEL_DAC", "S:1;S:1", ConnectionBias::kConnected, ConnectionBias::kRamping)
     1361        T::AddEvent("SET_CHANNEL_DAC", "S:1;S:1", ConnectionBias::kConnected, ConnectionBias::kAtReference, ConnectionBias::kOverCurrent)
    12801362            (bind(&StateMachineBias::SetChannelDac, this, placeholders::_1))
    12811363            ("Set a single channel a new DAC reference value. Starts ramping if necessary.");
    12821364
    1283         T::AddEvent("SET_GAPD_REFERENCE_VOLTAGE", ConnectionBias::kConnected, ConnectionBias::kRamping)
     1365        T::AddEvent("SET_GAPD_REFERENCE_VOLTAGE", ConnectionBias::kConnected, ConnectionBias::kAtReference, ConnectionBias::kOverCurrent)
    12841366            (Wrapper(bind(&ConnectionBias::SetGapdVoltage, &fBias)))
    12851367            ("Set all channels to their G-APD reference voltage. Starts ramping if necessary.");
    12861368
    1287         T::AddEvent("SET_ZERO_VOLTAGE", ConnectionBias::kConnected, ConnectionBias::kRamping)
     1369        T::AddEvent("SET_ZERO_VOLTAGE", ConnectionBias::kConnected, ConnectionBias::kAtReference, ConnectionBias::kOverCurrent)
    12881370            (Wrapper(bind(&ConnectionBias::SetZero, &fBias)))
    12891371            ("Set all channels to a zero reference voltage. Starts ramping if necessary.");
     
    12911373
    12921374
    1293         T::AddEvent("STOP", ConnectionBias::kConnected, ConnectionBias::kRamping)
     1375        T::AddEvent("STOP", ConnectionBias::kConnected, ConnectionBias::kRamping, ConnectionBias::kAtReference, ConnectionBias::kOverCurrent)
    12941376            (Wrapper(bind(&ConnectionBias::RampStop, &fBias)))
    12951377            ("");
    12961378
    1297         T::AddEvent("START", ConnectionBias::kConnected)
     1379        T::AddEvent("START", ConnectionBias::kConnected, ConnectionBias::kOverCurrent)
    12981380            (Wrapper(bind(&ConnectionBias::RampStart, &fBias)))
    12991381            ("");
     
    13011383
    13021384
    1303         T::AddEvent("PRINT", ConnectionBias::kConnected, ConnectionBias::kExpertMode, ConnectionBias::kRamping)
    1304             (Wrapper(bind(&ConnectionBias::Print, &fBias)))
     1385        T::AddEvent("PRINT_CURRENTS")
     1386            (Wrapper(bind(&ConnectionBias::PrintA, &fBias)))
     1387            ("");
     1388        T::AddEvent("PRINT_VOLTAGES")
     1389            (Wrapper(bind(&ConnectionBias::PrintV, &fBias)))
     1390            ("");
     1391        T::AddEvent("PRINT_GAPD_REFERENCE_VOLTAGES")
     1392            (Wrapper(bind(&ConnectionBias::PrintGapd, &fBias)))
    13051393            ("");
    13061394
     
    14361524        ("ramp-step",     var<uint16_t>(),  "")
    14371525        ;
     1526    // FIXME: Update interval
     1527    // FIXME: Synchronization interval
     1528    // FIXME: Make sure ramping / request and commands are not sent at the same time.
     1529    // FIXME: Add limit of 75V
    14381530
    14391531    conf.AddOptions(control);
Note: See TracChangeset for help on using the changeset viewer.