Compare commits

..

92 Commits
v1.0 ... master

Author SHA1 Message Date
Ryan Tang 63f447ab41 added code specifically for the SOLARIS DAQ, the root path is always under /mnt/data1/<expName> 2025-05-15 18:22:45 -05:00
Ryan Tang 66df74920e add more info on expName in Program setting and New Exp 2025-05-15 17:03:56 -05:00
Ryan Tang e9562fb4b1 UI bug for digitizerPlanel. when in All setting page, if a specific channel is focused, refresh setting now properly update the settings for that channel 2025-05-15 14:44:07 -05:00
Ryan Tang ce9d2d3063 small fix, prepare for clean up the git image for the firmware 2025-05-15 13:29:15 -05:00
Ryan Tang ceb4cf4563 remove all firmwares due to too big, can donwload from FSU Fox'Lab wiki 2025-05-13 16:33:47 -05:00
Ryan@iMac f8e60f94ce add python scripts to extract parameters to JSON and compare the JSON 2025-05-13 16:30:34 -05:00
Ryan Tang bd47bc4928 various fix focused on PSD firmware for VX2730, aim to match firmware version 2024092000 2025-05-12 18:19:06 -05:00
Ryan@fischam 8dd9023b68 fix display for 32 channels model on the scaler 2025-05-06 11:33:27 -05:00
Ryan Tang bc73eaa91d Create LICENSE
Add GPL License.
2024-12-07 14:32:29 -05:00
Ryan Tang 369d99524c bug fix on DigiParameters::GetFullPara for all channels 2024-10-30 12:13:01 -04:00
Ryan Tang 5c62ccbc89 added Save-runs-in-subFolders setting 2024-10-15 10:59:26 -04:00
Ryan Tang b5a974a38d add support for 32 channel board in the DigiParameters.h 2024-09-27 14:17:22 -04:00
Ryan Tang daf8d133a9 edit test.cpp and Makefile for ClassInfluxDB 2024-07-31 15:02:12 -04:00
Ryan Tang 2c039dc743 update the influxdb class to ClassInfixDB to suppport influx 2.0 2024-07-31 14:54:50 -04:00
Ryan Tang bcf73b4112 bug fix for VX2730 2024-07-27 15:36:30 -04:00
Ryan Tang beb4cdef8e Add Run Time for EventBuilder 2024-07-04 20:09:17 -04:00
Ryan Tang 005c752772 slightly change the EventBuilder to compatable with Root DataFrame. 2024-07-04 20:07:58 -04:00
Ryan Tang aa60a0dbe3 when create new branch in analysis Path, check the branch exist, display raw data path fix 2024-07-04 20:07:58 -04:00
Ryan@MBA2024 66ba308d9b fix Hit.h for Mac 2024-07-04 18:30:21 -04:00
Ryan Tang 852f4b52f4 [Major] fully tested new folder arrangement. the programSettings.txt will be saved on current directory, can run without analysis path 2024-07-01 17:56:03 -04:00
Ryan Tang 4b7ae83997 snapshot, not finished 2024-07-01 17:19:23 -04:00
Ryan Tang b7f2fcbc58 improve the user experiment on program setting. add alot of fault proof 2024-07-01 13:33:49 -04:00
Ryan Tang 6571f93d9b re structure the file structure. now the daq work without eanalysis folder. 2024-06-28 18:30:35 -04:00
Ryan Tang 844f14be5f setting file inlcuded DPP type 2024-06-11 14:25:56 -04:00
Ryan Tang ab94ef3dfa add the make file in Aux, small change for Ubuntu 23.04 2024-04-11 19:29:23 -04:00
Ryan Tang 0c6db57f47 comment out some useless codes 2024-04-08 20:41:57 -04:00
Ryan Tang 8b668cb8d5 fixed repeat run problems 2024-04-08 20:17:26 -04:00
Ryan Tang 378fffe4ec Scope will set digitizer into self-trigger 2024-04-08 16:55:26 -04:00
Ryan Tang 2fa22bbcc2 Add text in Sync button to indicate Sync mode 2024-04-08 13:57:31 -04:00
Ryan Tang f0f25f860d test Pulse tab is only avalible when Global trigger source has test pulse 2024-04-08 13:53:39 -04:00
Ryan Tang 95efe40ffa fixed VGA setting crash; remove unless buttons in the main panel 2024-04-08 13:42:13 -04:00
Ryan Tang b7a23b4a7e small modification of Hit.h and SolReader.h 2024-04-05 12:17:13 -04:00
Ryan Tang 119eb64fd2 move Eventbuilder from SOLARIS_Analysis to here. Created Aux folder to store Auxilary code, like EventBuilder 2024-03-20 18:54:43 -04:00
Ryan Tang bdf4208070 make the RunTimeStamp good within 1 sec 2023-12-07 18:10:17 -05:00
Ryan Tang 8d10d24d18 bug fix on the RunTimestamp.dat. 2023-12-07 17:06:33 -05:00
Ryan Tang fdc155ed90 display bug in digiPanel 2023-11-15 12:45:59 -05:00
Ryan Tang 68d86c3618 bug fix for ClassDigitizer2Gen::ReadData() for PHA data format 2023-11-14 16:50:55 -05:00
Ryan Tang d65c324119 added min+fine_timestamo data format 2023-11-06 13:44:55 -05:00
Ryan Tang 29f551018e bug fix on BoardVetoPolarity and InputDelay Display 2023-11-06 13:13:42 -05:00
Ryan Tang a8b87e70f4 fixed using old firmware with new libraries 2023-10-26 17:03:23 -04:00
Ryan Tang b888a8ea63 improved the Input Delay 2023-10-26 16:37:29 -04:00
Ryan Tang d96ed2984e add CupVer protection for Input Delay setting 2023-10-25 15:06:33 -04:00
Ryan Tang fbb20eff93 added InputDelay for latest firmware 2023-10-25 14:57:07 -04:00
Ryan Tang f5fd9174f9 do the same when digitizer changed in scope 2023-10-20 12:10:22 -04:00
Ryan Tang 20478c317e in scope when channel change, disbale all other channel but the one selected 2023-10-20 12:05:03 -04:00
Ryan Tang 40230300fe fixed scope stop, only restore ch on/off for 1st digitizer, added more comment string support for Mapping.h, change color green to orange for some Combox 2023-10-20 11:47:39 -04:00
Ryan Tang 6041a6880b remove settings using Sample in setting file 2023-10-19 09:38:57 -04:00
Ryan Tang ee3edbeba6 update the DigiParameters.h and Digitizer Class for latest PHA firmware. new parameters are not implemented. Still supporting old firmware 2023-10-16 13:27:40 -04:00
Ryan Tang 1186de195d added firmwares folder and update README.md 2023-10-16 12:43:45 -04:00
Ryan Tang 6edcd2c230 update the README.md 2023-10-16 12:34:06 -04:00
Ryan Tang 13a41b1982 bug fix for PSD Minimum dataFormat 2023-10-16 12:29:35 -04:00
Ryan Tang 30f01f5793 change enum::DataFormat::RAW to Raw, edited README.md 2023-10-13 13:05:59 -04:00
Ryan Tang 10e734e07d fix incorrect bit shift 2023-10-11 13:31:12 -04:00
Ryan Tang b667d4a416 stop digitziers from last to first 2023-09-26 13:15:10 -04:00
Ryan Tang e9d6f2a312 rename Eevnt class to Hit 2023-09-26 10:41:24 -04:00
Ryan Tang 2cc3056a9c set focus on OK and Save in Program setting 2023-09-26 10:31:55 -04:00
Ryan Tang 2caec2a6e6 for V2740 and PSD, EnStatEvents = true, trace will freeze after few sec 2023-09-25 17:46:22 -04:00
Ryan Tang 956467b193 add PSD supper in the Scope. Issue, the trace don't change after few sec for PSD, not PHA. firmware problem? 2023-09-25 17:07:17 -04:00
Ryan Tang c5c2c69b96 fix the inquary tab for different firmware 2023-09-25 14:57:21 -04:00
Ryan Tang dbb950d4df added PSU UI in digiSetting Panel 2023-09-25 14:29:27 -04:00
Ryan Tang 795a80d3a4 tested PSD data readout. OK! next UI 2023-09-22 18:35:14 -04:00
Ryan Tang e13713c299 fix ReadData logic problem 2023-09-22 17:57:43 -04:00
Ryan Tang 95310aa1c2 add PSD in the core Digitizer Class and SolReader 2023-09-22 15:58:28 -04:00
Ryan Tang 71464484ba added PSD prarmeeters 2023-09-21 19:00:48 -04:00
Ryan Tang d7d3988b75 break ProgramPHA into board and channel, some UI improve 2023-09-21 17:24:13 -04:00
Ryan Tang 2a9319fb5d added LVDS and DAC settings, some bugs fixed 2023-09-19 19:19:07 -04:00
Ryan Tang 7845b8fb8c change the scalar update rountine. scalar will update every 2 sec once it opened and keep running unit digitizer closed. scalar also update board status if digi setting pannel open 2023-09-19 12:57:42 -04:00
Ryan Tang 8169567af2 completed ITL setting UI 2023-09-18 19:16:28 -04:00
Ryan Tang 49fe750070 add ITL-AB and LVDS setting parameters, re-structure the digiSetting UI, leave space for LVDS and ITL settings 2023-09-18 17:05:13 -04:00
Ryan Tang 38525125c4 added Sync Helper 2023-09-18 12:52:15 -04:00
Ryan Tang eda5aeb36d start the DAQ form slave, able to Sync 2023-09-15 17:53:08 -04:00
Ryan Tang 9736f5cdc6 many bugs fix, plan to add SyncHelper 2023-09-15 17:31:07 -04:00
Ryan Tang 8a0c828ebe fixe delete scope bug 2023-04-25 17:36:20 -04:00
Ryan Tang 3df3fd50a1 combined trace and scalar thread. 2023-04-25 17:23:50 -04:00
Ryan Tang 8fe3e09b51 bring scalar, digiSetting, solariSetting in front 2023-04-18 17:37:30 -04:00
Ryan Tang 9f40081dbb remove debug code 2023-04-18 10:49:04 -04:00
Ryan Tang cefc5fd1ef fixed scalar bugs 2023-04-18 10:38:40 -04:00
Ryan Tang 1fc203818e UpdateScalar also update digiSettings status, if exist and visible 2023-04-14 14:10:02 -04:00
Ryan Tang b916295a4d bug fix and improve on Setup New Exp panel 2023-04-14 13:14:10 -04:00
Ryan Tang 66c7211d7a many UI bugs fix and improvement, save Setting to temSettings when close digitizers. 2023-04-12 13:52:42 -04:00
Ryan Tang e56cddaf06 panels enabled bug fix 2023-04-04 11:46:02 -04:00
Ryan Tang f6bbf0bf79 few bugs fix. add RunTimeStamp.CSV 2023-04-03 18:20:36 -04:00
Ryan Tang 7ba39bcc5a finished debug of Solaris panel after Mapping.h format changed 2023-04-03 12:25:23 -04:00
Ryan Tang 69955a863d Major Change. The Mapping.h changed. 2023-03-31 20:01:27 -04:00
Ryan Tang 23367d5ac4 attemp to capture grafana screen without open browser, fail 2023-03-30 18:01:54 -04:00
Ryan Tang aacac712ca tested endRunScript, fixed autoRun 2023-03-30 13:09:11 -04:00
Ryan Tang 97b05d2b99 added EndRunScript. when change/creaet new exp, push to database if exist 2023-03-29 15:24:53 -04:00
Ryan Tang 2898e8e69a add git fetch 2023-03-29 11:26:32 -04:00
Ryan Tang f90ae8905b added root data path 2023-03-28 16:58:46 -04:00
Ryan Tang 972059f475 small change in setting file, group setting together instead of channel 2023-03-28 12:01:22 -04:00
Ryan Tang 28b447673b fix bug when no digitizer connected. becasue the scalar did not setup 2023-03-27 18:34:22 -04:00
Ryan Tang d839def1f2 add a identiflier in the sol file to indicate the id of digi 2023-03-27 18:21:51 -04:00
43 changed files with 8260 additions and 3361 deletions

5
.gitignore vendored
View File

@ -5,11 +5,14 @@ SOLARIS_DAQ
programSettings.txt programSettings.txt
test test
windowID windowID
tempSettings
screenshot.* screenshot.*
*settings*.txt *settings*.txt
*settings*.dat *settings*.dat
*.dat *.dat
Logs Logs
*.png
.gdb_history
*~ *~
*.autosave *.autosave
@ -23,6 +26,7 @@ moc_*
*.rej *.rej
*.so *.so
*.so.* *.so.*
*.json
*_pch.h.cpp *_pch.h.cpp
*_resource.rc *_resource.rc
*.qm *.qm
@ -83,3 +87,4 @@ CMakeLists.txt.user*
*.dll *.dll
*.exe *.exe
EventBuilder

View File

@ -5,14 +5,26 @@
"includePath": [ "includePath": [
"${workspaceFolder}/**", "${workspaceFolder}/**",
"/usr/include/x86_64-linux-gnu/qt6/**", "/usr/include/x86_64-linux-gnu/qt6/**",
"/opt/root/include/**" "/opt/root/**"
], ],
"defines": [], "defines": [],
"compilerPath": "/usr/bin/gcc", "compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17", "cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
},
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++17", "cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64" "intelliSenseMode": "linux-gcc-x64"
} }
], ],
"version": 4 "version": 4
} }

364
Aux/EventBuilder.cpp Normal file
View File

@ -0,0 +1,364 @@
#include "SolReader.h"
#include <cstdio>
#include <cstdlib>
#include "TFile.h"
#include "TTree.h"
#include "TMath.h"
#include "TString.h"
#include "TMacro.h"
//#include "TClonesArray.h" // plan to save trace as TVector with TClonesArray
//#include "TVector.h"
#include <sys/time.h> /** struct timeval, select() */
inline unsigned int getTime_us(){
unsigned int time_us;
struct timeval t1;
struct timezone tz;
gettimeofday(&t1, &tz);
time_us = (t1.tv_sec) * 1000 * 1000 + t1.tv_usec;
return time_us;
}
#define MAX_MULTI 64
#define MAX_TRACE_LEN 1250 /// = 10 us
#define tick2ns 8 // 1 tick = 8 ns
SolReader ** reader;
Hit ** hit;
std::vector<std::vector<int>> idList;
unsigned long totFileSize = 0;
unsigned long processedFileSize = 0;
std::vector<int> activeFileID;
std::vector<int> groupIndex;
std::vector<std::vector<int>> group; // group[i][j], i = group ID, j = group member)
void findEarliestTime(int &fileID, int &groupID){
unsigned long firstTime = 0;
for( int i = 0; i < (int) activeFileID.size(); i++){
int id = activeFileID[i];
if( i == 0 ) {
firstTime = hit[id]->timestamp;
fileID = id;
groupID = i;
//printf("%d | %d %lu %d | %d \n", id, reader[id]->GetBlockID(), hit[id]->timestamp, hit[id]->channel, (int) activeFileID.size());
continue;
}
if( hit[id]->timestamp <= firstTime) {
firstTime = hit[id]->timestamp;
fileID = id;
groupID = i;
//printf("%d | %d %lu %d | %d \n", id, reader[id]->GetBlockID(), hit[id]->timestamp, hit[id]->channel, (int) activeFileID.size());
}
}
}
unsigned long long evID = 0;
unsigned int multi = 0;
unsigned short bd[MAX_MULTI] = {0};
unsigned short sn[MAX_MULTI] = {0};
unsigned short ch[MAX_MULTI] = {0};
unsigned short e[MAX_MULTI] = {0};
unsigned short e2[MAX_MULTI] = {0}; //for PSD energy short
unsigned long long e_t[MAX_MULTI] = {0};
unsigned short e_f[MAX_MULTI] = {0};
unsigned short lowFlag[MAX_MULTI] = {0};
unsigned short highFlag[MAX_MULTI] = {0};
int traceLen[MAX_MULTI] = {0};
int trace[MAX_MULTI][MAX_TRACE_LEN] = {0};
void fillData(int &fileID, const bool &saveTrace){
bd[multi] = idList[fileID][1];
sn[multi] = idList[fileID][3];
ch[multi] = hit[fileID]->channel;
e[multi] = hit[fileID]->energy;
e2[multi] = hit[fileID]->energy_short;
e_t[multi] = hit[fileID]->timestamp;
e_f[multi] = hit[fileID]->fine_timestamp;
lowFlag[multi] = hit[fileID]->flags_low_priority;
highFlag[multi] = hit[fileID]->flags_high_priority;
if( saveTrace ){
traceLen[multi] = hit[fileID]->traceLenght;
for( int i = 0; i < TMath::Min(traceLen[multi], MAX_TRACE_LEN); i++){
trace[multi][i] = hit[fileID]->analog_probes[0][i];
}
}
multi++;
reader[fileID]->ReadNextBlock();
}
void printEvent(){
printf("==================== evID : %llu\n", evID);
for( int i = 0; i < multi; i++){
printf(" %2d | %d %d | %llu %d \n", i, bd[i], ch[i], e_t[i], e[i] );
}
printf("==========================================\n");
}
//^##################################################################################
int main(int argc, char ** argv){
printf("=======================================================\n");
printf("=== SOLARIS Event Builder sol --> root ===\n");
printf("=======================================================\n");
if( argc <= 3){
printf("%s [outfile] [timeWindow] [saveTrace] [sol-1] [sol-2] ... \n", argv[0]);
printf(" outfile : output root file name\n");
printf(" timeWindow : number of tick, 1 tick = %d ns.\n", tick2ns);
printf(" saveTrace : 1 = save trace, 0 = no trace\n");
printf(" sol-X : the sol file(s)\n");
return -1;
}
unsigned int runStartTime = getTime_us();
TString outFileName = argv[1];
int timeWindow = abs(atoi(argv[2]));
const bool saveTrace = atoi(argv[3]);
const int nFile = argc - 4;
TString inFileName[nFile];
for( int i = 0 ; i < nFile ; i++){
inFileName[i] = argv[i+4];
}
//*======================================== setup reader
reader = new SolReader*[nFile];
hit = new Hit *[nFile];
for( int i = 0 ; i < nFile ; i++){
reader[i] = new SolReader(inFileName[i].Data());
hit[i] = reader[i]->hit; //TODO check is file open propertly
reader[i]->ReadNextBlock(); // read the first block
}
//*======================================== group files
idList.clear();
for( int i = 0; i < nFile; i++){
TString fn = inFileName[i];
int pos = fn.Last('/'); // path
fn.Remove(0, pos+1);
pos = fn.First('_'); // expName;
fn.Remove(0, pos+1);
pos = fn.First('_'); // runNum;
fn.Remove(0, pos+1);
pos = fn.First('_'); // digiID
TString f1 = fn;
int digiID = f1.Remove(pos).Atoi();
fn.Remove(0, pos+1);
pos = fn.Last('_'); // digi serial num
f1 = fn;
int digisn = f1.Remove(pos).Atoi();
fn.Remove(0, pos+1);
pos = fn.First('.'); // get the file id;
int indexID = fn.Remove(pos).Atoi();
int fileID = i;
std::vector<int> haha = {fileID, digiID, indexID, digisn};
idList.push_back(haha);
}
// sort by digiID
std::sort(idList.begin(), idList.end(), [](const std::vector<int>& a, const std::vector<int>& b){
if (a[1] == b[1]) {
return a[2] < b[2];
}
return a[1] < b[1];
});
group.clear(); // group[i][j], i is the group Index = digiID
int last_id = 0;
std::vector<int> kaka;
for( int i = 0; i < (int) idList.size() ; i++){
if( i == 0 ) {
kaka.clear();
last_id = idList[i][1];
kaka.push_back(idList[i][0]);
continue;
}
if( idList[i][1] != last_id ) {
last_id = idList[i][1];
group.push_back(kaka);
kaka.clear();
kaka.push_back(idList[i][0]);
}else{
kaka.push_back(idList[i][0]);
}
}
group.push_back(kaka);
printf(" out file : \033[1;33m%s\033[m\n", outFileName.Data());
printf(" Event building time window : %d tics = %d nsec \n", timeWindow, timeWindow*tick2ns);
printf(" Save Trace ? %s \n", saveTrace ? "Yes" : "No");
printf(" Number of input file : %d \n", nFile);
for( int i = 0; i < nFile; i++){
printf(" %2d| %5.1f MB| %s \n", i, reader[i]->GetFileSize()/1024./1024., inFileName[i].Data());
totFileSize += reader[i]->GetFileSize();
}
printf("------------------------------------\n");
for( int i = 0; i < (int) group.size(); i++){
printf("Group %d :", i);
for( int j = 0; j < (int) group[i].size(); j ++){
printf("%d, ", group[i][j]);
}
printf("\n");
}
printf("------------------------------------\n");
//*======================================== setup tree
TFile * outRootFile = new TFile(outFileName, "recreate");
outRootFile->cd();
TTree * tree = new TTree("tree", outFileName);
tree->Branch("evID", &evID, "evID/l");
tree->Branch("multi", &multi, "multi/i");
tree->Branch("bd", bd, "bd[multi]/s");
tree->Branch("sn", sn, "sn[multi]/s");
tree->Branch("ch", ch, "ch[multi]/s");
tree->Branch("e", e, "e[multi]/s");
tree->Branch("e2", e2, "e2[multi]/s");
tree->Branch("e_t", e_t, "e_t[multi]/l");
tree->Branch("e_f", e_f, "e_f[multi]/s");
tree->Branch("lowFlag", lowFlag, "lowFlag[multi]/s");
tree->Branch("highFlag", highFlag, "highFlag[multi]/s");
if( saveTrace){
tree->Branch("traceLen", traceLen, "traceLen[multi]/I");
tree->Branch("trace", trace, Form("trace[multi][%d]/I", MAX_TRACE_LEN));
tree->GetBranch("trace")->SetCompressionSettings(205);
}
//*=========================================== build event
//@---- using file from group[i][0] first
//--- find earlist time among the files
activeFileID.clear();
groupIndex.clear(); //the index of each group
for(int i = 0; i < (int) group.size(); i++) {
groupIndex.push_back(0);
activeFileID.push_back(group[i][0]);
}
int fileID = 0;
int groupID = 0;
findEarliestTime(fileID, groupID);
fillData(fileID, saveTrace);
unsigned long firstTimeStamp = hit[fileID]->timestamp;
unsigned long lastTimeStamp = 0;
int last_precentage = 0;
while((activeFileID.size() > 0)){
findEarliestTime(fileID, groupID);
if( reader[fileID]->IsEndOfFile() ){
groupIndex[groupID] ++;
if( groupIndex[groupID] < (int) group[groupID].size() ){
activeFileID[groupID] = group[groupID][groupIndex[groupID]];
fileID = activeFileID[groupID];
}else{
activeFileID.erase(activeFileID.begin() + groupID);
}
}
if( hit[fileID]->timestamp - e_t[0] < timeWindow ){
fillData(fileID, saveTrace);
}else{
outRootFile->cd();
tree->Fill();
evID ++;
multi = 0;
fillData(fileID, saveTrace);
}
///========= calculate progress
processedFileSize = 0;
for( int p = 0; p < (int) group.size(); p ++){
for( int q = 0; q <= groupIndex[p]; q++){
if( groupIndex[p] < (int) group[p].size() ){
int id = group[p][q];
processedFileSize += reader[id]->GetFilePos();
}
}
}
double percentage = processedFileSize * 100/ totFileSize;
if( percentage >= last_precentage ) {
printf("Processed : %llu, %.0f%% | %lu/%lu | ", evID, percentage, processedFileSize, totFileSize);
for( int i = 0; i < (int) activeFileID.size(); i++) printf("%d, ", activeFileID[i]);
printf(" \n\033[A\r");
last_precentage = percentage + 1.0;
}
}; ///====== end of event building loop
processedFileSize = 0;
for( int p = 0; p < (int) group.size(); p ++){
for( int q = 0; q < (int) group[p].size(); q++){
int id = group[p][q];
processedFileSize += reader[id]->GetFilePos();
}
}
double percentage = processedFileSize * 100/ totFileSize;
printf("Processed : %llu, %.0f%% | %lu/%lu \n", evID, percentage, processedFileSize, totFileSize);
lastTimeStamp = hit[fileID]->timestamp;
//*=========================================== save file
outRootFile->cd();
tree->Fill();
evID ++;
tree->Write();
//*=========================================== Save timestamp as TMacro
TMacro timeStamp;
TString str;
str.Form("%lu", firstTimeStamp); timeStamp.AddLine( str.Data() );
str.Form("%lu", lastTimeStamp); timeStamp.AddLine( str.Data() );
timeStamp.Write("timeStamp");
unsigned int numBlock = 0;
for( int i = 0; i < nFile; i++){
//printf("%d | %8ld | %10u/%10u\n", i, reader[i]->GetBlockID() + 1, reader[i]->GetFilePos(), reader[i]->GetFileSize());
numBlock += reader[i]->GetBlockID() + 1;
}
unsigned int runEndTime = getTime_us();
double runTime = (runEndTime - runStartTime) * 1e-6;
printf("===================================== done. \n");
printf(" event building time : %.2f sec = %.2f min\n", runTime, runTime/60.);
printf("Number of Block Scanned : %u\n", numBlock);
printf(" Number of Event Built : %lld\n", evID);
printf(" Output Root File Size : %.2f MB\n", outRootFile->GetSize()/1024./1024.);
printf(" first timestamp : %lu \n", firstTimeStamp);
printf(" last timestamp : %lu \n", lastTimeStamp);
unsigned long duration = lastTimeStamp - firstTimeStamp;
printf(" total duration : %lu = %.2f sec \n", duration, duration * tick2ns * 1.0 / 1e9 );
printf("===================================== end of summary. \n");
//^############## delete new
for( int i = 0; i < nFile; i++) delete reader[i];
delete [] reader;
outRootFile->Close();
return 0;
}

23
Aux/Makefile Normal file
View File

@ -0,0 +1,23 @@
CC=g++
CFLAG= -O2
#CFLAG= -g -O0
ROOTFLAG=`root-config --cflags --glibs`
OBJS = ClassDigitizer.o ClassInfluxDB.o
all: EventBuilder
EventBuilder: EventBuilder.cpp SolReader.h ../Hit.h
$(CC) $(CFLAG) EventBuilder.cpp -o EventBuilder ${ROOTFLAG}
ClassDigitizer.o : ../ClassDigitizer.cpp ../ClassDigitizer.h ../RegisterAddress.h ../macro.h ../ClassData.h
$(CC) $(COPTS) -c ../ClassDigitizer.cpp
ClassInfluxDB.o : ../ClassInfluxDB.cpp ../ClassInfluxDB.h
$(CC) $(COPTS) -c ../ClassInfluxDB.cpp -lcurl
test: test.cpp ../ClassDigitizer2Gen.o ../ClassInfluxDB.o
$(CC) $(CFLAG) test.cpp ../ClassDigitizer2Gen.o ../ClassInfluxDB.o -o test -lcurl -lCAEN_FELib -lX11
clean:
-rm EventBuilder test

271
Aux/SolReader.h Normal file
View File

