Changeset 10617 for fact/FADctrl
- Timestamp:
- 05/06/11 13:16:22 (14 years ago)
- Location:
- fact/FADctrl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/FADctrl/FAD.cc
r10504 r10617 28 28 {"sclk", &FAD::cmd_sclk, true, 1, "<on|off>", "Set SCLK"}, 29 29 {"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 theinternal trigger counter"},31 {" set_runnumber", &FAD::cmd_set_runnumber, false, 1, "<n> setsrunnumber"},30 {"reset_trigger", &FAD::cmd_reset_trigger, true, 0, "", "Reset internal trigger counter"}, 31 {"runnumber", &FAD::cmd_runnumber, true, 1, "<n>", "Set runnumber"}, 32 32 {"roi", &FAD::cmd_roi, true, 2, "<channel range> <value>", "Set region-of-interest to value"}, 33 33 {"dac", &FAD::cmd_dac, true, 2, "<range> <value>", "Set DAC numbers in range to value"}, … … 41 41 {"stop", &FAD::cmd_stop, false, 0, "", "Stop current operation/run"}, 42 42 {"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"}, 46 44 {"exit", &FAD::cmd_exit, false, 0, "", "Exit program"}, 47 45 {"help", &FAD::cmd_help, false, 0, "", "Print help"}}; … … 197 195 } 198 196 197 // 198 // Reset internal trigger 199 // 200 199 201 void 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 // 209 void FAD::cmd_runnumber() { 210 207 211 int Num; 208 212 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 225 226 // 226 227 // Switch socket mode … … 241 242 } 242 243 } 243 244 //245 // Set DAQ mode246 // "start" - DAQ started, no configurations may be issued247 // "stop" - DAQ stopped, configurations may be issued248 //249 // Note that socket 0 is always used to issue commands250 //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 263 244 264 245 // … … 671 652 PrintMessage("%4d ", S.ROI[j/NChannels][j%NChannels]); 672 653 } 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); 674 656 } // for() 675 657 } … … 704 686 } 705 687 } 706 }707 708 //709 // Reconnect to boards710 //711 void FAD::cmd_reconnect() {712 713 struct Range R = {0, Boards.size()};714 715 // Check ranges716 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 boards723 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 }741 688 } 742 689 -
fact/FADctrl/FAD.h
r10504 r10617 70 70 void cmd_acalib(); void cmd_serial(); 71 71 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(); 75 74 void cmd_srclk(); void cmd_sclk(); 76 75 void cmd_dwrite(); void cmd_domino(); … … 80 79 void cmd_phase(); void cmd_send(); 81 80 void cmd_stop(); void cmd_update(); 82 void cmd_take(); void cmd_reconnect();81 void cmd_take(); 83 82 84 83 void EnableDomino(); -
fact/FADctrl/History.txt
r10291 r10617 23 23 5/4/2011 Added DIM rate service for each board 24 24 6/4/2011 Bug fix in internal pipe communication 25 4/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.