have GUI fundation, linker and such

This commit is contained in:
Ryan Tang 2023-01-25 14:59:48 -05:00
commit 54ec85b849
13 changed files with 1462 additions and 0 deletions

76
.gitignore vendored Normal file
View File

@ -0,0 +1,76 @@
# This file is used to ignore files which are generated
# ----------------------------------------------------------------------------
SOLARIS_DAQ
*~
*.autosave
moc_*
*.a
*.core
*.moc
*.o
*.obj
*.orig
*.rej
*.so
*.so.*
*_pch.h.cpp
*_resource.rc
*.qm
.#*
*.*#
core
!core/
tags
.DS_Store
.directory
*.debug
Makefile*
*.prl
*.app
moc_*.cpp
ui_*.h
qrc_*.cpp
Thumbs.db
*.res
*.rc
/.qmake.cache
/.qmake.stash
# qtcreator generated files
*.pro.user*
CMakeLists.txt.user*
# xemacs temporary files
*.flc
# Vim temporary files
.*.swp
# Visual Studio generated files
*.ib_pdb_index
*.idb
*.ilk
*.pdb
*.sln
*.suo
*.vcproj
*vcproj.*.*.user
*.ncb
*.sdf
*.opensdf
*.vcxproj
*vcxproj.*
# MinGW generated files
*.Debug
*.Release
# Python byte code
*.pyc
# Binaries
# --------
*.dll
*.exe

17
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/x86_64-linux-gnu/qt6/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}

658
ClassDigitizer2Gen.cpp Normal file
View File