@ -0,0 +1,271 @@
#ifndef SOLREADER_H
#define SOLREADER_H
#include <stdio.h> /// for FILE
#include <cstdlib>
#include <string>
#include <vector>
#include <unistd.h>
#include <time.h> // time in nano-sec
#include "../Hit.h"
class SolReader {
private:
FILE * inFile;
unsigned int inFileSize;
unsigned int filePos;
unsigned int totNumBlock;
unsigned short blockStartIdentifier;
unsigned int numBlock;
bool isScanned;
void init();
std::vector<unsigned int> blockPos;
size_t dummy;
public:
SolReader();
SolReader(std::string fileName, unsigned short dataType);
~SolReader();
void OpenFile(std::string fileName);
int ReadNextBlock(bool fastRead = false, bool debug = false);
int ReadBlock(unsigned int index, bool verbose = false);
void ScanNumBlock();
bool IsEndOfFile() const {return (filePos >= inFileSize ? true : false);}
unsigned int GetBlockID() const {return numBlock - 1;}
unsigned int GetNumBlock() const {return numBlock;}
unsigned int GetTotalNumBlock() const {return totNumBlock;}
unsigned int GetFilePos() const {return filePos;}
unsigned int GetFileSize() const {return inFileSize;}
void RewindFile();
Hit * hit;
};
void SolReader::init(){
inFileSize = 0;
numBlock = 0;
filePos = 0;
totNumBlock = 0;
hit = new Hit();
isScanned = false;
blockPos.clear();
}
SolReader::SolReader(){
init();
}
SolReader::SolReader(std::string fileName, unsigned short dataType = 0){
init();
OpenFile(fileName);
hit->SetDataType(dataType, DPPType::PHA);
}
SolReader::~SolReader(){
if( inFile ) fclose(inFile);
delete hit;
}
inline void SolReader::OpenFile(std::string fileName){
inFile = fopen(fileName.c_str(), "r");
if( inFile == NULL ){
printf("Cannot open file : %s \n", fileName.c_str());
}else{
fseek(inFile, 0L, SEEK_END);
inFileSize = ftell(inFile);
rewind(inFile);
}
}
inline int SolReader::ReadBlock(unsigned int index, bool verbose){
if( isScanned == false) return -1;
if( index >= totNumBlock )return -1;
fseek(inFile, 0L, SEEK_SET);
if( verbose ) printf("Block index: %u, File Pos: %u byte\n", index, blockPos[index]);
fseek(inFile, blockPos[index], SEEK_CUR);
filePos = blockPos[index];
numBlock = index;
return ReadNextBlock();
}
inline int SolReader::ReadNextBlock(bool fastRead, bool debug){
if( inFile == NULL ) return -1;
if( feof(inFile) ) return -1;
if( filePos >= inFileSize) return -1;
dummy = fread(&blockStartIdentifier, 2, 1, inFile);
if( (blockStartIdentifier & 0xAA00) != 0xAA00 ) {
printf("header fail.\n");
return -2 ;
}
if( ( blockStartIdentifier & 0xF ) == DataFormat::Raw ){
hit->SetDataType(DataFormat::Raw, ((blockStartIdentifier >> 1) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD);
}
hit->dataType = blockStartIdentifier & 0xF;
hit->DPPType = ((blockStartIdentifier >> 4) & 0xF) == 0 ? DPPType::PHA : DPPType::PSD;
if( debug ) {
printf(" DPP Type : %s \n", hit->DPPType.c_str());
printf(" Data Type : %d \n", hit->dataType);
}
if( hit->dataType == DataFormat::ALL){
if( !fastRead ){
dummy = fread(&hit->channel, 1, 1, inFile);
dummy = fread(&hit->energy, 2, 1, inFile);
if( hit->DPPType == DPPType::PSD ) dummy = fread(&hit->energy_short, 2, 1, inFile);
dummy = fread(&hit->timestamp, 6, 1, inFile);
dummy = fread(&hit->fine_timestamp, 2, 1, inFile);
dummy = fread(&hit->flags_high_priority, 1, 1, inFile);
dummy = fread(&hit->flags_low_priority, 2, 1, inFile);
dummy = fread(&hit->downSampling, 1, 1, inFile);
dummy = fread(&hit->board_fail, 1, 1, inFile);
dummy = fread(&hit->flush, 1, 1, inFile);
dummy = fread(&hit->trigger_threashold, 2, 1, inFile);
dummy = fread(&hit->event_size, 8, 1, inFile);
dummy = fread(&hit->aggCounter, 4, 1, inFile);
}else{
fseek(inFile, hit->DPPType == DPPType::PHA ? 31 : 33, SEEK_CUR);
}
dummy = fread(&hit->traceLenght, 8, 1, inFile);
if( !fastRead ){
dummy = fread(hit->analog_probes_type, 2, 1, inFile);
dummy = fread(hit->digital_probes_type, 4, 1, inFile);
dummy = fread(hit->analog_probes[0], hit->traceLenght*4, 1, inFile);
dummy = fread(hit->analog_probes[1], hit->traceLenght*4, 1, inFile);
dummy = fread(hit->digital_probes[0], hit->traceLenght, 1, inFile);
dummy = fread(hit->digital_probes[1], hit->traceLenght, 1, inFile);
dummy = fread(hit->digital_probes[2], hit->traceLenght, 1, inFile);
dummy = fread(hit->digital_probes[3], hit->traceLenght, 1, inFile);
}else{
dummy = fseek(inFile, 6 + hit->traceLenght*(12), SEEK_CUR);
}
}else if( hit->dataType == DataFormat::OneTrace){
if( !fastRead ){
dummy = fread(&hit->channel, 1, 1, inFile);
dummy = fread(&hit->energy, 2, 1, inFile);
if( hit->DPPType == DPPType::PSD ) dummy = fread(&hit->energy_short, 2, 1, inFile);
dummy = fread(&hit->timestamp, 6, 1, inFile);
dummy = fread(&hit->fine_timestamp, 2, 1, inFile);
dummy = fread(&hit->flags_high_priority, 1, 1, inFile);
dummy = fread(&hit->flags_low_priority, 2, 1, inFile);
}else{
fseek(inFile, hit->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR);
}
dummy = fread(&hit->traceLenght, 8, 1, inFile);
if( !fastRead ){
dummy = fread(&hit->analog_probes_type[0], 1, 1, inFile);
dummy = fread(hit->analog_probes[0], hit->traceLenght*4, 1, inFile);
}else{
fseek(inFile, 1 + hit->traceLenght*4, SEEK_CUR);
}
}else if( hit->dataType == DataFormat::NoTrace){
if( !fastRead ){
dummy = fread(&hit->channel, 1, 1, inFile);
dummy = fread(&hit->energy, 2, 1, inFile);
if( hit->DPPType == DPPType::PSD ) dummy = fread(&hit->energy_short, 2, 1, inFile);
dummy = fread(&hit->timestamp, 6, 1, inFile);
dummy = fread(&hit->fine_timestamp, 2, 1, inFile);
dummy = fread(&hit->flags_high_priority, 1, 1, inFile);
dummy = fread(&hit->flags_low_priority, 2, 1, inFile);
}else{
fseek(inFile, hit->DPPType == DPPType::PHA ? 14 : 16, SEEK_CUR);
}
}else if( hit->dataType == DataFormat::MiniWithFineTime){
if( !fastRead ){
dummy = fread(&hit->channel, 1, 1, inFile);
dummy = fread(&hit->energy, 2, 1, inFile);
if( hit->DPPType == DPPType::PSD ) dummy = fread(&hit->energy_short, 2, 1, inFile);
dummy = fread(&hit->timestamp, 6, 1, inFile);
dummy = fread(&hit->fine_timestamp, 2, 1, inFile);
}else{
fseek(inFile, hit->DPPType == DPPType::PHA ? 11 : 13, SEEK_CUR);
}
}else if( hit->dataType == DataFormat::Minimum){
if( !fastRead ){
dummy = fread(&hit->channel, 1, 1, inFile);
dummy = fread(&hit->energy, 2, 1, inFile);
if( hit->DPPType == DPPType::PSD ) dummy = fread(&hit->energy_short, 2, 1, inFile);
dummy = fread(&hit->timestamp, 6, 1, inFile);
}else{
fseek(inFile, hit->DPPType == DPPType::PHA ? 9 : 11, SEEK_CUR);
}
}else if( hit->dataType == DataFormat::Raw){
dummy = fread(&hit->dataSize, 8, 1, inFile);
if( !fastRead ){
dummy = fread(hit->data, hit->dataSize, 1, inFile);
}else{
fseek(inFile, hit->dataSize, SEEK_CUR);
}
}
numBlock ++;
filePos = ftell(inFile);
if( debug ) {
hit->PrintAll();
printf(" file Pos : %u/%u\n", filePos, inFileSize);
}
return 0;
}
void SolReader::RewindFile(){
rewind(inFile);
filePos = 0;
numBlock = 0;
}
void SolReader::ScanNumBlock(){
if( inFile == NULL ) return;
if( feof(inFile) ) return;
numBlock = 0;
blockPos.clear();
blockPos.push_back(0);
while( ReadNextBlock(1) == 0){
blockPos.push_back(filePos);
printf("%u, %.2f%% %u/%u\n\033[A\r", numBlock, filePos*100./inFileSize, filePos, inFileSize);
}
totNumBlock = numBlock;
numBlock = 0;
isScanned = true;
printf("\nScan complete: number of data Block : %u\n", totNumBlock);
rewind(inFile);
filePos = 0;
//for( int i = 0; i < totNumBlock; i++){
// printf("%7d | %u \n", i, blockPos[i]);
//}
}
#endif

44
Aux/netTraffic.py Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/env python3
import psutil
import time
from datetime import datetime
def calculate_speed(interface, interval=1):
# Get the initial number of bytes sent and received
initial_bytes_sent = psutil.net_io_counters(pernic=True)[interface].bytes_sent
initial_bytes_recv = psutil.net_io_counters(pernic=True)[interface].bytes_recv
# Wait for the specified interval
time.sleep(interval)
# Get the number of bytes sent and received after the interval
final_bytes_sent = psutil.net_io_counters(pernic=True)[interface].bytes_sent
final_bytes_recv = psutil.net_io_counters(pernic=True)[interface].bytes_recv
# Calculate the data speed in bytes per second
sent_speed = final_bytes_sent - initial_bytes_sent
recv_speed = final_bytes_recv - initial_bytes_recv
return sent_speed, recv_speed
# Define the network interface
interface = 'enp6s0f0'
print("Monitoring data speed for interface: {}".format(interface))
# Continuous monitoring loop
while True:
# Calculate the data speed for the interface
sent_speed, recv_speed = calculate_speed(interface, 6)
# Convert bytes
sent_speed_mbps = sent_speed / 1024.
recv_speed_mbps = recv_speed / 1024.
current_time = datetime.now().strftime("%H:%M:%S")
print("{}| Data speed (sent): {:10f} KiB/s (received): {:10f} KiB/s".format(current_time, sent_speed_mbps,recv_speed_mbps))
# Wait for one second before the next iteration
#time.sleep(1)

103
Aux/script.C Normal file
View File

@ -0,0 +1,103 @@
#include "SolReader.h"
#include "TH1.h"
#include "TMath.h"
#include "TH2.h"
#include "TStyle.h"
#include "TCanvas.h"
#include "TGraph.h"
void script(std::string fileName){
SolReader * reader = new SolReader(fileName);
Hit * hit = reader->hit;
printf("----------file size: %u Byte\n", reader->GetFileSize());
reader->ScanNumBlock();
if( reader->GetTotalNumBlock() == 0 ) return;
unsigned long startTime, endTime;
reader->ReadBlock(0);
startTime = hit->timestamp;
reader->ReadBlock(reader->GetTotalNumBlock() - 1);
endTime = hit->timestamp;
double duration = double(endTime - startTime)*8./1e9;
printf("============== %lu ns = %.4f sec.\n", (endTime - startTime)*8, duration);
printf(" avarge rate : %f Hz\n", reader->GetTotalNumBlock()/duration);
reader->RewindFile();
TH1F * hid = new TH1F("hid", "Ch-ID", 64, 0, 64);
TH1F * h1 = new TH1F("h1", "Rate [Hz]; time [s] ; Hz", ceil(duration)+2, startTime*8/1e9 - 1 , ceil(endTime*8/1e9) + 1);
TH2F * h2 = new TH2F("h2", "Time vs Entry ; time [s] ; Entry", 1000, startTime*8/1e9, endTime*8/1e9 + 1, 1000, 0, reader->GetTotalNumBlock());
TGraph * g1 = new TGraph();
TGraph * g2 = new TGraph(); g2->SetLineColor(2);
TGraph * ga = new TGraph(); ga->SetLineColor(4);
TGraph * gb = new TGraph(); gb->SetLineColor(5);
TGraph * gc = new TGraph(); gc->SetLineColor(6);
TGraph * gd = new TGraph(); gd->SetLineColor(7);
uint64_t tOld = startTime;
for( int i = 0; i < reader->GetTotalNumBlock() ; i++){
//for( int i = 0; i < 8 ; i++){
reader->ReadNextBlock();
if( i < 8 ){
printf("########################## nBlock : %u, %u/%u\n", reader->GetNumBlock(),
reader->GetFilePos(),
reader->GetFileSize());
hit->PrintAll();
//hit->PrintAllTrace();
}
hid->Fill(hit->channel);
if( hit->channel == 0 ) h1->Fill(hit->timestamp*8/1e9);
h2->Fill(hit->timestamp*8/1e9, i);
if( i == 0){
for( int i = 0; i < hit->traceLenght; i++){
g1->AddPoint(i*8, hit->analog_probes[0][i]);
g2->AddPoint(i*8, hit->analog_probes[1][i]);
ga->AddPoint(i*8, 10000+5000*hit->digital_probes[0][i]);
gb->AddPoint(i*8, 20000+5000*hit->digital_probes[1][i]);
gc->AddPoint(i*8, 30000+5000*hit->digital_probes[2][i]);
gd->AddPoint(i*8, 40000+5000*hit->digital_probes[3][i]);
}
}
}
gStyle->SetOptStat("neiou");
TCanvas * canvas = new TCanvas("c1", "c1", 1200, 1200);
canvas->Divide(2,2);
canvas->cd(1); hid->Draw();
canvas->cd(2); h1->SetMinimum(0); h1->Draw();
canvas->cd(3); h2->Draw();
canvas->cd(4); g1->Draw("APl");
g1->GetYaxis()->SetRangeUser(0, 80000);
g2->Draw("same");
ga->Draw("same");
gb->Draw("same");
gc->Draw("same");
gd->Draw("same");
//printf("reader traceLength : %lu \n", hit->traceLenght);
/*
for( int i = 0; i < hit->traceLenght; i++){
printf("%4d| %d\n", i, hit->analog_probes[0][i]);
}
*/
hit = NULL;
delete reader;
}

159
Aux/test.cpp Normal file
View File

@ -0,0 +1,159 @@
#include <cstdlib>
#include <string>
#include <vector>
#include <unistd.h>
#include <time.h> // time in nano-sec
#include <iostream>
#include <thread>
#include <mutex>
#include "../ClassDigitizer2Gen.h"
#include "../ClassInfluxDB.h"
#define maxRead 400
ß
std::mutex digiMTX;
Digitizer2Gen * digi = new Digitizer2Gen();
InfluxDB * influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/", false);
unsigned int readCount = 0;
bool ThreadStop = false;
timespec ta, tb;
static void ReadDataLoop(){
clock_gettime(CLOCK_REALTIME, &ta);
//while(digi->IsAcqOn() && readCount < maxRead){
while(!ThreadStop){
digiMTX.lock();
int ret = digi->ReadData();
digiMTX.unlock();
if( ret == CAEN_FELib_Success){
digi->SaveDataToFile();
}else if(ret == CAEN_FELib_Stop){
digi->ErrorMsg("No more data");
break;
}else{
//digi->ErrorMsg("ReadDataLoop()");
}
//if( readCount % 1000 == 0 ) {
// clock_gettime(CLOCK_REALTIME, &tb);
// double duration = tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9;
// printf("%4d, duration : %10.0f, %6.1f\n", readCount, duration, 1e9/duration);
// ta = tb;
//}
//readCount++;
}
}
char cmdStr[100];
static void StatLoop(){
//while(digi->IsAcqOn() && readCount < maxRead){
while(digi->IsAcqOn()){
digiMTX.lock();
digi->ReadStat();
// for(int i = 0; i < 64; i++){
// digi->ReadValue( PHA::CH::SelfTrgRate, i, false);
// //influx->AddDataPoint("Rate,Bd=0,Ch=" + std::to_string(i) + " value=" + haha);
// }
// digi->ReadValue("/ch/4/par/ChRealtimeMonitor", true);
// digi->ReadValue("/ch/4/par/ChDeadtimeMonitor", true);
// digi->ReadValue("/ch/4/par/ChTriggerCnt", true);
// digi->ReadValue("/ch/4/par/ChSavedEventCnt", true);
// digi->ReadValue("/ch/4/par/ChWaveCnt", true);
digiMTX.unlock();
//influx->PrintDataPoints();
//influx->WriteData("testing");
//influx->ClearDataPointsBuffer();
digi->PrintStat();
usleep(1000*1000); // every 1000 msec
}
}
// #include <CAENDig2.h>
// int CAENDig2_GetLibVersion(char* version);
// void CAEN_test(){
// printf("##########################################\n");
// printf("\t CAEN firmware DPP-PHA testing \n");
// printf("##########################################\n");
// remove("haha_000.sol");
// char version[16];
// CAENDig2_GetLibVersion(version);
// puts(version);
// char haha[100];
// CAEN_FELib_GetLibInfo(haha, 100);
// puts(haha);
// CAEN_FELib_GetLibVersion(version);
// puts(version);
// }
int main(int argc, char* argv[]){
/*
const char * url = "dig2://192.168.0.100/";
//const char * url = "dig2://192.168.0.254/";
digi->OpenDigitizer(url);
//digi->Reset();
//digi->ReadAllSettings();
//digi->ProgramBoard();
//digi->WriteValue(PSD::CH::TriggerThreshold, "1000", -1);
digi->PrintChannelSettings(0);
digi->ReadValue(PHA::CH::ADCToVolts, 0, true);
digi->SetDataFormat(DataFormat::ALL);
digi->OpenOutFile("haha");
digi->StartACQ();
timespec t0, t1;
clock_gettime(CLOCK_REALTIME, &t0);
std::thread th1 (ReadDataLoop);
std::thread th2 (StatLoop);
char c;
printf("Press q for stop.");
do{
c = getchar();
}while( c != 'q');
ThreadStop = true;
digiMTX.lock();
digi->StopACQ();
digiMTX.unlock();
th1.join();
th2.join();
clock_gettime(CLOCK_REALTIME, &t1);
printf("t1-t0 : %.0f ns = %.2f sec\n",
t1.tv_nsec-t0.tv_nsec + t1.tv_sec*1e+9 - t0.tv_sec*1e+9,
(t1.tv_nsec-t0.tv_nsec + t1.tv_sec*1e+9 - t0.tv_sec*1e+9)*1.0/1e9);
digi->CloseOutFile();
digi->CloseDigitizer();
delete digi;
*/
delete influx;
}

File diff suppressed because it is too large Load Diff

View File

@ -5,13 +5,14 @@
#include <CAEN_FELib.h> #include <CAEN_FELib.h>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include <map> #include <unordered_map>
#include "Event.h" #include "Hit.h"
#define MaxOutFileSize 2*1024*1024*1024 //2GB #define MaxOutFileSize 2*1024*1024*1024 //2GB
//#define MaxOutFileSize 20*1024*1024 //20MB //#define MaxOutFileSize 20*1024*1024 //20MB
#define MaxNumberOfChannel 64 #define MaxNumberOfChannel 64
#define MaxNumberOfGroup 16
#include "DigiParameters.h" #include "DigiParameters.h"
@ -32,10 +33,11 @@ class Digitizer2Gen {
char retValue[256]; char retValue[256];
unsigned short serialNumber; unsigned short serialNumber;
std::string FPGAType; unsigned int CupVer;
unsigned int FPGAVer; std::string FPGAType; // look the DigitiParameter.h::PHA::DIG::FirwareType, DPP_PHA, DPP_ZLE, DPP_PSD, DPP_DAW, DPP_OPEN, and Scope
unsigned int FPGAVer; // for checking copy setting
unsigned short nChannels; unsigned short nChannels;
unsigned short ch2ns; unsigned short tick2ns;
std::string ModelName; std::string ModelName;
void Initialization(); void Initialization();
@ -60,53 +62,56 @@ class Digitizer2Gen {
std::string settingFileName; std::string settingFileName;
std::vector<Reg> boardSettings; std::vector<Reg> boardSettings;
std::vector<Reg> chSettings[MaxNumberOfChannel]; std::vector<Reg> chSettings[MaxNumberOfChannel];
std::vector<Reg> LVDSSettings[4];
Reg VGASetting[4]; Reg VGASetting[4];
Reg InputDelay[16];
std::map<std::string, int> boardMap; std::unordered_map<std::string, int> boardMap;
std::map<std::string, int> chMap; std::unordered_map<std::string, int> LVDSMap;
std::unordered_map<std::string, int> chMap;
public: public:
Digitizer2Gen(); Digitizer2Gen();
~Digitizer2Gen(); ~Digitizer2Gen();
unsigned short GetSerialNumber() const{return serialNumber;} unsigned short GetSerialNumber() const {return serialNumber;}
std::string GetFPGAType() const {return FPGAType;} std::string GetFPGAType() const {return FPGAType;}
std::string GetModelName() const {return ModelName;} std::string GetModelName() const {return ModelName;}
unsigned int GetFPGAVersion() const {return FPGAVer;} unsigned int GetFPGAVersion() const {return FPGAVer;}
unsigned int GetCupVer() const {return CupVer;}
void SetDummy(unsigned short sn); void SetDummy(unsigned short sn);
bool IsDummy() const {return isDummy;} bool IsDummy() const {return isDummy;}
bool IsConnected() const {return isConnected;}
int OpenDigitizer(const char * url); int OpenDigitizer(const char * url);
bool IsConnected() const {return isConnected;} int CloseDigitizer();
int CloseDigitizer();
int GetRet() const {return ret;}; int GetRet() const {return ret;};
int FindIndex(const Reg para); // get index from DIGIPARA
std::string ReadValue(const char * parameter, bool verbose = false);
std::string ReadValue(const Reg para, int ch_index = -1, bool verbose = false); // read digitizer and save to memory
bool WriteValue(const char * parameter, std::string value);
bool WriteValue(const Reg para, std::string value, int ch_index = -1); // write digituzer and save to memory
void SendCommand(const char * parameter);
void SendCommand(std::string shortPara);
uint64_t GetHandle(const char * parameter); uint64_t GetHandle(const char * parameter);
uint64_t GetParentHandle(uint64_t handle); uint64_t GetParentHandle(uint64_t handle);
std::string GetPath(uint64_t handle); std::string GetPath(uint64_t handle);
std::string ReadValue(const char * parameter, bool verbose = false);
std::string ReadValue(const Reg para, int ch_index = -1, bool verbose = false); // read digitizer and save to memory
bool WriteValue(const char * parameter, std::string value, bool verbose = true);
bool WriteValue(const Reg para, std::string value, int ch_index = -1); // write digituzer and save to memory
void SendCommand(const char * parameter);
void SendCommand(std::string shortPara);
int FindIndex(const Reg para); // get index from DIGIPARA
std::string GetSettingValueFromMemory(const Reg para, unsigned int ch_index = 0); // read from memory
std::string ErrorMsg(const char * funcName); std::string ErrorMsg(const char * funcName);
void StartACQ(); void StartACQ();
void StopACQ(); void StopACQ();
bool IsAcqOn() const {return acqON;} bool IsAcqOn() const {return acqON;}
void SetPHADataFormat(unsigned short dataFormat); // 0 = all data, void SetDataFormat(unsigned short dataFormat); // dataFormat = namespace DataFormat
// 1 = analog trace-0 only + flags
// 2 = no trace, only ch, energy, timestamp, fine_timestamp + flags
// 3 = only ch, energy, timestamp, minimum
// 15 = raw data
int ReadData(); int ReadData();
int ReadStat(); // digitizer update it every 500 msec int ReadStat(); // digitizer update it every 500 msec
void PrintStat(); void PrintStat();
@ -114,14 +119,18 @@ class Digitizer2Gen {
uint64_t GetRealTime(int ch) const {return realTime[ch];} uint64_t GetRealTime(int ch) const {return realTime[ch];}
void Reset(); void Reset();
void ProgramPHA(bool testPulse = false); void ProgramBoard();
void ProgramChannels(bool testPulse = false);
void PrintBoardSettings();
void PrintChannelSettings(unsigned short ch);
unsigned short GetNChannels() const {return nChannels;} unsigned short GetNChannels() const {return nChannels;}
unsigned short GetCh2ns() const {return ch2ns;} unsigned short GetTick2ns() const {return tick2ns;}
uint64_t GetHandle() const {return handle;} uint64_t GetHandle() const {return handle;}
Event *evt; // should be evt[MaxNumber], when full or stopACQ, save into file Hit *hit; // should be hit[MaxNumber], when full or stopACQ, save into file
void OpenOutFile(std::string fileName, const char * mode = "w"); void OpenOutFile(std::string fileName, const char * mode = "wb"); //overwrite binary
void CloseOutFile(); void CloseOutFile();
void SaveDataToFile(); void SaveDataToFile();
unsigned int GetFileSize() const {return outFileSize;} unsigned int GetFileSize() const {return outFileSize;}
@ -130,11 +139,10 @@ class Digitizer2Gen {
std::string GetSettingFileName() const {return settingFileName;} std::string GetSettingFileName() const {return settingFileName;}
void SetSettingFileName(std::string fileName) {settingFileName = fileName;} void SetSettingFileName(std::string fileName) {settingFileName = fileName;}
void ReadAllSettings(); // read settings from digitier and save to memory void ReadAllSettings(); // read settings from digitier and save to memory
int SaveSettingsToFile(const char * saveFileName = NULL); //Save settings from memory to text file int SaveSettingsToFile(const char * saveFileName = NULL, bool setReadOnly = false); //Save settings from memory to text file
int ReadAndSaveSettingsToFile(const char * saveFileName = NULL); // ReadAllSettings + text file int ReadAndSaveSettingsToFile(const char * saveFileName = NULL); // ReadAllSettings + text file
bool LoadSettingsFromFile(const char * loadFileName = NULL); // Load settings, write to digitizer and save to memory bool LoadSettingsFromFile(const char * loadFileName = NULL); // Load settings, write to digitizer and save to memory
std::string GetSettingValue(const Reg para, unsigned int ch_index = 0); // read from memory
}; };
#endif #endif

267
ClassInfluxDB.cpp Normal file
View File

@ -0,0 +1,267 @@
#include "ClassInfluxDB.h"
#include <regex>
InfluxDB::InfluxDB(){
curl = curl_easy_init();
databaseIP = "";
respondCode = 0;
dataPoints = "";
headers = nullptr;
influxVersionStr = "";
influxVersion = -1;
token = "";
connectionOK = false;
}
InfluxDB::InfluxDB(std::string url, bool verbose){
curl = curl_easy_init();
if( verbose) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
SetURL(url);
respondCode = 0;
dataPoints = "";
headers = nullptr;
influxVersionStr = "";
influxVersion = -1;
token = "";
connectionOK = false;
}
InfluxDB::~InfluxDB(){
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
void InfluxDB::SetURL(std::string url){
// check the last char of url is "/"
if( url.back() != '/') {
this->databaseIP = url + "/";
}else{
this->databaseIP = url;
}
}
void InfluxDB::SetToken(std::string token){
this->token = token;
headers = curl_slist_append(headers, "Accept: application/csv");
if( !token.empty() ) headers = curl_slist_append(headers, ("Authorization: Token " + token).c_str());
}
bool InfluxDB::TestingConnection(bool debug){
CheckInfluxVersion(debug);
if( respond != CURLE_OK ) return false;
connectionOK = true;
return true;
}
std::string InfluxDB::CheckInfluxVersion(bool debug){
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "ping").c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL);
curl_easy_setopt(curl, CURLOPT_HEADER, 1);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallBack);
std::string respondStr;
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &respondStr);
Execute();
if( respond != CURLE_OK) return "CURL Error.";
if( debug) printf("%s\n", respondStr.c_str());
//Find Version from readBuffer
std::regex pattern(R"(X-Influxdb-Version: (.*))");
std::smatch match;
if (regex_search(respondStr, match, pattern)) {
influxVersionStr = match[1];
size_t dotPosition = influxVersionStr.find('.');
if( dotPosition != std::string::npos){
influxVersion = atoi(influxVersionStr.substr(dotPosition-1, 1).c_str());
}
}
// printf("Influx Version : %s | %u\n", influxVersionStr.c_str(), influxVersion);
return respondStr;
}
std::string InfluxDB::CheckDatabases(){
if( ! connectionOK ) return "no connection. try TestConnection() again.";
if( influxVersion == 2 && token.empty() ) return "token no provided, abort.";
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_HEADER, 0);
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "query").c_str());
std::string postFields="q=Show databases";
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(postFields.length()));
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postFields.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallBack);
std::string respondStr;
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &respondStr);
Execute();
//printf("|%s|\n", respondStr.c_str());
if( respond != CURLE_OK) return "CURL Error.";
databaseList.clear();
// Split the input string into lines
std::istringstream iss(respondStr);
std::vector<std::string> lines;
std::string line;
// printf("==== InfluxDB::CheckDatabases()\n");
while (std::getline(iss, line)) {
// printf("%s\n", line.c_str());
lines.push_back(line);
}
// Extract the third column from each line and store it in a vector
std::vector<std::string> thirdColumn;
for (const auto& l : lines) {
std::istringstream lineIss(l);
std::string token;
for (int i = 0; std::getline(lineIss, token, ','); ++i) {
if (i == 2) { // Third column
databaseList.push_back(token);
break;
}
}
}
// {//============ when output is JSON
// size_t pos = readBuffer.find("values");
// if( pos > 0 ){
// std::string kaka = readBuffer.substr(pos+8);
// pos = kaka.find("}");
// kaka = kaka.substr(0, pos);
// int len = kaka.length();
// bool startFlag = false;
// std::string lala;
// char yaya = '"';
// for( int i = 0; i < len; i++){
// if( startFlag == false && kaka[i] == yaya ) {
// startFlag = true;
// lala = "";
// continue;
// }
// if( startFlag && kaka[i] == yaya ){
// startFlag = false;
// databaseList.push_back(lala);
// continue;
// }
// if( startFlag ) lala += kaka[i];
// }
// }
// }
return respondStr;
}
void InfluxDB::PrintDataBaseList(){
for( size_t i = 0; i < databaseList.size(); i++){
printf("%2ld| %s\n", i, databaseList[i].c_str());
}
}
std::string InfluxDB::Query(std::string databaseName, std::string influxQL_query){
if( ! connectionOK ) return "no connection. try TestConnection() again.";
if( influxVersion == 2 && token.empty() ) return "token no provided, abort.";
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_HEADER, 0);
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "query?db=" + databaseName).c_str());
std::string postFields = "q=" + influxQL_query;
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(postFields.length()));
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postFields.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallBack);
std::string respondStr;
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &respondStr);
Execute();
//printf("|%s|\n", readBuffer.c_str());
return respondStr;
}
void InfluxDB::CreateDatabase(std::string databaseName){
if( ! connectionOK ) return ;
if( influxVersion == 2 && token.empty() ) return;
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "query").c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_HEADER, 0);
std::string postFields = "q=CREATE DATABASE " + databaseName;
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(postFields.length()));
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postFields.c_str());
Execute();
}
void InfluxDB::AddDataPoint(std::string fullString){
// printf(" InfluxDB::%s |%s| \n", __func__, fullString.c_str());
dataPoints += fullString + "\n";
}
void InfluxDB::ClearDataPointsBuffer(){
// printf(" InfluxDB::%s \n", __func__);
dataPoints = "";
}
void InfluxDB::PrintDataPoints(){
// printf(" InfluxDB::%s \n", __func__);
printf("%s\n", dataPoints.c_str());
}
void InfluxDB::WriteData(std::string databaseName){
if( ! connectionOK ) return ;
if( influxVersion == 2 && token.empty() ) return;
// printf(" InfluxDB::%s \n", __func__);
if( dataPoints.length() == 0 ) return;
//printf("|%s|\n", (databaseIP + "write?db=" + databaseName).c_str());
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "write?db=" + databaseName).c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_HEADER, 0);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(dataPoints.length()));
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dataPoints.c_str());
Execute();
}
void InfluxDB::Execute(){
// printf(" InfluxDB::%s \n", __func__);
try{
respond = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &respondCode);
//printf("==== respond %d (OK = %d)\n", respond, CURLE_OK);
if( respond != CURLE_OK ) printf("############# InfluxDB::Execute fail | %ld\n", respondCode);
} catch (std::exception& e){ // in case of unexpected error
printf("%s\n", e.what());
respond = CURLE_SEND_ERROR;
}
}
size_t InfluxDB::WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp){
// printf(" InfluxDB::%s \n", __func__);
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}

View File

@ -10,32 +10,45 @@
class InfluxDB{ class InfluxDB{
private: private:
bool isURLValid;
CURL * curl; CURL * curl;
CURLcode respond; CURLcode respond;
long respondCode; long respondCode;
std::string databaseIP; std::string databaseIP;
std::string dataPoints; std::string dataPoints;
std::string token;
struct curl_slist * headers;
std::vector<std::string> databaseList; std::vector<std::string> databaseList;
unsigned short influxVersion;
std::string influxVersionStr;
bool connectionOK;
static size_t WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp); static size_t WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp);
void Execute(); void Execute();
public: public:
/// url = https://fsunuc.physics.fsu.edu/InfluxDB/
InfluxDB(std::string url, bool verbose = false); InfluxDB(std::string url, bool verbose = false);
InfluxDB();
~InfluxDB(); ~InfluxDB();
void SetURL(std::string url); void SetURL(std::string url);
bool TestingConnection(); void SetToken(std::string token);
bool IsURLValid() const {return isURLValid;} bool TestingConnection(bool debug = false);
bool IsConnectionOK() const {return connectionOK;}
/// Query unsigned short GetVersionNo() const {return influxVersion;}
std::string GetVersionString() const {return influxVersionStr;}
/// Query, query will be in CSV format
std::string CheckInfluxVersion(bool debug = false);
std::string CheckDatabases(); /// this save the list of database into databaseList std::string CheckDatabases(); /// this save the list of database into databaseList
void PrintDataBaseList();
std::string Query(std::string databaseName, std::string query); std::string Query(std::string databaseName, std::string query);
/// the CheckDatabases() function must be called before /// the CheckDatabases() function must be called before

105
CustomThreads.h Normal file
View File

@ -0,0 +1,105 @@
#ifndef CUSTOMTHREADS_H
#define CUSTOMTHREADS_H
#include <QThread>
#include <QMutex>
#include "macro.h"
#include "ClassDigitizer2Gen.h"
static QMutex digiMTX[MaxNumberOfDigitizer];
//^#===================================================== ReadData Thread
class ReadDataThread : public QThread {
Q_OBJECT
public:
ReadDataThread(Digitizer2Gen * dig, int digiID, QObject * parent = 0) : QThread(parent){
this->digi = dig;
this->ID = digiID;
isSaveData = false;
stop = false;
// canSendMsg = true;
}
// void SuppressFileSizeMsg() {canSendMsg = false;}
void Stop(){ this->stop = true;}
void SetSaveData(bool onOff) {this->isSaveData = onOff;}
void run(){
// canSendMsg = true;
stop = false;
// clock_gettime(CLOCK_REALTIME, &ta);
emit sendMsg("Digi-" + QString::number(digi->GetSerialNumber()) + " ReadDataThread started.");
while(!stop){
digiMTX[ID].lock();
int ret = digi->ReadData();
digiMTX[ID].unlock();
if( ret == CAEN_FELib_Success){
if( isSaveData) digi->SaveDataToFile();
}else if(ret == CAEN_FELib_Stop){
digi->ErrorMsg("ReadData Thread No more data");
//emit endOfLastData();
break;
}else{
//digi->ErrorMsg("ReadDataLoop()");
digi->hit->ClearTrace();
}
//
// if( isSaveData && canSendMsg ){
// clock_gettime(CLOCK_REALTIME, &tb);
// if( tb.tv_sec - ta.tv_sec > 2 ) {
// emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetTotalFilesSize()/1024./1024.) + " MB");
// //emit checkFileSize();
// //double duration = tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9;
// //printf("%4d, duration : %10.0f, %6.1f\n", readCount, duration, 1e9/duration);
// ta = tb;
// }
// }
}
emit sendMsg("Digi-" + QString::number(digi->GetSerialNumber()) + " ReadDataThread stopped.");
}
signals:
void sendMsg(const QString &msg);
//void endOfLastData();
//void checkFileSize();
private:
Digitizer2Gen * digi;
int ID;
timespec ta, tb;
// bool isSaveData, stop, canSendMsg;
bool isSaveData, stop;
};
//^#======================================================= Timing Thread, for some action need to be done periodically
class TimingThread : public QThread {
Q_OBJECT
public:
TimingThread(QObject * parent = 0 ) : QThread(parent){
waitTime = 20; // 20 x 100 milisec
stop = false;
}
void Stop() { this->stop = true;}
float GetWaitTimeinSec() const {return waitTime/10.;}
void SetWaitTimeSec(float sec) {waitTime = sec * 10;}
void run(){
unsigned int count = 0;
stop = false;
do{
usleep(100000); // sleep for 100 ms
count ++;
if( count % waitTime == 0){
emit TimeUp();
}
}while(!stop);
}
signals:
void TimeUp();
private:
bool stop;
unsigned int waitTime;
};
#endif

View File

@ -38,6 +38,9 @@ class RSpinBox : public QDoubleSpinBox{
setToolTipDuration(-1); setToolTipDuration(-1);
} }
void SetStyleNormal() { setStyleSheet(""); }
void SetStyleGreen() { setStyleSheet("color:green"); }
signals: signals:
void returnPressed(); void returnPressed();
protected: protected:

View File

