Compare commits

..

No commits in common. "master" and "v1.0" have entirely different histories.
master ... v1.0

43 changed files with 3351 additions and 8250 deletions

5
.gitignore vendored
View File

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

View File

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

View File

@ -1,364 +0,0 @@
#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;
}

View File

@ -1,23 +0,0 @@
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

View File

@ -1,271 +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 "../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

View File

@ -1,44 +0,0 @@
#!/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)

View File

@ -1,103 +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(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;
}

View File

@ -1,159 +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 "../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,14 +5,13 @@
#include <CAEN_FELib.h>
#include <cstdlib>
#include <string>
#include <unordered_map>
#include <map>
#include "Hit.h"
#include "Event.h"
#define MaxOutFileSize 2*1024*1024*1024 //2GB
//#define MaxOutFileSize 20*1024*1024 //20MB
#define MaxNumberOfChannel 64
#define MaxNumberOfGroup 16
#include "DigiParameters.h"
@ -33,11 +32,10 @@ class Digitizer2Gen {
char retValue[256];
unsigned short serialNumber;
unsigned int CupVer;
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
std::string FPGAType;
unsigned int FPGAVer;
unsigned short nChannels;
unsigned short tick2ns;
unsigned short ch2ns;
std::string ModelName;
void Initialization();
@ -62,47 +60,41 @@ class Digitizer2Gen {
std::string settingFileName;
std::vector<Reg> boardSettings;
std::vector<Reg> chSettings[MaxNumberOfChannel];
std::vector<Reg> LVDSSettings[4];
Reg VGASetting[4];
Reg InputDelay[16];
std::unordered_map<std::string, int> boardMap;
std::unordered_map<std::string, int> LVDSMap;
std::unordered_map<std::string, int> chMap;
std::map<std::string, int> boardMap;
std::map<std::string, int> chMap;
public:
Digitizer2Gen();
~Digitizer2Gen();
unsigned short GetSerialNumber() const {return serialNumber;}
unsigned short GetSerialNumber() const{return serialNumber;}
std::string GetFPGAType() const {return FPGAType;}
std::string GetModelName() const {return ModelName;}
unsigned int GetFPGAVersion() const {return FPGAVer;}
unsigned int GetCupVer() const {return CupVer;}
void SetDummy(unsigned short sn);
bool IsDummy() const {return isDummy;}
bool IsConnected() const {return isConnected;}
int OpenDigitizer(const char * url);
bool IsConnected() const {return isConnected;}
int CloseDigitizer();
int GetRet() const {return ret;};
uint64_t GetHandle(const char * parameter);
uint64_t GetParentHandle(uint64_t handle);
std::string GetPath(uint64_t handle);
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 verbose = true);
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);
int FindIndex(const Reg para); // get index from DIGIPARA
std::string GetSettingValueFromMemory(const Reg para, unsigned int ch_index = 0); // read from memory
uint64_t GetHandle(const char * parameter);
uint64_t GetParentHandle(uint64_t handle);
std::string GetPath(uint64_t handle);
std::string ErrorMsg(const char * funcName);
@ -110,8 +102,11 @@ class Digitizer2Gen {
void StopACQ();
bool IsAcqOn() const {return acqON;}
void SetDataFormat(unsigned short dataFormat); // dataFormat = namespace DataFormat
void SetPHADataFormat(unsigned short dataFormat); // 0 = all data,
// 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 ReadStat(); // digitizer update it every 500 msec
void PrintStat();
@ -119,18 +114,14 @@ class Digitizer2Gen {
uint64_t GetRealTime(int ch) const {return realTime[ch];}
void Reset();
void ProgramBoard();
void ProgramChannels(bool testPulse = false);
void PrintBoardSettings();
void PrintChannelSettings(unsigned short ch);
void ProgramPHA(bool testPulse = false);
unsigned short GetNChannels() const {return nChannels;}
unsigned short GetTick2ns() const {return tick2ns;}
unsigned short GetCh2ns() const {return ch2ns;}
uint64_t GetHandle() const {return handle;}
Hit *hit; // should be hit[MaxNumber], when full or stopACQ, save into file
void OpenOutFile(std::string fileName, const char * mode = "wb"); //overwrite binary
Event *evt; // should be evt[MaxNumber], when full or stopACQ, save into file
void OpenOutFile(std::string fileName, const char * mode = "w");
void CloseOutFile();
void SaveDataToFile();
unsigned int GetFileSize() const {return outFileSize;}
@ -139,10 +130,11 @@ class Digitizer2Gen {
std::string GetSettingFileName() const {return settingFileName;}
void SetSettingFileName(std::string fileName) {settingFileName = fileName;}
void ReadAllSettings(); // read settings from digitier and save to memory
int SaveSettingsToFile(const char * saveFileName = NULL, bool setReadOnly = false); //Save settings from memory to text file
int SaveSettingsToFile(const char * saveFileName = NULL); //Save settings from memory to 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
std::string GetSettingValue(const Reg para, unsigned int ch_index = 0); // read from memory
};
#endif

View File

@ -1,267 +0,0 @@
#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

@ -1,105 +0,0 @@
#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,9 +38,6 @@ class RSpinBox : public QDoubleSpinBox{
setToolTipDuration(-1);
}
void SetStyleNormal() { setStyleSheet(""); }
void SetStyleGreen() { setStyleSheet("color:green"); }
signals:
void returnPressed();
protected:

View File

@ -5,10 +5,8 @@
#include <string>
#include <vector>
#define MIN_VERSION_GROUP 2022122300
enum ANSTYPE {INTEGER, FLOAT, COMBOX, STR, BYTE, BINARY, NONE};
enum TYPE {CH, DIG, LVDS, VGA, GROUP};
enum ANSTYPE {INTEGER, FLOAT, LIST, STR, BYTE, BINARY, NONE};
enum TYPE {CH, DIG, LVDS, VGA};
enum RW { ReadOnly, WriteOnly, ReadWrite};
//^==================== Register Class
@ -30,14 +28,14 @@ class Reg {
type = TYPE::CH;
isCmd = false;
value = "";
ansType = ANSTYPE::COMBOX;
ansType = ANSTYPE::LIST;
answerUnit = "";
answer.clear();
}
Reg(std::string para, RW readwrite,
TYPE type = TYPE::CH,
std::vector<std::pair<std::string,std::string>> answer = {}, // first = value, second = display
ANSTYPE ansType = ANSTYPE::COMBOX,
std::vector<std::pair<std::string,std::string>> answer = {},
ANSTYPE ansType = ANSTYPE::LIST,
std::string ansUnit = "",
bool isCmd = false){
this->name = para;
@ -51,7 +49,7 @@ class Reg {
}
~Reg(){};
void SetValue(std::string sv) { value = sv;}
void SetValue(std::string sv) { this->value = sv;}
std::string GetValue() const { return value;}
RW ReadWrite() const {return readWrite;}
TYPE GetType() const {return type;}
@ -60,7 +58,7 @@ class Reg {
std::vector<std::pair<std::string,std::string>> GetAnswers() const {return answer;}
std::string GetPara() const {return name;}
std::string GetFullPara(int ch_index = -1, int nChannals = MaxNumberOfChannel) const {
std::string GetFullPara(int ch_index = -1) const {
switch (type){
case TYPE::DIG:{
if( isCmd){
@ -72,10 +70,10 @@ class Reg {
case TYPE::CH:{
std::string haha = "/par/";
if( isCmd ){
haha = "/cmd/"; // for SendChSWTrigger, not in GUI
haha = "/cmd/";
}
if( ch_index == -1 ){
return "/ch/0.." + std::to_string(nChannals-1) + haha + name;
return "/ch/0..63" + haha + name;
}else{
return "/ch/" + std::to_string(ch_index) + haha + name;
}
@ -94,19 +92,12 @@ class Reg {
return "/vga/" + std::to_string(ch_index) + "/par/"+ name;
}
}; 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:
return "invalid"; break;
}
}
operator std::string () const {return name;} // this allow Reg kaka("XYZ", true); std::string haha = kaka;
};
@ -161,7 +152,6 @@ namespace PHA{
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> TempSensOthers = {TempSensAirIn,TempSensAirOut,TempSensCore,TempSensFirstADC,TempSensLastADC,TempSensHottestADC};
const Reg TempSensDCDC ("TempSensDCDC", RW::ReadOnly, TYPE::DIG, {}, ANSTYPE::INTEGER, "C");
const Reg VInSensDCDC ("VInSensDCDC", RW::ReadOnly, TYPE::DIG, {}, ANSTYPE::INTEGER, "V");
@ -174,10 +164,6 @@ namespace PHA{
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 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
const Reg ClockSource ("ClockSource", RW::ReadWrite, TYPE::DIG, {{"Internal", "Internal Clock 62.5 MHz"},
{"FPClkIn", "Front Panel Clock Input"}});
@ -191,12 +177,7 @@ namespace PHA{
{"SwTrg", "Software" },
{"GPIO", "GPIO" },
{"TestPulse", "Test Pulse" },
{"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);
{"LVDS", "LVDS"}}, ANSTYPE::STR);
const Reg BusyInSource ("BusyInSource", RW::ReadWrite, TYPE::DIG, {{"Disabled","Disabled"},
{"SIN", "SIN"},
@ -208,11 +189,6 @@ namespace PHA{
{"TRGIN", "TRG-IN"},
{"SwTrg", "Software Trigger"},
{"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"},
{"RefClk", "Reference Clock"},
{"TestPulse", "Test Pulse"},
@ -222,19 +198,13 @@ namespace PHA{
{"SyncIn", "SyncIn Signal"},
{"SIN", "S-IN Signal"},
{"GPIO", "GPIO Signal"},
{"LBinClk", "GPIO Signal"},
{"AcceptTrg", "Acceped Trigger Signal"},
{"AccepTrg", "Acceped Trigger Signal"},
{"TrgClk", "Trigger Clock"}});
const Reg GPIOMode ("GPIOMode", RW::ReadWrite, TYPE::DIG, {{"Disabled", "Disabled"},
{"TRGIN", "TRG-IN"},
{"P0", "Back Plane"},
{"SIN", "S-IN Signal"},
{"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"},
{"Run", "Run Signal"},
{"RefClk", "Referece Clock"},
@ -251,8 +221,7 @@ namespace PHA{
{"SIN", "S-IN"},
{"LVDS", "LVDS"},
{"GPIO", "GPIO"},
{"P0", "Back Plane"},
{"EncodedClkIn", "Encoded CLK-IN"}});
{"P0", "Back Plane"}});
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 RunDelay ("RunDelay", RW::ReadWrite, TYPE::DIG, {{"0", ""}, {"524280", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ns");
@ -263,40 +232,21 @@ namespace PHA{
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 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, "ADC counts");
const Reg TestPulseHighLevel ("TestPulseHighLevel", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"65535", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ADC counts");
const Reg TestPulseLowLevel ("TestPulseLowLevel", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"65535", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ns");
const Reg TestPulseHighLevel ("TestPulseHighLevel", RW::ReadWrite, TYPE::DIG, {{"0", ""},{"65535", ""}, {"1", ""}}, ANSTYPE::INTEGER, "ns");
const Reg ErrorFlagMask ("ErrorFlagMask", 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 static level"},
const Reg DACoutMode ("DACoutMode", RW::ReadWrite, TYPE::DIG, {{"Static", "DAC fixed level"},
{"ChInput", "From Channel"},
{"ChSum", "Sum of all Channels"},
{"OverThrSum", "Number of Channels triggered"},
{"Ramp", "14-bit counter"},
{"Sin5MHz", "5 MHz Sin wave Vpp = 2V"},
{"IPE", "Internal Pulse Emultor"},
{"Sin5MHz", "5 MHz Sin wave"},
{"Square", "Test Pulse"}});
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 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
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
@ -306,7 +256,6 @@ namespace PHA{
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 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 = {
@ -360,9 +309,6 @@ namespace PHA{
SpeedSensFan2 ,
ErrorFlags ,
BoardReady ,
// SPFLinkPresence ,
// SPFLinkActive ,
// SPFLinkProtocol ,
ClockSource ,
IO_Level ,
StartSource ,
@ -391,55 +337,18 @@ namespace PHA{
DACoutMode ,
DACoutStaticLevel ,
DACoutChSelect ,
EnableOffsetCalibration ,
ITLAMainLogic ,
ITLAMajorityLev ,
ITLAPairLogic ,
ITLAPolarity ,
ITLAMask ,
ITLAGateWidth ,
ITLBMainLogic ,
ITLBMajorityLev ,
ITLBPairLogic ,
ITLBPolarity ,
ITLBMask ,
ITLBGateWidth ,
LVDSIOReg
//LVDSTrgMask
EnableOffsetCalibration
};
}
namespace GROUP{
const Reg InputDelay ("InputDelay", RW::ReadWrite, TYPE::GROUP, {{"0",""}, {"32768", ""}, {"8", ""}}, ANSTYPE::INTEGER, "ns");
}
namespace VGA{
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{
/// ========= command
const Reg SendChSWTrigger ("SendChSWrigger", RW::WriteOnly, TYPE::CH, {}, ANSTYPE::NONE, "", true);
/// ========= red only
const Reg SelfTrgRate ("SelfTrgRate", RW::ReadOnly, TYPE::CH, {}, ANSTYPE::INTEGER, "Hz");
const Reg ChannelStatus ("ChStatus", RW::ReadOnly, TYPE::CH, {}, ANSTYPE::STR);
@ -453,11 +362,6 @@ namespace PHA{
const Reg ChannelWaveCount ("ChWaveCnt", RW::ReadOnly, TYPE::CH, {}, ANSTYPE::STR);
/// ======= 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 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);
@ -468,7 +372,6 @@ namespace PHA{
{"ADC_TEST_RAMP", "ADC produces RAMP signal"},
{"ADC_TEST_SIN", "ADC produce SIN signal"},
{"Ramp", "Ramp generator"},
{"IPE", "Internal Pulse Emulator"},
{"SquareWave", "Test Pusle (Square Wave)"} });
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");
@ -570,9 +473,6 @@ namespace PHA{
{"SWTrigger", "Software Trigger"},
{"ChSelfTrigger", "Channel Self-Trigger"},
{"Ch64Trigger", "Channel 64-Trigger"},
{"ITLA", "ITL-A"},
{"ITLB", "ITL-B"},
{"LVDS", "LVDS"},
{"Disabled", "Disabled"}});
const Reg ChannelsTriggerMask ("ChannelsTriggerMask", RW::ReadWrite, TYPE::CH, {}, ANSTYPE::BYTE, "64-bit" );
const Reg ChannelVetoSource ("ChannelVetoSource", RW::ReadWrite, TYPE::CH, {{"BoardVeto", "Board Veto"},
@ -587,9 +487,6 @@ namespace PHA{
{"SWTrigger", "Software Trigger"},
{"ChSelfTrigger", "Channel Self-Trigger"},
{"Ch64Trigger", "Channel 64-Trigger"},
{"ITLA", "ITL-A"},
{"ITLB", "ITL-B"},
{"LVDS", "LVDS"},
{"Disabled", "Disabled"}});
const Reg EventSelector ("EventSelector", RW::ReadWrite, TYPE::CH, {{"All", "All"},
@ -628,43 +525,26 @@ namespace PHA{
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 ITLConnect ("ITLConnect", RW::ReadWrite, TYPE::CH, {{"Disabled", "Disabled"},{"ITLA", "ITLA"}, {"ITLB", "ITLB"}});
const std::vector<Reg> AllSettings = {
SelfTrgRate , // 0
ChannelStatus , // 1
GainFactor , // 2
ADCToVolts , // 3
Energy_Nbit , // 4
ChannelRealtime , // 5
ChannelDeadtime , // 6
ChannelTriggerCount , // 7
ChannelSavedCount , // 8
ChannelWaveCount , // 9
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
SelfTrgRate ,
ChannelStatus ,
GainFactor ,
ADCToVolts ,
Energy_Nbit ,
ChannelRealtime ,
ChannelDeadtime ,
ChannelTriggerCount ,
ChannelSavedCount ,
ChannelWaveCount ,
ChannelEnable ,
DC_Offset ,
TriggerThreshold ,
Polarity ,
WaveDataSource ,
RecordLength ,
WaveSaving ,
WaveResolution ,
PreTrigger ,
TimeFilterRiseTime ,
TimeFilterRetriggerGuard ,
EnergyFilterRiseTime ,
@ -683,20 +563,28 @@ namespace PHA{
WaveDigitalProbe1 ,
WaveDigitalProbe2 ,
WaveDigitalProbe3 ,
SelfTriggerWidth ,
SignalOffset
// CoincidenceLengthSample ,
// RecordLengthSample ,
// PreTriggerSample ,
// TimeFilterRiseTimeSample ,
// TimeFilterRetriggerGuardSample ,
// EnergyFilterRiseTimeSample ,
// EnergyFilterFlatTopSample ,
// EnergyFilterPoleZeroSample ,
// EnergyFilterBaselineGuardSample ,
// EnergyFilterPileUpGuardSample
EventTriggerSource ,
ChannelsTriggerMask ,
ChannelVetoSource ,
WaveTriggerSource ,
EventSelector ,
WaveSelector ,
CoincidenceMask ,
AntiCoincidenceMask ,
CoincidenceLength ,
CoincidenceLengthSample ,
ADCVetoWidth ,
EnergySkimLowDiscriminator ,
EnergySkimHighDiscriminator,
RecordLengthSample ,
PreTriggerSample ,
TimeFilterRiseTimeSample ,
TimeFilterRetriggerGuardSample ,
EnergyFilterRiseTimeSample ,
EnergyFilterFlatTopSample ,
EnergyFilterPoleZeroSample ,
EnergyFilterBaselineGuardSample ,
EnergyFilterPileUpGuardSample
};
}
@ -704,513 +592,4 @@ 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

View File

@ -1,51 +1,30 @@
#ifndef HIT_H
#define HIT_H
#ifndef EVENT_H
#define EVENT_H
#include <stdio.h>
#include <cstdlib>
#include <stdint.h>
#include <string>
#define MaxTraceLenght 8100
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 {
class Event {
public:
unsigned short dataType;
std::string DPPType;
///============= for dpp-pha
uint8_t channel; // 6 bit
uint16_t energy; // 16 bit
uint16_t energy_short; // 16 bit, only for PSD
uint64_t timestamp; // 48 bit
uint16_t fine_timestamp; // 10 bit
uint16_t fine_timestamp; // 16 bit
uint16_t flags_low_priority; // 12 bit
uint16_t flags_high_priority; // 8 bit
size_t traceLenght; // 64 bit
uint8_t downSampling; // 8 bit
bool board_fail;
bool flush;
uint8_t analog_probes_type[2]; // 3 bit for PHA, 4 bit for PSD
uint8_t digital_probes_type[4]; // 4 bit for PHA, 5 bit for PSD
uint8_t analog_probes_type[2]; // 3 bit
uint8_t digital_probes_type[4]; // 4 bit
int32_t * analog_probes[2]; // 18 bit
uint8_t * digital_probes[4]; // 1 bit
uint16_t trigger_threashold; // 16 bit
@ -59,21 +38,17 @@ class Hit {
bool isTraceAllZero;
Hit(){
Event(){
Init();
}
~Hit(){
~Event(){
ClearMemory();
}
void Init(){
DPPType = DPPType::PHA;
dataType = DataFormat::ALL;
channel = 0;
energy = 0;
energy_short = 0;
timestamp = 0;
fine_timestamp = 0;
downSampling = 0;
@ -116,12 +91,11 @@ class Hit {
isTraceAllZero = true;
}
void SetDataType(unsigned int type, std::string dppType){
void SetDataType(unsigned int type){
dataType = type;
DPPType = dppType;
ClearMemory();
if( dataType == DataFormat::Raw){
if( dataType == 0xF){
data = new uint8_t[20*1024*1024];
}else{
analog_probes[0] = new int32_t[MaxTraceLenght];
@ -157,29 +131,15 @@ class Hit {
}
std::string AnaProbeType(uint8_t probeType){
if( DPPType == DPPType::PHA){
switch(probeType){
case 0: return "ADC";
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){
if( DPPType == DPPType::PHA){
switch(probeType){
case 0: return "Trigger";
case 1: return "Time filter armed";
@ -196,26 +156,6 @@ class Hit {
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";
}
}
std::string HighPriority(uint16_t prio){
@ -236,20 +176,9 @@ class Hit {
//TODO LowPriority
void PrintAll(){
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("============= Type : %u\n", dataType);
printf("ch : %2d (0x%02X), fail: %d, flush: %d\n", channel, channel, board_fail, flush);
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("energy: %u, timestamp: %lu, fine_timestamp: %u \n", energy, timestamp, fine_timestamp);
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("AnaProbe Type: %s(%u), %s(%u)\n", AnaProbeType(analog_probes_type[0]).c_str(), analog_probes_type[0],
@ -271,14 +200,7 @@ class Hit {
}
}
void PrintTrace(){
printf("---------- trace length : %zu\n", traceLenght);
if( dataType == DataFormat::OneTrace ){
for(unsigned short i = 0; i < (unsigned short)traceLenght; i++){
printf("%4d| %6d\n", i, analog_probes[0][i]);
}
}
if( dataType == DataFormat::ALL){
void PrintAllTrace(){
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],
@ -288,7 +210,6 @@ class Hit {
digital_probes[3][i]);
}
}
}
};

674
LICENSE
View File

@ -1,674 +0,0 @@
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,85 +1,17 @@
# 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
Ubuntu 22.04
CAEN_FELIB_v1.2.2 + (install first)
CAEN_DIG2_v1.5.3
CAEN_DIG2_v1.5.3 +
CAEN_FELIB_v1.2.2
`sudo apt install qt6-base-dev libcurl4-openssl-dev libqt6charts6-dev`
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
## if *.pro does not exist
use `qmake6 -project ` to generate the *.pro
in the *.pro, add
@ -88,28 +20,6 @@ in the *.pro, add
` LIBS += -lcurl -lCAEN_FELib`
## if *.pro exist
run ` qmake6 *.pro` it will generate Makefile
then run ` qmake6 *.pro` it will generate Makefile
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,11 +10,6 @@ QT += widgets charts
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.
# In order to do so, uncomment the following line.
# Please consult the documentation of the deprecated API in order to know
@ -23,22 +18,5 @@ QMAKE_CFLAGS_RELEASE = -O0
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Input
HEADERS += ClassDigitizer2Gen.h \
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
HEADERS += ClassDigitizer2Gen.h Event.h influxdb.h mainwindow.h digiSettingsPanel.h Digiparameters.h scope.h manyThread.h CustomWidgets.h macro.h SOLARISpanel.h
SOURCES += ClassDigitizer2Gen.cpp influxdb.cpp main.cpp mainwindow.cpp digiSettingsPanel.cpp scope.cpp SOLARISpanel.cpp

View File

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

View File

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

234
SolReader.h Normal file
View File

@ -0,0 +1,234 @@
#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,8 +41,7 @@ private slots:
public slots:
void EnableControl();
void UpdatePanelFromMemory(bool onlyStatus = false);
void UpdateStatus();
void UpdatePanelFromMemory();
signals:
@ -57,16 +56,10 @@ private:
QString digiSettingPath;
QTabWidget * tabWidget;
//------------ Layout/GroupBox
QWidget * bdCfg[MaxNumberOfDigitizer];
QWidget * bdTestPulse[MaxNumberOfDigitizer];
QWidget * bdVGA[MaxNumberOfDigitizer];
QWidget * bdLVDS[MaxNumberOfDigitizer];
QWidget * bdITL[MaxNumberOfDigitizer];
QWidget * bdGroup[MaxNumberOfDigitizer];
QGroupBox * digiBox[MaxNumberOfDigitizer];
QGroupBox * VGABox[MaxNumberOfDigitizer];
QGroupBox * testPulseBox[MaxNumberOfDigitizer];
QGroupBox * box0[MaxNumberOfDigitizer];
QGroupBox * box1[MaxNumberOfDigitizer];
@ -82,9 +75,6 @@ private:
QTabWidget * triggerTab[MaxNumberOfDigitizer];
QTabWidget * triggerMapTab[MaxNumberOfDigitizer];
QTabWidget * chTabWidget[MaxNumberOfDigitizer];
QWidget * digiTab[MaxNumberOfDigitizer];
bool enableSignalSlot;
//---------------- Inquiry and copy
@ -122,7 +112,7 @@ private:
QPushButton * pbCopyDigi;
//------------ status
QLineEdit * leInfo[MaxNumberOfDigitizer][12];
QLineEdit * leInfo[MaxNumberOfChannel][12];
QPushButton * LEDStatus[MaxNumberOfDigitizer][19];
QPushButton * ACQStatus[MaxNumberOfDigitizer][19];
QLineEdit * leTemp[MaxNumberOfDigitizer][8];
@ -141,7 +131,6 @@ private:
//-------------- board settings
RComboBox * cbbClockSource[MaxNumberOfDigitizer];
RComboBox * cbbEnClockFrontPanel[MaxNumberOfDigitizer];
QCheckBox * ckbStartSource[MaxNumberOfDigitizer][5];
QCheckBox * ckbGlbTrgSource[MaxNumberOfDigitizer][5];
RComboBox * cbbTrgOut[MaxNumberOfDigitizer];
@ -164,47 +153,15 @@ private:
RSpinBox * spbTestPusleLowLevel[MaxNumberOfDigitizer];
RSpinBox * spbTestPusleHighLevel[MaxNumberOfDigitizer];
RSpinBox * sbIPEAmplitude[MaxNumberOfDigitizer];
RSpinBox * sbIPEBaseline[MaxNumberOfDigitizer];
RSpinBox * sbIPEDecayTime[MaxNumberOfDigitizer];
RSpinBox * sbIPERate[MaxNumberOfDigitizer];
RComboBox * cbIPETimeMode[MaxNumberOfDigitizer];
//-------------- VGA
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
//RComboBox * cbAllEvtTrigger[MaxNumberOfDigitizer];
//RComboBox * cbAllWaveTrigger[MaxNumberOfDigitizer];
//RComboBox * cbAllCoinMask[MaxNumberOfDigitizer];
//RComboBox * cbAllAntiCoinMask[MaxNumberOfDigitizer];
//RSpinBox * sbAllCoinLength[MaxNumberOfDigitizer];
RComboBox * cbAllEvtTrigger[MaxNumberOfDigitizer];
RComboBox * cbAllWaveTrigger[MaxNumberOfDigitizer];
RComboBox * cbAllCoinMask[MaxNumberOfDigitizer];
RComboBox * cbAllAntiCoinMask[MaxNumberOfDigitizer];
RSpinBox * sbAllCoinLength[MaxNumberOfDigitizer];
QPushButton * trgMap[MaxNumberOfDigitizer][MaxNumberOfChannel][MaxNumberOfChannel];
bool trgMapClickStatus[MaxNumberOfDigitizer][MaxNumberOfChannel][MaxNumberOfChannel];
@ -213,9 +170,6 @@ private:
QLineEdit * chGainFactor[MaxNumberOfDigitizer][MaxNumberOfChannel];
QLineEdit * chADCToVolts[MaxNumberOfDigitizer][MaxNumberOfChannel];
//--------------- Group settings
RSpinBox * spbInputDelay[MaxNumberOfDigitizer][MaxNumberOfGroup];
//--------------- Channel settings
RComboBox * cbChPick[MaxNumberOfDigitizer];
@ -230,35 +184,8 @@ private:
RComboBox * cbbWaveRes[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbWaveSave[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbEvtTrigger[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbWaveTrigger[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbCoinMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbAntiCoinMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbCoinLength[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
QLineEdit * leTriggerMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbChVetoSrc[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbADCVetoWidth[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 * cbbAnaProbe1[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbDigProbe0[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbDigProbe1[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbDigProbe2[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbDigProbe3[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
//........... PHA
RSpinBox * spbInputRiseTime[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbTriggerGuard[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbLowFilter[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbTrapRiseTime[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbTrapFlatTop[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
@ -268,35 +195,37 @@ private:
RSpinBox * spbBaselineGuard[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbPileupGuard[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbPeakingAvg[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbBaselineAvg[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbFineGain[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbPeakingAvg[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbLowFilter[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
//.............. PSD
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];
RComboBox * cbbAnaProbe0[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbAnaProbe1[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbTriggerFilter[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];
RComboBox * cbbDigProbe0[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbDigProbe1[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbDigProbe2[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbDigProbe3[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];
RComboBox * cbbEvtTrigger[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbWaveTrigger[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbChVetoSrc[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbEventSelector[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbWaveSelector[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbCoinMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbAntiCoinMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
QLineEdit * leTriggerMask[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbCoinLength[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbADCVetoWidth[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbEnergySkimLow[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbEnergySkimHigh[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RSpinBox * spbNeutronThreshold[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbEventNeutronReject[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
RComboBox * cbbWaveNeutronReject[MaxNumberOfDigitizer][MaxNumberOfChannel + 1];
//-------------------------
QLineEdit * leSettingFile[MaxNumberOfDigitizer];
@ -319,9 +248,6 @@ private:
void FillComboBoxValueFromMemory(RComboBox * &cbb, 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 ReadChannelSetting(int cbIndex);

View File

@ -1,37 +0,0 @@
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

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

View File

@ -1,76 +0,0 @@
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)

61
grafanaScreenShot.sh Executable file
View File

@ -0,0 +1,61 @@
#!/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

157
influxdb.cpp Normal file
View File

@ -0,0 +1,157 @@
#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

@ -10,45 +10,32 @@
class InfluxDB{
private:
bool isURLValid;
CURL * curl;
CURLcode respond;
long respondCode;
std::string databaseIP;
std::string dataPoints;
std::string token;
struct curl_slist * headers;
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);
void Execute();
public:
/// url = https://fsunuc.physics.fsu.edu/InfluxDB/
InfluxDB(std::string url, bool verbose = false);
InfluxDB();
~InfluxDB();
void SetURL(std::string url);
void SetToken(std::string token);
bool TestingConnection(bool debug = false);
bool IsConnectionOK() const {return connectionOK;}
bool TestingConnection();
bool IsURLValid() const {return isURLValid;}
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);
/// Query
std::string CheckDatabases(); /// this save the list of database into databaseList
void PrintDataBaseList();
std::string Query(std::string databaseName, std::string query);
/// the CheckDatabases() function must be called before

View File

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

View File

@ -8,8 +8,6 @@
int main(int argc, char *argv[]){
printf("######### Starting SOLARIS DAQ....\n");
QApplication a(argc, argv);
bool isLock = false;
@ -39,7 +37,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.setIcon(QMessageBox::Information);
QPushButton * kill = msgBox.addButton("Kill and Open New", QMessageBox::AcceptRole);
QPushButton * kill = msgBox.addButton("Kill", QMessageBox::AcceptRole);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
@ -62,7 +60,6 @@ int main(int argc, char *argv[]){
pidFile.write( QString::number(QCoreApplication::applicationPid() ).toStdString().c_str() );
pidFile.close();
printf("######### Open Main Window...\n");
MainWindow w;
w.show();
return a.exec();

File diff suppressed because it is too large Load Diff

View File

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

32
makeTest Executable file
View File

@ -0,0 +1,32 @@
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)

123
manyThread.h Normal file
View File

@ -0,0 +1,123 @@
#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

593
scope.cpp
View File

@ -12,7 +12,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
this->digi = digi;
this->nDigi = nDigi;
if( nDigi > MaxNumberOfDigitizer ) {
this->nDigi = MaxNumberOfDigitizer;
this->nDigi = MaxNumberOfChannel;
qDebug() << "Please increase the MaxNumberOfChannel";
}
this->readDataThread = readDataThread;
@ -22,7 +22,6 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
setWindowFlags( this->windowFlags() & ~Qt::WindowCloseButtonHint );
allowChange = false;
originalValueSet = false;
plot = new Trace();
for( int i = 0; i < 6; i++) {
@ -55,9 +54,8 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
xaxis->setLabelFormat("%.0f");
xaxis->setTitleText("Time [ns]");
updateTraceThread = new TimingThread();
updateTraceThread->SetWaitTimeSec(0.2);
connect(updateTraceThread, &TimingThread::TimeUp, this, &Scope::UpdateScope);
updateTraceThread = new UpdateTraceThread();
connect(updateTraceThread, &UpdateTraceThread::updateTrace, this, &Scope::UpdateScope);
//*================ add Widgets
int rowID = -1;
@ -73,43 +71,44 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
layout->addWidget(cbScopeDigi, rowID, 0);
layout->addWidget(cbScopeCh, rowID, 1);
allowChange = false;
cbScopeDigi->clear(); ///this will also trigger RComboBox::currentIndexChanged
cbScopeCh->clear();
for( unsigned int i = 0 ; i < nDigi; i++) {
cbScopeDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
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);
}
cbScopeDigi->setCurrentIndex(1);
allowChange = true;
connect(cbScopeDigi, &RComboBox::currentIndexChanged, this, &Scope::ChangeDigitizer);
//if( allowChange )StartScope(index);
});
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);
}
ReadScopeSettings();
digiMTX[iDigi].unlock();
});
bnScopeReset = new QPushButton("ReProgram Channels", this);
allowChange = false;
cbScopeDigi->clear(); ///this will also trigger RComboBox::currentIndexChanged
cbScopeCh->clear();
for( unsigned int i = 0 ; i < nDigi; i++) {
cbScopeDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
}
allowChange = true;
bnScopeReset = new QPushButton("ReProgram Digitizer", this);
layout->addWidget(bnScopeReset, rowID, 2);
connect(bnScopeReset, &QPushButton::clicked, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex();
//digi[iDigi]->Reset();
digi[iDigi]->ProgramChannels();
//SendLogMsg("Reset Digi-" + QString::number(digi[iDigi]->GetSerialNumber()) + " and Set Default PHA.");
ReadScopeSettings();
UpdateOtherPanels();
SendLogMsg("Re-program all Channels to default PHA settings");
digi[iDigi]->Reset();
digi[iDigi]->ProgramPHA(false);
SendLogMsg("Reset Digi-" + QString::number(digi[iDigi]->GetSerialNumber()) + " and Set Default PHA.");
});
bnScopeReadSettings = new QPushButton("Read Ch. Settings", this);
@ -126,25 +125,30 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
//------------ Probe selection
rowID ++;
//TODO --- add None for probel selection
//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));
}
cbAnaProbe[1] = new RComboBox(this);
cbDigProbe[0] = new RComboBox(this);
cbDigProbe[1] = new RComboBox(this);
cbDigProbe[2] = new RComboBox(this);
cbDigProbe[3] = new RComboBox(this);
for( int i = 0; i < cbAnaProbe[0]->count() ; i++) cbAnaProbe[1]->addItem(cbAnaProbe[0]->itemText(i), cbAnaProbe[0]->itemData(i));
connect(cbAnaProbe[0], &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, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(anaProbeList[0], (cbAnaProbe[0]->currentData()).toString().toStdString(), ch);
digi[iDigi]->WriteValue(PHA::CH::WaveAnalogProbe0, (cbAnaProbe[0]->currentData()).toString().toStdString(), ch);
digiMTX[iDigi].unlock();
});
@ -154,22 +158,44 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(anaProbeList[1], (cbAnaProbe[1]->currentData()).toString().toStdString(), ch);
digi[iDigi]->WriteValue(PHA::CH::WaveAnalogProbe1, (cbAnaProbe[1]->currentData()).toString().toStdString(), ch);
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[1], &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);});
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, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(digiProbeList[0], (cbDigProbe[0]->currentData()).toString().toStdString(), ch);
digi[iDigi]->WriteValue(PHA::CH::WaveDigitalProbe0, (cbDigProbe[0]->currentData()).toString().toStdString(), ch);
digiMTX[iDigi].unlock();
});
connect(cbDigProbe[1], &RComboBox::currentIndexChanged, this, [=](){
@ -178,7 +204,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(digiProbeList[1], (cbDigProbe[1]->currentData()).toString().toStdString(), ch);
digi[iDigi]->WriteValue(PHA::CH::WaveDigitalProbe1, (cbDigProbe[1]->currentData()).toString().toStdString(), ch);
digiMTX[iDigi].unlock();
});
connect(cbDigProbe[2], &RComboBox::currentIndexChanged, this, [=](){
@ -187,7 +213,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(digiProbeList[2], (cbDigProbe[2]->currentData()).toString().toStdString(), ch);
digi[iDigi]->WriteValue(PHA::CH::WaveDigitalProbe2, (cbDigProbe[2]->currentData()).toString().toStdString(), ch);
digiMTX[iDigi].unlock();
});
connect(cbDigProbe[3], &RComboBox::currentIndexChanged, this, [=](){
@ -196,7 +222,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
int ch = cbScopeCh->currentIndex();
if( chkSetAllChannel->isChecked() ) ch = -1;
digiMTX[iDigi].lock();
digi[iDigi]->WriteValue(digiProbeList[3], (cbDigProbe[3]->currentData()).toString().toStdString(), ch);
digi[iDigi]->WriteValue(PHA::CH::WaveDigitalProbe3, (cbDigProbe[3]->currentData()).toString().toStdString(), ch);
digiMTX[iDigi].unlock();
});
@ -211,187 +237,13 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
for( int i = 0; i < 6; i++) layout->setColumnStretch(i, 1);
rowID ++;
{//------------ wave settings
settingBox = new QGroupBox("Channel Settings (need ACQ stop)", this);
layout->addWidget(settingBox, rowID, 0, 1, 6);
QGroupBox * box = new QGroupBox("Channel Settings (need ACQ stop)", this);
layout->addWidget(box, rowID, 0, 1, 6);
bLayout = new QGridLayout(settingBox);
QGridLayout * bLayout = new QGridLayout(box);
bLayout->setSpacing(0);
if( digi[0]->GetFPGAType() == DPPType::PHA ) SetupPHA();
if( digi[0]->GetFPGAType() == DPPType::PSD ) SetupPSD();
}
//Trigger the ChangeDigitizer()
cbScopeDigi->setCurrentIndex(0);
cbScopeCh->setCurrentIndex(1);
cbScopeCh->setCurrentIndex(0);
//------------ plot view
rowID ++;
TraceView * plotView = new TraceView(plot);
plotView->setRenderHints(QPainter::Antialiasing);
layout->addWidget(plotView, rowID, 0, 1, 6);
//------------- Key binding
rowID ++;
QLabel * lbhints = new QLabel("Type 'r' to restore view, '+/-' Zoom in/out, arrow key to pan.", this);
layout->addWidget(lbhints, rowID, 0, 1, 4);
QLabel * lbinfo = new QLabel("Trace update every " + QString::number(updateTraceThread->GetWaitTimeinSec()) + " sec.", this);
lbinfo->setAlignment(Qt::AlignRight);
layout->addWidget(lbinfo, rowID, 5);
rowID ++;
QLabel * lbinfo2 = new QLabel("Maximum time range is " + QString::number(MaxDisplayTraceDataLength * PHA::TraceStep) + " ns due to processing speed.", this);
layout->addWidget(lbinfo2, rowID, 0, 1, 5);
//------------ close button
rowID ++;
bnScopeStart = new QPushButton("Start", this);
layout->addWidget(bnScopeStart, rowID, 0);
bnScopeStart->setEnabled(true);
connect(bnScopeStart, &QPushButton::clicked, this, [=](){this->StartScope();});
bnScopeStop = new QPushButton("Stop", this);
layout->addWidget(bnScopeStop, rowID, 1);
bnScopeStop->setEnabled(false);
connect(bnScopeStop, &QPushButton::clicked, this, &Scope::StopScope);
QLabel * lbTriggerRate = new QLabel("Trigger Rate [Hz] : ", this);
lbTriggerRate->setAlignment(Qt::AlignCenter | Qt::AlignRight);
layout->addWidget(lbTriggerRate, rowID, 2);
leTriggerRate = new QLineEdit(this);
leTriggerRate->setAlignment(Qt::AlignRight);
leTriggerRate->setReadOnly(true);
layout->addWidget(leTriggerRate, rowID, 3);
QPushButton * bnClose = new QPushButton("Close", this);
layout->addWidget(bnClose, rowID, 5);
connect(bnClose, &QPushButton::clicked, this, &Scope::close);
show();
//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(){
printf("------- %s \n", __func__);
StopScope();
updateTraceThread->Stop();
updateTraceThread->quit();
updateTraceThread->wait();
delete updateTraceThread;
for( int i = 0; i < 6; i++) delete dataTrace[i];
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);
@ -414,47 +266,67 @@ void Scope::SetupPHA(){
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);
}
//------------ plot view
rowID ++;
TraceView * plotView = new TraceView(plot);
plotView->setRenderHints(QPainter::Antialiasing);
layout->addWidget(plotView, rowID, 0, 1, 6);
//------------- Key binding
rowID ++;
QLabel * lbhints = new QLabel("Type 'r' to restore view, '+/-' Zoom in/out, arrow key to pan.", this);
layout->addWidget(lbhints, rowID, 0, 1, 4);
QLabel * lbinfo = new QLabel("Trace update every " + QString::number(updateTraceThread->GetWaitTimeSec()) + " sec.", this);
lbinfo->setAlignment(Qt::AlignRight);
layout->addWidget(lbinfo, rowID, 5);
rowID ++;
QLabel * lbinfo2 = new QLabel("Maximum time range is " + QString::number(MaxDisplayTraceDataLength * PHA::TraceStep) + " ns due to processing speed.", this);
layout->addWidget(lbinfo2, rowID, 0, 1, 5);
//------------ close button
rowID ++;
bnScopeStart = new QPushButton("Start", this);
layout->addWidget(bnScopeStart, rowID, 0);
bnScopeStart->setEnabled(false);
connect(bnScopeStart, &QPushButton::clicked, this, [=](){this->StartScope();});
bnScopeStop = new QPushButton("Stop", this);
layout->addWidget(bnScopeStop, rowID, 1);
connect(bnScopeStop, &QPushButton::clicked, this, &Scope::StopScope);
QLabel * lbTriggerRate = new QLabel("Trigger Rate [Hz] : ", this);
lbTriggerRate->setAlignment(Qt::AlignCenter | Qt::AlignRight);
layout->addWidget(lbTriggerRate, rowID, 2);
leTriggerRate = new QLineEdit(this);
leTriggerRate->setAlignment(Qt::AlignRight);
leTriggerRate->setReadOnly(true);
layout->addWidget(leTriggerRate, rowID, 3);
QPushButton * bnClose = new QPushButton("Close", this);
layout->addWidget(bnClose, rowID, 5);
connect(bnClose, &QPushButton::clicked, this, &Scope::close);
show();
StartScope();
}
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);
Scope::~Scope(){
updateTraceThread->Stop();
updateTraceThread->quit();
updateTraceThread->wait();
delete updateTraceThread;
for( int i = 0; i < 6; i++) delete dataTrace[i];
delete plot;
}
void Scope::ReadScopeSettings(){
@ -464,6 +336,34 @@ void Scope::ReadScopeSettings(){
int iDigi = cbScopeDigi->currentIndex();
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();
}
@ -481,16 +381,13 @@ void Scope::UpdateSettingsFromMemeory(){
int ch = cbScopeCh->currentIndex();
for( int i = 0 ; i < 2; 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]);
ScopeReadComboBoxValue(iDigi, ch, cbAnaProbe[i], PHA::CH::AnalogProbe[i]);
}
for( int i = 0 ; i < 4; 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, cbDigProbe[i], PHA::CH::DigitalProbe[i]);
}
if( digi[iDigi]->GetFPGAType() == DPPType::PHA ){
ScopeReadComboBoxValue(iDigi, ch, cbPolarity, PHA::CH::Polarity);
ScopeReadComboBoxValue(iDigi, ch, cbWaveRes, PHA::CH::WaveResolution);
ScopeReadComboBoxValue(iDigi, ch, cbTrapPeakAvg, PHA::CH::EnergyFilterPeakingAvg);
@ -523,89 +420,11 @@ void Scope::UpdateSettingsFromMemeory(){
sbTrapPeaking->setStyleSheet("");
sbBaselineGuard->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;
}
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(){
if( !digi ) return;
@ -621,32 +440,10 @@ void Scope::StartScope(){
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);
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]->SetPHADataFormat(0);
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();
readDataThread[iDigi]->SetSaveData(false);
@ -669,23 +466,16 @@ void Scope::StopScope(){
updateTraceThread->quit();
updateTraceThread->wait();
/// the settings are the same for PHA and PSD
if(digi){
for(int i = 0; i < nDigi; i++){
if( digi[i]->IsDummy() ) continue;
readDataThread[i]->Stop();
readDataThread[i]->quit();
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);
digi[i]->WriteValue(PHA::CH::ChannelEnable, "True", -1);
digiMTX[i].unlock();
readDataThread[i]->quit();
readDataThread[i]->wait();
}
emit TellACQOnOff(false);
@ -705,8 +495,6 @@ void Scope::UpdateScope(){
emit UpdateScalar();
/// the settings are the same for PHA and PSD
if( digi ){
digiMTX[iDigi].lock();
@ -714,8 +502,8 @@ void Scope::UpdateScope(){
std::string haha = digi[iDigi]->ReadValue(PHA::CH::SelfTrgRate, ch);
leTriggerRate->setText(QString::fromStdString(haha));
//unsigned int traceLength = qMin((int) digi[iDigi]->hit->traceLenght, MaxDisplayTraceDataLength);
unsigned int traceLength = qMin( atoi(digi[iDigi]->GetSettingValueFromMemory(PHA::CH::RecordLength, ch).c_str())/sample2ns, MaxDisplayTraceDataLength );
//unsigned int traceLength = qMin((int) digi[iDigi]->evt->traceLenght, MaxDisplayTraceDataLength);
unsigned int traceLength = qMin( atoi(digi[iDigi]->GetSettingValue(PHA::CH::RecordLength, ch).c_str())/sample2ns, MaxDisplayTraceDataLength );
if( atoi(haha.c_str()) == 0 ) {
digiMTX[iDigi].unlock();
@ -729,19 +517,16 @@ void Scope::UpdateScope(){
return;
}
//printf("%s, traceLength : %d , %d\n", __func__, traceLength, digi[iDigi]->hit->analog_probes[0][10]);
for( int j = 0; j < 2; j++) {
QVector<QPointF> points;
for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , digi[iDigi]->hit->analog_probes[j][i]));
for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , digi[iDigi]->evt->analog_probes[j][i]));
dataTrace[j]->replace(points);
}
for( int j = 0; j < 4; j++) {
QVector<QPointF> points;
for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , (j+1)*5000 + 4000*digi[iDigi]->hit->digital_probes[j][i]));
for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , (j+1)*1000 + 4000*digi[iDigi]->evt->digital_probes[j][i]));
dataTrace[j+2]->replace(points);
}
//digi[iDigi]->hit->ClearTrace();
digiMTX[iDigi].unlock();
plot->axes(Qt::Horizontal).first()->setRange(0, sample2ns * traceLength);
@ -751,9 +536,7 @@ void Scope::UpdateScope(){
void Scope::ProbeChange(RComboBox * cb[], const int size ){
if( allowChange == false ) return;
//printf("%s\n", __func__);
printf("%s\n", __func__);
QStandardItemModel * model[size] = {NULL};
for( int i = 0; i < size; i++){
model[i] = qobject_cast<QStandardItemModel*>(cb[i]->model());
@ -772,15 +555,15 @@ void Scope::ProbeChange(RComboBox * cb[], const int size ){
}
}
//int ID = cbScopeDigi->currentIndex();
//digiMTX[ID].lock();
int ID = cbScopeDigi->currentIndex();
digiMTX[ID].lock();
if( size == 2) {// analog probes
for( int j = 0; j < 2; j++ )dataTrace[j]->setName(cb[j]->currentText());
}
if( size == 4){ // digitial probes
for( int j = 2; j < 6; j++ )dataTrace[j]->setName(cb[j-2]->currentText());
}
//digiMTX[ID].unlock();
digiMTX[ID].unlock();
}
@ -791,7 +574,6 @@ void Scope::ScopeControlOnOff(bool on){
bnScopeReset->setEnabled(on);
bnScopeReadSettings->setEnabled(on);
if( digi[cbScopeDigi->currentIndex()]->GetFPGAType() == DPPType::PHA ){
sbRL->setEnabled(on);
sbPT->setEnabled(on);
sbTimeRiseTime->setEnabled(on);
@ -811,45 +593,16 @@ void Scope::ScopeControlOnOff(bool on){
//sbBaselineGuard->setEnabled(on);
//sbPileUpGuard->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){
std::string ans = digi[iDigi]->GetSettingValueFromMemory(digPara, ch);
std::string ans = digi[iDigi]->GetSettingValue(digPara, ch);
sb->setValue(atoi(ans.c_str()));
}
void Scope::ScopeReadComboBoxValue(int iDigi, int ch, RComboBox *cb, const Reg digPara){
std::string ans = digi[iDigi]->GetSettingValueFromMemory(digPara, ch);
std::string ans = digi[iDigi]->GetSettingValue(digPara, ch);
int index = cb->findData(QString::fromStdString(ans));
if( index >= 0 && index < cb->count()) {
cb->setCurrentIndex(index);
@ -859,11 +612,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){
//printf("%s\n", __func__);
QLabel * lb = new QLabel(str, settingBox);
printf("%s\n", __func__);
QLabel * lb = new QLabel(str, this);
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
layout->addWidget(lb, row, col);
sb = new RSpinBox(settingBox);
sb = new RSpinBox(this);
sb->setMinimum(atof(digPara.GetAnswers()[0].first.c_str()));
sb->setMaximum(atof(digPara.GetAnswers()[1].first.c_str()));
sb->setSingleStep(atof(digPara.GetAnswers()[2].first.c_str()));
@ -901,11 +654,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){
QLabel * lb = new QLabel(str, settingBox);
QLabel * lb = new QLabel(str, this);
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
layout->addWidget(lb, row, col);
cb = new RComboBox(settingBox);
cb = new RComboBox(this);
for( int i = 0 ; i < (int) digPara.GetAnswers().size(); i++){
cb->addItem(QString::fromStdString((digPara.GetAnswers())[i].second), QString::fromStdString((digPara.GetAnswers())[i].first));
}

78
scope.h
View File

@ -8,7 +8,6 @@
#include <QSpinBox>
#include <QLabel>
#include <QPushButton>
#include <QGroupBox>
#include <QCheckBox>
#include <QLineEdit>
#include <QComboBox>
@ -20,7 +19,7 @@
#include "macro.h"
#include "ClassDigitizer2Gen.h"
#include "CustomThreads.h"
#include "manyThread.h"
#include "CustomWidgets.h"
class Trace : public QChart{
@ -130,10 +129,10 @@ public:
public slots:
void ReadScopeSettings(); // read from digitizer and show;
void UpdateSettingsFromMemeory();
void StartScope();
void StopScope();
private slots:
void StartScope();
void StopScope();
void UpdateScope();
void ScopeControlOnOff(bool on);
void ScopeReadSpinBoxValue(int iDigi, int ch, RSpinBox *sb, const Reg digPara);
@ -163,13 +162,7 @@ private:
unsigned short nDigi;
ReadDataThread ** readDataThread;
TimingThread * updateTraceThread;
QGroupBox * settingBox;
QGridLayout * bLayout; // for wave setting
std::vector<Reg> anaProbeList;
std::vector<Reg> digiProbeList;
UpdateTraceThread * updateTraceThread;
QChart * plot;
QLineSeries * dataTrace[6];
@ -182,77 +175,32 @@ private:
QPushButton * bnScopeStart;
QPushButton * bnScopeStop;
QLineEdit * leTriggerRate;
RComboBox * cbAnaProbe[2];
RComboBox * cbDigProbe[4];
RSpinBox * sbRL; // record length
RSpinBox * sbThreshold;
RComboBox * cbPolarity;
RComboBox * cbWaveRes;
RSpinBox * sbPT; // pre trigger
RSpinBox * sbDCOffset;
//-------- PHA
RSpinBox * sbThreshold;
RSpinBox * sbTimeRiseTime;
RSpinBox * sbTimeGuard;
RComboBox * cbLowFreqFilter;
RSpinBox * sbTrapRiseTime;
RSpinBox * sbTrapFlatTop;
RSpinBox * sbTrapPoleZero;
RSpinBox * sbEnergyFineGain;
RSpinBox * sbTrapPeaking;
RComboBox * cbPolarity;
RComboBox * cbWaveRes;
RComboBox * cbTrapPeakAvg;
QLineEdit * leTriggerRate;
RSpinBox * sbBaselineGuard;
RSpinBox * sbPileUpGuard;
RComboBox * cbBaselineAvg;
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;
RComboBox * cbLowFreqFilter;
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

93
script.C Normal file
View File

@ -0,0 +1,93 @@
#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;
}

View File

@ -1,19 +0,0 @@
#!/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"

View File

@ -1,68 +0,0 @@
#!/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

@ -1,29 +0,0 @@
{
"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 Normal file
View File

@ -0,0 +1,176 @@
#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;
}

94
windowID.cpp Normal file
View File

@ -0,0 +1,94 @@
#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;
}