Changeset 11289
- Timestamp:
- 07/08/11 06:35:18 (14 years ago)
- Location:
- fact/FADctrl
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/FADctrl/FAD.cc
r11259 r11289 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 {"drsreset", &FAD::cmd_drsreset, true, 1, "<low|high>", " set DRS reset line"},30 {"drsreset", &FAD::cmd_drsreset, true, 1, "<low|high>", "Set DRS reset line"}, 31 31 {"reset", &FAD::cmd_reset, true, 0, "", "Reset internal trigger counter"}, 32 32 {"runnumber", &FAD::cmd_runnumber, true, 1, "<n>", "Set runnumber"}, … … 62 62 Mode = idle; 63 63 Datafile = -1; 64 EventUpdateDelay = atof(GetConfig("EventUpdateDelay", "0.5").c_str()); 65 TimeForDIMUpdate = 0; 64 EventUpdateDelay = atof(GetConfig("EventUpdateDelay", "2").c_str()); 66 65 67 66 // Create pipe for data exchange … … 106 105 107 106 int Ret; 107 108 ExitRequest = true; 109 110 // Stop run if in progress 111 if (Mode != idle) cmd_stop(); 108 112 109 113 // Close pipe (will make read() on pipe in DIM service thread return) … … 214 218 215 219 for (unsigned int i=0; i<Boards.size(); i++) { 216 if (Match(Parameter[1], "low")) Boards[i]->Send(CMD_DRS_RST_LOW);217 else if (Match(Parameter[1], "high")) Boards[i]->Send(CMD_DRS_RST_HIGH);220 if (Match(Parameter[1], "low")) Boards[i]->Send(CMD_DRS_RST_LOW); 221 else if (Match(Parameter[1], "high")) Boards[i]->Send(CMD_DRS_RST_HIGH); 218 222 else { 219 223 PrintUsage(); … … 223 227 } 224 228 225 226 229 // 227 230 // Execute: Confirm new ROI, DAC or what ever settings 228 231 // 229 230 232 void FAD::cmd_execute() { 231 233 232 234 for (unsigned int i=0; i<Boards.size(); i++) Boards[i]->Send(CMD_Execute); 233 235 } 234 235 236 236 237 // … … 259 260 // 260 261 // Switch socket mode 261 // "com" - command mode (only socket 0 is used )262 // "com" - command mode (only socket 0 is used for event data transmission) 262 263 // "daq" - daq mode (only sockets 1 - 7 are used) 263 //264 // Note that socket 0 is always used to issue commands265 //266 264 void FAD::cmd_socketmode() { 267 265 … … 652 650 else if (Mode == acalib) PrintMessage("Current mode is ACALIB (3x%d events, slowest board %d has %d events)\n", NumEventsRequested, SlowestBoard, MinCount); 653 651 else if (Mode == datarun) PrintMessage("Current mode is DATARUN (%d events requested, %d events taken)\n", NumEventsRequested, NumEvents); 654 PrintMessage("Execution time of last DIM event update %d seconds\n", TimeForDIMUpdate);655 652 return; 656 653 } … … 808 805 void FAD::cmd_exit() { 809 806 810 if (Mode != idle) cmd_stop();811 812 807 ExitRequest = true; 813 814 // Wait to allow console input to arrive at readline()815 usleep(10000);816 808 pthread_kill(MainThread, SIGTERM); 817 809 } … … 889 881 DimService FileSizeService(SERVER_NAME"/FileSizeMB", FileSizeMB); 890 882 891 // Calculate pointers to EventData array (will be updated when active number of boards changes)883 // Set/allocate pointers 892 884 RunHeader *RHeader = (RunHeader *) EventData; 893 885 BoardStructure **BStruct = new BoardStructure * [Boards.size()]; 894 895 for (unsigned int i=0; i<Boards.size(); i++) BStruct[i] = ((BoardStructure *) (RHeader + 1)) + i; 896 EventHeader *EHeader = (EventHeader *) ((char *) (RHeader + 1) + Boards.size()*sizeof(BoardStructure)); 897 int *TriggerCell = (int *) (EHeader + 1); 898 short *Data = (short *) (TriggerCell + NChips*Boards.size()); 886 EventHeader *EHeader; 887 int *TriggerCell; 888 short *Data; 899 889 900 890 // Fill fixed entries in M0 RunHeader … … 933 923 IDString.append(string(Buffer, Ret)); 934 924 935 // Active boards for DIM and data taking must only change when idle936 if (Mode == idle) {925 // Active boards must not change during data taking 926 if (Mode != datarun || NumEvents == 0) { 937 927 ActiveBoards.clear(); 938 for (unsigned int i=0; i<Boards.size(); i++) if (Boards[i]->Active) ActiveBoards.push_back(Boards[i]); 928 for (unsigned int i=0; i<Boards.size(); i++) { 929 if (Boards[i]->Active) ActiveBoards.push_back(Boards[i]); 930 } 939 931 RHeader->NBoards = ActiveBoards.size(); 932 } 940 933 941 // Calculate updated pointers to EventData array 942 for (unsigned int i=0; i<ActiveBoards.size(); i++) BStruct[i] = ((BoardStructure *) (RHeader + 1)) + i; 943 EHeader = (EventHeader *) ((char *) (RHeader + 1) + ActiveBoards.size()*sizeof(BoardStructure)); 944 TriggerCell = (int *) (EHeader + 1); 945 Data = (short *) (TriggerCell + NChips*ActiveBoards.size()); 946 } 934 // Calculate pointers to EventData array 935 for (unsigned int i=0; i<ActiveBoards.size(); i++) BStruct[i] = ((BoardStructure *) (RHeader + 1)) + i; 936 EHeader = (EventHeader *) ((char *) (RHeader + 1) + ActiveBoards.size()*sizeof(BoardStructure)); 937 TriggerCell = (int *) (EHeader + 1); 938 Data = (short *) (TriggerCell + NChips*ActiveBoards.size()); 947 939 948 940 // If amplitude calibration mode, check if all boards finished procedure … … 993 985 for(unsigned int i=0; i<NChips; i++) TriggerCell[Brd*NChips+i] = (int) S.TriggerCell[i]; 994 986 995 // Write channel data (12 bit signed two's complement with out-of-range-bit and leading zeroes)987 // Write channel data 996 988 int Count = Brd*NChips*NChannels*NBins; 997 989 memset(Data+Count, 0, NChips*NChannels*NBins*sizeof(short)); … … 1024 1016 } 1025 1017 1026 // Check if DIM service should be updated (delay between updates at least 10xtime to update)1027 if ((Time.tv_sec-LastUpdate.tv_sec)*1e6 + Time.tv_usec-LastUpdate.tv_usec > max(10*TimeForDIMUpdate, EventUpdateDelay)*1e6) {1018 // Check if DIM service should be updated 1019 if ((Time.tv_sec-LastUpdate.tv_sec)*1e6 + Time.tv_usec-LastUpdate.tv_usec > EventUpdateDelay*1e6) { 1028 1020 gettimeofday(&LastUpdate, NULL); 1029 1021 … … 1031 1023 EventNumService.updateService(); 1032 1024 1033 TimeForDIMUpdate = time(NULL) - LastUpdate.tv_sec;1034 1025 if (Mode == datarun) FileSizeService.updateService(); 1035 1026 } … … 1110 1101 // Close data file and terminate run 1111 1102 if(close(Datafile) == -1) Message(ERROR, "Could not close data file (%s)", strerror(errno)); 1112 else PrintMessage("Data file closed (size %.1f MByte, %d events).\n", FileSizeMB, NumEvents);1103 else PrintMessage("Data file closed (size %.1f MByte, rate %.1f MByte/s, %d events).\n", FileSizeMB, FileSizeMB/(FileRHeader.EndSecond-FileRHeader.StartSecond+(FileRHeader.EndMicrosecond-FileRHeader.StartMicrosecond)/1000000.0), NumEvents); 1113 1104 1114 1105 Datafile = -1; -
fact/FADctrl/FAD.h
r11232 r11289 47 47 static void LaunchEventThread(class FAD *); 48 48 pthread_t Thread; 49 float TimeForDIMUpdate;50 49 51 50 int Datafile; -
fact/FADctrl/FADctrl.cc
r11205 r11289 49 49 if (Command == NULL) continue; 50 50 51 // Process exit request for reasons of responsiveness here 52 if (strcmp(Command, "exit") == 0) break; 53 51 54 // Add command to history 52 55 if(strlen(Command) > 0 && LastHist != Command) { -
fact/FADctrl/History.txt
r11178 r11289 34 34 21/6/2011 Command 'boards' takes 'none as argument 35 35 24/6/2011 PLL lock status published as DIM service 36 7/7/2011 Fixed error in setting the active boards in EventThread()
Note:
See TracChangeset
for help on using the changeset viewer.