Changeset 10617


Ignore:
Timestamp:
May 6, 2011, 1:16:22 PM (9 years ago)
Author:
ogrimm
Message:
New FAD event format implemented
Location:
fact/FADctrl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fact/FADctrl/FAD.cc

    r10504 r10617  
    2828   {"sclk", &FAD::cmd_sclk, true, 1, "<on|off>", "Set SCLK"},
    2929   {"trigger", &FAD::cmd_trigger, false, 0, "[n|cont [rate]|stop|enable|disable]", "Issue software triggers"},
    30    {"reset_trigger", &FAD::cmd_reset_trigger, false, 0, "resets the internal trigger counter"},
    31    {"set_runnumber", &FAD::cmd_set_runnumber, false, 1, "<n> sets runnumber"},
     30   {"reset_trigger", &FAD::cmd_reset_trigger, true, 0, "", "Reset internal trigger counter"},
     31   {"runnumber", &FAD::cmd_runnumber, true, 1, "<n>", "Set runnumber"},
    3232   {"roi", &FAD::cmd_roi, true, 2, "<channel range> <value>", "Set region-of-interest to value"},
    3333   {"dac", &FAD::cmd_dac, true, 2, "<range> <value>", "Set DAC numbers in range to value"},
     
    4141   {"stop", &FAD::cmd_stop, false, 0, "", "Stop current operation/run"},
    4242   {"update", &FAD::cmd_update, false, 1, "<sec>", "Minimum delay between updates to DIM event service"},                 
    43    {"socketmode", &FAD::cmd_socketmode, true, 1, "<com|daq>", "Choose which Sockets are used for data transmission"},
    44    {"daqmode", &FAD::cmd_daqmode, true, 1, "<start|stop>", "Set FAD DAQ mode. when started, no configurations must be send."},                           
    45    {"reconnect", &FAD::cmd_reconnect, true, 1, "<board range> [init]", "Reconnect to boards (and re-initialise)"},               
     43   {"socketmode", &FAD::cmd_socketmode, true, 1, "<com|daq>", "Choose which Sockets are used for data transmission"},                     
    4644   {"exit", &FAD::cmd_exit, false, 0, "", "Exit program"},
    4745   {"help", &FAD::cmd_help, false, 0, "", "Print help"}};
     
    197195}
    198196
     197//
     198// Reset internal trigger
     199//
     200
    199201void FAD::cmd_reset_trigger() {
    200   for (unsigned int i=0; i<Boards.size(); i++) {
    201         Boards[i]->Send(CMD_RESET_TRIGGER_ID);
    202   }
    203 }
    204 
    205 
    206 void FAD::cmd_set_runnumber() {
     202
     203  for (unsigned int i=0; i<Boards.size(); i++) Boards[i]->Send(CMD_RESET_TRIGGER_ID);
     204}
     205
     206//
     207// Set run number
     208//
     209void FAD::cmd_runnumber() {
     210
    207211  int Num;
    208212
    209   if (Parameter.size() == 2) {
    210                 ConvertToInt(Parameter[1], &Num);
    211           for (unsigned int i=0; i<Boards.size(); i++) {
    212                         Boards[i]->Send( CMD_Write | ADDR_RUNNUMBER );
    213                         Boards[i]->Send((unsigned short) Num>>16);              // Write the HIGH-word first
    214                         Boards[i]->Send( CMD_Write | (ADDR_RUNNUMBER+1) );
    215                         Boards[i]->Send((unsigned short) (Num>>16)<<16); // now write the LOW-word
    216                 }
    217         }
    218         else {
    219           PrintUsage();
    220           return;
    221         }
    222 }
    223  
    224 
     213  if (!ConvertToInt(Parameter[1], &Num)) {
     214        PrintMessage("Error, incorrect parameter for run number\n");
     215        return;
     216  }
     217
     218  for (unsigned int i=0; i<Boards.size(); i++) {
     219        Boards[i]->Send(CMD_Write | ADDR_RUNNUMBER );
     220        Boards[i]->Send((unsigned short) (Num>>16));            // Write the HIGH-word first
     221        Boards[i]->Send(CMD_Write | (ADDR_RUNNUMBER+1) );
     222        Boards[i]->Send((unsigned short) Num); // now write the LOW-word
     223  }
     224}
     225 
    225226//
    226227// Switch socket mode
     
    241242  }
    242243}
    243 
    244 //
    245 // Set DAQ mode
    246 // "start" - DAQ started, no configurations may be issued
    247 // "stop" - DAQ stopped, configurations may be issued
    248 //
    249 //      Note that socket 0 is always used to issue commands
    250 //
    251 void FAD::cmd_daqmode() {
    252 
    253   for (unsigned int i=0; i<Boards.size(); i++) {
    254         if (Match(Parameter[1],"start")) Boards[i]->Send(CMD_Start);
    255         else if (Match(Parameter[1],"stop")) Boards[i]->Send(CMD_Stop);
    256         else {
    257           PrintUsage();
    258           return;
    259         }
    260   }
    261 }
    262 
    263244
    264245//
     
    671652          PrintMessage("%4d ", S.ROI[j/NChannels][j%NChannels]);
    672653        }
    673         PrintMessage("\n");
     654       
     655        PrintMessage("\nLast trigger: ID %d    Type %d   CRC %d     Run number %d\n", S.TriggerID, S.TriggerType, S.TriggerCRC, S.Runnumber);
    674656  } // for()
    675657}
     
    704686        }
    705687  } 
    706 }
    707 
    708 //
    709 // Reconnect to boards
    710 //
    711 void FAD::cmd_reconnect() {
    712 
    713   struct Range R = {0, Boards.size()};
    714 
    715   // Check ranges 
    716   if (!ConvertToRange(Parameter[1], R)) {
    717         PrintMessage("Error, board number(s) out of range\n");
    718         return;
    719   }
    720   PrintMessage("Note: Currently not protection against concurrent access in EventThread\n");
    721  
    722   // Reinstantiate boards
    723   for (int i=0; i<(int) Boards.size(); i++) if (i >= R.Min && i <= R.Max) {
    724         if (pthread_kill(Boards[i]->Thread, 0) != ESRCH) {
    725           PrintMessage("Event thread of board %d still running, cannot reconnect\n", i);
    726           continue;
    727         }
    728 
    729         delete Boards[i];
    730     Boards[i] = new class FADBoard(BoardList[i], PORT, this, i);
    731   }
    732  
    733   // Initialise boards if requested (use sendCommandNB() to avoid dead lock)
    734   if (Parameter.size() != 3 || !Match(Parameter[2], "init")) return;
    735    
    736   vector<string> Init = Tokenize(GetConfig("InitSequence"), ";");
    737 
    738   for (unsigned int i=0; i<Init.size(); i++) {
    739         DimClient::sendCommandNB(SERVER_NAME"/Command", (char *) Init[i].c_str());
    740   }
    741688}
    742689
  • fact/FADctrl/FAD.h

    r10504 r10617  
    7070        void cmd_acalib();              void cmd_serial();
    7171        void cmd_trigger();
    72         void cmd_reset_trigger();
    73         void cmd_set_runnumber();       
    74 void cmd_socketmode();void cmd_daqmode(); 
     72        void cmd_runnumber();   void cmd_reset_trigger();
     73        void cmd_socketmode();
    7574        void cmd_srclk();               void cmd_sclk();
    7675        void cmd_dwrite();              void cmd_domino();
     
    8079        void cmd_phase();               void cmd_send();
    8180        void cmd_stop();                void cmd_update();
    82         void cmd_take();                void cmd_reconnect();
     81        void cmd_take();
    8382
    8483    void EnableDomino();
  • fact/FADctrl/History.txt

    r10291 r10617  
    23235/4/2011        Added DIM rate service for each board
    24246/4/2011        Bug fix in internal pipe communication 
     254/5/2011        Removed 'daqmode' (had no function). Added 'reset_trigger' and 'runnumber' commands.
     26                        Event format adapted (ADC data not sent in network byte order anymore).
Note: See TracChangeset for help on using the changeset viewer.