@ -0,0 +1,658 @@
#include "ClassDigitizer2Gen.h"
Digitizer2Gen::Digitizer2Gen(){
printf("======== %s \n",__func__);
Initialization();
}
Digitizer2Gen::~Digitizer2Gen(){
printf("======== %s \n",__func__);
if(isConnected ) CloseDigitizer();
}
void Digitizer2Gen::Initialization(){
printf("======== %s \n",__func__);
handle = 0;
ret = 0;
isConnected = false;
modelName = "";
cupVersion = "";
DPPVersion = "";
DPPType = "";
serialNumber = 0;
adcBits = 0;
nChannels = 0;
adcRate = 0;
ch2ns = 0;
IPAddress = "";
netMask = "";
gateway = "";
outFileIndex = 0;
dataStartIndetifier = 0xAAA0;
outFile = NULL;
outFileSize = 0;
evt = NULL;
acqON = false;
}
//########################################### Handles functions
uint64_t Digitizer2Gen::GetHandle(const char * parameter){
uint64_t par_handle;
ret = CAEN_FELib_GetHandle(handle, parameter, &par_handle);
if(ret != CAEN_FELib_Success) {
ErrorMsg(__func__);
return 0;
}
return par_handle;
}
uint64_t Digitizer2Gen::GetParentHandle(uint64_t handle){
uint64_t par_handle;
ret = CAEN_FELib_GetParentHandle(handle, NULL, &par_handle);
if(ret != CAEN_FELib_Success) {
ErrorMsg(__func__);
return 0;
}
return par_handle;
}
std::string Digitizer2Gen::GetPath(uint64_t handle){
char path[256];
ret = CAEN_FELib_GetPath(handle, path);
if(ret != CAEN_FELib_Success) {
ErrorMsg(__func__);
return "Error";
}
return path;
}
//########################################### Read Write
std::string Digitizer2Gen::ReadValue(const char * parameter, bool verbose){
if( !isConnected ) return "not connected";
//printf(" %s|%s \n", __func__, parameter);
ret = CAEN_FELib_GetValue(handle, parameter, retValue);
if (ret != CAEN_FELib_Success) {
return ErrorMsg(__func__);
}else{
if( verbose ) printf("%-45s : %s\n", parameter, retValue);
}
return retValue;
}
void Digitizer2Gen::WriteValue(const char * parameter, std::string value){
if( !isConnected ) return;
printf(" %s| %-45s : %s\n", __func__, parameter, value.c_str());
ret = CAEN_FELib_SetValue(handle, parameter, value.c_str());
if (ret != CAEN_FELib_Success) {
ErrorMsg(__func__);
return;
}
}
void Digitizer2Gen::SendCommand(const char * parameter){
if( !isConnected ) return;
printf("Send Command : %s \n", parameter);
ret = CAEN_FELib_SendCommand(handle, parameter);
if (ret != CAEN_FELib_Success) {
ErrorMsg(__func__);
return;
}
}
//########################################### Open digitizer
int Digitizer2Gen::OpenDigitizer(const char * url){
printf("======== %s \n",__func__);
ret = CAEN_FELib_Open(url, &handle);
printf("=== ret : %d | %d \n", ret, CAEN_FELib_Success);
if (ret != CAEN_FELib_Success) {
ErrorMsg(__func__);
return -1;
}
isConnected = true;
modelName = ReadValue("/par/ModelName");
cupVersion = ReadValue("/par/cupver");
DPPVersion = ReadValue("/par/FPGA_FwVer");
DPPType = ReadValue("/par/FwType");
serialNumber = atoi(ReadValue("/par/SerialNum").c_str());
nChannels = atoi(ReadValue("/par/NumCh").c_str());
adcBits = atoi(ReadValue("/par/ADC_Nbit").c_str());
adcRate = atoi(ReadValue("/par/ADC_SamplRate").c_str());
ch2ns = 1000/adcRate;
IPAddress = ReadValue("/par/IPAddress");
netMask = ReadValue("/par/Netmask");
gateway = ReadValue("/par/Gateway");
printf(" IP address : %s\n", IPAddress.c_str());
printf(" Net Mask : %s\n", netMask.c_str());
printf(" Gateway : %s\n", gateway.c_str());
printf(" Model name : %s\n", modelName.c_str());
printf(" CUP version : %s\n", cupVersion.c_str());
printf(" DPP Type : %s\n", DPPType.c_str());
printf(" DPP Version : %s\n", DPPVersion.c_str());
printf("Serial number : %d\n", serialNumber);
printf(" ADC bits : %d\n", adcBits);
printf(" ADC rate : %d Msps, ch2ns : %d ns\n", adcRate, ch2ns);
printf(" Channels : %d\n", nChannels);
ReadValue("/par/InputRange", true);
ReadValue("/par/InputType", true);
ReadValue("/par/Zin", true);
return 0;
}
int Digitizer2Gen::CloseDigitizer(){
printf("======== %s \n",__func__);
ret = CAEN_FELib_Close(handle);
if (ret != CAEN_FELib_Success) {
ErrorMsg(__func__);
return 0;
}
isConnected = false;
return 0;
}
//########################################### DAQ
void Digitizer2Gen::StartACQ(){
SendCommand("/cmd/armacquisition"); // this will also clear data
SendCommand("/cmd/swstartacquisition");
acqON = true;
}
void Digitizer2Gen::StopACQ(){
SendCommand("/cmd/SwStopAcquisition");
SendCommand("/cmd/disarmacquisition");
acqON = false;
}
void Digitizer2Gen::SetPHADataFormat(unsigned short dataFormat){
///========== get endpoint and endpoint folder handle
if( dataFormat < 15 ){
ret = CAEN_FELib_GetHandle(handle, "/endpoint/dpppha", &ep_handle);
ret |= CAEN_FELib_GetParentHandle(ep_handle, NULL, &ep_folder_handle);
ret |= CAEN_FELib_SetValue(ep_folder_handle, "/par/activeendpoint", "dpppha");
if (ret != CAEN_FELib_Success) {
ErrorMsg("Set active endpoint");
return;
}
}else{
ret = CAEN_FELib_GetHandle(handle, "/endpoint/raw", &ep_handle);
ret |= CAEN_FELib_GetParentHandle(ep_handle, NULL, &ep_folder_handle);
ret |= CAEN_FELib_SetValue(ep_folder_handle, "/par/activeendpoint", "raw");
if (ret != CAEN_FELib_Success) {
ErrorMsg("Set active endpoint");
return;
}
}
evt = new Event();
evt->SetDataType(dataFormat);
dataStartIndetifier += dataFormat;
if( dataFormat == 0 ){
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
"[ \
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
{ \"name\" : \"ANALOG_PROBE_1\", \"type\" : \"I32\", \"dim\" : 1 }, \
{ \"name\" : \"ANALOG_PROBE_2\", \"type\" : \"I32\", \"dim\" : 1 }, \
{ \"name\" : \"DIGITAL_PROBE_1\", \"type\" : \"U8\", \"dim\" : 1 }, \
{ \"name\" : \"DIGITAL_PROBE_2\", \"type\" : \"U8\", \"dim\" : 1 }, \
{ \"name\" : \"DIGITAL_PROBE_3\", \"type\" : \"U8\", \"dim\" : 1 }, \
{ \"name\" : \"DIGITAL_PROBE_4\", \"type\" : \"U8\", \"dim\" : 1 }, \
{ \"name\" : \"ANALOG_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
{ \"name\" : \"ANALOG_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
{ \"name\" : \"DIGITAL_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
{ \"name\" : \"DIGITAL_PROBE_2_TYPE\", \"type\" : \"U8\" }, \
{ \"name\" : \"DIGITAL_PROBE_3_TYPE\", \"type\" : \"U8\" }, \
{ \"name\" : \"DIGITAL_PROBE_4_TYPE\", \"type\" : \"U8\" }, \
{ \"name\" : \"WAVEFORM_SIZE\", \"type\" : \"SIZE_T\" }, \
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
]");
}
if( dataFormat == 1 ){
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
"[ \
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
{ \"name\" : \"ANALOG_PROBE_1\", \"type\" : \"I32\", \"dim\" : 1 }, \
{ \"name\" : \"ANALOG_PROBE_1_TYPE\", \"type\" : \"U8\" }, \
{ \"name\" : \"WAVEFORM_SIZE\", \"type\" : \"SIZE_T\" }, \
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
]");
}
if( dataFormat == 2 ){
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
"[ \
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
{ \"name\" : \"FINE_TIMESTAMP\", \"type\" : \"U16\" }, \
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" }, \
{ \"name\" : \"FLAGS_LOW_PRIORITY\", \"type\" : \"U16\"}, \
{ \"name\" : \"FLAGS_HIGH_PRIORITY\", \"type\" : \"U16\" }, \
{ \"name\" : \"TRIGGER_THR\", \"type\" : \"U16\" }, \
{ \"name\" : \"TIME_RESOLUTION\", \"type\" : \"U8\" }, \
{ \"name\" : \"BOARD_FAIL\", \"type\" : \"BOOL\" }, \
{ \"name\" : \"FLUSH\", \"type\" : \"BOOL\" }, \
{ \"name\" : \"AGGREGATE_COUNTER\", \"type\" : \"U32\" }, \
{ \"name\" : \"EVENT_SIZE\", \"type\" : \"SIZE_T\" } \
]");
}
if( dataFormat == 3 ){
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
"[ \
{ \"name\" : \"CHANNEL\", \"type\" : \"U8\" }, \
{ \"name\" : \"TIMESTAMP\", \"type\" : \"U64\" }, \
{ \"name\" : \"ENERGY\", \"type\" : \"U16\" } \
]");
}
if( dataFormat == 15 ){
ret = CAEN_FELib_SetReadDataFormat(ep_handle,
" [ \
{ \"name\": \"DATA\", \"type\": \"U8\", \"dim\": 1 }, \
{ \"name\": \"SIZE\", \"type\": \"SIZE_T\" }, \
{ \"name\": \"N_EVENTS\", \"type\": \"U32\" } \
]"
);
}
if (ret != CAEN_FELib_Success) {
ErrorMsg("Set Read Data Format");
return;
}
//TODO Statistic handle and endpoint
ret = CAEN_FELib_GetHandle(handle, "/endpoint/dpppha/stats", &stat_handle);
ret |= CAEN_FELib_SetReadDataFormat(stat_handle,
" [ \
{ \"name\": \"REAL_TIME_NS\", \"type\": \"U64\", \"dim\": 1 }, \
{ \"name\": \"DEAD_TIME_NS\", \"type\": \"U64\", \"dim\": 1 }, \
{ \"name\": \"LIVE_TIME_NS\", \"type\": \"U64\", \"dim\": 1 }, \
{ \"name\": \"TRIGGER_CNT\", \"type\": \"U32\", \"dim\": 1 }, \
{ \"name\": \"SAVED_EVENT_CNT\", \"type\": \"U32\", \"dim\": 1 } \
]"
);
if (ret != CAEN_FELib_Success) {
ErrorMsg("Set Statistics");
return;
}
}
int Digitizer2Gen::ReadStat(){
ret = CAEN_FELib_ReadData(stat_handle, 100,
realTime,
deadTime,
liveTime,
triggerCount,
savedEventCount
);
if (ret != CAEN_FELib_Success) ErrorMsg("Read Statistics");
return ret;
}
void Digitizer2Gen::PrintStat(){
printf("ch | Real Time[ns] | Dead Time[ns] | Live Time[ns] | Trigger | Saved | Rate[Hz] \n");
for( int i = 0; i < MaxNumberOfChannel; i++){
if( triggerCount[i] == 0 ) continue;
printf("%02d | %13lu | %13lu | %13lu | %7u | %7u | %.3f\n",
i, realTime[i], deadTime[i], liveTime[i], triggerCount[i], savedEventCount[i], triggerCount[i]*1e9*1.0/realTime[i]);
}
}
int Digitizer2Gen::ReadData(){
//printf("========= %s \n", __func__);
if( evt->dataType == 0){
ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel,
&evt->timestamp,
&evt->fine_timestamp,
&evt->energy,
evt->analog_probes[0],
evt->analog_probes[1],
evt->digital_probes[0],
evt->digital_probes[1],
evt->digital_probes[2],
evt->digital_probes[3],
&evt->analog_probes_type[0],
&evt->analog_probes_type[1],
&evt->digital_probes_type[0],
&evt->digital_probes_type[1],
&evt->digital_probes_type[2],
&evt->digital_probes_type[3],
&evt->traceLenght,
&evt->flags_low_priority,
&evt->flags_high_priority,
&evt->trigger_threashold,
&evt->downSampling,
&evt->board_fail,
&evt->flush,
&evt->aggCounter,
&evt->event_size
);
}else if( evt->dataType == 1){
ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel,
&evt->timestamp,
&evt->fine_timestamp,
&evt->energy,
evt->analog_probes[0],
&evt->analog_probes_type[0],
&evt->traceLenght,
&evt->flags_low_priority,
&evt->flags_high_priority,
&evt->trigger_threashold,
&evt->downSampling,
&evt->board_fail,
&evt->flush,
&evt->aggCounter,
&evt->event_size
);
}else if( evt->dataType == 2){
ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel,
&evt->timestamp,
&evt->fine_timestamp,
&evt->energy,
&evt->flags_low_priority,
&evt->flags_high_priority,
&evt->trigger_threashold,
&evt->downSampling,
&evt->board_fail,
&evt->flush,
&evt->aggCounter,
&evt->event_size
);
}else if( evt->dataType == 3){
ret = CAEN_FELib_ReadData(ep_handle, 100,
&evt->channel,
&evt->timestamp,
&evt->energy
);
}else if( evt->dataType == 15){
ret = CAEN_FELib_ReadData(ep_handle, 100, evt->data, &evt->dataSize, &evt->n_events );
//printf("data size: %lu byte\n", evt.dataSize);
}else{
return CAEN_FELib_UNKNOWN;
}
if( ret != CAEN_FELib_Success) {
//ErrorMsg("ReadData()");
return ret;
}
return ret;
}
//###########################################
void Digitizer2Gen::OpenOutFile(std::string fileName){
outFileNameBase = fileName;
sprintf(outFileName, "%s_%03d.sol", fileName.c_str(), outFileIndex);
outFile = fopen(outFileName, "a+");
fseek(outFile, 0L, SEEK_END);
outFileSize = ftell(outFile); // unsigned int = Max ~4GB
}
void Digitizer2Gen::CloseOutFile(){
fclose(outFile);
}
void Digitizer2Gen::SaveDataToFile(){
if( outFileSize > (unsigned int) MaxOutFileSize){
fclose(outFile);
outFileIndex ++;
sprintf(outFileName, "%s_%03d.sol", outFileNameBase.c_str(), outFileIndex);
outFile = fopen(outFileName, "a+");
}
if( evt->dataType == 0){
fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&evt->channel, 1, 1, outFile);
fwrite(&evt->energy, 2, 1, outFile);
fwrite(&evt->timestamp, 6, 1, outFile);
fwrite(&evt->fine_timestamp, 2, 1, outFile);
fwrite(&evt->flags_high_priority, 1, 1, outFile);
fwrite(&evt->flags_low_priority, 2, 1, outFile);
fwrite(&evt->downSampling, 1, 1, outFile);
fwrite(&evt->board_fail, 1, 1, outFile);
fwrite(&evt->flush, 1, 1, outFile);
fwrite(&evt->trigger_threashold, 2, 1, outFile);
fwrite(&evt->event_size, 8, 1, outFile);
fwrite(&evt->aggCounter, 4, 1, outFile);
fwrite(&evt->traceLenght, 8, 1, outFile);
fwrite(evt->analog_probes_type, 2, 1, outFile);
fwrite(evt->digital_probes_type, 4, 1, outFile);
fwrite(evt->analog_probes[0], evt->traceLenght*4, 1, outFile);
fwrite(evt->analog_probes[1], evt->traceLenght*4, 1, outFile);
fwrite(evt->digital_probes[0], evt->traceLenght, 1, outFile);
fwrite(evt->digital_probes[1], evt->traceLenght, 1, outFile);
fwrite(evt->digital_probes[2], evt->traceLenght, 1, outFile);
fwrite(evt->digital_probes[3], evt->traceLenght, 1, outFile);
}else if( evt->dataType == 1){
fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&evt->channel, 1, 1, outFile);
fwrite(&evt->energy, 2, 1, outFile);
fwrite(&evt->timestamp, 6, 1, outFile);
fwrite(&evt->fine_timestamp, 2, 1, outFile);
fwrite(&evt->flags_high_priority, 1, 1, outFile);
fwrite(&evt->flags_low_priority, 2, 1, outFile);
fwrite(&evt->traceLenght, 8, 1, outFile);
fwrite(&evt->analog_probes_type[0], 1, 1, outFile);
fwrite(evt->analog_probes[0], evt->traceLenght*4, 1, outFile);
}else if( evt->dataType == 2){
fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&evt->channel, 1, 1, outFile);
fwrite(&evt->energy, 2, 1, outFile);
fwrite(&evt->timestamp, 6, 1, outFile);
fwrite(&evt->fine_timestamp, 2, 1, outFile);
fwrite(&evt->flags_high_priority, 1, 1, outFile);
fwrite(&evt->flags_low_priority, 2, 1, outFile);
}else if( evt->dataType == 3){
fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&evt->channel, 1, 1, outFile);
fwrite(&evt->energy, 2, 1, outFile);
fwrite(&evt->timestamp, 6, 1, outFile);
}else if( evt->dataType == 15){
fwrite(&dataStartIndetifier, 2, 1, outFile);
fwrite(&evt->dataSize, 8, 1, outFile);
fwrite(evt->data, evt->dataSize, 1, outFile);
}
outFileSize = ftell(outFile); // unsigned int = Max ~4GB
}
//###########################################
void Digitizer2Gen::Reset(){ SendCommand("/cmd/Reset"); }
void Digitizer2Gen::ProgramPHA(bool testPulse){
if( !isConnected ) return ;
// Acquistion
WriteValue("/par/StartSource" , "SWcmd | SINedge");
WriteValue("/par/TrgOutMode", "Disabled");
WriteValue("/par/GPIOMode", "Disabled");
WriteValue("/par/SyncOutMode", "Disabled");
WriteValue("/par/RunDelay", "0"); // ns, that is for sync time with multi board
WriteValue("/par/IOlevel", "NIM");
WriteValue("/par/EnStatEvents", "true");
// Channel setting
if( testPulse){
WriteValue("/ch/0..63/par/ChEnable" , "false");
WriteValue("/ch/0/par/ChEnable" , "true");
WriteValue("/ch/1/par/ChEnable" , "true");
WriteValue("/ch/2/par/ChEnable" , "true");
WriteValue("/ch/3/par/ChEnable" , "true");
//WriteValue("/ch/0..63/par/ChEnable" , "true");
WriteValue("/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource");
WriteValue("/ch/0..63/par/WaveTriggerSource" , "GlobalTriggerSource"); // EventTriggerSource enought
WriteValue("/par/GlobalTriggerSource", "SwTrg | TestPulse");
WriteValue("/par/TestPulsePeriod" , "1000000"); // 1.0 msec = 1000Hz, tested, 1 trace recording
WriteValue("/par/TestPulseWidth" , "1000"); // nsec
WriteValue("/par/TestPulseLowLevel" , "0");
WriteValue("/par/TestPulseHighLevel" , "10000");
}else{
//======= this is for manual send trigger signal via software
//WriteValue("/ch/0..63/par/EventTriggerSource", "SwTrg");
//WriteValue("/ch/0..63/par/WaveTriggerSource" , "SwTrg");
//======== Self trigger for each channel
//WriteValue("/ch/0..63/par/EventTriggerSource", "ChSelfTrigger");
//WriteValue("/ch/0..63/par/WaveTriggerSource" , "ChSelfTrigger");
//======== One (or more) slef-trigger can trigger whole board, ??? depend on Channel Trigger mask
WriteValue("/ch/0..63/par/EventTriggerSource", "Ch64Trigger");
WriteValue("/ch/0..63/par/WaveTriggerSource" , "Ch64Trigger");
WriteValue("/ch/0..63/par/ChannelsTriggerMask", "0x0000FFFF000F000F");
//WriteValue("/ch/0/par/ChannelsTriggerMask", "0x000F");
//WriteValue("/ch/12/par/ChannelsTriggerMask", "0x000F");
//WriteValue("/ch/38/par/ChannelsTriggerMask", "0x000F"); // when channel has no input, it still record.
//WriteValue("/ch/0..63/par/CoincidenceMask", "Ch64Trigger");
//WriteValue("/ch/0..63/par/CoincidenceLength", "100"); //ns
//======== ACQ trigger?
//WriteValue("/ch/0..63/par/EventTriggerSource", "GlobalTriggerSource");
//WriteValue("/ch/0..63/par/WaveTriggerSource" , "GlobalTriggerSource");
//WriteValue("/par/GlobalTriggerSource", "SwTrg");
WriteValue("/ch/0..63/par/ChEnable" , "true");
//WriteValue("/ch/0..15/par/ChEnable" , "true");
}
WriteValue("/ch/0..63/par/DCOffset" , "10"); /// 10%
WriteValue("/ch/0..63/par/WaveSaving" , "Always");
WriteValue("/ch/0..63/par/ChRecordLengthS" , "512"); /// 4096 ns
WriteValue("/ch/0..63/par/ChPreTriggerS" , "125"); /// 1000 ns
WriteValue("/ch/0..63/par/WaveResolution" , "RES8"); /// 8 ns
WriteValue("/ch/0..63/par/WaveAnalogProbe0" , "ADCInput");
WriteValue("/ch/0..63/par/WaveAnalogProbe1" , "EnergyFilterMinusBaseline");
WriteValue("/ch/0..63/par/WaveDigitalProbe0" , "Trigger");
WriteValue("/ch/0..63/par/WaveDigitalProbe1" , "EnergyFilterPeaking");
WriteValue("/ch/0..63/par/WaveDigitalProbe2" , "TimeFilterArmed");
WriteValue("/ch/0..63/par/WaveDigitalProbe3" , "EnergyFilterPeakReady");
// Filter parameters
WriteValue("/ch/0..63/par/TimeFilterRiseTimeS" , "10"); // 80 ns
WriteValue("/ch/0..63/par/TriggerThr" , "1000");
WriteValue("/ch/0..63/par/PulsePolarity" , "Positive");
WriteValue("/ch/0..63/par/EnergyFilterBaselineAvg" , "Medium"); // 1024 sample
WriteValue("/ch/0..63/par/EnergyFilterFineGain" , "1.0");
WriteValue("/ch/0..63/par/EnergyFilterRiseTimeS" , "62"); // 496 ns
WriteValue("/ch/0..63/par/EnergyFilterFlatTopS" , "200"); // 1600 ns
WriteValue("/ch/0..63/par/EnergyFilterPoleZeroS" , "6250"); // 50 us
WriteValue("/ch/0..63/par/EnergyFilterPeakingPosition" , "20"); // 20 % = Flatup * 20% = 320 ns
WriteValue("/ch/0..63/par/TimeFilterRetriggerGuardS" , "10"); // 80 ns
WriteValue("/ch/0..63/par/EnergyFilterPileupGuardS" , "10"); // 80 ns
WriteValue("/ch/0..63/par/EnergyFilterBaselineGuardS" , "100"); // 800 ns
WriteValue("/ch/0..63/par/EnergyFilterLFLimitation" , "Off");
}
void Digitizer2Gen::ReadDigitizerSettings(){
ReadValue("/ch/4/par/ChRecordLengthS" , true);
ReadValue("/ch/4/par/ChPreTriggerS" , true);
ReadValue("/ch/4/par/WaveResolution" , true);
ReadValue("/ch/4/par/WaveAnalogProbe0" , true);
ReadValue("/ch/4/par/WaveAnalogProbe1" , true);
ReadValue("/ch/4/par/WaveDigitalProbe0", true);
ReadValue("/ch/4/par/WaveDigitalProbe1", true);
ReadValue("/ch/4/par/WaveDigitalProbe2", true);
ReadValue("/ch/4/par/WaveDigitalProbe3", true);
ReadValue("/ch/4/par/ChannelsTriggerMask", true);
ReadValue("/ch/0/par/ChannelsTriggerMask", true);
}
std::string Digitizer2Gen::ErrorMsg(const char * funcName){
printf("======== %s | %s\n",__func__, funcName);
char msg[1024];
int ec = CAEN_FELib_GetErrorDescription((CAEN_FELib_ErrorCode) ret, msg);
if (ec != CAEN_FELib_Success) {
std::string errMsg = __func__;
errMsg += " failed";
printf("%s failed\n", __func__);
return errMsg;
}
printf("Error msg (%d): %s\n", ret, msg);
return msg;
}

