diff --git a/CPU/CPUsoftware/src/instrument/RunInstrument.cpp b/CPU/CPUsoftware/src/instrument/RunInstrument.cpp index d7872c72..8865d03a 100755 --- a/CPU/CPUsoftware/src/instrument/RunInstrument.cpp +++ b/CPU/CPUsoftware/src/instrument/RunInstrument.cpp @@ -158,7 +158,8 @@ int RunInstrument::DebugMode() { std::cout << std::endl; std::cout << "running checks of all subsystems..." <Usb.LookupUsbStorage(); std::cout << "there are " << num_usb_storage << " USB storage devices connected" << std::endl; @@ -233,25 +234,32 @@ int RunInstrument::DebugMode() { std::cout << "Zynq OFF " << std::endl; this->Lvps.SwitchOff(LvpsManager::ZYNQ); std::cout << "done!" << std::endl; - + */ + /* check the available disk space */ + /* const char * cmd1 = "df -h"; std::string output1 = CpuTools::CommandToStr(cmd1); std::cout << "Checking disk space: " << std::endl; std::cout << output1 << std::endl; clog << "info: " << logstream::info << "Checking disk space:" << std::endl; clog << "info: " << logstream::info << output1 << std::endl; - + */ + /* check CPU usage */ + /* const char * cmd2 = "top -d 5 -b -n1 | grep \"load average\" -A 15"; std::string output2 = CpuTools::CommandToStr(cmd2); std::cout << "Checking CPU usage: " << std::endl; std::cout << output2 << std::endl; clog << "info: " << logstream::info << "Checking CPU usage:" << std::endl; clog << "info: " << logstream::info << output2 << std::endl; + */ + + /* test new DAC10 commands */ + std::string path(USB_MOUNTPOINT_0); + this->Zynq.SetMatrixDac10(path, false); - std::cout << "debug tests completed, exiting the program" << std::endl; - return 0; } @@ -973,6 +981,14 @@ int RunInstrument::NightOperations() { std::cout << "waiting for boot..." << std::endl; this->CheckStatus(); + /* setup the Zynq */ + clog << "info: " << logstream::info << "setting up Zynq with DAC 10 tables and trigger mask" << std::endl; + std::string usb_str(USB_MOUNTPOINT_0); + { + std::unique_lock lock(this->Zynq.m_zynq); + this->Zynq.Setup(usb_str); + } + /* set hidden pixels */ if (this->CmdLine->hide_pixel == true) { { diff --git a/CPU/CPUsoftware/src/subsystems/ZynqManager.cpp b/CPU/CPUsoftware/src/subsystems/ZynqManager.cpp index bda97437..621c8246 100755 --- a/CPU/CPUsoftware/src/subsystems/ZynqManager.cpp +++ b/CPU/CPUsoftware/src/subsystems/ZynqManager.cpp @@ -360,6 +360,85 @@ int ZynqManager::Reboot() { } +/** + * Set the ASIC DAC10 values from a text file provided by the USB. + * Adapted from C. Giammanco's script to use socket programming instead of netcat. + */ +int ZynqManager::SetMatrixDac10(std::string usb_mountpoint, bool debug) { + + std::string dac10_filename; + std::vector dac10_values; + + dac10_filename = usb_mountpoint + ZYNQ_SETUP_SUBDIR + "/" + MATRIX_DAC_10; + + /* read values */ + if (debug == true) { + + /* set all values to 200 for testing */ + for (int i=0; iSetMatrixDac10(setup_script_path, false); + + return 0; +} + /** * check the HV status diff --git a/CPU/CPUsoftware/src/subsystems/ZynqManager.h b/CPU/CPUsoftware/src/subsystems/ZynqManager.h index 9583b3d4..ae39cfb1 100755 --- a/CPU/CPUsoftware/src/subsystems/ZynqManager.h +++ b/CPU/CPUsoftware/src/subsystems/ZynqManager.h @@ -32,10 +32,17 @@ /* for use with HV interface functions */ #define N_EC 9 +#define N_PMT 36 +#define N_ASIC 6 /* time between consecutive telnet commands in mus */ #define SLEEP_TIME 500000 +/* location of Zynq setup files */ +#define ZYNQ_SETUP_SUBDIR "/automated_boot" +#define MATRIX_DAC_10 "dac10.txt" + + /** * class to handle the Zynq interface. * commands and information are sent and received over telnet @@ -143,6 +150,8 @@ class ZynqManager { static std::string GetZynqVer(); int InstrumentClean(); int Reboot(); + int SetMatrixDac10(std::string usb_mountpoint, bool debug); + int Setup(std::string setup_script_path); private: diff --git a/CPU/CPUsoftware/src/tools/CpuTools.cpp b/CPU/CPUsoftware/src/tools/CpuTools.cpp index 78b2a0cb..2fc56432 100755 --- a/CPU/CPUsoftware/src/tools/CpuTools.cpp +++ b/CPU/CPUsoftware/src/tools/CpuTools.cpp @@ -261,3 +261,31 @@ uint32_t CpuTools::BuildCpuTimeStamp() { return timestamp; } + +/** + * read the DAC10 matrix file into a vector + */ +std::vector CpuTools::ReadMatrixDac10(std::string dac10_filename) { + + std::vector output; + + std::ifstream matrix(dac10_filename, std::ios::in); + int number; + + while(matrix >> number){ + + output.push_back(number); + + } + + if(output.size() != 36){ + + /* debug */ + std::cout << "ERROR: file \"" << dac10_filename << "\" is out of format. Check number of elements." << std::endl; + return output; + + } + matrix.close(); + + return output; +} diff --git a/CPU/CPUsoftware/src/tools/CpuTools.h b/CPU/CPUsoftware/src/tools/CpuTools.h index e7dd0bfd..14dcf802 100755 --- a/CPU/CPUsoftware/src/tools/CpuTools.h +++ b/CPU/CPUsoftware/src/tools/CpuTools.h @@ -42,7 +42,7 @@ class CpuTools { static std::streampos FileSize(std::string file_path); static uint32_t BuildCpuHeader(uint32_t type, uint32_t ver); static uint32_t BuildCpuTimeStamp(); - + static std::vector ReadMatrixDac10(std::string dac10_filename); }; diff --git a/minieuso_data_format/minieuso_data_format.h b/minieuso_data_format/minieuso_data_format.h index f45c0a0a..327197e6 100644 --- a/minieuso_data_format/minieuso_data_format.h +++ b/minieuso_data_format/minieuso_data_format.h @@ -19,8 +19,8 @@ * software definitions */ -#define VERSION 8.5 -#define VERSION_DATE_STRING "18/02/2020" +#define VERSION 8.8 +#define VERSION_DATE_STRING "09/03/2020" /* * instrument definitions