//------------------------------------------------------------------------------ // MAIN SCRIPT FUNCTIONS //------------------------------------------------------------------------------ //----------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------- // --- fill here the config file name, just one in the array string[] _cfgfilename = {"G:/TEMP/CTA/PDdiscri-A0-CH0-5-25-31"}; // --- fill here the board ID array const byte MCB_BOARD_ID = 0; byte[] _boardIds = {MCB_BOARD_ID, 2}; void ScriptMain() { Console.WriteLine("Script begins..."); // DAQ parameters, will stop on DAQ time reached or File Limit reached const int _DAQ_TIME = 20000; // in ms const int _FILE_LIMIT = 30000; //in Ko string l_daqFile = "G:/TEMP/CTA/Data/test"; // Readout parameters bool l_enableReadoutOnSpillGate = false; // no spill, continuous DAQ mode bool l_enableGtrigOnlyOnSpill = false; // continuous GTRIG bool l_syncResetEn = true; // enable Spill & GTRIG time/tag counters reset bool l_enableGtrig = true; // DAQ will see the GTRIG beacons, set it to false if you want only amplitude for histograms //------------------------------------------------------------------------------ Console.WriteLine("---------------------------------------------------"); Console.WriteLine("This will launch the TDM DAQ for MCB on slot 0 & SLAVE on slot 2 trough GTX chain"); Console.WriteLine("---------------------------------------------------"); Console.WriteLine(); //----------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------ Console.WriteLine("----------------------------------"); Console.WriteLine("Configure Master Clock FEB & TDM..."); // single MCR config file is mandatory for the master clock in order to enable CLK & SYNC signals first App.TDMPrepareDaq(MCB_BOARD_ID, MCB_BOARD_ID, _cfgfilename, MCB_BOARD_ID, l_enableGtrig, l_enableGtrigOnlyOnSpill, l_enableReadoutOnSpillGate, l_syncResetEn, x_beforeConfigure:beforeConfigure); Console.WriteLine("Succeeded\n"); //------------------------------------------------------------------------------ Console.WriteLine("----------------------------------"); Console.WriteLine("Prepare SYNC on slave slots"); App.ChainSetCheckSyncAndGtx(_boardIds); Console.WriteLine("Succeeded\n"); //------------------------------------------------------------------------------ Console.WriteLine("----------------------------------"); Console.WriteLine("prepare DAQ from last slot to USB slot 0"); App.TDMPrepareDaq(_boardIds, _cfgfilename, MCB_BOARD_ID, l_enableGtrig, l_enableGtrigOnlyOnSpill, l_enableReadoutOnSpillGate, l_syncResetEn, x_beforeConfigure:beforeConfigure); Console.WriteLine("Succeeded\n"); //------------------------------------------------------------------------------ Console.WriteLine("----------------------------------"); Console.WriteLine("Starting DAQ on all slot with USB on SLOT0"); BoardLib.SetVariable("Board.UsbParam.FileLimit", _FILE_LIMIT); App.TDMStartDaq(_boardIds, l_daqFile, MCB_BOARD_ID); //------------------------------------------------------------------------------ // 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.TDMStopDaq(); 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 // We're done! Console.WriteLine("Script ended"); } // function called between BoardLib.OpenConfigFile() and BoardLib.BoardConfigure() in App.TDMPrepareDaq() void beforeConfigure(byte x_boardId, byte x_cfgFileIndex) { if(x_boardId == MCB_BOARD_ID) { Console.WriteLine("MCB Additionnal configure called with BoardId = " + x_boardId); // insert here the variables you want to modify for MCB slot // ... }else { Console.WriteLine("Additionnal configure called with BoardId = " + x_boardId); // insert here the variables you want to modify for slot 2 // ... } Console.WriteLine(""); } // this function (if declared) will be called upon abort request from the user void ScriptAbort() { Console.WriteLine("Script Aborted, extra code executed..."); // insert here extra code called when an user script abort is requested // ... }