107
ClassDigitizer2Gen.h Normal file
View File

@ -0,0 +1,107 @@
#ifndef DIGITIZER_CLASS_H
#define DIGITIZER_CLASS_H
#include <CAEN_FELib.h>
#include <cstdlib>
#include <string>
#include "Event.h"
//#include "Parameter.h"
#define MaxOutFileSize 2*1024*1024*1024
#define MaxNumberOfChannel 64
class Digitizer2Gen {
private:
uint64_t handle;
uint64_t ep_handle; ///end point handle
uint64_t ep_folder_handle; ///end point folder handle
uint64_t stat_handle;
//uint64_t stat_folder_handle;
bool isConnected;
int ret;
char retValue[256];
std::string modelName;
std::string cupVersion;
std::string DPPVersion;
std::string DPPType;
unsigned short serialNumber;
unsigned short adcBits;
unsigned short nChannels;
unsigned short adcRate;
unsigned short ch2ns;
std::string IPAddress;
std::string netMask;
std::string gateway;
void Initialization();
uint64_t realTime[MaxNumberOfChannel];
uint64_t deadTime[MaxNumberOfChannel];
uint64_t liveTime[MaxNumberOfChannel];
uint32_t triggerCount[MaxNumberOfChannel];
uint32_t savedEventCount[MaxNumberOfChannel];
unsigned short outFileIndex;
unsigned short dataStartIndetifier;
std::string outFileNameBase;
char outFileName[100];
FILE * outFile;
unsigned int outFileSize;
bool acqON;
public:
Digitizer2Gen();
~Digitizer2Gen();
int OpenDigitizer(const char * url);
bool IsConnected() const {return isConnected;}
int CloseDigitizer();
std::string ReadValue(const char * parameter, bool verbose = false);
void WriteValue(const char * parameter, std::string value);
void SendCommand(const char * parameter);
uint64_t GetHandle(const char * parameter);
uint64_t GetParentHandle(uint64_t handle);
std::string GetPath(uint64_t handle);
std::string ErrorMsg(const char * funcName);
void StartACQ();
void StopACQ();
bool IsAcqOn() const {return acqON;}
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();
void PrintStat();
void Reset();
void ProgramPHA(bool testPulse = false);
void ReadDigitizerSettings();
unsigned short GetNChannels() const {return nChannels;}
unsigned short GetCh2ns() const {return ch2ns;}
uint64_t GetHandle() const {return handle;}
Event *evt; // should be evt[MaxNumber], when full or stopACQ, save into file
void OpenOutFile(std::string fileName);
void CloseOutFile();
void SaveDataToFile();
};
#endif

