//------------------------------------------------------------------------------ // Application task example -- // (C) Piero Giubilato 2008-2010, Berkeley Lab -- //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "task_Demo.cpp" // [Author] "Piero Giubilato" // [Version] "1.5" // [Modified by] "Piero Giubilato" // [Last revision] "23 Jun 2009" // [Language] "C++" // [Compiler] "Visual C++ 8.x 9.x" // [Member of] "Cool SEAL" // [Project] "SEAL" // [Description] "Application task example" // [Key documentation] // "Visual C++ Reference Help" // {Trace} //______________________________________________________________________________ // Standard components #include // Root Components #include "TSystem.h" // Application components #include "global.h" #include "cool.h" #include "task_Demo.h" //______________________________________________________________________________ task_Demo::task_Demo() { // Standard constructor dbg_Print("task_Demo::task_Demo:()", DBG_LVL_ZERO); // Clears handles burst_Raw = 0; frame_Pedestal = 0; frame_Image = 0; frame_Noise = 0; // Acq setting old_Det = -1; old_Col = -1; old_Row = -1; // Set up the detectors detector_Setup(); // Set up the data container(s) data_Setup(detector_List[0], 1); // Set up the interface gui_Setup(); } //______________________________________________________________________________ task_Demo::~task_Demo() { // Standard destructor dbg_Print("task_Demo::~task_Demo:()", DBG_LVL_ZERO); // Kill everything delete_All(); } //______________________________________________________________________________ UInt_t task_Demo::run() { // Debug dbg_Print("task_Demo::run: run called", DBG_LVL_MAKE); // Returns all ok return 0; } //______________________________________________________________________________ void task_Demo::delete_All() { // Delete the data dbg_Print("task_Demo::delete_All:()", DBG_LVL_FLOW); // Deletes all GUI objects cool::Gui->delete_All(); // Delete data structures if (burst_Raw) delete burst_Raw; if (frame_Noise) delete frame_Noise; if (frame_Image) delete frame_Image; if (frame_Pedestal)delete frame_Pedestal; // Delete detectors for (UInt_t i = 0; i < detector_List.size(); i++) { if (detector_List[i]) delete detector_List[i]; } } //______________________________________________________________________________ void task_Demo::static_Evn(const int arg) { // Try the call to a static function (here just to give an example) dbg_Print("task_Demo::static_Evn: it works!", DBG_LVL_FLOW); } //****************************************************************************** //* * //* GUI initialization and destruction * //* * //****************************************************************************** //______________________________________________________________________________ void task_Demo::gui_Setup() { // Set up all the interface objects dbg_Print("task_Demo::gui_Setup: defining interface!", DBG_LVL_FLOW); // General appearance // ------------------ // Main window color cool::Gui->update_Auto(false); cool::Gui->color_Set(0x88AA88, cool::Gui->kc_Black); // Buttons // ------- // Button Quit // Acquisition // ----------- // The main Panel & label lbl_Desk.push_back(new gui_Label("Acquisition", 20, 10)); lbl_Desk.back()->Transparent(true); lbl_Desk.back()->fontName("Arial"); lbl_Desk.back()->fontSize(14); lbl_Desk.back()->foreColor(cool::Gui->kc_White); lbl_Desk.back()->fontBold(true); pnl_Desk.push_back(new gui_Panel(20, 40, 360, 145, cool::Gui->kc_Cyan, true)); pnl_Desk.back()->LowerWindow(); // ACQ timing [0] cmb_Acq.push_back(new gui_Combo(pnl_Desk.back(), 20, 150, 35, 100, 24)); cmb_Acq.back()->fontName("Calibri"); cmb_Acq.back()->label_Set("Timing", 0); cmb_Acq.back()->cbox_Entry("Single Shot", 0); cmb_Acq.back()->cbox_Entry("Continuous", 1); cmb_Acq.back()->cbox_Entry("Countdown", 2); cmb_Acq.back()->cbox_Val(0); // Data path [1] cmb_Acq.push_back(new gui_Combo(pnl_Desk.back(), 40, 270, 35, 100, 24)); cmb_Acq.back()->fontName("Calibri"); cmb_Acq.back()->label_Set("Data source", 0); cmb_Acq.back()->cbox_Entry("ADCs", 0); cmb_Acq.back()->cbox_Entry("Dummy data", 1); cmb_Acq.back()->cbox_Entry("Gretina", 4); cmb_Acq.back()->cbox_Val(0); // Reset mode [2] cmb_Acq.push_back(new gui_Combo(pnl_Desk.back(), 40, 270, 80, 100, 24)); cmb_Acq.back()->fontName("Calibri"); cmb_Acq.back()->label_Set("Trigger mode", 0); cmb_Acq.back()->cbox_Entry("Chip synch", 0); cmb_Acq.back()->cbox_Entry("Trig synch", 1); cmb_Acq.back()->cbox_Val(0); // What to see mode [3] cmb_Acq.push_back(new gui_Combo(pnl_Desk.back(), 40, 270, 125, 100, 24)); cmb_Acq.back()->fontName("Calibri"); cmb_Acq.back()->label_Set("Show what", 0); cmb_Acq.back()->cbox_Entry("Raw data", 0); cmb_Acq.back()->cbox_Entry("Diff data", 1); cmb_Acq.back()->cbox_Val(0); // Connect the combos for (UInt_t i = 0; i < cmb_Acq.size(); i++) cmb_Acq[i]->task_Connect(this, &task_Demo::cmb_acq_Evn); // Frames per burst [0] num_Acq.push_back(new gui_Numeric(pnl_Desk.back(), 1, 150, 80, 100, 24)); num_Acq.back()->fontName("Calibri"); num_Acq.back()->label_Set("Frames per Burst", 0); num_Acq.back()->num_Min(1); num_Acq.back()->num_Max(1024); num_Acq.back()->num_Limits(true); // Countdown [1] num_Acq.push_back(new gui_Numeric(pnl_Desk.back(), 1, 150, 125, 100, 24)); num_Acq.back()->fontName("Calibri"); num_Acq.back()->label_Set("Countdown", 0); num_Acq.back()->num_Min(0); num_Acq.back()->num_Max(1000000); num_Acq.back()->num_Limits(true); // Buttons btn_Acq.push_back(new gui_CoolButton(pnl_Desk.back(), "Acquire", 20, 30, 110, 36, cool::Gui->kc_White, cool::Gui->kc_Green)); btn_Acq.back()->btn_Mode(gui_CoolButton::km_Latch); btn_Acq.push_back(new gui_CoolButton(pnl_Desk.back(), "Pedestals", 20, 75, 90, 36, cool::Gui->kc_White, cool::Gui->kc_Green)); btn_Acq.back()->btn_Mode(gui_CoolButton::km_Latch); btn_Acq.push_back(new gui_CoolButton(pnl_Desk.back(), "Quit", 20, 120, 110, 36, cool::Gui->kc_White, cool::Gui->kc_Red)); // Connect the buttons for (UInt_t i = 0; i < btn_Acq.size(); i++) btn_Acq[i]->task_Connect(this, &task_Demo::btn_acq_Evn); // Leds led_Acq.push_back(new gui_Led(pnl_Desk.back(), 110, 81, 24, 24)); // Detector // -------- // Detector panel & label lbl_Desk.push_back(new gui_Label("Detector", 410, 10)); lbl_Desk.back()->Transparent(true); lbl_Desk.back()->fontName("Arial Black"); lbl_Desk.back()->fontSize(14); lbl_Desk.back()->foreColor(cool::Gui->kc_White); lbl_Desk.back()->fontBold(true); pnl_Desk.push_back(new gui_Panel(410, 40, 280, 145, cool::Gui->kc_gray_Dark, true)); pnl_Desk.back()->LowerWindow(); // Detector type [0] cmb_Det.push_back(new gui_Combo(pnl_Desk.back(), 0, 20, 35, 120, 24)); cmb_Det.back()->fontName("Calibri"); cmb_Det.back()->label_Set("Detector", 0); cmb_Det.back()->cbox_Entry("Dummy 1Ch" , 0); cmb_Det.back()->cbox_Entry("Dummy 4Ch" , 1); cmb_Det.back()->cbox_Entry("LDRD2 Px + Ref" , 2); cmb_Det.back()->cbox_Entry("TEAM 1Ch" , 3); cmb_Det.back()->cbox_Entry("TEAM 4Ch" , 4); cmb_Det.back()->cbox_Val(0); // Detector clock divider [1] cmb_Det.push_back(new gui_Combo(pnl_Desk.back(), 0, 160, 35, 120, 24)); cmb_Det.back()->fontName("Calibri"); cmb_Det.back()->label_Set("Clock speed", 0); cmb_Det.back()->cbox_Entry("50 Mhz", 0); cmb_Det.back()->cbox_Entry("25 MHz", 1); cmb_Det.back()->cbox_Entry("12.5 MHz", 2); cmb_Det.back()->cbox_Entry("6.25 Mhz", 3); cmb_Det.back()->cbox_Entry("3.12 MHz", 4); cmb_Det.back()->cbox_Entry("1.56 MHz", 5); cmb_Det.back()->cbox_Entry("781 KHz", 6); cmb_Det.back()->cbox_Entry("390 Khz", 7); cmb_Det.back()->cbox_Entry("195 KHz", 8); cmb_Det.back()->cbox_Val(1); // Dummy detector cols [2] cmb_Det.push_back(new gui_Combo(pnl_Desk.back(), 0, 20, 80, 120, 24)); cmb_Det.back()->fontName("Calibri"); cmb_Det.back()->label_Set("Dummy cols", 0); cmb_Det.back()->cbox_Entry("2", 2); cmb_Det.back()->cbox_Entry("4", 4); cmb_Det.back()->cbox_Entry("8", 8); cmb_Det.back()->cbox_Entry("16", 16); cmb_Det.back()->cbox_Entry("32", 32); cmb_Det.back()->cbox_Entry("64", 64); cmb_Det.back()->cbox_Entry("128", 128); cmb_Det.back()->cbox_Entry("256", 256); cmb_Det.back()->cbox_Entry("512", 512); cmb_Det.back()->cbox_Entry("1024", 1024); cmb_Det.back()->cbox_Entry("2048", 2048); cmb_Det.back()->cbox_Entry("4096", 4096); cmb_Det.back()->cbox_Val(16); // Dummy detector rows [3] cmb_Det.push_back(new gui_Combo(pnl_Desk.back(), 0, 20, 125, 120, 24)); cmb_Det.back()->fontName("Calibri"); cmb_Det.back()->label_Set("Dummy rows", 0); cmb_Det.back()->cbox_Entry("2", 2); cmb_Det.back()->cbox_Entry("4", 4); cmb_Det.back()->cbox_Entry("8", 8); cmb_Det.back()->cbox_Entry("16", 16); cmb_Det.back()->cbox_Entry("32", 32); cmb_Det.back()->cbox_Entry("64", 64); cmb_Det.back()->cbox_Entry("128", 128); cmb_Det.back()->cbox_Entry("256", 256); cmb_Det.back()->cbox_Entry("512", 512); cmb_Det.back()->cbox_Entry("1024", 1024); cmb_Det.back()->cbox_Entry("2048", 2048); cmb_Det.back()->cbox_Entry("4096", 4096); cmb_Det.back()->cbox_Val(16); // Channels chk_Adc.clear(); TString chk_Adc_name; chk_Adc.push_back(new gui_Check(pnl_Desk.back(), "Ch 1", 170, 70, 50, 20)); chk_Adc.back()->foreColor(cool::Gui->kc_White); chk_Adc.push_back(new gui_Check(pnl_Desk.back(), "Ch 2", 170, 90, 50, 20)); chk_Adc.back()->foreColor(cool::Gui->kc_White); chk_Adc.push_back(new gui_Check(pnl_Desk.back(), "Ch 3", 230, 70, 50, 20)); chk_Adc.back()->foreColor(cool::Gui->kc_White); chk_Adc.push_back(new gui_Check(pnl_Desk.back(), "Ch 4", 230, 90, 50, 20)); chk_Adc.back()->foreColor(cool::Gui->kc_White); // Gretina button btn_Det.push_back(new gui_CoolButton(pnl_Desk.back(), "Set TEAM", 160, 120, 120, 36, cool::Gui->kc_White, cool::Gui->kc_Orange)); // Connect the buttons for (UInt_t i = 0; i < btn_Det.size(); i++) btn_Det[i]->task_Connect(this, &task_Demo::btn_det_Evn); // Connect the combos for (UInt_t i = 0; i < cmb_Det.size(); i++) cmb_Det[i]->task_Connect(this, &task_Demo::cmb_det_Evn); // Communication // ------------- // Comm panel & label lbl_Desk.push_back(new gui_Label("Communication", 720, 10)); lbl_Desk.back()->Transparent(true); lbl_Desk.back()->fontName("Arial Black"); lbl_Desk.back()->fontSize(14); lbl_Desk.back()->foreColor(cool::Gui->kc_White); lbl_Desk.back()->fontBold(true); pnl_Desk.push_back(new gui_Panel(720, 40, 240, 145, cool::Gui->kc_gray_Dark)); pnl_Desk.back()->label_Set("Communication", 0); pnl_Desk.back()->LowerWindow(); // Comm buttons btn_Comm.push_back(new gui_CoolButton(pnl_Desk.back(), "Open", 20, 25, 100, 36, cool::Gui->kc_White, cool::Gui->kc_Gray)); btn_Comm.push_back(new gui_CoolButton(pnl_Desk.back(), "Reset", 20, 70, 100, 36, cool::Gui->kc_Red, cool::Gui->kc_Gray)); btn_Comm.push_back(new gui_CoolButton(pnl_Desk.back(), "Close", 140, 25, 100, 36, cool::Gui->kc_Black, cool::Gui->kc_Gray)); btn_Comm.push_back(new gui_CoolButton(pnl_Desk.back(), "Purge", 140, 70, 100, 36, cool::Gui->kc_Black, cool::Gui->kc_Gray)); btn_Comm.push_back(new gui_CoolButton(pnl_Desk.back(), "Clear", 140, 115, 100, 36, cool::Gui->kc_Black, cool::Gui->kc_Gray)); for (UInt_t i = 0; i < btn_Comm.size(); i++) btn_Comm[i]->task_Connect(this, &task_Demo::btn_comm_Evn); // Registers // --------- // Register panel & label lbl_Desk.push_back(new gui_Label("Register IO", 720, 210)); lbl_Desk.back()->Transparent(true); lbl_Desk.back()->fontName("Arial"); lbl_Desk.back()->fontSize(14); lbl_Desk.back()->foreColor(cool::Gui->kc_White); lbl_Desk.back()->fontBold(true); pnl_Desk.push_back(new gui_Panel(720, 240, 90, 530, cool::Gui->kc_Orange)); pnl_Desk.back()->LowerWindow(); // Register numerics //for (UInt_t c = 0; c < 3; c++) { for (UInt_t i = 0; i < 16; i++) { num_Reg.push_back(new gui_Numeric(pnl_Desk.back(), 0, 35, 125 + i * 26, 60, 24)); num_Reg.back()->fontName("Calibri"); num_Reg.back()->num_Hex(true); num_Reg.back()->label_Set("0x", gui_Const::align_Middle + gui_Const::align_Left, cool::Gui->kc_White); //num_Grt.back()->label_Set("Frames per Burst", 0); } //} // Register buttons btn_Reg.push_back(new gui_CoolButton(pnl_Desk.back(), "Write", 20, 25, 80, 36, cool::Gui->kc_White, cool::Gui->kc_Orange)); btn_Reg.back()->task_Connect(this, &task_Demo::btn_reg_Evn); btn_Reg.push_back(new gui_CoolButton(pnl_Desk.back(), "Read", 20, 70, 80, 36, cool::Gui->kc_White, cool::Gui->kc_Green)); btn_Reg.back()->task_Connect(this, &task_Demo::btn_reg_Evn); //btn_Reg.push_back(new gui_CoolButton(pnl_Desk.back(), "Write", 110, 25, 80, 36, cool::Gui->kc_White, cool::Gui->kc_Orange)); //btn_Reg.back()->task_Connect(this, &task_Demo::btn_reg_Evn); //btn_Reg.push_back(new gui_CoolButton(pnl_Desk.back(), "Read", 110, 70, 80, 36, cool::Gui->kc_White, cool::Gui->kc_Green)); //btn_Reg.back()->task_Connect(this, &task_Demo::btn_reg_Evn); //btn_Reg.push_back(new gui_CoolButton(pnl_Desk.back(), "Write", 200, 25, 80, 36, cool::Gui->kc_White, cool::Gui->kc_Orange)); //btn_Reg.back()->task_Connect(this, &task_Demo::btn_reg_Evn); //btn_Reg.push_back(new gui_CoolButton(pnl_Desk.back(), "Read", 200, 70, 80, 36, cool::Gui->kc_White, cool::Gui->kc_Green)); //btn_Reg.back()->task_Connect(this, &task_Demo::btn_reg_Evn); // TEAM/Gretina // Comm panel & label lbl_Desk.push_back(new gui_Label("TEAM Detector", 990, 10)); lbl_Desk.back()->Transparent(true); lbl_Desk.back()->fontName("Arial Black"); lbl_Desk.back()->fontSize(14); lbl_Desk.back()->foreColor(cool::Gui->kc_White); lbl_Desk.back()->fontBold(true); pnl_Desk.push_back(new gui_Panel(990, 40, 140, 255, cool::Gui->kc_gray_Dark)); //pnl_Desk.back()->label_Set("TEAM", 0); pnl_Desk.back()->LowerWindow(); // Clock Combo [0] cmb_TEAM.push_back(new gui_Combo(pnl_Desk.back(), 0, 20, 35, 120, 24)); cmb_TEAM.back()->fontName("Calibri"); cmb_TEAM.back()->label_Set("Clocks", 0); cmb_TEAM.back()->cbox_Entry("Internal", 0); cmb_TEAM.back()->cbox_Entry("External", 1); cmb_TEAM.back()->cbox_Val(0); // Data Combo [1] cmb_TEAM.push_back(new gui_Combo(pnl_Desk.back(), 0, 20, 80, 120, 24)); cmb_TEAM.back()->fontName("Calibri"); cmb_TEAM.back()->label_Set("Data mode", 0); cmb_TEAM.back()->cbox_Entry("Real data", 0); cmb_TEAM.back()->cbox_Entry("GRT fake data", 1); cmb_TEAM.back()->cbox_Entry("V5 fake data", 2); cmb_TEAM.back()->cbox_Val(0); // Sector size columns Combo [2] cmb_TEAM.push_back(new gui_Combo(pnl_Desk.back(), 0, 20, 125, 50, 24)); cmb_TEAM.back()->fontName("Calibri"); cmb_TEAM.back()->label_Set("Cols", 0); cmb_TEAM.back()->cbox_Entry("8", 8); cmb_TEAM.back()->cbox_Entry("16", 16); cmb_TEAM.back()->cbox_Entry("32", 32); cmb_TEAM.back()->cbox_Entry("64", 64); cmb_TEAM.back()->cbox_Val(16); // Sector size rows Combo [3] cmb_TEAM.push_back(new gui_Combo(pnl_Desk.back(), 0, 80, 125, 60, 24)); cmb_TEAM.back()->fontName("Calibri"); cmb_TEAM.back()->label_Set("Rows", 0); cmb_TEAM.back()->cbox_Entry("32", 32); cmb_TEAM.back()->cbox_Entry("64", 64); cmb_TEAM.back()->cbox_Entry("128", 128); cmb_TEAM.back()->cbox_Entry("256", 256); cmb_TEAM.back()->cbox_Entry("512", 512); cmb_TEAM.back()->cbox_Entry("1024", 1024); cmb_TEAM.back()->cbox_Val(128); // Image size on V4 [4] cmb_TEAM.push_back(new gui_Combo(pnl_Desk.back(), 0, 20, 170, 120, 24)); cmb_TEAM.back()->fontName("Calibri"); cmb_TEAM.back()->label_Set("Rows", 0); cmb_TEAM.back()->cbox_Entry("32", 32); cmb_TEAM.back()->cbox_Entry("64", 64); cmb_TEAM.back()->cbox_Entry("128", 128); cmb_TEAM.back()->cbox_Entry("256", 256); cmb_TEAM.back()->cbox_Entry("512", 512); cmb_TEAM.back()->cbox_Entry("1024", 1024); cmb_TEAM.back()->cbox_Val(128); // Maps // ---- // Palette UInt_t col[6] = {0xFF0000, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF, 0xFF00FF}; // Signal map_Signal = new gui_Map(80, 240, 512, 512, cool::Gui->kc_White); map_Signal->range_Color(col, 6); //map_Signal->data_Style(gui_Map::ks_Map); // Refresh cool::Gui->Update(); //cool::Gui->update_Auto(true); } //****************************************************************************** //* * //* GUI Callback target functions * //* * //****************************************************************************** //______________________________________________________________________________ void task_Demo::btn_acq_Evn(const int arg) { // Play button events handler dbg_Print("task_Demo::btn_run_Evn: run called", DBG_LVL_FLOW); // Run/Stop if (arg == btn_Acq[0]->obj_Id()) { // Start acquisition if (btn_Acq[0]->btn_Status()) { btn_Acq[0]->Text("Stop"); btn_Acq[0]->backColor(gui_CoolButton::kc_Red); // Acquire data_Preset(); switch (cmb_Acq[3]->cbox_Val()) { case 0: data_Acquire(ka_Std); break; case 1: data_Acquire(ka_PedSub); break; } // Stop acquisition } else { btn_Acq[0]->Text("Start"); btn_Acq[0]->backColor(gui_CoolButton::kc_Green); } return; } // Pedestal Run if (arg == btn_Acq[1]->obj_Id()) { // Start pedestals if (btn_Acq[1]->btn_Status()) { btn_Acq[1]->Text("Stop"); btn_Acq[1]->backColor(gui_CoolButton::kc_Red); // Acquire data_Pedestal(); // Stop pedestals } else { btn_Acq[1]->Text("Pedestal"); btn_Acq[1]->backColor(gui_CoolButton::kc_Green); } } // Quit if (arg == btn_Acq[2]->obj_Id()) { // Quit button events handler dbg_Print("task_Demo::btn_quit_Evn: quit called", DBG_LVL_FLOW); // Exits by self-quitting the class cool::Gui->Quit(); } } //______________________________________________________________________________ void task_Demo::btn_comm_Evn(const int arg) { // Do some comm operation if (arg == btn_Comm[0]->obj_Id()) fpga_Setup(burst_Raw); if (arg == btn_Comm[1]->obj_Id()) cool::Comm->Reset(); if (arg == btn_Comm[2]->obj_Id()) cool::Comm->Close(); if (arg == btn_Comm[3]->obj_Id()) cool::Comm->Purge(); if (arg == btn_Comm[4]->obj_Id()) cool::Comm->Clear(); } //______________________________________________________________________________ void task_Demo::cmb_acq_Evn(const int arg) { // Nothing to do at the moment } //______________________________________________________________________________ void task_Demo::cmb_det_Evn(const int arg) { // Performs some options // Gretina detector constrains //if (arg == cmb_Det[0]->obj_Id()) { if (cmb_Det[0]->cbox_Val() == 2) { //cmb_Det[1]->cbox_Val((Int_t)sqrt((Double_t)(cmb_Det[4]->cbox_Val() * cmb_Det[5]->cbox_Val() / 4))); // Expected size //cmb_Det[2]->cbox_Val(0); // 50 MHz //cmb_Acq[1]->cbox_Val(4); // Gretina data path } } //______________________________________________________________________________ void task_Demo::btn_det_Evn(const int arg) { // Gretina default setup if (arg == btn_Det[0]->obj_Id()) team_Setup(); } //______________________________________________________________________________ void task_Demo::btn_reg_Evn(const int arg) { // Write if (arg == btn_Reg[0]->obj_Id()) { // Info std::cout << "Writing to Gretina!\n"; // Set up a pivot buffer UShort_t buff[16]; Int_t buff_Len = 16; // Fill the buffer with the numeric values for (UInt_t i = 0; i < buff_Len; i++) { buff[i] = (UShort_t)(num_Reg[i]->num_Val()); std::cout << num_Reg[i]->num_Val() << " "; } std::cout << "\n"; // Write cool::Comm->raw_Write(buff, &buff_Len); } // Read if (arg == btn_Reg[1]->obj_Id()) { // Info std::cout << "Reading from Gretina!\n"; // Issue the write command: // Set up buffers UShort_t wr_buff[16]; UShort_t rd_buff[256]; Int_t wr_buff_Len = 16; Int_t rd_buff_Len = 256; // Clean input buffer for (UInt_t i = 0; i < rd_buff_Len; i++) rd_buff[i] = 0; // Fill the write buffer with the numeric values std::cout << "Sending: "; for (UInt_t i = 0; i < wr_buff_Len; i++) { wr_buff[i] = (UShort_t)(num_Reg[i]->num_Val()); std::cout << num_Reg[i]->num_Val() << " "; } std::cout << "\n"; // Send the write command to the module cool::Comm->raw_Write(wr_buff, &wr_buff_Len); // Read back the data from the USB cool::Comm->raw_Read(rd_buff, &rd_buff_Len); // Show what found std::cout << "Reading: \n"; if (rd_buff_Len > 0) { for (UInt_t i = 0; i < rd_buff_Len; i++) { std::cout << "Word #" << i << ": 0x " << std::hex << rd_buff[i] << "\n"; } //std::cout << "\n"; } else { std::cout << "No answer!\n"; } } } //****************************************************************************** //* * //* Data & Detector initialization and destruction * //* * //****************************************************************************** //______________________________________________________________________________ void task_Demo::detector_Setup(UInt_t col_Count, UInt_t row_Count) { // Set up the data dbg_Print("task_Demo::data_Setup: defining data objects", DBG_LVL_FLOW); cool::Out->Print("Defining detector\n", WHITE); // Creates new detectors for (UInt_t i = 0; i < detector_List.size(); i++) delete detector_List[i]; detector_List.clear(); // TEST 1Ch // -------- detector_List.push_back(new geom_Frame()); geom_Frame* test1 = detector_List.back(); // This is a test chip! // Hardware ID test1->HrdID(1); // FPGA-encoded hardware ID // 1 Chip test1->chip(0)->Name("Chip 0"); test1->chip(0)->col_Count(col_Count); test1->chip(0)->row_Count(row_Count); // 1 Layer test1->layer(0)->Name("Layer 0"); test1->layer(0)->dp_col_Count(col_Count); test1->layer(0)->dp_row_Count(row_Count); // 1 Channel test1->channel(0)->Name("Channel 0"); test1->channel(0)->chip_Idx(0); test1->channel(0)->layer_Idx(0); // Dummy linear geometry test1->chip(0)->dp_all_Range(0, 1); // TEST 4Ch // -------- detector_List.push_back(new geom_Frame()); geom_Frame* test4 = detector_List.back(); // This is a test chip! // Hardware ID test4->HrdID(1); // FPGA-encoded hardware ID // 4 Chip test4->chip(0)->Name("Chip 0"); test4->chip(0)->col_Count(col_Count / 4); test4->chip(0)->row_Count(row_Count); for (UInt_t i = 1; i < 4; i++) { test4->chip_Add(); test4->chip(i)->col_Count(col_Count / 4); test4->chip(i)->row_Count(row_Count); } // 1 Layer test4->layer(0)->Name("Layer 0"); test4->layer(0)->dp_col_Count(col_Count); test4->layer(0)->dp_row_Count(row_Count); // 4 Channel test4->channel(0)->Name("Channel 0"); test4->channel(0)->chip_Idx(0); test4->channel(0)->layer_Idx(0); for (UInt_t i = 1; i < 4; i++) test4->channel_Add(i, 0); // Dummy linear geometry for (UInt_t i = 0; i < 4; i++) test4->chip(i)->dp_all_Range(i * col_Count * row_Count / 4, 1); // TEAM style geometry UInt_t row_Count = test4->chip(0)->row_Count(); UInt_t col_Count = test4->chip(0)->col_Count(); UInt_t width = col_Count * 4; UInt_t half_Width = col_Count * 2; for (UInt_t y = 0; y < row_Count; y++) { for (UInt_t x = 0; x < col_Count; x++) { test4->chip(0)->dp_Value(x, y)= y * width + x * 2; test4->chip(1)->dp_Value(x, y)= y * width + x * 2 + 1; test4->chip(2)->dp_Value(x, y)= y * width + x * 2 + half_Width; test4->chip(3)->dp_Value(x, y)= y * width + x * 2 + half_Width + 1; } } // LDRD2 // ----- detector_List.push_back(new geom_Frame()); geom_Frame* ldrd2 = detector_List.back(); // Defines the hardware chips // Hardwrae ID ldrd2->HrdID(2); // FPGA-encoded hardware ID // LEFT LDRD2 sector ldrd2->chip(0)->Name("Left"); // LEFT side of LDRD2 ldrd2->chip(0)->col_Count(48); // 48 columns ldrd2->chip(0)->row_Count(96); // 96 rows ldrd2->chip(0)->col_Pitch(20); // Pixel column pitch ldrd2->chip(0)->row_Pitch(20); // Pixel row pitch // RIGHT LDRD2 sector ldrd2->chip_Add(); ldrd2->chip(1)->Name("Right"); // RIGHT side of LDRD2 ldrd2->chip(1)->col_Count(48); // 48 columns ldrd2->chip(1)->row_Count(96); // 96 rows ldrd2->chip(1)->col_Pitch(20); // Pixel column pitch ldrd2->chip(1)->row_Pitch(20); // Pixel row pitch // Defines the logic layers // First logical layer (SIGNAL) ldrd2->layer(0)->Name("Signal"); // The signal (abstracted) layer ldrd2->layer(0)->dp_col_Count(96); // Logical column count ldrd2->layer(0)->dp_row_Count(96); // Logical row count // Second logical layer (REFERENCE) ldrd2->layer_Add(); ldrd2->layer(1)->Name("Reference"); // The reference (abstracted) layer ldrd2->layer(1)->dp_col_Count(96); // 96 columns ldrd2->layer(1)->dp_row_Count(96); // 96 rows // Defines the chip/channel/layer connections // 1st output, left sector signal ldrd2->channel(0)->Name("Left signal"); // Chip/Layer connection ldrd2->channel(0)->chip_Idx(0); // Data are shaped as decribed by chip #0 ldrd2->channel(0)->layer_Idx(0); // Data are directed to layer #0 // 2nd output, left sector reference ldrd2->channel_Add(0, 1); // Chip #0 to layer #1 ldrd2->channel(1)->Name("Left reference"); // 3rd output, right sector signal ldrd2->channel_Add(1, 0); // Chip #1 to layer #0 ldrd2->channel(2)->Name("Right signal"); // 4th output, right sector reference ldrd2->channel_Add(1, 1); // Chip #1 to layer #1 ldrd2->channel(3)->Name("Right reference"); // Sets the chip geometry // Here we set the chip mapping respect to layer mapping. Basically, the // number of pixels contained into one chip is considered as a linear vector, // where for each pixel is stored the location where to place it into the // logical target layer defined by the channel association. // Chip #0 is on the left side of the logical frame, chip #1 (Right) // on the right side but mirrored, i.e. the first data to exit is the\ // last in the row. geom_Chip* chip_Left = ldrd2->chip(0); geom_Chip* chip_Right = ldrd2->chip(1); UInt_t l_Col = 0, r_Col = 0, lr_Row = 0; for (UInt_t i = 0; i < chip_Left->dp_Count(); i++) { // Left l_Col = i % 48; r_Col = 95 - i % 48; lr_Row = (UInt_t)(i / 48); // Put the address in linear style chip_Left->dp_Value(i) = l_Col + lr_Row * 96; chip_Right->dp_Value(i) = r_Col + lr_Row * 96; } // Gretina digitizer / 1 Ch // ------------------------ detector_List.push_back(new geom_Frame()); geom_Frame* team1 = detector_List.back(); // Hardware ID team1->HrdID(128); // FPGA-encoded hardware ID // 16 Chip team1->chip(0)->col_Count(col_Count); team1->chip(0)->row_Count(row_Count); // 1 Layer team1->layer(0)->Name("TEAM chip"); team1->layer(0)->dp_col_Count(col_Count); team1->layer(0)->dp_row_Count(row_Count); // 1 Channel team1->channel(0)->chip_Idx(0); team1->channel(0)->layer_Idx(0); // Linear geometry for every sector for (UInt_t i = 0; i < team1->channel_Count() ; i++) team1->chip(i)->dp_all_Range(i * col_Count * row_Count, 1); // Gretina digitizer / 4 Ch - Full frame // ------------------------------------- detector_List.push_back(new geom_Frame()); geom_Frame* team4 = detector_List.back(); // Hardware ID team4->HrdID(128); // FPGA-encoded hardware ID // 4 Chips: as we are reading 4 channels, the 16 real sectors are rearranged into // 4 macro sectors, each one of 1/4 of the total number of pixels team4->chip(0)->col_Count(col_Count / 4); team4->chip(0)->row_Count(row_Count); for (UInt_t i = 1; i < 4; i++) { team4->chip_Add(); team4->chip(i)->col_Count(col_Count / 4); team4->chip(i)->row_Count(row_Count); } // 1 Layer team4->layer(0)->Name("TEAM chip"); team4->layer(0)->dp_col_Count(col_Count); team4->layer(0)->dp_row_Count(row_Count); // 4 Channels team4->channel(0)->chip_Idx(0); team4->channel(0)->layer_Idx(0); for (UInt_t i = 1; i < 4; i++) team4->channel_Add(i, 0); // The data sequence from the digitizer is: // Chn: 0 1 2 3 0 1 2 3 ... 0 1 2 3 0 1 2 3 ... 0 1 2 3 0 1 2 3 0 1 2 3 ... 0 1 2 3 // Sec: 0 0 8 8 0 0 8 8 ... 0 0 8 8 0 0 8 8 ... 0 0 8 8 1 1 9 9 1 1 9 9 ... 1 1 9 9 // Row: 0 0 0 0 0 0 0 0 ... 0 0 0 0 1 1 1 1 ... k k k k 0 0 0 0 0 0 0 0 k k k k // Col: 0 1 0 1 2 3 2 3 ... 626362630 1 0 1 ... 626362630 1 0 1 2 3 2 3 ... 62636263 // Pxl: // Trhough all the expected data point per channel row_Count = team4->chip(0)->row_Count(); col_Count = team4->chip(0)->col_Count(); width = col_Count * 4; half_Width = col_Count * 2; std::cout << "defining TEAM\n"; for (Int_t y = 0; y < row_Count; y++) { for (Int_t x = 0; x < col_Count; x++) { // Debug if (y == 0) {std::cout << x * 2 << ", " << ((x*2)/64+1)*64 - (x*2)%64 - 1<< " / ";} if (y == 0) {std::cout << x * 2+1 << ", " << ((x*2+1)/64+1)*64 - (x*2+1)%64 -1<< " / ";} // Digitizer 0 team4->chip(0)->dp_Value(x, y) = y * width + ((x*2)/64+1)*64 - (x*2)%64 - 1; team4->chip(1)->dp_Value(x, y) = y * width + ((x*2+1)/64+1)*64 - (x*2+1)%64 -1; // Digitizer 1 team4->chip(2)->dp_Value(x, y) = y * width + half_Width + ((x*2) /64+1)*64 - (x*2)%64 - 1; team4->chip(3)->dp_Value(x, y) = y * width + half_Width + ((x*2+1)/64+1)*64 - (x*2+1)%64 -1; } } } //****************************************************************************** //* * //* Data acquisition functions * //* * //****************************************************************************** //______________________________________________________________________________ void task_Demo::data_Preset() { // Preset the data dbg_Print("task_Demo::data_Preset: setting DAQ", DBG_LVL_FLOW); // Info cool::Out->Print("\nData preset\n", LWHITE); // Updates the detector with the selected number of col/row in case of need if ((old_Det != cmb_Det[0]->cbox_Val()) || (old_Col != cmb_Det[2]->cbox_Val()) || (old_Row != cmb_Det[3]->cbox_Val())) { // Set off the led led_Acq[0]->Status(gui_Led::ks_Off); detector_Setup(cmb_Det[2]->cbox_Val(), cmb_Det[3]->cbox_Val()); data_Setup(detector_List[cmb_Det[0]->cbox_Val()], 1); } old_Det = cmb_Det[0]->cbox_Val(); old_Col = cmb_Det[2]->cbox_Val(); old_Row = cmb_Det[3]->cbox_Val(); // Set FPGA fpga_Setup(burst_Raw); } //______________________________________________________________________________ void task_Demo::data_Setup(geom_Frame* detector, UInt_t fr_Count) { // Setup data structures dbg_Print("task_Demo::data_Preset: assigning memory space", DBG_LVL_FLOW); cool::Out->Print("Sizing data objects\n", WHITE); // Delete if (burst_Raw) delete burst_Raw; if (frame_Noise) delete frame_Noise; if (frame_Image) delete frame_Image; if (frame_Pedestal)delete frame_Pedestal; // New burst_Raw = new data_Burst(detector, fr_Count); frame_Pedestal = new data_Frame(detector); frame_Image = new data_Frame(detector); frame_Noise = new data_Frame(detector); // Debug //std::cout << "Current detector hard ID is: " << detector->HrdID() << "\n"; } //______________________________________________________________________________ void task_Demo::fpga_Setup(data_Burst* burst) { // Comm setup dbg_Print("task_Demo::comm_Setup: setting up communication", DBG_LVL_FLOW); // Info cool::Out->Print("FPGA setup\n", LWHITE); // Step if (!cool::Comm->isOpen()) cool::Comm->Open(); // Check comm status if (!cool::Comm->isOpen()) { cool::Out->Print("You need to open communication to set FPGA!\n", LYELLOW); return; } // Set the ADCs and the clock cool::Reg->adc_clk_Chn(0); // Reference ADC clock cool::Reg->adc_clk_Div(cmb_Det[1]->cbox_Val()); // Clock divider cool::Reg->adc_Avgs(0); // No averages // Set the data trigger cool::Reg->data_trg_Mode(0); // External triggering //cool::Reg->data_trg_Count(burst_Raw->dp_Count()); // Number of data point //cool::Reg->data_trg_Delay(0); // Trigger delay //cool::Reg->data_trg_Slope(0); // Positive slope //cool::Reg->data_trg_Chn(0); // Channel 0 //cool::Reg->data_trg_Thr(2000); // Trigger threshold // Set the dummy driver UInt_t dmy_Size = (UInt_t)sqrt((Double_t)burst->frame_Fit()->chip(0)->dp_Count()); cool::Reg->acq_dmy_Size(dmy_Size); // Set the acquisition mode cool::Reg->acq_Mode(cmb_Acq[2]->cbox_Val()); // Acq(trigger) mode // Set the acquisition driver cool::Reg->acq_drv_Delay(0); // No driving delay cool::Reg->acq_drv_Sel(burst->frame_Fit()->HrdID()); // Set the driver // Set data pipeline cool::Reg->acq_data_Mode(cmb_Acq[1]->cbox_Val()); // Data source; // Set channels UInt_t chn_Count = burst->frame_Fit()->channel_Count(); UInt_t chk_Count = 0; UInt_t chn_Mask = 0; for (UInt_t i = 0; i < 4; i++) { if (chk_Adc[i]->chk_Status()) { chn_Mask += (UInt_t)(pow((double)2, (int)i)); chk_Count++; } } // Check for improprer channelsettings if (chk_Count != chn_Count) { chn_Mask = (UInt_t)(pow((double)2, (int)burst->frame_Fit()->channel_Count()) - 1); } // Shows the actually selected channels for (UInt_t i = 0; i < 4; i++) chk_Adc[i]->chk_Status(1 & chn_Mask>>i); // Sets the channel on the FPGA cool::Reg->acq_chn_Enable(chn_Mask); // Set data count for the packet builder cool::Reg->acq_frm_Count(burst->frame_Count()); // Frame data count cool::Reg->acq_dp_Count(burst->frame_Fit()->chip(0)->dp_Count()); // Total data count (per channel!) // Set data triggering mode cool::Reg->acq_trg_Mode(0); // Internal trigger cool::Reg->acq_trg_Period(1000); // 10 Hz trigger period } //______________________________________________________________________________ void task_Demo::team_Setup() { // Preset the data dbg_Print("task_Demo::team_Set: setting DAQ", DBG_LVL_FLOW); // Set up a pivot buffer Int_t buff_Count = 14; Int_t buff_Len = 16; UShort_t wr_Buff[14][16] = { // Sets clock {5, 0, 0, 0x87c2, 0x0000, 0x0002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {5, 0, 0, 0x87c2, 0x0000, 0x0003, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // Sets digitizer to send clocks to the sensor and update the DAC values. {5, 0, 0, 0x8002, 0x000A, 0x8031, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {5, 0, 0, 0x8402, 0x0012, 0x8002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {5, 0, 0, 0x8402, 0x0012, 0xA002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {5, 0, 0, 0x8402, 0x0012, 0x8002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // Selects real data from digitizers {5, 0, 0, 0x8004, 0x0000, 0x0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {5, 0, 0, 0x8404, 0x0000, 0x0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // Sets image size (64 columns per output and 1024 rows, the full sector) {5, 0, 0, 0x800c, 0x0140, 0x0400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {5, 0, 0, 0x840c, 0x0140, 0x0400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // Sets APS clock speed {5, 0, 0, 0x800d, 0x0000, 0x0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {5, 0, 0, 0x840d, 0x0000, 0x0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // Sets image size on V4 (here it is 1024 * 1024) {5, 0, 0, 0x8803, 0x0400, 0x0400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // Sets DataNConfig {5, 0, 0, 0x8802, 0x0000, 0x0045, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; // Sets the other control cmb_Acq[1]->cbox_Val(4); // Data Mode cmb_Det[0]->cbox_Val(4); // Gretina 4 ch cmb_Det[1]->cbox_Val(4); // 3 MHz clock cmb_Det[2]->cbox_Val(4096); // Cols cmb_Det[3]->cbox_Val(1024); // Rows // Sends the buffer for (UInt_t i = 0; i < buff_Count; i++) cool::Comm->raw_Write(wr_Buff[i], &buff_Len); // Check readback //cool::Out->Print("Check readback\n", WHITE); //UShort_t rd_Buff[16]; //for (UInt_t i = 0; i < buff_Count; i++) { // wr_Buff[i][3] = wr_Buff[i][3] + 0x4000; // cool::Comm->raw_Write(wr_Buff[i], &buff_Len); // cool::Comm->raw_Read(rd_Buff, &buff_Len); // std::cout << std::hex << wr_Buff[i][3] << ": "; // for (UInt_t i = 0; i < buff_Len; i++) std::cout << rd_Buff[i] << ", "; // std::cout << "\n"; //} // TEAM mode set! cool::Out->Print("TEAM mode set\n", LWHITE); } //______________________________________________________________________________ void task_Demo::data_Pedestal() { // Acquire the pedestals dbg_Print("task_Demo::data_Pedestal: acquiring pedestals", DBG_LVL_FLOW); // Info cool::Out->Print("Taking pedestals\n", LWHITE); // Clear the led! led_Acq[0]->Status(gui_Led::ks_Off); // Run n times and add UInt_t runs =(UInt_t) num_Acq[1]->num_Val(); std::cout << runs << "\n"; // Blank the data data_Preset(); // Sum for (UInt_t i = 0; i < runs; i++) { // Check the button if (!btn_Acq[1]->btn_Status()) break; // Retrieves the data data_Acquire(ka_Ped); // Sum up *(frame_Pedestal) += *(burst_Raw->frame(0)); // Lit the led once the run is complete if (i == (runs - 1)) led_Acq[0]->Status(gui_Led::ks_On); } // Clear button btn_Acq[1]->btn_Status(false); // Averages and noise frame_Pedestal->dp_all_Div(runs); // Show map_Signal->data_Set(frame_Pedestal->layer(0)); map_Signal->range_Auto(true); cool::Out->Print("Pedestals done\n", LWHITE); } //______________________________________________________________________________ void task_Demo::data_Acquire(UInt_t acq_Mode) { // Acquire the data dbg_Print("task_Demo::data_Acquire: retriving data from DAQ", DBG_LVL_FLOW); //************ // Updates the detector with the selected number of col/row //detector_Setup(cmb_Det[2]->cbox_Val(), cmb_Det[3]->cbox_Val()); // Fit data structures //Int_t gfId = cmb_Det[0]->cbox_Val(); //data_Setup(detector_List[gfId], 1); //fpga_Setup(burst_Raw); // Fit and Setup maps map_Signal->data_Set(frame_Image->layer(0)); map_Signal->data_Refresh(true, true); map_Signal->range_Auto(true); //*********** // acq_Mode values: ka_Std = standard // ka_Ped = pedestal // ka_Grt = Gretina/TEAM // Acq type if (acq_Mode != ka_Ped) cool::Out->Print("ACQ started!\n", LWHITE); // DDR Memory // ---------- /* // This sets up the DDR memory cool::Reg->ddr_Cmd(0x01); // Data mode selection cool::Reg->ddr_Data(0x00); // Put the DDR in real data mode cool::Reg->ddr_Cmd(0x02); // Input FIFO selection cool::Reg->ddr_Data(0x00); // FIFO input are real data cool::Reg->ddr_Cmd(0x04); // Output FIFO input selection cool::Reg->ddr_Data(0x00); // Data from the DDR // Memory size: 4 pages, 8196 rows each page, 64 cg each row // where 1 cg = 32 * 8 bits = 32 byte = 16 word // considering 4 mandatory pages, and a minimum write/read lenght // of 1 row, the minimum amount of data is 64 * 32 * 4 = 8192 bytes, // or 4096 words // Less than 1024 points, they will stay in a row UInt_t dp_Count = burst_Raw->frame_Fit()->chip(0)->dp_Count(); dp_Count = burst_Raw->dp_Count(); std::cout << "burst_Raw->dp_Count = " << dp_Count << "\n"; UInt_t ddr_cg_Count = 63; UInt_t ddr_row_Count = 1; //(UInt_t)floor((double)dp_Count / 4096); // Debug info std::cout << "DDR row_Count = " << ddr_row_Count << "\n"; std::cout << "DDR cg_Count = " << ddr_cg_Count << "\n"; std::cout << "DDR set capacity = " << 4 * (ddr_row_Count + 1) * (ddr_cg_Count + 1) * 16 << " word/px\n"; cool::Reg->ddr_Cmd(0x08); // Set DDR number of row cool::Reg->ddr_Data(ddr_row_Count); // Data from the DDR cool::Reg->ddr_Cmd(0x09); // Set DDR number of bursts per row (each burst 256 bit) cool::Reg->ddr_Data(ddr_cg_Count); // Data from the DDR */ // This is for the Gretina control (5 is the Gretina ID in the USB chain), // It sends the start bit to the gretina controller UShort_t wr_Buff[16] = {5, 0, 0, 0x8801, 0x000, 0x0001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; Int_t wr_Len = 16; // Acquisition mode UInt_t burst_Count; UInt_t burst_Inc; // Acquisition if (cmb_Acq[0]->cbox_Val() == 0) { burst_Count = 1; burst_Inc = 1; } else if (cmb_Acq[0]->cbox_Val() == 1) { burst_Count = 1; burst_Inc = 0; } else { burst_Count = (UInt_t)num_Acq[1]->num_Val(); burst_Inc = 1; } // Timing references clock_t start = clock(); clock_t stop = clock(); Double_t elapsed; // This is the (strongly) suggested way to get data from the firmware. It // uses the multithreaded call to burst_Read, allowing for if (cool::Comm->isOpen()) { // Main acquisition loop for (UInt_t i = 0 ; i < burst_Count; i+= burst_Inc) { // Check the button status if (!btn_Acq[0]->btn_Status() && acq_Mode != ka_Ped) break; // Launch the read thread, the 'false' indicating a do not wait mode if (acq_Mode != ka_Ped) std::cout << "Starting the burst read...\n"; cool::Comm->burst_Read(burst_Raw, false, 200); // If Gretina is the target, trigger the gretina sync bit! if (cmb_Det[0]->cbox_Val() >= 3) { std::cout << "Sending gretina start bit...\n"; cool::Comm->raw_Write(wr_Buff, &wr_Len); // Wait for the read thread to be correctly launched } else { Sleep(50); } // Wait until the read request has been completed completed. Here // we are just waiting, but one could/should use this time to // perform data processing or others tasks. while (cool::Comm->burst_read_Status() != cool::Comm->kbr_Free) { // Use this to process the GUI events pipeline gSystem->ProcessEvents(); // Frees (milliseconds) CPU time. Values between (10 - 50) are // usually ok to give good user feedback. Sleep(50); } // Example: check the end status of the burst read. Note that this flag // value is also returned by 'burst_Read()' itself when used with the // 'wait' parameter set to 'true' switch (cool::Comm->burst_read_Exited()) { case cool::Comm->kbr_Free: break; // Everything fine! case cool::Comm->kbr_Missed: cool::Out->Print("No communication!\n",L + RED); break; // Error case cool::Comm->kbr_Timeout: cool::Out->Print("Timeout occurred!\n",L + RED); break; // Error case cool::Comm->kbr_Error: cool::Out->Print("Packet mismatch!\n", L + RED); break; // Error std::cout << "Something wrong!\n"; } // Shows if (acq_Mode != ka_Ped) { if (cool::Comm->burst_read_Exited() == cool::Comm->kbr_Free) { // Perform data copy or/nad pedestal subtraction in case std::cout << "Swapping image\n"; if (acq_Mode == ka_PedSub) { //*frame_Image = (*(burst_Raw->frame(0)) - *frame_Pedestal); UInt_t count = burst_Raw->frame(0)->layer(0)->dp_Count(); Int_t* img = frame_Image->layer(0)->dp_Front(); Int_t* ped = frame_Pedestal->layer(0)->dp_Front(); UShort_t* raw = burst_Raw->frame(0)->layer(0)->dp_Front(); for (UInt_t i = 0; i < count; i++) img[i] = (Int_t)(raw[i]) - ped[i]; //frame_Image->layer(0)->dp_all_Range(-10, 1); } else { *frame_Image = *(burst_Raw->frame(0)); } // Refresh the map map_Signal->data_Set(frame_Image->layer(0)); //map_Signal->data_Set(burst_Raw->frame(0)->layer(0)); //std::cout << "All OK\n"; map_Signal->data_Refresh(); } elapsed = (double)(clock() - stop) / CLOCKS_PER_SEC; std::cout << "Frame #" << i << " (" << elapsed << ") Exit status: " << cool::Comm->burst_read_Exited() << "\n"; } stop = clock(); // Anyway, allow the g-system to refresh, and to the user to interact gSystem->ProcessEvents(); Sleep(10); } } else { cool::Out->Print("\nDemo: You need to open communication!\n", LYELLOW); //burst_Raw->dp_all_Range(0, 1); //map_Signal->data_Refresh(); } // Some standard acq procedures elapsed = (double)(stop - start) / CLOCKS_PER_SEC; if (acq_Mode != ka_Ped) { std::cout << "\n"; cool::Out->Print(burst_Count); cool::Out->Print(" burst(s): "); cool::Out->Print(elapsed, LWHITE, true); cool::Out->Print("Speed: "); cool::Out->Print((burst_Count * burst_Raw->dp_Count() * 2) / (elapsed * 1024 * 1024)); cool::Out->Print(" MB/s\n"); // Reset the button btn_Acq[0]->btn_Status(false); // Shows data commitment std::cout << "\nTotal allocated data: " << data_Object::stc_data_Size() / 1024 << " kBytes\n"; //std::cout << "raw_Burst data:" << burst_Raw->dp_Size() / 1024 << " kBytes\n"; } }