This commit is contained in:
Ryan Tang 2022-04-08 17:01:48 -04:00
parent ca63063e62
commit 2fb4d0a11e
5 changed files with 68 additions and 222 deletions

View File

@ -424,6 +424,19 @@ void Pixie16::ReadData(unsigned short modID){
}
}
unsigned int Pixie16::ScanNumDataBlockInExtFIFO(){
unsigned int numDataBlock = 0;
unsigned int nextWordtemp = nextWord;
while( nextWordtemp < nFIFOWords ){
nextWordtemp += (ExtFIFO_Data[nextWordtemp] >> 17) & 0x3FFF;
numDataBlock ++;
}
return numDataBlock;
}
int Pixie16::ProcessSingleData(){
int breakProcessLoopFlag = 0;

View File

@ -196,6 +196,8 @@ public:
void CheckExternalFIFOWords(unsigned short modID);
void ReadData(unsigned short modID);
unsigned int ScanNumDataBlockInExtFIFO();
unsigned int GetTotalNumWords() {return totNumFIFOWords;}
unsigned int GetnFIFOWords() {return nFIFOWords;}

View File

@ -31,6 +31,8 @@ enum MenuIdentifiers{
};
//TODO timed Run, //pixie->SetDigitizerPresetRunTime(100000, 0);
///make static members
Pixie16 * MainWindow::pixie = NULL;
TGTextEdit * MainWindow::teLog = NULL;
@ -452,7 +454,7 @@ void * MainWindow::SaveData(void* ptr){
localClock.Reset();
localClock.Start("timer");
int pauseTime = 500 ; ///msec
int pauseTime = 10 ; ///msec
while( pixie->IsRunning() ){
@ -461,36 +463,41 @@ void * MainWindow::SaveData(void* ptr){
if( !pixie->IsRunning() ) break;
pixie->ReadData(0);
pixie->SaveData();
double MByteRead = pixie->GetnFIFOWords()*4./1024./1024.;
if( pixie->GetnFIFOWords() > 0 ) {
pixie->SaveData();
if( MByteRead > 70 && pauseTime > 10) pauseTime = pauseTime - 20;
//TODO Fill HISTORGRAM;
time_t now = time(0);
tm * ltm = localtime(&now);
int year = 1900 + ltm->tm_year;
int month = 1 + ltm->tm_mon;
int day = ltm->tm_mday;
int hour = ltm->tm_hour;
int minute = ltm->tm_min;
int secound = ltm->tm_sec;
newFileSize = pixie->GetFileSize()/1024./1024.;
localClock.Stop("timer");
newTime = localClock.GetRealTime("timer"); /// sec
localClock.Start("timer");
double rate = (newFileSize - oldFileSize)/ (newTime-oldTime);
oldFileSize = newFileSize;
oldTime = newTime;
localClock.Stop("timer");
newTime = localClock.GetRealTime("timer"); /// sec
localClock.Start("timer");
if( newTime - oldTime > 1 ) {
//double MByteRead = pixie->GetnFIFOWords()*4./1024./1024.;
//if( MByteRead > 70 && pauseTime > 10) pauseTime = pauseTime - 20;
//TODO Fill HISTORGRAM;
time_t now = time(0);
tm * ltm = localtime(&now);
int year = 1900 + ltm->tm_year;
int month = 1 + ltm->tm_mon;
int day = ltm->tm_mday;
int hour = ltm->tm_hour;
int minute = ltm->tm_min;
int secound = ltm->tm_sec;
newFileSize = pixie->GetFileSize()/1024./1024.;
double rate = (newFileSize - oldFileSize)/ (newTime-oldTime);
oldFileSize = newFileSize;
oldTime = newTime;
teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] File Size : %.2f MB [%.2f MB/s], %.2f MB readed",
year, month, day, hour, minute, secound, newFileSize, rate, MByteRead));
teLog->LineDown();
//teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] File Size : %.2f MB [%.2f MB/s], %.2f MB readed",
// year, month, day, hour, minute, secound, newFileSize, rate, MByteRead));
teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] File Size : %.2f MB [%.2f MB/s]",
year, month, day, hour, minute, secound, newFileSize, rate));
teLog->LineDown();
}
}
}
pixie->ReadData(0);

View File