194
Event.h Normal file
View File

@ -0,0 +1,194 @@
#ifndef EVENT_H
#define EVENT_H
#include <stdio.h>
#include <cstdlib>
#include <stdint.h>
#define MaxTraceLenght 2048
class Event {
public:
unsigned short dataType;
///============= for dpp-pha
uint8_t channel; // 6 bit
uint16_t energy; // 16 bit
uint64_t timestamp; // 48 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
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
size_t event_size; // 64 bit
uint32_t aggCounter; // 32 bit
///============= for raw
uint8_t * data;
size_t dataSize; /// number of byte of the data, size/8 = word [64 bits]
uint32_t n_events;
Event(){
Init();
}
~Event(){
ClearMemory();
}
void Init(){
channel = 0;
energy = 0;
timestamp = 0;
fine_timestamp = 0;
downSampling = 0;
board_fail = false;
flush = false;
flags_low_priority = 0;
flags_high_priority = 0;
trigger_threashold = 0;
event_size = 0;
aggCounter = 0;
analog_probes[0] = NULL;
analog_probes[1] = NULL;
digital_probes[0] = NULL;
digital_probes[1] = NULL;
digital_probes[2] = NULL;
digital_probes[3] = NULL;
analog_probes_type[0] = 0xFF;
analog_probes_type[1] = 0xFF;
digital_probes_type[0] = 0xFF;
digital_probes_type[1] = 0xFF;
digital_probes_type[2] = 0xFF;
digital_probes_type[3] = 0xFF;
data = NULL;
}
void ClearMemory(){
if( data != NULL ) delete data;
if( analog_probes[0] != NULL) delete analog_probes[0];
if( analog_probes[1] != NULL) delete analog_probes[1];
if( digital_probes[0] != NULL) delete digital_probes[0];
if( digital_probes[1] != NULL) delete digital_probes[1];
if( digital_probes[2] != NULL) delete digital_probes[2];
if( digital_probes[3] != NULL) delete digital_probes[3];
}
void SetDataType(unsigned int type){
dataType = type;
ClearMemory();
if( dataType == 0xF){
data = new uint8_t[20*1024*1024];
}else{
analog_probes[0] = new int32_t[MaxTraceLenght];
analog_probes[1] = new int32_t[MaxTraceLenght];
digital_probes[0] = new uint8_t[MaxTraceLenght];
digital_probes[1] = new uint8_t[MaxTraceLenght];
digital_probes[2] = new uint8_t[MaxTraceLenght];
digital_probes[3] = new uint8_t[MaxTraceLenght];
}
}
void PrintEnergyTimeStamp(){
printf("ch: %2d, energy: %u, timestamp: %lu ch, traceLenght: %lu\n", channel, energy, timestamp, traceLenght);
}
std::string AnaProbeType(uint8_t probeType){
switch(probeType){
case 0: return "ADC";
case 1: return "Time filter";
case 2: return "Energy filter";
default : return "none";
}
}
std::string DigiProbeType(uint8_t probeType){
switch(probeType){
case 0: return "Trigger";
case 1: return "Time filter armed";
case 2: return "Re-trigger guard";
case 3: return "Energy filter baseline freeze";
case 4: return "Energy filter peaking";
case 5: return "Energy filter peaking ready";
case 6: return "Energy filter pile-up guard";
case 7: return "Event pile-up";
case 8: return "ADC saturation";
case 9: return "ADC saturation protection";
case 10: return "Post-saturation event";
case 11: return "Energy filter saturation";
case 12: return "Signal inhibit";
default : return "none";
}
}
std::string HighPriority(uint16_t prio){
std::string output;
bool pileup = prio & 0x1;
//bool pileupGuard = (prio >> 1) & 0x1;
//bool eventSaturated = (prio >> 2) & 0x1;
//bool postSatEvent = (prio >> 3) & 0x1;
//bool trapSatEvent = (prio >> 4) & 0x1;
//bool SCA_Event = (prio >> 5) & 0x1;
output = std::string("Pile-up: ") + (pileup ? "Yes" : "No");
return output;
}
//TODO LowPriority
void PrintAll(){
printf("============= Type : %u\n", dataType);
printf("ch : %2d (0x%02X), fail: %d, flush: %d\n", channel, channel, board_fail, flush);
printf("energy: %u, timestamp: %lu, fine_timestamp: %u \n", energy, timestamp, fine_timestamp);
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],
AnaProbeType(analog_probes_type[1]).c_str(), analog_probes_type[1]);
printf("DigProbe Type: %s(%u), %s(%u), %s(%u), %s(%u)\n", DigiProbeType(digital_probes_type[0]).c_str(), digital_probes_type[0],
DigiProbeType(digital_probes_type[1]).c_str(), digital_probes_type[1],
DigiProbeType(digital_probes_type[2]).c_str(), digital_probes_type[2],
DigiProbeType(digital_probes_type[3]).c_str(), digital_probes_type[3]);
}
void PrintTrace(unsigned short ID){
for(unsigned short i = 0; i < (unsigned short)traceLenght; i++){
if( ID == 0 ) printf("%4d| %6d\n", i, analog_probes[0][i]);
if( ID == 1 ) printf("%4d| %6d\n", i, analog_probes[1][i]);
if( ID == 2 ) printf("%4d| %u\n", i, digital_probes[0][i]);
if( ID == 3 ) printf("%4d| %u\n", i, digital_probes[1][i]);
if( ID == 4 ) printf("%4d| %u\n", i, digital_probes[2][i]);
if( ID == 5 ) printf("%4d| %u\n", i, digital_probes[3][i]);
}
}
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],
digital_probes[0][i],
digital_probes[1][i],
digital_probes[2][i],
digital_probes[3][i]);
}
}
};
#endif

