88 * CTerminal. Pixie16 data acquisition is handled by interfacing
99 * with the PixieInterface library.
1010 *
11- * \author Cory R. Thornsberry
11+ * \author Karl Smith, Robert Grzywacz, David Miller, and Cory R. Thornsberry
1212 *
13- * \date Oct. 6th, 2015
13+ * \date Apr. 25th, 2017
1414 *
15- * \version 1.3.10
15+ * \version 1.3.11
1616*/
1717
1818#include < algorithm>
5151// Adjusted to help alleviate the issue with data corruption
5252#define POLL_TRIES 100
5353
54- // 4 GB. Maximum allowable .ldf file size in bytes
55- #define MAX_FILE_SIZE 4294967296ll
54+ // 2 GB. Maximum allowable .ldf file size in bytes
55+ #define MAX_FILE_SIZE 2147483648ll
5656
5757// Length of shm packet header (in bytes)
5858#define PKT_HEAD_LEN 8
@@ -90,7 +90,7 @@ const std::vector<std::string> Poll::runControlCommands_ ({"run", "stop",
9090
9191const std::vector<std::string> Poll::paramControlCommands_ ({" dump" , " pread" ,
9292 " pmread" , " pwrite" , " pmwrite" , " adjust_offsets" , " find_tau" , " toggle" ,
93- " toggle_bit" , " csr_test" , " bit_test" , " get_traces" });
93+ " toggle_bit" , " csr_test" , " bit_test" , " get_traces" , " save " });
9494
9595const std::vector<std::string> Poll::pollStatusCommands_ ({" status" , " thresh" ,
9696 " debug" , " quiet" , " quit" , " help" , " version" });
@@ -466,6 +466,7 @@ int Poll::write_data(word_t *data, unsigned int nWords){
466466 }
467467
468468 // Handle the writing of buffers to the file
469+ // 65552 = 8194 * 4 * 2 , 2 EOF buffers are need 8194 words at 4 bytes per word
469470 std::streampos current_filesize = output_file.GetFilesize ();
470471 if (current_filesize + (std::streampos)(4 *nWords + 65552 ) > MAX_FILE_SIZE){
471472 // Adding nWords plus 2 EOF buffers to the file will push it over MAX_FILE_SIZE.
@@ -657,6 +658,7 @@ void Poll::help(){
657658 std::cout << " toggle_bit <mod> <chan> <param> <bit> - Toggle any bit of any parameter of 32 bits or less\n " ;
658659 std::cout << " csr_test <number> - Output the CSRA parameters for a given integer\n " ;
659660 std::cout << " bit_test <num_bits> <number> - Display active bits in a given integer up to 32 bits long\n " ;
661+ std::cout << " save [setFilename] - Writes the DSP Parameters to [setFileName] (default='active .set from pixie_cfg')\n " ;
660662 std::cout << " get_traces <mod> <chan> [threshold] - Get traces for all channels in a specified module\n " ;
661663 std::cout << " status - Display system status information\n " ;
662664 std::cout << " thresh [threshold] - Modify or display the current polling threshold.\n " ;
@@ -667,6 +669,11 @@ void Poll::help(){
667669 std::cout << " version (v) - Display Poll2 version information\n " ;
668670}
669671
672+ void Poll::save_help () {
673+ std::cout << " Saves the DSP parameters to disk. Optionally, a file can be"
674+ " provided, otherwise the file set file from pixie.cfg is used.\n " ;
675+ }
676+
670677/* Print help dialogue for reading/writing pixie channel parameters. */
671678void Poll::pchan_help (){
672679 std::cout << " Valid Pixie16 channel parameters:\n " ;
@@ -1092,11 +1099,10 @@ void Poll::CommandControl(){
10921099 }
10931100
10941101 ParameterChannelWriter writer;
1095- bool error = false ;
1102+
10961103 if (forChannel (pif, modStart, modStop, chStart, chStop, writer, make_pair (arguments.at (2 ), value))){
1097- error = true ;
1098- }
1099- if (!error) pif->SaveDSPParameters ();
1104+ pif->SaveDSPParameters ();
1105+ }
11001106 }
11011107 else {
11021108 std::cout << sys_message_head << " Invalid number of parameters to pwrite\n " ;
@@ -1141,6 +1147,27 @@ void Poll::CommandControl(){
11411147 }
11421148 }
11431149 }
1150+ else if (cmd == " save" ) {
1151+ if (acq_running || do_MCA_run){
1152+ std::cout << sys_message_head << " Warning! Cannot view pixie parameters while acquisition is running\n\n " ;
1153+ continue ;
1154+ }
1155+ if (p_args > 0 && arguments.at (0 ) == " help" ){
1156+ save_help ();
1157+ continue ;
1158+ }
1159+ if (p_args == 0 ) {
1160+ pif->SaveDSPParameters ();
1161+ }
1162+ else if (p_args == 1 ) {
1163+ pif->SaveDSPParameters (arguments.at (0 ).c_str ());
1164+ }
1165+ else {
1166+ std::cout << sys_message_head << " Invalid number of parameters to save\n " ;
1167+ std::cout << sys_message_head << " -SYNTAX- save [setFilename]\n " ;
1168+ continue ;
1169+ }
1170+ }
11441171 else if (cmd == " pread" || cmd == " pmread" ){ // Read pixie parameters
11451172 if (acq_running || do_MCA_run){
11461173 std::cout << sys_message_head << " Warning! Cannot view pixie parameters while acquisition is running\n\n " ;
0 commit comments