@ -105,8 +105,11 @@ ScalarPanel::~ScalarPanel(){
}
///=========================== Thread
void * ScalarPanel::UpdateScalar(void * ptr){
//TODO save txt file
while(updateFlag){
int ss = Pixie16GetStatisticsSize();
@ -115,9 +118,8 @@ void * ScalarPanel::UpdateScalar(void * ptr){
for( int mod = 0; mod < nMod; mod++){
Pixie16ReadStatisticsFromModule (statistics, mod);
double realTime = Pixie16ComputeRealTime (statistics, mod);
double realTime = Pixie16ComputeRealTime (statistics, mod);
teRealTime[mod]->SetText(Form("%.2f", realTime));
for( int ch = 0; ch < MAXCH ; ch ++){
@ -127,13 +129,9 @@ void * ScalarPanel::UpdateScalar(void * ptr){
double liveTime = Pixie16ComputeLiveTime (statistics, mod, ch);
teRate[mod][ch]->SetText(Form("%.2f[%.2f] %.2f", ICR, OCR, liveTime));
}
gSystem->Sleep(updateTime);
}
}
printf("quite Update Scalar\n");

View File

@ -41,12 +41,6 @@
#include "evtReader.h"
long get_time();
static struct termios g_old_kbd_mode;
static void cooked(void); ///set keyboard behaviour as wait-for-enter
static void uncooked(void); ///set keyboard behaviour as immediate repsond
static void raw(void);
int getch(void);
int keyboardhit();
bool QuitFlag = false;
@ -91,7 +85,7 @@ void GetBaseline(int ch){
double * baselineTime = pixie->GetBaselineTimestamp();
for( int i = 0 ; i < pixie->GetBaslineLength(); i++){
gTrace->SetPoint(i, baselineTime[i]*1000, baseline[i]);
//printf("%5d | %f, %f \n", i, baselineTime[i]*1000, baseline[i]);
///printf("%5d | %f, %f \n", i, baselineTime[i]*1000, baseline[i]);
}
canvas->cd(2); gTrace->Draw("APL");
@ -114,8 +108,9 @@ void ProcessData(){
while( evt->GetFileSize() > 0 && evt->GetFileSize() > evt->GetFilePos() ){
int status = evt->ReadBlock();
if( status == -1 ) break;
//printf("%d, %ld, %ld, %lld\n", status, evt->GetFilePos(), evt->GetFileSize(), evt->GetBlockID());
//data->Print(0);
@ -153,8 +148,6 @@ void ProcessData(){
}
printf("========= finished ProcessData()\n");
canvas->cd(1); hch->Draw();
canvas->cd(2); hE->Draw();
@ -189,31 +182,11 @@ int main(int argc, char *argv[]){
ch2ns = pixie->GetCh2ns(0);
gTrace->GetXaxis()->SetTitle("time [ns]");
//pixie->SetDigitizerPresetRunTime(100000, 0);
//pixie->SetDigitizerSynchWait(0, 0); // not simultaneously
//pixie->SetDigitizerInSynch(1, 0); //not simultaneously
pixie->PrintDigitizerSettings(0);
int ch = 6;
double time = 10.0; ///sec
//pixie->AdjustOffset();
//pixie->SetChannelEnergyRiseTime(2, 0, ch);
//pixie->SetChannelTriggerThreshold(300, 0, ch);
//pixie->SetChannelEnergyTau(50, 0, ch);
//pixie->SetChannelOnOff(true, 0, ch);
//pixie->SetChannelPositivePolarity(true, 0, ch);
//pixie->SetChannelTraceOnOff(true, 0, ch);
//pixie->SetChannelBaseLinePrecent(10, 0, ch);
//pixie->SetChannelVOffset(-0.5, 0, ch);
//pixie->SetChannelTraceLenght(10, 0, ch);
//pixie->SetChannelTraceDelay(2, 0, ch);
//pixie->SetChannelGain(1, 0, ch);
//pixie->SaveSettings("test_ryan.set");
double time = 4.0; ///sec
pixie->PrintChannelAllSettings(0, ch);
pixie->PrintChannelSettingsSummary(0);
@ -232,7 +205,13 @@ int main(int argc, char *argv[]){
while( CurrentTime - StartTime < time * 1000 ){
pixie->ReadData(0);
pixie->SaveData();
if( pixie->GetnFIFOWords() > 0 ) pixie->SaveData();
if( pixie->GetnFIFOWords() > 0 ) {/// msec
printf("number of dataBlack read : %u\n", pixie->ScanNumDataBlockInExtFIFO());
}
//TODO a quick way to read and fill histogram; the most time consumping part is filling trace
if( ElapsedTime > 1000 ) {
pixie->PrintStatistics(0);
@ -254,99 +233,6 @@ int main(int argc, char *argv[]){
unsigned int haha = pixie->GetTotalNumWords();
printf("=========== total nFIFO words : %d (%f) \n", haha, haha/1256.);
//kakakaka.join();
//pixie->SaveSettings("/home/ryan/Pixie16/ryan/test_ryan.set");
//pixie->GetTrace(0,0);
/*
uint32_t StartTime = get_time(), CurrentTime, ElapsedTime;
uint32_t PreviousTime = get_time();
uint32_t updatePeriod = 1000;
PrintCommands();
//start event loop
while(!QuitFlag){
if( keyboardhit()){
char c = getch();
if( c =='s' ){
pixie->StartRun(1);
StartTime = get_time();
}
if( c == 'a'){
pixie->StopRun();
}
if( c == 'q'){
pixie->StopRun();
QuitFlag = true;
}
if( c == 'r'){
float haha;
cooked();
printf("Rise time [us] ? ");
int temp = scanf("%f", &haha);
pixie->WriteChannelEnergyRiseTime((double)haha, 0, 0);
printf("Rise time for channle 0 is now : %f us\n", pixie->GetChannelEnergyRiseTime(0,0));
uncooked();
}
if( c == 't'){
float haha;
cooked();
printf("Trigger [ADC] ? ");
int temp = scanf("%f", &haha);
pixie->WriteChannelTriggerThreshold(haha, 0, 0);
printf("Tigger for channle 0 is now : %f ADC\n", pixie->GetChannelTriggerThreshold(0,0));
uncooked();
}
}
CurrentTime = get_time();
ElapsedTime = CurrentTime - PreviousTime; /// milliseconds
if (ElapsedTime > updatePeriod){
system("clear");
printf("\n======== Tree, Histograms, and Table update every ~%.2f sec\n", updatePeriod/1000.);
if( pixie->IsRunning() ) {
printf("\033[1;33m DAQ is running \033[m\n");
printf(" Rise time for channle 0: %f us\n", pixie->GetChannelEnergyRiseTime(0,0));
printf(" Flat top for channle 0: %f us\n", pixie->GetChannelEnergyFlatTop(0,0));
printf(" Decay time for channle 0: %f us\n", pixie->GetChannelEnergyTau(0,0));
printf("Trigger threshold for channle 0: %.0f ADC\n", pixie->GetChannelTriggerThreshold(0,0));
}
printf("Time Elapsed = %.3f sec = %.1f min\n", (CurrentTime - StartTime)/1e3, (CurrentTime - StartTime)/1e3/60.);
pixie->ReadData(0);
pixie->PrintData();
PreviousTime = CurrentTime;
PrintCommands();
}
}
*/
//delete pixie;
app->Run();
@ -365,63 +251,3 @@ long get_time(){
time_ms = (t1.tv_sec) * 1000 + t1.tv_usec / 1000;
return time_ms;
}
static void cooked(void){
tcsetattr(0, TCSANOW, &g_old_kbd_mode);
}
static void uncooked(void){
struct termios new_kbd_mode;
/* put keyboard (stdin, actually) in raw, unbuffered mode */
tcgetattr(0, &g_old_kbd_mode);
memcpy(&new_kbd_mode, &g_old_kbd_mode, sizeof(struct termios));
new_kbd_mode.c_lflag &= ~(ICANON | ECHO);
new_kbd_mode.c_cc[VTIME] = 0;
new_kbd_mode.c_cc[VMIN] = 1;
tcsetattr(0, TCSANOW, &new_kbd_mode);
}
static void raw(void){
static char init;
if(init) return;
/* put keyboard (stdin, actually) in raw, unbuffered mode */
uncooked();
/* when we exit, go back to normal, "cooked" mode */
atexit(cooked);
init = 1;
}
int getch(void){
unsigned char temp;
raw();
/* stdin = fd 0 */
if(read(0, &temp, 1) != 1) return 0;
//printf("%s", &temp);
return temp;
}
int keyboardhit(){
struct timeval timeout;
fd_set read_handles;
int status;
raw();
/* check stdin (fd 0) for activity */
FD_ZERO(&read_handles);
FD_SET(0, &read_handles);
timeout.tv_sec = timeout.tv_usec = 0;
status = select(0 + 1, &read_handles, NULL, NULL, &timeout);
if(status < 0){
printf("select() failed in keyboardhit()\n");
exit(1);
}
return (status);
}