0
README.md Normal file
View File

22
SOLARIS_Qt6_DAQ.pro Normal file
View File

@ -0,0 +1,22 @@
######################################################################
# Automatically generated by qmake (3.1) Wed Jan 25 13:51:50 2023
######################################################################
TEMPLATE = app
TARGET = SOLARIS_DAQ
INCLUDEPATH += .
QT += widgets
LIBS += -lcurl -lCAEN_FELib
# 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
# how to port your code away from it.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Input
HEADERS += ClassDigitizer2Gen.h Event.h influxdb.h mainwindow.h
SOURCES += ClassDigitizer2Gen.cpp influxdb.cpp main.cpp mainwindow.cpp

BIN
SOLARIS_favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

138
influxdb.cpp Normal file
View File

@ -0,0 +1,138 @@
#include "influxdb.h"
InfluxDB::InfluxDB(std::string url, bool verbose){
curl = curl_easy_init();
if( verbose) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
this->databaseIP = url;
respondCode = 0;
dataPoints = "";
}
InfluxDB::~InfluxDB(){
curl_easy_cleanup(curl);
}
void InfluxDB::SetURL(std::string url){
this->databaseIP = url;
}
std::string InfluxDB::ShowDatabases(){
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());
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){
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "write?db=" + databaseName).c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(dataPoints.length()));
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, dataPoints.c_str());
Execute();
}
void InfluxDB::Execute(){
respond = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &respondCode);
//printf("==== respond code %ld \n", respondCode);
if( respond != CURLE_OK) printf("############# fail\n");
}
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;
}