@ -5,8 +5,10 @@
#include <string> #include <string>
#include <vector> #include <vector>
enum ANSTYPE {INTEGER, FLOAT, LIST, STR, BYTE, BINARY, NONE}; #define MIN_VERSION_GROUP 2022122300
enum TYPE {CH, DIG, LVDS, VGA};
enum ANSTYPE {INTEGER, FLOAT, COMBOX, STR, BYTE, BINARY, NONE};
enum TYPE {CH, DIG, LVDS, VGA, GROUP};
enum RW { ReadOnly, WriteOnly, ReadWrite}; enum RW { ReadOnly, WriteOnly, ReadWrite};
//^==================== Register Class //^==================== Register Class
@ -28,14 +30,14 @@ class Reg {
type = TYPE::CH; type = TYPE::CH;
isCmd = false; isCmd = false;
value = ""; value = "";
ansType = ANSTYPE::LIST; ansType = ANSTYPE::COMBOX;
answerUnit = ""; answerUnit = "";
answer.clear(); answer.clear();
} }
Reg(std::string para, RW readwrite, Reg(std::string para, RW readwrite,
TYPE type = TYPE::CH, TYPE type = TYPE::CH,
std::vector<std::pair<std::string,std::string>> answer = {}, std::vector<std::pair<std::string,std::string>> answer = {}, // first = value, second = display
ANSTYPE ansType = ANSTYPE::LIST, ANSTYPE ansType = ANSTYPE::COMBOX,
std::string ansUnit = "", std::string ansUnit = "",
bool isCmd = false){ bool isCmd = false){
this->name = para; this->name = para;
@ -49,7 +51,7 @@ class Reg {
} }
~Reg(){}; ~Reg(){};
void SetValue(std::string sv) { this->value = sv;} void SetValue(std::string sv) { value = sv;}
std::string GetValue() const { return value;} std::string GetValue() const { return value;}
RW ReadWrite() const {return readWrite;} RW ReadWrite() const {return readWrite;}
TYPE GetType() const {return type;} TYPE GetType() const {return type;}
@ -58,7 +60,7 @@ class Reg {
std::vector<std::pair<std::string,std::string>> GetAnswers() const {return answer;} std::vector<std::pair<std::string,std::string>> GetAnswers() const {return answer;}
std::string GetPara() const {return name;} std::string GetPara() const {return name;}
std::string GetFullPara(int ch_index = -1) const { std::string GetFullPara(int ch_index = -1, int nChannals = MaxNumberOfChannel) const {
switch (type){ switch (type){
case TYPE::DIG:{ case TYPE::DIG:{
if( isCmd){ if( isCmd){
@ -70,10 +72,10 @@ class Reg {
case TYPE::CH:{ case TYPE::CH:{
std::string haha = "/par/"; std::string haha = "/par/";
if( isCmd ){ if( isCmd ){
haha = "/cmd/"; haha = "/cmd/"; // for SendChSWTrigger, not in GUI
} }
if( ch_index == -1 ){ if( ch_index == -1 ){
return "/ch/0..63" + haha + name; return "/ch/0.." + std::to_string(nChannals-1) + haha + name;
}else{ }else{
return "/ch/" + std::to_string(ch_index) + haha + name; return "/ch/" + std::to_string(ch_index) + haha + name;
} }
@ -92,12 +94,19 @@ class Reg {
return "/vga/" + std::to_string(ch_index) + "/par/"+ name; return "/vga/" + std::to_string(ch_index) + "/par/"+ name;
} }
}; break; }; break;
case TYPE::GROUP:{
if( ch_index == -1 ){
return "/group/0..15/par/" + name;
}else{
return "/group/" + std::to_string(ch_index) + "/par/" + name;
}
break;
}
default: default:
return "invalid"; break; return "invalid"; break;
} }
} }
operator std::string () const {return name;} // this allow Reg kaka("XYZ", true); std::string haha = kaka; operator std::string () const {return name;} // this allow Reg kaka("XYZ", true); std::string haha = kaka;
}; };
@ -152,6 +161,7 @@ namespace PHA{
const Reg TempSensADC7 ("TempSensADC7", RW::ReadOnly, TYPE::DIG, {}, ANSTYPE::INTEGER, "C"); const Reg TempSensADC7 ("TempSensADC7", RW::ReadOnly, TYPE::DIG, {}, ANSTYPE::INTEGER, "C");
const std::vector<Reg> TempSensADC = {TempSensADC0,TempSensADC1,TempSensADC2,TempSensADC3,TempSensADC4,TempSensADC5,TempSensADC6,TempSensADC7}; const std::vector<Reg> TempSensADC = {TempSensADC0,TempSensADC1,TempSensADC2,TempSensADC3,TempSensADC4,TempSensADC5,TempSensADC6,TempSensADC7};
const std::vector<Reg> TempSensOthers = {TempSensAirIn,TempSensAirOut,TempSensCore,TempSensFirstADC,TempSensLastADC,TempSensHottestADC};
const Reg TempSensDCDC ("TempSensDCDC", RW::ReadOnly, TYPE::DIG, {}, ANSTYPE::INTEGER, "C"); const Reg TempSensDCDC ("TempSensDCDC", RW::ReadOnly, TYPE::DIG, {}, ANSTYPE::INTEGER, "C");
const Reg VInSensDCDC ("VInSensDCDC", RW::ReadOnly, TYPE::DIG, {}, ANSTYPE::INTEGER, "V"); const Reg VInSensDCDC ("VInSensDCDC", RW::ReadOnly, TYPE::DIG, {}, ANSTYPE::INTEGER, "V");
@ -164,6 +174,10 @@ namespace PHA{
const Reg ErrorFlags ("ErrorFlags", RW::ReadOnly, TYPE::DIG, {}, ANSTYPE::BINARY, "byte"); const Reg ErrorFlags ("ErrorFlags", RW::ReadOnly, TYPE::DIG, {}, ANSTYPE::BINARY, "byte");
const Reg BoardReady ("BoardReady", RW::ReadOnly, TYPE::DIG, {{"True", "No Error"}, {"False", "Error"}}); const Reg BoardReady ("BoardReady", RW::ReadOnly, TYPE::DIG, {{"True", "No Error"}, {"False", "Error"}});
const Reg SPFLinkPresence ("SPFLinkPresence", RW::ReadOnly, TYPE::DIG, {{"True", "Inserted"}, {"False", "Disconnected"}});
const Reg SPFLinkActive ("SPFLinkActive", RW::ReadOnly, TYPE::DIG, {{"True", "Active"}, {"False", "Deactive"}});
const Reg SPFLinkProtocol ("SPFLinkProtocal", RW::ReadOnly, TYPE::DIG, {{"Eth1G", "1 GB/s"}, {"Eth10G", "10 GB/s"}, {"CONET2", "Conet2"}});
///============= read write ///============= read write
const Reg ClockSource ("ClockSource", RW::ReadWrite, TYPE::DIG, {{"Internal", "Internal Clock 62.5 MHz"}, const Reg ClockSource ("ClockSource", RW::ReadWrite, TYPE::DIG, {{"Internal", "Internal Clock 62.5 MHz"},
{"FPClkIn", "Front Panel Clock Input"}}); {"FPClkIn", "Front Panel Clock Input"}});
@ -177,7 +191,12 @@ namespace PHA{
{"SwTrg", "Software" }, {"SwTrg", "Software" },
{"GPIO", "GPIO" }, {"GPIO", "GPIO" },
{"TestPulse", "Test Pulse" }, {"TestPulse", "Test Pulse" },
{"LVDS", "LVDS"}}, ANSTYPE::STR); {"LVDS", "LVDS"},
{"ITLA", "ITL-A"},
{"ITLB", "ITL-B"},
{"ITLA_AND_ITLB", "ITL-A & ITL-B"},
{"ITLA_OR_ITLB", "ITL-A || ITL-B"},
{"UserTrg", "User custom Trigger"}}, ANSTYPE::STR);
const Reg BusyInSource ("BusyInSource", RW::ReadWrite, TYPE::DIG, {{"Disabled","Disabled"}, const Reg BusyInSource ("BusyInSource", RW::ReadWrite, TYPE::DIG, {{"Disabled","Disabled"},
{"SIN", "SIN"}, {"SIN", "SIN"},
@ -189,6 +208,11 @@ namespace PHA{
{"TRGIN", "TRG-IN"}, {"TRGIN", "TRG-IN"},
{"SwTrg", "Software Trigger"}, {"SwTrg", "Software Trigger"},
{"LVDS", "LVDS"}, {"LVDS", "LVDS"},
{"ITLA", "ITL-A"},
{"ITLB", "ITL-B"},
{"ITLA_AND_ITLB", "ITL-A & B"},
{"ITLA_OR_ITLB", "ITL-A || B"},
{"EncodedClkIn", "Encoded CLK-IN"},
{"Run", "Run Signal"}, {"Run", "Run Signal"},
{"RefClk", "Reference Clock"}, {"RefClk", "Reference Clock"},
{"TestPulse", "Test Pulse"}, {"TestPulse", "Test Pulse"},
@ -198,13 +222,19 @@ namespace PHA{
{"SyncIn", "SyncIn Signal"}, {"SyncIn", "SyncIn Signal"},
{"SIN", "S-IN Signal"}, {"SIN", "S-IN Signal"},
{"GPIO", "GPIO Signal"}, {"GPIO", "GPIO Signal"},
{"AccepTrg", "Acceped Trigger Signal"}, {"LBinClk", "GPIO Signal"},
{"AcceptTrg", "Acceped Trigger Signal"},
{"TrgClk", "Trigger Clock"}}); {"TrgClk", "Trigger Clock"}});
const Reg GPIOMode ("GPIOMode", RW::ReadWrite, TYPE::DIG, {{"Disabled", "Disabled"}, const Reg GPIOMode ("GPIOMode", RW::ReadWrite, TYPE::DIG, {{"Disabled", "Disabled"},
{"TRGIN", "TRG-IN"}, {"TRGIN", "TRG-IN"},
{"P0", "Back Plane"}, {"P0", "Back Plane"},
{"SIN", "S-IN Signal"}, {"SIN", "S-IN Signal"},
{"LVDS", "LVDS Trigger"}, {"LVDS", "LVDS Trigger"},
{"ITLA", "ITL-A"},
{"ITLB", "ITL-B"},
{"ITLA_AND_ITLB", "ITL-A & B"},
{"ITLA_OR_ITLB", "ITL-A || B"},
{"EncodedClkIn", "Encoded CLK-IN"},
{"SwTrg", "Software Trigger"}, {"SwTrg", "Software Trigger"},
{"Run", "Run Signal"}, {"Run", "Run Signal"},
{"RefClk", "Referece Clock"}, {"RefClk", "Referece Clock"},
@ -221,7 +251,8 @@ namespace PHA{
{"SIN", "S-IN"}, {"SIN", "S-IN"},
{"LVDS", "LVDS"}, {"LVDS", "LVDS"},
{"GPIO", "GPIO"}, {"GPIO", "GPIO"},
{"P0", "Back Plane"}}); {"P0", "Back Plane"},
{"EncodedClkIn", "Encoded CLK-IN"}});
const Reg BoardVetoWidth ("BoardVetoWidth", RW::ReadWrite, TYPE::DIG, {{"0", ""}, {"34359738360", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ns"); const Reg BoardVetoWidth ("BoardVetoWidth", RW::ReadWrite, TYPE::DIG, {{"0", ""}, {"34359738360", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ns");
const Reg BoardVetoPolarity ("BoardVetoPolarity", RW::ReadWrite, TYPE::DIG, {{"ActiveHigh", "High"}, {"ActiveLow", "Low"}}); const Reg BoardVetoPolarity ("BoardVetoPolarity", RW::ReadWrite, TYPE::DIG, {{"ActiveHigh", "High"}, {"ActiveLow", "Low"}});
const Reg RunDelay ("RunDelay", RW::ReadWrite, TYPE::DIG, {{"0", ""}, {"524280", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ns"); const Reg RunDelay ("RunDelay", RW::ReadWrite, TYPE::DIG, {{"0", ""}, {"524280", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ns");
@ -232,21 +263,40 @@ namespace PHA{
const Reg PermanentClockOutDelay ("PermanentClockOutDelay", RW::ReadWrite, TYPE::DIG, {{"-18888.888", ""}, {"18888.888", ""}, {"74.074", ""}}, ANSTYPE::FLOAT, "ps"); const Reg PermanentClockOutDelay ("PermanentClockOutDelay", RW::ReadWrite, TYPE::DIG, {{"-18888.888", ""}, {"18888.888", ""}, {"74.074", ""}}, ANSTYPE::FLOAT, "ps");
const Reg TestPulsePeriod ("TestPulsePeriod", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"34359738360", ""}, {"8", ""}}, ANSTYPE::INTEGER, "ns"); const Reg TestPulsePeriod ("TestPulsePeriod", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"34359738360", ""}, {"8", ""}}, ANSTYPE::INTEGER, "ns");
const Reg TestPulseWidth ("TestPulseWidth", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"34359738360", ""}, {"8", ""}}, ANSTYPE::INTEGER, "ns"); const Reg TestPulseWidth ("TestPulseWidth", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"34359738360", ""}, {"8", ""}}, ANSTYPE::INTEGER, "ns");
const Reg TestPulseLowLevel ("TestPulseLowLevel", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"65535", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ns"); const Reg TestPulseLowLevel ("TestPulseLowLevel", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"65535", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ADC counts");
const Reg TestPulseHighLevel ("TestPulseHighLevel", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"65535", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ns"); const Reg TestPulseHighLevel ("TestPulseHighLevel", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"65535", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ADC counts");
const Reg ErrorFlagMask ("ErrorFlagMask", RW::ReadWrite, TYPE::DIG, {}, ANSTYPE::BINARY); const Reg ErrorFlagMask ("ErrorFlagMask", RW::ReadWrite, TYPE::DIG, {}, ANSTYPE::BINARY);
const Reg ErrorFlagDataMask ("ErrorFlagDataMask", RW::ReadWrite, TYPE::DIG, {}, ANSTYPE::BINARY); const Reg ErrorFlagDataMask ("ErrorFlagDataMask", RW::ReadWrite, TYPE::DIG, {}, ANSTYPE::BINARY);
const Reg DACoutMode ("DACoutMode", RW::ReadWrite, TYPE::DIG, {{"Static", "DAC fixed level"}, const Reg DACoutMode ("DACoutMode", RW::ReadWrite, TYPE::DIG, {{"Static", "DAC static level"},
{"ChInput", "From Channel"}, {"ChInput", "From Channel"},
{"ChSum", "Sum of all Channels"}, {"ChSum", "Sum of all Channels"},
{"OverThrSum", "Number of Channels triggered"}, {"OverThrSum", "Number of Channels triggered"},
{"Ramp", "14-bit counter"}, {"Ramp", "14-bit counter"},
{"Sin5MHz", "5 MHz Sin wave"}, {"Sin5MHz", "5 MHz Sin wave Vpp = 2V"},
{"Square", "Test Pulse"}}); {"IPE", "Internal Pulse Emultor"},
{"Square", "Test Pulse"}});
const Reg DACoutStaticLevel ("DACoutStaticLevel", RW::ReadWrite, TYPE::DIG, {{"0", ""}, {"16383", ""}, {"1",""}}, ANSTYPE::INTEGER, "units"); const Reg DACoutStaticLevel ("DACoutStaticLevel", RW::ReadWrite, TYPE::DIG, {{"0", ""}, {"16383", ""}, {"1",""}}, ANSTYPE::INTEGER, "units");
const Reg DACoutChSelect ("DACoutChSelect", RW::ReadWrite, TYPE::DIG, {{"0", ""}, {"64", ""}, {"1",""}}, ANSTYPE::INTEGER); const Reg DACoutChSelect ("DACoutChSelect", RW::ReadWrite, TYPE::DIG, {{"0", ""}, {"64", ""}, {"1",""}}, ANSTYPE::INTEGER);
const Reg EnableOffsetCalibration ("EnOffsetCalibration", RW::ReadWrite, TYPE::DIG, {{"True", "Applied Cali."}, {"False", "No Cali."}}); const Reg EnableOffsetCalibration ("EnOffsetCalibration", RW::ReadWrite, TYPE::DIG, {{"True", "Applied Cali."}, {"False", "No Cali."}});
const Reg ITLAMainLogic ("ITLAMainLogic", RW::ReadWrite, TYPE::DIG, {{"OR", "OR"},{"AND", "AND"}, {"Majority", "Majority"}});
const Reg ITLAMajorityLev ("ITLAMajorityLev", RW::ReadWrite, TYPE::DIG, {{"1", ""},{"63", ""}, {"1", ""}}, ANSTYPE::INTEGER);
const Reg ITLAPairLogic ("ITLAPairLogic", RW::ReadWrite, TYPE::DIG, {{"OR", "OR"},{"AND", "AND"}, {"NONE", "NONE"}});
const Reg ITLAPolarity ("ITLAPolarity", RW::ReadWrite, TYPE::DIG, {{"Direct", "Direct"},{"Inverted", "Inverted"}});
const Reg ITLAMask ("ITLAMask", RW::ReadWrite, TYPE::DIG, {}, ANSTYPE::BYTE, "64-bit");
const Reg ITLAGateWidth ("ITLAGateWidth", RW::ReadWrite, TYPE::DIG, {{"0", ""}, {"524280", ""}, {"8", ""}}, ANSTYPE::INTEGER, "ns");
const Reg ITLBMainLogic ("ITLBMainLogic", RW::ReadWrite, TYPE::DIG, {{"OR", "OR"},{"AND", "AND"}, {"Majority", "Majority"}});
const Reg ITLBMajorityLev ("ITLBMajorityLev", RW::ReadWrite, TYPE::DIG, {{"1", ""},{"63", ""}, {"1", ""}}, ANSTYPE::INTEGER);
const Reg ITLBPairLogic ("ITLBPairLogic", RW::ReadWrite, TYPE::DIG, {{"OR", "OR"},{"AND", "AND"}, {"NONE", "NONE"}});
const Reg ITLBPolarity ("ITLBPolarity", RW::ReadWrite, TYPE::DIG, {{"Direct", "Direct"},{"Inverted", "Inverted"}});
const Reg ITLBMask ("ITLBMask", RW::ReadWrite, TYPE::DIG, {}, ANSTYPE::BYTE, "64-bit");
const Reg ITLBGateWidth ("ITLBGateWidth", RW::ReadWrite, TYPE::DIG, {{"0", ""}, {"524280", ""}, {"8", ""}}, ANSTYPE::INTEGER, "ns");
const Reg LVDSIOReg ("LVDSIOReg", RW::ReadWrite, TYPE::DIG, {}, ANSTYPE::STR);
//const Reg LVDSTrgMask ("lvdstrgmask", RW::ReadWrite, TYPE::DIG, {}, ANSTYPE::BYTE, "64-bit");
/// ========== command /// ========== command
const Reg Reset ("Reset", RW::WriteOnly, TYPE::DIG, {}, ANSTYPE::NONE, "", true); const Reg Reset ("Reset", RW::WriteOnly, TYPE::DIG, {}, ANSTYPE::NONE, "", true);
const Reg ClearData ("ClearData", RW::WriteOnly, TYPE::DIG, {}, ANSTYPE::NONE, "", true); // clear memory, setting not affected const Reg ClearData ("ClearData", RW::WriteOnly, TYPE::DIG, {}, ANSTYPE::NONE, "", true); // clear memory, setting not affected
@ -256,6 +306,7 @@ namespace PHA{
const Reg SoftwareStopACQ ("SwStopAcquisition", RW::WriteOnly, TYPE::DIG, {}, ANSTYPE::NONE, "", true); // stop ACQ, whatever start source const Reg SoftwareStopACQ ("SwStopAcquisition", RW::WriteOnly, TYPE::DIG, {}, ANSTYPE::NONE, "", true); // stop ACQ, whatever start source
const Reg SendSoftwareTrigger ("SendSWTrigger", RW::WriteOnly, TYPE::DIG, {}, ANSTYPE::NONE, "", true); // only work when Swtrg in the GlobalTriggerSource const Reg SendSoftwareTrigger ("SendSWTrigger", RW::WriteOnly, TYPE::DIG, {}, ANSTYPE::NONE, "", true); // only work when Swtrg in the GlobalTriggerSource
const Reg ReloadCalibration ("ReloadCalibration", RW::WriteOnly, TYPE::DIG, {}, ANSTYPE::NONE, "", true); const Reg ReloadCalibration ("ReloadCalibration", RW::WriteOnly, TYPE::DIG, {}, ANSTYPE::NONE, "", true);
const Reg Reboot ("Reboot", RW::WriteOnly, TYPE::DIG, {}, ANSTYPE::NONE, "", true); //^ not implemented
const std::vector<Reg> AllSettings = { const std::vector<Reg> AllSettings = {
@ -309,6 +360,9 @@ namespace PHA{
SpeedSensFan2 , SpeedSensFan2 ,
ErrorFlags , ErrorFlags ,
BoardReady , BoardReady ,
// SPFLinkPresence ,
// SPFLinkActive ,
// SPFLinkProtocol ,
ClockSource , ClockSource ,
IO_Level , IO_Level ,
StartSource , StartSource ,
@ -337,18 +391,55 @@ namespace PHA{
DACoutMode , DACoutMode ,
DACoutStaticLevel , DACoutStaticLevel ,
DACoutChSelect , DACoutChSelect ,
EnableOffsetCalibration EnableOffsetCalibration ,
ITLAMainLogic ,
ITLAMajorityLev ,
ITLAPairLogic ,
ITLAPolarity ,
ITLAMask ,
ITLAGateWidth ,
ITLBMainLogic ,
ITLBMajorityLev ,
ITLBPairLogic ,
ITLBPolarity ,
ITLBMask ,
ITLBGateWidth ,
LVDSIOReg
//LVDSTrgMask
}; };
} }
namespace GROUP{
const Reg InputDelay ("InputDelay", RW::ReadWrite, TYPE::GROUP, {{"0",""}, {"32768", ""}, {"8", ""}}, ANSTYPE::INTEGER, "ns");
}
namespace VGA{ namespace VGA{
const Reg VGAGain ("VGAGain", RW::ReadWrite, TYPE::VGA, {{"0", ""},{"40", ""}, {"0.5",""}}, ANSTYPE::INTEGER, "dB"); // VX2745 only const Reg VGAGain ("VGAGain", RW::ReadWrite, TYPE::VGA, {{"0", ""},{"40", ""}, {"0.5",""}}, ANSTYPE::INTEGER, "dB"); // VX2745 only
} }
namespace LVDS{
const Reg LVDSMode ("LVDSMode", RW::ReadWrite, TYPE::LVDS, {{"SelfTriggers", "Self-Trigger"},
{"Sync", "Sync"},
{"IORegister", "IORegister"}});
const Reg LVDSDirection ("LVDSDirection", RW::ReadWrite, TYPE::LVDS, {{"Input", "Input"},
{"Output", "Output"}});
const std::vector<Reg> AllSettings = {
LVDSMode ,
LVDSDirection
};
}
namespace CH{ namespace CH{
/// ========= command
const Reg SendChSWTrigger ("SendChSWrigger", RW::WriteOnly, TYPE::CH, {}, ANSTYPE::NONE, "", true);
/// ========= red only /// ========= red only
const Reg SelfTrgRate ("SelfTrgRate", RW::ReadOnly, TYPE::CH, {}, ANSTYPE::INTEGER, "Hz"); const Reg SelfTrgRate ("SelfTrgRate", RW::ReadOnly, TYPE::CH, {}, ANSTYPE::INTEGER, "Hz");
const Reg ChannelStatus ("ChStatus", RW::ReadOnly, TYPE::CH, {}, ANSTYPE::STR); const Reg ChannelStatus ("ChStatus", RW::ReadOnly, TYPE::CH, {}, ANSTYPE::STR);
@ -362,6 +453,11 @@ namespace PHA{
const Reg ChannelWaveCount ("ChWaveCnt", RW::ReadOnly, TYPE::CH, {}, ANSTYPE::STR); const Reg ChannelWaveCount ("ChWaveCnt", RW::ReadOnly, TYPE::CH, {}, ANSTYPE::STR);
/// ======= read write /// ======= read write
//^ not impletemented in digitizer panel
const Reg SelfTriggerWidth ("SelfTriggerWidth", RW::ReadWrite, TYPE::CH, {{"0", ""},{"6000", ""},{"8", ""}}, ANSTYPE::INTEGER, "ns"); // not sure the max
const Reg SignalOffset ("SignalOffset", RW::ReadWrite, TYPE::CH, {{"-1000000", ""},{"1000000", ""},{"1", ""}}, ANSTYPE::INTEGER, "uV"); // not sure the max
//^ impletemented
const Reg ChannelEnable ("ChEnable", RW::ReadWrite, TYPE::CH, {{"True", "Enabled"}, {"False", "Disabled"}}); const Reg ChannelEnable ("ChEnable", RW::ReadWrite, TYPE::CH, {{"True", "Enabled"}, {"False", "Disabled"}});
const Reg DC_Offset ("DCOffset", RW::ReadWrite, TYPE::CH, {{"0", ""}, {"100", ""}, {"1",""}}, ANSTYPE::INTEGER, "%"); const Reg DC_Offset ("DCOffset", RW::ReadWrite, TYPE::CH, {{"0", ""}, {"100", ""}, {"1",""}}, ANSTYPE::INTEGER, "%");
const Reg TriggerThreshold ("TriggerThr", RW::ReadWrite, TYPE::CH, {{"0", ""},{"8191", ""}, {"1",""}}, ANSTYPE::INTEGER); const Reg TriggerThreshold ("TriggerThr", RW::ReadWrite, TYPE::CH, {{"0", ""},{"8191", ""}, {"1",""}}, ANSTYPE::INTEGER);
@ -372,6 +468,7 @@ namespace PHA{
{"ADC_TEST_RAMP", "ADC produces RAMP signal"}, {"ADC_TEST_RAMP", "ADC produces RAMP signal"},
{"ADC_TEST_SIN", "ADC produce SIN signal"}, {"ADC_TEST_SIN", "ADC produce SIN signal"},
{"Ramp", "Ramp generator"}, {"Ramp", "Ramp generator"},
{"IPE", "Internal Pulse Emulator"},
{"SquareWave", "Test Pusle (Square Wave)"} }); {"SquareWave", "Test Pusle (Square Wave)"} });
const Reg RecordLength ("ChRecordLengthT", RW::ReadWrite, TYPE::CH, {{"32", ""}, {"64800", ""}, {"8",""}}, ANSTYPE::INTEGER, "ns"); const Reg RecordLength ("ChRecordLengthT", RW::ReadWrite, TYPE::CH, {{"32", ""}, {"64800", ""}, {"8",""}}, ANSTYPE::INTEGER, "ns");
const Reg PreTrigger ("ChPreTriggerT", RW::ReadWrite, TYPE::CH, {{"32", ""}, {"32000", ""}, {"8",""}}, ANSTYPE::INTEGER, "ns"); const Reg PreTrigger ("ChPreTriggerT", RW::ReadWrite, TYPE::CH, {{"32", ""}, {"32000", ""}, {"8",""}}, ANSTYPE::INTEGER, "ns");
@ -473,6 +570,9 @@ namespace PHA{
{"SWTrigger", "Software Trigger"}, {"SWTrigger", "Software Trigger"},
{"ChSelfTrigger", "Channel Self-Trigger"}, {"ChSelfTrigger", "Channel Self-Trigger"},
{"Ch64Trigger", "Channel 64-Trigger"}, {"Ch64Trigger", "Channel 64-Trigger"},
{"ITLA", "ITL-A"},
{"ITLB", "ITL-B"},
{"LVDS", "LVDS"},
{"Disabled", "Disabled"}}); {"Disabled", "Disabled"}});
const Reg ChannelsTriggerMask ("ChannelsTriggerMask", RW::ReadWrite, TYPE::CH, {}, ANSTYPE::BYTE, "64-bit" ); const Reg ChannelsTriggerMask ("ChannelsTriggerMask", RW::ReadWrite, TYPE::CH, {}, ANSTYPE::BYTE, "64-bit" );
const Reg ChannelVetoSource ("ChannelVetoSource", RW::ReadWrite, TYPE::CH, {{"BoardVeto", "Board Veto"}, const Reg ChannelVetoSource ("ChannelVetoSource", RW::ReadWrite, TYPE::CH, {{"BoardVeto", "Board Veto"},
@ -487,6 +587,9 @@ namespace PHA{
{"SWTrigger", "Software Trigger"}, {"SWTrigger", "Software Trigger"},
{"ChSelfTrigger", "Channel Self-Trigger"}, {"ChSelfTrigger", "Channel Self-Trigger"},
{"Ch64Trigger", "Channel 64-Trigger"}, {"Ch64Trigger", "Channel 64-Trigger"},
{"ITLA", "ITL-A"},
{"ITLB", "ITL-B"},
{"LVDS", "LVDS"},
{"Disabled", "Disabled"}}); {"Disabled", "Disabled"}});
const Reg EventSelector ("EventSelector", RW::ReadWrite, TYPE::CH, {{"All", "All"}, const Reg EventSelector ("EventSelector", RW::ReadWrite, TYPE::CH, {{"All", "All"},
@ -525,26 +628,43 @@ namespace PHA{
const Reg EnergyFilterBaselineGuardSample ("EnergyFilterBaselineGuardS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"1000", ""}, {"1", ""}}, ANSTYPE::INTEGER, "sample"); const Reg EnergyFilterBaselineGuardSample ("EnergyFilterBaselineGuardS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"1000", ""}, {"1", ""}}, ANSTYPE::INTEGER, "sample");
const Reg EnergyFilterPileUpGuardSample ("EnergyFilterPileUpGuardS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"8000", ""}, {"1", ""}}, ANSTYPE::INTEGER, "sample"); const Reg EnergyFilterPileUpGuardSample ("EnergyFilterPileUpGuardS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"8000", ""}, {"1", ""}}, ANSTYPE::INTEGER, "sample");
const Reg ITLConnect ("ITLConnect", RW::ReadWrite, TYPE::CH, {{"Disabled", "Disabled"},{"ITLA", "ITLA"}, {"ITLB", "ITLB"}});
const std::vector<Reg> AllSettings = { const std::vector<Reg> AllSettings = {
SelfTrgRate , SelfTrgRate , // 0
ChannelStatus , ChannelStatus , // 1
GainFactor , GainFactor , // 2
ADCToVolts , ADCToVolts , // 3
Energy_Nbit , Energy_Nbit , // 4
ChannelRealtime , ChannelRealtime , // 5
ChannelDeadtime , ChannelDeadtime , // 6
ChannelTriggerCount , ChannelTriggerCount , // 7
ChannelSavedCount , ChannelSavedCount , // 8
ChannelWaveCount , ChannelWaveCount , // 9
ChannelEnable ,
DC_Offset , ChannelEnable , // 0
TriggerThreshold , DC_Offset , // 1
Polarity , TriggerThreshold , // 2
WaveDataSource , Polarity , // 3
RecordLength , WaveDataSource , // 4
WaveSaving , RecordLength , // 5
WaveResolution , PreTrigger , // 6
PreTrigger , WaveSaving , // 7
WaveResolution , // 8
EventTriggerSource , // 9
ChannelsTriggerMask , // 10
ChannelVetoSource , // 11
WaveTriggerSource , // 12
EventSelector , // 13
WaveSelector , // 14
CoincidenceMask , // 15
AntiCoincidenceMask , // 16
CoincidenceLength , // 17
ADCVetoWidth , // 18
EnergySkimLowDiscriminator , // 19
EnergySkimHighDiscriminator, // 20
ITLConnect , // 21
TimeFilterRiseTime , TimeFilterRiseTime ,
TimeFilterRetriggerGuard , TimeFilterRetriggerGuard ,
EnergyFilterRiseTime , EnergyFilterRiseTime ,
@ -563,28 +683,20 @@ namespace PHA{
WaveDigitalProbe1 , WaveDigitalProbe1 ,
WaveDigitalProbe2 , WaveDigitalProbe2 ,
WaveDigitalProbe3 , WaveDigitalProbe3 ,
EventTriggerSource ,
ChannelsTriggerMask , SelfTriggerWidth ,
ChannelVetoSource , SignalOffset
WaveTriggerSource ,
EventSelector , // CoincidenceLengthSample ,
WaveSelector , // RecordLengthSample ,
CoincidenceMask , // PreTriggerSample ,
AntiCoincidenceMask , // TimeFilterRiseTimeSample ,
CoincidenceLength , // TimeFilterRetriggerGuardSample ,
CoincidenceLengthSample , // EnergyFilterRiseTimeSample ,
ADCVetoWidth , // EnergyFilterFlatTopSample ,
EnergySkimLowDiscriminator , // EnergyFilterPoleZeroSample ,
EnergySkimHighDiscriminator, // EnergyFilterBaselineGuardSample ,
RecordLengthSample , // EnergyFilterPileUpGuardSample
PreTriggerSample ,
TimeFilterRiseTimeSample ,
TimeFilterRetriggerGuardSample ,
EnergyFilterRiseTimeSample ,
EnergyFilterFlatTopSample ,
EnergyFilterPoleZeroSample ,
EnergyFilterBaselineGuardSample ,
EnergyFilterPileUpGuardSample
}; };
} }
@ -592,4 +704,513 @@ namespace PHA{
}; };
namespace PSD{
namespace DIG{ // the PSD::DIG are identical to PHA::DIG
///============== read only
const Reg CupVer = PHA::DIG::CupVer;
const Reg FPGA_firmwareVersion = PHA::DIG::FPGA_firmwareVersion;
const Reg FirmwareType = PHA::DIG::FirmwareType;
const Reg ModelCode = PHA::DIG::ModelCode;
const Reg PBCode = PHA::DIG::PBCode;
const Reg ModelName = PHA::DIG::ModelName;
const Reg FromFactor = PHA::DIG::FromFactor;
const Reg FamilyCode = PHA::DIG::FamilyCode;
const Reg SerialNumber = PHA::DIG::SerialNumber;
const Reg PCBrev_MB = PHA::DIG::PCBrev_MB;
const Reg PCBrev_PB = PHA::DIG::PCBrev_PB;
const Reg DPP_License = PHA::DIG::DPP_License;
const Reg DPP_LicenseStatus = PHA::DIG::DPP_LicenseStatus;
const Reg DPP_LicenseRemainingTime = PHA::DIG::DPP_LicenseRemainingTime;
const Reg NumberOfChannel = PHA::DIG::NumberOfChannel;
const Reg ADC_bit = PHA::DIG::ADC_bit;
const Reg ADC_SampleRate = PHA::DIG::ADC_SampleRate;
const Reg InputDynamicRange = PHA::DIG::InputDynamicRange;
const Reg InputType = PHA::DIG::InputType;
const Reg InputImpedance = PHA::DIG::InputImpedance;
const Reg IPAddress = PHA::DIG::IPAddress;
const Reg NetMask = PHA::DIG::NetMask;
const Reg Gateway = PHA::DIG::Gateway;
const Reg LED_status = PHA::DIG::LED_status;
const Reg ACQ_status = PHA::DIG::ACQ_status;
const Reg MaxRawDataSize = PHA::DIG::MaxRawDataSize;
const Reg TempSensAirIn = PHA::DIG::TempSensAirIn;
const Reg TempSensAirOut = PHA::DIG::TempSensAirOut;
const Reg TempSensCore = PHA::DIG::TempSensCore;
const Reg TempSensFirstADC = PHA::DIG::TempSensFirstADC;
const Reg TempSensLastADC = PHA::DIG::TempSensLastADC;
const Reg TempSensHottestADC = PHA::DIG::TempSensHottestADC;
const Reg TempSensADC0 = PHA::DIG::TempSensADC0;
const Reg TempSensADC1 = PHA::DIG::TempSensADC1;
const Reg TempSensADC2 = PHA::DIG::TempSensADC2;
const Reg TempSensADC3 = PHA::DIG::TempSensADC3;
const Reg TempSensADC4 = PHA::DIG::TempSensADC4;
const Reg TempSensADC5 = PHA::DIG::TempSensADC5;
const Reg TempSensADC6 = PHA::DIG::TempSensADC6;
const Reg TempSensADC7 = PHA::DIG::TempSensADC7;
const std::vector<Reg> TempSensADC = {TempSensADC0,TempSensADC1,TempSensADC2,TempSensADC3,TempSensADC4,TempSensADC5,TempSensADC6,TempSensADC7};
const std::vector<Reg> TempSensOthers = {TempSensAirIn,TempSensAirOut,TempSensCore,TempSensFirstADC,TempSensLastADC,TempSensHottestADC};
const Reg TempSensDCDC = PHA::DIG::TempSensDCDC;
const Reg VInSensDCDC = PHA::DIG::VInSensDCDC;
const Reg VOutSensDCDC = PHA::DIG::VOutSensDCDC;
const Reg IOutSensDCDC = PHA::DIG::IOutSensDCDC;
const Reg FreqSensCore = PHA::DIG::FreqSensCore;
const Reg DutyCycleSensDCDC = PHA::DIG::DutyCycleSensDCDC;
const Reg SpeedSensFan1 = PHA::DIG::SpeedSensFan1;
const Reg SpeedSensFan2 = PHA::DIG::SpeedSensFan2;
const Reg ErrorFlags = PHA::DIG::ErrorFlags;
const Reg BoardReady = PHA::DIG::BoardReady;
const Reg SPFLinkPresence = PHA::DIG::SPFLinkPresence;
const Reg SPFLinkActive = PHA::DIG::SPFLinkActive;
const Reg SPFLinkProtocol = PHA::DIG::SPFLinkProtocol;
///============= read write
//const Reg EnableClockOutBackplane ("EnClockOutP0", RW::ReadWrite, TYPE::DIG);
const Reg ClockSource = PHA::DIG::ClockSource;
const Reg IO_Level = PHA::DIG::IO_Level;
const Reg StartSource = PHA::DIG::StartSource;
const Reg GlobalTriggerSource = PHA::DIG::GlobalTriggerSource;
const Reg BusyInSource = PHA::DIG::BusyInSource;
const Reg EnableClockOutFrontPanel = PHA::DIG::EnableClockOutFrontPanel;
const Reg TrgOutMode = PHA::DIG::TrgOutMode;
const Reg GPIOMode = PHA::DIG::GPIOMode;
const Reg SyncOutMode = PHA::DIG::SyncOutMode;
const Reg BoardVetoSource = PHA::DIG::BoardVetoSource;
const Reg BoardVetoWidth = PHA::DIG::BoardVetoWidth;
const Reg BoardVetoPolarity = PHA::DIG::BoardVetoPolarity;
const Reg RunDelay = PHA::DIG::RunDelay;
const Reg EnableAutoDisarmACQ = PHA::DIG::EnableAutoDisarmACQ;
const Reg EnableDataReduction = PHA::DIG::EnableDataReduction;
const Reg EnableStatisticEvents = PHA::DIG::EnableStatisticEvents;
const Reg VolatileClockOutDelay = PHA::DIG::VolatileClockOutDelay;
const Reg PermanentClockOutDelay = PHA::DIG::PermanentClockOutDelay;
const Reg TestPulsePeriod = PHA::DIG::TestPulsePeriod;
const Reg TestPulseWidth = PHA::DIG::TestPulseWidth;
const Reg TestPulseLowLevel = PHA::DIG::TestPulseLowLevel;
const Reg TestPulseHighLevel = PHA::DIG::TestPulseHighLevel;
// only for version >= 2024041200
const Reg IPEAmplitude ("IPEAmplitude", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"16383", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ADC counts");
const Reg IPEBaseline ("IPEBaseline", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"16383", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ADC counts");
const Reg IPEDecayTime ("IPEDecayTime", RW::ReadWrite, TYPE::DIG, {{"8", ""},{ "2000", ""}, {"8", ""}}, ANSTYPE::INTEGER, "ns");
const Reg IPERate ("IPERate", RW::ReadWrite, TYPE::DIG, {{"1", ""},{"60000", ""}, {"1", ""}}, ANSTYPE::INTEGER, "Hz");
const Reg IPETimeMode ("IPETimeMode", RW::ReadWrite, TYPE::DIG, {{"ConstantRate", "constant rate"},
{"Poissonian", "Poisson"}});
const Reg ErrorFlagMask = PHA::DIG::ErrorFlagMask;
const Reg ErrorFlagDataMask = PHA::DIG::ErrorFlagDataMask;
const Reg DACoutMode = PHA::DIG::DACoutMode;
const Reg DACoutStaticLevel = PHA::DIG::DACoutStaticLevel;
const Reg DACoutChSelect = PHA::DIG::DACoutChSelect;
const Reg EnableOffsetCalibration = PHA::DIG::EnableOffsetCalibration;
const Reg ITLAMainLogic = PHA::DIG::ITLAMainLogic;
const Reg ITLAMajorityLev = PHA::DIG::ITLAMajorityLev;
const Reg ITLAPairLogic = PHA::DIG::ITLAPairLogic;
const Reg ITLAPolarity = PHA::DIG::ITLAPolarity;
const Reg ITLAMask = PHA::DIG::ITLAMask;
const Reg ITLAGateWidth = PHA::DIG::ITLAGateWidth;
const Reg ITLBMainLogic = PHA::DIG::ITLBMainLogic;
const Reg ITLBMajorityLev = PHA::DIG::ITLBMajorityLev;
const Reg ITLBPairLogic = PHA::DIG::ITLBPairLogic;
const Reg ITLBPolarity = PHA::DIG::ITLBPolarity;
const Reg ITLBMask = PHA::DIG::ITLBMask;
const Reg ITLBGateWidth = PHA::DIG::ITLBGateWidth;
const Reg LVDSIOReg = PHA::DIG::LVDSIOReg;
//const Reg LVDSTrgMask ("lvdstrgmask", RW::ReadWrite, TYPE::DIG, {}, ANSTYPE::BYTE, "64-bit");
/// ========== command
const Reg Reset = PHA::DIG::Reset;
const Reg ClearData = PHA::DIG::ClearData;
const Reg ArmACQ = PHA::DIG::ArmACQ;
const Reg DisarmACQ = PHA::DIG::DisarmACQ;
const Reg SoftwareStartACQ = PHA::DIG::SoftwareStartACQ;
const Reg SoftwareStopACQ = PHA::DIG::SoftwareStopACQ;
const Reg SendSoftwareTrigger = PHA::DIG::SendSoftwareTrigger;
const Reg ReloadCalibration = PHA::DIG::ReloadCalibration;
const std::vector<Reg> AllSettings = {
CupVer ,
FPGA_firmwareVersion ,
FirmwareType ,
ModelCode ,
PBCode ,
ModelName ,
FromFactor ,
FamilyCode ,
SerialNumber ,
PCBrev_MB ,
PCBrev_PB ,
DPP_License ,
DPP_LicenseStatus ,
DPP_LicenseRemainingTime ,
NumberOfChannel ,
ADC_bit ,
ADC_SampleRate ,
InputDynamicRange ,
InputType ,
InputImpedance ,
IPAddress ,
NetMask ,
Gateway ,
LED_status ,
ACQ_status ,
MaxRawDataSize ,
TempSensAirIn ,
TempSensAirOut ,
TempSensCore ,
TempSensFirstADC ,
TempSensLastADC ,
TempSensHottestADC ,
TempSensADC0 ,
TempSensADC1 ,
TempSensADC2 ,
TempSensADC3 ,
TempSensADC4 ,
TempSensADC5 ,
TempSensADC6 ,
TempSensADC7 ,
TempSensDCDC ,
VInSensDCDC ,
VOutSensDCDC ,
IOutSensDCDC ,
FreqSensCore ,
DutyCycleSensDCDC ,
SpeedSensFan1 ,
SpeedSensFan2 ,
ErrorFlags ,
BoardReady ,
// SPFLinkPresence ,
// SPFLinkActive ,
// SPFLinkProtocol ,
ClockSource ,
IO_Level ,
StartSource ,
GlobalTriggerSource ,
BusyInSource ,
//EnableClockOutBackplane ,
EnableClockOutFrontPanel ,
TrgOutMode ,
GPIOMode ,
SyncOutMode ,
BoardVetoSource ,
BoardVetoWidth ,
BoardVetoPolarity ,
RunDelay ,
EnableAutoDisarmACQ ,
EnableDataReduction ,
EnableStatisticEvents ,
VolatileClockOutDelay ,
PermanentClockOutDelay ,
TestPulsePeriod ,
TestPulseWidth ,
TestPulseLowLevel ,
TestPulseHighLevel ,
ErrorFlagMask ,
ErrorFlagDataMask ,
DACoutMode ,
DACoutStaticLevel ,
DACoutChSelect ,
EnableOffsetCalibration ,
ITLAMainLogic ,
ITLAMajorityLev ,
ITLAPairLogic ,
ITLAPolarity ,
ITLAMask ,
ITLAGateWidth ,
ITLBMainLogic ,
ITLBMajorityLev ,
ITLBPairLogic ,
ITLBPolarity ,
ITLBMask ,
ITLBGateWidth ,
LVDSIOReg
//LVDSTrgMask
};
}
namespace GROUP{
const Reg InputDelay = PHA::GROUP::InputDelay;
}
namespace VGA{
const Reg VGAGain = PHA::VGA::VGAGain;
}
namespace LVDS{
const Reg LVDSMode = PHA::LVDS::LVDSMode;
const Reg LVDSDirection = PHA::LVDS::LVDSDirection;
const std::vector<Reg> AllSettings = {
LVDSMode ,
LVDSDirection
};
}
namespace CH{
/// ========= command
const Reg SendChSWTrigger ("SendChSWrigger", RW::WriteOnly, TYPE::CH, {}, ANSTYPE::NONE, "", true);
/// ========= red only
const Reg SelfTrgRate = PHA::CH::SelfTrgRate;
const Reg ChannelStatus = PHA::CH::ChannelStatus;
const Reg GainFactor = PHA::CH::GainFactor;
const Reg ADCToVolts = PHA::CH::ADCToVolts;
const Reg ChannelRealtime = PHA::CH::ChannelRealtime;
const Reg ChannelDeadtime = PHA::CH::ChannelDeadtime;
const Reg ChannelTriggerCount = PHA::CH::ChannelTriggerCount;
const Reg ChannelSavedCount = PHA::CH::ChannelSavedCount;
const Reg ChannelWaveCount = PHA::CH::ChannelWaveCount;
/// ======= read write
//^ not impletemented in digitizer panel
//--- only for VX2745
const Reg SelfTriggerWidth = PHA::CH::SelfTriggerWidth;
//--- for VX2730
const Reg ChGain ("ChGain", RW::ReadWrite, TYPE::CH, {{"0", ""},{"29", ""}, {"1", ""}}, ANSTYPE::INTEGER, "dB");
//--- for VX2745 and VX2730
const Reg SignalOffset = PHA::CH::SignalOffset;
//^ impletemented
const Reg ChannelEnable = PHA::CH::ChannelEnable;
const Reg DC_Offset = PHA::CH::DC_Offset;
const Reg TriggerThreshold = PHA::CH::TriggerThreshold;
const Reg Polarity = PHA::CH::Polarity;
const Reg WaveDataSource = PHA::CH::WaveDataSource;
const Reg RecordLength = PHA::CH::RecordLength;
const Reg PreTrigger = PHA::CH::PreTrigger;
const Reg WaveSaving = PHA::CH::WaveSaving;
const Reg WaveResolution = PHA::CH::WaveResolution;
const Reg WaveAnalogProbe0 ("WaveAnalogProbe0", RW::ReadWrite, TYPE::CH, {{"ADCInput", "ADC Input"},
{"ADCInputBaseline", "ADC Input baseline"},
{"CFDFilter", "CFD Filter"}});
const Reg WaveAnalogProbe1 ("WaveAnalogProbe1", RW::ReadWrite, TYPE::CH, {{"ADCInput", "ADC Input"},
{"ADCInputBaseline", "ADC Input baseline"},
{"CFDFilter", "CFD Filter"}});
const Reg WaveDigitalProbe0 ("WaveDigitalProbe0", RW::ReadWrite, TYPE::CH, {{"Trigger", "Trigger"},
{"CFDFilterArmed", "CFD Filter Armed"},
{"ReTriggerGuard", "ReTrigger Guard"},
{"ADCInputBaselineFreeze", "ADC Input basline Freeze"},
{"ADCInputOverthreshold", "ADC Input Over-threshold"},
{"ChargeReady", "Charge Ready"},
{"LongGate", "Long Gate"},
{"ShortGate", "Short Gate"},
{"PileUpTrigger", "Pile-up Trig."},
{"ChargeOverRange", "Charge Over Range"},
{"ADCSaturation", "ADC Saturate"},
{"ADCInputNegativeOverthreshold", "ADC Input Neg. Over-Threshold"} });
const Reg WaveDigitalProbe1 ("WaveDigitalProbe1", RW::ReadWrite, TYPE::CH, {{"Trigger", "Trigger"},
{"CFDFilterArmed", "CFD Filter Armed"},
{"ReTriggerGuard", "ReTrigger Guard"},
{"ADCInputBaselineFreeze", "ADC Input basline Freeze"},
{"ADCInputOverthreshold", "ADC Input Over-threshold"},
{"ChargeReady", "Charge Ready"},
{"LongGate", "Long Gate"},
{"ShortGate", "Short Gate"},
{"PileUpTrigger", "Pile-up Trig."},
{"ChargeOverRange", "Charge Over Range"},
{"ADCSaturation", "ADC Saturate"},
{"ADCInputNegativeOverthreshold", "ADC Input Neg. Over-Threshold"} });
const Reg WaveDigitalProbe2 ("WaveDigitalProbe2", RW::ReadWrite, TYPE::CH, {{"Trigger", "Trigger"},
{"CFDFilterArmed", "CFD Filter Armed"},
{"ReTriggerGuard", "ReTrigger Guard"},
{"ADCInputBaselineFreeze", "ADC Input basline Freeze"},
{"ADCInputOverthreshold", "ADC Input Over-threshold"},
{"ChargeReady", "Charge Ready"},
{"LongGate", "Long Gate"},
{"ShortGate", "Short Gate"},
{"PileUpTrigger", "Pile-up Trig."},
{"ChargeOverRange", "Charge Over Range"},
{"ADCSaturation", "ADC Saturate"},
{"ADCInputNegativeOverthreshold", "ADC Input Neg. Over-Threshold"} });
const Reg WaveDigitalProbe3 ("WaveDigitalProbe3", RW::ReadWrite, TYPE::CH, {{"Trigger", "Trigger"},
{"CFDFilterArmed", "CFD Filter Armed"},
{"ReTriggerGuard", "ReTrigger Guard"},
{"ADCInputBaselineFreeze", "ADC Input basline Freeze"},
{"ADCInputOverthreshold", "ADC Input Over-threshold"},
{"ChargeReady", "Charge Ready"},
{"LongGate", "Long Gate"},
{"ShortGate", "Short Gate"},
{"PileUpTrigger", "Pile-up Trig."},
{"ChargeOverRange", "Charge Over Range"},
{"ADCSaturation", "ADC Saturate"},
{"ADCInputNegativeOverthreshold", "ADC Input Neg. Over-Threshold"} });
const std::vector<Reg> AnalogProbe = {WaveAnalogProbe0, WaveAnalogProbe1};
const std::vector<Reg> DigitalProbe = {WaveDigitalProbe0, WaveDigitalProbe1, WaveDigitalProbe2, WaveDigitalProbe3};
const Reg EventTriggerSource = PHA::CH::EventTriggerSource;
const Reg ChannelsTriggerMask = PHA::CH::ChannelsTriggerMask;
const Reg ChannelVetoSource = PHA::CH::ChannelVetoSource;
const Reg WaveTriggerSource = PHA::CH::WaveTriggerSource;
const Reg EventSelector = PHA::CH::EventSelector;
const Reg WaveSelector = PHA::CH::WaveSelector;
const Reg CoincidenceMask = PHA::CH::CoincidenceMask;
const Reg AntiCoincidenceMask = PHA::CH::AntiCoincidenceMask;
const Reg CoincidenceLength = PHA::CH::CoincidenceLength;
const Reg CoincidenceLengthSample = PHA::CH::CoincidenceLengthSample;
const Reg ADCVetoWidth = PHA::CH::ADCVetoWidth;
const Reg EventNeutronReject ("EventNeutronReject", RW::ReadWrite, TYPE::CH, {{"Disabled", "Disabled"},{"Enabled", "Enabled"}});
const Reg WaveNeutronReject ("WaveNeutronReject", RW::ReadWrite, TYPE::CH, {{"Disabled", "Disabled"},{"Enabled", "Enabled"}});
const Reg EnergySkimLowDiscriminator = PHA::CH::EnergySkimLowDiscriminator;
const Reg EnergySkimHighDiscriminator = PHA::CH::EnergySkimHighDiscriminator;
const Reg RecordLengthSample = PHA::CH::RecordLengthSample;
const Reg PreTriggerSample = PHA::CH::PreTriggerSample;
const Reg ITLConnect = PHA::CH::ITLConnect;
const Reg ADCInputBaselineAvg ("ADCInputBaselineAvg", RW::ReadWrite, TYPE::CH, {{"Fixed", "Fixed"},
{"Low", "Low"},
{"MediumLow", "MediumLow"},
{"MediumHigh", "MediumHigh"},
{"High", "High"}});
const Reg AbsoluteBaseline ("AbsoluteBaseline", RW::ReadWrite, TYPE::CH, {{"0", ""},{"65535", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
const Reg ADCInputBaselineGuard ("ADCInputBaselineGuardT", RW::ReadWrite, TYPE::CH, {{"0", ""},{"8000", ""},{"8", ""}}, ANSTYPE::INTEGER, "ns");
const Reg SmoothingFactor ("SmoothingFactor", RW::ReadWrite, TYPE::CH, {{"1", "Disabled"},
{"2", "Avg. 2 samples"},
{"4", "Avg. 4 samples"},
{"8", "Avg. 8 samples"},
{"16", "Avg. 16 samples"}});
const Reg ChargeSmoothing ("ChargeSmoothing", RW::ReadWrite, TYPE::CH, {{"Enabled", "Enabled"}, {"Disabled", "Disabled"}});
const Reg TimeFilterSmoothing ("TimeFilterSmoothing", RW::ReadWrite, TYPE::CH, {{"Enabled", "Enabled"}, {"Disabled", "Disabled"}});
const Reg TriggerFilterSelection ("TriggerFilterSelection", RW::ReadWrite, TYPE::CH, {{"LeadingEdge", "Leading Edge"}, {"CFD", "CFD"}});
const Reg CFDDelay ("CFDDelayT", RW::ReadWrite, TYPE::CH, {{"32", ""},{"8184", ""},{"8", ""}}, ANSTYPE::INTEGER, "ns");
const Reg CFDFraction ("CFDFraction", RW::ReadWrite, TYPE::CH, {{"25", ""},{"100", ""},{"0", ""}}, ANSTYPE::INTEGER, "%");
const Reg TimeFilterRetriggerGuard ("TimeFilterRetriggerGuardT", RW::ReadWrite, TYPE::CH, {{"8", ""},{"8000", ""},{"8", ""}}, ANSTYPE::INTEGER, "ns");
const Reg TriggerHysteresis ("TriggerHysteresis", RW::ReadWrite, TYPE::CH, {{"Enabled", "Enabled"}, {"Disabled", "Disabled"}});
const Reg PileupGap ("PileupGap", RW::ReadWrite, TYPE::CH, {{"0", ""},{"65535", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
const Reg GateLongLength ("GateLongLengthT", RW::ReadWrite, TYPE::CH, {{"0", ""},{"32000", ""},{"8", ""}}, ANSTYPE::INTEGER, "ns");
const Reg GateShortLength ("GateShortLengthT", RW::ReadWrite, TYPE::CH, {{"0", ""},{"32000", ""},{"8", ""}}, ANSTYPE::INTEGER, "ns");
const Reg GateOffset ("GateOffsetT", RW::ReadWrite, TYPE::CH, {{"0", ""},{"2000", ""},{"8", ""}}, ANSTYPE::INTEGER, "ns");
const Reg LongChargeIntegratorPedestal ("LongChargeIntegratorPedestal", RW::ReadWrite, TYPE::CH, {{"0", ""},{"1000", ""},{"1", ""}}, ANSTYPE::INTEGER, "count");
const Reg ShortChargeIntegratorPedestal ("ShortChargeIntegratorPedestal", RW::ReadWrite, TYPE::CH, {{"0", ""},{"1000", ""},{"1", ""}}, ANSTYPE::INTEGER, "count");
const Reg EnergyGain ("EnergyGain", RW::ReadWrite, TYPE::CH, {{"x1", "No Gain"},
{"x4", "x4"},
{"x16", "x16"},
{"x64", "x64"},
{"x256", "x256"}});
const Reg NeutronThreshold ("NeutronThreshold", RW::ReadWrite, TYPE::CH, {{"0", ""},{"1000", ""},{"1", ""}}, ANSTYPE::INTEGER, "count");
const Reg ADCInputBaselineGuardSample ("ADCInputBaselineGuardS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"1000", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
const Reg CFDDelaySample ("CFDDelayS", RW::ReadWrite, TYPE::CH, {{"4", ""},{"1023", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
const Reg TimeFilterRetriggerGuardSample ("TimeFilterRetriggerGuardS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"8000", ""},{"8", ""}}, ANSTYPE::INTEGER, "sample");
const Reg GateLongLengthSample ("GateLongLengthS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"4000", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
const Reg GateShortLengthSample ("GateShortLengthS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"4000", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
const Reg GateOffsetSample ("GateOffsetS", RW::ReadWrite, TYPE::CH, {{"0", ""},{"250", ""},{"1", ""}}, ANSTYPE::INTEGER, "sample");
const std::vector<Reg> AllSettings = {
SelfTrgRate , // 0
ChannelStatus , // 1
GainFactor , // 2
ADCToVolts , // 3
ChannelRealtime , // 4
ChannelDeadtime , // 5
ChannelTriggerCount , // 6
ChannelSavedCount , // 7
ChannelWaveCount , // 8
ChannelEnable , // 0
DC_Offset , // 1
TriggerThreshold , // 2
Polarity , // 3
WaveDataSource , // 4
RecordLength , // 5
PreTrigger , // 6
WaveSaving , // 7
WaveResolution , // 8
EventTriggerSource , // 9
ChannelsTriggerMask , // 10
ChannelVetoSource , // 11
WaveTriggerSource , // 12
EventSelector , // 13
WaveSelector , // 14
CoincidenceMask , // 15
AntiCoincidenceMask , // 16
CoincidenceLength , // 17
ADCVetoWidth , // 18
EnergySkimLowDiscriminator , // 19
EnergySkimHighDiscriminator, // 20
ITLConnect , // 21
EventNeutronReject ,
WaveNeutronReject ,
ADCInputBaselineAvg ,
AbsoluteBaseline ,
ADCInputBaselineGuard ,
SmoothingFactor ,
ChargeSmoothing ,
TimeFilterSmoothing ,
TriggerFilterSelection ,
CFDDelay ,
CFDFraction ,
TimeFilterRetriggerGuard ,
TriggerHysteresis ,
PileupGap ,
GateLongLength ,
GateShortLength ,
GateOffset ,
LongChargeIntegratorPedestal, //
ShortChargeIntegratorPedestal, //
EnergyGain ,
NeutronThreshold ,
WaveAnalogProbe0 , //
WaveAnalogProbe1 , //
WaveDigitalProbe0 , //
WaveDigitalProbe1 , //
WaveDigitalProbe2 , //
WaveDigitalProbe3 ,
SelfTriggerWidth ,
SignalOffset ,
ChGain
// RecordLengthSample , // 21
// PreTriggerSample , // 22
// CoincidenceLengthSample , //
// ADCInputBaselineGuardSample,
// CFDDelaySample ,
// TimeFilterRetriggerGuardSample,
// GateLongLengthSample ,
// GateShortLengthSample ,
// GateOffsetSample
};
}
};
#endif #endif

View File

@ -1,33 +1,54 @@
#ifndef EVENT_H #ifndef HIT_H
#define EVENT_H #define HIT_H
#include <stdio.h> #include <stdio.h>
#include <cstdlib> #include <cstdlib>
#include <stdint.h> #include <stdint.h>
#include <string>
#define MaxTraceLenght 8100 #define MaxTraceLenght 8100
class Event { enum DataFormat{
ALL = 0x00,
OneTrace = 0x01,
NoTrace = 0x02,
Minimum = 0x03,
MiniWithFineTime = 0x04,
Raw = 0x0A,
};
namespace DPPType{
const std::string PHA = "DPP_PHA";
const std::string PSD = "DPP_PSD";
};
class Hit {
public: public:
unsigned short dataType; unsigned short dataType;
std::string DPPType;
///============= for dpp-pha ///============= for dpp-pha
uint8_t channel; // 6 bit uint8_t channel; // 6 bit
uint16_t energy; // 16 bit uint16_t energy; // 16 bit
uint64_t timestamp; // 48 bit uint16_t energy_short; // 16 bit, only for PSD
uint16_t fine_timestamp; // 16 bit uint64_t timestamp; // 48 bit
uint16_t fine_timestamp; // 10 bit
uint16_t flags_low_priority; // 12 bit uint16_t flags_low_priority; // 12 bit
uint16_t flags_high_priority; // 8 bit uint16_t flags_high_priority; // 8 bit
size_t traceLenght; // 64 bit size_t traceLenght; // 64 bit
uint8_t downSampling; // 8 bit uint8_t downSampling; // 8 bit
bool board_fail; bool board_fail;
bool flush; bool flush;
uint8_t analog_probes_type[2]; // 3 bit uint8_t analog_probes_type[2]; // 3 bit for PHA, 4 bit for PSD
uint8_t digital_probes_type[4]; // 4 bit uint8_t digital_probes_type[4]; // 4 bit for PHA, 5 bit for PSD
int32_t * analog_probes[2]; // 18 bit int32_t * analog_probes[2]; // 18 bit
uint8_t * digital_probes[4]; // 1 bit uint8_t * digital_probes[4]; // 1 bit
uint16_t trigger_threashold; // 16 bit uint16_t trigger_threashold; // 16 bit
size_t event_size; // 64 bit size_t event_size; // 64 bit
uint32_t aggCounter; // 32 bit uint32_t aggCounter; // 32 bit
@ -38,17 +59,21 @@ class Event {
bool isTraceAllZero; bool isTraceAllZero;
Event(){ Hit(){
Init(); Init();
} }
~Event(){ ~Hit(){
ClearMemory(); ClearMemory();
} }
void Init(){ void Init(){
DPPType = DPPType::PHA;
dataType = DataFormat::ALL;
channel = 0; channel = 0;
energy = 0; energy = 0;
energy_short = 0;
timestamp = 0; timestamp = 0;
fine_timestamp = 0; fine_timestamp = 0;
downSampling = 0; downSampling = 0;
@ -91,11 +116,12 @@ class Event {
isTraceAllZero = true; isTraceAllZero = true;
} }
void SetDataType(unsigned int type){ void SetDataType(unsigned int type, std::string dppType){
dataType = type; dataType = type;
DPPType = dppType;
ClearMemory(); ClearMemory();
if( dataType == 0xF){ if( dataType == DataFormat::Raw){
data = new uint8_t[20*1024*1024]; data = new uint8_t[20*1024*1024];
}else{ }else{
analog_probes[0] = new int32_t[MaxTraceLenght]; analog_probes[0] = new int32_t[MaxTraceLenght];
@ -131,30 +157,64 @@ class Event {
} }
std::string AnaProbeType(uint8_t probeType){ std::string AnaProbeType(uint8_t probeType){
switch(probeType){
case 0: return "ADC"; if( DPPType == DPPType::PHA){
case 1: return "Time filter"; switch(probeType){
case 2: return "Energy filter"; case 0: return "ADC";
default : return "none"; case 1: return "Time filter";
case 2: return "Energy filter";
default : return "none";
}
}else if (DPPType == DPPType::PSD){
switch(probeType){
case 0: return "ADC";
case 9: return "Baseline";
case 10: return "CFD";
default : return "none";
}
}else{
return "none";
} }
} }
std::string DigiProbeType(uint8_t probeType){ std::string DigiProbeType(uint8_t probeType){
switch(probeType){
case 0: return "Trigger"; if( DPPType == DPPType::PHA){
case 1: return "Time filter armed"; switch(probeType){
case 2: return "Re-trigger guard"; case 0: return "Trigger";
case 3: return "Energy filter baseline freeze"; case 1: return "Time filter armed";
case 4: return "Energy filter peaking"; case 2: return "Re-trigger guard";
case 5: return "Energy filter peaking ready"; case 3: return "Energy filter baseline freeze";
case 6: return "Energy filter pile-up guard"; case 4: return "Energy filter peaking";
case 7: return "Event pile-up"; case 5: return "Energy filter peaking ready";
case 8: return "ADC saturation"; case 6: return "Energy filter pile-up guard";
case 9: return "ADC saturation protection"; case 7: return "Event pile-up";
case 10: return "Post-saturation event"; case 8: return "ADC saturation";
case 11: return "Energy filter saturation"; case 9: return "ADC saturation protection";
case 12: return "Signal inhibit"; case 10: return "Post-saturation event";
default : return "none"; case 11: return "Energy filter saturation";
case 12: return "Signal inhibit";
default : return "none";
}
}else if (DPPType == DPPType::PSD){
switch(probeType){
case 0: return "Trigger";
case 1: return "CFD Filter Armed";
case 2: return "Re-trigger guard";
case 3: return "ADC Input Baseline freeze";
case 20: return "ADC Input OverThreshold";
case 21: return "Charge Ready";
case 22: return "Long Gate";
case 7: return "Pile-Up Trig.";
case 24: return "Short Gate";
case 25: return "Energy Saturation";
case 26: return "Charge over-range";
case 27: return "ADC Input Neg. OverThreshold";
default : return "none";
}
}else{
return "none";
} }
} }
@ -176,9 +236,20 @@ class Event {
//TODO LowPriority //TODO LowPriority
void PrintAll(){ void PrintAll(){
printf("============= Type : %u\n", dataType);
switch(dataType){
case DataFormat::ALL : printf("============= Type : ALL\n"); break;
case DataFormat::OneTrace : printf("============= Type : OneTrace\n"); break;
case DataFormat::NoTrace : printf("============= Type : NoTrace\n"); break;
case DataFormat::MiniWithFineTime : printf("============= Type : Min with FineTimestamp\n"); break;
case DataFormat::Minimum : printf("============= Type : Minimum\n"); break;
case DataFormat::Raw : printf("============= Type : Raw\n"); return; break;
default : return;
}
printf("ch : %2d (0x%02X), fail: %d, flush: %d\n", channel, channel, board_fail, flush); printf("ch : %2d (0x%02X), fail: %d, flush: %d\n", channel, channel, board_fail, flush);
printf("energy: %u, timestamp: %lu, fine_timestamp: %u \n", energy, timestamp, fine_timestamp); if( DPPType == DPPType::PHA ) printf("energy: %u, timestamp: %lu, fine_timestamp: %u \n", energy, timestamp, fine_timestamp);
if( DPPType == DPPType::PSD ) printf("energy: %u, energy_S : %u, timestamp: %lu, fine_timestamp: %u \n", energy, energy_short, timestamp, fine_timestamp);
printf("flag (high): 0x%02X, (low): 0x%03X, traceLength: %lu\n", flags_high_priority, flags_low_priority, traceLenght); printf("flag (high): 0x%02X, (low): 0x%03X, traceLength: %lu\n", flags_high_priority, flags_low_priority, traceLenght);
printf("Agg counter : %u, trigger Thr.: %u, downSampling: %u \n", aggCounter, trigger_threashold, downSampling); printf("Agg counter : %u, trigger Thr.: %u, downSampling: %u \n", aggCounter, trigger_threashold, downSampling);
printf("AnaProbe Type: %s(%u), %s(%u)\n", AnaProbeType(analog_probes_type[0]).c_str(), analog_probes_type[0], printf("AnaProbe Type: %s(%u), %s(%u)\n", AnaProbeType(analog_probes_type[0]).c_str(), analog_probes_type[0],
@ -200,14 +271,22 @@ class Event {
} }
} }
void PrintAllTrace(){ void PrintTrace(){
for(unsigned short i = 0; i < (unsigned short)traceLenght; i++){ printf("---------- trace length : %zu\n", traceLenght);
printf("%4d| %6d %6d %1d %1d %1d %1d\n", i, analog_probes[0][i], if( dataType == DataFormat::OneTrace ){
analog_probes[1][i], for(unsigned short i = 0; i < (unsigned short)traceLenght; i++){
digital_probes[0][i], printf("%4d| %6d\n", i, analog_probes[0][i]);
digital_probes[1][i], }
digital_probes[2][i], }
digital_probes[3][i]); if( dataType == DataFormat::ALL){
for(unsigned short i = 0; i < (unsigned short)traceLenght; i++){
printf("%4d| %6d %6d %1d %1d %1d %1d\n", i, analog_probes[0][i],
analog_probes[1][i],
digital_probes[0][i],
digital_probes[1][i],
digital_probes[2][i],
digital_probes[3][i]);
}
} }
} }

674
LICENSE Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -1,17 +1,85 @@
# Architecture
The core digitizer control classes are independent from the UI classes
## Core digitizer class/files
- Event.h
- DigiParameters.h
- ClassDigitizer2Gen.h/cpp
The test.cpp is a demo code to use the ClassDigitizer2Gen.h/cpp.
## Auxillary classes
- influxdb.h/cpp
## UI classes/files
- main.cpp
- mainwindow.h/cpp
- digiSettingsPanel.h/cpp
- CustomWidget.h
- CustomThreads.h
- scope.h/cpp
- SOLARISpanel.h/cpp
## Other files
- makeTest
- test.cpp
- script.C
- SolReader.h
- windowID.cpp
## Wiki
https://fsunuc.physics.fsu.edu/wiki/index.php/FRIB_SOLARIS_Collaboration
# Additional function
## connect to analysis working directory
When the analysis path is set, it will do servera things
- save the expName.sh
- save Settings
- try to load the Mapping.h in the working directory
## End run bash script
When run stop, it will run the bash script under the directory scripts/endRUnScript.h
# Required / Development enviroment # Required / Development enviroment
Ubuntu 22.04 Ubuntu 22.04
CAEN_DIG2_v1.5.3 CAEN_FELIB_v1.2.2 + (install first)
CAEN_FELIB_v1.2.2 CAEN_DIG2_v1.5.3 +
`sudo apt install qt6-base-dev libcurl4-openssl-dev libqt6charts6-dev` `sudo apt install qt6-base-dev libcurl4-openssl-dev libqt6charts6-dev`
Digitizer firmware V2745-dpp-pha-2022092903.cup Digitizer firmware V2745-dpp-pha-2022092903.cup
## Developer is using these at 2023-Oct-13
CAEN_FELIB_v1.2.5
CAEN_DIG2_v1.5.10
with these new API, Digitizer firmwares
* V2745-dpp-pha-1G-2023091800.cup
* V2745-dpp-psd-1G-2023091901.cup
* V2740-dpp-pha-1G-2023091800.cup
* V2740-dpp-psd-1G-2023091901.cup
are supported.
# Compile # Compile
## if *.pro does not exist
use `qmake6 -project ` to generate the *.pro use `qmake6 -project ` to generate the *.pro
in the *.pro, add in the *.pro, add
@ -20,6 +88,28 @@ in the *.pro, add
` LIBS += -lcurl -lCAEN_FELib` ` LIBS += -lcurl -lCAEN_FELib`
then run ` qmake6 *.pro` it will generate Makefile ## if *.pro exist
run ` qmake6 *.pro` it will generate Makefile
then ` make` then ` make`
# Using the CAENDig2.h
The CAENDig2.h is not copied to system include path as the CAEN+FELib.h. But we can copy it from the source. In the caen_dig2-vXXXX folder, go to the include folder, copy the CAENDig2.h to /usr/local/include/.
This enable us to compile code with -lCAEN_Dig2. For example, we can use the following to get the CAEN Dig2 Library version.
```
char version[16];
CAENDig2_GetLibVersion(version);
puts(version);
```
# Known Issues
- The "Trig." Rate in the Scaler does not included the coincident condition. This is related to the ChSavedEventCnt from the firmware.
- LVDSTrgMask cannot acess.
- The CoincidenceLengthT not loaded.
- Sometime, the digitizer halt after sent the /cmd/armacquisition command. This is CAEN library problem.
- Event/Wave trig. Source cannot set as SWTrigger.
- After update to CAEN_FELIB_v1.2.5 and CAEN_DIG2_v1.5.10, old firmware version before 202309XXXX is not supported.

View File

@ -10,6 +10,11 @@ QT += widgets charts
LIBS += -lcurl -lCAEN_FELib -lX11 LIBS += -lcurl -lCAEN_FELib -lX11
#=========== for GDB debug
QMAKE_CXXFLAGS += -g # for gdb debug
QMAKE_CXXFLAGS_RELEASE = -O0
QMAKE_CFLAGS_RELEASE = -O0
# You can make your code fail to compile if you use deprecated APIs. # You can make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line. # In order to do so, uncomment the following line.
# Please consult the documentation of the deprecated API in order to know # Please consult the documentation of the deprecated API in order to know
@ -18,5 +23,22 @@ LIBS += -lcurl -lCAEN_FELib -lX11
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Input # Input
HEADERS += ClassDigitizer2Gen.h Event.h influxdb.h mainwindow.h digiSettingsPanel.h Digiparameters.h scope.h manyThread.h CustomWidgets.h macro.h SOLARISpanel.h HEADERS += ClassDigitizer2Gen.h \
SOURCES += ClassDigitizer2Gen.cpp influxdb.cpp main.cpp mainwindow.cpp digiSettingsPanel.cpp scope.cpp SOLARISpanel.cpp Hit.h \
ClassInfluxDB.h \
mainwindow.h \
digiSettingsPanel.h \
Digiparameters.h \
scope.h \
CustomThreads.h \
CustomWidgets.h \
macro.h \
SOLARISpanel.h
SOURCES += ClassDigitizer2Gen.cpp \
ClassInfluxDB.cpp \
main.cpp \
mainwindow.cpp \
digiSettingsPanel.cpp \
scope.cpp \
SOLARISpanel.cpp

View File

@ -9,13 +9,16 @@
#define NCOL 10 // number of column #define NCOL 10 // number of column
#define ChStartIndex 2 // the index of detIDList for channel
std::vector<Reg> SettingItems = {PHA::CH::TriggerThreshold, PHA::CH::DC_Offset}; std::vector<Reg> SettingItems = {PHA::CH::TriggerThreshold, PHA::CH::DC_Offset};
const std::vector<QString> arrayLabel = {"e", "xf", "xn"};
SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi, SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
QString analysisPath, QString analysisPath,
std::vector<std::vector<int>> mapping, std::vector<std::vector<int>> mapping,
QStringList detType, QStringList detType,
QStringList detGroupName,
std::vector<int> detGroupID,
std::vector<int> detMaxID, std::vector<int> detMaxID,
QWidget *parent) : QWidget(parent){ QWidget *parent) : QWidget(parent){
@ -25,72 +28,97 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
this->digi = digi; this->digi = digi;
this->nDigi = nDigi; this->nDigi = nDigi;
if( this->nDigi > MaxNumberOfDigitizer ) { if( this->nDigi > MaxNumberOfDigitizer ) {
this->nDigi = MaxNumberOfChannel; this->nDigi = MaxNumberOfDigitizer;
qDebug() << "Please increase the MaxNumberOfChannel"; qDebug() << "Please increase the MaxNumberOfChannel";
} }
this->mapping = mapping; this->mapping = mapping;
this->detType = detType; this->detTypeNameList = detType;
this->detMaxID = detMaxID; this->detMaxID = detMaxID;
this->detGroupID = detGroupID;
this->detGroupNameList = detGroupName;
this->digiSettingPath = analysisPath + "/working/Settings/"; this->digiSettingPath = analysisPath + "/working/Settings/";
//Check number of detector type; Array 0-199, Recoil 200-299, other 300- //Check number of detector type; Array 0-199, Recoil 200-299, other 300-
int nDetType = detType.size(); int nDetType = detTypeNameList.size();
for( int k = 0 ; k < nDetType; k++) nDet.push_back(0); for( int k = 0 ; k < nDetType; k++) nDetinType.push_back(0);
QList<QList<int>> detIDListTemp; // store { detID, (Digi << 8 ) + ch}, making mapping into 1-D array to be consolidated std::vector<int> condenGroupID = detGroupID;
std::sort(condenGroupID.begin(), condenGroupID.end()); // sort the detGroupID
auto last = std::unique(condenGroupID.begin(), condenGroupID.end());
condenGroupID.erase(last, condenGroupID.end());
int nDetGroup = condenGroupID.size();
for( int k = 0 ; k < nDetGroup; k++) nDetinGroup.push_back(0);
QList<QList<int>> detIDListTemp; // store { detGroup, detID, (Digi << 8 ) + ch}, making mapping into 1-D array to be consolidated
printf("################################# \n"); printf("################################# \n");
for( int i = 0; i < (int) mapping.size() ; i++){ for( int i = 0; i < (int) mapping.size() ; i++){
for( int j = 0; j < (int) mapping[i].size(); j++ ){ for( int j = 0; j < (int) mapping[i].size(); j++ ){
printf("%3d,", mapping[i][j]); printf("%4d,", mapping[i][j]);
QList<int> haha ; if( mapping[i][j] >= 0 ) {
haha << mapping[i][j] << ((i << 8 ) + j); int groupID = FindDetGroup(mapping[i][j]);
if( mapping[i][j] >= 0 ) detIDListTemp << haha; int typeID = FindDetTypeID(mapping[i][j]);
QList<int> haha ;
haha << groupID << mapping[i][j] << ((i << 8 ) + j);
detIDListTemp << haha;
nDetinType[typeID] ++;
nDetinGroup[groupID] ++;
}
if( j % 16 == 15 ) printf("\n"); if( j % 16 == 15 ) printf("\n");
} }
printf("------------------ \n"); printf("------------------ \n");
} }
//----- consolidate detIDList; //consolidate detIDListTemp --> 2D array of (detID, (Digi << 8) + ch, +.... )
detIDList.clear(); //for example, {2, 0, 0}, {2, 100, 1}, {2, 200, 2}--> {2, 0, 0, 1, 2};
//for example, {2, 1, 3}, {2, 101, 4}, {2, 201, 5}--> {2, 0, 3, 4, 5};
detIDArrayList.clear();
bool repeated = false; bool repeated = false;
for( int i = 0; i < detIDListTemp.size(); i++ ){ for( int i = 0; i < detIDListTemp.size(); i++ ){
repeated = false; repeated = false;
if( detIDList.size() == 0 ){ if( detIDArrayList.size() == 0 ){
detIDList << detIDListTemp[i]; detIDArrayList << detIDListTemp[i];
for( int k = 0 ; k < nDetType; k++){
int lowID = (k == 0 ? 0 : detMaxID[k-1]);
if( lowID <= detIDListTemp[i][0] && detIDListTemp[i][0] < detMaxID[k] ) nDet[k] ++ ;
}
continue; continue;
} }
for( int j = 0; j < detIDList.size() ; j++){ for( int j = 0; j < detIDArrayList.size() ; j++){
if( detIDList[j][0] == detIDListTemp[i][0] ) { if( detIDArrayList[j][0] == detIDListTemp[i][0] ) { // same group
repeated = true;
detIDList[j] << detIDListTemp[i][1]; int type1 = FindDetTypeID(detIDArrayList[j][1]);
break; int type2 = FindDetTypeID(detIDListTemp[i][1]);
int low1 = (type1 == 0 ? 0 : detMaxID[type1-1]);
int low2 = (type2 == 0 ? 0 : detMaxID[type2-1]);
int detID1 = detIDArrayList[j][1] - low1;
int detID2 = detIDListTemp[i][1] - low2;
if( detID1 == detID2) {
repeated = true;
detIDArrayList[j] << detIDListTemp[i][2];
break;
}
} }
} }
if( !repeated ) { if( !repeated ) {
detIDList << detIDListTemp[i]; detIDArrayList << detIDListTemp[i];
for( int k = 0 ; k < nDetType; k++){
int lowID = (k == 0 ? 0 : detMaxID[k-1]);
if( lowID <= detIDListTemp[i][0] && detIDListTemp[i][0] < detMaxID[k] ) nDet[k] ++ ;
}
} }
} }
//---- sort detIDList; //---- sort detIDList;
std::sort(detIDList.begin(), detIDList.end(), [](const QList<int>& a, const QList<int>& b) { std::sort(detIDArrayList.begin(), detIDArrayList.end(), [](const QList<int>& a, const QList<int>& b) {
return a.at(0) < b.at(0); return a.at(1) < b.at(1);
}); });
//------------- display detector summary //------------- display detector summary
//qDebug() << detIDList; //qDebug() << detIDList;
printf("---------- num. of det. Type : %d\n", nDetType); printf("---------- num. of det. Type : %d\n", nDetType);
for( int i =0; i < nDetType; i ++ ) { for( int i =0; i < nDetType; i ++ ) {
printf(" Type-%d (%6s) : %3d det. (%3d - %3d)\n", i, detType[i].toStdString().c_str(), nDet[i], (i==0 ? 0 : detMaxID[i-1]), detMaxID[i]-1); detType[i].remove(' ');
printf(" Type-%d (%6s) : %3d det. (%3d - %3d)\n", i, detType[i].toStdString().c_str(), nDetinType[i], (i==0 ? 0 : detMaxID[i-1]), detMaxID[i]-1);
}
printf("---------- num. of det. Group : %d\n", nDetGroup);
for( int i =0; i < nDetGroup; i++){
printf(" Group-%d (%10s) : %3d det.\n", i, detGroupName[i].toStdString().c_str(), nDetinGroup[i]);
} }
//---------- Set Panel //---------- Set Panel
@ -122,6 +150,7 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
sbCoinTime->SetToolTip(atof(PHA::CH::CoincidenceLength.GetAnswers()[1].first.c_str())); sbCoinTime->SetToolTip(atof(PHA::CH::CoincidenceLength.GetAnswers()[1].first.c_str()));
mainLayout->addWidget(sbCoinTime, rowIndex, 8, 1, 2); mainLayout->addWidget(sbCoinTime, rowIndex, 8, 1, 2);
connect(sbCoinTime, &RSpinBox::valueChanged, this, [=](){ connect(sbCoinTime, &RSpinBox::valueChanged, this, [=](){
if( !enableSignalSlot ) return; if( !enableSignalSlot ) return;
sbCoinTime->setStyleSheet("color:blue;"); sbCoinTime->setStyleSheet("color:blue;");
@ -156,14 +185,17 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
rowIndex ++; rowIndex ++;
QLabel * info = new QLabel("Only simple trigger is avalible. For complex trigger scheme, please use the setting panel.", this); QLabel * info = new QLabel("Only simple trigger is avalible. For complex trigger scheme, please use the setting panel.", this);
mainLayout->addWidget(info, rowIndex, 0, 1, 4); mainLayout->addWidget(info, rowIndex, 0, 1, 4);
rowIndex ++;
QLabel * info2 = new QLabel("The panel is defined by " + analysisPath + "/working/Mapping.h", this);
mainLayout->addWidget(info2, rowIndex, 0, 1, 4);
///================================= ///=================================
rowIndex ++; rowIndex ++;
QTabWidget * tabWidget = new QTabWidget(this); mainLayout->addWidget(tabWidget, rowIndex, 0, 1, 10); QTabWidget * tabWidget = new QTabWidget(this); mainLayout->addWidget(tabWidget, rowIndex, 0, 1, 10);
for( int detTypeID = 0; detTypeID < nDetType; detTypeID ++ ){ for( int detGroup = 0; detGroup < nDetGroup; detGroup ++ ){
QTabWidget * tabSetting = new QTabWidget(tabWidget); QTabWidget * tabSetting = new QTabWidget(tabWidget);
tabWidget->addTab(tabSetting, detType[detTypeID]); tabWidget->addTab(tabSetting, detGroupName[detGroup]);
for( int SettingID = 0; SettingID < (int) SettingItems.size(); SettingID ++){ for( int SettingID = 0; SettingID < (int) SettingItems.size(); SettingID ++){
@ -179,13 +211,19 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
layout->setAlignment(Qt::AlignLeft|Qt::AlignTop); layout->setAlignment(Qt::AlignLeft|Qt::AlignTop);
layout->setSpacing(0); layout->setSpacing(0);
chkAll[detTypeID][SettingID] = new QCheckBox("Set for all", tab); chkAll[detGroup][SettingID] = new QCheckBox("Set for all", tab);
layout->addWidget(chkAll[detTypeID][SettingID], 0, 0); layout->addWidget(chkAll[detGroup][SettingID], 0, 0);
connect(chkAll[detTypeID][SettingID], &QCheckBox::stateChanged, this, [=](bool state){
int lowID = (detTypeID == 0 ? 0 : detMaxID[detTypeID-1]); connect(chkAll[detGroup][SettingID], &QCheckBox::stateChanged, this, [=](bool state){
for(int i = 1; i < detIDList.size(); i++){ bool found = false;
if( detIDList[i][0] >= detMaxID[detTypeID] || lowID > detIDList[i][0] ) continue; for(int i = 0; i < detIDArrayList.size(); i++){
groupBox[detTypeID][SettingID][detIDList[i][0]]->setEnabled(!state); if( detIDArrayList[i][0] != detGroup ) continue;
if( found == false ){
found = true;
continue;
}else{
groupBox[detGroup][SettingID][detIDArrayList[i][1]]->setEnabled(!state);
}
} }
}); });
@ -195,19 +233,16 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
line->setFixedHeight(10); line->setFixedHeight(10);
layout->addWidget(line, 1, 0, 1, NCOL); layout->addWidget(line, 1, 0, 1, NCOL);
//range of detID for(int i = 0; i < detIDArrayList.size(); i++){
int lowID = (detTypeID == 0 ? 0 : detMaxID[detTypeID-1]); if( detIDArrayList[i][0] != detGroup ) continue;
CreateDetGroup(SettingID, detIDArrayList[i], layout, i/NCOL + 2, i%NCOL);
for(int i = 0; i < detIDList.size(); i++){
if( detIDList[i][0] >= detMaxID[detTypeID] || lowID > detIDList[i][0] ) continue;
CreateDetGroup(detTypeID, SettingID, detIDList[i], layout, i/NCOL + 2, i%NCOL);
} }
} }
} }
enableSignalSlot = true;
} }
SOLARISpanel::~SOLARISpanel(){ SOLARISpanel::~SOLARISpanel(){
@ -215,43 +250,59 @@ SOLARISpanel::~SOLARISpanel(){
} }
//^###################################################################### //^######################################################################
int SOLARISpanel::FindDetTypeID(QList<int> detIDListElement){ int SOLARISpanel::FindDetTypeID(int detID){
for( int i = 0; i < (int) detType.size(); i++){ for( int i = 0; i < (int) detTypeNameList.size(); i++){
int lowID = (i == 0) ? 0 : detMaxID[i-1]; int lowID = (i == 0) ? 0 : detMaxID[i-1];
if( lowID <= detIDListElement[0] && detIDListElement[0] < detMaxID[i]) { if( lowID <= detID && detID < detMaxID[i]) {
return i; return i;
} }
} }
return -1; return -1;
} }
void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID, QGridLayout * &layout, int row, int col){ int SOLARISpanel::FindDetGroup(int detID){
int typeID = FindDetTypeID(detID);
if( typeID == -1) return -999;
return detGroupID[typeID];
}
//QGroupBox * groupbox = new QGroupBox("Det-" + QString::number(detID[0]), this); void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detIDArray, QGridLayout * &layout, int row, int col){
groupBox[detTypeID][SettingID][detID[0]] = new QGroupBox("Det-" + QString::number(detID[0]), this);
groupBox[detTypeID][SettingID][detID[0]]->setFixedWidth(130); int detGroup = detIDArray[0];
groupBox[detTypeID][SettingID][detID[0]]->setAlignment(Qt::AlignCenter); int detID = detIDArray[1];
QGridLayout * layout0 = new QGridLayout(groupBox[detTypeID][SettingID][detID[0]]);
groupBox[detGroup][SettingID][detID] = new QGroupBox("Det-" + QString::number(detID), this);
groupBox[detGroup][SettingID][detID]->setFixedWidth(130);
groupBox[detGroup][SettingID][detID]->setAlignment(Qt::AlignCenter);
QGridLayout * layout0 = new QGridLayout(groupBox[detGroup][SettingID][detID]);
layout0->setSpacing(0); layout0->setSpacing(0);
layout0->setAlignment(Qt::AlignLeft); layout0->setAlignment(Qt::AlignLeft);
//@======================================== SpinBox and Display //@======================================== SpinBox and Display
bool isDisableDetector = false; bool isDisableDetector = false;
for( int chIndex = 1; chIndex < (int) detID.size(); chIndex ++){
int nChInGroupBox = 0;
for( int ppp = ChStartIndex; ppp < detIDArray.size(); ppp ++){
int chIndex = ppp - ChStartIndex;
isDisableDetector = false; isDisableDetector = false;
nChInGroupBox ++;
QLabel * lb = new QLabel(arrayLabel[chIndex-1], this); int digiID = (detIDArray[ppp] >> 8 );
int chID = (detIDArray[ppp] & 0xFF);
int typeID = FindDetTypeID(mapping[digiID][chID]);
QLabel * lb = new QLabel(detTypeNameList[typeID].remove(' '), this);
layout0->addWidget(lb, 2*chIndex, 0, 2, 1); layout0->addWidget(lb, 2*chIndex, 0, 2, 1);
int digiID = (detID[chIndex] >> 8 );
int chID = (detID[chIndex] & 0xFF);
chkOnOff[SettingID][digiID][chID] = new QCheckBox(this); chkOnOff[SettingID][digiID][chID] = new QCheckBox(this);
layout0->addWidget(chkOnOff[SettingID][digiID][chID], 2*chIndex, 1, 2, 1); layout0->addWidget(chkOnOff[SettingID][digiID][chID], 2*chIndex, 1, 2, 1);
leDisplay[SettingID][digiID][chID] = new QLineEdit(this); leDisplay[SettingID][digiID][chID] = new QLineEdit(this);
leDisplay[SettingID][digiID][chID]->setFixedWidth(70); leDisplay[SettingID][digiID][chID]->setFixedWidth(70);
leDisplay[SettingID][digiID][chID]->setReadOnly(true);
leDisplay[SettingID][digiID][chID]->setStyleSheet("color : green;");
layout0->addWidget(leDisplay[SettingID][digiID][chID], 2*chIndex, 2); layout0->addWidget(leDisplay[SettingID][digiID][chID], 2*chIndex, 2);
sbSetting[SettingID][digiID][chID] = new RSpinBox(this); sbSetting[SettingID][digiID][chID] = new RSpinBox(this);
@ -262,7 +313,6 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
sbSetting[SettingID][digiID][chID]->setMinimum(atoi(SettingItems[SettingID].GetAnswers()[0].first.c_str())); sbSetting[SettingID][digiID][chID]->setMinimum(atoi(SettingItems[SettingID].GetAnswers()[0].first.c_str()));
sbSetting[SettingID][digiID][chID]->setMaximum(atoi(SettingItems[SettingID].GetAnswers()[1].first.c_str())); sbSetting[SettingID][digiID][chID]->setMaximum(atoi(SettingItems[SettingID].GetAnswers()[1].first.c_str()));
sbSetting[SettingID][digiID][chID]->setSingleStep(atoi(SettingItems[SettingID].GetAnswers()[2].first.c_str())); sbSetting[SettingID][digiID][chID]->setSingleStep(atoi(SettingItems[SettingID].GetAnswers()[2].first.c_str()));
sbSetting[SettingID][digiID][chID]->SetToolTip();
layout0->addWidget(sbSetting[SettingID][digiID][chID], 2*chIndex+1, 2); layout0->addWidget(sbSetting[SettingID][digiID][chID], 2*chIndex+1, 2);
@ -291,19 +341,21 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
spb->setValue( (std::round(value/step) * step) ); spb->setValue( (std::round(value/step) * step) );
} }
if( chkAll[detTypeID][SettingID]->isChecked() ){ if( chkAll[detGroup][SettingID]->isChecked() ){
for(int k = 0; k < detIDList.size() ; k++){ for(int k = 0; k < detIDArrayList.size() ; k++){
if( detTypeID == FindDetTypeID(detIDList[k]) ){ if( detGroup == detIDArrayList[k][0] ){
for( int h = 1; h < detIDList[k].size() ; h++){ for( int h = ChStartIndex; h < detIDArrayList[k].size() ; h++){
if( h != chIndex) continue; if( h != chIndex + ChStartIndex) continue;
int index = (detIDList[k][h] & 0xFF); int digiK = (detIDArrayList[k][h] >> 8);
if( digiK >= nDigi ) continue;
int index = (detIDArrayList[k][h] & 0xFF);
QString msg; QString msg;
msg = QString::fromStdString(para.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber()); msg = QString::fromStdString(para.GetPara()) + "|DIG:"+ QString::number(digi[digiK]->GetSerialNumber());
msg += ",CH:" + QString::number(index) + "(" + arrayLabel[chIndex-1] + ")"; msg += ",CH:" + QString::number(index) + "(" + detTypeNameList[typeID] + ")";
msg += " = " + QString::number(spb->value()); msg += " = " + QString::number(spb->value());
if( digi[digiID]->WriteValue(para, std::to_string(spb->value()), index)){ if( digi[digiK]->WriteValue(para, std::to_string(spb->value()), index)){
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
spb->setStyleSheet(""); spb->setStyleSheet("");
}else{ }else{
@ -316,7 +368,7 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
}else{ }else{
QString msg; QString msg;
msg = QString::fromStdString(para.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber()); msg = QString::fromStdString(para.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber());
msg += ",CH:" + QString::number(chID) + "(" + arrayLabel[chIndex-1] + ")"; msg += ",CH:" + QString::number(chID) + "(" + detTypeNameList[typeID] + ")";
msg += " = " + QString::number(spb->value()); msg += " = " + QString::number(spb->value());
if( digi[digiID]->WriteValue(para, std::to_string(spb->value()), chID)){ if( digi[digiID]->WriteValue(para, std::to_string(spb->value()), chID)){
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
@ -334,26 +386,28 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
connect(chkOnOff[SettingID][digiID][chID], &QCheckBox::stateChanged, this, [=](int state){ connect(chkOnOff[SettingID][digiID][chID], &QCheckBox::stateChanged, this, [=](int state){
if( !enableSignalSlot ) return; if( !enableSignalSlot ) return;
if( chkAll[detTypeID][SettingID]->isChecked() ){ if( chkAll[detGroup][SettingID]->isChecked() ){
for(int k = 0; k < detIDList.size() ; k++){
if( detTypeID == FindDetTypeID(detIDList[k]) ){
for( int h = 1; h < detIDList[k].size() ; h++){
if( h != chIndex) continue;
int index = (detIDList[k][h] & 0xFF);
for(int k = 0; k < detIDArrayList.size() ; k++){
if( detGroup == detIDArrayList[k][0] ){
for( int h = ChStartIndex; h < detIDArrayList[k].size() ; h++){
if( h != chIndex + ChStartIndex) continue;
int digiK = (detIDArrayList[k][h] >> 8);
if( digiK >= nDigi ) continue;
int index = (detIDArrayList[k][h] & 0xFF);
QString msg; QString msg;
msg = QString::fromStdString(PHA::CH::ChannelEnable.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber()); msg = QString::fromStdString(PHA::CH::ChannelEnable.GetPara()) + "|DIG:"+ QString::number(digi[digiK]->GetSerialNumber());
msg += ",CH:" + QString::number(index) + "(" + arrayLabel[chIndex-1] + ")"; msg += ",CH:" + QString::number(index) + "(" + detTypeNameList[typeID] + ")";
msg += ( state ? " = True" : " = False"); msg += ( state ? " = True" : " = False");
if( digi[digiID]->WriteValue(PHA::CH::ChannelEnable, state ? "True" : "False", index)){ if( digi[digiK]->WriteValue(PHA::CH::ChannelEnable, state ? "True" : "False", index)){
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
enableSignalSlot = false; enableSignalSlot = false;
for( int k = 0; k < (int) detType.size(); k++){
leDisplay[k][digiID][index]->setEnabled(state); leDisplay[detGroup][digiK][index]->setEnabled(state);
sbSetting[k][digiID][index]->setEnabled(state); sbSetting[detGroup][digiK][index]->setEnabled(state);
chkOnOff[k][digiID][index]->setChecked(state); chkOnOff [detGroup][digiK][index]->setChecked(state);
}
enableSignalSlot = true; enableSignalSlot = true;
}else{ }else{
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
@ -361,20 +415,22 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
} }
} }
} }
}else{ }else{
QString msg; QString msg;
msg = QString::fromStdString(PHA::CH::ChannelEnable.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber()); msg = QString::fromStdString(PHA::CH::ChannelEnable.GetPara()) + "|DIG:"+ QString::number(digi[digiID]->GetSerialNumber());
msg += ",CH:" + QString::number(chID) + "(" + arrayLabel[chIndex-1] + ")";
msg += ",CH:" + QString::number(chID) + "(" + detTypeNameList[typeID] + ")";
msg += ( state ? " = True" : " = False"); msg += ( state ? " = True" : " = False");
qDebug() << msg;
if( digi[digiID]->WriteValue(PHA::CH::ChannelEnable, state ? "True" : "False", chID)){ if( digi[digiID]->WriteValue(PHA::CH::ChannelEnable, state ? "True" : "False", chID)){
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
enableSignalSlot = false; enableSignalSlot = false;
for( int k = 0; k < (int) detType.size(); k++){ leDisplay[detGroup][digiID][chID]->setEnabled(state);
leDisplay[k][digiID][chID]->setEnabled(state); sbSetting[detGroup][digiID][chID]->setEnabled(state);
sbSetting[k][digiID][chID]->setEnabled(state); chkOnOff [detGroup][digiID][chID]->setChecked(state);
chkOnOff[k][digiID][chID]->setChecked(state);
}
enableSignalSlot = true; enableSignalSlot = true;
}else{ }else{
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
@ -402,33 +458,40 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
// 6, CoincidenceLengthT in ns, set to be 100 ns. // 6, CoincidenceLengthT in ns, set to be 100 ns.
if( SettingItems[SettingID].GetPara() == PHA::CH::TriggerThreshold.GetPara()){ if( SettingItems[SettingID].GetPara() == PHA::CH::TriggerThreshold.GetPara()){
cbTrigger[detTypeID][detID[0]] = new RComboBox(this); cbTrigger[detGroup][detID] = new RComboBox(this);
cbTrigger[detTypeID][detID[0]]->addItem("Self Trigger", "ChSelfTrigger"); /// no coincident cbTrigger[detGroup][detID]->addItem("Self Trigger", "ChSelfTrigger"); /// no coincident
cbTrigger[detTypeID][detID[0]]->addItem("Trigger e", 0x1); // Self-trigger and coincient Ch64Trigger cbTrigger[detGroup][detID]->addItem("Trigger e", 0x1); // Self-trigger and coincient Ch64Trigger
cbTrigger[detTypeID][detID[0]]->addItem("Ext. Trigger", "TRGIN"); // with coincident with TRGIN. cbTrigger[detGroup][detID]->addItem("Ext. Trigger", "TRGIN"); // with coincident with TRGIN.
cbTrigger[detTypeID][detID[0]]->addItem("Disabled", "Disabled"); // no Trigger, no coincident, basically channel still alive, but no recording cbTrigger[detGroup][detID]->addItem("Disabled", "Disabled"); // no Trigger, no coincident, basically channel still alive, but no recording
cbTrigger[detTypeID][detID[0]]->addItem("Others", -999); // other settings cbTrigger[detGroup][detID]->addItem("Others", -999); // other settings
layout0->addWidget(cbTrigger[detTypeID][detID[0]], 8, 0, 1, 3); layout0->addWidget(cbTrigger[detGroup][detID], 2*nChInGroupBox, 0, 1, 3);
if( isDisableDetector ) cbTrigger[detTypeID][detID[0]]->setEnabled(false); if( isDisableDetector ) cbTrigger[detGroup][detID]->setEnabled(false);
//*========== connection //*========== connection
connect(cbTrigger[detTypeID][detID[0]], &RComboBox::currentIndexChanged, this , [=](int index){ connect(cbTrigger[detGroup][detID], &RComboBox::currentIndexChanged, this , [=](int index){
if( !enableSignalSlot) return; if( !enableSignalSlot) return;
if( chkAll[detTypeID][SettingID]->isChecked() ){ if( cbTrigger[detGroup][detID]->itemData(index).toInt() == -999 ) return;
for( int gg = 0; gg < nDet[detTypeID]; gg++){
if( gg == detID[0] ) continue; if( chkAll[detGroup][SettingID]->isChecked() ){
cbTrigger[detTypeID][gg]->setCurrentIndex(index);
for( int k = 0; k < detIDArrayList.size(); k++){
if( detIDArrayList[k][0] != detGroup ) continue;
int haha = detIDArrayList[k][1];
if( haha == detID )continue;
cbTrigger[detGroup][haha]->setCurrentIndex(index);
} }
} }
///----------- single ///----------- single
for( int i = 1; i < detID.size(); i++){ for( int i = ChStartIndex ; i < detIDArray.size(); i++){
int digiID = (detID[i] >> 8 ); int digiID = (detIDArray[i] >> 8 );
int chID = (detID[i] & 0xFF); if( digiID >= nDigi) continue;
int chID = (detIDArray[i] & 0xFF);
if( digi[digiID]->IsDummy() || !digi[digiID]->IsConnected() ) continue; if( digi[digiID]->IsDummy() || !digi[digiID]->IsConnected() ) continue;
@ -444,14 +507,14 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "ChSelfTrigger", chID); digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "ChSelfTrigger", chID);
digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "ChSelfTrigger", chID); digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "ChSelfTrigger", chID);
if( i == 1 ){ if( i == ChStartIndex ){
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID); digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID);
}else { }else {
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Ch64Trigger", chID); digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Ch64Trigger", chID);
digi[digiID]->WriteValue(PHA::CH::CoincidenceLength, "100"); digi[digiID]->WriteValue(PHA::CH::CoincidenceLength, "100");
//Form the trigger bit //Form the trigger bit
unsigned long mask = 1ULL << (detID[1] & 0xFF ); // trigger by energy unsigned long mask = 1ULL << (detIDArray[ChStartIndex] & 0xFF ); // trigger by energy
QString maskStr = QString::number(mask); QString maskStr = QString::number(mask);
digi[digiID]->WriteValue(PHA::CH::ChannelsTriggerMask, maskStr.toStdString() , chID); digi[digiID]->WriteValue(PHA::CH::ChannelsTriggerMask, maskStr.toStdString() , chID);
} }
@ -470,7 +533,7 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
}; break; }; break;
} }
SendLogMsg("SOLARIS panel : Set Trigger = " + cbTrigger[detTypeID][detID[0]]->itemText(index) + "|Digi:" + QString::number(digi[digiID]->GetSerialNumber()) + ",Det:" + QString::number(detID[0])); SendLogMsg("SOLARIS panel : Set Trigger = " + cbTrigger[detGroup][detID]->itemText(index) + "|Digi:" + QString::number(digi[digiID]->GetSerialNumber()) + ",Det:" + QString::number(detID));
} }
UpdatePanelFromMemory(); UpdatePanelFromMemory();
@ -480,7 +543,7 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
} }
layout->addWidget(groupBox[detTypeID][SettingID][detID[0]], row, col); layout->addWidget(groupBox[detGroup][SettingID][detID], row, col);
} }
//^############################################################## //^##############################################################
@ -505,59 +568,64 @@ void SOLARISpanel::UpdatePanelFromMemory(){
for( int SettingID = 0; SettingID < (int) SettingItems.size() ; SettingID ++){ for( int SettingID = 0; SettingID < (int) SettingItems.size() ; SettingID ++){
for( int DigiID = 0; DigiID < (int) mapping.size(); DigiID ++){ for( int DigiID = 0; DigiID < (int) mapping.size(); DigiID ++){
if( DigiID >= nDigi ) continue;; if( DigiID >= nDigi ) continue;;
for( int chID = 0; chID < (int) mapping[DigiID].size(); chID++){ for( int chID = 0; chID < (int) mapping[DigiID].size(); chID++){
if( mapping[DigiID][chID] < 0 ) continue; if( mapping[DigiID][chID] < 0 ) continue;
std::string haha = digi[DigiID]->GetSettingValue(SettingItems[SettingID], chID); std::string haha = digi[DigiID]->GetSettingValueFromMemory(SettingItems[SettingID], chID);
sbSetting[SettingID][DigiID][chID]->setValue( atof(haha.c_str())); sbSetting[SettingID][DigiID][chID]->setValue( atof(haha.c_str()));
if( SettingItems[SettingID].GetPara() == PHA::CH::TriggerThreshold.GetPara() ){ if( SettingItems[SettingID].GetPara() == PHA::CH::TriggerThreshold.GetPara() ){
std::string haha = digi[DigiID]->GetSettingValue(PHA::CH::SelfTrgRate, chID); std::string haha = digi[DigiID]->GetSettingValueFromMemory(PHA::CH::SelfTrgRate, chID);
leDisplay[SettingID][DigiID][chID]->setText(QString::fromStdString(haha)); leDisplay[SettingID][DigiID][chID]->setText(QString::number(atof(haha.c_str()), 'f', 2) );
}else{ }else{
leDisplay[SettingID][DigiID][chID]->setText(QString::fromStdString(haha)); leDisplay[SettingID][DigiID][chID]->setText(QString::number(atof(haha.c_str()), 'f', 2) );
} }
haha = digi[DigiID]->GetSettingValue(PHA::CH::ChannelEnable, chID); haha = digi[DigiID]->GetSettingValueFromMemory(PHA::CH::ChannelEnable, chID);
chkOnOff[SettingID][DigiID][chID]->setChecked( haha == "True" ? true : false); chkOnOff[SettingID][DigiID][chID]->setChecked( haha == "True" ? true : false);
leDisplay[SettingID][DigiID][chID]->setEnabled(haha == "True" ? true : false); leDisplay[SettingID][DigiID][chID]->setEnabled(haha == "True" ? true : false);
sbSetting[SettingID][DigiID][chID]->setEnabled(haha == "True" ? true : false); sbSetting[SettingID][DigiID][chID]->setEnabled(haha == "True" ? true : false);
///printf("====== %d %d %d |%s|\n", SettingID, DigiID, chID, haha.c_str()); //printf("====== %d %d %d |%s|\n", SettingID, DigiID, chID, haha.c_str());
} }
} }
} }
//@===================== Trigger //@===================== Trigger
for( int k = 0; k < detIDList.size() ; k++){ for( int k = 0; k < detIDArrayList.size() ; k++){
if( detIDList[k][0] >= detMaxID[0] || 0 > detIDList[k][0]) continue; //! only for array if( detIDArrayList[k][1] >= detMaxID[0] || 0 > detIDArrayList[k][1]) continue; //! only for array
if( detIDArrayList[k][0] != 0 ) continue;
//if( detIDList[k].size() <= 2) continue; //if( detIDList[k].size() <= 2) continue;
bool skipFlag = false;
std::vector<unsigned long> triggerMap; std::vector<unsigned long> triggerMap;
std::vector<std::string> coincidentMask; std::vector<std::string> coincidentMask;
std::vector<std::string> antiCoincidentMask; std::vector<std::string> antiCoincidentMask;
std::vector<std::string> eventTriggerSource; std::vector<std::string> eventTriggerSource;
std::vector<std::string> waveTriggerSource; std::vector<std::string> waveTriggerSource;
for( int h = 1; h < detIDList[k].size(); h++){ for( int h = ChStartIndex; h < detIDArrayList[k].size(); h++){
int digiID = detIDList[k][h] >> 8; int digiID = detIDArrayList[k][h] >> 8;
int chID = (detIDList[k][h] & 0xFF); if( digiID >= nDigi) {
skipFlag = true;
continue;
}
triggerMap.push_back(Utility::TenBase(digi[digiID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, chID))); int chID = (detIDArrayList[k][h] & 0xFF);
coincidentMask.push_back(digi[digiID]->GetSettingValue(PHA::CH::CoincidenceMask, chID)); triggerMap.push_back(Utility::TenBase(digi[digiID]->GetSettingValueFromMemory(PHA::CH::ChannelsTriggerMask, chID)));
antiCoincidentMask.push_back(digi[digiID]->GetSettingValue(PHA::CH::AntiCoincidenceMask, chID)); coincidentMask.push_back(digi[digiID]->GetSettingValueFromMemory(PHA::CH::CoincidenceMask, chID));
eventTriggerSource.push_back(digi[digiID]->GetSettingValue(PHA::CH::EventTriggerSource, chID)); antiCoincidentMask.push_back(digi[digiID]->GetSettingValueFromMemory(PHA::CH::AntiCoincidenceMask, chID));
waveTriggerSource.push_back(digi[digiID]->GetSettingValue(PHA::CH::WaveTriggerSource, chID)); eventTriggerSource.push_back(digi[digiID]->GetSettingValueFromMemory(PHA::CH::EventTriggerSource, chID));
waveTriggerSource.push_back(digi[digiID]->GetSettingValueFromMemory(PHA::CH::WaveTriggerSource, chID));
} }
if(skipFlag) continue;
//====== only acceptable condition is eventTriggerSource are all ChSelfTrigger //====== only acceptable condition is eventTriggerSource are all ChSelfTrigger
// and coincidentMask for e, xf, xn, are at least one for Ch64Trigger // and coincidentMask for e, xf, xn, are at least one for Ch64Trigger
// and waveTriggerSource are all ChSelfTrigger // and waveTriggerSource are all ChSelfTrigger
int detTypeID = FindDetTypeID(detIDList[k]);
//====== a stupid way //====== a stupid way
// triggerSource : Other = 0x0, Disabled = 0x1, ChSelfTrigger = 0x2, TRGIN = 0x3 // triggerSource : Other = 0x0, Disabled = 0x1, ChSelfTrigger = 0x2, TRGIN = 0x3
// CoinMask : Other = 0x0, Disbaled = 0x1, Ch64Trigger = 0x2, TRGIN = 0x3 // CoinMask : Other = 0x0, Disbaled = 0x1, Ch64Trigger = 0x2, TRGIN = 0x3
@ -596,6 +664,8 @@ void SOLARISpanel::UpdatePanelFromMemory(){
stupidIndex.push_back(index); stupidIndex.push_back(index);
} }
//printf("===================== detIDList : %d %d \n", detIDList[k][0], detIDList[k][1]);
int jaja[5] = {0}; // this store the count for each comboxIndex; int jaja[5] = {0}; // this store the count for each comboxIndex;
for( int i = 0; i < (int) stupidIndex.size(); i++){ for( int i = 0; i < (int) stupidIndex.size(); i++){
//printf(" %d | 0x%s \n", i, QString::number(stupidIndex[i], 16).toUpper().toStdString().c_str()); //printf(" %d | 0x%s \n", i, QString::number(stupidIndex[i], 16).toUpper().toStdString().c_str());
@ -617,27 +687,28 @@ void SOLARISpanel::UpdatePanelFromMemory(){
// if Trigger e, need to check the trigger mask; // if Trigger e, need to check the trigger mask;
if( comboxIndex == 3){ if( comboxIndex == 3){
unsigned long ShouldBeMask = 1ULL << (detIDList[k][1] & 0xFF); unsigned long ShouldBeMask = 1ULL << (detIDArrayList[k][ChStartIndex] & 0xFF);
for( int i = 1; i < (int) triggerMap.size(); i ++){ for( int i = 1; i < (int) triggerMap.size(); i ++){
//printf(" %d | %lu =? %lu \n", i, triggerMap[i], ShouldBeMask); //printf(" %d | %lu =? %lu \n", i, triggerMap[i], ShouldBeMask);
if( triggerMap[i] != ShouldBeMask) comboxIndex = 4; if( triggerMap[i] != ShouldBeMask) comboxIndex = 4;
} }
} }
cbTrigger[detTypeID][detIDList[k][0]]->setCurrentIndex(comboxIndex); int detGroup = FindDetGroup(detIDArrayList[k][1]);
cbTrigger[detGroup][detIDArrayList[k][1]]->setCurrentIndex(comboxIndex);
} }
//@===================== Coin. time //@===================== Coin. time
std::vector<int> coinTime; std::vector<int> coinTime;
for( int i = 0; i < detIDList.size(); i++){ for( int i = 0; i < detIDArrayList.size(); i++){
for( int j = 1; j < detIDList[i].size(); j++){ for( int j = ChStartIndex; j < detIDArrayList[i].size(); j++){
int digiID = detIDList[i][j] >> 8; int digiID = detIDArrayList[i][j] >> 8;
int chID = (detIDList[i][j] & 0xFF); int chID = (detIDArrayList[i][j] & 0xFF);
if( digiID >= nDigi ) continue; if( digiID >= nDigi ) continue;
if( digi[digiID]->IsDummy() || !digi[digiID]->IsConnected() ) continue; if( digi[digiID]->IsDummy() || !digi[digiID]->IsConnected() ) continue;
coinTime.push_back( atoi(digi[digiID]->GetSettingValue(PHA::CH::CoincidenceLength, chID).c_str())); coinTime.push_back( atoi(digi[digiID]->GetSettingValueFromMemory(PHA::CH::CoincidenceLength, chID).c_str()));
} }
} }
@ -671,7 +742,7 @@ void SOLARISpanel::UpdateThreshold(){
if( mapping[DigiID][chID] < 0 ) continue; if( mapping[DigiID][chID] < 0 ) continue;
std::string haha = digi[DigiID]->GetSettingValue(PHA::CH::SelfTrgRate, chID); std::string haha = digi[DigiID]->GetSettingValueFromMemory(PHA::CH::SelfTrgRate, chID);
leDisplay[SettingID][DigiID][chID]->setText(QString::fromStdString(haha)); leDisplay[SettingID][DigiID][chID]->setText(QString::fromStdString(haha));
///printf("====== %d %d %d |%s|\n", SettingID, DigiID, chID, haha.c_str()); ///printf("====== %d %d %d |%s|\n", SettingID, DigiID, chID, haha.c_str());

View File

@ -22,7 +22,7 @@
#include "CustomWidgets.h" #include "CustomWidgets.h"
#include "macro.h" #include "macro.h"
#define MaxDetType 10 #define MaxDetGroup 10
#define MaxDetID 60 #define MaxDetID 60
#define MaxSettingItem 3 #define MaxSettingItem 3
@ -35,6 +35,8 @@ public:
QString analysisPath, QString analysisPath,
std::vector<std::vector<int>> mapping, std::vector<std::vector<int>> mapping,
QStringList detType, QStringList detType,
QStringList detGroupName,
std::vector<int> detGroupID,
std::vector<int> detMaxID, std::vector<int> detMaxID,
QWidget * parent = nullptr); QWidget * parent = nullptr);
~SOLARISpanel(); ~SOLARISpanel();
@ -55,31 +57,35 @@ signals:
void SendLogMsg(const QString str); void SendLogMsg(const QString str);
private: private:
void CreateDetGroup(int detTypeID, int SettingID, QList<int> detID, QGridLayout * &layout, int row, int col); void CreateDetGroup(int SettingID, QList<int> detIDArray, QGridLayout * &layout, int row, int col);
Digitizer2Gen ** digi; Digitizer2Gen ** digi;
unsigned short nDigi; unsigned short nDigi;
std::vector<std::vector<int>> mapping; std::vector<std::vector<int>> mapping;
QStringList detType; QStringList detTypeNameList;
std::vector<int> nDet; // number of distgish detector std::vector<int> nDetinType;
std::vector<int> detMaxID; std::vector<int> detMaxID;
QList<QList<int>> detIDList; // 1-D array of { detID, (Digi << 8 ) + ch} QStringList detGroupNameList;
std::vector<int> detGroupID;
std::vector<int> nDetinGroup;
QList<QList<int>> detIDArrayList; // 1-D array of { detID, (Digi << 8 ) + ch}
QString digiSettingPath; QString digiSettingPath;
int FindDetTypeID(QList<int> detIDListElement); int FindDetTypeID(int detID);
int FindDetGroup(int detID);
RSpinBox * sbCoinTime; RSpinBox * sbCoinTime;
QCheckBox * chkAll[MaxDetType][MaxSettingItem]; // checkBox for all setting on that tab; QCheckBox * chkAll[MaxDetGroup][MaxSettingItem]; // checkBox for all setting on that tab;
QGroupBox * groupBox[MaxDetType][MaxSettingItem][MaxDetID]; QGroupBox * groupBox[MaxDetGroup][MaxSettingItem][MaxDetID];
QLineEdit * leDisplay[MaxSettingItem][MaxNumberOfDigitizer][MaxNumberOfChannel]; // [SettingID][DigiID][ChID] QLineEdit * leDisplay[MaxSettingItem][MaxNumberOfDigitizer][MaxNumberOfChannel]; // [SettingID][DigiID][ChID]
RSpinBox * sbSetting[MaxSettingItem][MaxNumberOfDigitizer][MaxNumberOfChannel]; RSpinBox * sbSetting[MaxSettingItem][MaxNumberOfDigitizer][MaxNumberOfChannel];
QCheckBox * chkOnOff[MaxSettingItem][MaxNumberOfDigitizer][MaxNumberOfChannel]; QCheckBox * chkOnOff[MaxSettingItem][MaxNumberOfDigitizer][MaxNumberOfChannel];
RComboBox * cbTrigger[MaxDetType][MaxDetID]; //[detTypeID][detID] for array only RComboBox * cbTrigger[MaxDetGroup][MaxDetID]; //[detTypeID][detID] for array only
bool enableSignalSlot; bool enableSignalSlot;

View File

@ -1,234 +0,0 @@
#ifndef SOLREADER_H
#define SOLREADER_H
#include <stdio.h> /// for FILE
#include <cstdlib>
#include <string>
#include <vector>
#include <unistd.h>
#include <time.h> // time in nano-sec
#include "Event.h"
class SolReader {
private:
FILE * inFile;
unsigned int inFileSize;
unsigned int filePos;
unsigned int totNumBlock;
unsigned short blockStartIdentifier;
unsigned int numBlock;
bool isScanned;
void init();
std::vector<unsigned int> blockPos;
public:
SolReader();
SolReader(std::string fileName, unsigned short dataType);
~SolReader();
void OpenFile(std::string fileName);
int ReadNextBlock(int opt = 0); // opt = 0, noraml, 1, fast
int ReadBlock(unsigned int index);
void ScanNumBlock();
unsigned int GetNumBlock() {return numBlock;}
unsigned int GetTotalNumBlock() {return totNumBlock;}
unsigned int GetFilePos() {return filePos;}
unsigned int GetFileSize() {return inFileSize;}
void RewindFile();
Event * evt;
};
void SolReader::init(){
inFileSize = 0;
numBlock = 0;
filePos = 0;
totNumBlock = 0;
evt = new Event();
isScanned = false;
blockPos.clear();
}
SolReader::SolReader(){
init();
}
SolReader::SolReader(std::string fileName, unsigned short dataType = 0){
init();
OpenFile(fileName);
evt->SetDataType(dataType);
}
SolReader::~SolReader(){
if( !inFile ) fclose(inFile);
delete evt;
}
inline void SolReader::OpenFile(std::string fileName){
inFile = fopen(fileName.c_str(), "r");
if( inFile == NULL ){
printf("Cannot open file : %s \n", fileName.c_str());
}else{
fseek(inFile, 0L, SEEK_END);
inFileSize = ftell(inFile);
rewind(inFile);
}
}
inline int SolReader::ReadBlock(unsigned int index){
if( isScanned == false) return -1;
if( index >= totNumBlock )return -1;
fseek(inFile, 0L, SEEK_SET);
printf("-----------%u, %u\n", index, blockPos[index]);
fseek(inFile, blockPos[index], SEEK_CUR);
numBlock = index;
return ReadNextBlock();
}
inline int SolReader::ReadNextBlock(int opt){
if( inFile == NULL ) return -1;
if( feof(inFile) ) return -1;
if( filePos >= inFileSize) return -1;
fread(&blockStartIdentifier, 2, 1, inFile);
if( (blockStartIdentifier & 0xAAA0) != 0xAAA0 ) {
printf("header fail.\n");
return -2 ;
}
if( ( blockStartIdentifier & 0xF ) == 15 ){
evt->SetDataType(15);
}
evt->dataType = blockStartIdentifier & 0xF;
if( evt->dataType == 0){
if( opt == 0 ){
fread(&evt->channel, 1, 1, inFile);
fread(&evt->energy, 2, 1, inFile);
fread(&evt->timestamp, 6, 1, inFile);
fread(&evt->fine_timestamp, 2, 1, inFile);
fread(&evt->flags_high_priority, 1, 1, inFile);
fread(&evt->flags_low_priority, 2, 1, inFile);
fread(&evt->downSampling, 1, 1, inFile);
fread(&evt->board_fail, 1, 1, inFile);
fread(&evt->flush, 1, 1, inFile);
fread(&evt->trigger_threashold, 2, 1, inFile);
fread(&evt->event_size, 8, 1, inFile);
fread(&evt->aggCounter, 4, 1, inFile);
}else{
fseek(inFile, 31, SEEK_CUR);
}
fread(&evt->traceLenght, 8, 1, inFile);
if( opt == 0){
fread(evt->analog_probes_type, 2, 1, inFile);
fread(evt->digital_probes_type, 4, 1, inFile);
fread(evt->analog_probes[0], evt->traceLenght*4, 1, inFile);
fread(evt->analog_probes[1], evt->traceLenght*4, 1, inFile);
fread(evt->digital_probes[0], evt->traceLenght, 1, inFile);
fread(evt->digital_probes[1], evt->traceLenght, 1, inFile);
fread(evt->digital_probes[2], evt->traceLenght, 1, inFile);
fread(evt->digital_probes[3], evt->traceLenght, 1, inFile);
}else{
fseek(inFile, 6 + evt->traceLenght*(12), SEEK_CUR);
}
}else if( evt->dataType == 1){
if( opt == 0 ){
fread(&evt->channel, 1, 1, inFile);
fread(&evt->energy, 2, 1, inFile);
fread(&evt->timestamp, 6, 1, inFile);
fread(&evt->fine_timestamp, 2, 1, inFile);
fread(&evt->flags_high_priority, 1, 1, inFile);
fread(&evt->flags_low_priority, 2, 1, inFile);
}else{
fseek(inFile, 14, SEEK_CUR);
}
fread(&evt->traceLenght, 8, 1, inFile);
if( opt == 0){
fread(&evt->analog_probes_type[0], 1, 1, inFile);
fread(evt->analog_probes[0], evt->traceLenght*4, 1, inFile);
}else{
fseek(inFile, 1 + evt->traceLenght*4, SEEK_CUR);
}
}else if( evt->dataType == 2){
if( opt == 0 ){
fread(&evt->channel, 1, 1, inFile);
fread(&evt->energy, 2, 1, inFile);
fread(&evt->timestamp, 6, 1, inFile);
fread(&evt->fine_timestamp, 2, 1, inFile);
fread(&evt->flags_high_priority, 1, 1, inFile);
fread(&evt->flags_low_priority, 2, 1, inFile);
}else{
fseek(inFile, 14, SEEK_CUR);
}
}else if( evt->dataType == 3){
if( opt == 0 ){
fread(&evt->channel, 1, 1, inFile);
fread(&evt->energy, 2, 1, inFile);
fread(&evt->timestamp, 6, 1, inFile);
}else{
fseek(inFile, 9, SEEK_CUR);
}
}else if( evt->dataType == 15){
fread(&evt->dataSize, 8, 1, inFile);
if( opt == 0){
fread(evt->data, evt->dataSize, 1, inFile);
}else{
fseek(inFile, evt->dataSize, SEEK_CUR);
}
}
numBlock ++;
filePos = ftell(inFile);
return 0;
}
void SolReader::RewindFile(){
rewind(inFile);
filePos = 0;
numBlock = 0;
}
void SolReader::ScanNumBlock(){
if( inFile == NULL ) return;
if( feof(inFile) ) return;
numBlock = 0;
blockPos.clear();
blockPos.push_back(0);
while( ReadNextBlock(1) == 0){
blockPos.push_back(filePos);
printf("%u, %.2f%% %u/%u\n\033[A\r", numBlock, filePos*100./inFileSize, filePos, inFileSize);
}
totNumBlock = numBlock;
numBlock = 0;
isScanned = true;
printf("\nScan complete: number of data Block : %u\n", totNumBlock);
rewind(inFile);
filePos = 0;
//for( int i = 0; i < totNumBlock; i++){
// printf("%7d | %u \n", i, blockPos[i]);
//}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -41,7 +41,8 @@ private slots:
public slots: public slots:
void EnableControl(); void EnableControl();
void UpdatePanelFromMemory(); void UpdatePanelFromMemory(bool onlyStatus = false);
void UpdateStatus();
signals: signals:
@ -56,10 +57,16 @@ private:
QString digiSettingPath; QString digiSettingPath;
QTabWidget * tabWidget;
//------------ Layout/GroupBox //------------ Layout/GroupBox
QGroupBox * digiBox[MaxNumberOfDigitizer]; QWidget * bdCfg[MaxNumberOfDigitizer];
QGroupBox * VGABox[MaxNumberOfDigitizer]; QWidget * bdTestPulse[MaxNumberOfDigitizer];
QGroupBox * testPulseBox[MaxNumberOfDigitizer]; QWidget * bdVGA[MaxNumberOfDigitizer];
QWidget * bdLVDS[MaxNumberOfDigitizer];
QWidget * bdITL[MaxNumberOfDigitizer];
QWidget * bdGroup[MaxNumberOfDigitizer];
QGroupBox * box0[MaxNumberOfDigitizer]; QGroupBox * box0[MaxNumberOfDigitizer];
QGroupBox * box1[MaxNumberOfDigitizer]; QGroupBox * box1[MaxNumberOfDigitizer];
@ -75,6 +82,9 @@ private:
QTabWidget * triggerTab[MaxNumberOfDigitizer]; QTabWidget * triggerTab[MaxNumberOfDigitizer];
QTabWidget * triggerMapTab[MaxNumberOfDigitizer]; QTabWidget * triggerMapTab[MaxNumberOfDigitizer];
QTabWidget * chTabWidget[MaxNumberOfDigitizer];
QWidget * digiTab[MaxNumberOfDigitizer];
bool enableSignalSlot; bool enableSignalSlot;
//---------------- Inquiry and copy //---------------- Inquiry and copy
@ -112,7 +122,7 @@ private:
QPushButton * pbCopyDigi; QPushButton * pbCopyDigi;
//------------ status //------------ status
QLineEdit * leInfo[MaxNumberOfChannel][12]; QLineEdit * leInfo[MaxNumberOfDigitizer][12];
QPushButton * LEDStatus[MaxNumberOfDigitizer][19]; QPushButton * LEDStatus[MaxNumberOfDigitizer][19];
QPushButton * ACQStatus[MaxNumberOfDigitizer][19]; QPushButton * ACQStatus[MaxNumberOfDigitizer][19];
QLineEdit * leTemp[MaxNumberOfDigitizer][8]; QLineEdit * leTemp[MaxNumberOfDigitizer][8];
@ -131,6 +141,7 @@ private:
//-------------- board settings //-------------- board settings
RComboBox * cbbClockSource[MaxNumberOfDigitizer]; RComboBox * cbbClockSource[MaxNumberOfDigitizer];
RComboBox * cbbEnClockFrontPanel[MaxNumberOfDigitizer];
QCheckBox * ckbStartSource[MaxNumberOfDigitizer][5]; QCheckBox * ckbStartSource[MaxNumberOfDigitizer][5];
QCheckBox * ckbGlbTrgSource[MaxNumberOfDigitizer][5]; QCheckBox * ckbGlbTrgSource[MaxNumberOfDigitizer][5];
RComboBox * cbbTrgOut[MaxNumberOfDigitizer]; RComboBox * cbbTrgOut[MaxNumberOfDigitizer];
@ -153,15 +164,47 @@ private:
RSpinBox * spbTestPusleLowLevel[MaxNumberOfDigitizer]; RSpinBox * spbTestPusleLowLevel[MaxNumberOfDigitizer];
RSpinBox * spbTestPusleHighLevel[MaxNumberOfDigitizer]; RSpinBox * spbTestPusleHighLevel[MaxNumberOfDigitizer];
RSpinBox * sbIPEAmplitude[MaxNumberOfDigitizer];
RSpinBox * sbIPEBaseline[MaxNumberOfDigitizer];
RSpinBox * sbIPEDecayTime[MaxNumberOfDigitizer];
RSpinBox * sbIPERate[MaxNumberOfDigitizer];
RComboBox * cbIPETimeMode[MaxNumberOfDigitizer];
//-------------- VGA //-------------- VGA
RSpinBox * VGA[MaxNumberOfDigitizer][4]; RSpinBox * VGA[MaxNumberOfDigitizer][4];
//-------------- ITL-A/B
RComboBox * cbITLAMainLogic[MaxNumberOfDigitizer];
RSpinBox * sbITLAMajority[MaxNumberOfDigitizer];
RComboBox * cbITLAPairLogic[MaxNumberOfDigitizer];
RComboBox * cbITLAPolarity[MaxNumberOfDigitizer];
RSpinBox * sbITLAGateWidth[MaxNumberOfDigitizer];
RComboBox * cbITLBMainLogic[MaxNumberOfDigitizer];
RComboBox * cbITLBPairLogic[MaxNumberOfDigitizer];
RComboBox * cbITLBPolarity[MaxNumberOfDigitizer];
RSpinBox * sbITLBMajority[MaxNumberOfDigitizer];
RSpinBox * sbITLBGateWidth[MaxNumberOfDigitizer];
QPushButton * chITLConnect[MaxNumberOfDigitizer][MaxNumberOfChannel][2]; // 0 for A, 1 for B
unsigned short ITLConnectStatus[MaxNumberOfDigitizer][MaxNumberOfChannel]; // 0 = disabled, 1 = A, 2 = B
//-------------- LVDS
RComboBox * cbLVDSMode[MaxNumberOfDigitizer][4];
RComboBox * cbLVDSDirection[MaxNumberOfDigitizer][4];
QLineEdit * leLVDSIOReg[MaxNumberOfDigitizer];
//-------------- DAC output
RComboBox * cbDACoutMode[MaxNumberOfDigitizer];
RSpinBox * sbDACoutStaticLevel[MaxNumberOfDigitizer];
RSpinBox * sbDACoutChSelect[MaxNumberOfDigitizer];
//--------------- trigger map //--------------- trigger map
RComboBox * cbAllEvtTrigger[MaxNumberOfDigitizer]; //RComboBox * cbAllEvtTrigger[MaxNumberOfDigitizer];
RComboBox * cbAllWaveTrigger[MaxNumberOfDigitizer]; //RComboBox * cbAllWaveTrigger[MaxNumberOfDigitizer];
RComboBox * cbAllCoinMask[MaxNumberOfDigitizer]; //RComboBox * cbAllCoinMask[MaxNumberOfDigitizer];
RComboBox * cbAllAntiCoinMask[MaxNumberOfDigitizer]; //RComboBox * cbAllAntiCoinMask[MaxNumberOfDigitizer];
RSpinBox * sbAllCoinLength[MaxNumberOfDigitizer]; //RSpinBox * sbAllCoinLength[MaxNumberOfDigitizer];
QPushButton * trgMap[MaxNumberOfDigitizer][MaxNumberOfChannel][MaxNumberOfChannel]; QPushButton * trgMap[MaxNumberOfDigitizer][MaxNumberOfChannel][MaxNumberOfChannel];
bool trgMapClickStatus[MaxNumberOfDigitizer][MaxNumberOfChannel][MaxNumberOfChannel]; bool trgMapClickStatus[MaxNumberOfDigitizer][MaxNumberOfChannel][MaxNumberOfChannel];
@ -170,6 +213,9 @@ private:
QLineEdit * chGainFactor[MaxNumberOfDigitizer][MaxNumberOfChannel]; QLineEdit * chGainFactor[MaxNumberOfDigitizer][MaxNumberOfChannel];
QLineEdit * chADCToVolts[MaxNumberOfDigitizer][MaxNumberOfChannel]; QLineEdit * chADCToVolts[MaxNumberOfDigitizer][MaxNumberOfChannel];
//--------------- Group settings
RSpinBox * spbInputDelay[MaxNumberOfDigitizer][MaxNumberOfGroup];
//--------------- Channel settings //--------------- Channel settings
RComboBox * cbChPick[MaxNumberOfDigitizer]; RComboBox * cbChPick[MaxNumberOfDigitizer];
@ -184,21 +230,22 @@ private:
RComboBox * cbbWaveRes[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbWaveRes[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbWaveSave[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbWaveSave[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbInputRiseTime[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbEvtTrigger[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbTriggerGuard[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbWaveTrigger[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbTrapRiseTime[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbCoinMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbTrapFlatTop[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbAntiCoinMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbTrapPoleZero[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RSpinBox * spbCoinLength[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbPeaking[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; QLineEdit * leTriggerMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbBaselineGuard[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbPileupGuard[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbPeakingAvg[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbChVetoSrc[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbBaselineAvg[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RSpinBox * spbADCVetoWidth[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbFineGain[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbLowFilter[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbEventSelector[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbWaveSelector[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbEnergySkimLow[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbEnergySkimHigh[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbAnaProbe0[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbAnaProbe0[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbAnaProbe1[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbAnaProbe1[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
@ -208,24 +255,48 @@ private:
RComboBox * cbbDigProbe2[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbDigProbe2[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbDigProbe3[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbDigProbe3[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbEvtTrigger[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; //........... PHA
RComboBox * cbbWaveTrigger[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RSpinBox * spbInputRiseTime[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbChVetoSrc[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RSpinBox * spbTriggerGuard[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbLowFilter[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbEventSelector[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RSpinBox * spbTrapRiseTime[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbWaveSelector[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RSpinBox * spbTrapFlatTop[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbTrapPoleZero[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbCoinMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RSpinBox * spbPeaking[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbAntiCoinMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RSpinBox * spbBaselineGuard[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbPileupGuard[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
QLineEdit * leTriggerMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbBaselineAvg[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbFineGain[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbPeakingAvg[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbCoinLength[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; //.............. PSD
RSpinBox * spbADCVetoWidth[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbADCInputBaselineAvg[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbAbsBaseline[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbADCInputBaselineGuard[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbTimeFilterReTriggerGuard[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbTriggerHysteresis[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbEnergySkimLow[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RComboBox * cbbTriggerFilter[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbEnergySkimHigh[MaxNumberOfDigitizer][MaxNumberOfChannel + 1]; RSpinBox * spbCFDDelay[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbCFDFraction[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbSmoothingFactor[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbChargeSmooting[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbTimeFilterSmoothing[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbPileupGap[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbGateLong[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbGateShort[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbGateOffset[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbLongChargeIntergratorPedestal[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbShortChargeIntergratorPedestal[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbEnergyGain[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbNeutronThreshold[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbEventNeutronReject[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbWaveNeutronReject[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
//------------------------- //-------------------------
QLineEdit * leSettingFile[MaxNumberOfDigitizer]; QLineEdit * leSettingFile[MaxNumberOfDigitizer];
@ -248,6 +319,9 @@ private:
void FillComboBoxValueFromMemory(RComboBox * &cbb, const Reg para, int ch_index = -1); void FillComboBoxValueFromMemory(RComboBox * &cbb, const Reg para, int ch_index = -1);
void FillSpinBoxValueFromMemory(RSpinBox * &spb, const Reg para, int ch_index = -1 ); void FillSpinBoxValueFromMemory(RSpinBox * &spb, const Reg para, int ch_index = -1 );
void SetupPHAChannels(unsigned short digiID);
void SetupPSDChannels(unsigned short digiID);
void ReadBoardSetting(int cbIndex); void ReadBoardSetting(int cbIndex);
void ReadChannelSetting(int cbIndex); void ReadChannelSetting(int cbIndex);

37
firmwares/compareJSON.py Normal file
View File

@ -0,0 +1,37 @@
import json
# Load the two JSON files
with open("x2745_DPP-PHA_2023091800_parameters.json") as f1:
old_params = json.load(f1)
with open("x2745_DPP-PHA_2025012205_parameters.json") as f2:
new_params = json.load(f2)
# Index by parameter name for easy lookup
old_dict = {param["name"]: param for param in old_params}
new_dict = {param["name"]: param for param in new_params}
# 1. Find new parameter names
new_names = set(new_dict.keys()) - set(old_dict.keys())
print("🆕 New parameters in new version:")
for name in sorted(new_names):
print(f" - {name}")
# 2. Compare allowed values for common parameters
print("\n🔍 Parameters with changed allowed values:")
for name in sorted(set(old_dict.keys()) & set(new_dict.keys())):
old_vals = {v["value"]: v["description"] for v in old_dict[name].get("allowed_values", [])}
new_vals = {v["value"]: v["description"] for v in new_dict[name].get("allowed_values", [])}
if old_vals != new_vals:
print(f" - {name}")
removed = set(old_vals) - set(new_vals)
added = set(new_vals) - set(old_vals)
changed = {k for k in old_vals if k in new_vals and old_vals[k] != new_vals[k]}
if added:
print(f" Added: {sorted(added)}")
if removed:
print(f" Removed: {sorted(removed)}")
if changed:
print(f" 🔄 Modified descriptions: {sorted(changed)}")

View File

@ -0,0 +1 @@
https://fsunuc.physics.fsu.edu/wiki/index.php/FSU_SOLARIS_DAQ#Firmware

76
firmwares/web2JSON.py Normal file
View File

@ -0,0 +1,76 @@
import requests
from bs4 import BeautifulSoup
url = "http://192.168.0.102/documentation/a00103.html"
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
print(url)
# print(soup)
# Get the entire div
project_div = soup.find('div', id='projectname')
print("Full Text:", project_div.get_text(strip=True))
# Get just the main project name (excluding the span)
project_name = project_div.contents[0].strip()
print("Name:", project_name)
# Get the project number from the span
project_number = project_div.find('span', id='projectnumber').get_text(strip=True)
print("Number:", project_number)
safe_name = project_name.replace(" ", "_")
filename = f"{safe_name}_{project_number}_parameters.json"
import json
data = []
# Iterate through all <h2> blocks which denote parameters
for h2 in soup.find_all("h2"):
param = {}
name = h2.get_text(strip=True)
param['name'] = name
# Description is usually the next <p>
desc_tag = h2.find_next_sibling('p')
if desc_tag:
param['description'] = desc_tag.get_text(strip=True)
# Get the next two blockquotes: one for options, one for allowed values
blockquotes = desc_tag.find_all_next('blockquote', class_='doxtable', limit=2)
# Parse Options
if len(blockquotes) > 0:
options = {}
for li in blockquotes[0].find_all('li'):
text = li.get_text(strip=True)
if ':' in text:
key, val = text.split(':', 1)
options[key.strip()] = val.strip()
param['options'] = options
# Parse Allowed Values
if len(blockquotes) > 1:
allowed_values = []
for li in blockquotes[1].find_all('li'):
b_tag = li.find('b')
em_tag = li.find('em')
if b_tag and em_tag:
allowed_values.append({
'value': b_tag.get_text(strip=True),
'description': em_tag.get_text(strip=True)
})
param['allowed_values'] = allowed_values
data.append(param)
# print(parameters)
# Output as JSON
with open(filename, 'w') as f:
json.dump(data, f, indent=2)

View File

@ -1,61 +0,0 @@
#!/bin/bash
#url=http://localhost:3000/dashboard/snapshot/qHdJjri9Uk7DPbwnFh0fIBDEELMn4nzP
#url="http://localhost:3000/d/iXH6cG-Vz/test-dashboard?orgId=1&refresh=5s&from=1678824051707&to=1678827651708"
#firefox -screenshot http://solarisdaq:3000/dashboard/snapshot/qHdJjri9Uk7DPbwnFh0fIBDEELMn4nzP haha.png
#cutycapt --url=${url} --out=haha.png
#wget --output-document="haha.png" ${url}
usr=GeneralSOLARIS
pwd='gam$hippie'
APIKEY=eyJrIjoid25Bc3U3NEdxVDZYV2xrdEJ0QTlxNTdFM25JcXVTTlAiLCJuIjoiYWRtaW5LRVkiLCJpZCI6MX0=
url=http://localhost:3000/
#curl http://${usr}:${pwd}@localhost:3000/api/search
#curl http://${usr}:${pwd}@localhost:3000/api/admin/settings
#curl -v -H "Accept: application/json" -H "Content-Type: application/json" http://${usr}:${pwd}@localhost:3000/api/dashboard/snapshots
#get list of snapshot
#curl -v http://${usr}:${pwd}@localhost:3000/api/dashboard/snapshots
#delet snapshot
#curl -X DELETE http://${usr}:${pwd}@localhost:3000/api/snapshots/HzQd70cK1NhqZ7lDV7bSU4GkmNMezacs
#curl -v -X -d ${msg} http://${usr}:${pwd}@localhost:3000/api/snapshots
#curl -X DELETE -H "Authorization: Bearer ${APIKEY}" ${url}api/snapshots/Yn7MnDIzXsOL3VoRS617N17K5ojTsnOk
# curl -X POST -H "Authorization: Bearer ${APIKEY}" -H "Accept: application/json" -H "Content-Type: application/json" -d '{
# "dashboard": {
# "editable":false,
# "nav":[{"enable":false, "type":"timepicker"}],
# "rows": [ {} ],
# "style":"dark",
# "tags":[],
# "templating":{ "list":[]},
# "time":{ },
# "timezone":"browser",
# "title":"Home",
# "version":5
# },
# "expires": 2
# }' ${url}/api/snapshots
#curl -v -X GET -H "Authorization: Bearer ${APIKEY}" -H "Accept: application/json" ${url}api/dashboard/snapshots
#curl -v -X GET -H "Authorization: Bearer ${APIKEY}" -H "Accept: application/json" ${url}api/search
#successfull single panel
#curl 'http://localhost:3000/render/d-solo/iXH6cG-Vz/test-dashboard?orgId=1&refresh=5s&from=now-6h&to=now&panelId=2&width=1000&height=500&tz=America%2FNew_York' -H "Authorization: Bearer ${APIKEY}" --compressed > haha.png
curl 'http://localhost:3000/render/d-solo/iXH6cG-Vz/test-dashboard?orgId=1&refresh=5s&from=now-6h&to=now&panelId=2' -H "Authorization: Bearer ${APIKEY}" --compressed > haha.png
eog haha.png

View File

@ -1,157 +0,0 @@
#include "influxdb.h"
InfluxDB::InfluxDB(std::string url, bool verbose){
curl = curl_easy_init();
if( verbose) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
SetURL(url);
respondCode = 0;
dataPoints = "";
}
InfluxDB::~InfluxDB(){
curl_easy_cleanup(curl);
}
void InfluxDB::SetURL(std::string url){
// check the last char of url is "/"
if( url.back() != '/') {
this->databaseIP = url + "/";
}else{
this->databaseIP = url;
}
}
bool InfluxDB::TestingConnection(){
CheckDatabases();
if( respond != CURLE_OK ) return false;
return true;
}
std::string InfluxDB::CheckDatabases(){
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "query").c_str());
std::string postFields="q=Show databases";
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(postFields.length()));
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postFields.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallBack);
std::string readBuffer;
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
Execute();
//printf("|%s|\n", readBuffer.c_str());
if( respond != CURLE_OK) return "";
databaseList.clear();
size_t pos = readBuffer.find("values");
if( pos > 0 ){
std::string kaka = readBuffer.substr(pos+8);
pos = kaka.find("}");
kaka = kaka.substr(0, pos);
int len = kaka.length();
bool startFlag = false;
std::string lala;
char yaya = '"';
for( int i = 0; i < len; i++){
if( startFlag == false && kaka[i] == yaya ) {
startFlag = true;
lala = "";
continue;
}
if( startFlag && kaka[i] == yaya ){
startFlag = false;
databaseList.push_back(lala);
continue;
}
if( startFlag ) lala += kaka[i];
}
}
return readBuffer;
}
std::string InfluxDB::Query(std::string databaseName, std::string query){
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "query?db=" + databaseName).c_str());
std::string postFields = "q=" + query;
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(postFields.length()));
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postFields.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallBack);
std::string readBuffer;
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
Execute();
//printf("|%s|\n", readBuffer.c_str());
return readBuffer;
}
void InfluxDB::CreateDatabase(std::string databaseName){
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "query").c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1);
std::string postFields = "q=CREATE DATABASE " + databaseName;
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(postFields.length()));
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postFields.c_str());
Execute();
}
void InfluxDB::AddDataPoint(std::string fullString){
dataPoints += fullString + "\n";
}
void InfluxDB::ClearDataPointsBuffer(){
dataPoints = "";
}
void InfluxDB::PrintDataPoints(){
printf("%s\n", dataPoints.c_str());
}
void InfluxDB::WriteData(std::string databaseName){
if( dataPoints.length() == 0 ) return;
//printf("|%s|\n", (databaseIP + "write?db=" + databaseName).c_str());
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "write?db=" + databaseName).c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(dataPoints.length()));
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dataPoints.c_str());
Execute();
}
void InfluxDB::Execute(){
try{
respond = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &respondCode);
//printf("==== respond %d (OK = %d)\n", respond, CURLE_OK);
if( respond != CURLE_OK) printf("############# InfluxDB::Execute fail\n");
} catch (std::exception& e){ // in case of unexpected error
printf("%s\n", e.what());
respond = CURLE_SEND_ERROR;
}
}
size_t InfluxDB::WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp){
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}

View File

@ -5,6 +5,8 @@
#define DAQLockFile "DAQLock.dat" #define DAQLockFile "DAQLock.dat"
#define PIDFile "pid.dat" #define PIDFile "pid.dat"
#include <QString>
//^================================= //^=================================
namespace Utility{ namespace Utility{
/// either haha is "0xFFF" or "12435", convert to 10-base /// either haha is "0xFFF" or "12435", convert to 10-base

View File

@ -8,6 +8,8 @@
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
printf("######### Starting SOLARIS DAQ....\n");
QApplication a(argc, argv); QApplication a(argc, argv);
bool isLock = false; bool isLock = false;
@ -37,7 +39,7 @@ int main(int argc, char *argv[]){
msgBox.setText("The DAQ program is already opened, or crashed perviously. \nPID is " + QString::number(pid) + "\n You can kill the procee by \"kill -9 <pid>\" and delete the " + DAQLockFile + "\n or click the \"Kill\" button"); msgBox.setText("The DAQ program is already opened, or crashed perviously. \nPID is " + QString::number(pid) + "\n You can kill the procee by \"kill -9 <pid>\" and delete the " + DAQLockFile + "\n or click the \"Kill\" button");
msgBox.setIcon(QMessageBox::Information); msgBox.setIcon(QMessageBox::Information);
QPushButton * kill = msgBox.addButton("Kill", QMessageBox::AcceptRole); QPushButton * kill = msgBox.addButton("Kill and Open New", QMessageBox::AcceptRole);
msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok);
@ -60,6 +62,7 @@ int main(int argc, char *argv[]){
pidFile.write( QString::number(QCoreApplication::applicationPid() ).toStdString().c_str() ); pidFile.write( QString::number(QCoreApplication::applicationPid() ).toStdString().c_str() );
pidFile.close(); pidFile.close();
printf("######### Open Main Window...\n");
MainWindow w; MainWindow w;
w.show(); w.show();
return a.exec(); return a.exec();

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@
#include <QComboBox> #include <QComboBox>
#include <QLabel> #include <QLabel>
#include <QTimer> #include <QTimer>
#include <QThread>
#include <QChart> #include <QChart>
#include <QLineSeries> #include <QLineSeries>
@ -21,9 +22,10 @@
#include "macro.h" #include "macro.h"
#include "ClassDigitizer2Gen.h" #include "ClassDigitizer2Gen.h"
#include "influxdb.h" // #include "influxdb.h"
#include "ClassInfluxDB.h"
#include "manyThread.h" #include "CustomThreads.h"
#include "digiSettingsPanel.h" #include "digiSettingsPanel.h"
#include "scope.h" #include "scope.h"
@ -46,17 +48,18 @@ private slots:
void OpenScope(); void OpenScope();
void OpenDigitizersSettings(); void OpenDigitizersSettings();
void OpenSyncHelper();
void OpenSOLARISpanel(); void OpenSOLARISpanel();
bool CheckSOLARISpanelOK(); bool CheckSOLARISpanelOK();
void StartACQ(); int StartACQ(); // return 1 when ACQ start
void StopACQ(); void StopACQ();
void AutoRun(); void AutoRun();
void OpenScaler(); void OpenScaler();
void SetUpScalar(); void SetUpScalar();
void DeleteTriggerLineEdit(); void CleanUpScalar();
void UpdateScalar(); void UpdateScalar();
void ProgramSettingsPanel(); void ProgramSettingsPanel();
@ -68,11 +71,13 @@ private slots:
void OpenDirectory(int id); void OpenDirectory(int id);
void SetupNewExpPanel(); void SetupNewExpPanel();
bool LoadExpSettings(); bool LoadExpNameSh();
void CreateNewExperiment(const QString newExpName); void CreateNewExperiment(const QString newExpName);
void ChangeExperiment(const QString newExpName); void ChangeExperiment(const QString newExpName);
void WriteExpNameSh(); void WriteExpNameSh();
void CreateRawDataFolderAndLink(); void CreateFolder(QString path, QString AdditionalMsg);
void CreateRawDataFolder();
void CreateDataSymbolicLink();
void closeEvent(QCloseEvent * event){ void closeEvent(QCloseEvent * event){
if( digiSetting ) digiSetting->close(); if( digiSetting ) digiSetting->close();
@ -84,7 +89,7 @@ private slots:
void WriteElog(QString htmlText, QString subject = "", QString category = "", int runNumber = 0); void WriteElog(QString htmlText, QString subject = "", QString category = "", int runNumber = 0);
void AppendElog(QString appendHtmlText, int screenID = -1); void AppendElog(QString appendHtmlText, int screenID = -1);
void WriteRunTimeStampDat(bool isStartRun); void WriteRunTimeStampDat(bool isStartRun, QString timeStr);
signals : signals :
@ -92,6 +97,8 @@ private:
static Digitizer2Gen ** digi; static Digitizer2Gen ** digi;
unsigned short nDigi; unsigned short nDigi;
unsigned short nDigiConnected = 0;
int maxNumChannelAcrossDigitizer = 0;
//@----- log msg //@----- log msg
QPlainTextEdit * logInfo; QPlainTextEdit * logInfo;
@ -103,25 +110,30 @@ private:
QPushButton * bnNewExp; QPushButton * bnNewExp;
QLineEdit * leExpName; QLineEdit * leExpName;
QPushButton * bnSyncHelper;
QPushButton * bnOpenDigitizers; QPushButton * bnOpenDigitizers;
QPushButton * bnCloseDigitizers; QPushButton * bnCloseDigitizers;
QPushButton * bnDigiSettings; QPushButton * bnDigiSettings;
QPushButton * bnSOLSettings; QPushButton * bnSOLSettings;
//@----- scope //@----- scope
Scope * scope; Scope * scope;
QPushButton * bnOpenScope; QPushButton * bnOpenScope;
//@----- scalar; //@----- scalar;
QMainWindow * scalar; QMainWindow * scalar;
QGridLayout * scalarLayout;
TimingThread * scalarThread;
QPushButton * bnOpenScalar; QPushButton * bnOpenScalar;
QLabel ** lbFileSize;// need to delete manually
QLineEdit *** leTrigger; // need to delete manually QLineEdit *** leTrigger; // need to delete manually
QLineEdit *** leAccept; // need to delete manually QLineEdit *** leAccept; // need to delete manually
QGridLayout * scalarLayout;
ScalarThread * scalarThread;
QLabel * lbLastUpdateTime; QLabel * lbLastUpdateTime;
QLabel * lbScalarACQStatus; QLabel * lbScalarACQStatus;
bool scalarOutputInflux;
InfluxDB * influx; InfluxDB * influx;
//@------ ACQ things //@------ ACQ things
@ -129,6 +141,7 @@ private:
QPushButton * bnStopACQ; QPushButton * bnStopACQ;
QCheckBox * chkSaveRun; QCheckBox * chkSaveRun;
QComboBox * cbAutoRun; QComboBox * cbAutoRun;
QComboBox * cbDataFormat;
QLineEdit * leRunID; QLineEdit * leRunID;
QLineEdit * leRawDataPath; QLineEdit * leRawDataPath;
QLineEdit * leRunComment; QLineEdit * leRunComment;
@ -137,10 +150,13 @@ private:
QString stopComment; QString stopComment;
QString appendComment; QString appendComment;
bool needManualComment; bool needManualComment;
bool isRunning; bool isACQRunning;
QTimer * runTimer; QTimer * runTimer;
QElapsedTimer elapsedTimer;
unsigned int autoRunStartRunID; unsigned int autoRunStartRunID;
bool ACQStopButtonPressed;
//@----- digi Setting panel //@----- digi Setting panel
DigiSettingsPanel * digiSetting; DigiSettingsPanel * digiSetting;
@ -149,31 +165,47 @@ private:
std::vector<std::vector<int>> mapping; std::vector<std::vector<int>> mapping;
QStringList detType; QStringList detType;
std::vector<int> detMaxID; std::vector<int> detMaxID;
std::vector<int> detGroupID;
QStringList detGroupName;
//@----- Program settings //@----- Program settings
QLineEdit * lSaveSettingPath; // only live in ProgramSettigns() QLineEdit * lAnalysisPath; //for git
QLineEdit * lAnalysisPath; // only live in ProgramSettigns() QLineEdit * lExpDataPath;
QLineEdit * lDataPath; // only live in ProgramSettigns()
QLineEdit * lExpName;
QLineEdit * lIPDomain; QLineEdit * lIPDomain;
QLineEdit * lDatbaseIP; QLineEdit * lDatbaseIP;
QLineEdit * lDatbaseName; QLineEdit * lDatbaseName;
QLineEdit * lDatbaseToken;
QLineEdit * lElogIP; QLineEdit * lElogIP;
QLineEdit * lElogUser;
QLineEdit * lElogPWD;
QString settingFilePath; QCheckBox * chkSaveSubFolder;
bool isSaveSubFolder;
QStringList existGitBranches;
QString programPath;
QString analysisPath; QString analysisPath;
QString dataPath; QString masterExpDataPath;
QString expDataPath;
QString rawDataPath;
QString rootDataPath;
QString IPListStr; QString IPListStr;
QStringList IPList; QStringList IPList;
QString DatabaseIP; QString DatabaseIP;
QString DatabaseName; QString DatabaseName;
QString DatabaseToken;
QString ElogIP; QString ElogIP;
QString ElogUser;
QString ElogPWD;
//@------ experiment settings //@------ experiment settings
bool isGitExist; bool isGitExist;
bool useGit; bool useGit;
QString expName; QString expName;
QString rawDataFolder;
int runID; int runID;
QString runIDStr; QString runIDStr;
int elogID; // 0 = ready, -1 = disable, >1 = elogID int elogID; // 0 = ready, -1 = disable, >1 = elogID
@ -188,6 +220,19 @@ private:
//@------ custom comment; //@------ custom comment;
QPushButton * bnComment; QPushButton * bnComment;
void AppendComment(); void AppendComment();
QString maskText(const QString &password) {
if (password.length() <= 3) {
return password; // No masking needed for short passwords
} else if (password.length() <= 10) {
QString maskedPassword = password.left(3);
maskedPassword += QString("*").repeated(password.length() - 3);
return maskedPassword;
} else {
return password.left(3) + QString("*").repeated(7);
}
}
}; };

View File

@ -1,32 +0,0 @@
CC = g++
COPTS = -fPIC -DLINUX -O2 -std=c++17 -lpthread
CAENLIBS = -lCAEN_FELib
CURLLIBS = -lcurl
OBJS= ClassDigitizer2Gen.o influxdb.o
#
#
################################################################
all : test windowID
#
test : test.cpp ClassDigitizer2Gen.o influxdb.o
@echo "------- test"
$(CC) $(COPTS) $(OBJS) -o test test.cpp $(CAENLIBS) $(CURLLIBS)
#
ClassDigitizer2Gen.o : ClassDigitizer2Gen.cpp ClassDigitizer2Gen.h Event.h
@echo "------- ClassDigitizer2Gen.o"
$(CC) $(COPTS) -c ClassDigitizer2Gen.cpp $(CAENLIBS)
#
influxdb.o : influxdb.cpp influxdb.h
@echo "------- influxdb.o"
$(CC) $(COPTS) -c influxdb.cpp $(CURLLIBS)
#
windowID : windowID.cpp
@echo "------- windowID"
${CC} ${COPTS} -o windowID windowID.cpp -lX11 -lpng
clean :
rm -f $(ALL) $(OBJS)

View File

@ -1,123 +0,0 @@
#ifndef MANYTHREADS_H
#define MANYTHREADS_H
#include <QThread>
#include <QMutex>
#include "macro.h"
#include "ClassDigitizer2Gen.h"
#include "macro.h"
static QMutex digiMTX[MaxNumberOfDigitizer];
//^#===================================================== ReadData Thread
class ReadDataThread : public QThread {
Q_OBJECT
public:
ReadDataThread(Digitizer2Gen * dig, int digiID, QObject * parent = 0) : QThread(parent){
this->digi = dig;
this->ID = digiID;
isSaveData = false;
}
void SetSaveData(bool onOff) {this->isSaveData = onOff;}
void run(){
clock_gettime(CLOCK_REALTIME, &ta);
while(true){
digiMTX[ID].lock();
int ret = digi->ReadData();
digiMTX[ID].unlock();
if( ret == CAEN_FELib_Success){
if( isSaveData) digi->SaveDataToFile();
}else if(ret == CAEN_FELib_Stop){
digi->ErrorMsg("No more data");
//emit endOfLastData();
break;
}else{
//digi->ErrorMsg("ReadDataLoop()");
digi->evt->ClearTrace();
}
if( isSaveData ){
clock_gettime(CLOCK_REALTIME, &tb);
if( tb.tv_sec - ta.tv_sec > 2 ) {
emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetTotalFilesSize()/1024./1024.) + " MB");
//emit checkFileSize();
//double duration = tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9;
//printf("%4d, duration : %10.0f, %6.1f\n", readCount, duration, 1e9/duration);
ta = tb;
}
}
}
}
signals:
void sendMsg(const QString &msg);
//void endOfLastData();
//void checkFileSize();
private:
Digitizer2Gen * digi;
int ID;
timespec ta, tb;
bool isSaveData;
};
//^#===================================================== UpdateTrace Thread
class UpdateTraceThread : public QThread {
Q_OBJECT
public:
UpdateTraceThread(QObject * parent = 0) : QThread(parent){
waitTime = 2;
stop = false;
}
unsigned int GetWaitTimeSec() const {return waitTime;}
void SetWaitTimeSec(unsigned sec) {waitTime = sec;}
void Stop() {this->stop = true;}
void run(){
unsigned int count = 0;
stop = false;
do{
usleep(100000);
count ++;
if( count % waitTime == 0){
emit updateTrace();
}
}while(!stop);
}
signals:
void updateTrace();
private:
bool stop;
unsigned int waitTime; //100 of milisec
};
//^#======================================================= Scalar Thread
class ScalarThread : public QThread {
Q_OBJECT
public:
ScalarThread(QObject * parent = 0 ) : QThread(parent){
waitTime = 20; // 10 x 100 milisec
stop = false;
}
void Stop() { this->stop = true;}
unsigned int GetWaitTimeinSec() const {return waitTime/10;}
void run(){
unsigned int count = 0;
stop = false;
do{
usleep(100000);
count ++;
if( count % waitTime == 0){
emit updataScalar();
}
}while(!stop);
}
signals:
void updataScalar();
private:
bool stop;
unsigned int waitTime;
};
#endif

639
scope.cpp
View File

@ -12,7 +12,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
this->digi = digi; this->digi = digi;
this->nDigi = nDigi; this->nDigi = nDigi;
if( nDigi > MaxNumberOfDigitizer ) { if( nDigi > MaxNumberOfDigitizer ) {
this->nDigi = MaxNumberOfChannel; this->nDigi = MaxNumberOfDigitizer;
qDebug() << "Please increase the MaxNumberOfChannel"; qDebug() << "Please increase the MaxNumberOfChannel";
} }
this->readDataThread = readDataThread; this->readDataThread = readDataThread;
@ -22,6 +22,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
setWindowFlags( this->windowFlags() & ~Qt::WindowCloseButtonHint ); setWindowFlags( this->windowFlags() & ~Qt::WindowCloseButtonHint );
allowChange = false; allowChange = false;
originalValueSet = false;
plot = new Trace(); plot = new Trace();
for( int i = 0; i < 6; i++) { for( int i = 0; i < 6; i++) {
@ -54,8 +55,9 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
xaxis->setLabelFormat("%.0f"); xaxis->setLabelFormat("%.0f");
xaxis->setTitleText("Time [ns]"); xaxis->setTitleText("Time [ns]");
updateTraceThread = new UpdateTraceThread(); updateTraceThread = new TimingThread();
connect(updateTraceThread, &UpdateTraceThread::updateTrace, this, &Scope::UpdateScope); updateTraceThread->SetWaitTimeSec(0.2);
connect(updateTraceThread, &TimingThread::TimeUp, this, &Scope::UpdateScope);
//*================ add Widgets //*================ add Widgets
int rowID = -1; int rowID = -1;
@ -71,44 +73,43 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
layout->addWidget(cbScopeDigi, rowID, 0); layout->addWidget(cbScopeDigi, rowID, 0);
layout->addWidget(cbScopeCh, rowID, 1); layout->addWidget(cbScopeCh, rowID, 1);
connect(cbScopeDigi, &RComboBox::currentIndexChanged, this, [=](){
//if( allowChange ) StopScope();
int index = cbScopeDigi->currentIndex();
if( index == -1 ) return;
for( int i = 0; i < digi[index]->GetNChannels(); i++){
cbScopeCh->addItem("ch-" + QString::number(i), i);
}
//if( allowChange )StartScope(index);
});
connect(cbScopeCh, &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "False", -1);
digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "True", ch);
ReadScopeSettings();
digiMTX[iDigi].unlock();
});
allowChange = false; allowChange = false;
cbScopeDigi->clear(); ///this will also trigger RComboBox::currentIndexChanged cbScopeDigi->clear(); ///this will also trigger RComboBox::currentIndexChanged
cbScopeCh->clear(); cbScopeCh->clear();
for( unsigned int i = 0 ; i < nDigi; i++) { for( unsigned int i = 0 ; i < nDigi; i++) {
cbScopeDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i); cbScopeDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
} }
cbScopeDigi->setCurrentIndex(1);
allowChange = true; allowChange = true;
connect(cbScopeDigi, &RComboBox::currentIndexChanged, this, &Scope::ChangeDigitizer);
bnScopeReset = new QPushButton("ReProgram Digitizer", this); connect(cbScopeCh, &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
digiMTX[iDigi].lock();
ReadScopeSettings();
RestoreSettings(false);
if( digi[iDigi]->IsAcqOn()){
digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "False", -1);
digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "True", ch);
}
digiMTX[iDigi].unlock();
});
bnScopeReset = new QPushButton("ReProgram Channels", this);
layout->addWidget(bnScopeReset, rowID, 2); layout->addWidget(bnScopeReset, rowID, 2);
connect(bnScopeReset, &QPushButton::clicked, this, [=](){ connect(bnScopeReset, &QPushButton::clicked, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
digi[iDigi]->Reset(); //digi[iDigi]->Reset();
digi[iDigi]->ProgramPHA(false); digi[iDigi]->ProgramChannels();
SendLogMsg("Reset Digi-" + QString::number(digi[iDigi]->GetSerialNumber()) + " and Set Default PHA."); //SendLogMsg("Reset Digi-" + QString::number(digi[iDigi]->GetSerialNumber()) + " and Set Default PHA.");
ReadScopeSettings();
UpdateOtherPanels();
SendLogMsg("Re-program all Channels to default PHA settings");
}); });
bnScopeReadSettings = new QPushButton("Read Ch. Settings", this); bnScopeReadSettings = new QPushButton("Read Ch. Settings", this);
@ -125,30 +126,25 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
//------------ Probe selection //------------ Probe selection
rowID ++; rowID ++;
//TODO --- add None
cbAnaProbe[0] = new RComboBox(this);
for( int i = 0; i < (int) PHA::CH::WaveAnalogProbe0.GetAnswers().size(); i++ ) {
cbAnaProbe[0]->addItem(QString::fromStdString((PHA::CH::WaveAnalogProbe0.GetAnswers())[i].second),
QString::fromStdString((PHA::CH::WaveAnalogProbe0.GetAnswers())[i].first));
}
//TODO --- add None for probel selection
cbAnaProbe[0] = new RComboBox(this);
cbAnaProbe[1] = new RComboBox(this); cbAnaProbe[1] = new RComboBox(this);
for( int i = 0; i < cbAnaProbe[0]->count() ; i++) cbAnaProbe[1]->addItem(cbAnaProbe[0]->itemText(i), cbAnaProbe[0]->itemData(i)); cbDigProbe[0] = new RComboBox(this);
cbDigProbe[1] = new RComboBox(this);
cbDigProbe[2] = new RComboBox(this);
cbDigProbe[3] = new RComboBox(this);
connect(cbAnaProbe[0], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);}); connect(cbAnaProbe[0], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);});
connect(cbAnaProbe[1], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);}); connect(cbAnaProbe[1], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);});
cbAnaProbe[0]->setCurrentIndex(1); ///trigger the AnaProbeChange
cbAnaProbe[0]->setCurrentIndex(0);
cbAnaProbe[1]->setCurrentIndex(4);
connect(cbAnaProbe[0], &RComboBox::currentIndexChanged, this, [=](){ connect(cbAnaProbe[0], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1; if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock(); digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(PHA::CH::WaveAnalogProbe0, (cbAnaProbe[0]->currentData()).toString().toStdString(), ch); digi[iDigi]->WriteValue(anaProbeList[0], (cbAnaProbe[0]->currentData()).toString().toStdString(), ch);
digiMTX[iDigi].unlock(); digiMTX[iDigi].unlock();
}); });
@ -158,44 +154,22 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1; if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock(); digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(PHA::CH::WaveAnalogProbe1, (cbAnaProbe[1]->currentData()).toString().toStdString(), ch); digi[iDigi]->WriteValue(anaProbeList[1], (cbAnaProbe[1]->currentData()).toString().toStdString(), ch);
digiMTX[iDigi].unlock(); digiMTX[iDigi].unlock();
}); });
//TODO --- add None
cbDigProbe[0] = new RComboBox(this);
for( int i = 0; i < (int) PHA::CH::WaveDigitalProbe0.GetAnswers().size(); i++ ) {
cbDigProbe[0]->addItem(QString::fromStdString((PHA::CH::WaveDigitalProbe0.GetAnswers())[i].second),
QString::fromStdString((PHA::CH::WaveDigitalProbe0.GetAnswers())[i].first));
}
cbDigProbe[1] = new RComboBox(this);
cbDigProbe[2] = new RComboBox(this);
cbDigProbe[3] = new RComboBox(this);
for( int i = 0; i < cbDigProbe[0]->count() ; i++) {
cbDigProbe[1]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
cbDigProbe[2]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
cbDigProbe[3]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
}
connect(cbDigProbe[0], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);}); connect(cbDigProbe[0], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[1], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);}); connect(cbDigProbe[1], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[2], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);}); connect(cbDigProbe[2], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[3], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);}); connect(cbDigProbe[3], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
cbDigProbe[0]->setCurrentIndex(1); ///trigger the DigProbeChange
cbDigProbe[0]->setCurrentIndex(0);
cbDigProbe[1]->setCurrentIndex(4);
cbDigProbe[2]->setCurrentIndex(5);
cbDigProbe[3]->setCurrentIndex(6);
connect(cbDigProbe[0], &RComboBox::currentIndexChanged, this, [=](){ connect(cbDigProbe[0], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1; if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock(); digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(PHA::CH::WaveDigitalProbe0, (cbDigProbe[0]->currentData()).toString().toStdString(), ch); digi[iDigi]->WriteValue(digiProbeList[0], (cbDigProbe[0]->currentData()).toString().toStdString(), ch);
digiMTX[iDigi].unlock(); digiMTX[iDigi].unlock();
}); });
connect(cbDigProbe[1], &RComboBox::currentIndexChanged, this, [=](){ connect(cbDigProbe[1], &RComboBox::currentIndexChanged, this, [=](){
@ -204,7 +178,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1; if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock(); digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(PHA::CH::WaveDigitalProbe1, (cbDigProbe[1]->currentData()).toString().toStdString(), ch); digi[iDigi]->WriteValue(digiProbeList[1], (cbDigProbe[1]->currentData()).toString().toStdString(), ch);
digiMTX[iDigi].unlock(); digiMTX[iDigi].unlock();
}); });
connect(cbDigProbe[2], &RComboBox::currentIndexChanged, this, [=](){ connect(cbDigProbe[2], &RComboBox::currentIndexChanged, this, [=](){
@ -213,7 +187,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1; if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock(); digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(PHA::CH::WaveDigitalProbe2, (cbDigProbe[2]->currentData()).toString().toStdString(), ch); digi[iDigi]->WriteValue(digiProbeList[2], (cbDigProbe[2]->currentData()).toString().toStdString(), ch);
digiMTX[iDigi].unlock(); digiMTX[iDigi].unlock();
}); });
connect(cbDigProbe[3], &RComboBox::currentIndexChanged, this, [=](){ connect(cbDigProbe[3], &RComboBox::currentIndexChanged, this, [=](){
@ -222,7 +196,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1; if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock(); digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(PHA::CH::WaveDigitalProbe3, (cbDigProbe[3]->currentData()).toString().toStdString(), ch); digi[iDigi]->WriteValue(digiProbeList[3], (cbDigProbe[3]->currentData()).toString().toStdString(), ch);
digiMTX[iDigi].unlock(); digiMTX[iDigi].unlock();
}); });
@ -237,40 +211,25 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
for( int i = 0; i < 6; i++) layout->setColumnStretch(i, 1); for( int i = 0; i < 6; i++) layout->setColumnStretch(i, 1);
rowID ++; rowID ++;
{//------------ wave settings
QGroupBox * box = new QGroupBox("Channel Settings (need ACQ stop)", this);
layout->addWidget(box, rowID, 0, 1, 6);
QGridLayout * bLayout = new QGridLayout(box); {//------------ wave settings
settingBox = new QGroupBox("Channel Settings (need ACQ stop)", this);
layout->addWidget(settingBox, rowID, 0, 1, 6);
bLayout = new QGridLayout(settingBox);
bLayout->setSpacing(0); bLayout->setSpacing(0);
ScopeMakeSpinBox(sbRL, "Record Lenght [ns] ", bLayout, 0, 0, PHA::CH::RecordLength); if( digi[0]->GetFPGAType() == DPPType::PHA ) SetupPHA();
ScopeMakeSpinBox(sbThreshold, "Threshold [LSB] ", bLayout, 0, 2, PHA::CH::TriggerThreshold);
ScopeMakeComoBox(cbPolarity, "Polarity ", bLayout, 0, 4, PHA::CH::Polarity);
ScopeMakeComoBox(cbWaveRes, "Wave Re. ", bLayout, 0, 6, PHA::CH::WaveResolution);
//------------------ next row if( digi[0]->GetFPGAType() == DPPType::PSD ) SetupPSD();
ScopeMakeSpinBox(sbPT, "Pre Trigger [ns] ", bLayout, 1, 0, PHA::CH::PreTrigger);
ScopeMakeSpinBox(sbDCOffset, "DC offset [%] ", bLayout, 1, 2, PHA::CH::DC_Offset);
ScopeMakeSpinBox(sbTimeRiseTime, "Trigger Rise Time [ns] ", bLayout, 1, 4, PHA::CH::TimeFilterRiseTime);
ScopeMakeSpinBox(sbTimeGuard, "Trigger Guard [ns] ", bLayout, 1, 6, PHA::CH::TimeFilterRetriggerGuard);
//----------------- next row
ScopeMakeSpinBox(sbTrapRiseTime, "Trap. Rise Time [ns] ", bLayout, 2, 0, PHA::CH::EnergyFilterRiseTime);
ScopeMakeSpinBox(sbTrapFlatTop, "Trap. Flat Top [ns] ", bLayout, 2, 2, PHA::CH::EnergyFilterFlatTop);
ScopeMakeSpinBox(sbTrapPoleZero, "Trap. Pole Zero [ns] ", bLayout, 2, 4, PHA::CH::EnergyFilterPoleZero);
ScopeMakeSpinBox(sbEnergyFineGain, "Energy Fine Gain ", bLayout, 2, 6, PHA::CH::EnergyFilterFineGain);
//----------------- next row
ScopeMakeSpinBox(sbTrapPeaking, "Trap. Peaking [%] ", bLayout, 3, 0, PHA::CH::EnergyFilterPeakingPosition);
ScopeMakeComoBox(cbTrapPeakAvg, "Trap. Peaking ", bLayout, 3, 2, PHA::CH::EnergyFilterPeakingAvg);
ScopeMakeSpinBox(sbBaselineGuard, "Baseline Guard [ns] ", bLayout, 3, 4, PHA::CH::EnergyFilterBaselineGuard);
ScopeMakeComoBox(cbBaselineAvg, "Baseline Avg ", bLayout, 3, 6, PHA::CH::EnergyFilterBaselineAvg);
ScopeMakeSpinBox(sbPileUpGuard, "Pile-up Guard [ns] ", bLayout, 4, 0, PHA::CH::EnergyFilterPileUpGuard);
ScopeMakeComoBox(cbLowFreqFilter, "Low Freq. Filter ", bLayout, 4, 2, PHA::CH::EnergyFilterLowFreqFilter);
} }
//Trigger the ChangeDigitizer()
cbScopeDigi->setCurrentIndex(0);
cbScopeCh->setCurrentIndex(1);
cbScopeCh->setCurrentIndex(0);
//------------ plot view //------------ plot view
rowID ++; rowID ++;
TraceView * plotView = new TraceView(plot); TraceView * plotView = new TraceView(plot);
@ -282,7 +241,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
QLabel * lbhints = new QLabel("Type 'r' to restore view, '+/-' Zoom in/out, arrow key to pan.", this); QLabel * lbhints = new QLabel("Type 'r' to restore view, '+/-' Zoom in/out, arrow key to pan.", this);
layout->addWidget(lbhints, rowID, 0, 1, 4); layout->addWidget(lbhints, rowID, 0, 1, 4);
QLabel * lbinfo = new QLabel("Trace update every " + QString::number(updateTraceThread->GetWaitTimeSec()) + " sec.", this); QLabel * lbinfo = new QLabel("Trace update every " + QString::number(updateTraceThread->GetWaitTimeinSec()) + " sec.", this);
lbinfo->setAlignment(Qt::AlignRight); lbinfo->setAlignment(Qt::AlignRight);
layout->addWidget(lbinfo, rowID, 5); layout->addWidget(lbinfo, rowID, 5);
@ -294,11 +253,12 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
rowID ++; rowID ++;
bnScopeStart = new QPushButton("Start", this); bnScopeStart = new QPushButton("Start", this);
layout->addWidget(bnScopeStart, rowID, 0); layout->addWidget(bnScopeStart, rowID, 0);
bnScopeStart->setEnabled(false); bnScopeStart->setEnabled(true);
connect(bnScopeStart, &QPushButton::clicked, this, [=](){this->StartScope();}); connect(bnScopeStart, &QPushButton::clicked, this, [=](){this->StartScope();});
bnScopeStop = new QPushButton("Stop", this); bnScopeStop = new QPushButton("Stop", this);
layout->addWidget(bnScopeStop, rowID, 1); layout->addWidget(bnScopeStop, rowID, 1);
bnScopeStop->setEnabled(false);
connect(bnScopeStop, &QPushButton::clicked, this, &Scope::StopScope); connect(bnScopeStop, &QPushButton::clicked, this, &Scope::StopScope);
QLabel * lbTriggerRate = new QLabel("Trigger Rate [Hz] : ", this); QLabel * lbTriggerRate = new QLabel("Trigger Rate [Hz] : ", this);
@ -316,17 +276,185 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
show(); show();
StartScope(); //StartScope();
UpdateSettingsFromMemeory();
oldDigi = cbScopeDigi->currentIndex();
oldCh = cbScopeCh->currentIndex();;
waveSaving = digi[oldDigi]->ReadValue(PHA::CH::WaveSaving, oldCh);
waveTriggerSource = digi[oldDigi]->ReadValue(PHA::CH::WaveTriggerSource, oldCh);
clockSource = digi[oldDigi]->ReadValue(PHA::DIG::ClockSource);
startSource = digi[oldDigi]->ReadValue(PHA::DIG::StartSource);
syncOutMode = digi[oldDigi]->ReadValue(PHA::DIG::SyncOutMode);
for( int ch2 = 0 ; ch2 < digi[oldDigi]->GetNChannels(); ch2 ++){
channelEnable[oldDigi][ch2] = digi[oldDigi]->ReadValue(PHA::CH::ChannelEnable, ch2);
}
originalValueSet = true;
} }
Scope::~Scope(){ Scope::~Scope(){
printf("------- %s \n", __func__);
StopScope();
updateTraceThread->Stop(); updateTraceThread->Stop();
updateTraceThread->quit(); updateTraceThread->quit();
updateTraceThread->wait(); updateTraceThread->wait();
delete updateTraceThread; delete updateTraceThread;
for( int i = 0; i < 6; i++) delete dataTrace[i]; for( int i = 0; i < 6; i++) delete dataTrace[i];
delete plot; delete plot;
printf("------- end of %s \n", __func__);
}
void Scope::ChangeDigitizer(){
int index = cbScopeDigi->currentIndex();
if( index == -1 ) return;
allowChange = false;
cbScopeCh->clear();
for( int i = 0; i < digi[index]->GetNChannels(); i++){
cbScopeCh->addItem("ch-" + QString::number(i), i);
}
cbScopeCh->setCurrentIndex(0);
anaProbeList.clear();
digiProbeList.clear();
if( digi[index]->GetFPGAType() == DPPType::PHA ) {
anaProbeList.push_back(PHA::CH::WaveAnalogProbe0);
anaProbeList.push_back(PHA::CH::WaveAnalogProbe1);
digiProbeList.push_back(PHA::CH::WaveDigitalProbe0);
digiProbeList.push_back(PHA::CH::WaveDigitalProbe1);
digiProbeList.push_back(PHA::CH::WaveDigitalProbe2);
digiProbeList.push_back(PHA::CH::WaveDigitalProbe3);
}
if( digi[index]->GetFPGAType() == DPPType::PSD){
anaProbeList.push_back(PSD::CH::WaveAnalogProbe0);
anaProbeList.push_back(PSD::CH::WaveAnalogProbe1);
digiProbeList.push_back(PSD::CH::WaveDigitalProbe0);
digiProbeList.push_back(PSD::CH::WaveDigitalProbe1);
digiProbeList.push_back(PSD::CH::WaveDigitalProbe2);
digiProbeList.push_back(PSD::CH::WaveDigitalProbe3);
}
cbAnaProbe[0]->clear();
cbAnaProbe[1]->clear();
for( int i = 0; i < (int) anaProbeList[0].GetAnswers().size(); i++ ) {
cbAnaProbe[0]->addItem(QString::fromStdString((anaProbeList[0].GetAnswers())[i].second),
QString::fromStdString((anaProbeList[0].GetAnswers())[i].first));
}
for( int i = 0; i < cbAnaProbe[0]->count() ; i++) cbAnaProbe[1]->addItem(cbAnaProbe[0]->itemText(i), cbAnaProbe[0]->itemData(i));
cbDigProbe[0]->clear();
cbDigProbe[1]->clear();
cbDigProbe[2]->clear();
cbDigProbe[3]->clear();
for( int i = 0; i < (int) digiProbeList[0].GetAnswers().size(); i++ ) {
cbDigProbe[0]->addItem(QString::fromStdString((digiProbeList[0].GetAnswers())[i].second),
QString::fromStdString((digiProbeList[0].GetAnswers())[i].first));
}
for( int i = 0; i < cbDigProbe[0]->count() ; i++) {
cbDigProbe[1]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
cbDigProbe[2]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
cbDigProbe[3]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
}
if( digi[index]->GetFPGAType() == DPPType::PHA ) SetupPHA();
if( digi[index]->GetFPGAType() == DPPType::PSD ) SetupPSD();
digiMTX[index].lock();
ReadScopeSettings();
if( digi[index]->IsAcqOn() ){
digi[index]->WriteValue(PHA::CH::ChannelEnable, "False", -1);
digi[index]->WriteValue(PHA::CH::ChannelEnable, "True", cbScopeCh->currentIndex());
}
digiMTX[index].unlock();
allowChange = true;
}
void Scope::CleanUpSettingsGroupBox(){
QList<QLabel *> labelChildren1 = settingBox->findChildren<QLabel *>();
for( int i = 0; i < labelChildren1.size(); i++) delete labelChildren1[i];
QList<RComboBox *> labelChildren2 = settingBox->findChildren<RComboBox *>();
for( int i = 0; i < labelChildren2.size(); i++) delete labelChildren2[i];
QList<RSpinBox *> labelChildren3 = settingBox->findChildren<RSpinBox *>();
for( int i = 0; i < labelChildren3.size(); i++) delete labelChildren3[i];
}
void Scope::SetupPHA(){
CleanUpSettingsGroupBox();
ScopeMakeSpinBox(sbRL, "Record Lenght [ns] ", bLayout, 0, 0, PHA::CH::RecordLength);
ScopeMakeSpinBox(sbThreshold, "Threshold [LSB] ", bLayout, 0, 2, PHA::CH::TriggerThreshold);
ScopeMakeComoBox(cbPolarity, "Polarity ", bLayout, 0, 4, PHA::CH::Polarity);
ScopeMakeComoBox(cbWaveRes, "Wave Re. ", bLayout, 0, 6, PHA::CH::WaveResolution);
//------------------ next row
ScopeMakeSpinBox(sbPT, "Pre Trigger [ns] ", bLayout, 1, 0, PHA::CH::PreTrigger);
ScopeMakeSpinBox(sbDCOffset, "DC offset [%] ", bLayout, 1, 2, PHA::CH::DC_Offset);
ScopeMakeSpinBox(sbTimeRiseTime, "Trigger Rise Time [ns] ", bLayout, 1, 4, PHA::CH::TimeFilterRiseTime);
ScopeMakeSpinBox(sbTimeGuard, "Trigger Guard [ns] ", bLayout, 1, 6, PHA::CH::TimeFilterRetriggerGuard);
//----------------- next row
ScopeMakeSpinBox(sbTrapRiseTime, "Trap. Rise Time [ns] ", bLayout, 2, 0, PHA::CH::EnergyFilterRiseTime);
ScopeMakeSpinBox(sbTrapFlatTop, "Trap. Flat Top [ns] ", bLayout, 2, 2, PHA::CH::EnergyFilterFlatTop);
ScopeMakeSpinBox(sbTrapPoleZero, "Trap. Pole Zero [ns] ", bLayout, 2, 4, PHA::CH::EnergyFilterPoleZero);
ScopeMakeSpinBox(sbEnergyFineGain, "Energy Fine Gain ", bLayout, 2, 6, PHA::CH::EnergyFilterFineGain);
//----------------- next row
ScopeMakeSpinBox(sbTrapPeaking, "Trap. Peaking [%] ", bLayout, 3, 0, PHA::CH::EnergyFilterPeakingPosition);
ScopeMakeComoBox(cbTrapPeakAvg, "Trap. Peaking ", bLayout, 3, 2, PHA::CH::EnergyFilterPeakingAvg);
ScopeMakeSpinBox(sbBaselineGuard, "Baseline Guard [ns] ", bLayout, 3, 4, PHA::CH::EnergyFilterBaselineGuard);
ScopeMakeComoBox(cbBaselineAvg, "Baseline Avg ", bLayout, 3, 6, PHA::CH::EnergyFilterBaselineAvg);
//----------------- next row
ScopeMakeSpinBox(sbPileUpGuard, "Pile-up Guard [ns] ", bLayout, 4, 0, PHA::CH::EnergyFilterPileUpGuard);
ScopeMakeComoBox(cbLowFreqFilter, "Low Freq. Filter ", bLayout, 4, 2, PHA::CH::EnergyFilterLowFreqFilter);
}
void Scope::SetupPSD(){
CleanUpSettingsGroupBox();
ScopeMakeSpinBox(sbRL, "Record Lenght [ns] ", bLayout, 0, 0, PSD::CH::RecordLength);
ScopeMakeSpinBox(sbThreshold, "Threshold [LSB] ", bLayout, 0, 2, PSD::CH::TriggerThreshold);
ScopeMakeComoBox(cbPolarity, "Polarity ", bLayout, 0, 4, PSD::CH::Polarity);
ScopeMakeComoBox(cbWaveRes, "Wave Re. ", bLayout, 0, 6, PSD::CH::WaveResolution);
//------------------ next row
ScopeMakeSpinBox(sbPT, "Pre Trigger [ns] ", bLayout, 1, 0, PSD::CH::PreTrigger);
ScopeMakeSpinBox(sbDCOffset, "DC offset [%] ", bLayout, 1, 2, PSD::CH::DC_Offset);
ScopeMakeComoBox(cbbADCInputBaselineAvg, "ADC BL Avg. ", bLayout, 1, 4, PSD::CH::ADCInputBaselineAvg);
ScopeMakeSpinBox(spbADCInputBaselineGuard, "ADC BL Guard [ns] ", bLayout, 1, 6, PSD::CH::ADCInputBaselineGuard);
//------------------ next row
ScopeMakeSpinBox(spbCFDDelay, "CFD Delay [ns] ", bLayout, 2, 0, PSD::CH::CFDDelay);
ScopeMakeSpinBox(spbCFDFraction, "CFD Frac. [%] ", bLayout, 2, 2, PSD::CH::CFDFraction);
ScopeMakeComoBox(cbbSmoothingFactor, "Smoothing ", bLayout, 2, 4, PSD::CH::SmoothingFactor);
ScopeMakeSpinBox(spbAbsBaseline, "Abs. BL ", bLayout, 2, 6, PSD::CH::AbsoluteBaseline);
//------------------ next row
ScopeMakeComoBox(cbbTriggerFilter, "Trig. Filter ", bLayout, 3, 0, PSD::CH::TriggerFilterSelection);
ScopeMakeComoBox(cbbTimeFilterSmoothing, "Trig. Smooth ", bLayout, 3, 2, PSD::CH::TimeFilterSmoothing);
ScopeMakeSpinBox(spbTimeFilterReTriggerGuard, "Trig. Guard [ns] ", bLayout, 3, 4, PSD::CH::TimeFilterRetriggerGuard);
ScopeMakeSpinBox(spbPileupGap, "PileUp Gap [ns] ", bLayout, 3, 6, PSD::CH::PileupGap);
//------------------ next row
ScopeMakeSpinBox(spbGateLong, "Long Gate [ns] ", bLayout, 4, 0, PSD::CH::GateLongLength);
ScopeMakeSpinBox(spbGateShort, "Shart Gate [ns] ", bLayout, 4, 2, PSD::CH::GateLongLength);
ScopeMakeSpinBox(spbGateOffset, "Gate offset [ns] ", bLayout, 4, 4, PSD::CH::GateLongLength);
ScopeMakeComoBox(cbbEnergyGain, "Energy Gain ", bLayout, 4, 6, PSD::CH::EnergyGain);
} }
void Scope::ReadScopeSettings(){ void Scope::ReadScopeSettings(){
@ -336,34 +464,6 @@ void Scope::ReadScopeSettings(){
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
if( !digi[iDigi] || digi[iDigi]->IsDummy() || !digi[iDigi]->IsConnected()) return; if( !digi[iDigi] || digi[iDigi]->IsDummy() || !digi[iDigi]->IsConnected()) return;
int ch = cbScopeCh->currentIndex();
digi[iDigi]->ReadValue(PHA::CH::WaveAnalogProbe0, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveAnalogProbe1, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveDigitalProbe0, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveDigitalProbe1, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveDigitalProbe2, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveDigitalProbe3, ch);
digi[iDigi]->ReadValue(PHA::CH::Polarity, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveResolution, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterPeakingAvg, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterBaselineAvg, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterLowFreqFilter, ch);
digi[iDigi]->ReadValue(PHA::CH::RecordLength, ch);
digi[iDigi]->ReadValue(PHA::CH::PreTrigger, ch);
digi[iDigi]->ReadValue(PHA::CH::DC_Offset, ch);
digi[iDigi]->ReadValue(PHA::CH::TriggerThreshold, ch);
digi[iDigi]->ReadValue(PHA::CH::TimeFilterRiseTime, ch);
digi[iDigi]->ReadValue(PHA::CH::TimeFilterRetriggerGuard, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterRiseTime, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterFlatTop, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterPoleZero, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterFineGain, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterPeakingPosition, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterBaselineGuard, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterPileUpGuard, ch);
UpdateSettingsFromMemeory(); UpdateSettingsFromMemeory();
} }
@ -381,50 +481,131 @@ void Scope::UpdateSettingsFromMemeory(){
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
for( int i = 0 ; i < 2; i++){ for( int i = 0 ; i < 2; i++){
ScopeReadComboBoxValue(iDigi, ch, cbAnaProbe[i], PHA::CH::AnalogProbe[i]); if( digi[iDigi]->GetFPGAType() == DPPType::PHA ) ScopeReadComboBoxValue(iDigi, ch, cbAnaProbe[i], PHA::CH::AnalogProbe[i]);
if( digi[iDigi]->GetFPGAType() == DPPType::PSD ) ScopeReadComboBoxValue(iDigi, ch, cbAnaProbe[i], PSD::CH::AnalogProbe[i]);
} }
for( int i = 0 ; i < 4; i++){ for( int i = 0 ; i < 4; i++){
ScopeReadComboBoxValue(iDigi, ch, cbDigProbe[i], PHA::CH::DigitalProbe[i]); if( digi[iDigi]->GetFPGAType() == DPPType::PHA ) ScopeReadComboBoxValue(iDigi, ch, cbDigProbe[i], PHA::CH::DigitalProbe[i]);
if( digi[iDigi]->GetFPGAType() == DPPType::PSD ) ScopeReadComboBoxValue(iDigi, ch, cbDigProbe[i], PSD::CH::DigitalProbe[i]);
} }
ScopeReadComboBoxValue(iDigi, ch, cbPolarity, PHA::CH::Polarity); if( digi[iDigi]->GetFPGAType() == DPPType::PHA ){
ScopeReadComboBoxValue(iDigi, ch, cbWaveRes, PHA::CH::WaveResolution); ScopeReadComboBoxValue(iDigi, ch, cbPolarity, PHA::CH::Polarity);
ScopeReadComboBoxValue(iDigi, ch, cbTrapPeakAvg, PHA::CH::EnergyFilterPeakingAvg); ScopeReadComboBoxValue(iDigi, ch, cbWaveRes, PHA::CH::WaveResolution);
ScopeReadComboBoxValue(iDigi, ch, cbBaselineAvg, PHA::CH::EnergyFilterBaselineAvg); ScopeReadComboBoxValue(iDigi, ch, cbTrapPeakAvg, PHA::CH::EnergyFilterPeakingAvg);
ScopeReadComboBoxValue(iDigi, ch, cbLowFreqFilter, PHA::CH::EnergyFilterLowFreqFilter); ScopeReadComboBoxValue(iDigi, ch, cbBaselineAvg, PHA::CH::EnergyFilterBaselineAvg);
ScopeReadComboBoxValue(iDigi, ch, cbLowFreqFilter, PHA::CH::EnergyFilterLowFreqFilter);
ScopeReadSpinBoxValue(iDigi, ch, sbRL, PHA::CH::RecordLength); ScopeReadSpinBoxValue(iDigi, ch, sbRL, PHA::CH::RecordLength);
ScopeReadSpinBoxValue(iDigi, ch, sbPT, PHA::CH::PreTrigger); ScopeReadSpinBoxValue(iDigi, ch, sbPT, PHA::CH::PreTrigger);
ScopeReadSpinBoxValue(iDigi, ch, sbDCOffset, PHA::CH::DC_Offset); ScopeReadSpinBoxValue(iDigi, ch, sbDCOffset, PHA::CH::DC_Offset);
ScopeReadSpinBoxValue(iDigi, ch, sbThreshold, PHA::CH::TriggerThreshold); ScopeReadSpinBoxValue(iDigi, ch, sbThreshold, PHA::CH::TriggerThreshold);
ScopeReadSpinBoxValue(iDigi, ch, sbTimeRiseTime, PHA::CH::TimeFilterRiseTime); ScopeReadSpinBoxValue(iDigi, ch, sbTimeRiseTime, PHA::CH::TimeFilterRiseTime);
ScopeReadSpinBoxValue(iDigi, ch, sbTimeGuard, PHA::CH::TimeFilterRetriggerGuard); ScopeReadSpinBoxValue(iDigi, ch, sbTimeGuard, PHA::CH::TimeFilterRetriggerGuard);
ScopeReadSpinBoxValue(iDigi, ch, sbTrapRiseTime, PHA::CH::EnergyFilterRiseTime); ScopeReadSpinBoxValue(iDigi, ch, sbTrapRiseTime, PHA::CH::EnergyFilterRiseTime);
ScopeReadSpinBoxValue(iDigi, ch, sbTrapFlatTop, PHA::CH::EnergyFilterFlatTop); ScopeReadSpinBoxValue(iDigi, ch, sbTrapFlatTop, PHA::CH::EnergyFilterFlatTop);
ScopeReadSpinBoxValue(iDigi, ch, sbTrapPoleZero, PHA::CH::EnergyFilterPoleZero); ScopeReadSpinBoxValue(iDigi, ch, sbTrapPoleZero, PHA::CH::EnergyFilterPoleZero);
ScopeReadSpinBoxValue(iDigi, ch, sbEnergyFineGain, PHA::CH::EnergyFilterFineGain); ScopeReadSpinBoxValue(iDigi, ch, sbEnergyFineGain, PHA::CH::EnergyFilterFineGain);
ScopeReadSpinBoxValue(iDigi, ch, sbTrapPeaking, PHA::CH::EnergyFilterPeakingPosition); ScopeReadSpinBoxValue(iDigi, ch, sbTrapPeaking, PHA::CH::EnergyFilterPeakingPosition);
ScopeReadSpinBoxValue(iDigi, ch, sbBaselineGuard, PHA::CH::EnergyFilterBaselineGuard); ScopeReadSpinBoxValue(iDigi, ch, sbBaselineGuard, PHA::CH::EnergyFilterBaselineGuard);
ScopeReadSpinBoxValue(iDigi, ch, sbPileUpGuard, PHA::CH::EnergyFilterPileUpGuard); ScopeReadSpinBoxValue(iDigi, ch, sbPileUpGuard, PHA::CH::EnergyFilterPileUpGuard);
sbRL->setStyleSheet(""); sbRL->setStyleSheet("");
sbPT->setStyleSheet(""); sbPT->setStyleSheet("");
sbThreshold->setStyleSheet(""); sbThreshold->setStyleSheet("");
sbTimeRiseTime->setStyleSheet(""); sbTimeRiseTime->setStyleSheet("");
sbTimeGuard->setStyleSheet(""); sbTimeGuard->setStyleSheet("");
sbTrapRiseTime->setStyleSheet(""); sbTrapRiseTime->setStyleSheet("");
sbTrapFlatTop->setStyleSheet(""); sbTrapFlatTop->setStyleSheet("");
sbTrapPoleZero->setStyleSheet(""); sbTrapPoleZero->setStyleSheet("");
sbEnergyFineGain->setStyleSheet(""); sbEnergyFineGain->setStyleSheet("");
sbTrapPeaking->setStyleSheet(""); sbTrapPeaking->setStyleSheet("");
sbBaselineGuard->setStyleSheet(""); sbBaselineGuard->setStyleSheet("");
sbPileUpGuard->setStyleSheet(""); sbPileUpGuard->setStyleSheet("");
}
if( digi[iDigi]->GetFPGAType() == DPPType::PSD ){
ScopeReadComboBoxValue(iDigi, ch, cbPolarity, PSD::CH::Polarity);
ScopeReadComboBoxValue(iDigi, ch, cbWaveRes, PSD::CH::WaveResolution);
ScopeReadComboBoxValue(iDigi, ch, cbbADCInputBaselineAvg, PSD::CH::ADCInputBaselineAvg);
ScopeReadComboBoxValue(iDigi, ch, cbbSmoothingFactor, PSD::CH::SmoothingFactor);
ScopeReadComboBoxValue(iDigi, ch, cbbTriggerFilter, PSD::CH::TriggerFilterSelection);
ScopeReadComboBoxValue(iDigi, ch, cbbTimeFilterSmoothing, PSD::CH::TimeFilterSmoothing);
ScopeReadComboBoxValue(iDigi, ch, cbbEnergyGain, PSD::CH::EnergyGain);
ScopeReadSpinBoxValue(iDigi, ch, sbRL, PSD::CH::RecordLength);
ScopeReadSpinBoxValue(iDigi, ch, sbThreshold, PSD::CH::TriggerThreshold);
ScopeReadSpinBoxValue(iDigi, ch, sbPT, PSD::CH::PreTrigger);
ScopeReadSpinBoxValue(iDigi, ch, sbDCOffset, PSD::CH::DC_Offset);
ScopeReadSpinBoxValue(iDigi, ch, spbADCInputBaselineGuard, PSD::CH::ADCInputBaselineGuard);
ScopeReadSpinBoxValue(iDigi, ch, spbCFDDelay, PSD::CH::CFDDelay);
ScopeReadSpinBoxValue(iDigi, ch, spbCFDFraction, PSD::CH::CFDFraction);
ScopeReadSpinBoxValue(iDigi, ch, spbAbsBaseline, PSD::CH::AbsoluteBaseline);
ScopeReadSpinBoxValue(iDigi, ch, spbTimeFilterReTriggerGuard, PSD::CH::TimeFilterRetriggerGuard);
ScopeReadSpinBoxValue(iDigi, ch, spbPileupGap, PSD::CH::PileupGap);
ScopeReadSpinBoxValue(iDigi, ch, spbGateLong, PSD::CH::GateLongLength);
ScopeReadSpinBoxValue(iDigi, ch, spbGateShort, PSD::CH::GateShortLength);
ScopeReadSpinBoxValue(iDigi, ch, spbGateOffset, PSD::CH::GateOffset);
cbPolarity->setStyleSheet("");
cbWaveRes->setStyleSheet("");
cbbADCInputBaselineAvg->setStyleSheet("");
cbbSmoothingFactor->setStyleSheet("");
cbbTriggerFilter->setStyleSheet("");
cbbTimeFilterSmoothing->setStyleSheet("");
cbbEnergyGain->setStyleSheet("");
sbRL->setStyleSheet("");
sbThreshold->setStyleSheet("");
sbPT->setStyleSheet("");
sbDCOffset->setStyleSheet("");
spbADCInputBaselineGuard->setStyleSheet("");
spbCFDDelay->setStyleSheet("");
spbCFDFraction->setStyleSheet("");
spbAbsBaseline->setStyleSheet("");
spbTimeFilterReTriggerGuard->setStyleSheet("");
spbPileupGap->setStyleSheet("");
spbGateLong->setStyleSheet("");
spbGateShort->setStyleSheet("");
spbGateOffset->setStyleSheet("");
}
allowChange = true; allowChange = true;
} }
void Scope::RestoreSettings(bool changeBoard){
if( !originalValueSet) return;
//restore for old digi and old ch
if( changeBoard ){
digi[oldDigi]->WriteValue(PHA::DIG::ClockSource, clockSource);
digi[oldDigi]->WriteValue(PHA::DIG::StartSource, startSource);
digi[oldDigi]->WriteValue(PHA::DIG::SyncOutMode, syncOutMode);
}
digi[oldDigi]->WriteValue(PHA::CH::WaveSaving, waveSaving, oldCh);
digi[oldDigi]->WriteValue(PHA::CH::WaveTriggerSource, waveTriggerSource, oldCh);
// back up data for new digi and ch
int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
waveSaving = digi[iDigi]->ReadValue(PHA::CH::WaveSaving, ch);
waveTriggerSource = digi[iDigi]->ReadValue(PHA::CH::WaveTriggerSource, ch);
if( changeBoard ){
clockSource = digi[iDigi]->ReadValue(PHA::DIG::ClockSource);
startSource = digi[iDigi]->ReadValue(PHA::DIG::StartSource);
syncOutMode = digi[iDigi]->ReadValue(PHA::DIG::SyncOutMode);
}
oldDigi = iDigi;
oldCh = ch;
}
void Scope::StartScope(){ void Scope::StartScope(){
if( !digi ) return; if( !digi ) return;
@ -440,10 +621,32 @@ void Scope::StartScope(){
ReadScopeSettings(); ReadScopeSettings();
/// the settings are the same for PHA and PSD
for( int ch2 = 0 ; ch2 < digi[iDigi]->GetNChannels(); ch2 ++){
channelEnable[iDigi][ch2] = digi[iDigi]->ReadValue(PHA::CH::ChannelEnable, ch2);
}
digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "False", -1); digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "False", -1);
digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "True", ch);
digi[iDigi]->SetPHADataFormat(0);
if( iDigi == cbScopeDigi->currentIndex() ){
clockSource = digi[iDigi]->ReadValue(PHA::DIG::ClockSource);
startSource = digi[iDigi]->ReadValue(PHA::DIG::StartSource);
syncOutMode = digi[iDigi]->ReadValue(PHA::DIG::SyncOutMode);
waveSaving = digi[iDigi]->ReadValue(PHA::CH::WaveSaving, ch);
waveTriggerSource = digi[iDigi]->ReadValue(PHA::CH::WaveTriggerSource, ch);
oldDigi = iDigi;
oldCh = ch;
digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "True", ch);
digi[iDigi]->WriteValue(PHA::CH::WaveSaving, "Always", ch);
digi[iDigi]->WriteValue(PHA::CH::WaveTriggerSource, "ChSelfTrigger", ch);
digi[iDigi]->WriteValue(PHA::DIG::ClockSource, "Internal");
digi[iDigi]->WriteValue(PHA::DIG::StartSource, "SWcmd");
digi[iDigi]->WriteValue(PHA::DIG::SyncOutMode, "Disabled");
}
digi[iDigi]->SetDataFormat(DataFormat::ALL);
digi[iDigi]->StartACQ(); digi[iDigi]->StartACQ();
readDataThread[iDigi]->SetSaveData(false); readDataThread[iDigi]->SetSaveData(false);
@ -466,16 +669,23 @@ void Scope::StopScope(){
updateTraceThread->quit(); updateTraceThread->quit();
updateTraceThread->wait(); updateTraceThread->wait();
/// the settings are the same for PHA and PSD
if(digi){ if(digi){
for(int i = 0; i < nDigi; i++){ for(int i = 0; i < nDigi; i++){
if( digi[i]->IsDummy() ) continue; if( digi[i]->IsDummy() ) continue;
digiMTX[i].lock();
digi[i]->StopACQ();
digi[i]->WriteValue(PHA::CH::ChannelEnable, "True", -1);
digiMTX[i].unlock();
readDataThread[i]->Stop();
readDataThread[i]->quit(); readDataThread[i]->quit();
readDataThread[i]->wait(); readDataThread[i]->wait();
digiMTX[i].lock();
digi[i]->StopACQ();
for( int ch2 = 0 ; ch2 < digi[i]->GetNChannels(); ch2 ++){
digi[i]->WriteValue(PHA::CH::ChannelEnable, channelEnable[i][ch2], ch2);
}
RestoreSettings(true);
digiMTX[i].unlock();
} }
emit TellACQOnOff(false); emit TellACQOnOff(false);
@ -495,6 +705,8 @@ void Scope::UpdateScope(){
emit UpdateScalar(); emit UpdateScalar();
/// the settings are the same for PHA and PSD
if( digi ){ if( digi ){
digiMTX[iDigi].lock(); digiMTX[iDigi].lock();
@ -502,8 +714,8 @@ void Scope::UpdateScope(){
std::string haha = digi[iDigi]->ReadValue(PHA::CH::SelfTrgRate, ch); std::string haha = digi[iDigi]->ReadValue(PHA::CH::SelfTrgRate, ch);
leTriggerRate->setText(QString::fromStdString(haha)); leTriggerRate->setText(QString::fromStdString(haha));
//unsigned int traceLength = qMin((int) digi[iDigi]->evt->traceLenght, MaxDisplayTraceDataLength); //unsigned int traceLength = qMin((int) digi[iDigi]->hit->traceLenght, MaxDisplayTraceDataLength);
unsigned int traceLength = qMin( atoi(digi[iDigi]->GetSettingValue(PHA::CH::RecordLength, ch).c_str())/sample2ns, MaxDisplayTraceDataLength ); unsigned int traceLength = qMin( atoi(digi[iDigi]->GetSettingValueFromMemory(PHA::CH::RecordLength, ch).c_str())/sample2ns, MaxDisplayTraceDataLength );
if( atoi(haha.c_str()) == 0 ) { if( atoi(haha.c_str()) == 0 ) {
digiMTX[iDigi].unlock(); digiMTX[iDigi].unlock();
@ -517,16 +729,19 @@ void Scope::UpdateScope(){
return; return;
} }
//printf("%s, traceLength : %d , %d\n", __func__, traceLength, digi[iDigi]->hit->analog_probes[0][10]);
for( int j = 0; j < 2; j++) { for( int j = 0; j < 2; j++) {
QVector<QPointF> points; QVector<QPointF> points;
for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , digi[iDigi]->evt->analog_probes[j][i])); for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , digi[iDigi]->hit->analog_probes[j][i]));
dataTrace[j]->replace(points); dataTrace[j]->replace(points);
} }
for( int j = 0; j < 4; j++) { for( int j = 0; j < 4; j++) {
QVector<QPointF> points; QVector<QPointF> points;
for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , (j+1)*1000 + 4000*digi[iDigi]->evt->digital_probes[j][i])); for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , (j+1)*5000 + 4000*digi[iDigi]->hit->digital_probes[j][i]));
dataTrace[j+2]->replace(points); dataTrace[j+2]->replace(points);
} }
//digi[iDigi]->hit->ClearTrace();
digiMTX[iDigi].unlock(); digiMTX[iDigi].unlock();
plot->axes(Qt::Horizontal).first()->setRange(0, sample2ns * traceLength); plot->axes(Qt::Horizontal).first()->setRange(0, sample2ns * traceLength);
@ -536,7 +751,9 @@ void Scope::UpdateScope(){
void Scope::ProbeChange(RComboBox * cb[], const int size ){ void Scope::ProbeChange(RComboBox * cb[], const int size ){
printf("%s\n", __func__); if( allowChange == false ) return;
//printf("%s\n", __func__);
QStandardItemModel * model[size] = {NULL}; QStandardItemModel * model[size] = {NULL};
for( int i = 0; i < size; i++){ for( int i = 0; i < size; i++){
model[i] = qobject_cast<QStandardItemModel*>(cb[i]->model()); model[i] = qobject_cast<QStandardItemModel*>(cb[i]->model());
@ -555,15 +772,15 @@ void Scope::ProbeChange(RComboBox * cb[], const int size ){
} }
} }
int ID = cbScopeDigi->currentIndex(); //int ID = cbScopeDigi->currentIndex();
digiMTX[ID].lock(); //digiMTX[ID].lock();
if( size == 2) {// analog probes if( size == 2) {// analog probes
for( int j = 0; j < 2; j++ )dataTrace[j]->setName(cb[j]->currentText()); for( int j = 0; j < 2; j++ )dataTrace[j]->setName(cb[j]->currentText());
} }
if( size == 4){ // digitial probes if( size == 4){ // digitial probes
for( int j = 2; j < 6; j++ )dataTrace[j]->setName(cb[j-2]->currentText()); for( int j = 2; j < 6; j++ )dataTrace[j]->setName(cb[j-2]->currentText());
} }
digiMTX[ID].unlock(); //digiMTX[ID].unlock();
} }
@ -574,35 +791,65 @@ void Scope::ScopeControlOnOff(bool on){
bnScopeReset->setEnabled(on); bnScopeReset->setEnabled(on);
bnScopeReadSettings->setEnabled(on); bnScopeReadSettings->setEnabled(on);
sbRL->setEnabled(on); if( digi[cbScopeDigi->currentIndex()]->GetFPGAType() == DPPType::PHA ){
sbPT->setEnabled(on); sbRL->setEnabled(on);
sbTimeRiseTime->setEnabled(on); sbPT->setEnabled(on);
sbTimeGuard->setEnabled(on); sbTimeRiseTime->setEnabled(on);
sbTrapRiseTime->setEnabled(on); sbTimeGuard->setEnabled(on);
sbTrapFlatTop->setEnabled(on); sbTrapRiseTime->setEnabled(on);
sbTrapPoleZero->setEnabled(on); sbTrapFlatTop->setEnabled(on);
sbEnergyFineGain->setEnabled(on); sbTrapPoleZero->setEnabled(on);
sbTrapPeaking->setEnabled(on); sbEnergyFineGain->setEnabled(on);
cbPolarity->setEnabled(on); sbTrapPeaking->setEnabled(on);
cbWaveRes->setEnabled(on); cbPolarity->setEnabled(on);
cbTrapPeakAvg->setEnabled(on); cbWaveRes->setEnabled(on);
cbBaselineAvg->setEnabled(on); cbTrapPeakAvg->setEnabled(on);
cbBaselineAvg->setEnabled(on);
//sbDCOffset->setEnabled(on); //sbDCOffset->setEnabled(on);
//sbThreshold->setEnabled(on); //sbThreshold->setEnabled(on);
//sbBaselineGuard->setEnabled(on); //sbBaselineGuard->setEnabled(on);
//sbPileUpGuard->setEnabled(on); //sbPileUpGuard->setEnabled(on);
//cbLowFreqFilter->setEnabled(on); //cbLowFreqFilter->setEnabled(on);
}
if( digi[cbScopeDigi->currentIndex()]->GetFPGAType() == DPPType::PSD ){
cbPolarity->setEnabled(on);
cbWaveRes->setEnabled(on);
cbbADCInputBaselineAvg->setEnabled(on);
cbbSmoothingFactor->setEnabled(on);
cbbTriggerFilter->setEnabled(on);
cbbTimeFilterSmoothing->setEnabled(on);
cbbEnergyGain->setEnabled(on);
sbRL->setEnabled(on);
sbPT->setEnabled(on);
//sbThreshold->setEnabled(on);
//sbDCOffset->setEnabled(on);
//spbADCInputBaselineGuard->setEnabled(on);
//spbCFDDelay->setEnabled(on);
//spbCFDFraction->setEnabled(on);
//spbAbsBaseline->setEnabled(on);
//spbTimeFilterReTriggerGuard->setEnabled(on);
//spbPileupGap->setEnabled(on);
//spbGateLong->setEnabled(on);
//spbGateShort->setEnabled(on);
//spbGateOffset->setEnabled(on);
}
} }
void Scope::ScopeReadSpinBoxValue(int iDigi, int ch, RSpinBox *sb, const Reg digPara){ void Scope::ScopeReadSpinBoxValue(int iDigi, int ch, RSpinBox *sb, const Reg digPara){
std::string ans = digi[iDigi]->GetSettingValue(digPara, ch); std::string ans = digi[iDigi]->GetSettingValueFromMemory(digPara, ch);
sb->setValue(atoi(ans.c_str())); sb->setValue(atoi(ans.c_str()));
} }
void Scope::ScopeReadComboBoxValue(int iDigi, int ch, RComboBox *cb, const Reg digPara){ void Scope::ScopeReadComboBoxValue(int iDigi, int ch, RComboBox *cb, const Reg digPara){
std::string ans = digi[iDigi]->GetSettingValue(digPara, ch); std::string ans = digi[iDigi]->GetSettingValueFromMemory(digPara, ch);
int index = cb->findData(QString::fromStdString(ans)); int index = cb->findData(QString::fromStdString(ans));
if( index >= 0 && index < cb->count()) { if( index >= 0 && index < cb->count()) {
cb->setCurrentIndex(index); cb->setCurrentIndex(index);
@ -612,11 +859,11 @@ void Scope::ScopeReadComboBoxValue(int iDigi, int ch, RComboBox *cb, const Reg d
} }
void Scope::ScopeMakeSpinBox(RSpinBox * &sb, QString str, QGridLayout *layout, int row, int col, const Reg digPara){ void Scope::ScopeMakeSpinBox(RSpinBox * &sb, QString str, QGridLayout *layout, int row, int col, const Reg digPara){
printf("%s\n", __func__); //printf("%s\n", __func__);
QLabel * lb = new QLabel(str, this); QLabel * lb = new QLabel(str, settingBox);
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter); lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
layout->addWidget(lb, row, col); layout->addWidget(lb, row, col);
sb = new RSpinBox(this); sb = new RSpinBox(settingBox);
sb->setMinimum(atof(digPara.GetAnswers()[0].first.c_str())); sb->setMinimum(atof(digPara.GetAnswers()[0].first.c_str()));
sb->setMaximum(atof(digPara.GetAnswers()[1].first.c_str())); sb->setMaximum(atof(digPara.GetAnswers()[1].first.c_str()));
sb->setSingleStep(atof(digPara.GetAnswers()[2].first.c_str())); sb->setSingleStep(atof(digPara.GetAnswers()[2].first.c_str()));
@ -654,11 +901,11 @@ void Scope::ScopeMakeSpinBox(RSpinBox * &sb, QString str, QGridLayout *layout, i
} }
void Scope::ScopeMakeComoBox(RComboBox * &cb, QString str, QGridLayout *layout, int row, int col, const Reg digPara){ void Scope::ScopeMakeComoBox(RComboBox * &cb, QString str, QGridLayout *layout, int row, int col, const Reg digPara){
QLabel * lb = new QLabel(str, this); QLabel * lb = new QLabel(str, settingBox);
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter); lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
layout->addWidget(lb, row, col); layout->addWidget(lb, row, col);
cb = new RComboBox(this); cb = new RComboBox(settingBox);
for( int i = 0 ; i < (int) digPara.GetAnswers().size(); i++){ for( int i = 0 ; i < (int) digPara.GetAnswers().size(); i++){
cb->addItem(QString::fromStdString((digPara.GetAnswers())[i].second), QString::fromStdString((digPara.GetAnswers())[i].first)); cb->addItem(QString::fromStdString((digPara.GetAnswers())[i].second), QString::fromStdString((digPara.GetAnswers())[i].first));
} }

78
scope.h
View File

@ -8,6 +8,7 @@
#include <QSpinBox> #include <QSpinBox>
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
#include <QGroupBox>
#include <QCheckBox> #include <QCheckBox>
#include <QLineEdit> #include <QLineEdit>
#include <QComboBox> #include <QComboBox>
@ -19,7 +20,7 @@
#include "macro.h" #include "macro.h"
#include "ClassDigitizer2Gen.h" #include "ClassDigitizer2Gen.h"
#include "manyThread.h" #include "CustomThreads.h"
#include "CustomWidgets.h" #include "CustomWidgets.h"
class Trace : public QChart{ class Trace : public QChart{
@ -129,10 +130,10 @@ public:
public slots: public slots:
void ReadScopeSettings(); // read from digitizer and show; void ReadScopeSettings(); // read from digitizer and show;
void UpdateSettingsFromMemeory(); void UpdateSettingsFromMemeory();
private slots:
void StartScope(); void StartScope();
void StopScope(); void StopScope();
private slots:
void UpdateScope(); void UpdateScope();
void ScopeControlOnOff(bool on); void ScopeControlOnOff(bool on);
void ScopeReadSpinBoxValue(int iDigi, int ch, RSpinBox *sb, const Reg digPara); void ScopeReadSpinBoxValue(int iDigi, int ch, RSpinBox *sb, const Reg digPara);
@ -162,7 +163,13 @@ private:
unsigned short nDigi; unsigned short nDigi;
ReadDataThread ** readDataThread; ReadDataThread ** readDataThread;
UpdateTraceThread * updateTraceThread; TimingThread * updateTraceThread;
QGroupBox * settingBox;
QGridLayout * bLayout; // for wave setting
std::vector<Reg> anaProbeList;
std::vector<Reg> digiProbeList;
QChart * plot; QChart * plot;
QLineSeries * dataTrace[6]; QLineSeries * dataTrace[6];
@ -175,32 +182,77 @@ private:
QPushButton * bnScopeStart; QPushButton * bnScopeStart;
QPushButton * bnScopeStop; QPushButton * bnScopeStop;
QLineEdit * leTriggerRate;
RComboBox * cbAnaProbe[2]; RComboBox * cbAnaProbe[2];
RComboBox * cbDigProbe[4]; RComboBox * cbDigProbe[4];
RSpinBox * sbRL; // record length RSpinBox * sbRL; // record length
RSpinBox * sbThreshold;
RComboBox * cbPolarity;
RComboBox * cbWaveRes;
RSpinBox * sbPT; // pre trigger RSpinBox * sbPT; // pre trigger
RSpinBox * sbDCOffset; RSpinBox * sbDCOffset;
RSpinBox * sbThreshold;
//-------- PHA
RSpinBox * sbTimeRiseTime; RSpinBox * sbTimeRiseTime;
RSpinBox * sbTimeGuard; RSpinBox * sbTimeGuard;
RComboBox * cbLowFreqFilter;
RSpinBox * sbTrapRiseTime; RSpinBox * sbTrapRiseTime;
RSpinBox * sbTrapFlatTop; RSpinBox * sbTrapFlatTop;
RSpinBox * sbTrapPoleZero; RSpinBox * sbTrapPoleZero;
RSpinBox * sbEnergyFineGain;
RSpinBox * sbTrapPeaking; RSpinBox * sbTrapPeaking;
RComboBox * cbPolarity;
RComboBox * cbWaveRes;
RComboBox * cbTrapPeakAvg;
QLineEdit * leTriggerRate;
RSpinBox * sbBaselineGuard; RSpinBox * sbBaselineGuard;
RSpinBox * sbPileUpGuard; RSpinBox * sbPileUpGuard;
RComboBox * cbBaselineAvg; RComboBox * cbBaselineAvg;
RComboBox * cbLowFreqFilter; RComboBox * cbTrapPeakAvg;
RSpinBox * sbEnergyFineGain;
//--------- PSD
RComboBox * cbbADCInputBaselineAvg;
RSpinBox * spbADCInputBaselineGuard;
RSpinBox * spbCFDDelay;
RSpinBox * spbCFDFraction;
RComboBox * cbbSmoothingFactor;
RSpinBox * spbAbsBaseline;
RComboBox * cbbTriggerFilter;
RComboBox * cbbTimeFilterSmoothing;
RSpinBox * spbTimeFilterReTriggerGuard;
RSpinBox * spbPileupGap;
RSpinBox * spbGateLong;
RSpinBox * spbGateShort;
RSpinBox * spbGateOffset;
RComboBox * cbbEnergyGain;
bool allowChange; bool allowChange;
void ChangeDigitizer();
void CleanUpSettingsGroupBox();
void SetupPHA();
void SetupPSD();
// remembee setting, once the scope stop, restore it.
void RestoreSettings(bool changeBoard); // except channelEnable
bool originalValueSet;
short oldCh, oldDigi;
std::string channelEnable[MaxNumberOfDigitizer][MaxNumberOfChannel];
std::string waveSaving;
std::string waveTriggerSource;
std::string clockSource;
std::string startSource;
std::string syncOutMode;
}; };
#endif #endif

View File

@ -1,93 +0,0 @@
#include "SolReader.h"
#include "TH1.h"
#include "TMath.h"
#include "TH2.h"
#include "TStyle.h"
#include "TCanvas.h"
#include "TGraph.h"
void script(){
SolReader * reader = new SolReader("haha_000.sol");
Event * evt = reader->evt;
printf("----------file size: %u Byte\n", reader->GetFileSize());
reader->ScanNumBlock();
if( reader->GetTotalNumBlock() == 0 ) return;
unsigned long startTime, endTime;
reader->ReadBlock(0);
startTime = evt->timestamp;
reader->ReadBlock(reader->GetTotalNumBlock() - 1);
endTime = evt->timestamp;
double duration = double(endTime - startTime)*8./1e9;
printf("============== %lu ns = %.4f sec.\n", (endTime - startTime)*8, duration);
printf(" avarge rate (16ch): %f Hz\n", reader->GetTotalNumBlock()/duration/16);
reader->RewindFile();
TH1F * hid = new TH1F("hid", "hid", 64, 0, 64);
TH1F * h1 = new TH1F("h1", "h1", duration, startTime, endTime);
TH2F * h2 = new TH2F("h2", "h2", 1000, startTime, endTime, 1000, 0, reader->GetTotalNumBlock());
TH1F * hTdiff = new TH1F("hTdiff", "hTdiff", 400, 0, 200000);
TGraph * g1 = new TGraph();
uint64_t tOld = startTime;
for( int i = 0; i < reader->GetTotalNumBlock() ; i++){
//for( int i = 0; i < 8 ; i++){
reader->ReadNextBlock();
if( i < 8 ){
printf("########################## nBlock : %u, %u/%u\n", reader->GetNumBlock(),
reader->GetFilePos(),
reader->GetFileSize());
evt->PrintAll();
//evt->PrintAllTrace();
}
hid->Fill(evt->channel);
if( evt->channel == 0 ) h1->Fill(evt->timestamp);
h2->Fill(evt->timestamp, i);
if( i > 0 ){
hTdiff->Fill(evt->timestamp - tOld);
if( evt->timestamp < tOld) printf("-------- time not sorted.");
tOld = evt->timestamp;
}
if( i == 0){
for( int i = 0; i < evt->traceLenght; i++){
g1->AddPoint(i*8, evt->analog_probes[0][i]);
}
}
}
gStyle->SetOptStat("neiou");
TCanvas * canvas = new TCanvas("c1", "c1", 1200, 1200);
canvas->Divide(2,2);
canvas->cd(1); hid->Draw();
canvas->cd(2); h1->SetMinimum(0); h1->Draw();
canvas->cd(3); hTdiff->Draw();
canvas->cd(4); g1->Draw("APl");
//printf("reader traceLength : %lu \n", evt->traceLenght);
/*
for( int i = 0; i < evt->traceLenght; i++){
printf("%4d| %d\n", i, evt->analog_probes[0][i]);
}
*/
evt = NULL;
delete reader;
}

19
scripts/endRunScript.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash -l
echo "################# End-Run Script"
#xterm -T endRunScript -hold -geometry 100x20+0+0 -sb -sl 1000 -e "Process_Run" "lastRun"
#xterm -T endRunScript -geometry 100x20+0+0 -sb -sl 1000 -e "source ~/Analysis/SOLARIS.sh; Process_Run lastRun 2 0"
#master data path
dataPath=~/ExpData/SOLARISDAQ/Haha/
#load the runID from expName
source $dataPath/data_raw/expName.sh
#format runID to 3 digit
runIDStr=$(printf "run%03d" $runID)
cp $dataPath/ExpSetup.txt $dataPath/data_raw/$runIDStr/.
echo "################# done"

68
scripts/grafanaScreenShot.sh Executable file
View File

@ -0,0 +1,68 @@
#!/bin/bash
APIKEY=eyJrIjoid25Bc3U3NEdxVDZYV2xrdEJ0QTlxNTdFM25JcXVTTlAiLCJuIjoiYWRtaW5LRVkiLCJpZCI6MX0=
url=http://localhost:3000
############# successfull single panel screenshot
#dashboardID=solaris-main-dashoard
#panelID=2
#curl "$url/render/d-solo/iXH6cG-Vz/$dashboardID?orgId=1&refresh=5s&from=now-6h&to=now&panelId=$panelID" -H "Authorization: Bearer ${APIKEY}" --compressed > haha.png
############# get list of snapshot
SNAPSHOT_LIST=$(curl -X GET -H "Authorization: Bearer ${APIKEY}" $url/api/dashboard/snapshots)
############ list the key
SNAPSHOT_KEYS=$(echo $SNAPSHOT_LIST | jq -r '.[].key')
#echo $SNAPSHOT_KEYS
echo "========== list of key"
for haha in $SNAPSHOT_KEYS
do
echo $haha
done
echo "============================="
############# delete snapshot
for haha in $SNAPSHOT_KEYS
do
echo "Deleting snapshot $haha"
curl -s -X DELETE -H "Authorization: Bearer $APIKEY" "$url/api/snapshots/$haha"
done
echo ""
echo "==========================="
curl -X GET -H "Authorization: Bearer ${APIKEY}" $url/api/dashboard/snapshots
############ reset the snapshot count
# # Set the new snapshot count
# NEW_SNAPSHOT_COUNT=0
# DASHBOARD_UID="iXH6cG-Vz"
# # Get the current dashboard settings
# DASHBOARD_SETTINGS=$(curl -s -H "Authorization: Bearer $APIKEY" "$url/api/dashboards/uid/$DASHBOARD_UID")
# # Update the snapshot count in the dashboard settings
# UPDATED_DASHBOARD_SETTINGS=$(echo "$DASHBOARD_SETTINGS" | jq ".dashboard.snapshotData.snapshotCount = $NEW_SNAPSHOT_COUNT")
# # Send the updated dashboard settings back to Grafana
# curl -s -X POST -H "Authorization: Bearer $APIKEY" -H "Content-Type: application/json" -d "$UPDATED_DASHBOARD_SETTINGS" "$url/api/dashboards/db"
############ get snapshot by key
#curl -X GET -H "Authorization: Bearer ${APIKEY}" $url/api/snapshots/gH0GK86ExXR0zr5rNhSUaweyxVH607BH
############ Generate snapshot [FAIL!!!!!!!!!!]
# SNAPSHOT_FILE=haha.png
# SNAPSHOT_RESULT=$(curl -s -X POST -H "Authorization: Bearer $APIKEY" -H "Content-Type: application/json" -d "@snapshot-data.json" "$url/api/snapshots")
# echo "========================"
# echo $SNAPSHOT_RESULT
# SNAPSHOT_URL=$(echo $SNAPSHOT_RESULT | jq -r '.url')
# echo "========================"
# echo $SNAPSHOT_URL
# #microsoft-edge $SNAPSHOT_URL
# microsoft-edge --headless --window-size=2000,1000 --screenshot=$SNAPSHOT_FILE $SNAPSHOT_URL
# #echo "Snapshot saved to $SNAPSHOT_FILE"
# #eog $SNAPSHOT_FILE
echo ""

View File

@ -0,0 +1,29 @@
{
"dashboard": {
"uid": "iXH6cG-Vz",
"editable":false,
"nav":[
{
"enable":false,
"type":"timepicker"
}
],
"rows": [
{
}
],
"style":"dark",
"tags":[],
"templating":{
"list":[
]
},
"time":{
},
"timezone":"browser",
"title":"haha",
"version":5
},
"expires": 10
}

176
test.cpp
View File

@ -1,176 +0,0 @@
#include <cstdlib>
#include <string>
#include <vector>
#include <unistd.h>
#include <time.h> // time in nano-sec
#include <iostream>
#include <thread>
#include <mutex>
#include "ClassDigitizer2Gen.h"
#include "influxdb.h"
#define maxRead 400
std::mutex digiMTX;
Digitizer2Gen * digi = new Digitizer2Gen();
InfluxDB * influx = new InfluxDB("https://fsunuc.physics.fsu.edu/influx/", false);
unsigned int readCount = 0;
timespec ta, tb;
static void ReadDataLoop(){
clock_gettime(CLOCK_REALTIME, &ta);
//while(digi->IsAcqOn() && readCount < maxRead){
while(true){
digiMTX.lock();
int ret = digi->ReadData();
digiMTX.unlock();
if( ret == CAEN_FELib_Success){
digi->SaveDataToFile();
}else if(ret == CAEN_FELib_Stop){
digi->ErrorMsg("No more data");
break;
}else{
digi->ErrorMsg("ReadDataLoop()");
}
//if( readCount % 1000 == 0 ) {
// clock_gettime(CLOCK_REALTIME, &tb);
// double duration = tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9;
// printf("%4d, duration : %10.0f, %6.1f\n", readCount, duration, 1e9/duration);
// ta = tb;
//}
//readCount++;
}
}
char cmdStr[100];
static void StatLoop(){
//while(digi->IsAcqOn() && readCount < maxRead){
while(digi->IsAcqOn()){
digiMTX.lock();
digi->ReadStat();
for(int i = 0; i < 64; i++){
sprintf(cmdStr, "/ch/%d/par/SelfTrgRate", i);
std::string haha = digi->ReadValue( cmdStr, false);
influx->AddDataPoint("Rate,Bd=0,Ch=" + std::to_string(i) + " value=" + haha);
}
//digi->ReadValue("/ch/4/par/ChRealtimeMonitor", true);
//digi->ReadValue("/ch/4/par/ChDeadtimeMonitor", true);
//digi->ReadValue("/ch/4/par/ChTriggerCnt", true);
//digi->ReadValue("/ch/4/par/ChSavedEventCnt", true);
//digi->ReadValue("/ch/4/par/ChWaveCnt", true);
digiMTX.unlock();
//influx->PrintDataPoints();
influx->WriteData("testing");
influx->ClearDataPointsBuffer();
digi->PrintStat();
usleep(1000*1000); // every 1000 msec
}
}
int main(int argc, char* argv[]){
printf("##########################################\n");
printf("\t CAEN firmware DPP-PHA testing \n");
printf("##########################################\n");
remove("haha_000.sol");
const char * url = "dig2://192.168.0.100/";
digi->OpenDigitizer(url);
digi->Reset();
//digi->ProgramPHA(false);
//printf("--------%s \n", digi->ReadChValue("0..63", "WaveAnalogprobe0", true).c_str());
//digi->SaveSettingsToFile(("settings_" + std::to_string(digi->GetSerialNumber()) + ".dat").c_str());
//printf("===================================\n");
printf("======== index : %d \n", digi->FindIndex(PHA::CH::ChannelEnable));
//digi->LoadSettingsFromFile("settings_21245.dat");
//printf("%s \n", digi->ReadValue("/ch/0/par/ChRealtimeMonitor").c_str());
//printf("%s \n", digi->ReadValue("/ch/0/par/Energy_Nbit").c_str());
//printf("%s \n", digi->ReadValue("/par/MaxRawDataSize").c_str());
/*///======================= Play with handle
uint64_t parHandle;
parHandle = digi->GetHandle("/ch/0/par/ChRealtimeMonitor"); printf("%lu|%lX\n", parHandle, parHandle);
parHandle = digi->GetHandle("/ch/1/par/ChRealtimeMonitor"); printf("%lu|%lX\n", parHandle, parHandle);
printf("%s\n", digi->GetPath(parHandle).c_str());
parHandle = digi->GetParentHandle(parHandle); printf("%lu|%lX\n", parHandle, parHandle);
printf("%s\n", digi->GetPath(parHandle).c_str());
parHandle = digi->GetParentHandle(parHandle); printf("%lu|%lX\n", parHandle, parHandle);
printf("%s\n", digi->GetPath(parHandle).c_str());
parHandle = digi->GetParentHandle(parHandle); printf("%lu|%lX\n", parHandle, parHandle);
printf("%s\n", digi->GetPath(parHandle).c_str());
parHandle = digi->GetParentHandle(parHandle); printf("%lu|%lX\n", parHandle, parHandle);
printf("%s\n", digi->GetPath(parHandle).c_str());
*/
/*
digi->ReadDigitizerSettings();
digi->SetPHADataFormat(1);
//printf("0x%X \n", atoi(digi->ReadValue("/par/AcquisitionStatus").c_str()) & 0x3F );
digi->OpenOutFile("haha");
digi->StartACQ();
timespec t0, t1;
clock_gettime(CLOCK_REALTIME, &t0);
std::thread th1 (ReadDataLoop);
std::thread th2 (StatLoop);
char c;
printf("Press q for stop.");
do{
c = getchar();
}while( c != 'q');
digiMTX.lock();
digi->StopACQ();
digiMTX.unlock();
th1.join();
th2.join();
clock_gettime(CLOCK_REALTIME, &t1);
printf("t1-t0 : %.0f ns = %.2f sec\n",
t1.tv_nsec-t0.tv_nsec + t1.tv_sec*1e+9 - t0.tv_sec*1e+9,
(t1.tv_nsec-t0.tv_nsec + t1.tv_sec*1e+9 - t0.tv_sec*1e+9)*1.0/1e9);
digi->CloseOutFile();
*/
digi->CloseDigitizer();
delete digi;
delete influx;
}

View File

@ -1,94 +0,0 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <png.h>
#include <fstream>
#include <cstring>
#include <vector>
#include <iostream>
void saveScreenshot(Display* display, const Window window, const char* filename){
XWindowAttributes attrs;
XGetWindowAttributes(display, window, &attrs);
printf("(x,y) :(%d, %d), (w,h) : (%d, %d) \n", attrs.x, attrs.y, attrs.width, attrs.height);
int window_width = attrs.width;
int window_height = attrs.height;
XImage *image = XGetImage(display, window, 0, 0, window_width, window_height, AllPlanes, ZPixmap);
png_bytep *row_pointers = new png_bytep[window_height];
for (int i = 0; i < window_height; i++) {
row_pointers[i] = (png_bytep)(image->data + i * image->bytes_per_line);
}
FILE *png_file = fopen(filename, "w");
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_infop info_ptr = png_create_info_struct(png_ptr);
png_init_io(png_ptr, png_file);
png_set_IHDR(png_ptr, info_ptr, window_width, window_height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_write_info(png_ptr, info_ptr);
png_write_image(png_ptr, row_pointers);
png_write_end(png_ptr, NULL);
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(png_file);
XFree(image->data);
}
int main(int argc, char* argv[]){
Window screenID;
if( argc > 1){
screenID = atoi(argv[1]);
}
// Connect to the X server
Display *display = XOpenDisplay(nullptr);
//============== show all windows ID
Window root = DefaultRootWindow(display);
Window parent;
Window *children;
unsigned int numChildren;
Status status = XQueryTree(display, root, &root, &parent, &children, &numChildren);
if (!status) {
std::cerr << "Failed to query window tree\n";
return 1;
}
for (unsigned int i = 0; i < numChildren; i++) {
XTextProperty windowName;
status = XGetWMName(display, children[i], &windowName);
if( i == 0 ) {
printf("%12s | %12s \n", "Window ID", "Name");
printf("--------------+--------------------------------\n");
}
if (status) {
char **list;
int count;
status = XmbTextPropertyToTextList(display, &windowName, &list, &count);
if (status >= Success && count > 0 && *list) {
printf("%12ld | %s \n", children[i], *list);
//std::cout << "Window ID: " << children[i] << ", Window Name: " << *list << "\n";
XFreeStringList(list);
}
XFree(windowName.value);
}
}
XFree(children);
//================ end of show windows ID
if( argc >1 ){
saveScreenshot(display, screenID, "screenshot.png");
printf("captured screenshot of windowID(%ld) as screenshot.png\n", screenID);
}
// Close the display connection
XCloseDisplay(display);
return 0;
}