diff --git a/include/trick/IPPython.hh b/include/trick/IPPython.hh index 57378123..72c429f2 100644 --- a/include/trick/IPPython.hh +++ b/include/trick/IPPython.hh @@ -36,7 +36,8 @@ namespace Trick { /** Returned value from event condition evaluation.\n */ int return_val ; /**< trick_io(**) trick_units(--) */ - /** Input processor mutex for protection for var server and event processing.\n */ pthread_mutex_t ip_mutex; /**< trick_io(**) trick_units(--) */ + /** Input processor mutex for protection for var server and event processing.\n */ + pthread_mutex_t ip_mutex; /**< trick_io(**) trick_units(--) */ /** @brief Constructor. @@ -48,6 +49,16 @@ namespace Trick { */ void get_TMM_named_variables() ; + /** + @brief Get the status of the units conversion message flag + */ + bool get_units_conversion_msgs() ; + + /** + @brief Setting to see units conversions warnings + */ + void shoot_the_units_conversion_messenger(bool onoff) ; + /** @brief Initialize and run the Python input processor on the user input file. */ @@ -75,6 +86,11 @@ namespace Trick { @return always 0 */ int restart() ; + + protected : + /** false = see units conversion messages, true = head in sand */ + bool units_conversion_msgs ; + } ; } @@ -82,6 +98,12 @@ namespace Trick { extern "C" { //SWIG generated routine. void init_swig_modules(void) ; + +/* Call this if you you refuse to fix your units problems and want to shoot the messenger instead */ +void shoot_the_units_conversion_messenger() ; +void revive_the_units_conversion_messenger() ; + +int check_units_conversion_messenger_for_signs_of_life() ; } #endif diff --git a/trick_source/sim_services/InputProcessor/IPPython.cpp b/trick_source/sim_services/InputProcessor/IPPython.cpp index 4d2fd02f..5217afe6 100644 --- a/trick_source/sim_services/InputProcessor/IPPython.cpp +++ b/trick_source/sim_services/InputProcessor/IPPython.cpp @@ -25,8 +25,7 @@ Trick::IPPython * the_pip ; //Constructor -Trick::IPPython::IPPython() : Trick::InputProcessor::InputProcessor() { - +Trick::IPPython::IPPython() : Trick::InputProcessor::InputProcessor() , units_conversion_msgs(true) { the_pip = this ; return ; } @@ -67,6 +66,14 @@ void Trick::IPPython::get_TMM_named_variables() { } } +bool Trick::IPPython::get_units_conversion_msgs() { + return units_conversion_msgs ; +} + +void Trick::IPPython::shoot_the_units_conversion_messenger(bool onoff) { + units_conversion_msgs = !onoff ; +} + //Initialize and run the Python input processor on the user input file. int Trick::IPPython::init() { /** @par Detailed Design: */ @@ -193,3 +200,14 @@ int Trick::IPPython::shutdown() { return(0) ; } +void shoot_the_units_conversion_messenger() { + the_pip->shoot_the_units_conversion_messenger(true) ; +} + +void revive_the_units_conversion_messenger() { + the_pip->shoot_the_units_conversion_messenger(false) ; +} + +int check_units_conversion_messenger_for_signs_of_life() { + return the_pip->get_units_conversion_msgs() ; +} diff --git a/trick_source/trick_swig/units_attach.i b/trick_source/trick_swig/units_attach.i index 6dde6ecb..bcb01ad2 100644 --- a/trick_source/trick_swig/units_attach.i +++ b/trick_source/trick_swig/units_attach.i @@ -9,6 +9,7 @@ #include #include "trick/swig/swig_double.hh" #include "trick/map_trick_units_to_udunits.hh" +#include "trick/IPPython.hh" %} @@ -50,8 +51,10 @@ PyObject * attach_units(PyObject * in_units_obj , PyObject * in_object) { line_no = PyFrame_GetLineNumber(tstate->frame) ; #endif } - std::cout << "\033[33mUnits converted from [" << in_units << "] to [" << new_units << "] " - << file_name << ":" << line_no << "\033[0m" << std::endl ; + if ( check_units_conversion_messenger_for_signs_of_life() ) { + std::cout << "\033[33mUnits converted from [" << in_units << "] to [" << new_units << "] " + << file_name << ":" << line_no << "\033[0m" << std::endl ; + } in_units = new_units ; } }