//------------------------------------------------------------------------------ // MAIN SCRIPT FUNCTIONS //------------------------------------------------------------------------------ // MCB external input settings bool _mcbExtSpillEn = true; bool _mcbExtSpillInv = false; // slots allocation const byte _BOARD_ID_MCB = 0; const byte _BOARD_ID_START = 0; const byte _BOARD_ID_STOP = 2; const byte _BOARD_ID_FBW = 2; const byte _NB_SLOTS = _BOARD_ID_STOP-_BOARD_ID_START+1; void ScriptMain() { Console.WriteLine("Script begins..."); // DAQ const int _DAQ_TIME = 19000; // in ms const int _FILE_LIMIT = 10000; string l_daqFile = "G:/TEMP/AIDA/HW_TEST/TEMP/FULL/gbit-full-slot2"; // parameters bool l_monitoring = true; // Allows DAQ with real time plots monitoring : you must also enable the Monitoring Queue in the DAQ area bool l_enableReadoutOnSpillGate = true; bool l_enableGtrigOnlyOnSpill = true; bool l_syncResetEn = true; // enable Spill & GTRIG time/tag counters bool l_enableGtrig = true; // DAQ will see the GTRIG beacons, set it to false if you want only amplitude for histograms bool l_toCsv = false; // want the csv conversion UInt64 l_toCsvWords = 0; // limit the nb of words to convert, set to 0 for all bool l_gtrigSpillCheck = true; // want the GTRIG & SPILL check //----------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------- // --- fill there the config file names. If only one for all boards, just put 1, else put the exact number of boards // --- single MCR with a common cfg file for all slots : string l_cfgfilenameMCR = "G:/TEMP/AIDA/HW_TEST/CFG/PDdiscri-A0-CH0-extclk"; string l_cfgfilenameFBW = "G:/TEMP/AIDA/HW_TEST/CFG/PDdiscri-A0-CH0-extclk"; //------------------------------------------------------------------------------ Console.WriteLine("---------------------------------------------------"); Console.WriteLine("This will launch the FULL BANDWIDTH DAQ for slot " + _BOARD_ID_STOP + " trough GTX with " + _NB_SLOTS + " boards in the chain"); Console.WriteLine("---------------------------------------------------"); Console.WriteLine(); //------------------------------------------------------------------------------ Console.WriteLine("----------------------------------"); Console.WriteLine("Configure MCB FEB & FBW..."); // fill there the config file names. If only one for all boards, just put 1, else put the exact number of boards App.FBWPrepareDaq(_BOARD_ID_MCB, _BOARD_ID_MCB, _BOARD_ID_FBW, l_cfgfilenameMCR, _BOARD_ID_MCB, l_enableGtrig, l_enableGtrigOnlyOnSpill, l_enableReadoutOnSpillGate, l_syncResetEn, x_beforeConfigure:beforeConfigure); //------------------------------------------------------------------------------ Console.WriteLine("----------------------------------"); Console.WriteLine("Prepare SYNC on SLOT0, 1 & 2 ..."); App.ChainSetCheckSyncAndGtx(_BOARD_ID_START, _BOARD_ID_STOP); //------------------------------------------------------------------------------ Console.WriteLine("----------------------------------"); Console.WriteLine("prepare FBW DAQ of all MCR"); App.FBWPrepareDaq(_BOARD_ID_START, _BOARD_ID_STOP, _BOARD_ID_FBW, l_cfgfilenameFBW, _BOARD_ID_MCB, l_enableGtrig, l_enableGtrigOnlyOnSpill, l_enableReadoutOnSpillGate, l_syncResetEn, x_beforeConfigure:beforeConfigure); //------------------------------------------------------------------------------ Console.WriteLine("----------------------------------"); Console.WriteLine("DAQ on FBW slot with USB on SLOT0"); // only FBW HV on App.ChainSetHV(_BOARD_ID_FBW, _BOARD_ID_FBW, true); Sync.Sleep(200); // allow HV on to be established BoardLib.SetVariable("Board.UsbParam.FileLimit", _FILE_LIMIT); App.FBWStartDaq(_BOARD_ID_START, _BOARD_ID_FBW, l_daqFile, _BOARD_ID_MCB, x_monitoring:l_monitoring); //------------------------------------------------------------------------------ // DAQ is now started Console.WriteLine("----------------------------------"); Console.WriteLine("DAQ started for " + _DAQ_TIME/1000 + "s and limited to " + _FILE_LIMIT/1000 + "Mo"); const int _SLEEP_TIME = 50; //ms int l_timeEnd = _DAQ_TIME/_SLEEP_TIME; int l_sleepCnt = 0; while ((l_sleepCnt < l_timeEnd) && (BoardLib.IsTransferingData)) { Sync.Sleep(_SLEEP_TIME); l_sleepCnt++; } //------------------------------------------------------------------------------ //----- STOP DAQ --------- Console.WriteLine("----------------------------------"); Console.WriteLine("Stop DAQ"); App.FBWStopDaq(); Sync.SleepUntil(()=>!BoardLib.IsTransferingData); Console.WriteLine(""); Console.WriteLine("DAQ Total Time (hh:mm:ss): " + BoardLib.ElapsedTime); Console.WriteLine("DAQ Total KBytes: " + BoardLib.XferKBytes); Console.WriteLine("DAQ Xfer rate (KB/s): Avg=" + BoardLib.AvgXferRate + " / Max=" + BoardLib.MaxXferRate); Console.WriteLine(""); Sync.Sleep(500); // allow DAQ stop thread to be finished //------------------------------------------------------------------------------ //----- HV OFF --------- Console.WriteLine("----------------------------------"); Console.WriteLine("Stop HV"); App.ChainSetHV(_BOARD_ID_START, _BOARD_ID_FBW, false); Sync.Sleep(50); //------------------------------------------------------------------------------ Console.WriteLine("----------------------------------"); Console.WriteLine("DAQ to CSV & GTRIG check"); if(l_gtrigSpillCheck) { App.GtrigAndSpillCheck(l_daqFile); Console.WriteLine(""); } if(l_toCsv) { App.DaqToCsv(l_daqFile, l_toCsvWords); Console.WriteLine(""); } // We're done! Console.WriteLine("Script ended"); } // function called between BoardLib.OpenConfigFile() and BoardLib.BoardConfigure() in App.FBWPrepareDaq() void beforeConfigure(byte x_boardId) { if(x_boardId == _BOARD_ID_MCB) { Console.WriteLine("MCB Additionnal configure called with BoardId = " + x_boardId); BoardLib.SetVariable("FPGA.GlobalControl.MCBExtSpillGateEn", _mcbExtSpillEn); BoardLib.SetVariable("FPGA.GlobalControl.MCBExtSpillGateInv", _mcbExtSpillInv); }else { Console.WriteLine("Additionnal configure called with BoardId = " + x_boardId); } } // this function (if declared) will be called upon abort request from the user void ScriptAbort() { Console.WriteLine("Script Aborted : stop HV..."); App.ChainSetHV(_BOARD_ID_START, _BOARD_ID_FBW, false); }