52
influxdb.h Normal file
View File

@ -0,0 +1,52 @@
#ifndef INFLUXDB_H
#define INFLUXDB_H
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <curl/curl.h>
class InfluxDB{
private:
CURL * curl;
CURLcode respond;
long respondCode;
std::string databaseIP;
std::string dataPoints;
std::vector<std::string> databaseList;
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();
void SetURL(std::string url);
/// Query
std::string ShowDatabases(); /// this save the list of database into databaseList
std::string Query(std::string databaseName, std::string query);
/// the ShowDatabases() function must be called before
std::vector<std::string> GetDatabaseList() {return databaseList;}
void CreateDatabase(std::string databaseName);
/// for single or batch write,
/// 1, addDataPoint first, you can add as many as you like
/// 2, writeData.
void AddDataPoint(std::string fullString);
void ClearDataPointsBuffer();
void PrintDataPoints();
void WriteData(std::string databaseName);
};
#endif

11
main.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

131
mainwindow.cpp Normal file
View File

@ -0,0 +1,131 @@
#include "mainwindow.h"
#include <QLabel>
#include <QGridLayout>
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
setWindowTitle("SOLARIS DAQ");
setGeometry(500, 500, 1000, 500);
QIcon icon("SOLARIS_favicon.png");
setWindowIcon(icon);
nDigi = 0;
QWidget * mainLayoutWidget = new QWidget(this);
setCentralWidget(mainLayoutWidget);
QVBoxLayout * layout1 = new QVBoxLayout();
mainLayoutWidget->setLayout(layout1);
{
QGridLayout *layout = new QGridLayout();
layout1->addLayout(layout);
layout1->addStretch();
layout1->setStretchFactor(layout, 8);
bnProgramSettings = new QPushButton("Program Settings", this);
bnOpenDigitizers = new QPushButton("Open Digitizers", this);
connect(bnOpenDigitizers, SIGNAL(clicked()), this, SLOT(bnOpenDigitizers_clicked()));
bnCloseDigitizers = new QPushButton("Close Digitizers", this);
bnCloseDigitizers->setEnabled(false);
connect(bnCloseDigitizers, SIGNAL(clicked()), this, SLOT(bnCloseDigitizers_clicked()));
bnDigiSettings = new QPushButton("Digitizers Settings", this);
bnDigiSettings->setEnabled(false);
bnStartACQ = new QPushButton("Start ACQ", this);
bnStartACQ->setEnabled(false);
bnStopACQ = new QPushButton("Stop ACQ", this);
bnStopACQ->setEnabled(false);
layout->addWidget(bnProgramSettings, 0, 0);
layout->addWidget(bnOpenDigitizers, 0, 1);
layout->addWidget(bnCloseDigitizers, 0, 2);
layout->addWidget(bnDigiSettings, 1, 1);
QFrame * separator = new QFrame();
separator->setFrameShape(QFrame::HLine);
layout->addWidget(separator, 2, 0, 1, 3);
layout->addWidget(bnStartACQ, 3, 0);
layout->addWidget(bnStopACQ, 3, 1);
}
logInfo = new QPlainTextEdit(this);
logInfo->isReadOnly();
logInfo->setGeometry(100, 200, 500, 100);
layout1->addWidget(logInfo);
layout1->setStretchFactor(logInfo, 1);
//StartRunThread = new QThread(this);
//connect(StartRunThread, &QThread::started, this, &MainWindow::onThreadStarted);
//connect(StartRunThread, &QThread::finished, this, &MainWindow::onThreadFinished);
LogMsg("Welcome to SOLARIS DAQ.");
}
MainWindow::~MainWindow(){
delete bnProgramSettings;
delete bnOpenDigitizers;
delete bnCloseDigitizers;
delete bnDigiSettings;
delete logInfo;
if( digi != NULL ){
digi->CloseDigitizer();
delete digi;
}
//StartRunThread->quit();
//StartRunThread->wait();
//delete StartRunThread;
}
void MainWindow::bnOpenDigitizers_clicked(){
LogMsg("Opening digitizer.....");
digi = new Digitizer2Gen();
digi->OpenDigitizer("dig2://192.168.0.100/");
if(digi->IsConnected()){
LogMsg("Open digitizer.");
bnCloseDigitizers->setEnabled(true);
bnOpenDigitizers->setEnabled(false);
}else{
LogMsg("Cannot open digitizer");
}
}
void MainWindow::bnCloseDigitizers_clicked(){
if( digi != NULL ){
digi->CloseDigitizer();
delete digi;
digi = NULL;
LogMsg("Closed Digitizer.");
bnOpenDigitizers->setEnabled(true);
}
}
void MainWindow::LogMsg(QString msg){
QString countStr = QStringLiteral("[%1] %2").arg(QDateTime::currentDateTime().toString("MM.dd hh:mm:ss"), msg);
logInfo->appendPlainText(countStr);
QScrollBar *v = logInfo->verticalScrollBar();
v->setValue(v->maximum());
qDebug() << msg;
logInfo->repaint();
}

56
mainwindow.h Normal file
View File

@ -0,0 +1,56 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
#include <QMainWindow>
#include <QTabWidget>
#include <QPlainTextEdit>
#include <QThread>
#include <qdebug.h>
#include <QDateTime>
#include <QScrollBar>
#include <QPushButton>
#include "ClassDigitizer2Gen.h"
static Digitizer2Gen * digi = NULL;
class MainWindow : public QMainWindow{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private slots:
//void onThreadStarted(){ qDebug() << "kkkkkkkkkkk"; }
//void onThreadFinished(){ qDebug() << "thread done"; }
void bnOpenDigitizers_clicked();
void bnCloseDigitizers_clicked();
signals :
private:
QPushButton * bnProgramSettings;
QPushButton * bnOpenDigitizers;
QPushButton * bnCloseDigitizers;
QPushButton * bnDigiSettings;
QPushButton * bnStartACQ;
QPushButton * bnStopACQ;
QPlainTextEdit * logInfo;
unsigned short nDigi;
//QThread * StartRunThread;
void LogMsg(QString msg);
};
#endif // MAINWINDOW_H