various bugs fix, add StartStopDialog for run comment, added channel on/off in TriggerSummary.
This commit is contained in:
parent
8742f7f284
commit
6cfb1f32eb
|
@ -31,9 +31,6 @@ class Data{
|
|||
unsigned long TotNumEvents[MaxNChannels];
|
||||
unsigned short NumEventsDecoded[MaxNChannels];
|
||||
|
||||
unsigned long long firstTimestamp[MaxNChannels];
|
||||
unsigned long long lastTimestamp[MaxNChannels];
|
||||
|
||||
/// stored Raw event
|
||||
bool IsNotRollOverFakeAgg;
|
||||
unsigned short NumEvents[MaxNChannels];
|
||||
|
@ -113,7 +110,7 @@ inline Data::Data(){
|
|||
|
||||
inline Data::~Data(){
|
||||
printf("----- %s \n", __func__);
|
||||
delete buffer;
|
||||
if( buffer != NULL ) delete buffer;
|
||||
}
|
||||
|
||||
inline void Data::AllocateMemory(uint32_t size){
|
||||
|
@ -140,8 +137,6 @@ inline void Data::ClearData(){
|
|||
IsNotRollOverFakeAgg = false;
|
||||
for( int i = 0 ; i < MaxNChannels; i++){
|
||||
NumEvents[i] = 0;
|
||||
firstTimestamp[0] = -1;
|
||||
lastTimestamp[0] = 0;
|
||||
for( int j = 0; j < MaxNData; j++){
|
||||
Timestamp[i][j] = 0;
|
||||
fineTime[i][j] = 0;
|
||||
|
@ -307,19 +302,15 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){
|
|||
nw++;
|
||||
///printf("nw : %d ,x 4 = %d, nByte : %d \n", nw, 4*nw, nByte);
|
||||
}while(4*nw < nByte);
|
||||
///}while(true);
|
||||
|
||||
///Calculate trigger rate and first and last Timestamp
|
||||
for(int ch = 0; ch < MaxNChannels; ch++){
|
||||
if( NumEventsDecoded[ch] > 0 ) IsNotRollOverFakeAgg = true;
|
||||
unsigned long long dTime = Timestamp[ch][NumEvents[ch]-1] - Timestamp[ch][NumEvents[ch] - NumEventsDecoded[ch]];
|
||||
double sec = dTime * ch2ns / 1e9;
|
||||
if( sec != 0 ){
|
||||
if( sec != 0 && NumEventsDecoded[ch] > 1 ){
|
||||
TriggerRate[ch] = NumEventsDecoded[ch]/sec;
|
||||
}
|
||||
|
||||
firstTimestamp[ch] = Timestamp[ch][0];
|
||||
lastTimestamp[ch] = Timestamp[ch][NumEvents[ch]-1];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "ClassDigitizer.h"
|
||||
|
||||
Digitizer::Digitizer(){
|
||||
printf("----- %s \n", __func__);
|
||||
Initalization();
|
||||
}
|
||||
|
||||
|
@ -11,10 +10,8 @@ Digitizer::Digitizer(int boardID, int portID, bool program, bool verbose){
|
|||
}
|
||||
|
||||
Digitizer::~Digitizer(){
|
||||
printf("----- %s \n", __func__);
|
||||
delete data;
|
||||
delete settingFile;
|
||||
CloseDigitizer();
|
||||
delete data;
|
||||
}
|
||||
|
||||
void Digitizer::Initalization(){
|
||||
|
@ -205,9 +202,15 @@ void Digitizer::SetChannelMask(uint32_t mask){
|
|||
channelMask = mask;
|
||||
ret |= CAEN_DGTZ_SetChannelEnableMask(handle, channelMask);
|
||||
SaveSettingToFile(Register::DPP::ChannelEnableMask, mask);
|
||||
SetSettingToMemory(Register::DPP::ChannelEnableMask, mask);
|
||||
ErrorMsg(__func__);
|
||||
}
|
||||
|
||||
void Digitizer::SetChannelOnOff(unsigned short ch, bool onOff){
|
||||
if( !isConnected ) return;
|
||||
channelMask = ((channelMask & ~( 1 << ch) ) | ( onOff << ch)) ;
|
||||
SetChannelMask(channelMask);
|
||||
}
|
||||
|
||||
int Digitizer::ProgramBoard(){
|
||||
|
||||
|
@ -269,8 +272,8 @@ int Digitizer::ProgramPHABoard(){
|
|||
ret = CAEN_DGTZ_Reset(handle);
|
||||
printf("======== program board PHA\n");
|
||||
|
||||
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 250);
|
||||
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x0F8115); /// has Extra2
|
||||
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 62);
|
||||
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x0F8915); /// has Extra2
|
||||
///ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x0D8115); /// diable Extra2
|
||||
|
||||
//TODO change to write register
|
||||
|
@ -290,7 +293,7 @@ int Digitizer::ProgramPHABoard(){
|
|||
uint32_t address;
|
||||
|
||||
address = Register::DPP::PHA::DecayTime; ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 5000 );
|
||||
address = Register::DPP::PHA::TrapezoidFlatTop; ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 0x62 );
|
||||
address = Register::DPP::PHA::TrapezoidFlatTop; ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 0x1A );
|
||||
address = Register::DPP::PHA::TrapezoidRiseTime; ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 6 );
|
||||
address = Register::DPP::PHA::PeakingTime; ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 6 );
|
||||
address = Register::DPP::PHA::RCCR2SmoothingFactor; ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 4 );
|
||||
|
@ -302,13 +305,13 @@ int Digitizer::ProgramPHABoard(){
|
|||
|
||||
|
||||
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(Register::DPP::ChannelDCOffset) + 0x7000 , 0xEEEE );
|
||||
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(Register::DPP::PreTrigger) + 0x7000 , 124 );
|
||||
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(Register::DPP::PreTrigger) + 0x7000 , 32 );
|
||||
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(Register::DPP::InputDynamicRange) + 0x7000 , 0x0 );
|
||||
|
||||
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::NumberEventsPerAggregate_G) + 0x7000, 511);
|
||||
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::AggregateOrganization), 0);
|
||||
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::MaxAggregatePerBlockTransfer), 4);
|
||||
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::DPPAlgorithmControl) + 0x7000, 0xe30200f);
|
||||
ret |= CAEN_DGTZ_WriteRegister(handle, (int32_t)(Register::DPP::DPPAlgorithmControl) + 0x7000, 0xC30200f);
|
||||
|
||||
if( ret != 0 ) { printf("==== set channels error.\n"); return 0;}
|
||||
|
||||
|
@ -537,6 +540,9 @@ void Digitizer::ReadAllSettingsFromBoard(){
|
|||
if( RegisterDPPList[p].GetType() == RW::WriteONLY) continue;
|
||||
ReadRegister(RegisterDPPList[p]);
|
||||
}
|
||||
|
||||
channelMask = GetSettingFromMemory(Register::DPP::ChannelEnableMask);
|
||||
|
||||
/// Channels Setting
|
||||
for( int ch = 0; ch < NChannel; ch ++){
|
||||
if( DPPType == V1730_DPP_PHA_CODE ){
|
||||
|
|
|
@ -66,6 +66,7 @@ class Digitizer{
|
|||
int OpenDigitizer(int boardID, int portID = 0, bool program = false, bool verbose = false);
|
||||
void SetDPPType (int type) { this->DPPType = type;} /// for manual override, or, digitizer does not open
|
||||
void SetChannelMask (uint32_t mask);
|
||||
void SetChannelOnOff (unsigned short ch, bool onOff);
|
||||
int CloseDigitizer();
|
||||
void Initalization();
|
||||
void Reset();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "macro.h"
|
||||
#include "ClassData.h"
|
||||
|
||||
#include "TROOT.h"
|
||||
|
@ -21,22 +22,6 @@ unsigned short e[MAX_MULTI] = {0}; /// 15 bit
|
|||
unsigned long long e_t[MAX_MULTI] = {0}; /// timestamp 47 bit
|
||||
unsigned short e_f[MAX_MULTI] = {0}; /// fine time 10 bit
|
||||
|
||||
|
||||
class Trace{
|
||||
public:
|
||||
Trace() {trace.clear(); }
|
||||
~Trace();
|
||||
void Clear() { trace.clear(); };
|
||||
Trace operator = (std::vector<unsigned short> v){
|
||||
Trace tt;
|
||||
for( int i = 0 ; i < (int) v.size() ; i++){
|
||||
trace.push_back(v[i]);
|
||||
}
|
||||
return tt;
|
||||
}
|
||||
std::vector<unsigned short> trace;
|
||||
};
|
||||
|
||||
/// using TClonesArray to hold the trace in TGraph
|
||||
TClonesArray * arrayTrace = NULL;
|
||||
unsigned short traceLength[MAX_MULTI] = {0};
|
||||
|
@ -45,7 +30,6 @@ TGraph * trace = NULL;
|
|||
template<typename T> void swap(T * a, T *b );
|
||||
int partition(int arr[], int kaka[], TString file[], int start, int end);
|
||||
void quickSort(int arr[], int kaka[], TString file[], int start, int end);
|
||||
unsigned long get_time();
|
||||
void EventBuilder(Data * data, const unsigned int timeWin, bool traceOn = false, bool isLastData = false, unsigned int verbose = 0);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
@ -389,16 +373,6 @@ void EventBuilder(Data * data, const unsigned int timeWin, bool traceOn, bool is
|
|||
|
||||
}
|
||||
|
||||
unsigned long get_time(){
|
||||
unsigned long time_us;
|
||||
struct timeval t1;
|
||||
struct timezone tz;
|
||||
gettimeofday(&t1, &tz);
|
||||
time_us = (t1.tv_sec) * 1000000 + t1.tv_usec;
|
||||
return time_us;
|
||||
}
|
||||
|
||||
|
||||
template<typename T> void swap(T * a, T *b ){
|
||||
T temp = * b;
|
||||
*b = *a;
|
||||
|
|
133
DAQ/FSUDAQ.cpp
133
DAQ/FSUDAQ.cpp
|
@ -14,20 +14,12 @@
|
|||
#include <TAxis.h>
|
||||
#include <TGFileDialog.h>
|
||||
#include <TF1.h>
|
||||
#include <TGMsgBox.h>
|
||||
#include <unistd.h>
|
||||
#include <ctime>
|
||||
|
||||
#include "FSUDAQ.h"
|
||||
|
||||
long get_time(){
|
||||
long time_ms;
|
||||
struct timeval t1;
|
||||
struct timezone tz;
|
||||
gettimeofday(&t1, &tz);
|
||||
time_ms = (t1.tv_sec) * 1000 + t1.tv_usec / 1000;
|
||||
return time_ms;
|
||||
}
|
||||
|
||||
Double_t traceFunc(Double_t *x, Double_t *par){
|
||||
///par[0] = baseline
|
||||
///par[1] = start time
|
||||
|
@ -54,13 +46,13 @@ TGraph * gDigiTrace2 = NULL ;
|
|||
|
||||
Pixel_t red, blue, green;
|
||||
|
||||
unsigned short nDigi;
|
||||
unsigned short nDigi = 0;
|
||||
Digitizer ** digi = NULL;
|
||||
|
||||
unsigned short lastRunID;
|
||||
|
||||
///============ static members
|
||||
TGTextEdit * MainWindow::teLog = NULL;
|
||||
TGTextView * MainWindow::teLog = NULL;
|
||||
TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL;
|
||||
TGNumberEntry * MainWindow::boardIDEntry = NULL;
|
||||
TGNumberEntry * MainWindow::chIDEntry = NULL;
|
||||
|
@ -96,10 +88,6 @@ enum ModeIdentifiers{
|
|||
|
||||
MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
||||
|
||||
printf("----- %s \n", __func__);
|
||||
|
||||
nDigi = 0;
|
||||
|
||||
gClient->GetColorByName("red", red);
|
||||
gClient->GetColorByName("blue", blue);
|
||||
gClient->GetColorByName("green", green);
|
||||
|
@ -234,7 +222,8 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
|||
TGGroupFrame * groupLog = new TGGroupFrame(fMain, "Log Message", kHorizontalFrame);
|
||||
fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsExpandX, 10,10,10,10) );
|
||||
|
||||
teLog = new TGTextEdit(groupLog, w, 100); groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsExpandX, 2,2,10,0) );
|
||||
teLog = new TGTextView(groupLog, w, 100); groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsExpandX, 2,2,10,0) );
|
||||
teLog->SetReadOnly(true);
|
||||
}
|
||||
|
||||
/// Set a name to the main frame
|
||||
|
@ -297,17 +286,18 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
|||
|
||||
void MainWindow::GoodBye(){
|
||||
|
||||
for( int i = 0; i < nDigi; i++) digi[i]->CloseDigitizer();
|
||||
|
||||
printf("/// Closing Digitizer and Releasing digitizer memory\n");
|
||||
for( int i = 0; i < nDigi; i++) delete digi[i];
|
||||
|
||||
printf("/// Releasing histograms memory\n");
|
||||
for( int i = 0; i < MaxNBoards; i++){
|
||||
delete hChannel[i];
|
||||
if( hChannel[i] != NULL ) delete hChannel[i];
|
||||
for( int j = 0; j < MaxNChannels; j++){
|
||||
delete hEnergy[i][j];
|
||||
if( hEnergy[i][j] != NULL ) delete hEnergy[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
printf("/// Releasing graphs memory\n");
|
||||
delete gDummy;
|
||||
delete gAnaTrace1 ;
|
||||
delete gAnaTrace2 ;
|
||||
|
@ -353,6 +343,8 @@ MainWindow::~MainWindow() {
|
|||
delete registerSetting;
|
||||
delete triggerSummary;
|
||||
delete programSetting;
|
||||
delete startStopDialog;
|
||||
|
||||
delete runThread;
|
||||
|
||||
fMain->Cleanup();
|
||||
|
@ -369,7 +361,6 @@ void MainWindow::HandleMenu(Int_t id){
|
|||
///========================= File Open
|
||||
case M_FILE_OPEN:{
|
||||
LogMsg((char *) "Not implemented.");
|
||||
|
||||
}break;
|
||||
|
||||
///========================= Exit
|
||||
|
@ -378,8 +369,10 @@ void MainWindow::HandleMenu(Int_t id){
|
|||
///========================= Trigger summary
|
||||
case M_TRIGGER_SUMMARY: {
|
||||
triggerSummary = new TriggerSummary(gClient->GetRoot(), 600, 600);
|
||||
TriggerSummary::isManualOpened = true;
|
||||
}break;
|
||||
|
||||
///========================= Load setting file offline
|
||||
case M_LOAD_SETTINGS:{
|
||||
LoadSettingFromFile();
|
||||
}break;
|
||||
|
@ -415,19 +408,13 @@ void MainWindow::HandleMenu(Int_t id){
|
|||
case M_PROGRAM_SETTINGS:{
|
||||
programSetting = new ProgramSetting(gClient->GetRoot());
|
||||
programSetting->Connect("SetSetting()", "MainWindow", this, "UpdateExpName()");
|
||||
///LogMsg((char*) Form("database : %s, name : %s ", ProgramSetting::databaseIP.c_str(), ProgramSetting::databaseName.c_str() ));
|
||||
|
||||
}break;
|
||||
|
||||
///====================== Fit Gaussian
|
||||
case M_FINDPEAKS:{
|
||||
|
||||
LogMsg((char*)"[Find Gaussian Peaks] Not impelmented");
|
||||
|
||||
}break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::OpenDigitizers(){
|
||||
|
@ -444,9 +431,10 @@ void MainWindow::OpenDigitizers(){
|
|||
nDigi = 0;
|
||||
|
||||
Digitizer * dig = new Digitizer();
|
||||
LogMsg((char*)"Finding Digitizer for 4 ports and 3 boards for each port...");
|
||||
for( int port = 0; port < 4 ; port ++){
|
||||
for( int board = 0; board < 3 ; board ++){
|
||||
TString haha = Form("Finding Digitizer for %d ports and %d boards for each port...", ProgramSetting::maxPort, ProgramSetting::maxBoardPrePort );
|
||||
LogMsg((char*) haha.Data());
|
||||
for( int port = 0; port < ProgramSetting::maxPort ; port ++){
|
||||
for( int board = 0; board < ProgramSetting::maxBoardPrePort ; board ++){
|
||||
dig->OpenDigitizer(board, port);
|
||||
if ( dig->GetConnectionStatus() ) {
|
||||
nDigi++;
|
||||
|
@ -557,12 +545,9 @@ void MainWindow::UpdateExpName(){
|
|||
}
|
||||
|
||||
void MainWindow::MakeElogEntry(bool start){
|
||||
|
||||
if( ProgramSetting::EnableElog == false ) return;
|
||||
|
||||
TString cmd = Form("%s/DAQ/elogEntry.sh %d", ProgramSetting::programPath.c_str(), start);
|
||||
int temp = system(cmd.Data());
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::StartRun(){
|
||||
|
@ -584,11 +569,18 @@ void MainWindow::StartRun(){
|
|||
bFitTrace->SetEnabled(false);
|
||||
|
||||
if( cbDataRun->GetState() == kButtonDown ) {
|
||||
cbMode->SetEnabled(false);
|
||||
MakeElogEntry(true);
|
||||
startStopDialog = new StartStopDialog(gClient->GetRoot(), fMain, 400, 200, true);
|
||||
}
|
||||
|
||||
HandleMenu(M_TRIGGER_SUMMARY);
|
||||
if( StartStopDialog::isOK){
|
||||
|
||||
cbMode->SetEnabled(false);
|
||||
MakeElogEntry(true);
|
||||
|
||||
if( !TriggerSummary::isOpened ) {
|
||||
triggerSummary = new TriggerSummary(gClient->GetRoot(), 600, 600);
|
||||
TriggerSummary::isManualOpened = false;
|
||||
}
|
||||
|
||||
bool threadFlag = false;
|
||||
for( int i = 0 ; i < nDigi; i++) {
|
||||
|
@ -598,8 +590,15 @@ void MainWindow::StartRun(){
|
|||
|
||||
if( threadFlag ) runThread->Run();
|
||||
|
||||
if( boardSetting != NULL ) boardSetting->ReadStatus();
|
||||
|
||||
}else{
|
||||
bStartRun->SetEnabled(true);
|
||||
bStopRun->SetEnabled(false);
|
||||
dataPrefix->SetEnabled(true);
|
||||
runIDEntry->SetState(true);
|
||||
bPlotSingleTrace->SetEnabled(true);
|
||||
bFitTrace->SetEnabled(true);
|
||||
cbMode->SetEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::StopRun(){
|
||||
|
@ -621,15 +620,26 @@ void MainWindow::StopRun(){
|
|||
bFitTrace->SetEnabled(true);
|
||||
cbMode->SetEnabled(true);
|
||||
|
||||
if( triggerSummary != NULL ) triggerSummary->CloseWindow();
|
||||
if( !TriggerSummary::isManualOpened ) triggerSummary->CloseWindow();
|
||||
|
||||
///if( cbMode->GetSelected() == Mode_DataRun ){
|
||||
if( cbDataRun->GetState() == kButtonDown ) {
|
||||
startStopDialog = new StartStopDialog(gClient->GetRoot(), fMain, 400, 200, false);
|
||||
|
||||
if( StartStopDialog::isOK){
|
||||
int runID = runIDEntry->GetNumber();
|
||||
lastRunID = runID + 1;
|
||||
runIDEntry->SetNumber(runID +1);
|
||||
MakeElogEntry(false);
|
||||
ProgramSetting::SaveProgramSetting();
|
||||
}else{
|
||||
bStartRun->SetEnabled(false);
|
||||
bStopRun->SetEnabled(true);
|
||||
dataPrefix->SetEnabled(false);
|
||||
runIDEntry->SetState(false);
|
||||
bPlotSingleTrace->SetEnabled(false);
|
||||
bFitTrace->SetEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -671,8 +681,9 @@ void MainWindow::LogMsg(char * msg){
|
|||
|
||||
TString outMsg = Form("[%4d-%02d-%02d %02d:%02d:%02d] %s", year, month, day, hour, minute, secound, msg);
|
||||
|
||||
teLog->AddLine(outMsg);
|
||||
teLog->AddLineFast(outMsg);
|
||||
printf("%s\n", outMsg.Data());
|
||||
teLog->Update();
|
||||
teLog->ShowBottom();
|
||||
|
||||
}
|
||||
|
@ -724,6 +735,8 @@ void MainWindow::PlotSingleTrace(){
|
|||
digi[boardID]->StartACQ();
|
||||
|
||||
int count = 0;
|
||||
int traceLength;
|
||||
|
||||
while(count < 10){
|
||||
usleep(100*1000); /// wait half sec
|
||||
digi[boardID]->ReadData();
|
||||
|
@ -732,7 +745,7 @@ void MainWindow::PlotSingleTrace(){
|
|||
data->DecodeBuffer(false, 2);
|
||||
data->PrintStat();
|
||||
|
||||
int traceLength = (data->Waveform1[chID][0]).size();
|
||||
traceLength = (data->Waveform1[chID][0]).size();
|
||||
|
||||
if( traceLength == 0 ) {
|
||||
LogMsg((char *)"no trace");
|
||||
|
@ -741,7 +754,6 @@ void MainWindow::PlotSingleTrace(){
|
|||
|
||||
for( int i = 0; i < traceLength ; i++) {
|
||||
gAnaTrace1->SetPoint(i, i*ch2ns*(1+isDualTrace), (data->Waveform1[chID][0])[i]);
|
||||
|
||||
}
|
||||
|
||||
double xmin, xmax, ymin, ymax;
|
||||
|
@ -766,11 +778,8 @@ void MainWindow::PlotSingleTrace(){
|
|||
break;
|
||||
|
||||
bFitTrace->SetEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
count++;
|
||||
|
||||
};
|
||||
digi[0]->StopACQ();
|
||||
if( count == 10 ) LogMsg((char*)"Plot Trace TimeOut, please check setting");
|
||||
|
@ -845,6 +854,8 @@ void * MainWindow::Run(void * ptr){
|
|||
uint32_t PreviousTime = get_time();
|
||||
uint32_t CurrentTime = 0;
|
||||
uint32_t ElapsedTime = 0;
|
||||
uint32_t t1 = get_time();
|
||||
uint32_t t2 = 0;
|
||||
|
||||
TString dataFileName = ProgramSetting::DataSavingPath + "/data/" + dataPrefix->GetText();
|
||||
dataFileName += Form("_run%03d", (int) runIDEntry->GetNumber());
|
||||
|
@ -853,7 +864,8 @@ void * MainWindow::Run(void * ptr){
|
|||
|
||||
if( cbDataRun->GetState() == kButtonDown) {
|
||||
TString msg = Form("Save data to : %s_***.bin\n", dataFileName.Data());
|
||||
teLog->AddLine(msg.Data());
|
||||
teLog->AddLineFast(msg.Data());
|
||||
teLog->Update();
|
||||
teLog->ShowBottom();
|
||||
}
|
||||
|
||||
|
@ -865,34 +877,47 @@ void * MainWindow::Run(void * ptr){
|
|||
|
||||
DrawDummyGraph();
|
||||
|
||||
unsigned int printFileSizeCount = 0;
|
||||
unsigned int nLine;
|
||||
|
||||
while(digi[boardID]->IsRunning()){
|
||||
|
||||
usleep(100*1000); /// wait 100 msec
|
||||
digi[boardID]->ReadData();
|
||||
if( boardSetting != NULL ) boardSetting->ReadStatus();
|
||||
|
||||
ch2ns = (int) digi[boardID]->GetCh2ns();
|
||||
ch = chIDEntry->GetNumber();
|
||||
|
||||
if( data->nByte > 0 ){
|
||||
//data->PrintStat();
|
||||
|
||||
if( cbDataRun->GetState() == kButtonDown ) {
|
||||
// Rate graph?
|
||||
data->SaveBuffer(dataFileName.Data());
|
||||
data->DecodeBuffer(true, 0);
|
||||
|
||||
CurrentTime = get_time();
|
||||
if( CurrentTime - PreviousTime > 1000 ){
|
||||
if( CurrentTime - PreviousTime > 1e6 ){
|
||||
if( printFileSizeCount > 0 ){
|
||||
nLine = teLog->ReturnLineCount();
|
||||
teLog->GetText()->DelLine(nLine-1);
|
||||
}
|
||||
std::string msg = Form("File Size : %.2f MB", data->GetPresentFileSize() / 1024./1024. );
|
||||
teLog->AddLine(msg.c_str());
|
||||
teLog->AddLineFast(msg.c_str());
|
||||
teLog->Update();
|
||||
teLog->ShowBottom();
|
||||
PreviousTime = CurrentTime;
|
||||
|
||||
printFileSizeCount ++;
|
||||
}
|
||||
|
||||
}else{
|
||||
data->DecodeBuffer(false, 0);
|
||||
}
|
||||
|
||||
//t2 = get_time();
|
||||
//printf("========= dt : %u usec\n", t2 - t1);
|
||||
////data->PrintStat();
|
||||
//t1 = t2 ;
|
||||
|
||||
}
|
||||
|
||||
if( cbDataRun->GetState() == kButtonUp ) {
|
||||
|
@ -915,7 +940,6 @@ void * MainWindow::Run(void * ptr){
|
|||
}
|
||||
|
||||
/// since the gDummy fixed the draw range, it does not really matter to remove extra points
|
||||
|
||||
gAnaTrace1->Draw("same L");
|
||||
gAnaTrace2->Draw("same L");
|
||||
}
|
||||
|
@ -924,8 +948,9 @@ void * MainWindow::Run(void * ptr){
|
|||
CurrentTime = get_time();
|
||||
ElapsedTime = CurrentTime - PreviousTime; /// milliseconds
|
||||
|
||||
if( ElapsedTime > 1000 * 1000 && BoardSetting::isOpened ) boardSetting->ReadStatus();
|
||||
|
||||
if( ElapsedTime > 200 ){
|
||||
if( ElapsedTime > 200 * 1000 ){
|
||||
|
||||
///Fill Channel Count
|
||||
for( int i = 0 ; i < digi[boardID]->GetNChannel(); i++){
|
||||
|
@ -963,7 +988,5 @@ int main(int argc, char **argv) {
|
|||
new MainWindow(gClient->GetRoot(),800,800);
|
||||
theApp.Run();
|
||||
|
||||
printf("------ see you next time :) ------ \n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "channelSettingPSD.h"
|
||||
#include "registerSetting.h"
|
||||
#include "triggerSummary.h"
|
||||
#include "startStopDialog.h"
|
||||
|
||||
class TGWindow;
|
||||
class TGMainFrame;
|
||||
|
@ -40,7 +41,7 @@ private:
|
|||
|
||||
static TGNumberEntry * boardIDEntry, *chIDEntry;
|
||||
|
||||
static TGTextEdit * teLog;
|
||||
static TGTextView * teLog;
|
||||
|
||||
TGTextButton *bOpenDigitizers;
|
||||
TGTextButton *bStartRun;
|
||||
|
@ -63,6 +64,7 @@ private:
|
|||
RegisterSetting * registerSetting;
|
||||
TriggerSummary * triggerSummary;
|
||||
ProgramSetting * programSetting;
|
||||
StartStopDialog * startStopDialog;
|
||||
|
||||
TThread * runThread;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ CAENLIBS = -lCAENDigitizer
|
|||
|
||||
ROOTLIBS = `root-config --cflags --glibs`
|
||||
|
||||
OBJS = programSetting.o triggerSummary.o registerSetting.o channelSettingPSD.o channelSettingPHA.o boardSetting.o ClassDigitizer.o FSUDAQ.o
|
||||
OBJS = startStopDialog.o programSetting.o triggerSummary.o registerSetting.o channelSettingPSD.o channelSettingPHA.o boardSetting.o ClassDigitizer.o FSUDAQ.o
|
||||
|
||||
#########################################################################
|
||||
|
||||
|
@ -72,6 +72,9 @@ programSetting.o : programSetting.h programSetting.cpp
|
|||
@echo "----------- creating programSetting.o"
|
||||
$(CC) $(COPTS) -c programSetting.cpp $(ROOTLIBS)
|
||||
|
||||
startStopDialog.o: startStopDialog.h startStopDialog.cpp
|
||||
@echo "----------- creating startStopDialog.o"
|
||||
$(CC) $(COPTS) -c startStopDialog.cpp $(ROOTLIBS)
|
||||
|
||||
#CutsCreator: $(OBJS3) src/CutsCreator.c
|
||||
# g++ -std=c++17 -pthread src/CutsCreator.c -o CutsCreator $(ROOTLIBS)
|
||||
|
|
|
@ -21,13 +21,14 @@ TString boardSettingName[NUM_BOARD_INFO] = { "Model",
|
|||
"AMC version"
|
||||
};
|
||||
|
||||
bool BoardSetting::isOpened = false;
|
||||
|
||||
///======== declared at FSUDAQ.cpp
|
||||
extern Pixel_t red, blue, green;
|
||||
extern unsigned short nDigi;
|
||||
extern Digitizer ** digi;
|
||||
|
||||
BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h){
|
||||
printf("----- %s \n", __func__);
|
||||
|
||||
fMain = new TGMainFrame(p,w,h);
|
||||
fMain->SetWindowName("Board Settings & Status");
|
||||
|
@ -266,7 +267,6 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h){
|
|||
bDualTrace->SetState(kButtonUp);
|
||||
bDualTrace->Connect("Clicked()", "BoardSetting", this, "SetBoardConfiguration()");
|
||||
|
||||
|
||||
TGHorizontalFrame * hBdCfg_Probe = new TGHorizontalFrame(vBdCfg2); vBdCfg2->AddFrame(hBdCfg_Probe);
|
||||
|
||||
TGVerticalFrame * vBdCfg_Probe_Label = new TGVerticalFrame(hBdCfg_Probe); hBdCfg_Probe->AddFrame(vBdCfg_Probe_Label);
|
||||
|
@ -787,6 +787,14 @@ BoardSetting::~BoardSetting(){
|
|||
delete GlbMajorLevel;
|
||||
|
||||
delete boardIDEntry;
|
||||
for( int i = 0; i < NUM_BOARD_INFO; i++ ) delete entry[i];
|
||||
delete txtSettingFile;
|
||||
|
||||
delete enPLLStatus;
|
||||
delete enTempStatus;
|
||||
delete enADCPwrStatus;
|
||||
|
||||
delete txtBufferSize;
|
||||
|
||||
fMain->Cleanup();
|
||||
delete fMain;
|
||||
|
|
|
@ -122,14 +122,12 @@ class BoardSetting{
|
|||
TGTextEntry * txtBusError;
|
||||
TGTextEntry * txtVMEFIFO;
|
||||
|
||||
bool isOpened;
|
||||
|
||||
|
||||
public:
|
||||
BoardSetting(const TGWindow *p, UInt_t w, UInt_t h);
|
||||
virtual ~BoardSetting();
|
||||
|
||||
bool IsOpen() {return isOpened;}
|
||||
static bool isOpened;
|
||||
|
||||
void CloseWindow() { delete this;}
|
||||
void ChangeBoard();
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@ extern Digitizer ** digi;
|
|||
|
||||
ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, int boardID){
|
||||
|
||||
printf("----- %s \n", __func__);
|
||||
|
||||
fMain = new TGMainFrame(p,w,h);
|
||||
fMain->SetWindowName("Channel Settings PHA");
|
||||
fMain->Connect("CloseWindow()", "ChannelSettingPHA", this, "CloseWindow()");
|
||||
|
|
|
@ -16,8 +16,6 @@ extern Digitizer ** digi;
|
|||
|
||||
ChannelSettingPSD::ChannelSettingPSD(const TGWindow *p, UInt_t w, UInt_t h, int boardID){
|
||||
|
||||
printf("----- %s \n", __func__);
|
||||
|
||||
fMain = new TGMainFrame(p,w,h);
|
||||
fMain->SetWindowName("Channel Settings PSD");
|
||||
fMain->Connect("CloseWindow()", "ChannelSettingPSD", this, "CloseWindow()");
|
||||
|
|
12
DAQ/macro.h
12
DAQ/macro.h
|
@ -1,6 +1,7 @@
|
|||
#ifndef MACRO_H
|
||||
#define MACRO_H
|
||||
|
||||
#define MaxNPorts 4
|
||||
#define MaxNBoards 22
|
||||
#define MaxNChannels 16
|
||||
#define MaxRecordLength 0x3fff * 8
|
||||
|
@ -8,4 +9,15 @@
|
|||
|
||||
#define SETTINGSIZE 2048
|
||||
|
||||
#include <sys/time.h> /** struct timeval, select() */
|
||||
|
||||
inline unsigned int get_time(){
|
||||
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;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,6 +26,9 @@ std::string ProgramSetting::ElogIP = "128.186.111.127";
|
|||
bool ProgramSetting::EnableElog = true;
|
||||
bool ProgramSetting::EnableDatabase = true;
|
||||
|
||||
unsigned short ProgramSetting::maxPort = 4;
|
||||
unsigned short ProgramSetting::maxBoardPrePort = 3;
|
||||
|
||||
/// fixed program things
|
||||
const std::string ProgramSetting::settingFileName = "FSUDAQ.sh";
|
||||
const std::string ProgramSetting::programPath = "~/FSUDAQ/";
|
||||
|
@ -37,8 +40,6 @@ extern Digitizer ** digi;
|
|||
|
||||
ProgramSetting::ProgramSetting(const TGWindow *p){
|
||||
|
||||
printf("----- %s \n", __func__);
|
||||
|
||||
fMain = new TGMainFrame(p, 600, 400);
|
||||
fMain->SetWindowName("Program Setting");
|
||||
fMain->Connect("CloseWindow()", "ProgramSetting", this, "CloseWindow()");
|
||||
|
@ -49,7 +50,7 @@ ProgramSetting::ProgramSetting(const TGWindow *p){
|
|||
TGVerticalFrame * vframe = new TGVerticalFrame(fMain); fMain->AddFrame(vframe);
|
||||
|
||||
{///============== Data Saving Path
|
||||
TGGroupFrame * gfData = new TGGroupFrame(vframe, "Data Storage", kHorizontalFrame); vframe->AddFrame(gfData, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
|
||||
TGGroupFrame * gfData = new TGGroupFrame(vframe, "Data Storage", kVerticalFrame); vframe->AddFrame(gfData, new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
|
||||
|
||||
TGHorizontalFrame * hfData = new TGHorizontalFrame(gfData); gfData->AddFrame(hfData, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
|
||||
|
||||
|
@ -77,7 +78,7 @@ ProgramSetting::ProgramSetting(const TGWindow *p){
|
|||
}
|
||||
|
||||
{///============== Database & Elog
|
||||
TGGroupFrame * gfDatabase = new TGGroupFrame(vframe, "Database & Elog Setting", kHorizontalFrame); vframe->AddFrame(gfDatabase, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
|
||||
TGGroupFrame * gfDatabase = new TGGroupFrame(vframe, "Database & Elog Setting", kVerticalFrame); vframe->AddFrame(gfDatabase, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
|
||||
|
||||
TGHorizontalFrame * hfDB1 = new TGHorizontalFrame(gfDatabase); gfDatabase->AddFrame(hfDB1, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
|
||||
|
||||
|
@ -121,9 +122,24 @@ ProgramSetting::ProgramSetting(const TGWindow *p){
|
|||
|
||||
}
|
||||
|
||||
{///============== Read Time event building
|
||||
{///============== Other setting Read Time event building
|
||||
TGGroupFrame * gfOther = new TGGroupFrame(vframe, "Other Settings", kVerticalFrame); vframe->AddFrame(gfOther, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
|
||||
|
||||
TGHorizontalFrame * hfOther1 = new TGHorizontalFrame(gfOther); gfOther->AddFrame(hfOther1, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
|
||||
|
||||
TGLabel * lbPort = new TGLabel(hfOther1, "Number of Port :"); hfOther1->AddFrame(lbPort, kaka);
|
||||
numPort = new TGNumberEntry(hfOther1, ProgramSetting::maxPort, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hfOther1->AddFrame(numPort, kaka);
|
||||
numPort->SetWidth(50);
|
||||
numPort->SetLimits(TGNumberFormat::kNELLimitMinMax, 1, MaxNPorts);
|
||||
numPort->Connect("Modified()", "ProgramSetting", this, "SetSearchRange()");
|
||||
|
||||
TGHorizontalFrame * hfOther2 = new TGHorizontalFrame(gfOther); gfOther->AddFrame(hfOther2, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
|
||||
|
||||
TGLabel * lbBoard = new TGLabel(hfOther2, "Number of Board / Port :"); hfOther2->AddFrame(lbBoard, kaka);
|
||||
numBoard = new TGNumberEntry(hfOther2, ProgramSetting::maxBoardPrePort, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hfOther2->AddFrame(numBoard, kaka);
|
||||
numBoard->SetWidth(50);
|
||||
numBoard->SetLimits(TGNumberFormat::kNELLimitMinMax, 1, 9);
|
||||
numBoard->Connect("Modified()", "ProgramSetting", this, "SetSearchRange()");
|
||||
}
|
||||
|
||||
fMain->MapSubwindows();
|
||||
|
@ -144,6 +160,9 @@ ProgramSetting::~ProgramSetting(){
|
|||
delete cbDatabase;
|
||||
delete cbElog;
|
||||
|
||||
delete numPort;
|
||||
delete numBoard;
|
||||
|
||||
fMain->Cleanup();
|
||||
delete fMain;
|
||||
}
|
||||
|
@ -273,3 +292,8 @@ void ProgramSetting::SetDataBaseElogOnOff(){
|
|||
EnableElog = ( cbElog->GetState() == kButtonDown ? true : false );
|
||||
|
||||
}
|
||||
|
||||
void ProgramSetting::SetSearchRange(){
|
||||
maxPort = numPort->GetNumber();
|
||||
maxBoardPrePort = numPort->GetNumber();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,9 @@ class ProgramSetting{
|
|||
TGCheckButton * cbDatabase;
|
||||
TGCheckButton * cbElog;
|
||||
|
||||
TGNumberEntry * numPort;
|
||||
TGNumberEntry * numBoard;
|
||||
|
||||
public:
|
||||
ProgramSetting(const TGWindow *p);
|
||||
virtual ~ProgramSetting();
|
||||
|
@ -44,6 +47,9 @@ class ProgramSetting{
|
|||
static bool EnableElog;
|
||||
static bool EnableDatabase;
|
||||
|
||||
static unsigned short maxPort;
|
||||
static unsigned short maxBoardPrePort;
|
||||
|
||||
const static std::string settingFileName; // fixed as FSUDAQ.sh
|
||||
const static std::string programPath;
|
||||
|
||||
|
@ -57,6 +63,8 @@ class ProgramSetting{
|
|||
|
||||
void SetDataBaseElogOnOff();
|
||||
|
||||
void SetSearchRange();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,8 +14,6 @@ extern Digitizer ** digi;
|
|||
|
||||
RegisterSetting::RegisterSetting(const TGWindow *p, UInt_t w, UInt_t h, uint32_t address){
|
||||
|
||||
printf("----- %s \n", __func__);
|
||||
|
||||
for( int i = 0; i < MaxNChannels; i++) value[i] = 0;
|
||||
|
||||
fMain = new TGMainFrame(p,w,h);
|
||||
|
|
67
DAQ/startStopDialog.cpp
Normal file
67
DAQ/startStopDialog.cpp
Normal file
|
@ -0,0 +1,67 @@
|
|||
#include "startStopDialog.h"
|
||||
|
||||
|
||||
TString StartStopDialog::startComment = "";
|
||||
TString StartStopDialog::stopComment = "";
|
||||
bool StartStopDialog::isOK = false;
|
||||
|
||||
StartStopDialog::StartStopDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, bool isStart){
|
||||
|
||||
this->isStart = isStart;
|
||||
|
||||
startComment = "";
|
||||
stopComment = "";
|
||||
|
||||
fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
|
||||
fMain->DontCallClose(); /// to avoid double deletions.
|
||||
//fMain->SetCleanup(kDeepCleanup); /// use hierarchical cleaning
|
||||
fMain->Connect("CloseWindow()", "StartStopDialog", this, "CloseWindow()");
|
||||
|
||||
TGHorizontalFrame * fFrame1 = new TGHorizontalFrame(fMain); fMain->AddFrame(fFrame1, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX ));
|
||||
txtComment = new TGTextEntry(fFrame1, ""); fFrame1->AddFrame(txtComment);
|
||||
txtComment->Resize(300, 20);
|
||||
txtComment->Connect("ReturnPressed()", "StartStopDialog", this, "DoOK()");
|
||||
|
||||
TGHorizontalFrame * fFrame2 = new TGHorizontalFrame(fMain); fMain->AddFrame(fFrame2,new TGLayoutHints(kLHintsCenterX | kLHintsExpandX));
|
||||
|
||||
TGTextButton * bOK = new TGTextButton(fFrame2, "OK"); fFrame2->AddFrame(bOK, new TGLayoutHints(kLHintsCenterX));
|
||||
bOK->Connect("Clicked()", "StartStopDialog", this, "DoOK()");
|
||||
|
||||
TGTextButton * bCancel = new TGTextButton(fFrame2, "Cancel"); fFrame2->AddFrame(bCancel, new TGLayoutHints(kLHintsCenterX));
|
||||
bCancel->Connect("Clicked()", "StartStopDialog", this, "DoClose()");
|
||||
|
||||
fMain->MapSubwindows();
|
||||
fMain->Resize();
|
||||
|
||||
fMain->CenterOnParent(); /// position relative to the parent's window
|
||||
if( isStart) {
|
||||
fMain->SetWindowName("Start Comment");
|
||||
}else{
|
||||
fMain->SetWindowName("Stop Comment");
|
||||
}
|
||||
fMain->MapWindow();
|
||||
|
||||
gClient->WaitFor(fMain); /// make everything wait for it
|
||||
|
||||
}
|
||||
|
||||
|
||||
StartStopDialog::~StartStopDialog(){
|
||||
printf("-------- %s \n", __func__);
|
||||
isOK = false;
|
||||
delete txtComment;
|
||||
fMain->DeleteWindow(); /// deletes fMain
|
||||
}
|
||||
|
||||
void StartStopDialog::DoClose(){
|
||||
isOK = false;
|
||||
///Wait for 500 msec
|
||||
TTimer::SingleShot(500, "StartStopDialog", this, "CloseWindow()");
|
||||
}
|
||||
|
||||
void StartStopDialog::DoOK(){
|
||||
if( isStart ) startComment = txtComment->GetText();
|
||||
if( !isStart ) stopComment = txtComment->GetText();
|
||||
isOK = true;
|
||||
TTimer::SingleShot(500, "StartStopDialog", this, "CloseWindow()");
|
||||
}
|
40
DAQ/startStopDialog.h
Normal file
40
DAQ/startStopDialog.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef START_STOP_DIALOG_H
|
||||
#define START_STOP_DIALOG_H
|
||||
|
||||
#include <TQObject.h>
|
||||
#include <RQ_OBJECT.h>
|
||||
#include <TGButton.h>
|
||||
#include <TGLabel.h>
|
||||
#include <TTimer.h>
|
||||
#include <TGTextEntry.h>
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
class TGWindow;
|
||||
class TGMainFrame;
|
||||
|
||||
class StartStopDialog{
|
||||
RQ_OBJECT("StartStopDialog")
|
||||
private:
|
||||
|
||||
TGTextEntry * txtComment;
|
||||
bool isStart;
|
||||
|
||||
public:
|
||||
StartStopDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, bool isStart);
|
||||
virtual ~StartStopDialog();
|
||||
|
||||
TGTransientFrame * fMain;
|
||||
|
||||
void DoClose();
|
||||
void DoOK();
|
||||
|
||||
void CloseWindow() { delete this;}
|
||||
|
||||
static TString startComment;
|
||||
static TString stopComment;
|
||||
static bool isOK;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
23
DAQ/test.cpp
23
DAQ/test.cpp
|
@ -1,3 +1,4 @@
|
|||
#include "macro.h"
|
||||
#include "ClassData.h"
|
||||
#include "ClassDigitizer.h"
|
||||
|
||||
|
@ -69,35 +70,27 @@ int getch(void){
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
unsigned long get_time(){
|
||||
unsigned long time_us;
|
||||
struct timeval t1;
|
||||
struct timezone tz;
|
||||
gettimeofday(&t1, &tz);
|
||||
time_us = (t1.tv_sec) * 1000000 + t1.tv_usec;
|
||||
return time_us;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
|
||||
/**////##################### Demo for loading and change setting without open a digitizer
|
||||
Digitizer * dig = new Digitizer();
|
||||
dig->OpenDigitizer(0, 1, false, true);
|
||||
dig->LoadSettingBinary("setting_323.bin");
|
||||
dig->LoadSettingBinary("expDir/settings/setting_323.bin");
|
||||
|
||||
//dig->ProgramPHABoard();
|
||||
//dig->OpenSettingBinary("setting_323.bin");
|
||||
//dig->ReadAllSettingsFromBoard();
|
||||
|
||||
//dig->PrintSettingFromMemory();
|
||||
dig->StopACQ();
|
||||
|
||||
dig->WriteRegister(Register::DPP::SoftwareClear_W, 1);
|
||||
|
||||
///dig->SaveSettingAsText("haha.txt");
|
||||
|
||||
std::remove("Test_323_139_000.fsu");
|
||||
///std::remove("Test_323_139_000.fsu");
|
||||
|
||||
/**
|
||||
{///============ Checking the buffer size calculation
|
||||
unsigned short B = 10; /// BLT
|
||||
unsigned short Eg = 511; /// Event / dual channel
|
||||
|
@ -151,12 +144,12 @@ int main(int argc, char* argv[]){
|
|||
|
||||
dig->StartACQ();
|
||||
|
||||
for( int i = 0; i < 2; i++){
|
||||
usleep(1000000);
|
||||
for( int i = 0; i < 60; i++){
|
||||
usleep(500*1000);
|
||||
dig->ReadData();
|
||||
printf("------------------- %d\n", i);
|
||||
unsigned long time1 = get_time();
|
||||
dig->GetData()->DecodeBuffer(false,4);
|
||||
dig->GetData()->DecodeBuffer(false,0);
|
||||
unsigned long time2 = get_time();
|
||||
printf("********************* decode time : %lu usec\n", time2-time1);
|
||||
dig->GetData()->PrintStat();
|
||||
|
|
|
@ -18,25 +18,28 @@ extern Digitizer ** digi;
|
|||
|
||||
//extern bool ProgramSetting::EnableDatabase;
|
||||
|
||||
bool TriggerSummary::isOpened = false;
|
||||
bool TriggerSummary::isManualOpened = false;
|
||||
bool TriggerSummary::updateFlag = true;
|
||||
TGTextEntry * TriggerSummary::txtTrigger[MaxNBoards][MaxNChannels] = {NULL};
|
||||
TGTextEntry * TriggerSummary::txtThresholdValue[MaxNBoards][MaxNChannels] = {NULL};
|
||||
TGTextEntry * TriggerSummary::txtThreshold[MaxNBoards][MaxNChannels] = {NULL};
|
||||
TGCheckButton * TriggerSummary::cbChannelEnable[MaxNBoards][MaxNChannels] = {NULL};
|
||||
TGNumberEntry * TriggerSummary::numUpdateTime = NULL;
|
||||
unsigned short TriggerSummary::value[MaxNBoards][MaxNChannels] = {0};
|
||||
|
||||
bool TriggerSummary::onOff[MaxNBoards][MaxNChannels] = {1};
|
||||
|
||||
TriggerSummary::TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h){
|
||||
|
||||
printf("----- %s \n", __func__);
|
||||
|
||||
fMain = new TGMainFrame(p,w,h);
|
||||
fMain->SetWindowName("Scalar Panel");
|
||||
fMain->Connect("CloseWindow()", "TriggerSummary", this, "CloseWindow()");
|
||||
//fMain->SetMWMHints(0,0, 0);
|
||||
|
||||
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain); fMain->AddFrame(hframe);
|
||||
|
||||
TGLayoutHints * kaka = new TGLayoutHints(kLHintsLeft, 0,0,0,0); /// left, right, top, bottom
|
||||
TGLayoutHints * lala = new TGLayoutHints(kLHintsLeft, 0,0,3,2); /// left, right, top, bottom
|
||||
|
||||
TGGroupFrame * gBD[nDigi];
|
||||
TGLabel * lbCh[nDigi][MaxNChannels];
|
||||
|
@ -49,11 +52,16 @@ TriggerSummary::TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h){
|
|||
TGVerticalFrame * vframe1 = new TGVerticalFrame(gBD[bd]); gBD[bd]->AddFrame(vframe1, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0));
|
||||
TGVerticalFrame * vframe2 = new TGVerticalFrame(gBD[bd]); gBD[bd]->AddFrame(vframe2, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0));
|
||||
TGVerticalFrame * vframe3 = new TGVerticalFrame(gBD[bd]); gBD[bd]->AddFrame(vframe3, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0));
|
||||
TGVerticalFrame * vframe4 = new TGVerticalFrame(gBD[bd]); gBD[bd]->AddFrame(vframe4, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0));
|
||||
|
||||
TGLabel * lbCh0 = new TGLabel(vframe0, "ch"); vframe0->AddFrame(lbCh0, new TGLayoutHints(kLHintsCenterY, 0,5,3,2));
|
||||
TGLabel * lbTrigger = new TGLabel(vframe1, "Trig.[Hz]"); vframe1->AddFrame(lbTrigger, new TGLayoutHints(kLHintsCenterY, 5,5,3,2));
|
||||
TGLabel * lbThreshold = new TGLabel(vframe2, "Thres."); vframe2->AddFrame(lbThreshold, new TGLayoutHints(kLHintsCenterY, 5,5,3,2));
|
||||
TGLabel * lbdummy = new TGLabel(vframe3, ""); vframe3->AddFrame(lbdummy, new TGLayoutHints(kLHintsCenterY, 5,5,3,2));
|
||||
TGLabel * lbdummy2 = new TGLabel(vframe4, ""); vframe4->AddFrame(lbdummy2, new TGLayoutHints(kLHintsCenterY, 5,5,3,2));
|
||||
|
||||
uint32_t chMask = 0xFFFF;
|
||||
if( digi != NULL ) chMask = digi[bd]->ReadRegister(Register::DPP::ChannelEnableMask);
|
||||
|
||||
for( int ch = 0; ch < (digi == NULL ? MaxNChannels: digi[bd]->GetNChannel()); ch++){
|
||||
lbCh[bd][ch] = new TGLabel(vframe0, Form("%02d", ch)); vframe0->AddFrame(lbCh[bd][ch], new TGLayoutHints(kLHintsCenterY, 0,5,4,2));
|
||||
|
@ -75,12 +83,22 @@ TriggerSummary::TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h){
|
|||
}
|
||||
txtThresholdValue[bd][ch]->SetText(Form("%d", value[bd][ch]), false);
|
||||
|
||||
txtThreshold[bd][ch] = new TGTextEntry(vframe3, ""); vframe3->AddFrame(txtThreshold[bd][ch], kaka);
|
||||
|
||||
txtThreshold[bd][ch] = new TGTextEntry(vframe3, "", 100*bd + ch); vframe3->AddFrame(txtThreshold[bd][ch], kaka);
|
||||
txtThreshold[bd][ch]->Resize(50,20);
|
||||
txtThreshold[bd][ch]->SetAlignment(kTextRight);
|
||||
txtThreshold[bd][ch]->Connect("ReturnPressed()", "TriggerSummary", this, "SetThreshold()");
|
||||
txtThreshold[bd][ch]->SetText(Form("%d", value[bd][ch]), false);
|
||||
|
||||
cbChannelEnable[bd][ch] = new TGCheckButton(vframe4, ""); vframe4->AddFrame(cbChannelEnable[bd][ch], lala);
|
||||
cbChannelEnable[bd][ch]->Resize(50,20);
|
||||
cbChannelEnable[bd][ch]->SetState(kButtonDown);
|
||||
cbChannelEnable[bd][ch]->Connect("Clicked()", "TriggerSummary", this, "SetChannelEnable()");
|
||||
if( ( chMask & ( 1 << ch ) ) == 0 ) {
|
||||
txtThreshold[bd][ch]->SetEnabled(false);
|
||||
cbChannelEnable[bd][ch]->SetState(kButtonUp);
|
||||
onOff[bd][ch] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +107,7 @@ TriggerSummary::TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h){
|
|||
TGLabel * lbUpDateTime = new TGLabel(hframeSetting, "Update Period [msec]:");
|
||||
hframeSetting->AddFrame(lbUpDateTime, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
|
||||
|
||||
numUpdateTime = new TGNumberEntry(hframeSetting, 3000, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
|
||||
numUpdateTime = new TGNumberEntry(hframeSetting, 1000, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
|
||||
hframeSetting->AddFrame(numUpdateTime, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
|
||||
numUpdateTime->Resize(50, 20);
|
||||
|
||||
|
@ -98,6 +116,7 @@ TriggerSummary::TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h){
|
|||
fMain->MapWindow();
|
||||
|
||||
updateFlag = true;
|
||||
isOpened = true;
|
||||
|
||||
if( digi != NULL ){
|
||||
printf("-------- %s thread\n", __func__);
|
||||
|
@ -115,10 +134,13 @@ TriggerSummary::~TriggerSummary(){
|
|||
delete txtTrigger[i][j];
|
||||
delete txtThresholdValue[i][j];
|
||||
delete txtThreshold[i][j];
|
||||
delete cbChannelEnable[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
delete numUpdateTime;
|
||||
isOpened = false;
|
||||
isManualOpened = false;
|
||||
|
||||
updateFlag = false;
|
||||
thread->Join();
|
||||
|
@ -135,27 +157,30 @@ void * TriggerSummary::UpdateTriggerRate(void * ptr){
|
|||
|
||||
std::ofstream myfile;
|
||||
|
||||
unsigned int t1 = get_time();
|
||||
unsigned int t2 = 0;
|
||||
|
||||
while( updateFlag){
|
||||
|
||||
|
||||
if( ProgramSetting::EnableDatabase ) myfile.open( "tempDB.txt");
|
||||
|
||||
for( int bd = 0; bd < nDigi; bd++){
|
||||
for( int ch = 0; ch < digi[bd]->GetNChannel(); ch++){
|
||||
txtTrigger[bd][ch]->SetText(Form("%.2f", digi[bd]->GetData()->TriggerRate[ch]));
|
||||
value[bd][ch] = digi[bd]->GetSettingFromMemory(Register::DPP::PHA::TriggerThreshold, ch);
|
||||
txtThresholdValue[bd][ch]->SetText(Form("%d", value[bd][ch]), false);
|
||||
}
|
||||
}
|
||||
|
||||
if( ProgramSetting::EnableDatabase ) {
|
||||
t2 = get_time();
|
||||
if( ProgramSetting::EnableDatabase && (t2 - t1) > 5*1e6){
|
||||
myfile.open( "tempDB.txt");
|
||||
for( int bd = 0; bd < nDigi; bd++){
|
||||
for( int ch = 0; ch < digi[bd]->GetNChannel(); ch++){
|
||||
myfile << "Rate,Bd=" << bd << ",Ch=" << ch << " value=" << digi[bd]->GetData()->TriggerRate[ch] << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( ProgramSetting::EnableDatabase ){
|
||||
myfile.close();
|
||||
int temp = system(cmd.c_str());
|
||||
t1 = t2;
|
||||
}
|
||||
|
||||
usleep(numUpdateTime->GetNumber() * 1000);
|
||||
|
@ -170,27 +195,58 @@ void TriggerSummary::SetThreshold(){
|
|||
for( int bd = 0; bd < nDigi; bd++){
|
||||
for( int ch = 0; ch < digi[bd]->GetNChannel(); ch++){
|
||||
|
||||
unsigned short haha = atoi( txtThreshold[bd][ch]->GetText());
|
||||
unsigned int haha = atoi( txtThreshold[bd][ch]->GetText());
|
||||
|
||||
if( value[bd][ch] != haha ){
|
||||
|
||||
if( digi[bd]->IsRunning() ) {
|
||||
digi[bd]->StopACQ();
|
||||
usleep(100*1000);
|
||||
}
|
||||
|
||||
if( digi[bd]->GetDPPType() == V1730_DPP_PSD_CODE ) {
|
||||
|
||||
|
||||
digi[bd]->WriteRegister(Register::DPP::PSD::TriggerThreshold, haha, ch);
|
||||
|
||||
value[bd][ch] = digi[bd]->GetSettingFromMemory(Register::DPP::PSD::TriggerThreshold, ch);
|
||||
|
||||
}
|
||||
if( digi[bd]->GetDPPType() == V1730_DPP_PHA_CODE ) {
|
||||
digi[bd]->WriteRegister(Register::DPP::PHA::TriggerThreshold, haha, ch);
|
||||
|
||||
value[bd][ch] = digi[bd]->GetSettingFromMemory(Register::DPP::PHA::TriggerThreshold, ch);
|
||||
|
||||
}
|
||||
|
||||
txtThresholdValue[bd][ch]->SetText(Form("%d", value[bd][ch]), false);
|
||||
|
||||
if( digi[bd]->IsRunning() ) {
|
||||
usleep(100*1000);
|
||||
digi[bd]->StartACQ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerSummary::SetChannelEnable(){
|
||||
if( digi == NULL ) return;
|
||||
|
||||
for( int bd = 0; bd < nDigi; bd++){
|
||||
for( int ch = 0; ch < digi[bd]->GetNChannel(); ch++){
|
||||
|
||||
bool state = ( cbChannelEnable[bd][ch]->GetState() == kButtonDown ? true : false);
|
||||
|
||||
if( onOff[bd][ch] != state ){
|
||||
|
||||
if( digi[bd]->IsRunning() ) {
|
||||
digi[bd]->StopACQ();
|
||||
usleep(100*1000);
|
||||
}
|
||||
|
||||
digi[bd]->SetChannelOnOff(ch, state);
|
||||
onOff[bd][ch] = state;
|
||||
txtThreshold[bd][ch]->SetEnabled(state);
|
||||
|
||||
if( digi[bd]->IsRunning() ) {
|
||||
usleep(100*1000);
|
||||
digi[bd]->StartACQ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,23 +22,29 @@ class TriggerSummary{
|
|||
static TGTextEntry * txtTrigger[MaxNBoards][MaxNChannels];
|
||||
static TGTextEntry * txtThresholdValue[MaxNBoards][MaxNChannels];
|
||||
static TGTextEntry * txtThreshold[MaxNBoards][MaxNChannels];
|
||||
static TGCheckButton * cbChannelEnable[MaxNBoards][MaxNChannels];
|
||||
|
||||
TThread * thread;
|
||||
static bool updateFlag;
|
||||
static TGNumberEntry * numUpdateTime;
|
||||
|
||||
static unsigned short value[MaxNBoards][MaxNChannels];
|
||||
static bool onOff[MaxNBoards][MaxNChannels];
|
||||
|
||||
public:
|
||||
TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h);
|
||||
virtual ~TriggerSummary();
|
||||
|
||||
static bool isOpened;
|
||||
static bool isManualOpened;
|
||||
|
||||
void CloseWindow() { delete this;}
|
||||
|
||||
static void * UpdateTriggerRate(void *ptr);
|
||||
|
||||
void SetThreshold();
|
||||
void SetThreshold(int boardID, int ch, unsigned short val) { value[boardID][ch] = val; }
|
||||
//void SetThreshold(int boardID, int ch, unsigned short val) { value[boardID][ch] = val; }
|
||||
void SetChannelEnable();
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user