diff --git a/.gitignore b/.gitignore index e68000d7..8f45bde9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ bin/trick-fxplot bin/trick-gxplot bin/trick-trk2ascii bin/trick-trk2csv +bin/trick-trkConvert aclocal.m4 autom4te.cache trick_test diff --git a/Makefile b/Makefile index c38b3a2a..ba43b81c 100644 --- a/Makefile +++ b/Makefile @@ -343,7 +343,20 @@ ${ER7_HEADERS} : ${PREFIX}/include/% : trick_source/% install -m 0644 $? $@ install: ${ER7_HEADERS} + @if [ ! -d ${TRICK_LIB_DIR} ]; then \ + make; \ + fi + + @if [ ${PREFIX} = "/usr/local" ]; then \ + if [[ $EUID -ne 0 ]]; then \ + echo -e "\n\e[31mInstalling Trick to /usr/local, the default installation location, requires super user privileges."; \ + echo -e "Please log in as a super user to continue.\e[0m\n"; \ + exit 1; \ + fi; \ + fi + cp -r bin include $(notdir ${TRICK_LIB_DIR}) libexec share ${PREFIX} + @echo -e "\n\e[32mTrick has been installed successfully to ${PREFIX}.\e[0m\n" uninstall: rm -f ${PREFIX}/bin/trick-CP diff --git a/autoconf/configure.ac b/autoconf/configure.ac index b09f79ab..d26b589b 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -1,6 +1,9 @@ dnl To generate a new top level configure script from this autoconf directory dnl 1. aclocal dnl 2. autoconf -o ../configure +dnl If you run into "configure.ac:15: error: possibly undefined macro: AC_MSG_ERROR", +dnl try: +dnl autoreconf -fi AC_INIT([Trick],[17+]) AC_LANG(C++) @@ -174,6 +177,25 @@ AC_DEFUN([AX_JSC_DIRS],[ AC_SUBST([MOTIF_HOME]) ]) +AC_DEFUN([AX_GCC_VERSION], [ + GCC_VERSION="" + AS_IF([test "x$GCC" = "xyes"],[ + AS_IF([test "x$ax_gcc_version_option" != "xno"],[ + AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[ + ax_cv_gcc_version="`$CC -dumpversion`" + AS_IF([test "x$ax_cv_gcc_version" = "x"],[ + ax_cv_gcc_version="" + ]) + ]) + GCC_VERSION=$ax_cv_gcc_version + ]) + ]) + AC_SUBST([GCC_VERSION]) +]) + +dnl get the host_os. +AC_CANONICAL_HOST + dnl add extra paths to find gcc on RHEL 6 systems PATH="/opt/rh/devtoolset-3/root/usr/bin:${PATH}" dnl add extra paths to find xml headers and X headers on the mac. @@ -185,7 +207,17 @@ dnl look for programs we need to compile and run AC_PROG_AWK AC_PROG_CC AC_PROG_CXX -AX_GCC_VERSION + +dnl do not test gcc version on mac. clang as gcc will return version and it's not >= 4.8 +TEST_GCC=yes +case "${host_os}" in + darwin*) + TEST_GCC=no + ;; + *) + ;; +esac +AS_IF([test "$TEST_GCC" = "yes"],[AX_GCC_VERSION],[]) dnl if the compiler is gcc, test for gcc >= 4.8 AS_IF([test "x$GCC_VERSION" = "x"],[], [AC_MSG_CHECKING([gcc version >= 4.8]) @@ -206,6 +238,8 @@ AC_PROG_LEX AS_IF([test "x$LEX" = "x:"],AC_MSG_ERROR([could not find flex]),[]) AC_PATH_PROG(BISON, bison, nobison) AS_IF([test "$ac_cv_path_BISON" = "nobison"],AC_MSG_ERROR([could not find bison]),[]) +AC_PATH_PROG(CURL, curl, nocurl) +AS_IF([test "$ac_cv_path_CURL" = "nocurl"],AC_MSG_ERROR([could not find curl]),[]) AC_PATH_PROG(PERL, perl, noperl) AS_IF([test "$ac_cv_path_PERL" = "noperl"],AC_MSG_ERROR([could not find perl]),[]) AC_PATH_PROG(PYTHON, python${PYTHON_VERSION}, nopython) @@ -249,6 +283,25 @@ AC_PATH_PROG(CLANG, clang, noclang, "$LLVM_BIN_DIR:/bin:/usr/bin:/usr/local/bin: AS_IF([test "$ac_cv_path_CLANG" = "noclang"],AC_MSG_ERROR([could not find clang]),[]) AC_SUBST([LLVM_HOME]) +AC_DEFUN([AX_CLANG_VERSION], [ + CLANG_VERSION="" + ax_cv_clang_version="`$CLANG --version | grep "version" | sed "s/.*version \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/"`" + AS_IF([test "x$ax_cv_clang_version" = "x"],[ + ax_cv_clang_version="" + ]) + CLANG_VERSION=$ax_cv_clang_version + AC_SUBST([CLANG_VERSION]) +]) +AX_CLANG_VERSION +dnl if llvm/clang, test for version >= 3.4.2 +AS_IF([test "x$CLANG_VERSION" = "x"],[], + [AC_MSG_CHECKING([clang version >= 3.4.2]) + AX_COMPARE_VERSION([$CLANG_VERSION],[ge],[3.4.2], [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([Trick requires llvm/clang version >= 3.4.2]) + ]) +]) + AX_CHECK_ZLIB([],AC_MSG_ERROR([could not find zlib])) dnl look for udunits in /usr/include and /usr/include/udunits2 @@ -260,13 +313,14 @@ AS_IF([test "$UDUNITS_HOME" = ""], UDUNITS_LDFLAGS=-ludunits2 ], [ + UDUNITS_EXCLUDE=$UDUNITS_HOME AC_CHECK_FILE([$UDUNITS_HOME/include/udunits2.h], [UDUNITS_INCLUDES=-I$UDUNITS_HOME/include - UDUNITS_LDFLAGS="-L$UDUNITS_HOME/lib -ludunits2" + UDUNITS_LDFLAGS="-Wl,-rpath,$UDUNITS_HOME/lib -L$UDUNITS_HOME/lib -ludunits2" ], [AC_CHECK_FILE([$UDUNITS_HOME/lib/udunits2.h], [UDUNITS_INCLUDES=-I$UDUNITS_HOME/lib - UDUNITS_LDFLAGS="-L$UDUNITS_HOME/lib -ludunits2" + UDUNITS_LDFLAGS="-Wl,-rpath,$UDUNITS_HOME/lib -L$UDUNITS_HOME/lib -ludunits2" ], AC_MSG_ERROR([could not find udunits2])) ] @@ -275,6 +329,7 @@ AS_IF([test "$UDUNITS_HOME" = ""], ) AC_SUBST([UDUNITS_INCLUDES]) AC_SUBST([UDUNITS_LDFLAGS]) +AC_SUBST([UDUNITS_EXCLUDE]) dnl process the other optional command line arguments AX_HDF5_HOME([]) diff --git a/bin/trick-CP b/bin/trick-CP index afe970cd..7ec8865b 100755 --- a/bin/trick-CP +++ b/bin/trick-CP @@ -67,7 +67,6 @@ ifndef TRICK_VERBOSE_BUILD endif MAKE_OUT := build/MAKE_out -REMOVE_MAKE_OUT := $(shell rm -f $(MAKE_OUT)) all: $(info Trick Build Process Complete) @@ -90,11 +89,11 @@ $(TRICK_STATIC_LIB): # CP creates S_source.hh required for ICG and SWIG processing S_source.hh: S_define | build $(PRINT_CP) - $(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/configuration_processor $(TRICK_CPFLAGS) + $(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/configuration_processor $(TRICK_CPFLAGS) 2>&1 | $(TEE) -a $(MAKE_OUT) ; exit $${PIPESTATUS[0]} build/Makefile_S_define: S_source.hh $(PRINT_S_DEF_DEPS) - $(ECHO_CMD)$(TRICK_CPPC) $(TRICK_SFLAGS) $(TRICK_SYSTEM_SFLAGS) -MM -MT S_source.hh -MF build/Makefile_S_define -x c++ S_define + $(ECHO_CMD)$(TRICK_CPPC) $(TRICK_SFLAGS) $(TRICK_SYSTEM_SFLAGS) -MM -MT S_source.hh -MF build/Makefile_S_define -x c++ S_define 2>&1 | $(TEE) -a $(MAKE_OUT) ; exit $${PIPESTATUS[0]} # Automatic and manual ICG rules ICG: @@ -108,20 +107,20 @@ force_ICG: # Create makefile for IO code build/Makefile_io_src: S_source.hh | build $(PRINT_ICG) - $(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} $< + $(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} $< 2>&1 | $(TEE) -a $(MAKE_OUT) ; exit $${PIPESTATUS[0]} # Create makefile for source code #build/Makefile_src: build/ICG_processed build/ICG_no_found build/S_define.lib_deps build/Makefile_src: build/Makefile_src_deps build/Makefile_io_src S_source.hh $(PRINT_MAKEFILE_SRC) - $(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_src $? + $(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_src $? 2>&1 | $(TEE) -a $(MAKE_OUT) ; exit $${PIPESTATUS[0]} build/Makefile_src_deps: ; # Create makefile for SWIG code build/Makefile_swig: S_source.hh build/Makefile_swig_deps $(PRINT_MAKEFILE_SWIG) - $(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_swig + $(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_swig 2>&1 | $(TEE) -a $(MAKE_OUT) ; exit $${PIPESTATUS[0]} build/Makefile_swig_deps: ; @@ -129,7 +128,7 @@ build/Makefile_swig_deps: ; # build process. .PHONY: convert_swig convert_swig: build/S_library_swig - $(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/convert_swig ${TRICK_CONVERT_SWIG_FLAGS} + $(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/convert_swig ${TRICK_CONVERT_SWIG_FLAGS} 2>&1 | $(TEE) -a $(MAKE_OUT) ; exit $${PIPESTATUS[0]} # Force S_define_exp to be remade each time this rule runs .PHONY: S_define_exp @@ -155,14 +154,17 @@ ifeq ($(findstring ${MAKECMDGOALS},$(CLEAN_TARGETS)),) -include build/Makefile_swig_deps -include build/Makefile_ICG endif --include S_overrides.mk -include build/Makefile_overrides +-include S_overrides.mk +ifndef MAKE_RESTARTS +REMOVE_MAKE_OUT := $(shell rm -f $(MAKE_OUT)) ifeq ($(MAKECMDGOALS),) $(info $(call COLOR,Building with the following compilation flags:)) $(info TRICK_CFLAGS = $(TRICK_CFLAGS)) $(info TRICK_CXXFLAGS = $(TRICK_CXXFLAGS)) endif +endif else all: diff --git a/configure b/configure index 0e90678b..fd2b6502 100755 --- a/configure +++ b/configure @@ -627,9 +627,11 @@ BC635_HOME TPROCTE_HOME DMTCP_HOME HDF5_HOME +UDUNITS_EXCLUDE UDUNITS_LDFLAGS UDUNITS_INCLUDES UDUNITS_HOME +CLANG_VERSION LLVM_HOME CLANG LLVM_CONFIG @@ -644,14 +646,7 @@ PTHREAD_LIBS PTHREAD_CC ax_pthread_config CPP -host_os -host_vendor -host_cpu -host -build_os -build_vendor -build_cpu -build +SED LIBXML MOTIF_HOME X_LIB_DIR @@ -669,6 +664,7 @@ GNUPLOT SWIG PYTHON PERL +CURL BISON LEXLIB LEX_OUTPUT_ROOT @@ -676,7 +672,6 @@ LEX LD TEE GCC_VERSION -SED ac_ct_CXX CXXFLAGS CXX @@ -688,6 +683,14 @@ LDFLAGS CFLAGS CC AWK +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build target_alias host_alias build_alias @@ -1572,231 +1575,6 @@ fi } # ac_fn_cxx_try_compile -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES -# -------------------------------------------- -# Tries to find the compile-time value of EXPR in a program that includes -# INCLUDES, setting VAR accordingly. Returns whether the value could be -# computed -ac_fn_c_compute_int () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=0 ac_mid=0 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid; break -else - as_fn_arith $ac_mid + 1 && ac_lo=$as_val - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=-1 ac_mid=-1 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=$ac_mid; break -else - as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - ac_lo= ac_hi= -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid -else - as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in #(( -?*) eval "$3=\$ac_lo"; ac_retval=0 ;; -'') ac_retval=1 ;; -esac - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -static long int longval () { return $2; } -static unsigned long int ulongval () { return $2; } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (($2) < 0) - { - long int i = longval (); - if (i != ($2)) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ($2)) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - echo >>conftest.val; read $3 /dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac @@ -3714,1068 +3566,45 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler vendor" >&5 -$as_echo_n "checking for C compiler vendor... " >&6; } -if ${ax_cv_c_compiler_vendor+:} false; then : - $as_echo_n "(cached) " >&6 -else - # note: don't check for gcc first since some other compilers define __GNUC__ - vendors="intel: __ICC,__ECC,__INTEL_COMPILER - ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__ - pathscale: __PATHCC__,__PATHSCALE__ - clang: __clang__ - cray: _CRAYC - fujitsu: __FUJITSU - gnu: __GNUC__ - sun: __SUNPRO_C,__SUNPRO_CC - hp: __HP_cc,__HP_aCC - dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER - borland: __BORLANDC__,__CODEGEARC__,__TURBOC__ - comeau: __COMO__ - kai: __KCC - lcc: __LCC__ - sgi: __sgi,sgi - microsoft: _MSC_VER - metrowerks: __MWERKS__ - watcom: __WATCOMC__ - portland: __PGI - tcc: __TINYC__ - unknown: UNKNOWN" - for ventest in $vendors; do - case $ventest in - *:) vendor=$ventest; continue ;; - *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;; - esac - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - #if !($vencpp) - thisisanerror; - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - break -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done - ax_cv_c_compiler_vendor=`echo $vendor | cut -d: -f1` - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_c_compiler_vendor" >&5 -$as_echo "$ax_cv_c_compiler_vendor" >&6; } - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 -$as_echo_n "checking for a sed that does not truncate output... " >&6; } -if ${ac_cv_path_SED+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ - for ac_i in 1 2 3 4 5 6 7; do - ac_script="$ac_script$as_nl$ac_script" - done - echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed - { ac_script=; unset ac_script;} - if test -z "$SED"; then - ac_path_SED_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_SED" || continue -# Check for GNU ac_path_SED and select it if it is found. - # Check for GNU $ac_path_SED -case `"$ac_path_SED" --version 2>&1` in -*GNU*) - ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo '' >> "conftest.nl" - "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_SED_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_SED="$ac_path_SED" - ac_path_SED_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +TEST_GCC=yes +case "${host_os}" in + darwin*) + TEST_GCC=no + ;; + *) + ;; esac - - $ac_path_SED_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_SED"; then - as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 - fi -else - ac_cv_path_SED=$SED -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 -$as_echo "$ac_cv_path_SED" >&6; } - SED="$ac_cv_path_SED" - rm -f conftest.sed - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -$as_echo_n "checking for C compiler version... " >&6; } -if ${ax_cv_c_compiler_version+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $ax_cv_c_compiler_vendor in #( - intel) : - if ac_fn_c_compute_int "$LINENO" "__INTEL_COMPILER/100" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_INTEL unknown intel compiler version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(__INTEL_COMPILER%100)/10" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_INTEL unknown intel compiler version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(__INTEL_COMPILER%10)" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_INTEL unknown intel compiler version -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - ;; #( - ibm) : - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - -int -main () -{ - - #if defined(__COMPILER_VER__) - choke me; - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - if ac_fn_c_compute_int "$LINENO" "__xlC__/100" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "__xlC__%100" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "__xlC_ver__/0x100" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler patch version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "__xlC_ver__%0x100" "_ax_c_compiler_version_build" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler build version -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch.$_ax_c_compiler_version_build" - -else - - if ac_fn_c_compute_int "$LINENO" "__xlC__%1000" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler patch version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(__xlC__/10000)%10" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(__xlC__/100000)%10" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_IBM unknown IBM compiler major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ;; #( - pathscale) : - - if ac_fn_c_compute_int "$LINENO" "__PATHCC__" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_PATHSCALE unknown pathscale major -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "__PATHCC_MINOR__" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_PATHSCALE unknown pathscale minor -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "__PATHCC_PATCHLEVEL__" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_PATHSCALE unknown pathscale patch level -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - ;; #( - clang) : - - if ac_fn_c_compute_int "$LINENO" "__clang_major__" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_CLANG unknown clang major -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "__clang_minor__" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_CLANG unknown clang minor -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "__clang_patchlevel__" "_ax_c_compiler_version_patch" ""; then : - -else - 0 -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - ;; #( - cray) : - - if ac_fn_c_compute_int "$LINENO" "_RELEASE" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_CRAY unknown crayc release -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "_RELEASE_MINOR" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_CRAY unknown crayc minor -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor" - ;; #( - fujitsu) : - - if ac_fn_c_compute_int "$LINENO" "__FCC_VERSION" "ax_cv_c_compiler_version" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_FUJITSUunknown fujitsu release -See \`config.log' for more details" "$LINENO" 5; } -fi - - ;; #( - gnu) : - - if ac_fn_c_compute_int "$LINENO" "__GNUC__" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_GNU unknown gcc major -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "__GNUC_MINOR__" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_GNU unknown gcc minor -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "__GNUC_PATCHLEVEL__" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_GNU unknown gcc patch level -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - ;; #( - sun) : - - - if ac_fn_c_compute_int "$LINENO" "!!( - #if defined(__SUNPRO_CC) - __SUNPRO_CC - #else - __SUNPRO_C - #endif - < 0x1000)" "_ax_c_compiler_version_until59" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun release version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if test "X$_ax_c_compiler_version_until59" = X1; then : - if ac_fn_c_compute_int "$LINENO" " - #if defined(__SUNPRO_CC) - __SUNPRO_CC - #else - __SUNPRO_C - #endif - % 0x10" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun patch version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "( - #if defined(__SUNPRO_CC) - __SUNPRO_CC - #else - __SUNPRO_C - #endif - / 0x10) % 0x10" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "( - #if defined(__SUNPRO_CC) - __SUNPRO_CC - #else - __SUNPRO_C - #endif - / 0x100)" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - -else - if ac_fn_c_compute_int "$LINENO" " - #if defined(__SUNPRO_CC) - __SUNPRO_CC - #else - __SUNPRO_C - #endif - % 0x10" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun patch version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "( - #if defined(__SUNPRO_CC) - __SUNPRO_CC - #else - __SUNPRO_C - #endif - / 0x100) % 0x100" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "( - #if defined(__SUNPRO_CC) - __SUNPRO_CC - #else - __SUNPRO_C - #endif - / 0x1000)" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_SUN unknown sun major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - -fi - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - ;; #( - hp) : - - - if ac_fn_c_compute_int "$LINENO" "!!( - #if defined(__HP_cc) - __HP_cc - #else - __HP_aCC - #endif - <= 1)" "_ax_c_compiler_version_untilA0121" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_HP unknown hp release version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if test "X$_ax_c_compiler_version_untilA0121" = X1; then : - ax_cv_c_compiler_version="01.21.00" - -else - if ac_fn_c_compute_int "$LINENO" "( - #if defined(__HP_cc) - __HP_cc - #else - __HP_aCC - #endif - % 100)" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_HP unknown hp release version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(( - #if defined(__HP_cc) - __HP_cc - #else - __HP_aCC - #endif - / 100)%100)" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_HP unknown hp minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(( - #if defined(__HP_cc) - __HP_cc - #else - __HP_aCC - #endif - / 10000)%100)" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_HP unknown hp major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - -fi - ;; #( - dec) : - - if ac_fn_c_compute_int "$LINENO" "( - #if defined(__DECC_VER) - __DECC_VER - #else - __DECCXX_VER - #endif - % 10000)" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_DEC unknown dec release version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(( - #if defined(__DECC_VER) - __DECC_VER - #else - __DECCXX_VER - #endif - / 100000UL)%100)" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_DEC unknown dec minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(( - #if defined(__DECC_VER) - __DECC_VER - #else - __DECCXX_VER - #endif - / 10000000UL)%100)" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_DEC unknown dec major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - ;; #( - borland) : - - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - #if defined(__TURBOC__) - __TURBOC__ - #else - choke me - #endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - if ac_fn_c_compute_int "$LINENO" " - #if defined(__TURBOC__) - __TURBOC__ - #else - choke me - #endif - " "_ax_c_compiler_version_turboc_raw" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_BORLAND unknown turboc version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if test $_ax_c_compiler_version_turboc_raw -lt 661 || test $_ax_c_compiler_version_turboc_raw -gt 1023; then : - if ac_fn_c_compute_int "$LINENO" " - #if defined(__TURBOC__) - __TURBOC__ - #else - choke me - #endif - % 0x100" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_BORLAND unknown turboc minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "( - #if defined(__TURBOC__) - __TURBOC__ - #else - choke me - #endif - /0x100)%0x100" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_BORLAND unknown turboc major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="0turboc:$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor" -else - case $_ax_c_compiler_version_turboc_raw in #( - 661) : - ax_cv_c_compiler_version="0turboc:1.00" ;; #( - 662) : - ax_cv_c_compiler_version="0turboc:1.01" ;; #( - 663) : - ax_cv_c_compiler_version="0turboc:2.00" ;; #( - *) : - - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: [_AX_COMPILER_VERSION_BORLAND] unknown turboc version between 0x295 and 0x400 please report bug" >&5 -$as_echo "$as_me: WARNING: [_AX_COMPILER_VERSION_BORLAND] unknown turboc version between 0x295 and 0x400 please report bug" >&2;} - ax_cv_c_compiler_version="" - ;; -esac - -fi - -else - # borlandc - - if ac_fn_c_compute_int "$LINENO" " - #if defined(__BORLANDC__) - __BORLANDC__ - #else - __CODEGEARC__ - #endif - " "_ax_c_compiler_version_borlandc_raw" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_BORLAND unknown borlandc version -See \`config.log' for more details" "$LINENO" 5; } -fi - - case $_ax_c_compiler_version_borlandc_raw in #( - 512 ) : - ax_cv_c_compiler_version="1borlanc:2.00" ;; #( - 1024) : - ax_cv_c_compiler_version="1borlanc:3.00" ;; #( - 1024) : - ax_cv_c_compiler_version="1borlanc:3.00" ;; #( - 1040) : - ax_cv_c_compiler_version="1borlanc:3.1" ;; #( - 1106) : - ax_cv_c_compiler_version="1borlanc:4.0" ;; #( - 1280) : - ax_cv_c_compiler_version="1borlanc:5.0" ;; #( - 1312) : - ax_cv_c_compiler_version="1borlanc:5.02" ;; #( - 1328) : - ax_cv_c_compiler_version="2cppbuilder:3.0" ;; #( - 1344) : - ax_cv_c_compiler_version="2cppbuilder:4.0" ;; #( - 1360) : - ax_cv_c_compiler_version="3borlancpp:5.5" ;; #( - 1361) : - ax_cv_c_compiler_version="3borlancpp:5.51" ;; #( - 1378) : - ax_cv_c_compiler_version="3borlancpp:5.6.4" ;; #( - 1392) : - ax_cv_c_compiler_version="4cppbuilder:2006" ;; #( - 1424) : - ax_cv_c_compiler_version="4cppbuilder:2007" ;; #( - 1555) : - ax_cv_c_compiler_version="4cppbuilder:2009" ;; #( - 1569) : - ax_cv_c_compiler_version="4cppbuilder:2010" ;; #( - 1584) : - ax_cv_c_compiler_version="5xe" ;; #( - 1600) : - ax_cv_c_compiler_version="5xe:2" ;; #( - 1616) : - ax_cv_c_compiler_version="5xe:3" ;; #( - 1632) : - ax_cv_c_compiler_version="5xe:4" ;; #( - *) : - - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: [_AX_COMPILER_VERSION_BORLAND] Unknow borlanc compiler version $_ax_c_compiler_version_borlandc_raw please report bug" >&5 -$as_echo "$as_me: WARNING: [_AX_COMPILER_VERSION_BORLAND] Unknow borlanc compiler version $_ax_c_compiler_version_borlandc_raw please report bug" >&2;} - ;; -esac - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - ;; #( - comeau) : - if ac_fn_c_compute_int "$LINENO" "__COMO_VERSION__%100" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_COMEAU unknown comeau compiler minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(__COMO_VERSION__/100)%10" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_COMEAU unknown comeau compiler major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor" - ;; #( - kai) : - - if ac_fn_c_compute_int "$LINENO" "__KCC_VERSION%100" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_KAI unknown kay compiler patch version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(__KCC_VERSION/100)%10" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_KAI unknown kay compiler minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(__KCC_VERSION/1000)%10" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_KAI unknown kay compiler major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - ;; #( - sgi) : - - - if ac_fn_c_compute_int "$LINENO" " - #if defined(_COMPILER_VERSION) - _COMPILER_VERSION - #else - _SGI_COMPILER_VERSION - #endif - %10" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_SGI unknown SGI compiler patch version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "( - #if defined(_COMPILER_VERSION) - _COMPILER_VERSION - #else - _SGI_COMPILER_VERSION - #endif - /10)%10" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_SGI unknown SGI compiler minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "( - #if defined(_COMPILER_VERSION) - _COMPILER_VERSION - #else - _SGI_COMPILER_VERSION - #endif - /100)%10" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_SGI unknown SGI compiler major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - ;; #( - microsoft) : - - if ac_fn_c_compute_int "$LINENO" "_MSC_VER%100" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_MICROSOFT unknown microsoft compiler minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(_MSC_VER/100)%100" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_MICROSOFT unknown microsoft compiler major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - _ax_c_compiler_version_patch=0 - _ax_c_compiler_version_build=0 - # special case for version 6 - if test "X$_ax_c_compiler_version_major" = "X12"; then : - if ac_fn_c_compute_int "$LINENO" "_MSC_FULL_VER%1000" "_ax_c_compiler_version_patch" ""; then : - -else - _ax_c_compiler_version_patch=0 -fi - -fi - # for version 7 - if test "X$_ax_c_compiler_version_major" = "X13"; then : - if ac_fn_c_compute_int "$LINENO" "_MSC_FULL_VER%1000" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_MICROSOFT unknown microsoft compiler patch version -See \`config.log' for more details" "$LINENO" 5; } -fi - - -fi - # for version > 8 - if test $_ax_c_compiler_version_major -ge 14; then : - if ac_fn_c_compute_int "$LINENO" "_MSC_FULL_VER%10000" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_MICROSOFT unknown microsoft compiler patch version -See \`config.log' for more details" "$LINENO" 5; } -fi - - -fi - if test $_ax_c_compiler_version_major -ge 15; then : - if ac_fn_c_compute_int "$LINENO" "_MSC_BUILD" "_ax_c_compiler_version_build" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_MICROSOFT unknown microsoft compiler build version -See \`config.log' for more details" "$LINENO" 5; } -fi - - -fi - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch.$_ax_c_compiler_version_build" - ;; #( - metrowerks) : - if ac_fn_c_compute_int "$LINENO" "__MWERKS__%0x100" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_METROWERKS unknown metrowerks compiler patch version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(__MWERKS__/0x100)%0x10" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_METROWERKS unknown metrowerks compiler minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(__MWERKS__/0x1000)%0x10" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_METROWERKS unknown metrowerks compiler major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - ;; #( - watcom) : - if ac_fn_c_compute_int "$LINENO" "__WATCOMC__%100" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_WATCOM unknown watcom compiler minor version -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "(__WATCOMC__/100)%100" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_WATCOM unknown watcom compiler major version -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor" - ;; #( - portland) : - - if ac_fn_c_compute_int "$LINENO" "__PGIC__" "_ax_c_compiler_version_major" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_PORTLAND unknown pgi major -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "__PGIC_MINOR__" "_ax_c_compiler_version_minor" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_PORTLAND unknown pgi minor -See \`config.log' for more details" "$LINENO" 5; } -fi - - if ac_fn_c_compute_int "$LINENO" "__PGIC_PATCHLEVEL__" "_ax_c_compiler_version_patch" ""; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "_AX_COMPILER_VERSION_PORTLAND unknown pgi patch level -See \`config.log' for more details" "$LINENO" 5; } -fi - - ax_cv_c_compiler_version="$_ax_c_compiler_version_major.$_ax_c_compiler_version_minor.$_ax_c_compiler_version_patch" - ;; #( - tcc) : - - ax_cv_c_compiler_version=`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'` - ;; #( - *) : - ax_cv_c_compiler_version="" ;; -esac - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_c_compiler_version" >&5 -$as_echo "$ax_cv_c_compiler_version" >&6; } - - - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test "$TEST_GCC" = "yes"; then : GCC_VERSION="" - ax_cv_gcc_version="" - if test "X$ax_cv_c_compiler_vendor" = "Xgnu"; then : - ax_cv_gcc_version=$ax_cv_c_compiler_version - GCC_VERSION=$ax_cv_gcc_version + if test "x$GCC" = "xyes"; then : + + if test "x$ax_gcc_version_option" != "xno"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking gcc version" >&5 +$as_echo_n "checking gcc version... " >&6; } +if ${ax_cv_gcc_version+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_cv_gcc_version="`$CC -dumpversion`" + if test "x$ax_cv_gcc_version" = "x"; then : + + ax_cv_gcc_version="" + +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_version" >&5 +$as_echo "$ax_cv_gcc_version" >&6; } + GCC_VERSION=$ax_cv_gcc_version + +fi fi +fi if test "x$GCC_VERSION" = "x"; then : else @@ -5121,6 +3950,50 @@ fi if test "$ac_cv_path_BISON" = "nobison"; then : as_fn_error $? "could not find bison" "$LINENO" 5 fi +# Extract the first word of "curl", so it can be a program name with args. +set dummy curl; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_CURL+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $CURL in + [\\/]* | ?:[\\/]*) + ac_cv_path_CURL="$CURL" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CURL="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_CURL" && ac_cv_path_CURL="nocurl" + ;; +esac +fi +CURL=$ac_cv_path_CURL +if test -n "$CURL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CURL" >&5 +$as_echo "$CURL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +if test "$ac_cv_path_CURL" = "nocurl"; then : + as_fn_error $? "could not find curl" "$LINENO" 5 +fi # Extract the first word of "perl", so it can be a program name with args. set dummy perl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -6239,75 +5112,74 @@ else fi -# Make sure we can run config.sub. -$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 -$as_echo_n "checking build system type... " >&6; } -if ${ac_cv_build+:} false; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else - ac_build_alias=$build_alias -test "x$ac_build_alias" = x && - ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` -test "x$ac_build_alias" = x && - as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 -ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 -$as_echo "$ac_cv_build" >&6; } -case $ac_cv_build in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + { ac_script=; unset ac_script;} + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_SED" || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac -build=$ac_cv_build -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_build -shift -build_cpu=$1 -build_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -build_os=$* -IFS=$ac_save_IFS -case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 -$as_echo_n "checking host system type... " >&6; } -if ${ac_cv_host+:} false; then : - $as_echo_n "(cached) " >&6 + $ac_path_SED_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi else - if test "x$host_alias" = x; then - ac_cv_host=$ac_cv_build -else - ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 + ac_cv_path_SED=$SED fi fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 -$as_echo "$ac_cv_host" >&6; } -case $ac_cv_host in -*-*-*) ;; -*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; -esac -host=$ac_cv_host -ac_save_IFS=$IFS; IFS='-' -set x $ac_cv_host -shift -host_cpu=$1 -host_vendor=$2 -shift; shift -# Remember, the first character of IFS is used to create $*, -# except with old shells: -host_os=$* -IFS=$ac_save_IFS -case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +$as_echo "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed ac_ext=c @@ -7203,7 +6075,7 @@ variable to configure. See \`\`configure --help'' for reference. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the distutils Python package" >&5 $as_echo_n "checking for the distutils Python package... " >&6; } ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` - if test -z "$ac_distutils_result"; then + if test $? -eq 0; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else @@ -7792,6 +6664,66 @@ if test "$ac_cv_path_CLANG" = "noclang"; then : fi + + + CLANG_VERSION="" + ax_cv_clang_version="`$CLANG --version | grep "version" | sed "s/.*version \(0-9*\.0-9*\.0-9*\).*/\1/"`" + if test "x$ax_cv_clang_version" = "x"; then : + + ax_cv_clang_version="" + +fi + CLANG_VERSION=$ax_cv_clang_version + + +if test "x$CLANG_VERSION" = "x"; then : + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking clang version >= 3.4.2" >&5 +$as_echo_n "checking clang version >= 3.4.2... " >&6; } + + + + # Used to indicate true or false condition + ax_compare_version=false + + # Convert the two version strings to be compared into a format that + # allows a simple string comparison. The end result is that a version + # string of the form 1.12.5-r617 will be converted to the form + # 0001001200050617. In other words, each number is zero padded to four + # digits, and non digits are removed. + + ax_compare_version_A=`echo "$CLANG_VERSION" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version_B=`echo "3.4.2" | sed -e 's/\([0-9]*\)/Z\1Z/g' \ + -e 's/Z\([0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \ + -e 's/[^0-9]//g'` + + + ax_compare_version=`echo "x$ax_compare_version_A +x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"` + + + + if test "$ax_compare_version" = "true" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "Trick requires llvm/clang version >= 3.4.2" "$LINENO" 5 + + fi + + +fi + # # Handle user hints # @@ -7959,6 +6891,7 @@ fi else + UDUNITS_EXCLUDE=$UDUNITS_HOME as_ac_File=`$as_echo "ac_cv_file_$UDUNITS_HOME/include/udunits2.h" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $UDUNITS_HOME/include/udunits2.h" >&5 $as_echo_n "checking for $UDUNITS_HOME/include/udunits2.h... " >&6; } @@ -7978,7 +6911,7 @@ eval ac_res=\$$as_ac_File $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes"; then : UDUNITS_INCLUDES=-I$UDUNITS_HOME/include - UDUNITS_LDFLAGS="-L$UDUNITS_HOME/lib -ludunits2" + UDUNITS_LDFLAGS="-Wl,-rpath,$UDUNITS_HOME/lib -L$UDUNITS_HOME/lib -ludunits2" else as_ac_File=`$as_echo "ac_cv_file_$UDUNITS_HOME/lib/udunits2.h" | $as_tr_sh` @@ -8000,7 +6933,7 @@ eval ac_res=\$$as_ac_File $as_echo "$ac_res" >&6; } if eval test \"x\$"$as_ac_File"\" = x"yes"; then : UDUNITS_INCLUDES=-I$UDUNITS_HOME/lib - UDUNITS_LDFLAGS="-L$UDUNITS_HOME/lib -ludunits2" + UDUNITS_LDFLAGS="-Wl,-rpath,$UDUNITS_HOME/lib -L$UDUNITS_HOME/lib -ludunits2" else as_fn_error $? "could not find udunits2" "$LINENO" 5 @@ -8018,6 +6951,7 @@ fi + # Check whether --with-hdf5 was given. if test "${with_hdf5+set}" = set; then : withval=$with_hdf5; HDF5_HOME="$withval" diff --git a/include/trick/ClassicCheckPointAgent.hh b/include/trick/ClassicCheckPointAgent.hh index bf37f59b..de5a7991 100644 --- a/include/trick/ClassicCheckPointAgent.hh +++ b/include/trick/ClassicCheckPointAgent.hh @@ -52,15 +52,15 @@ namespace Trick { @param address Address of the variable. @param attr ATTRIBUTES of the variable. - @param curr_dim - @param offset + @param curr_dim Dimensions of the array + @param offset Offset into the array */ void assign_rvalue( std::ostream& chkpnt_os, void* address, ATTRIBUTES* attr, int curr_dim, int offset); /** Restore memory allocations from a checkpoint stream. @param checkpoint_stream Input stream from which the checkpoint is read. - @return + @return 0/1 success flag */ int restore( std::istream* checkpoint_stream); @@ -72,7 +72,6 @@ namespace Trick { @param address - address of the object within which we are checking for nil values. @param attr - attr describing the object at the address. @param curr_dim - dimension of the sub-element being checked. - @param offset - offset of the sub-element @param offset - if the object specified by @b address and @b attr is arrayed, then this parameter specifies where, within the array, the sub-object to be checked, is located. @@ -86,7 +85,7 @@ namespace Trick { The pointer must be an address that is being managed by MM (the MemoryManager) or a character string (char* or wchar_t*). - @param pointer + @param pointer Pointer to be converted. @param attr ATTRIBUTES of the pointer. @param curr_dim current dimension. @return text expression that represents the pointer. diff --git a/include/trick/DRBinary.hh b/include/trick/DRBinary.hh index c5ba3966..bcf5c4ef 100644 --- a/include/trick/DRBinary.hh +++ b/include/trick/DRBinary.hh @@ -117,7 +117,7 @@ namespace Trick { private: /** The log file.\n */ - int fp ; /**< trick_io(**) trick_units(--) */ + int fd ; /**< trick_io(**) trick_units(--) */ } ; diff --git a/include/trick/DataRecordDispatcher.hh b/include/trick/DataRecordDispatcher.hh index 32936e92..b1fb332c 100644 --- a/include/trick/DataRecordDispatcher.hh +++ b/include/trick/DataRecordDispatcher.hh @@ -100,6 +100,12 @@ namespace Trick { /** @brief Disable a group or all groups */ int record_now_group( const char * in_name ) ; + /** @brief set max file size for group */ + int set_group_max_file_size(const char * in_name, uint64_t bytes) ; + + /** @brief set max file size for all groups */ + int set_max_file_size(uint64_t bytes) ; + // override the default Schduler::add_sim_object virtual int add_sim_object( Trick::SimObject * in_object ) ; diff --git a/include/trick/DataRecordGroup.hh b/include/trick/DataRecordGroup.hh index 823fdb4d..43ff0fae 100644 --- a/include/trick/DataRecordGroup.hh +++ b/include/trick/DataRecordGroup.hh @@ -115,6 +115,12 @@ namespace Trick { /** Current write to file record number.\n */ unsigned int writer_num; /**< trick_io(**) trick_units(--) */ + /** Maximum file size for data record file in bytes.\n */ + uint64_t max_file_size; /**< trick_io(**) trick_units(--) */ + + /** Current file size for data record file in bytes.\n */ + uint64_t total_bytes_written; /**< trick_io(**) trick_units(--) */ + /** Buffer to hold formatted data ready for disk or other destination.\n */ char * writer_buff ; /**< trick_io(**) trick_units(--) */ @@ -207,6 +213,17 @@ namespace Trick { */ virtual int set_buffer_type(int buffer_type) ; + /** + @brief @userdesc Command to set the max file size in bytes. + This tells the data record group when it stops writing to the disk. + @par Python Usage: + @code .set_max_file_size() @endcode + @param type - the file size in bytes + @return always 0 + */ + virtual int set_max_file_size(uint64_t bytes) ; + + /** @brief @userdesc Command to print double variable values as single precision (float) in the log file to save space. @par Python Usage: diff --git a/include/trick/EventManager.hh b/include/trick/EventManager.hh index 4f8b80bb..029fbe98 100644 --- a/include/trick/EventManager.hh +++ b/include/trick/EventManager.hh @@ -146,6 +146,9 @@ namespace Trick { /** Number of active events\n */ unsigned int num_active_events ; /**< trick_io(*io) trick_units(--) */ + /** Number of active events allocated\n */ + unsigned int num_allocated ; /**< trick_io(*io) trick_units(--) */ + /** All of the event processors, one per thread. */ std::vector< Trick::EventProcessor * > event_processors ; /**< trick_io(**) */ diff --git a/include/trick/FrameLog.hh b/include/trick/FrameLog.hh index fd2c3667..a61fb143 100644 --- a/include/trick/FrameLog.hh +++ b/include/trick/FrameLog.hh @@ -13,6 +13,7 @@ PROGRAMMERS: #include "trick/FrameDataRecordGroup.hh" #include "trick/attributes.h" #include "trick/JobData.hh" +#include "trick/Clock.hh" namespace Trick { @@ -77,10 +78,12 @@ namespace Trick { /** Save the name of the trick master/slave sim object.\n */ std::string ms_sim_object_name; /**< trick_io(**) */ + Trick::Clock & clock ; /**< trick_io(**) */ + /** @brief Constructor. */ - FrameLog() ; + FrameLog(Trick::Clock & in_clock) ; /** @brief Destructor. @@ -152,6 +155,8 @@ namespace Trick { */ int shutdown() ; + void set_clock(Trick::Clock & in_clock) ; + private: std::vector trick_jobs; // ** vector containing all trick job names std::vector user_jobs; // ** vector containing all user job names @@ -188,6 +193,9 @@ namespace Trick { */ int create_DP_timeline_files(); + // This object is not copyable + void operator =(const FrameLog &) {}; + } ; } ; diff --git a/include/trick/IPPythonEvent.hh b/include/trick/IPPythonEvent.hh index a8c846ef..7a512d4b 100644 --- a/include/trick/IPPythonEvent.hh +++ b/include/trick/IPPythonEvent.hh @@ -111,9 +111,9 @@ namespace Trick { /** @userdesc Last simulation time that this event ran an action.\n */ double ran_time ; /**< trick_io(*io) trick_units(s) */ /** Array of event's conditions.\n */ - condition_t * cond ; /**< trick_io(*io) trick_units(--) */ + condition_t ** condition_list ; /**< trick_io(*io) trick_units(--) */ /** Array of event's actions.\n */ - action_t * act ; /**< trick_io(*io) trick_units(--) */ + action_t ** action_list ; /**< trick_io(*io) trick_units(--) */ /** @brief Constructor. diff --git a/include/trick/IntegLoopManager.hh b/include/trick/IntegLoopManager.hh index a5436ba9..b6febe17 100644 --- a/include/trick/IntegLoopManager.hh +++ b/include/trick/IntegLoopManager.hh @@ -84,7 +84,7 @@ class IntegLoopScheduler; * Designate the specified sim object as integrated by the specified * scheduler. * @param sim_object Simulation object. - * @param scheduler Integration loop scheduler. + * @param integrator Integration loop scheduler. */ void set_integrated_by ( Trick::SimObject * sim_object, diff --git a/include/trick/IntegLoopScheduler.hh b/include/trick/IntegLoopScheduler.hh index 9cc5e3ea..6b86462f 100644 --- a/include/trick/IntegLoopScheduler.hh +++ b/include/trick/IntegLoopScheduler.hh @@ -114,7 +114,7 @@ namespace Trick { /** * Non-default constructor. - * @param cycle The time interval at which the loop's integrate + * @param in_cycle The time interval at which the loop's integrate * function will be called. * @param parent_so The Trick simulation object that contains this * IntegLoopScheduler object. diff --git a/include/trick/JobData.hh b/include/trick/JobData.hh index d16670a6..3e6c4e74 100644 --- a/include/trick/JobData.hh +++ b/include/trick/JobData.hh @@ -179,7 +179,7 @@ namespace Trick { /** * Sets/Resets the static time_tic value - * @param time_tic_value - number of tics per second + * @param in_time_tic_value - number of tics per second * @return always 0 */ static int set_time_tic_value(long long in_time_tic_value) ; @@ -187,7 +187,6 @@ namespace Trick { /** * Sets/Resets the job cycle rate * @param rate - desired cycle rate in seconds - * @param time_tic_value - number of tics per second * @return always 0 */ virtual int set_cycle(double rate) ; @@ -214,10 +213,10 @@ namespace Trick { /** * Adds another job as a dependency to this job - * @param depend - JobData instance of depends_on job + * @param in_tag - JobData instance of depends_on job * @return always 0 */ - virtual int add_tag( std::string ) ; + virtual int add_tag( std::string in_tag) ; /** * Adds another job as a dependency to this job diff --git a/include/trick/MemoryManager.hh b/include/trick/MemoryManager.hh index c49252b4..1aead346 100644 --- a/include/trick/MemoryManager.hh +++ b/include/trick/MemoryManager.hh @@ -305,7 +305,7 @@ namespace Trick { /** Forget about the variable with the given name and deallocate the memory associated with it. - @param address - the address of the variable. + @param var_name - the address of the variable. @return 0 = SUCCESS, 1 = FAILURE */ int delete_var(const char* var_name); @@ -321,7 +321,7 @@ namespace Trick { /** Forget about the external variable with the given name. DOES NOT attempt to deallocate the memory at the given address. - @param address - the address of the external variable. + @param var_name - the address of the external variable. @return 0 = SUCCESS, 1 = FAILURE */ int delete_extern_var(const char* var_name); @@ -334,35 +334,35 @@ namespace Trick { /** Checkpoint all allocations known to the MemoryManager to a file. - @param filename + @param filename Name of file to be written. */ void write_checkpoint( const char* filename); /** Checkpoint the named variable (allocation) and it dependencies to the given stream. @param out_s output stream. - @param var_name + @param var_name Variable name. */ void write_checkpoint( std::ostream& out_s, const char* var_name); /** Checkpoint the named variable (allocation) and it dependencies to a file. - @param filename - @param var_name + @param filename Checkpoint file. + @param var_name Variable name. */ void write_checkpoint( const char* filename, const char* var_name); /** Checkpoint the named variables and their dependencies to a stream. @param out_s output stream. - @param var_name_list + @param var_name_list List of variable names. */ void write_checkpoint( std::ostream& out_s, std::vector& var_name_list); /** Checkpoint the named variables and their dependencies to a file. - @param filename - @param var_name_list + @param filename output file name. + @param var_name_list List of variable names. */ void write_checkpoint( const char* filename, std::vector& var_name_list); @@ -521,13 +521,13 @@ namespace Trick { /** Return the number of array elements in the allocation. - @param ptr address. + @param addr Address. */ int get_size(void *addr); /** Return the number of array elements in the allocation following ptr. - @param ptr - pointer. + @param addr Address. */ int get_truncated_size(void *addr); @@ -565,7 +565,7 @@ namespace Trick { /** Opens a handle to the shared library file. The handles are used to look for io_src functions. - @param name The name of the file to open. + @param file_name The name of the file to open. */ int add_shared_library_symbols( const char * file_name ); @@ -609,7 +609,7 @@ namespace Trick { Write the contents of the variable with the given name to the given stream. In other words, checkpoint a single variable to a file. @param out_s - output stream. - @param address - address of the variable. + @param var_name - Name of the variable. */ void write_var( std::ostream& out_s, const char* var_name ); @@ -798,16 +798,13 @@ namespace Trick { /** Call the default destructor for one or more instances of the named class. - @param class_name The name of the class to allocate. - @param num The number of instances to allocate. - @return The address of the allocation, or NULL on failure. + @param alloc_info The alloc_info struct that contains the address and type to delete. */ void io_src_destruct_class(ALLOC_INFO * alloc_info); /** Call the proper class/struct delete for the address given in the ALLOC_INFO struct. - @alloc_info The alloc_info struct that contains the address and type to delete. - @return none. + @param alloc_info The alloc_info struct that contains the address and type to delete. */ void io_src_delete_class(ALLOC_INFO * alloc_info); diff --git a/include/trick/MessageFile.hh b/include/trick/MessageFile.hh index 00f84eeb..de21a88b 100644 --- a/include/trick/MessageFile.hh +++ b/include/trick/MessageFile.hh @@ -59,7 +59,7 @@ namespace Trick { @brief Initializes this subscriber. @return always 0 */ - int init() ; + virtual int init() ; protected: /** The output file stream. \n */ diff --git a/include/trick/MessageSubscriber.hh b/include/trick/MessageSubscriber.hh index 7abde06b..32e24d40 100644 --- a/include/trick/MessageSubscriber.hh +++ b/include/trick/MessageSubscriber.hh @@ -45,6 +45,11 @@ namespace Trick { */ virtual ~MessageSubscriber() {} ; + /** + @brief Initializes the subscriber + */ + virtual int init() { return 0 ; } ; + /** @brief Get a message and send to output. This gets called every time when the message publisher that this subscriber subscribes to publishes a message. Actual output done in the derived class. @@ -54,6 +59,11 @@ namespace Trick { */ virtual void update( unsigned int level , std::string header, std::string message ) = 0 ; + /** + @brief Shutdown the subscriber + */ + virtual int shutdown() { return 0 ; } ; + } ; } diff --git a/include/trick/MessageTCDevice.hh b/include/trick/MessageTCDevice.hh index 8504e249..8d2656e1 100644 --- a/include/trick/MessageTCDevice.hh +++ b/include/trick/MessageTCDevice.hh @@ -86,7 +86,7 @@ namespace Trick { @brief Initializes this subscriber. @return always 0 */ - int init() ; + virtual int init() ; /** @brief Restarts this subscriber. @@ -98,7 +98,7 @@ namespace Trick { @brief Shuts down this subscriber. @return always 0 */ - int shutdown() ; + virtual int shutdown() ; /** The port number for message socket connection. Copied out from listen_thread.\n */ int port ; /**< trick_units(--) */ diff --git a/include/trick/MessageThreadedCout.hh b/include/trick/MessageThreadedCout.hh new file mode 100644 index 00000000..740fc9d1 --- /dev/null +++ b/include/trick/MessageThreadedCout.hh @@ -0,0 +1,78 @@ +/* + PURPOSE: + (Print messages to std::cout on a seperate thread) +*/ + +#ifndef MESSAGETHREADEDCOUT_HH +#define MESSAGETHREADEDCOUT_HH + +#include +#include "trick/ThreadBase.hh" +#include "trick/MessageSubscriber.hh" + +namespace Trick { + + /** + * This MessageThreadedCout is a class that inherits from MessageSubscriber. + * It defines a type of MessageSubscriber with its received message sending to the standard output stream. + */ + class MessageThreadedCout : public MessageSubscriber , public Trick::ThreadBase { + + public: + + /** + @brief Maximum number of items to hold in ring buffer + */ + unsigned int max_buffer_items ; // trick_units(--) + + /** + @brief Maximum size of string to hold + */ + unsigned int max_buffer_size ; // trick_units(--) + + std::string color_code ; + + /** + @brief The constructor. + */ + MessageThreadedCout() ; + virtual ~MessageThreadedCout() {} ; + + // From MessageSubscriber + virtual int init() ; + virtual void update( unsigned int level , std::string header , std::string message ) ; + virtual int shutdown() ; + + // From Trick::ThreadBase + virtual void * thread_body() ; + virtual void dump( std::ostream & oss = std::cout ) ; + + // Specific Classes + void write_pending_messages() ; + + protected: + // After sim shutdown print immediately. + bool print_immediate ; + + struct StringNode { + std::string buffer ; + size_t max_len ; + StringNode * next ; + StringNode(size_t str_len) : max_len(str_len) { buffer.reserve(max_len) ; } ; + void copy( std::string &header, std::string & in_color_code, std::string & message ) { + buffer.assign(header, 0, max_len) ; + buffer.append(in_color_code, 0, max_len - buffer.length()) ; + buffer.append(message, 0, max_len - buffer.length()) ; + buffer.append("\033[00m", 0, max_len - buffer.length()) ; + } ; + } ; + + StringNode * copy_ptr ; /* trick_io(**) pointer to next buffer to copy data */ + StringNode * write_ptr ; /* trick_io(**) pointer to next buffer to write to screen */ + pthread_mutex_t write_mutex ; /* trick_io(**) mutex for writing */ + } ; + +} + +#endif + diff --git a/include/trick/RodriguesRotation.h b/include/trick/RodriguesRotation.h new file mode 100644 index 00000000..164d7ff7 --- /dev/null +++ b/include/trick/RodriguesRotation.h @@ -0,0 +1,32 @@ +#ifndef RODRIGUES_ROTATION_H +#define RODRIGUES_ROTATION_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* @ingroup TRICK_MATH +* @brief Generate a transformation matrix for rotation about a given line by a given +* angle, using Rodrigues’ formula. +* +* @param C_out - Transformation matrix for final to initial state. +* @param k - Vector in the direction of the rotation Axis. +* @param theta - Angle of rotation in radians. +*/ +void RotAboutLineByAngle(double C_out[3][3], double k[3], double theta); + +/** +* @ingroup TRICK_MATH +* @brief Generate a transformation matrix to rotate a vector to new a new orientation. +* +* @param v - Original vector. +* @param w - Vector after rotation. +* @param R_out - Rotation matrix, such that w = Rv. +*/ +void RotVectorToNewOrientation(double R_out[3][3], double v[3], double w[3]); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/include/trick/ScheduledJobQueue.hh b/include/trick/ScheduledJobQueue.hh index 487bf5e7..00e97e70 100644 --- a/include/trick/ScheduledJobQueue.hh +++ b/include/trick/ScheduledJobQueue.hh @@ -71,7 +71,7 @@ namespace Trick { /** * @brief Sets the curr_index to value. - * @param value - Value of index. + * @param ii - Value of index. * @return always 0. */ int set_curr_index( unsigned int ii ) ; @@ -122,8 +122,6 @@ namespace Trick { * @brief Adds the incoming instrumentation job before target job if specified, or all jobs in list. * Will reallocate list to accommodate additional instrumentation jobs. * @param instrumentation_job - name of the instrument job - * @param target_job - name of the target job, empty string means all jobs are to be instrumented - * @param in_event - instrumentation data to be stored with instrument job * @return number of insertions made */ int instrument_before(JobData * instrumentation_job) ; @@ -132,8 +130,6 @@ namespace Trick { * @brief Adds the incoming instrumentation job after target job if specified, or all jobs in the list. * Will reallocate list to accommodate additional instrumentation jobs. * @param instrumentation_job - name of the instrument job - * @param target_job - name of the target job, empty string means all jobs are to be instrumented - * @param in_event - instrumentation data to be stored with instrument job * @return number of insertions made */ int instrument_after(JobData * instrumentation_job) ; @@ -142,7 +138,6 @@ namespace Trick { * @brief Removes all jobs in the list that match the name job_name. * If in_event is specified, only remove this event's instrument job. * @param job_name - name of the instrument job - * @param in_event - instrumentation data to be stored with instrument job * @return always 0 */ int instrument_remove(std::string job_name) ; diff --git a/include/trick/Scheduler.hh b/include/trick/Scheduler.hh index 2ff99b3d..275a18fc 100644 --- a/include/trick/Scheduler.hh +++ b/include/trick/Scheduler.hh @@ -85,8 +85,6 @@ namespace Trick { * otherwise adds in_job before each job in the initialization and scheduled queues. * Requirement [@ref r_exec_instrument_0] * @param instrument_job - the instrument job - * @param target_job - name of the target job, empty string means all jobs are to be instrumented - * @param in_event - instrumentation data to be stored with instrument job * @return always 0 */ virtual int instrument_job_before(Trick::JobData * instrument_job ) = 0 ; @@ -96,8 +94,6 @@ namespace Trick { * otherwise adds in_job after each job in the initialization and scheduled queues. * Requirement [@ref r_exec_instrument_2] * @param instrument_job - the instrument job - * @param target_job - name of the target job, empty string means all jobs are to be instrumented - * @param in_event - instrumentation data to be stored with instrument job * @return always 0 */ virtual int instrument_job_after(Trick::JobData * instrument_job ) = 0 ; @@ -106,7 +102,6 @@ namespace Trick { * Removes an instrumentation job with the name in_job in the initialization and scheduled queues. * Requirement [@ref r_exec_instrument_3] * @param in_job - name of the instrument job - * @param in_event - instrumentation data to be searched for * @return always 0 */ virtual int instrument_job_remove(std::string in_job ) = 0 ; diff --git a/include/trick/SimObject.hh b/include/trick/SimObject.hh index 1dbb6a8c..7ada230e 100644 --- a/include/trick/SimObject.hh +++ b/include/trick/SimObject.hh @@ -65,7 +65,7 @@ namespace Trick { * @param name - name of lower level SimObject * @return always 0 */ - int add_pre_component_object(SimObject *, std::string name) ; + int add_pre_component_object(SimObject * in_object, std::string name) ; /** * Includes a lower level SimObject where the lower level jobs are called after this SimObject @@ -73,7 +73,7 @@ namespace Trick { * @param name - name of lower level SimObject * @return always 0 */ - int add_post_component_object(SimObject *, std::string name) ; + int add_post_component_object(SimObject * in_object, std::string name) ; /** * Adds a job to the sim_object. This call is typically in the S_source.cpp file diff --git a/include/trick/UnitTest.hh b/include/trick/UnitTest.hh index 84cc7d8c..00a2d49a 100644 --- a/include/trick/UnitTest.hh +++ b/include/trick/UnitTest.hh @@ -53,6 +53,9 @@ namespace Trick { /** Create test xml output.\n*/ bool enabled ; /**< trick_units(--) */ + /** Send the unit test exit code up the chain to Executive.\n*/ + bool exit_code_enabled ; /**< trick_units(--) */ + /** Name of Unit test\n*/ std::string name ; @@ -77,6 +80,12 @@ namespace Trick { */ bool enable() ; + /** + @brief Enable/Disable exit code return feature. + @return always 0 + */ + int set_exit_code_enabled( bool in_enable ) ; + /** @brief Output message to the file. */ @@ -96,6 +105,10 @@ namespace Trick { */ int set_file_name(std::string in_name) ; + /** + @brief Write output to xml file. + @return always 0 + */ int write_output() ; } ; diff --git a/include/trick/checkpoint_map.hh b/include/trick/checkpoint_map.hh index cd58c6c8..8c2cdf82 100644 --- a/include/trick/checkpoint_map.hh +++ b/include/trick/checkpoint_map.hh @@ -55,22 +55,26 @@ int checkpoint_map_ik_id(STL & in_map , std::string object_name , std::string va var_declare << type_string << " " << object_name << "_" << var_name << "_keys[" << cont_size << "]" ; keys = (typename STL::key_type *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ; - //message_publish(1, "HERE with %s\n", var_declare) ; + if ( keys ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ; + //message_publish(1, "HERE with %s\n", var_declare) ; - var_declare.str("") ; - var_declare.clear() ; - type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ; - var_declare << type_string << " " - << object_name << "_" << var_name << "_data[" << cont_size << "]" ; - items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ; - //message_publish(1, "HERE with %s\n", var_declare) ; + var_declare.str("") ; + var_declare.clear() ; + type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ; + var_declare << type_string << " " + << object_name << "_" << var_name << "_data[" << cont_size << "]" ; + items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare.str().c_str()) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ; + //message_publish(1, "HERE with %s\n", var_declare) ; - /* copy the contents of the map the 2 arrays */ - for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) { - keys[ii] = iter->first ; - items[ii] = iter->second ; + /* copy the contents of the map the 2 arrays */ + for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) { + keys[ii] = iter->first ; + items[ii] = iter->second ; + } + } } } return 0 ; @@ -111,29 +115,33 @@ int checkpoint_map_ik_sd(STL & in_map , std::string object_name , std::string va var_declare << type_string << " " << object_name << "_" << var_name << "_keys[" << cont_size << "]" ; keys = (typename STL::key_type *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ; - //message_publish(1, "HERE with %s\n", var_declare) ; + if ( keys ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ; + //message_publish(1, "HERE with %s\n", var_declare) ; - var_declare.str("") ; - var_declare.clear() ; - var_declare << "std::string " - << object_name << "_" << var_name << "_data[" << cont_size << "]" ; - items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ; - //message_publish(1, "HERE with %s\n", var_declare) ; + var_declare.str("") ; + var_declare.clear() ; + var_declare << "std::string " + << object_name << "_" << var_name << "_data[" << cont_size << "]" ; + items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ; + //message_publish(1, "HERE with %s\n", var_declare) ; - /* copy the contents of the map the 2 arrays */ - for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) { - keys[ii] = iter->first ; + /* copy the contents of the map the 2 arrays */ + for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) { + keys[ii] = iter->first ; - std::ostringstream sub_elements ; - sub_elements << object_name << "_" << var_name << "_data_" << ii ; - items[ii] = sub_elements.str() ; + std::ostringstream sub_elements ; + sub_elements << object_name << "_" << var_name << "_data_" << ii ; + items[ii] = sub_elements.str() ; - std::ostringstream index_string ; - index_string << ii ; - //message_publish(1, "recursive call to checkpoint_stl %s\n", __PRETTY_FUNCTION__) ; - checkpoint_stl( iter->second , object_name + "_" + var_name + "_data" , index_string.str() ) ; + std::ostringstream index_string ; + index_string << ii ; + //message_publish(1, "recursive call to checkpoint_stl %s\n", __PRETTY_FUNCTION__) ; + checkpoint_stl( iter->second , object_name + "_" + var_name + "_data" , index_string.str() ) ; + } + } } } return 0 ; @@ -173,30 +181,34 @@ int checkpoint_map_sk_id(STL & in_map , std::string object_name , std::string va var_declare << "std::string " << object_name << "_" << var_name << "_keys[" << cont_size << "]" ; keys = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ; - //message_publish(1, "HERE with %s\n", var_declare) ; + if ( keys ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ; + //message_publish(1, "HERE with %s\n", var_declare) ; - var_declare.str("") ; - var_declare.clear() ; - std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ; - var_declare << type_string << " " - << object_name << "_" << var_name << "_data[" << cont_size << "]" ; - items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ; - //message_publish(1, "HERE with %s\n", var_declare) ; + var_declare.str("") ; + var_declare.clear() ; + std::string type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*items).name(), 0, 0, &status )) ; + var_declare << type_string << " " + << object_name << "_" << var_name << "_data[" << cont_size << "]" ; + items = (typename STL::mapped_type *)TMM_declare_var_s(var_declare.str().c_str()) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ; + //message_publish(1, "HERE with %s\n", var_declare) ; - /* copy the contents of the map the 2 arrays */ - for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) { - std::ostringstream sub_elements ; - sub_elements << object_name << "_" << var_name << "_keys_" << ii ; - keys[ii] = sub_elements.str() ; + /* copy the contents of the map the 2 arrays */ + for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) { + std::ostringstream sub_elements ; + sub_elements << object_name << "_" << var_name << "_keys_" << ii ; + keys[ii] = sub_elements.str() ; - std::ostringstream index_string ; - index_string << ii ; - checkpoint_stl( const_cast(iter->first) , - object_name + "_" + var_name + "_keys", index_string.str() ) ; + std::ostringstream index_string ; + index_string << ii ; + checkpoint_stl( const_cast(iter->first) , + object_name + "_" + var_name + "_keys", index_string.str() ) ; - items[ii] = iter->second ; + items[ii] = iter->second ; + } + } } } return 0 ; @@ -235,33 +247,37 @@ int checkpoint_map_stl_sk_sd(STL & in_map , std::string object_name , std::strin var_declare << "std::string " << object_name << "_" << var_name << "_keys[" << cont_size << "]" ; keys = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ; - //message_publish(1, "HERE with %s\n", var_declare) ; + if ( keys ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_keys").c_str()) ; + //message_publish(1, "HERE with %s\n", var_declare) ; - var_declare.str("") ; - var_declare.clear() ; - var_declare << "std::string " - << object_name << "_" << var_name << "_data[" << cont_size << "]" ; - items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ; - //message_publish(1, "HERE with %s\n", var_declare) ; + var_declare.str("") ; + var_declare.clear() ; + var_declare << "std::string " + << object_name << "_" << var_name << "_data[" << cont_size << "]" ; + items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_data").c_str()) ; + //message_publish(1, "HERE with %s\n", var_declare) ; - /* copy the contents of the map the 2 arrays */ - for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) { - std::ostringstream sub_elements ; - sub_elements << object_name << "_" << var_name << "_keys_" << ii ; - keys[ii] = sub_elements.str() ; + /* copy the contents of the map the 2 arrays */ + for ( iter = in_map.begin() , ii = 0 ; iter != in_map.end() ; iter++ , ii++ ) { + std::ostringstream sub_elements ; + sub_elements << object_name << "_" << var_name << "_keys_" << ii ; + keys[ii] = sub_elements.str() ; - std::ostringstream index_string ; - index_string << ii ; - checkpoint_stl( const_cast(iter->first) , - object_name + "_" + var_name + "_keys", index_string.str() ) ; + std::ostringstream index_string ; + index_string << ii ; + checkpoint_stl( const_cast(iter->first) , + object_name + "_" + var_name + "_keys", index_string.str() ) ; - sub_elements << object_name << "_" << var_name << "_data_" << ii ; - items[ii] = sub_elements.str() ; + sub_elements << object_name << "_" << var_name << "_data_" << ii ; + items[ii] = sub_elements.str() ; - checkpoint_stl( iter->second , - object_name + "_" + var_name + "_data", index_string.str() ) ; + checkpoint_stl( iter->second , + object_name + "_" + var_name + "_data", index_string.str() ) ; + } + } } } return 0 ; diff --git a/include/trick/checkpoint_pair.hh b/include/trick/checkpoint_pair.hh index 7591846e..5b710c51 100644 --- a/include/trick/checkpoint_pair.hh +++ b/include/trick/checkpoint_pair.hh @@ -38,17 +38,21 @@ int checkpoint_stl(std::pair & in_pair , std::string object_name var_declare << type_string << " " << object_name << "_" << var_name << "_first[1]" ; first = (FIRST *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").c_str()) ; - first[0] = in_pair.first ; + if ( first ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").c_str()) ; + first[0] = in_pair.first ; - var_declare.str("") ; - var_declare.clear() ; - type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*second).name(), 0, 0, &status )) ; - var_declare << type_string << " " - << object_name << "_" << var_name << "_second[1]" ; - second = (SECOND *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_second").c_str()) ; - second[0] = in_pair.second ; + var_declare.str("") ; + var_declare.clear() ; + type_string = stl_type_name_convert(abi::__cxa_demangle(typeid(*second).name(), 0, 0, &status )) ; + var_declare << type_string << " " + << object_name << "_" << var_name << "_second[1]" ; + second = (SECOND *)TMM_declare_var_s(var_declare.str().c_str()) ; + if ( second ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_second").c_str()) ; + second[0] = in_pair.second ; + } + } return 0 ; } @@ -69,16 +73,20 @@ int checkpoint_stl(std::pair & in_pair , std::string object_name var_declare << type_string << " " << object_name << "_" << var_name << "_first[1]" ; first = (FIRST *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").c_str()) ; - first[0] = in_pair.first ; + if ( first ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_first").c_str()) ; + first[0] = in_pair.first ; - var_declare.str("") ; - var_declare.clear() ; - var_declare << "std::string " - << object_name << "_" << var_name << "_second[1]" ; - second = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_second").c_str()) ; - checkpoint_stl( in_pair.second , object_name + "_" + var_name , "second" ) ; + var_declare.str("") ; + var_declare.clear() ; + var_declare << "std::string " + << object_name << "_" << var_name << "_second[1]" ; + second = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; + if ( second ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name + "_second").c_str()) ; + checkpoint_stl( in_pair.second , object_name + "_" + var_name , "second" ) ; + } + } return 0 ; } diff --git a/include/trick/checkpoint_queue.hh b/include/trick/checkpoint_queue.hh index f46af853..3cf1ee64 100644 --- a/include/trick/checkpoint_queue.hh +++ b/include/trick/checkpoint_queue.hh @@ -47,12 +47,14 @@ int checkpoint_stl(std::queue & in_stl , std::string object var_declare << type_string << " " << object_name << "_" << var_name << "[" << cont_size << "]" ; items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; - //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; + //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; - for ( ii = 0 ; ii < cont_size ; ii++ ) { - items[ii] = temp_queue.front() ; - temp_queue.pop() ; + for ( ii = 0 ; ii < cont_size ; ii++ ) { + items[ii] = temp_queue.front() ; + temp_queue.pop() ; + } } } @@ -78,18 +80,20 @@ int checkpoint_stl(std::queue & in_stl , std::string object var_declare << "std::string " << object_name << "_" << var_name << "[" << cont_size << "]" ; items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; - //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; + //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; - for ( ii = 0 ; ii < cont_size ; ii++ ) { - std::ostringstream sub_elements ; - sub_elements << object_name << "_" << var_name << "_" << ii ; - items[ii] = sub_elements.str() ; + for ( ii = 0 ; ii < cont_size ; ii++ ) { + std::ostringstream sub_elements ; + sub_elements << object_name << "_" << var_name << "_" << ii ; + items[ii] = sub_elements.str() ; - std::ostringstream index_string ; - index_string << ii ; - checkpoint_stl (temp_queue.front(), object_name + "_" + var_name, index_string.str()) ; - temp_queue.pop() ; + std::ostringstream index_string ; + index_string << ii ; + checkpoint_stl (temp_queue.front(), object_name + "_" + var_name, index_string.str()) ; + temp_queue.pop() ; + } } } return 0 ; @@ -116,12 +120,14 @@ int checkpoint_stl(std::priority_queue & in_stl var_declare << type_string << " " << object_name << "_" << var_name << "[" << cont_size << "]" ; items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; - //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; + //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; - for ( ii = 0 ; ii < cont_size ; ii++ ) { - items[ii] = temp_queue.top() ; - temp_queue.pop() ; + for ( ii = 0 ; ii < cont_size ; ii++ ) { + items[ii] = temp_queue.top() ; + temp_queue.pop() ; + } } } @@ -148,18 +154,20 @@ int checkpoint_stl(std::priority_queue & in_stl var_declare << "std::string " << object_name << "_" << var_name << "[" << cont_size << "]" ; items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; - //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; + //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; - for ( ii = 0 ; ii < cont_size ; ii++ ) { - std::ostringstream sub_elements ; - sub_elements << object_name << "_" << var_name << "_" << ii ; - items[ii] = sub_elements.str() ; + for ( ii = 0 ; ii < cont_size ; ii++ ) { + std::ostringstream sub_elements ; + sub_elements << object_name << "_" << var_name << "_" << ii ; + items[ii] = sub_elements.str() ; - std::ostringstream index_string ; - index_string << ii ; - checkpoint_stl (const_cast< ITEM_TYPE &>(temp_queue.top()), object_name + "_" + var_name, index_string.str()) ; - temp_queue.pop() ; + std::ostringstream index_string ; + index_string << ii ; + checkpoint_stl (const_cast< ITEM_TYPE &>(temp_queue.top()), object_name + "_" + var_name, index_string.str()) ; + temp_queue.pop() ; + } } } diff --git a/include/trick/checkpoint_sequence_stl.hh b/include/trick/checkpoint_sequence_stl.hh index e135dd5e..1f992864 100644 --- a/include/trick/checkpoint_sequence_stl.hh +++ b/include/trick/checkpoint_sequence_stl.hh @@ -50,12 +50,14 @@ int checkpoint_sequence_i(STL & in_stl , std::string object_name , std::string v var_declare << type_string << " " << object_name << "_" << var_name << "[" << cont_size << "]" ; items = (typename STL::value_type *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; - //message_publish(1, "CHECKPOINT_SEQUENCE_STL with %s\n", var_declare) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; + //message_publish(1, "CHECKPOINT_SEQUENCE_STL with %s\n", var_declare) ; - /* copy the contents of the stl */ - for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; it++ , ii++ ) { - items[ii] = *it ; + /* copy the contents of the stl */ + for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; it++ , ii++ ) { + items[ii] = *it ; + } } } @@ -84,19 +86,21 @@ int checkpoint_sequence_s(STL & in_stl , std::string object_name , std::string v var_declare << "std::string " << object_name << "_" << var_name << "[" << cont_size << "]" ; items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; - //message_publish(1, "CHECKPOINT_SEQUENCE_STL_STL with %s\n", var_declare.str().c_str()) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; + //message_publish(1, "CHECKPOINT_SEQUENCE_STL_STL with %s\n", var_declare.str().c_str()) ; - /* create the names of the sub stl checkpoint names we're going to be using */ - for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; it++ , ii++ ) { - std::ostringstream sub_elements ; - sub_elements << object_name << "_" << var_name << "_" << ii ; - items[ii] = sub_elements.str() ; + /* create the names of the sub stl checkpoint names we're going to be using */ + for ( ii = 0 , it = in_stl.begin() , end = in_stl.end() ; it != end ; it++ , ii++ ) { + std::ostringstream sub_elements ; + sub_elements << object_name << "_" << var_name << "_" << ii ; + items[ii] = sub_elements.str() ; - std::ostringstream index_string ; - index_string << ii ; - //message_publish(1, "recursive call to checkpoint_stl %s\n", __PRETTY_FUNCTION__) ; - checkpoint_stl( (*it) , object_name + "_" + var_name , index_string.str() ) ; + std::ostringstream index_string ; + index_string << ii ; + //message_publish(1, "recursive call to checkpoint_stl %s\n", __PRETTY_FUNCTION__) ; + checkpoint_stl( (*it) , object_name + "_" + var_name , index_string.str() ) ; + } } } return 0 ; diff --git a/include/trick/checkpoint_stack.hh b/include/trick/checkpoint_stack.hh index 4dca87e5..84d66304 100644 --- a/include/trick/checkpoint_stack.hh +++ b/include/trick/checkpoint_stack.hh @@ -44,12 +44,14 @@ int checkpoint_stl(std::stack & in_stl , std::string object var_declare << type_string << " " << object_name << "_" << var_name << "[" << cont_size << "]" ; items = (ITEM_TYPE *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; - //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; + //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; - for ( ii = 0 ; ii < cont_size ; ii++ ) { - items[ii] = temp_stack.top() ; - temp_stack.pop() ; + for ( ii = 0 ; ii < cont_size ; ii++ ) { + items[ii] = temp_stack.top() ; + temp_stack.pop() ; + } } } @@ -75,18 +77,20 @@ int checkpoint_stl(std::stack & in_stl , std::string object var_declare << "std::string " << object_name << "_" << var_name << "[" << cont_size << "]" ; items = (std::string *)TMM_declare_var_s(var_declare.str().c_str()) ; - TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; - //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; + if ( items ) { + TMM_add_checkpoint_alloc_dependency(std::string(object_name + "_" + var_name).c_str()) ; + //message_publish(1, "CHECKPOINT_STL_STACK with %s\n", var_declare) ; - for ( ii = 0 ; ii < cont_size ; ii++ ) { - std::ostringstream sub_elements ; - sub_elements << object_name << "_" << var_name << "_" << ii ; - items[ii] = sub_elements.str() ; + for ( ii = 0 ; ii < cont_size ; ii++ ) { + std::ostringstream sub_elements ; + sub_elements << object_name << "_" << var_name << "_" << ii ; + items[ii] = sub_elements.str() ; - std::ostringstream index_string ; - index_string << ii ; - checkpoint_stl (temp_stack.top(), object_name + "_" + var_name, index_string.str()) ; - temp_stack.pop() ; + std::ostringstream index_string ; + index_string << ii ; + checkpoint_stl (temp_stack.top(), object_name + "_" + var_name, index_string.str()) ; + temp_stack.pop() ; + } } } diff --git a/include/trick/constant.h b/include/trick/constant.h index 2d4d70b1..b18f6660 100644 --- a/include/trick/constant.h +++ b/include/trick/constant.h @@ -15,14 +15,14 @@ PROGRAMMERS: #define MTOIN (39.370079) /* meters to inches */ #define FTOM (0.3048) /* feet to meters */ #define NMTOM (1852.0) /* nautical miles to meters */ -#define MTF (3.28083989501312336) /* meters to feet */ +#define MTF (3.28084) /* meters to feet */ #define LBFTON (4.4482216152605) /* pound-force to newtons */ -#define LBTOKG (0.4535923697760192) /* pound-mass to kilograms */ +#define LBTOKG (0.45359237) /* pound-mass to kilograms */ #define SLFTOKGM (1.355817947661907) /* slug-ft**2 to kilogram-m**2 */ -#define KGTOLB (2.204622622937404) /* kilograms to pound-mass */ +#define KGTOLB (2.20462262185) /* kilograms to pound-mass */ #define NMTOFP (0.7375621492772654) /* newton-meters to foot-pounds */ -#define SLTOLB (32.17404855643046) /* slugs to pounds */ -#define SLTOKG (14.5939029372064) /* slugs to kilograms */ +#define SLTOLB (32.174049) /* slugs to pounds */ +#define SLTOKG (14.59390) /* slugs to kilograms */ #endif diff --git a/include/trick/data_record_proto.h b/include/trick/data_record_proto.h index cd06c47b..bb1d557c 100644 --- a/include/trick/data_record_proto.h +++ b/include/trick/data_record_proto.h @@ -14,7 +14,10 @@ int dr_disable() ; int dr_enable_group( const char * in_name ) ; int dr_disable_group( const char * in_name ) ; int dr_record_now_group( const char * in_name ) ; +int dr_set_max_file_size ( uint64_t bytes ) ; void remove_all_data_record_groups() ; +int set_max_size_record_group (const char * in_name, uint64_t bytes ) ; + #ifdef __cplusplus int add_data_record_group( Trick::DataRecordGroup * in_group, Trick::DR_Buffering buffering = Trick::DR_Not_Specified ) ; diff --git a/include/trick/files_to_ICG.hh b/include/trick/files_to_ICG.hh index cf92da51..e3f59623 100644 --- a/include/trick/files_to_ICG.hh +++ b/include/trick/files_to_ICG.hh @@ -25,6 +25,7 @@ #include "trick/MSSharedMem.hh" #include "trick/MemoryManager.hh" #include "trick/MessageCout.hh" +#include "trick/MessageThreadedCout.hh" #include "trick/MessageFile.hh" #include "trick/MessageLCout.hh" #include "trick/MessagePublisher.hh" @@ -90,5 +91,6 @@ #include "trick/Flag.h" #include "trick/wave_form.h" #include "trick/rand_generator.h" +#include "trick/units_conv.h" #endif diff --git a/include/trick/message_type.h b/include/trick/message_type.h index 768b6790..3392335c 100644 --- a/include/trick/message_type.h +++ b/include/trick/message_type.h @@ -8,7 +8,7 @@ extern "C" { #endif /** - * @class Trick::MessagePublisher::MESSAGE_TYPE message_proto.h + * @enum Trick::MessagePublisher::MESSAGE_TYPE * The MESSAGE_TYPE enumeration represents types of messages to publish, which corresponds to the displayed color of the message. */ typedef enum { diff --git a/include/trick/parameter_types.h b/include/trick/parameter_types.h index e88347a8..9c430a11 100644 --- a/include/trick/parameter_types.h +++ b/include/trick/parameter_types.h @@ -11,7 +11,6 @@ extern "C" { #endif /** - * @class Trick::MemoryManager::TRICK_TYPE parameter_types.h * The TRICK_TYPE enumeration represents the Trick data types. */ typedef enum { @@ -45,6 +44,9 @@ extern "C" { const char* trickTypeCharString( TRICK_TYPE type, const char* name); +/* here for backwards compatibility */ +#define TRICK_USER_DEFINED_TYPE TRICK_OPAQUE_TYPE + /* Define int_64t and uint_64t depending on compiler options */ #if __linux # include diff --git a/include/trick/release.h b/include/trick/release.h index 85b0383c..54b86bae 100644 --- a/include/trick/release.h +++ b/include/trick/release.h @@ -1,8 +1,7 @@ /* PURPOSE: (This header file defines the "RELEASE()" macro for supported platforms. - The release function should yield the processor from the processes that - makes the call. This allows the UNIX schedular to arbitrate process + The release function should yield the processor from the processes that makes the call. This allows the UNIX schedular to arbitrate process priorities during spinloops based on the status of processes waiting to run) PROGRAMMER: diff --git a/include/trick/sim_mode.h b/include/trick/sim_mode.h index e8ca159e..1bdbd2ac 100644 --- a/include/trick/sim_mode.h +++ b/include/trick/sim_mode.h @@ -7,7 +7,7 @@ PROGRAMMERS: */ /** - * @class SIM_COMMAND sim_mode.h + * @enum SIM_COMMAND * The SIM_COMMAND enumeration represents the TRICK simulation commmands. */ @@ -24,7 +24,7 @@ typedef enum { } SIM_COMMAND; /** - * @class SIM_MODE sim_mode.h + * @enum SIM_MODE * The SIM_MODE enumeration represents the TRICK simulation modes. */ diff --git a/include/trick/trick_math_proto.h b/include/trick/trick_math_proto.h index 34445d6c..9953bbb8 100644 --- a/include/trick/trick_math_proto.h +++ b/include/trick/trick_math_proto.h @@ -9,6 +9,7 @@ #include "trick/wave_form.h" #include "trick/reference_frame.h" #include "trick/rand_generator.h" +#include "trick/RodriguesRotation.h" #ifdef __cplusplus extern "C" { diff --git a/include/trick/trick_tests.h b/include/trick/trick_tests.h index 268df9bb..0e6a6a53 100644 --- a/include/trick/trick_tests.h +++ b/include/trick/trick_tests.h @@ -80,6 +80,13 @@ #ifdef __cplusplus extern "C" { #endif + +int trick_test_enable() ; + +int trick_test_set_file_name( const char * in_file_name ) ; + +int trick_test_set_test_name( const char * in_test_name ) ; + int trick_test_add_parent(const char * in_test_suite_name, const char * in_test_case, const char * par_num ) ; diff --git a/libexec/trick/convert_swig b/libexec/trick/convert_swig index e3bac711..6caa904e 100755 --- a/libexec/trick/convert_swig +++ b/libexec/trick/convert_swig @@ -127,9 +127,14 @@ if ( $help ) { @include_dirs = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS -@exclude_paths = map abs_path($_), split /:/ , $ENV{"TRICK_EXCLUDE"} ; -@swig_exclude_paths = map abs_path($_), split /:/ , $ENV{"TRICK_SWIG_EXCLUDE"} ; -@ext_lib_paths = map abs_path($_), split /:/ , $ENV{"TRICK_EXT_LIB_DIRS"} ; +# Get environment variables, split on colons, strip leading/trailing whitespace, remove empty elements, get absolute paths +sub get_paths { + return map abs_path($_), grep { $_ ne '' } map { s/(^\s+|\s+$)//g ; $_ } split /:/, $ENV{$_[0]} ; +} +@exclude_paths = get_paths( "TRICK_EXCLUDE") ; +@swig_exclude_paths = get_paths( "TRICK_SWIG_EXCLUDE") ; +@ext_lib_paths = get_paths( "TRICK_EXT_LIB_DIRS") ; + @defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS if ( $ENV{"TRICK_CFLAGS"} !~ /DTRICK_VER=/ ) { push @defines , "-DTRICK_VER=$year" ; @@ -211,8 +216,8 @@ sub process_file() { # remove all comments, they can cause all kinds of trouble # leave the line continuation character if present - $raw_contents =~ s/\/\/(?:.*?)(\\)?(\n)/$1\n/sg ; - $raw_contents =~ s/\/\*(?:.*?)\*\/(\s*\\\n)?/$1/sg ; + $raw_contents =~ s/\/\*(?:.*?)\*\/|\/\/(?:.*?)(\\)?(\n)/$1\n/sg ; + ## The init_attr functions cause problems when we try and wrap them with SWIG. ## We can safely remove them from the header files. @@ -258,7 +263,7 @@ sub process_file() { } # Get the canonical path (resolve ., .., and symbolic links) - $file_name = abs_path($file_name) ; + $file_name = abs_path(dirname($file_name)) . "/" . basename($file_name) ; # Skip excluded paths foreach my $i ( @exclude_paths, @swig_exclude_paths ) { @@ -266,7 +271,6 @@ sub process_file() { next outer ; } } - $file_name = "build" . $file_name ; $file_name =~ s/\.[^\.]+?$/\_py.i/ ; $contents .= "\%import \"$file_name\"\n" ; diff --git a/libexec/trick/java/lib/JUnitXmlFormatter.jar b/libexec/trick/java/lib/JUnitXmlFormatter.jar new file mode 100644 index 00000000..f931412c Binary files /dev/null and b/libexec/trick/java/lib/JUnitXmlFormatter.jar differ diff --git a/libexec/trick/java/lib/Makefile b/libexec/trick/java/lib/Makefile index f3f3ca0d..f66ab9a0 100644 --- a/libexec/trick/java/lib/Makefile +++ b/libexec/trick/java/lib/Makefile @@ -15,7 +15,8 @@ EXTERNAL_JARS = \ jfreesvg-2.1.jar \ jopt-simple-4.8.jar \ junit-4.12.jar \ - swingx-1.6.1.jar + swingx-1.6.1.jar \ + hamcrest-core-1.3.jar external_jars : ${EXTERNAL_JARS} @@ -35,6 +36,8 @@ junit-4.12.jar: curl -O http://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.jar swingx-1.6.1.jar : curl -O http://repo.maven.apache.org/maven2/org/swinglabs/swingx/1.6.1/swingx-1.6.1.jar +hamcrest-core-1.3.jar : + curl -O http://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar clean: rm -f ${EXTERNAL_JARS} diff --git a/libexec/trick/make_makefile_src b/libexec/trick/make_makefile_src index 30e055cc..325a0dac 100755 --- a/libexec/trick/make_makefile_src +++ b/libexec/trick/make_makefile_src @@ -133,7 +133,7 @@ if (scalar @exclude_dirs) { # Error check - delete any element that is null # (note: sort forced all blank names to front of array @exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @exclude_dirs ; - while ( not length @exclude_dirs[0] ) { + while ( scalar @exclude_dirs and not length @exclude_dirs[0] ) { # Delete an element from the left side of an array (element zero) shift @exclude_dirs ; } @@ -370,7 +370,7 @@ foreach $k ( sort keys %files_by_dir ) { s/\$[{(]CURDIR[})]\/(\S+)/$k\/$1/g ; s/(?:\$[{(]CURDIR[})]\/)?(\S*)\$[{(]OBJ_DIR[})]/$k\/$1object_\${TRICK_HOST_CPU}/g ; s/\$[{(]CURDIR[})]/$k/g ; - while ( s,/[^/]+/\.\.,, ) {} + while ( s,/[^/.]+/\.\.,, ) {} s//$comment/ ; if ( s/^objects\s*:\s*// ) { foreach my $ext ( qw{c C cc cxx cpp CPLUSPLUS l y} ) { @@ -388,8 +388,10 @@ foreach $k ( sort keys %files_by_dir ) { } } close OV_FILE ; + print MAKEFILEOVER "\nMAKEFILE_LIST += $k/makefile_overrides\n" ; print MAKEFILEOVER "\n# Overrides from $k\n\n" ; print MAKEFILEOVER "$files_by_dir{$k}{overrides}\n" ; + print MAKEFILEOVER "\nMAKEFILE_LIST := \$(filter-out $k/makefile_overrides,\$(MAKEFILE_LIST))\n" ; } } close MAKEFILEOVER ; diff --git a/libexec/trick/make_makefile_swig b/libexec/trick/make_makefile_swig index d296dee9..cf5033cd 100755 --- a/libexec/trick/make_makefile_swig +++ b/libexec/trick/make_makefile_swig @@ -27,7 +27,7 @@ sub get_paths { # trim whitespace @paths = map { s/(^\s+|\s+$)//g ; $_ } @paths ; # Remove empty elements. Sort forced all blank names to the front. - while ( not length @paths[0] ) { + while ( scalar @paths and not length @paths[0] ) { shift @paths ; } @paths = map { (-e $_) ? abs_path($_) : $_ } @paths ; @@ -95,6 +95,10 @@ sub read_files_to_process() { print "SWIG Skip TRICK_EXCLUDE: $path$1\n" if $verbose_build ; next outer ; } + if ( abs_path($word) =~ /^\Q$path\E(.*)/ ) { + print "SWIG Skip TRICK_EXCLUDE: $path$1\n" if $verbose_build ; + next outer ; + } } # skip paths in TRICK_SWIG_EXCLUDE @@ -103,6 +107,10 @@ sub read_files_to_process() { print "SWIG Skip TRICK_SWIG_EXCLUDE: $path$1\n" if $verbose_build ; next outer ; } + if ( abs_path($word) =~ /^\Q$path\E(.*)/ ) { + print "SWIG Skip TRICK_SWIG_EXCLUDE: $path$1\n" if $verbose_build ; + next outer ; + } } # we'll be needing this later @@ -165,6 +173,8 @@ sub write_makefile_swig() { ifeq (\$(IS_CC_CLANG), 1) SWIG_CFLAGS += -Wno-self-assign -Wno-sometimes-uninitialized -Wno-deprecated-register +else + SWIG_CFLAGS += -Wno-unused-but-set-variable endif ifndef TRICK_VERBOSE_BUILD diff --git a/libexec/trick/pm/gte.pm b/libexec/trick/pm/gte.pm index b5ec518b..dbf48a6b 100644 --- a/libexec/trick/pm/gte.pm +++ b/libexec/trick/pm/gte.pm @@ -93,6 +93,7 @@ sub gte (@) { $def{"TRICK_ICG_COMPAT15"} = "" ; $def{"TRICK_ICG_NOCOMMENT"} = "" ; $def{"TRICK_ICG_EXCLUDE"} = "" ; + $def{"TRICK_ICG_IGNORE_TYPES"} = "" ; $def{"TRICK_SWIG_EXCLUDE"} = "" ; $def{"TRICK_EXT_LIB_DIRS"} = "" ; $def{"TRICK_PYTHON_PATH"} = "" ; diff --git a/libexec/trick/pm/launch_java.pm b/libexec/trick/pm/launch_java.pm index bb386fc4..006a3add 100644 --- a/libexec/trick/pm/launch_java.pm +++ b/libexec/trick/pm/launch_java.pm @@ -1,11 +1,11 @@ #!/usr/bin/perl package launch_java ; -@ISA = qw(Exporter); -@EXPORT = qw(launch_java); +@ISA = qw(Exporter) ; +@EXPORT = qw(launch_java) ; # launch_java determines trick_home based on execution location of the calling script. use File::Basename ; -use Cwd 'abs_path'; +use Cwd 'abs_path' ; use gte ; sub launch_java($$) { @@ -26,6 +26,10 @@ sub launch_java($$) { $lib_dir = "lib" ; } $java_dir = "$ENV{TRICK_HOME}/$lib_dir/trick/java" ; + + $javac_version = `javac -version 2>&1` ; + $javac_version =~ /(\d+)/ ; + $javac_version = $1 ; $host_cpu = gte("TRICK_HOST_CPU") ; chomp($host_cpu) ; @@ -35,18 +39,23 @@ sub launch_java($$) { $command = "java -classpath $java_dir/dist/*:$java_dir/lib/*:$java_dir/lib/ \\ -Xdock:name=\"$name\" \\ -Xdock:icon=$java_dir/resources/trick_icon.png \\ - -Djava.net.preferIPv4Stack=true \\ - $application" ; + -Djava.net.preferIPv4Stack=true \\" ; } else { - $command = "java -cp $java_dir/dist/*:$java_dir/lib/*:$java_dir/lib/ $application" ; + $command = "java -cp $java_dir/dist/*:$java_dir/lib/*:$java_dir/lib/ \\" ; } + if ( ($javac_version eq "9") or ($javac_version eq "10") ) { + $command .= " + --add-modules java.se.ee \\" ; + } + $command .= " + $application" ; foreach (@ARGV) { - $command .= " $_"; + $command .= " $_" ; } system $command ; - exit $? >> 8; + exit $? >> 8 ; } -1; +1 ; diff --git a/libexec/trick/pm/parse_s_define.pm b/libexec/trick/pm/parse_s_define.pm index eec2a21d..8c2dfe92 100644 --- a/libexec/trick/pm/parse_s_define.pm +++ b/libexec/trick/pm/parse_s_define.pm @@ -746,7 +746,8 @@ sub handle_sim_class_job($$$) { $tag =~ s/\s+//g ; @tags = split /,/ , $tag ; } - $job_push = "job = add_job($child, $job_id, $class, $sup_class_data, $cycle, \"$job_name\", \"\"" ; + # do not remove "this->", see issue #532 + $job_push = "job = this->add_job($child, $job_id, $class, $sup_class_data, $cycle, \"$job_name\", \"\"" ; if ( $class =~ /^integration$/ ) { if ($job_ret !~ /trick_ret/ ) { diff --git a/share/doc/trick/Trick17_Tutorial_Review.pdf b/share/doc/trick/Trick17_Tutorial_Review.pdf new file mode 100644 index 00000000..50c247bf Binary files /dev/null and b/share/doc/trick/Trick17_Tutorial_Review.pdf differ diff --git a/share/doc/trick/Trick17_Tutorial_Review.pptx b/share/doc/trick/Trick17_Tutorial_Review.pptx new file mode 100644 index 00000000..172959e0 Binary files /dev/null and b/share/doc/trick/Trick17_Tutorial_Review.pptx differ diff --git a/share/trick/makefiles/Makefile.common b/share/trick/makefiles/Makefile.common index a5ffd2b0..084d8307 100644 --- a/share/trick/makefiles/Makefile.common +++ b/share/trick/makefiles/Makefile.common @@ -33,30 +33,24 @@ ifndef TRICK_LD export TRICK_LD := $(LD) endif -ifndef TRICK_SFLAGS - export TRICK_SFLAGS := -endif - -export TRICK_CFLAGS -export TRICK_CXXFLAGS -export TRICK_LDFLAGS -export TRICK_SFLAGS -export TRICK_EXCLUDE -export TRICK_ICG_COMPAT15 -export TRICK_ICG_EXCLUDE -export TRICK_ICG_NOCOMMENT -export TRICK_SWIG_EXCLUDE -export TRICK_EXT_LIB_DIRS -export TRICK_PYTHON_PATH -export TRICK_GTE_EXT +export TRICK_CFLAGS := $(TRICK_CFLAGS) +export TRICK_CXXFLAGS := $(TRICK_CXXFLAGS) +export TRICK_LDFLAGS := $(TRICK_LDFLAGS) +export TRICK_SFLAGS := $(TRICK_SFLAGS) +export TRICK_EXCLUDE := $(TRICK_EXCLUDE) +export TRICK_ICG_COMPAT15 := $(TRICK_ICG_COMPAT15) +export TRICK_ICG_EXCLUDE := $(TRICK_ICG_EXCLUDE) +export TRICK_ICG_IGNORE_TYPES := $(TRICK_ICG_IGNORE_TYPES) +export TRICK_ICG_NOCOMMENT := $(TRICK_ICG_NOCOMMENT) +export TRICK_SWIG_EXCLUDE := $(TRICK_SWIG_EXCLUDE) +export TRICK_EXT_LIB_DIRS := $(TRICK_EXT_LIB_DIRS) +export TRICK_PYTHON_PATH := $(TRICK_PYTHON_PATH) +export TRICK_GTE_EXT := $(TRICK_GTE_EXT) export TRICK_HOST_CPU := $(shell $(TRICK_HOME)/bin/trick-gte TRICK_HOST_CPU) -export TRICK_EXEC_LINK_LIBS = ${PTHREAD_LIBS} $(PYTHON_LIB) $(UDUNITS_LDFLAGS) $(PLATFORM_LIBS) -lm -ldl -export TRICK_LIBS = ${RPATH} -L${TRICK_LIB_DIR} -ltrick -ltrick_pyip -ltrick_comm -ltrick_math -ltrick_units -ltrick_mm -export TRICK_SYSTEM_CFLAGS -export TRICK_SYSTEM_CXXFLAGS -export TRICK_SYSTEM_SFLAGS -export TRICK_SYSTEM_LDFLAGS -export SWIG_FLAGS +export TRICK_EXEC_LINK_LIBS := ${PTHREAD_LIBS} $(PYTHON_LIB) $(UDUNITS_LDFLAGS) $(PLATFORM_LIBS) -lm -ldl +export TRICK_LIBS := ${RPATH} -L${TRICK_LIB_DIR} -ltrick -ltrick_pyip -ltrick_comm -ltrick_math -ltrick_units -ltrick_mm +export TRICK_SYSTEM_LDFLAGS := $(TRICK_SYSTEM_LDFLAGS) +export SWIG_FLAGS := $(SWIG_FLAGS) IO_SRC_DIR := io_src/ OBJ_DIR := object_${TRICK_HOST_CPU} @@ -80,14 +74,8 @@ endif TRICK_INCLUDES := -I${TRICK_HOME}/trick_source -I${TRICK_HOME}/include -I${TRICK_HOME}/include/trick/compat TRICK_VERSIONS := -DTRICK_VER=$(TRICK_MAJOR) -DTRICK_MINOR=$(TRICK_MINOR) -TRICK_SYSTEM_CXXFLAGS = $(TRICK_INCLUDES) $(TRICK_VERSIONS) -fpic $(UDUNITS_INCLUDES) -TRICK_SYSTEM_SFLAGS = -I${TRICK_HOME}/share/trick -I${TRICK_HOME}/share $(TRICK_INCLUDES) $(TRICK_VERSIONS) - -# We pipe the output of compiler through tee. If the user wanted gcc color, make sure they get it. -ifdef GCC_COLORS - TRICK_SYSTEM_CXXFLAGS += -fdiagnostics-color=always - TRICK_SYSTEM_CFLAGS += -fdiagnostics-color=always -endif +export TRICK_SYSTEM_CXXFLAGS := $(TRICK_INCLUDES) $(TRICK_VERSIONS) -fpic $(UDUNITS_INCLUDES) +export TRICK_SYSTEM_SFLAGS := -I${TRICK_HOME}/share/trick -I${TRICK_HOME}/share $(TRICK_INCLUDES) $(TRICK_VERSIONS) HAVE_ZEROCONF ?= 0 ifeq ($(HAVE_ZEROCONF),1) @@ -147,8 +135,13 @@ ifneq ($(GSL_HOME),) TRICK_SYSTEM_CXXFLAGS += -D_HAVE_GSL endif +# We pipe the output of compiler through tee. If the user wanted gcc color, make sure they get it. +ifdef GCC_COLORS + TRICK_SYSTEM_CXXFLAGS += -fdiagnostics-color=always +endif + # -fexceptions is included to propogate execptions through C code. -TRICK_SYSTEM_CFLAGS := $(TRICK_SYSTEM_CXXFLAGS) -fexceptions +export TRICK_SYSTEM_CFLAGS := $(TRICK_SYSTEM_CXXFLAGS) -fexceptions # append additional c and cxx flags defined in config_*.mk files. TRICK_SYSTEM_CFLAGS += $(TRICK_ADDITIONAL_CFLAGS) diff --git a/share/trick/makefiles/config_user.mk.in b/share/trick/makefiles/config_user.mk.in index d74fce6e..ca72ec51 100644 --- a/share/trick/makefiles/config_user.mk.in +++ b/share/trick/makefiles/config_user.mk.in @@ -26,6 +26,7 @@ MOTIF_HOME = @MOTIF_HOME@ UDUNITS_INCLUDES = @UDUNITS_INCLUDES@ UDUNITS_LDFLAGS = @UDUNITS_LDFLAGS@ +TRICK_EXCLUDE += :@UDUNITS_EXCLUDE@ HDF5 = @HDF5_HOME@ DMTCP = @DMTCP_HOME@ diff --git a/pymods/trick/__init__.py b/share/trick/pymods/trick/__init__.py similarity index 100% rename from pymods/trick/__init__.py rename to share/trick/pymods/trick/__init__.py diff --git a/pymods/trick/tests/__init__.py b/share/trick/pymods/trick/tests/__init__.py similarity index 100% rename from pymods/trick/tests/__init__.py rename to share/trick/pymods/trick/tests/__init__.py diff --git a/pymods/trick/tests/test_variable_server.py b/share/trick/pymods/trick/tests/test_variable_server.py similarity index 100% rename from pymods/trick/tests/test_variable_server.py rename to share/trick/pymods/trick/tests/test_variable_server.py diff --git a/pymods/trick/variable_server.py b/share/trick/pymods/trick/variable_server.py similarity index 100% rename from pymods/trick/variable_server.py rename to share/trick/pymods/trick/variable_server.py diff --git a/share/trick/sim_objects/default_trick_sys.sm b/share/trick/sim_objects/default_trick_sys.sm index f945fdcb..33c6bd75 100644 --- a/share/trick/sim_objects/default_trick_sys.sm +++ b/share/trick/sim_objects/default_trick_sys.sm @@ -47,6 +47,7 @@ a replacement SimObject will create an uncompilable sim. ##include "trick/MessagePublisher.hh" ##include "trick/MessageSubscriber.hh" ##include "trick/MessageCout.hh" +##include "trick/MessageThreadedCout.hh" ##include "trick/MessageLCout.hh" ##include "trick/MessageFile.hh" ##include "trick/MessageTCDevice.hh" @@ -266,6 +267,7 @@ class MessageSimObject : public Trick::SimObject { public: Trick::MessagePublisher mpublisher ; Trick::MessageCout mcout ; + Trick::MessageThreadedCout mtcout ; Trick::MessageFile mfile ; Trick::MessageTCDevice mdevice ; Trick::PlaybackFile pfile ; @@ -273,11 +275,13 @@ class MessageSimObject : public Trick::SimObject { MessageSimObject() { {TRK} ("default_data") mpublisher.subscribe(&mcout) ; + //{TRK} ("default_data") mpublisher.subscribe(&mtcout) ; {TRK} ("default_data") mpublisher.subscribe(&mfile) ; {TRK} ("default_data") mpublisher.subscribe(&mdevice) ; {TRK} ("default_data") mpublisher.subscribe(&pfile) ; {TRK} ("default_data") mdevice.default_data() ; {TRK} P1 ("initialization") mpublisher.init() ; + //{TRK} P1 ("initialization") mtcout.init() ; {TRK} P1 ("initialization") mfile.init() ; {TRK} P1 ("initialization") pfile.init() ; {TRK} P1 ("initialization") mdevice.init() ; @@ -287,6 +291,7 @@ class MessageSimObject : public Trick::SimObject { #ifndef TRICK_NO_DMTCP {TRK} P1 ("dmtcp_restart") mdevice.restart() ; #endif + {TRK} ("shutdown") mtcout.shutdown() ; {TRK} ("shutdown") mdevice.shutdown() ; } @@ -583,7 +588,7 @@ class FrameLogSimObject : public Trick::SimObject { Trick::FrameLog frame_log ; - FrameLogSimObject() { + FrameLogSimObject(Trick::Clock &in_clock) : frame_log(in_clock) { // Frame log Instrumentation class jobs. Not scheduled by default {TRK} P0 ("instrumentation") frame_log.frame_clock_start(curr_job) ; {TRK} P65535 ("instrumentation") frame_log.frame_clock_stop(curr_job) ; @@ -601,9 +606,13 @@ class FrameLogSimObject : public Trick::SimObject { // the frame_log and rt_sync shutdown jobs should be last in sim {TRK} P65535 ("shutdown") frame_log.shutdown() ; } + + private: + // This object is not copyable + void operator =(const FrameLogSimObject &) {}; } -FrameLogSimObject trick_frame_log ; +FrameLogSimObject trick_frame_log(trick_real_time.gtod_clock) ; #endif #ifndef TRICK_NO_MASTERSLAVE diff --git a/test/SIM_rti/ClassOfEverything.hh b/test/SIM_rti/ClassOfEverything.hh index 8f0f2471..340b5e26 100644 --- a/test/SIM_rti/ClassOfEverything.hh +++ b/test/SIM_rti/ClassOfEverything.hh @@ -55,8 +55,8 @@ class ClassOfEverything { float * fap[4] ; /* kg blah */ float ** fpp ; /* kg blah */ - float f_rad ; /* r float test value */ - double d_deg ; /* d blah */ + float f_rad ; /* rad float test value */ + double d_deg ; /* degree blah */ char c ; /* -- blah */ char ca[20] ; /* -- blah */ diff --git a/test/SIM_test_dp/models/dp/include/dp.h b/test/SIM_test_dp/models/dp/include/dp.h index ca8267fe..3186563c 100644 --- a/test/SIM_test_dp/models/dp/include/dp.h +++ b/test/SIM_test_dp/models/dp/include/dp.h @@ -16,8 +16,8 @@ typedef struct { float f[3] ; /* m/s2 -- */ double d[3] ; /* kg*m/s2 -- */ unsigned short us[3] ; /* N -- */ - unsigned int ui[3] ; /* cnt -- */ - unsigned long ul[3] ; /* v -- */ + unsigned int ui[3] ; /* count -- */ + unsigned long ul[3] ; /* V -- */ long long ll[3] ; /* K -- */ } STRUCT_1 ; diff --git a/trick_sims/Cannon/models/cannon/gravity/src/cannon_numeric.c b/trick_sims/Cannon/models/cannon/gravity/src/cannon_numeric.c index eb66964e..05d71443 100644 --- a/trick_sims/Cannon/models/cannon/gravity/src/cannon_numeric.c +++ b/trick_sims/Cannon/models/cannon/gravity/src/cannon_numeric.c @@ -49,21 +49,20 @@ int cannon_integ( CANNON* C ) { /* The cannonball sim's dynamic job */ double cannon_impact( CANNON* C ) { - - double tgo ; - double now ; - /* Set error function --- how far ball is above ground */ - C->rf.error = C->pos[1] ; - now = get_integ_time() ; - tgo = regula_falsi( now, &(C->rf) ) ; - if (tgo == 0.0) { + double tgo ; /* time-to-go */ + double now ; /* current integration time. */ + + C->rf.error = C->pos[1] ; /* Specify the event boundary. */ + now = get_integ_time() ; /* Get the current integration time */ + tgo = regula_falsi( now, &(C->rf) ) ; /* Estimate remaining integration time. */ + if (tgo == 0.0) { /* If we are at the event, it's action time! */ now = get_integ_time() ; - reset_regula_falsi( now, &(C->rf) ) ; + reset_regula_falsi( now, &(C->rf) ) ; C->impact = 1 ; - C->impactTime = now; + C->impactTime = now ; C->vel[0] = 0.0 ; C->vel[1] = 0.0 ; C->acc[0] = 0.0 ; C->acc[1] = 0.0 ; - fprintf(stderr, "\n\nIMPACT: SimTime = %.9f, ModelTime = %.9f, pos = %.9f\n\n", now, C->impactTime, C->pos[0] ) ; + fprintf(stderr, "\n\nIMPACT: SimTime = %.9f, pos = %.9f\n\n", now, C->pos[0] ) ; } - return ( tgo ) ; + return (tgo) ; } diff --git a/trick_sims/Cannon/models/graphics/Makefile b/trick_sims/Cannon/models/graphics/Makefile index c1756b7c..80c71dec 100644 --- a/trick_sims/Cannon/models/graphics/Makefile +++ b/trick_sims/Cannon/models/graphics/Makefile @@ -29,7 +29,7 @@ $(JAR_DIR): @ mkdir -p $(JAR_DIR) jar: compile manifest | $(JAR_DIR) - jar cvfm $(JAR_DIR)/$(PROJECT_NAME).jar manifest -C $(CLASSES_DIR) . + jar cvfm $(JAR_DIR)/$(PROJECT_NAME).jar manifest -C $(CLASSES_DIR) . -C resources . @ echo "-------------------------------------------------------------------------------" @ echo " BUILD COMPLETE" @ echo "The Java jar file (the Java Executable) is located at: $(JAR_DIR)/$(PROJECT_NAME).jar" diff --git a/trick_sims/Cannon/models/graphics/resources/CannonBoom.wav b/trick_sims/Cannon/models/graphics/resources/CannonBoom.wav new file mode 100644 index 00000000..9d9df008 Binary files /dev/null and b/trick_sims/Cannon/models/graphics/resources/CannonBoom.wav differ diff --git a/trick_sims/Cannon/models/graphics/resources/Explosion.wav b/trick_sims/Cannon/models/graphics/resources/Explosion.wav new file mode 100644 index 00000000..0941a309 Binary files /dev/null and b/trick_sims/Cannon/models/graphics/resources/Explosion.wav differ diff --git a/trick_sims/Cannon/models/graphics/src/CannonDisplay.java b/trick_sims/Cannon/models/graphics/src/CannonDisplay.java index b73e5677..f39157bf 100644 --- a/trick_sims/Cannon/models/graphics/src/CannonDisplay.java +++ b/trick_sims/Cannon/models/graphics/src/CannonDisplay.java @@ -24,7 +24,8 @@ import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; - +import javax.sound.sampled.*; +import java.net.URL; /** * * @author penn @@ -531,7 +532,7 @@ class TrickSimMode { } public class CannonDisplay extends JFrame { - + private RangeView rangeView; private ElevationPanel elevPanel; private MuzzleVelPanel velPanel; @@ -541,6 +542,34 @@ public class CannonDisplay extends JFrame { private JPanel panelGroup1; private ButtonPanel buttonPanel; + public enum SoundEffect { + EXPLOSION("Explosion.wav"), + CANNONBOOM("CannonBoom.wav"); + + private Clip clip; + + SoundEffect(String soundFileName) { + try { + URL url = this.getClass().getClassLoader().getResource(soundFileName); + AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(url); + clip = AudioSystem.getClip(); + clip.open(audioInputStream); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void play() { + if (clip.isRunning()) clip.stop(); + clip.setFramePosition(0); + clip.start(); + } + + static void init() { + values(); + } + } + public CannonDisplay(RangeView arena) { setTitle("Cannon Range"); @@ -570,6 +599,8 @@ public class CannonDisplay extends JFrame { setSize(800, 500); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + SoundEffect.init(); } public int getBarrelAngle() { @@ -654,6 +685,7 @@ public class CannonDisplay extends JFrame { String host = "localHost"; int port = 0; + boolean boom = false; // ========================================================== // Handle program arguments. @@ -771,21 +803,18 @@ public class CannonDisplay extends JFrame { } if (simMode == TrickSimMode.RUN) { - evd.resetFireCommand(); + if (boom) { + SoundEffect.CANNONBOOM.play(); + boom = false; + } } // Update the display data. evd.setCannonBallPos(posx, posy); evd.setCannonBallVel(velx, vely); - // Get inputs from the GUI. - angle = evd.getBarrelAngle(); - speed = evd.getMuzzleVelocity(); - armCommand = evd.getArmCommand(); - fireCommand = evd.getFireCommand(); - if (simMode == TrickSimMode.FREEZE) { - if (armCommand) { + if (evd.getArmCommand()) { evd.out.writeBytes( String.format("dyn.cannon.pos[0] = %.2f ;\n", -0.1020 )); evd.out.writeBytes( String.format("dyn.cannon.pos[1] = %.2f ;\n", 0.9400 )); evd.out.writeBytes( String.format("dyn.cannon.vel[0] = %.2f ;\n", 0.0000 )); @@ -794,7 +823,9 @@ public class CannonDisplay extends JFrame { evd.resetArmCommand(); } - if (fireCommand) { + if (evd.getFireCommand()) { + angle = evd.getBarrelAngle(); + speed = evd.getMuzzleVelocity(); evd.out.writeBytes( String.format("dyn.cannon.init_angle = %.2f ;\n", Math.toRadians(angle))); evd.out.writeBytes( String.format("dyn.cannon.init_speed = %.2f;\n", speed )); evd.out.writeBytes( String.format("dyn.cannon.pos0[0] = %.2f ;\n", -0.1020 )); @@ -802,8 +833,9 @@ public class CannonDisplay extends JFrame { evd.out.writeBytes( String.format("dyn.cannon.time = %.2f ;\n", 0.0 )); evd.out.writeBytes( String.format("trick.cannon_init( dyn.cannon );\n" )); evd.out.writeBytes( String.format("trick.exec_run();\n" )); - evd.resetFireCommand(); evd.out.flush(); + evd.resetFireCommand(); + boom = true; } } @@ -823,6 +855,7 @@ public class CannonDisplay extends JFrame { exticks = 0; evd.setExplosionPos(posx, posy); explosionModelState = ModelState.ACTIVE; + SoundEffect.EXPLOSION.play(); } break; case ACTIVE: diff --git a/trick_sims/SIM_msd/Modified_data/realtime.py b/trick_sims/SIM_msd/Modified_data/realtime.py new file mode 100644 index 00000000..76de2adf --- /dev/null +++ b/trick_sims/SIM_msd/Modified_data/realtime.py @@ -0,0 +1,7 @@ +trick.frame_log_on() +trick.real_time_enable() +trick.exec_set_software_frame(0.1) +trick.itimer_enable() +trick.exec_set_enable_freeze(True) +trick.exec_set_freeze_command(True) +trick.sim_control_panel_set_enabled(True) \ No newline at end of file diff --git a/trick_sims/SIM_msd/README.md b/trick_sims/SIM_msd/README.md new file mode 100644 index 00000000..b546ab88 --- /dev/null +++ b/trick_sims/SIM_msd/README.md @@ -0,0 +1,84 @@ +# SIM_MSD + +SIM\_MSD is a simulator for a mass-spring-damper system. + +![Picture of MSD](./images/MSD0.png) + + The system is described by the equation _mẍ_ + _bẋ_ + _kx_ = _F_, where: + + _m_ is the mass of an object. + + _x_ is the position of the mass. + + _b_ is the damping coefficient. + + _k_ is the spring coefficient. + + _F_ is an external force applied to the mass. + +--- +### Building the Simulation + +In the SIM_MSD directory, execute **trick-CP** to build the simulation executable. When it's complete, you should see: + +``` +=== Simulation make complete === +``` + +Now **cd** into models/Graphics/ and type **make**. This builds the display client for the simulation. + +### Running the Simulation +In the SIM_MSD directory: + +``` +% ./S_main_*.exe RUN_test/input.py +``` + +The following windows should appear: + +![Picture of MSD](./images/MSD2.png) + +![Picture of Control](./images/MSD3.png) + +### Controlling the Simulation +Click **Start** to begin the simulation. + +Click **Reset** to freeze the simulation and reset the position and velocity to +their initial conditions. + +Change **Position** and **Velocity** to adjust the initial conditions for those +attributes. + +Change **Mass**, **Spring Coefficient**, **Damping Coefficient**, and **Applied +Force** to adjust initial conditions _**and**_ also update the sim in real-time. + + + + + + +--- +The following inputs can be set in any of the RUN_*/input.py files to change +the inputs on startup +### Inputs + +Variable | Type | Units | Default Value +---------- |-----------|-------|-------------- +dyn.msd.x_0 | double | m | 5.0 +dyn.msd.v_0 | double | m/s | 0.0 +dyn.msd.b | double | N.s/m | 0.5 +dyn.msd.k | double | N/m | 2.0 +dyn.msd.F | double | N | 5.0 +dyn.msd.m | double | kg | 1.0 + +--- +Some sample input.py files have been created to demonstrate different +mass-spring-damper conditions +### Samples + +Path |Type +------------------------|---------------------------------------------- +RUN_underdamp/input.py |Underdamped Harmonic Oscillator +RUN_critdamp/input.py |Critically Damped Harmonic Oscillator +RUN_overdamp/input.py |Overdamped Harmonic Oscillator +RUN_nodamp/input.py | Simple Harmonic Oscillator (No Damping Force) diff --git a/trick_sims/SIM_msd/RUN_critdamp/input.py b/trick_sims/SIM_msd/RUN_critdamp/input.py new file mode 100644 index 00000000..dbad25fe --- /dev/null +++ b/trick_sims/SIM_msd/RUN_critdamp/input.py @@ -0,0 +1,23 @@ +dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 4) +execfile("Modified_data/realtime.py") + +dyn.msd.b = 2*(2**(0.5)) + +#========================================== +# Start the display VarServer Client +#========================================== +varServerPort = trick.var_server_get_port(); +MsdGui_path = "models/graphics/dist/MsdGui.jar" + +if (os.path.isfile(MsdGui_path)) : + MsdGui_cmd = "java -jar " \ + + MsdGui_path \ + + " " + str(varServerPort) + " &" ; + print(MsdGui_cmd) + os.system( MsdGui_cmd); +else : + print('==================================================================================') + print('MsdGui needs to be built. Please \"cd\" into models/Graphics and type \"make\".') + print('==================================================================================') + +trick.stop(300.0) diff --git a/trick_sims/SIM_msd/RUN_nodamp/input.py b/trick_sims/SIM_msd/RUN_nodamp/input.py new file mode 100644 index 00000000..bbb30c2d --- /dev/null +++ b/trick_sims/SIM_msd/RUN_nodamp/input.py @@ -0,0 +1,23 @@ +dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 4) +execfile("Modified_data/realtime.py") + +dyn.msd.b = 0 + +#========================================== +# Start the display VarServer Client +#========================================== +varServerPort = trick.var_server_get_port(); +MsdGui_path = "models/graphics/dist/MsdGui.jar" + +if (os.path.isfile(MsdGui_path)) : + MsdGui_cmd = "java -jar " \ + + MsdGui_path \ + + " " + str(varServerPort) + " &" ; + print(MsdGui_cmd) + os.system( MsdGui_cmd); +else : + print('==================================================================================') + print('MsdGui needs to be built. Please \"cd\" into models/Graphics and type \"make\".') + print('==================================================================================') + +trick.stop(300.0) diff --git a/trick_sims/SIM_msd/RUN_overdamp/input.py b/trick_sims/SIM_msd/RUN_overdamp/input.py new file mode 100644 index 00000000..9d62bbe3 --- /dev/null +++ b/trick_sims/SIM_msd/RUN_overdamp/input.py @@ -0,0 +1,23 @@ +dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 4) +execfile("Modified_data/realtime.py") + +dyn.msd.b = 4*(2**(0.5)) - 1/2 + +#========================================== +# Start the display VarServer Client +#========================================== +varServerPort = trick.var_server_get_port(); +MsdGui_path = "models/graphics/dist/MsdGui.jar" + +if (os.path.isfile(MsdGui_path)) : + MsdGui_cmd = "java -jar " \ + + MsdGui_path \ + + " " + str(varServerPort) + " &" ; + print(MsdGui_cmd) + os.system( MsdGui_cmd); +else : + print('==================================================================================') + print('MsdGui needs to be built. Please \"cd\" into models/Graphics and type \"make\".') + print('==================================================================================') + +trick.stop(300.0) diff --git a/trick_sims/SIM_msd/RUN_test/input.py b/trick_sims/SIM_msd/RUN_test/input.py new file mode 100644 index 00000000..fb5c80ab --- /dev/null +++ b/trick_sims/SIM_msd/RUN_test/input.py @@ -0,0 +1,21 @@ +dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 4) +execfile("Modified_data/realtime.py") + +#========================================== +# Start the display VarServer Client +#========================================== +varServerPort = trick.var_server_get_port(); +MsdGui_path = "models/graphics/dist/MsdGui.jar" + +if (os.path.isfile(MsdGui_path)) : + MsdGui_cmd = "java -jar " \ + + MsdGui_path \ + + " " + str(varServerPort) + " &" ; + print(MsdGui_cmd) + os.system( MsdGui_cmd); +else : + print('==================================================================================') + print('MsdGui needs to be built. Please \"cd\" into models/Graphics and type \"make\".') + print('==================================================================================') + +trick.stop(300.0) diff --git a/trick_sims/SIM_msd/RUN_underdamp/input.py b/trick_sims/SIM_msd/RUN_underdamp/input.py new file mode 100644 index 00000000..1ced0935 --- /dev/null +++ b/trick_sims/SIM_msd/RUN_underdamp/input.py @@ -0,0 +1,23 @@ +dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 4) +execfile("Modified_data/realtime.py") + +dyn.msd.b = 0.5 + +#========================================== +# Start the display VarServer Client +#========================================== +varServerPort = trick.var_server_get_port(); +MsdGui_path = "models/graphics/dist/MsdGui.jar" + +if (os.path.isfile(MsdGui_path)) : + MsdGui_cmd = "java -jar " \ + + MsdGui_path \ + + " " + str(varServerPort) + " &" ; + print(MsdGui_cmd) + os.system( MsdGui_cmd); +else : + print('==================================================================================') + print('MsdGui needs to be built. Please \"cd\" into models/Graphics and type \"make\".') + print('==================================================================================') + +trick.stop(300.0) diff --git a/trick_sims/SIM_msd/S_define b/trick_sims/SIM_msd/S_define new file mode 100644 index 00000000..3b74619c --- /dev/null +++ b/trick_sims/SIM_msd/S_define @@ -0,0 +1,33 @@ +/************************TRICK HEADER************************* +PURPOSE: + (This S_define works with the RUN_numeric input file) +LIBRARY DEPENDENCIES: + ( + (msd/src/msd_init.cpp) + (msd/src/msd_numeric.cpp) + (msd/src/msd_shutdown.cpp) + (msd/src/msd.cpp) + (msd/src/msd_deriv.cpp) + (msd/src/msd_integ.cpp) + ) +*************************************************************/ + +#include "sim_objects/default_trick_sys.sm" +##include "msd/include/msd_numeric.hh" + + +class MSDSimObject : public Trick::SimObject { + + public: + MSD msd; + + MSDSimObject() { + ("default_data") msd_default_data( msd ) ; + ("initialization") msd_init( msd ) ; + ("derivative") msd.state_deriv(); + ("integration") trick_ret= msd.state_integ(); + } +} ; + +MSDSimObject dyn ; +IntegLoop dyn_integloop (0.01) dyn ; \ No newline at end of file diff --git a/trick_sims/SIM_msd/S_overrides.mk b/trick_sims/SIM_msd/S_overrides.mk new file mode 100644 index 00000000..1b84a37b --- /dev/null +++ b/trick_sims/SIM_msd/S_overrides.mk @@ -0,0 +1,2 @@ +TRICK_CFLAGS += -Imodels +TRICK_CXXFLAGS += -Imodels \ No newline at end of file diff --git a/trick_sims/SIM_msd/images/MSD0.png b/trick_sims/SIM_msd/images/MSD0.png new file mode 100644 index 00000000..11f07ac6 Binary files /dev/null and b/trick_sims/SIM_msd/images/MSD0.png differ diff --git a/trick_sims/SIM_msd/images/MSD1.png b/trick_sims/SIM_msd/images/MSD1.png new file mode 100644 index 00000000..9472a7fe Binary files /dev/null and b/trick_sims/SIM_msd/images/MSD1.png differ diff --git a/trick_sims/SIM_msd/images/MSD2.png b/trick_sims/SIM_msd/images/MSD2.png new file mode 100644 index 00000000..2466e633 Binary files /dev/null and b/trick_sims/SIM_msd/images/MSD2.png differ diff --git a/trick_sims/SIM_msd/images/MSD3.png b/trick_sims/SIM_msd/images/MSD3.png new file mode 100644 index 00000000..fcb1a9d3 Binary files /dev/null and b/trick_sims/SIM_msd/images/MSD3.png differ diff --git a/trick_sims/SIM_msd/models/graphics/MSD/src/MsdController.java b/trick_sims/SIM_msd/models/graphics/MSD/src/MsdController.java new file mode 100644 index 00000000..ebeebe4f --- /dev/null +++ b/trick_sims/SIM_msd/models/graphics/MSD/src/MsdController.java @@ -0,0 +1,200 @@ +/* + * Trick + * 2018 (c) National Aeronautics and Space Administration (NASA) + * Programmers: Scott P. Fennell + */ + + + +import javax.swing.*; +import javax.swing.JTextField; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class MsdController extends JFrame { + JTextField positionTextField; + JTextField velocityTextField; + JTextField springTextField; + JTextField dampingTextField; + JTextField forceTextField; + JTextField massTextField; + + ButtonPanel buttonPanel; + JPanel positionPanel; + JPanel labelPanel; + + public void armResetCommand() { + buttonPanel.armResetCommand(); + } + + public void armStartCommand() { + buttonPanel.armStartCommand(); + } + + public boolean getResetCommand() { + return buttonPanel.getResetCommand(); + } + + public boolean getStartCommand() { + return buttonPanel.getStartCommand(); + } + + public MsdController(MsdDisplay display){ + setTitle("Mass-Spring-Damper Control"); + setLayout(new GridLayout(1, 2)); + + buttonPanel = new ButtonPanel(display); + positionPanel = new JPanel(); + labelPanel = new JPanel(); + labelPanel.setAlignmentX(Component.RIGHT_ALIGNMENT); + + positionPanel.setLayout(new GridLayout(13, 1)); + labelPanel.setLayout(new GridLayout(13, 1)); + JPanel framePanel = new JPanel(); + GridLayout layout = new GridLayout(1, 3); + framePanel.setLayout(layout); + + positionTextField = new JTextField(2); + velocityTextField = new JTextField(2); + massTextField = new JTextField(2); + forceTextField = new JTextField(2); + springTextField = new JTextField(2); + dampingTextField = new JTextField(2); + + + + + + + labelPanel.add(new JLabel()); + labelPanel.add(new JLabel("Position: ")); + labelPanel.add(new JLabel()); + labelPanel.add(new JLabel("Velocity: ")); + labelPanel.add(new JLabel()); + labelPanel.add(new JLabel("Mass: ")); + labelPanel.add(new JLabel()); + labelPanel.add(new JLabel("Spring Coefficient: ")); + labelPanel.add(new JLabel()); + labelPanel.add(new JLabel("Damping Coefficient: ")); + labelPanel.add(new JLabel()); + labelPanel.add(new JLabel("Applied Force: ")); + labelPanel.add(new JLabel()); + + positionPanel.add(new JLabel()); + positionPanel.add(positionTextField); + positionPanel.add(new JLabel()); + positionPanel.add(velocityTextField); + positionPanel.add(new JLabel()); + positionPanel.add(massTextField); + positionPanel.add(new JLabel()); + positionPanel.add(springTextField); + positionPanel.add(new JLabel()); + positionPanel.add(dampingTextField); + positionPanel.add(new JLabel()); + positionPanel.add(forceTextField); + positionPanel.add(new JLabel()); + + + for(Component L : labelPanel.getComponents()){ + if(L instanceof JLabel){ + ((JLabel)L).setHorizontalAlignment(JLabel.RIGHT); + } + } + framePanel.add(buttonPanel); + framePanel.add(labelPanel); + framePanel.add(positionPanel); + + add(framePanel); + positionPanel.setSize(positionPanel.getLayout().preferredLayoutSize(positionPanel)); + buttonPanel.setSize(buttonPanel.getPreferredSize()); + setSize(getPreferredSize()); + setLocationByPlatform(true); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + } + + class ButtonPanel extends JPanel implements ActionListener { + + private MsdDisplay msdDisplay; + private boolean startCommand; + private boolean resetCommand; + private JButton startButton, resetButton, zoomOutButton, zoomInButton; + + + public ButtonPanel(MsdDisplay cd) { + msdDisplay = cd; + startCommand = false; + resetCommand = false; + setLayout(new GridLayout(4,1 )); + + startButton = new JButton("Start"); + startButton.addActionListener(this); + startButton.setActionCommand("start"); + startButton.setToolTipText("Start MSD"); + add(startButton); + + resetButton = new JButton("Reset"); + resetButton.addActionListener(this); + resetButton.setActionCommand("reset"); + resetButton.setToolTipText("Reset MSD"); + add(resetButton); + + zoomOutButton = new JButton("\u25b2"); + zoomOutButton.addActionListener(this); + zoomOutButton.setActionCommand("zoomout"); + zoomOutButton.setToolTipText("Zoom in"); + add(zoomOutButton); + + zoomInButton = new JButton("\u25bc"); + zoomInButton.addActionListener(this); + zoomInButton.setActionCommand("zoomin"); + zoomInButton.setToolTipText("Zoom Out"); + add(zoomInButton); + + } + + public void actionPerformed(ActionEvent e) { + String s = e.getActionCommand(); + switch (s) { + case "start": + startCommand = true; + break; + case "reset": + resetCommand = true; + + break; + case "zoomin": + msdDisplay.setScale(msdDisplay.getScale() / 2); + break; + case "zoomout": + msdDisplay.setScale(msdDisplay.getScale() * 2); + break; + default: + System.out.println("Unknown Action Command:" + s); + break; + } + } + + public void armResetCommand() { + resetCommand = false; + startButton.setForeground(Color.red); + } + + public void armStartCommand() { + startCommand = false; + startButton.setForeground(Color.gray); + } + + public boolean getResetCommand() { + return resetCommand; + } + + public boolean getStartCommand() { + return startCommand; + } + + } // class ButtonPanel + + +} diff --git a/trick_sims/SIM_msd/models/graphics/MSD/src/MsdDisplay.java b/trick_sims/SIM_msd/models/graphics/MSD/src/MsdDisplay.java new file mode 100644 index 00000000..46aec4d1 --- /dev/null +++ b/trick_sims/SIM_msd/models/graphics/MSD/src/MsdDisplay.java @@ -0,0 +1,50 @@ +/* + * Trick + * 2018 (c) National Aeronautics and Space Administration (NASA) + * Programmers: Scott P. Fennell + */ + + +import javax.swing.*; + + +public class MsdDisplay extends JFrame { + MsdView msdView; + + + + public void setPosition(double value) { + msdView.setPosition(value); + } + + public void setVelocity(double value) { + msdView.setVelocity(value); + } + + public void setScale(int value) { + msdView.setScale(value); + } + + public int getScale() { + return msdView.getScale(); + } + + public void drawMsdView() { + msdView.repaint(); + } + + + + public MsdDisplay(MsdView arena) { + setTitle("Mass-Spring-Damper"); + msdView = arena; + add(msdView); + + + setSize(800, 500); + setLocationByPlatform(true); + + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } + +} diff --git a/trick_sims/SIM_msd/models/graphics/MSD/src/MsdGui.java b/trick_sims/SIM_msd/models/graphics/MSD/src/MsdGui.java new file mode 100644 index 00000000..bdbff287 --- /dev/null +++ b/trick_sims/SIM_msd/models/graphics/MSD/src/MsdGui.java @@ -0,0 +1,218 @@ +/* + * Trick + * 2018 (c) National Aeronautics and Space Administration (NASA) + * Programmers: Scott P. Fennell + */ + + +import java.awt.*; +import java.io.*; +import java.net.Socket; + +public class MsdGui { + + static BufferedReader in; + static DataOutputStream out; + + public static void connectToServer(String host, int port) throws IOException { + Socket socket = new Socket(host, port); + in = new BufferedReader(new InputStreamReader(socket.getInputStream())); + out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream())); + } + + public static void main(String[] args) throws IOException { + + String host = "localHost"; + int port = 0; + + // ========================================================== + // Handle program arguments. + // ========================================================== + int ii = 0; + while (ii < args.length) { + switch (args[ii]) { + case "-help": + case "--help": { + MsdUtils.printHelpText(); + System.exit(0); + } + break; + default: { + port = (Integer.parseInt(args[ii])); + } + break; + } + ++ii; + } + + if (port == 0) { + System.out.println("No variable server port specified."); + MsdUtils.printHelpText(); + System.exit(0); + } + + boolean go = true; + double dt = 0.01; // Time between updates (seconds). + double pos = 0.0; + double vel = 0.0; + boolean resetCommand; + boolean startCommand; + + + int simMode = 0; + + + int mapScale = 32; // pixels per meter. + + MsdView msdView = new MsdView(mapScale); + MsdDisplay display = new MsdDisplay(msdView); + MsdController controller = new MsdController(display); + display.setVisible(true); + display.drawMsdView(); + controller.setVisible(true); + controller.setLocation(new Point((int)display.getLocationOnScreen().getX() + display.getWidth(), (int)display.getLocationOnScreen().getY())); + controller.setSize(controller.getWidth() + 10, display.getHeight()); + + // Connect to the Trick simulation's variable server + System.out.println("Connecting to: " + host + ":" + port); + connectToServer(host, port); + + out.writeBytes("trick.var_set_client_tag(\"MsdGui\") \n"); + out.flush(); + + // Have the Variable Server send us the simulation mode ONCE. + out.writeBytes("trick.var_add(\"trick_sys.sched.mode\")\n" + + "trick.var_add(\"dyn.msd.x_0\")\n" + + "trick.var_add(\"dyn.msd.v_0\")\n" + + "trick.var_add(\"dyn.msd.m\")\n" + + "trick.var_add(\"dyn.msd.b\")\n" + + "trick.var_add(\"dyn.msd.k\")\n" + + "trick.var_add(\"dyn.msd.F\")\n" + + "trick.var_send() \n" + + "trick.var_clear() \n"); + out.flush(); + + // Read the response and extract the simulation mode. Initialize text fields with initial values. + try { + String line; + String field[]; + line = in.readLine(); + field = line.split("\t"); + simMode = Integer.parseInt(field[1]); + controller.positionTextField.setText(String.format("%.2f", new Double(field[2]))); + controller.velocityTextField.setText(String.format("%.2f", new Double(field[3]))); + controller.massTextField.setText(String.format("%.2f", new Double(field[4]))); + controller.dampingTextField.setText(String.format("%.2f", new Double(field[5]))); + controller.springTextField.setText(String.format("%.2f", new Double(field[6]))); + controller.forceTextField.setText(String.format("%.2f", new Double(field[7]))); + } catch (IOException | NullPointerException e) { + go = false; + } + + // If we're in FREEZE, make ready to start. + if (simMode == TrickSimMode.FREEZE) { + controller.armResetCommand(); + } + + // Configure the Variable Server to cyclically send us the following variables. + // Tell the variable server: + // 1) We want the values of the following variables: + out.writeBytes("trick.var_pause() \n" + + "trick.var_add(\"dyn.msd.x\")\n" + + "trick.var_add(\"dyn.msd.v\")\n" + + "trick.var_add(\"trick_sys.sched.mode\")\n" + + // 2) We want the responses in ASCII: + "trick.var_ascii() \n" + + /* 3) We want debug information: + "trick.var_debug(1) \n" + + */ + // 4) We want values to be updated at the specified rate: + String.format("trick.var_cycle(%.3f)\n", dt) + + // 5) Start sending values as specified. + "trick.var_unpause() \n"); + out.flush(); + + while (go) { + + // Receive and parse periodic data response from the variable server. + try { + String line; + String field[]; + line = in.readLine(); + field = line.split("\t"); + pos = Double.parseDouble(field[1]); + vel = Double.parseDouble(field[2]); + simMode = Integer.parseInt(field[3]); + } catch (IOException | NullPointerException e) { + go = false; + } + // Get inputs from the GUI. + resetCommand = controller.getResetCommand(); + startCommand = controller.getStartCommand(); + + if (simMode == TrickSimMode.FREEZE) { + + controller.armResetCommand(); + resetCommand = false; + if (!controller.positionTextField.getText().isEmpty() && new Double(controller.positionTextField.getText()) >= 0.0) { + display.msdView.hideWall = false; + } + if (!(controller.positionTextField.getText().isEmpty() || + controller.velocityTextField.getText().isEmpty() || + controller.springTextField.getText().isEmpty() || + controller.dampingTextField.getText().isEmpty() || + controller.massTextField.getText().isEmpty() || + controller.forceTextField.getText().isEmpty())) { + + out.writeBytes( + "dyn.msd.x_0 = " + controller.positionTextField.getText() + ";\n" + + "dyn.msd.v_0 = " + controller.velocityTextField.getText() + ";\n" + + "dyn.msd.k = " + controller.springTextField.getText() + ";\n" + + "dyn.msd.b = " + controller.dampingTextField.getText() + ";\n" + + "dyn.msd.m = " + controller.massTextField.getText() + ";\n" + + "dyn.msd.F = " + controller.forceTextField.getText() + ";\n"); + out.writeBytes("dyn.msd.x = dyn.msd.x_0 ;\n"); + out.writeBytes("dyn.msd.v = dyn.msd.v_0 ;\n"); + } + + if (startCommand) { + out.writeBytes(String.format("trick.exec_run();\n")); + + out.flush(); + } + if (resetCommand) { + out.writeBytes(String.format("trick.exec_freeze() ;\n")); + continue; + } + out.flush(); + + } else if (simMode == TrickSimMode.RUN) { + controller.armStartCommand(); + startCommand = false; + if (resetCommand) { + out.writeBytes(String.format("trick.exec_freeze() ;\n")); + out.flush(); + } + if (!(controller.springTextField.getText().isEmpty() || + controller.dampingTextField.getText().isEmpty() || + controller.massTextField.getText().isEmpty() || + controller.forceTextField.getText().isEmpty())) { + out.writeBytes( + "dyn.msd.k = " + controller.springTextField.getText() + ";\n" + + "dyn.msd.b = " + controller.dampingTextField.getText() + ";\n" + + "dyn.msd.m = " + controller.massTextField.getText() + ";\n" + + "dyn.msd.F = " + controller.forceTextField.getText() + ";\n"); + } + } + + // Update the display data. + display.setPosition(pos); + display.setVelocity(vel); + + // Update the scene. + display.drawMsdView(); + + } // while + + } +} diff --git a/trick_sims/SIM_msd/models/graphics/MSD/src/MsdUtils.java b/trick_sims/SIM_msd/models/graphics/MSD/src/MsdUtils.java new file mode 100644 index 00000000..7c8f52ca --- /dev/null +++ b/trick_sims/SIM_msd/models/graphics/MSD/src/MsdUtils.java @@ -0,0 +1,24 @@ +/* + * Trick + * 2018 (c) National Aeronautics and Space Administration (NASA) + * Programmers: Scott P. Fennell + */ + + + +public class MsdUtils { + + public static void printHelpText() { + System.out.println( + "----------------------------------------------------------------------\n" + + "usage: java jar CannonDisplay.jar \n" + + "----------------------------------------------------------------------\n" + ); + } +} + +class TrickSimMode { + public static final int INIT = 0; + public static final int FREEZE = 1; + public static final int RUN = 5; +} \ No newline at end of file diff --git a/trick_sims/SIM_msd/models/graphics/MSD/src/MsdView.java b/trick_sims/SIM_msd/models/graphics/MSD/src/MsdView.java new file mode 100644 index 00000000..8dbdbf80 --- /dev/null +++ b/trick_sims/SIM_msd/models/graphics/MSD/src/MsdView.java @@ -0,0 +1,183 @@ +/* + * Trick + * 2018 (c) National Aeronautics and Space Administration (NASA) + * Programmers: Scott P. Fennell + */ + + + +import javax.swing.*; +import java.awt.*; + +class MsdView extends JPanel { + + private int scale; + private Color massColor; + private Color backgroundColor; + private Color wallColor; + private Color springColor; + private Double position; + private Double velocity; + private Double massRadius; + boolean hideWall = false; + + // Origin of world coordinates in jpanel coordinates. + private int worldOriginX; + private int worldOriginY; + + + /** + * Class constructor. + */ + public MsdView(int mapScale) { + + setScale(mapScale); + + backgroundColor = new Color(200, 200, 255); + springColor = new Color(150, 150, 100); + massColor = new Color(10, 10, 10); + wallColor = new Color(120, 118, 118); + springColor = Color.BLUE; + massRadius = 0.75; + position = 0.0; + velocity = 0.0; + } + + /** + * @param value angle in degrees + */ + public void setPosition(double value) { + position = value; + } + + public void setVelocity(double value) { + velocity = value; + } + + public void setScale(int mapScale) { + if (mapScale < 4) { + scale = 4; + } else if (mapScale > 128) { + scale = 128; + } else { + scale = mapScale; + } + repaint(); + } + + public int getScale() { + return scale; + } + + public void drawCenteredCircle(Graphics2D g, int x, int y, int r) { + x = x - (r / 2); + y = y - (r / 2); + g.fillOval(x, y, r, r); + } + + private void doDrawing(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + + RenderingHints rh = new RenderingHints( + RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + rh.put(RenderingHints.KEY_RENDERING, + RenderingHints.VALUE_RENDER_QUALITY); + + int ii, jj; + int width = getWidth(); + int height = getHeight(); + + + worldOriginX = (width / 3); + worldOriginY = (height / 2); + + while (worldOriginX + scale * position > width) { + scale = scale / 2; + } + + // Draw Sky + g2d.setPaint(backgroundColor); + g2d.fillRect(0, 0, width, worldOriginY); + + // Draw mass + g2d.setPaint(massColor); + int bx = (int) (worldOriginX + scale * position); + int by = (int) (worldOriginY); + drawCenteredCircle(g2d, bx, by, (int) (scale * massRadius)); + + // Draw spring + double springPosition; + // reflect spring visual over origin correctly + if(position < massRadius/2 && position > -massRadius/2){ + springPosition = 0.0; + } else if(position < 0){ + springPosition = position + massRadius/2; + } else{ + springPosition = position - massRadius/2; + } + int SCALEFACTOR = 200; + int cycles = 5; + int points = SCALEFACTOR * cycles * 2; + double[] sines = new double[points]; + for (int i = 0; i < points; i++) { + double radians = (Math.PI / SCALEFACTOR) * i; + sines[i] = Math.sin(radians); + } + int maxWidth = (int) (scale * (springPosition /*- massRadius / 2*/)); + double hstep = (double) maxWidth / (double) points; + int maxHeight = (int) (scale); + int[] pts = new int[points]; + for (int i = 0; i < points; i++) { + pts[i] = (int) (sines[i] * maxHeight / 2 * .95 + maxHeight / 2); + } + g2d.setColor(springColor); + for (int i = 1; i < points; i++) { + int x1 = (int) ((i - 1) * hstep); + int x2 = (int) (i * hstep); + int y1 = pts[i - 1]; + int y2 = pts[i]; + g2d.drawLine(x1 + worldOriginX, y1 + height / 2 - scale / 2, x2 + worldOriginX, y2 + height / 2 - scale / 2); + + } + + //Draw wall + if (!hideWall && position >= 0) { + g2d.setPaint(wallColor); + g2d.fillRect(0, 0, worldOriginX, height); + } else { + hideWall = true; + } + + + // Draw range markers. + int tickRange = 50; + if (scale >= 8) tickRange = 20; + if (scale >= 16) tickRange = 10; + if (scale >= 32) tickRange = 5; + if (scale >= 64) tickRange = 1; + + int lower = ((int) ((-worldOriginX) / (scale * tickRange)) + 1) * tickRange; + int upper = ((int) ((width - worldOriginX) / (scale * tickRange)) + 1) * tickRange; + + g2d.setPaint(Color.BLACK); + + for (ii = lower; ii < upper; ii += tickRange) { + int mx = (int) (worldOriginX + scale * ii); + g2d.drawLine(mx, worldOriginY, mx, worldOriginY + 20); + g2d.drawString(String.format("%d", ii), mx, worldOriginY + 15); + } + + g2d.drawString(String.format("SCALE: %d pixels/meter", scale), 20, 20); + g2d.drawString(String.format(" Position (m): %.2f", position), 20, 80); + g2d.drawString(String.format("Velocity (m/s): %.2f", velocity), 20, 120); + + } + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + doDrawing(g); + } +} \ No newline at end of file diff --git a/trick_sims/SIM_msd/models/graphics/Makefile b/trick_sims/SIM_msd/models/graphics/Makefile new file mode 100644 index 00000000..fe61dffd --- /dev/null +++ b/trick_sims/SIM_msd/models/graphics/Makefile @@ -0,0 +1,36 @@ +SHELL = /bin/sh + +PROJECT_NAME = MsdGui +SRC_DIR = MSD/src +BUILD_DIR = build +CLASSES_DIR = $(BUILD_DIR)/classes +JAR_DIR = dist +MAIN_CLASS = MsdGui + +all: jar + +clean: + rm -rf $(BUILD_DIR) + rm -f manifest + +spotless: clean + rm -rf dist + +$(CLASSES_DIR): + @ mkdir -p $(CLASSES_DIR) + +compile: | $(CLASSES_DIR) + javac -sourcepath $(SRC_DIR) -d $(CLASSES_DIR) $(SRC_DIR)/MsdGui.java + +manifest: + @ echo "Main-Class: $(MAIN_CLASS)" > $@ + +$(JAR_DIR): + @ mkdir -p $(JAR_DIR) + +jar: compile manifest | $(JAR_DIR) + jar cvfm $(JAR_DIR)/$(PROJECT_NAME).jar manifest -C $(CLASSES_DIR) . + @ echo "-------------------------------------------------------------------------------" + @ echo " BUILD COMPLETE" + @ echo "The Java jar file (the Java Executable) is located at: $(JAR_DIR)/$(PROJECT_NAME).jar" + @ echo "-------------------------------------------------------------------------------" diff --git a/trick_sims/SIM_msd/models/msd/include/msd.hh b/trick_sims/SIM_msd/models/msd/include/msd.hh new file mode 100644 index 00000000..832ecf1c --- /dev/null +++ b/trick_sims/SIM_msd/models/msd/include/msd.hh @@ -0,0 +1,48 @@ +/************************TRICK HEADER************************* +PURPOSE: Mass-Spring-Damper class header file . +PROGRAMMERS: + (((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project))) +*************************************************************/ + +#ifndef MSD_H +#define MSD_H + +class MSD { +public: + + double a; /* m/s2 acceleration */ + double v; /* m/s velocity */ + double x; /* m position */ + double m; /* kg mass */; + + double v_0; /* *i m/s initial velocity of the mass (at t = 0) */ + double x_0; /* *i m initial position of the mass (at t = 0) */ + + double b; /* N.s/m damping constant */ + double k; /* N/m spring constant */ + double F; /* N force constant */ + + + + MSD(void); /* not used */ + + MSD(double _m, double _k, double _b, double _F, + double _v_0, double _x_0); + + int state_deriv(void); + int state_integ(void); + + }; + + +#ifdef __cplusplus +extern "C" { +#endif +int msd_default_data(MSD &); +int msd_init(MSD &); +int msd_shutdown(const MSD &); +#ifdef __cplusplus +} +#endif + +#endif /* MSD_H */ \ No newline at end of file diff --git a/trick_sims/SIM_msd/models/msd/include/msd_numeric.hh b/trick_sims/SIM_msd/models/msd/include/msd_numeric.hh new file mode 100644 index 00000000..29093004 --- /dev/null +++ b/trick_sims/SIM_msd/models/msd/include/msd_numeric.hh @@ -0,0 +1,17 @@ +/************************TRICK HEADER************************* +PURPOSE: Msd Numeric model +PROGRAMMERS: + (((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project))) +*************************************************************/ +#ifndef MSD_NUMERIC_H +#define MSD_NUMERIC_H + +#include "msd.hh" + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/trick_sims/SIM_msd/models/msd/src/msd.cpp b/trick_sims/SIM_msd/models/msd/src/msd.cpp new file mode 100644 index 00000000..4c2a3f60 --- /dev/null +++ b/trick_sims/SIM_msd/models/msd/src/msd.cpp @@ -0,0 +1,19 @@ +/************************TRICK HEADER************************* +PURPOSE: MSD is a mass-spring-damper class for a trick sim. +PROGRAMMERS: + (((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project))) +*************************************************************/ +#include +#include "../include/msd_numeric.hh" +#include + +MSD::MSD(double _m, double _k, double _b, double _F, double _v_0, double _x_0) { + m = _m; + k = _k; + b = _b; + F = _F; + v_0 = _v_0; + x_0 = _x_0; +} + +MSD::MSD(void) {/* not used */} \ No newline at end of file diff --git a/trick_sims/SIM_msd/models/msd/src/msd_deriv.cpp b/trick_sims/SIM_msd/models/msd/src/msd_deriv.cpp new file mode 100644 index 00000000..815256ca --- /dev/null +++ b/trick_sims/SIM_msd/models/msd/src/msd_deriv.cpp @@ -0,0 +1,15 @@ +/************************TRICK HEADER************************* + PURPOSE: ( Trick integration ) +PROGRAMMERS: + (((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project))) +*************************************************************/ +#include "../include/msd_numeric.hh" +#include "../include/msd.hh" +#include + +int MSD::state_deriv(void) { + /* system equation for second derivitive */ + a = (F - b*v - k*x)/m; + + return(0); +} \ No newline at end of file diff --git a/trick_sims/SIM_msd/models/msd/src/msd_init.cpp b/trick_sims/SIM_msd/models/msd/src/msd_init.cpp new file mode 100644 index 00000000..627c41ee --- /dev/null +++ b/trick_sims/SIM_msd/models/msd/src/msd_init.cpp @@ -0,0 +1,28 @@ +/************************TRICK HEADER************************* +PURPOSE: Set the initial data values of the MSD +PROGRAMMERS: + (((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project))) +*************************************************************/ + +/* Model Include files */ +#include "../include/msd.hh" + +/* default data job */ +int msd_default_data(MSD &M) { + M = MSD( + 1.0, /* m */ + 2.0, /* k */ + 0.5, /* b */ + 5.0, /* F */ + 0.0, /* v_0 */ + 5.0 /* x_0 */ + + ); + + return 0; +} + +/* initialization job */ +int msd_init(MSD &M) { + return 0; +} diff --git a/trick_sims/SIM_msd/models/msd/src/msd_integ.cpp b/trick_sims/SIM_msd/models/msd/src/msd_integ.cpp new file mode 100644 index 00000000..30566922 --- /dev/null +++ b/trick_sims/SIM_msd/models/msd/src/msd_integ.cpp @@ -0,0 +1,31 @@ +/************************TRICK HEADER************************* + PURPOSE: ( Trick integration ) + PROGRAMMERS: + (((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project))) +*************************************************************/ +#include "../include/msd_numeric.hh" +#include "msd.hh" +#include "trick/Integrator.hh" +#include "trick/integrator_c_intf.h" +#include + +int MSD::state_integ(void) { + int ipass; + load_state( + &x, + &v, + NULL); + + load_deriv( + &v, + &a, + NULL); + + ipass = integrate(); + + unload_state( + &x, + &v, + NULL); + return(ipass); +} \ No newline at end of file diff --git a/trick_sims/SIM_msd/models/msd/src/msd_shutdown.cpp b/trick_sims/SIM_msd/models/msd/src/msd_shutdown.cpp new file mode 100644 index 00000000..48fa22e4 --- /dev/null +++ b/trick_sims/SIM_msd/models/msd/src/msd_shutdown.cpp @@ -0,0 +1,17 @@ +/************************TRICK HEADER************************* +PURPOSE: (Print the final msd state.) +PROGRAMMERS: + (((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project))) +*************************************************************/ +#include "../include/msd.hh" +#include "trick/exec_proto.h" +#include + +int msd_shutdown(const MSD &M) { + printf("========================================\n"); + printf(" MSD State at Shutdown \n"); + printf("pos = [%g], vel = [%g], acc = [%g]\n", + M.x, M.v, M.a); + printf("========================================\n"); + return 0; +} \ No newline at end of file diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp index 79a921a1..6ff65d7b 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp @@ -270,7 +270,7 @@ void FieldDescription::parseComment(std::string comment) { if ( chkpnt_io_found == true ) { // If a checkpoint I/O spec is found add it to the io field. io = (chkpnt_io << 2 ) + ( io & 3 ) ; - } else { + } else if ( io_found == true ) { // else duplicated the io field to the chkpnt io field. io |= (io << 2 ) ; } diff --git a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp index d670ef79..a3600ab7 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldVisitor.cpp @@ -128,6 +128,10 @@ bool FieldVisitor::VisitBuiltinType(clang::BuiltinType *bt) { bool FieldVisitor::VisitConstantArrayType(clang::ConstantArrayType *cat) { //cat->dump() ; std::cout << std::endl ; fdes->addArrayDim(cat->getSize().getZExtValue()) ; + // If this field is an arrayed STL, skip it! + if ( fdes->isSTL() ) { + fdes->setIO(0) ; + } return true; } @@ -249,6 +253,10 @@ bool FieldVisitor::VisitFieldDecl( clang::FieldDecl *field ) { bool FieldVisitor::VisitPointerType(clang::PointerType *p) { fdes->addArrayDim(-1) ; + // If this field is a pointer to an STL, skip it! + if ( fdes->isSTL() ) { + fdes->setIO(0) ; + } return true; } @@ -426,7 +434,7 @@ bool FieldVisitor::VisitRecordType(clang::RecordType *rt) { tst_string.erase(pos , 7) ; } // clang changes bool to _Bool. We need to change it back - if ((pos = tst_string.find("<_Bool")) != std::string::npos ) { + while ((pos = tst_string.find("<_Bool")) != std::string::npos ) { tst_string.replace(pos , 6, "setIO(0) ; + return false ; + } /* Template specialization types will be processed here because the canonical type will be typed as a record. We test if we have a template specialization type. If so process the template type and return */ diff --git a/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp b/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp index 9f3d5a42..082aeb1d 100644 --- a/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FindTrickICG.cpp @@ -35,7 +35,12 @@ void FindTrickICG::FileChanged(clang::SourceLocation Loc, FileChangeReason Reaso } } -void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) { +#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) +void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue) +#else +void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) +#endif +{ if ( ConditionRange.isValid() ) { // Get the full text of the if statement into a string clang::FullSourceLoc fsl_begin(ConditionRange.getBegin() , ci.getSourceManager()) ; @@ -67,12 +72,22 @@ void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRan } } -void FindTrickICG::ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) { +#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) +void FindTrickICG::ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue) +#else +void FindTrickICG::ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) +#endif +{ // Do the same processing for an #elif statement as an #if statement. If(Loc,ConditionRange,ConditionValue) ; } -void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) { +#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) +void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) +#else +void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) +#endif +{ // Get the token name that is being tested. std::string name = MacroNameTok.getIdentifierInfo()->getName().str() ; if ( ! name.compare("TRICK_ICG") ) { @@ -94,7 +109,12 @@ void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNam } -void FindTrickICG::Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) { +#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) +void FindTrickICG::Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) +#else +void FindTrickICG::Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) +#endif +{ // Get the token name that is being tested. std::string name = MacroNameTok.getIdentifierInfo()->getName().str() ; if ( ! name.compare("TRICK_ICG") ) { diff --git a/trick_source/codegen/Interface_Code_Gen/FindTrickICG.hh b/trick_source/codegen/Interface_Code_Gen/FindTrickICG.hh index 57cf6455..ae9034ab 100644 --- a/trick_source/codegen/Interface_Code_Gen/FindTrickICG.hh +++ b/trick_source/codegen/Interface_Code_Gen/FindTrickICG.hh @@ -21,10 +21,17 @@ class FindTrickICG : public clang::PPCallbacks { clang::FileID PrevFID = clang::FileID()) ; // callbacks called when the preprocessor directives of types are processed. +#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) + virtual void If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue) ; + virtual void ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue) ; + virtual void Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) ; + virtual void Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) ; +#else virtual void If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) ; virtual void ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) ; virtual void Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) ; virtual void Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) ; +#endif // print a warning about using TRICK_ICG. void print_header() ; diff --git a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp index 5eb0bd10..2249d175 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp +++ b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -32,6 +33,23 @@ PrintAttributes::PrintAttributes(int in_attr_version , HeaderSearchDirs & in_hsd printer = new PrintFileContents10() ; } +void PrintAttributes::addIgnoreTypes() { + + char * env_var_contents = getenv("TRICK_ICG_IGNORE_TYPES") ; + + if( env_var_contents != NULL ) { + std::string s = std::string(env_var_contents) ; + std::stringstream ss(s); + std::string item; + while(std::getline(ss, item, ';')) { + item = trim(item) ; + if ( ! item.empty() ) { + global_ignore_types.insert(item) ; + } + } + } +} + /** @details @@ -240,6 +258,10 @@ void PrintAttributes::printClass( ClassValues * cv ) { outfile.close(); } + if (!isHeaderExcluded(fileName)) { + printer->printClassMap(class_map_outfile, cv); + } +/* char* realPath = almostRealPath(fileName.c_str()); if (realPath) { if (isFileIncluded(fileName) or hsd.isPathInExtLib(realPath)) { @@ -247,6 +269,7 @@ void PrintAttributes::printClass( ClassValues * cv ) { } free(realPath); } +*/ } void PrintAttributes::printEnum(EnumValues* ev) { @@ -270,9 +293,14 @@ void PrintAttributes::printEnum(EnumValues* ev) { outfile.close() ; } + if (!isHeaderExcluded(fileName)) { + printer->printEnumMap(enum_map_outfile, ev); + } +/* if (isFileIncluded(fileName)) { printer->printEnumMap(enum_map_outfile, ev) ; } +*/ } void PrintAttributes::createMapFiles() { @@ -472,7 +500,9 @@ bool PrintAttributes::isIgnored(ConstructValues& constructValues) { std::set& constructs = ignored_types[fileName]; const bool ignored = constructs.find(constructValues.getName()) != constructs.end() or - constructs.find(constructValues.getFullyQualifiedName()) != constructs.end(); + constructs.find(constructValues.getFullyQualifiedName()) != constructs.end() or + global_ignore_types.find(constructValues.getName()) != global_ignore_types.end() or + global_ignore_types.find(constructValues.getFullyQualifiedName()) != global_ignore_types.end(); if (ignored and verboseBuild) { std::cout << skipping << "ICG Ignore Type: " << constructValues.getName() << " (from " << fileName << ")" << std::endl; @@ -531,6 +561,35 @@ bool PrintAttributes::isHeaderExcluded(const std::string& header, bool exclude_e return true; } + temp = realpath(header.c_str(),NULL); + if ( temp ) { + const std::string real_path = std::string(temp); + free(temp) ; + if ( real_path.compare(path) ) { + if (hsd.isPathInExclude(real_path)) { + if (verboseBuild) { + std::cout << skipping << "TRICK_EXCLUDE: " << underline(real_path, hsd.getPathInExclude(real_path).size()) << std::endl; + } + return true; + } + + if (hsd.isPathInICGExclude(real_path)) { + if (verboseBuild) { + std::cout << skipping << "TRICK_ICG_EXCLUDE: " << underline(real_path, hsd.getPathInICGExclude(real_path).size()) << std::endl; + } + return true; + } + + if (hsd.isPathInExtLib(real_path) && exclude_ext_libs) { + if (verboseBuild) { + std::cout << skipping << "TRICK_EXT_LIB_DIRS: " << underline(real_path, hsd.getPathInExtLib(real_path).size()) << std::endl; + } + ext_lib_io_files.insert(header) ; + return true; + } + } + } + return false; } diff --git a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.hh b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.hh index f545575d..5a381419 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.hh +++ b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.hh @@ -39,6 +39,9 @@ class PrintAttributes { PrintAttributes( int attr_version , HeaderSearchDirs & hsd , CommentSaver & cs , clang::CompilerInstance & in_ci, bool force , bool sim_services, std::string output_dir ) ; + /** Adds construct names to ignore from TRICK_ICG_IGNORE_TYPES environment variable */ + void addIgnoreTypes() ; + /** Prints all of the processed classes and enumerations */ virtual void createMapFiles() ; virtual void closeMapFiles() ; @@ -128,6 +131,9 @@ class PrintAttributes { /** List of files that have ICG: No */ std::vector< std::string > icg_no_files ; + /** set of types from the TRICK_ICG_IGNORE_TYPES environment variable */ + std::set< std::string > global_ignore_types ; + /** map of ignored types sorted by file */ std::map< std::string , std::set< std::string > > ignored_types ; /** map of processed classes sorted by file */ diff --git a/trick_source/codegen/Interface_Code_Gen/PrintFileContentsBase.cpp b/trick_source/codegen/Interface_Code_Gen/PrintFileContentsBase.cpp index 258b54e8..4718f3dc 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintFileContentsBase.cpp +++ b/trick_source/codegen/Interface_Code_Gen/PrintFileContentsBase.cpp @@ -60,6 +60,9 @@ bool PrintFileContentsBase::isPrintable( ClassValues * c , FieldDescription * fd if ( !(fdes->getIO() & ioMask) || !fdes->getTypeName().compare("void") || !fdes->getEnumString().compare("TRICK_VOID")) { return false; } + if ( fdes->isSTL() and fdes->getNumDims() ) { + return false; + } if ( fdes->getAccess() == clang::AS_public || (!fdes->isStatic() && !global_compat15 && !c->isCompat15())) { return true; } diff --git a/trick_source/codegen/Interface_Code_Gen/main.cpp b/trick_source/codegen/Interface_Code_Gen/main.cpp index f19cfcea..47716b6e 100644 --- a/trick_source/codegen/Interface_Code_Gen/main.cpp +++ b/trick_source/codegen/Interface_Code_Gen/main.cpp @@ -8,6 +8,7 @@ #include "llvm/Support/Host.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/raw_ostream.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Basic/TargetOptions.h" @@ -58,9 +59,14 @@ Most of the main program is pieced together from examples on the web. We are doi -# Parsing the input file. */ int main(int argc, char * argv[]) { - llvm::cl::SetVersionPrinter([] { - std::cout << "Trick Interface Code Generator (trick-ICG) " << TRICK_VERSION << std::endl; - }); + llvm::cl::SetVersionPrinter([] +#if (LIBCLANG_MAJOR >= 6) + (llvm::raw_ostream& stream) {stream +#else + {std::cout +#endif + << "Trick Interface Code Generator (trick-ICG) " << TRICK_VERSION << '\n';} + ); /** * Gather all of the command line arguments into lists of include directories, defines, and input files. @@ -164,6 +170,7 @@ int main(int argc, char * argv[]) { PrintAttributes printAttributes(attr_version, hsd, cs, ci, force, sim_services_flag, output_dir); + printAttributes.addIgnoreTypes() ; // Create new class and enum map files if (create_map) { printAttributes.createMapFiles(); diff --git a/trick_source/data_products/.gitignore b/trick_source/data_products/.gitignore index 6b55aac5..8826e6b2 100644 --- a/trick_source/data_products/.gitignore +++ b/trick_source/data_products/.gitignore @@ -1 +1,3 @@ fermi-ware +Apps/trkConvert/*.o +Apps/trkConvert/trkConvert diff --git a/trick_source/data_products/Apps/trkConvert/CSV_Formatter.cpp b/trick_source/data_products/Apps/trkConvert/CSV_Formatter.cpp new file mode 100644 index 00000000..62d2b237 --- /dev/null +++ b/trick_source/data_products/Apps/trkConvert/CSV_Formatter.cpp @@ -0,0 +1,24 @@ +#include "CSV_Formatter.hh" +/* ================================================================================ + * CLASS: CSV_Formatter isa LogFormatter. + * ================================================================================ + */ + +void CSV_Formatter::writeHeader(FILE* out_fp, int version, int endianness) {}; +void CSV_Formatter::writeColumnLabel(FILE* out_fp, const char* name, const char* units) { + fprintf(out_fp,"%s {%s}", name, units); +} +void CSV_Formatter::writeColumnLabelSeparator(FILE* out_fp) { fprintf(out_fp,","); } +void CSV_Formatter::writeDatumSeparator(FILE* out_fp) { fprintf(out_fp,","); } +void CSV_Formatter::writeRecordSeparator(FILE* out_fp) { fprintf(out_fp,"\n"); } +void CSV_Formatter::writeDatum(FILE* out_fp, int8_t datum) { fprintf(out_fp,"%d", datum); } +void CSV_Formatter::writeDatum(FILE* out_fp, uint8_t datum) { fprintf(out_fp,"%u", datum); } +void CSV_Formatter::writeDatum(FILE* out_fp, int16_t datum) { fprintf(out_fp,"%d", datum); } +void CSV_Formatter::writeDatum(FILE* out_fp, uint16_t datum) { fprintf(out_fp,"%u", datum); } +void CSV_Formatter::writeDatum(FILE* out_fp, int32_t datum) { fprintf(out_fp,"%d", datum); } +void CSV_Formatter::writeDatum(FILE* out_fp, uint32_t datum) { fprintf(out_fp,"%u", datum); } +void CSV_Formatter::writeDatum(FILE* out_fp, int64_t datum) { fprintf(out_fp,"%lld", datum); } +void CSV_Formatter::writeDatum(FILE* out_fp, uint64_t datum) { fprintf(out_fp,"%lld", datum); } +void CSV_Formatter::writeDatum(FILE* out_fp, float datum) { fprintf(out_fp,"%.7f", datum); } +void CSV_Formatter::writeDatum(FILE* out_fp, double datum) { fprintf(out_fp,"%.15g", datum); } +const char* CSV_Formatter::extension() { return ".csv"; }; diff --git a/trick_source/data_products/Apps/trkConvert/CSV_Formatter.hh b/trick_source/data_products/Apps/trkConvert/CSV_Formatter.hh new file mode 100644 index 00000000..04a4837f --- /dev/null +++ b/trick_source/data_products/Apps/trkConvert/CSV_Formatter.hh @@ -0,0 +1,27 @@ + +#ifndef CSV_FORMATTER +#define CSV_FORMATTER + +#include +#include "LogFormatter.hh" + +class CSV_Formatter: public LogFormatter { + public: + void writeHeader(FILE* out_fp, int version, int endianness); + void writeColumnLabel(FILE* out_fp, const char* name, const char* units); + void writeColumnLabelSeparator(FILE* out_fp); + void writeDatumSeparator(FILE* out_fp); + void writeRecordSeparator(FILE* out_fp); + void writeDatum(FILE* out_fp, int8_t datum); + void writeDatum(FILE* out_fp, uint8_t datum); + void writeDatum(FILE* out_fp, int16_t datum); + void writeDatum(FILE* out_fp, uint16_t datum); + void writeDatum(FILE* out_fp, int32_t datum); + void writeDatum(FILE* out_fp, uint32_t datum); + void writeDatum(FILE* out_fp, int64_t datum); + void writeDatum(FILE* out_fp, uint64_t datum); + void writeDatum(FILE* out_fp, float datum); + void writeDatum(FILE* out_fp, double datum); + const char* extension(); +}; +#endif diff --git a/trick_source/data_products/Apps/trkConvert/LogFormatter.hh b/trick_source/data_products/Apps/trkConvert/LogFormatter.hh new file mode 100644 index 00000000..5b7b290a --- /dev/null +++ b/trick_source/data_products/Apps/trkConvert/LogFormatter.hh @@ -0,0 +1,32 @@ +#ifndef LOG_FORMATTER +#define LOG_FORMATTER +#include +#include + +class LogFormatter { + + public: + virtual void writeHeader(FILE* out_fp, + int version, + int endianness) = 0; + + virtual void writeColumnLabel(FILE* out_fp, + const char* name, + const char* units) = 0; + + virtual void writeColumnLabelSeparator(FILE* out_fp) = 0; + virtual void writeDatumSeparator( FILE* out_fp) = 0; + virtual void writeRecordSeparator(FILE* out_fp) = 0; + virtual void writeDatum(FILE* out_fp, int8_t datum) = 0; + virtual void writeDatum(FILE* out_fp, uint8_t datum) = 0; + virtual void writeDatum(FILE* out_fp, int16_t datum) = 0; + virtual void writeDatum(FILE* out_fp, uint16_t datum) = 0; + virtual void writeDatum(FILE* out_fp, int32_t datum) = 0; + virtual void writeDatum(FILE* out_fp, uint32_t datum) = 0; + virtual void writeDatum(FILE* out_fp, int64_t datum) = 0; + virtual void writeDatum(FILE* out_fp, uint64_t datum) = 0; + virtual void writeDatum(FILE* out_fp, float datum) = 0; + virtual void writeDatum(FILE* out_fp, double datum) = 0; + virtual const char* extension() = 0; +}; +#endif diff --git a/trick_source/data_products/Apps/trkConvert/Varlist_Formatter.cpp b/trick_source/data_products/Apps/trkConvert/Varlist_Formatter.cpp new file mode 100644 index 00000000..901e1197 --- /dev/null +++ b/trick_source/data_products/Apps/trkConvert/Varlist_Formatter.cpp @@ -0,0 +1,25 @@ +#include "Varlist_Formatter.hh" +/* ================================================================================ + * CLASS: Varlist_Formatter isa LogFormatter. + * ================================================================================ + */ + + void Varlist_Formatter::writeHeader(FILE* out_fp, int version, int endianness) {}; + void Varlist_Formatter::writeColumnLabel(FILE* out_fp, const char* name, const char* units) { + fprintf(out_fp,"%s {%s}", name, units); + } + void Varlist_Formatter::writeColumnLabelSeparator(FILE* out_fp) { fprintf(out_fp,"\n"); } + void Varlist_Formatter::writeDatumSeparator(FILE* out_fp __attribute__((unused))) {} + void Varlist_Formatter::writeRecordSeparator(FILE* out_fp __attribute__((unused))) {} + void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), int8_t datum __attribute__((unused))) {} + void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), uint8_t datum __attribute__((unused))) {} + void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), int16_t datum __attribute__((unused))) {} + void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), uint16_t datum __attribute__((unused))) {} + void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), int32_t datum __attribute__((unused))) {} + void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), uint32_t datum __attribute__((unused))) {} + void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), int64_t datum __attribute__((unused))) {} + void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), uint64_t datum __attribute__((unused))) {} + void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), float datum __attribute__((unused))) {} + void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), double datum __attribute__((unused))) {} + + const char* Varlist_Formatter::extension() { return ".varlist"; }; diff --git a/trick_source/data_products/Apps/trkConvert/Varlist_Formatter.hh b/trick_source/data_products/Apps/trkConvert/Varlist_Formatter.hh new file mode 100644 index 00000000..b49fd981 --- /dev/null +++ b/trick_source/data_products/Apps/trkConvert/Varlist_Formatter.hh @@ -0,0 +1,28 @@ +#ifndef VARLIST_FORMATTER +#define VARLIST_FORMATTER + +#include "LogFormatter.hh" +/* ================================================================================ + * CLASS: Varlist_Formatter isa LogFormatter. + * ================================================================================ + */ +class Varlist_Formatter: public LogFormatter { + public: + void writeHeader(FILE* out_fp, int version, int endianness); + void writeColumnLabel(FILE* out_fp, const char* name, const char* units); + void writeColumnLabelSeparator(FILE* out_fp); + void writeDatumSeparator(FILE* out_fp); + void writeRecordSeparator(FILE* out_fp); + void writeDatum(FILE* out_fp, int8_t datum); + void writeDatum(FILE* out_fp, uint8_t datum); + void writeDatum(FILE* out_fp, int16_t datum); + void writeDatum(FILE* out_fp, uint16_t datum); + void writeDatum(FILE* out_fp, int32_t datum); + void writeDatum(FILE* out_fp, uint32_t datum); + void writeDatum(FILE* out_fp, int64_t datum); + void writeDatum(FILE* out_fp, uint64_t datum); + void writeDatum(FILE* out_fp, float datum); + void writeDatum(FILE* out_fp, double datum); + const char* extension(); +}; +#endif diff --git a/trick_source/data_products/Apps/trkConvert/makefile b/trick_source/data_products/Apps/trkConvert/makefile new file mode 100644 index 00000000..ff1180c1 --- /dev/null +++ b/trick_source/data_products/Apps/trkConvert/makefile @@ -0,0 +1,26 @@ +CPP = g++ +CC = gcc + +CXXFLAGS = + +MAIN = trkConvert + +OBJECTS = CSV_Formatter.o Varlist_Formatter.o trkConvert.o + +.c.o: + ${CC} ${CFLAGS} ${INCDIRS} -c $< + +.cpp.o: + ${CPP} ${CFLAGS} ${INCDIRS} -c $< + +all: install + +trkConvert: $(OBJECTS) + $(CPP) -o trkConvert $(OBJECTS) + +install: trkConvert + cp trkConvert $${TRICK_HOME}/bin/trick-trkConvert + +clean: + rm -f *.o + rm -f trkConvert diff --git a/trick_source/data_products/Apps/trkConvert/trkConvert.cpp b/trick_source/data_products/Apps/trkConvert/trkConvert.cpp new file mode 100644 index 00000000..e8b193e2 --- /dev/null +++ b/trick_source/data_products/Apps/trkConvert/trkConvert.cpp @@ -0,0 +1,395 @@ +#include +#include +#include // Requires C99 +#include +#include +#include +#include +#include +#include + +#include "LogFormatter.hh" +#include "CSV_Formatter.hh" +#include "Varlist_Formatter.hh" + +typedef enum { + TRICK_VOID = 0, /* No type */ + TRICK_CHARACTER = 1, /* (char) */ + TRICK_UNSIGNED_CHARACTER = 2, /* (unsigned char) */ + TRICK_STRING = 3, /* (char *) */ + TRICK_SHORT = 4, /* (short) */ + TRICK_UNSIGNED_SHORT = 5, /* (unsigned short) */ + TRICK_INTEGER = 6, /* (int) */ + TRICK_UNSIGNED_INTEGER = 7, /* (unsigned int) */ + TRICK_LONG = 8, /* (long) */ + TRICK_UNSIGNED_LONG = 9, /* (unsigned long) */ + TRICK_FLOAT = 10, /* (float) */ + TRICK_DOUBLE = 11, /* (double) */ + TRICK_BITFIELD = 12, /* (signed int : 1) */ + TRICK_UNSIGNED_BITFIELD = 13, /* (unsigned int : 1) */ + TRICK_LONG_LONG = 14, /* (long long) */ + TRICK_UNSIGNED_LONG_LONG = 15, /* (long long) */ + TRICK_FILE_PTR = 16, /* (file *) */ + TRICK_BOOLEAN = 17, /* (C++ boolean) */ + TRICK_WCHAR = 18, /* (wchar_t) */ + TRICK_WSTRING = 19, /* (wchar_t *) */ + TRICK_VOID_PTR = 20, /* an arbitrary address */ + TRICK_ENUMERATED = 21, /* User defined type (enumeration) */ + TRICK_STRUCTURED = 22, /* User defined type (struct/class) */ + TRICK_OPAQUE_TYPE = 23, /* User defined type (where type details are as yet unknown) */ + TRICK_STL = 24, /* Standard template library type */ + TRICK_NUMBER_OF_TYPES +} TRICK_TYPE ; + +class ReadException: public std::exception { + virtual const char* what() const throw() { + return "fread() failed."; + } +} readException; + +/* ================================================================================ + * CLASS: ParamDescription + * ================================================================================ + */ +class ParamDescription { + public: + char* parameterName; + char* unitsName; + int32_t dataType; + int32_t dataSize; + + ParamDescription(){} + ParamDescription(FILE* fp); +}; + +ParamDescription::ParamDescription(FILE* in_fp){ + + int32_t nameStringLength; + if ( fread( &nameStringLength, 1, 4, in_fp) != 4) throw readException; + + parameterName = new char[nameStringLength+1]; + if ( fread( parameterName, 1, nameStringLength, in_fp) != (size_t)nameStringLength) throw readException; + parameterName[nameStringLength] = 0; + + int32_t unitsStringLength; + if ( fread( &unitsStringLength, 1, 4 , in_fp) != 4) throw readException; + + unitsName = new char[unitsStringLength+1]; + if ( fread( unitsName, 1, unitsStringLength, in_fp) != (size_t)unitsStringLength) throw readException; + unitsName[unitsStringLength] = 0; + + if ( fread( &dataType, 1, 4, in_fp) != 4) throw readException; + if ( fread( &dataSize, 1, 4, in_fp) != 4) throw readException; +} + +/* ================================================================================ + * CLASS: DataLog + * ================================================================================ + */ +class DataLog { + + public: + std::string fileName; + FILE* in_fp; + int version; + int endianness; + uint32_t N_params; + fpos_t dataPosition; + int dataRecordSize; + char* dataRecord; + + static const int LittleEndian; + static const int BigEndian; + + std::vector paramDescriptions; + std::vector paramOffsets; + std::vector paramSelected; + + DataLog(){} + DataLog(std::string fileName); + void selectAllParameters(); + void selectParameter(unsigned int index); + void selectParameter(const char * paramName); + void deselectParameter(unsigned int index); + void formattedWrite(FILE* out_fp, LogFormatter* formatter); +}; + +const int DataLog::LittleEndian = 1; +const int DataLog::BigEndian = 2; + +DataLog::DataLog(std::string file_name) { + + fileName = file_name; + in_fp = fopen(fileName.c_str(), "rb"); + + if (in_fp != NULL) { + + char trick_header_string[11]; + if (fread( trick_header_string, 1, 10, in_fp) != 10) throw readException; + trick_header_string[10] = 0; + + if (!strncmp( trick_header_string, "Trick-", 6)) { + + char version_txt[3]; + memcpy(version_txt, &trick_header_string[6], 2) ; + version_txt[2] = 0; + version = atoi(version_txt); + + char endian_txt[2]; + memcpy(endian_txt, &trick_header_string[9], 1) ; + endian_txt[1] = 0; + + if (!strncmp( endian_txt, "L", 1)) { + endianness = LittleEndian; + } else if (!strncmp( endian_txt, "B", 1)) { + endianness = BigEndian; + } else { + fprintf (stderr, "Trick header error. Endianness should be \"L\" or \"B\"."); + } + + if (fread( &N_params, 1, 4, in_fp) != 4) throw readException; + + dataRecordSize = 0; + for (int ii = 0 ; ii < (int)N_params ; ii++ ) { + ParamDescription* paramDescription = new ParamDescription(in_fp); + paramDescriptions.push_back(paramDescription); + paramOffsets.push_back(dataRecordSize); + paramSelected.push_back(false); + + dataRecordSize += paramDescription->dataSize; + } + dataRecord = new char[dataRecordSize]; + + // Time should always be selected. + paramSelected[0] = true; + + if (fgetpos(in_fp, &dataPosition) != 0) { + fprintf (stderr, "fgetpos failure.\n"); + } + } else { + std::cerr << "File \"" << fileName << "\" isn't a Trick binary log file." << std::endl; + } + } else { + std::cerr << "File \"" << fileName << "\" failed to open." << std::endl; + } +} + +void DataLog::selectAllParameters() { + for (int ii = 1 ; ii < (int)N_params ; ii++ ) { + paramSelected[ii] = true; + } +} + +void DataLog::selectParameter(unsigned int index) { + if ((index > 0) && (index < N_params)) { + paramSelected[index] = true; + } +} + +void DataLog::selectParameter(const char * paramName) { + bool found = false; + int ii = 1; + while ((ii < (int)N_params) && (found == false)) { + if ( !strcmp( paramName, paramDescriptions[ii]->parameterName )) { + paramSelected[ii] = true; + found = true; + } + ii ++; + } +} + +void DataLog::deselectParameter(unsigned int index) { + if ((index > 0) && (index < N_params)) { + paramSelected[index] = false; + } +} + +void DataLog::formattedWrite(FILE* out_fp, LogFormatter* formatter) { + + formatter->writeHeader(out_fp, version, endianness); + formatter->writeColumnLabel(out_fp, paramDescriptions[0]->parameterName, paramDescriptions[0]->unitsName); + for (int ii = 1; ii < (int)N_params ; ii++) { + if (paramSelected[ii]) + formatter->writeColumnLabelSeparator(out_fp); + formatter->writeColumnLabel(out_fp, paramDescriptions[ii]->parameterName, paramDescriptions[ii]->unitsName); + } + + if ( fsetpos(in_fp, &dataPosition) != 0 ) { + fprintf(stderr,"fsetpos() error.\n"); + } + while ( fread( dataRecord, 1, dataRecordSize, in_fp) == (size_t)dataRecordSize) { + formatter->writeRecordSeparator(out_fp); + formatter->writeDatum(out_fp, *(double*)&dataRecord[0]); // Time is always selected. + for (int ii = 1 ; ii < (int)N_params ; ii++ ) { + if (paramSelected[ii]) { + formatter->writeDatumSeparator(out_fp); + switch (paramDescriptions[ii]->dataType) { + case TRICK_CHARACTER: { /*1*/ + formatter->writeDatum(out_fp, *(int8_t*)&dataRecord[paramOffsets[ii]]); + } break; + case TRICK_UNSIGNED_CHARACTER: { /*2*/ + formatter->writeDatum(out_fp, *(uint8_t*)&dataRecord[paramOffsets[ii]]) ; + } break; + case TRICK_SHORT: { /*4*/ + formatter->writeDatum(out_fp, *(int16_t*)&dataRecord[paramOffsets[ii]]); + } break; + case TRICK_UNSIGNED_SHORT: { /*5*/ + formatter->writeDatum(out_fp, *(uint16_t*)&dataRecord[paramOffsets[ii]]); + } break; + case TRICK_INTEGER: {/*6*/ + formatter->writeDatum(out_fp, *(int32_t*)&dataRecord[paramOffsets[ii]]); + } break; + case TRICK_UNSIGNED_INTEGER: {/*7*/ + formatter->writeDatum(out_fp, *(uint32_t*)&dataRecord[paramOffsets[ii]]); + } break; + case TRICK_LONG: { /*8*/ + formatter->writeDatum(out_fp, *(int64_t*)&dataRecord[paramOffsets[ii]]); + } break; + case TRICK_UNSIGNED_LONG: { /*9*/ + formatter->writeDatum(out_fp, *(uint64_t*)&dataRecord[paramOffsets[ii]]); + } break; + case TRICK_FLOAT: {/*10*/ + formatter->writeDatum(out_fp, *(float*)&dataRecord[paramOffsets[ii]]); + } break; + case TRICK_DOUBLE: {/*11*/ + formatter->writeDatum(out_fp, *(double*)&dataRecord[paramOffsets[ii]]); + } break; + case TRICK_LONG_LONG: { /*14*/ + formatter->writeDatum(out_fp, *(int64_t*)&dataRecord[paramOffsets[ii]]); + } break; + case TRICK_UNSIGNED_LONG_LONG: { /*15*/ + formatter->writeDatum(out_fp, *(uint64_t*)&dataRecord[paramOffsets[ii]]); + } break; + case TRICK_BOOLEAN: { /*17*/ + formatter->writeDatum(out_fp, *(uint8_t*)&dataRecord[paramOffsets[ii]]); + } break; + default: { + fprintf(stdout, "Unknown Data Type [%d] of size [%d] bytes.", + paramDescriptions[ii]->dataType, + paramDescriptions[ii]->dataSize); + fflush(stdout); + exit(1); + } + } + } + } + } + formatter->writeRecordSeparator(out_fp); +} + +static const char *usage_doc[] = { +"----------------------------------------------------------------------------", +" trkConvert - ", +" ", +" USAGE: trkConvert -help ", +" trkConvert [-csv|-varlist] [-o ] ", +" Options: ", +" -help Print this message and exit. ", +" -csv (the default) Generates a comma-separated value (CSV) file from ", +" a Trick binary data file. CSV files are a common ", +" means of sharing data between applications. ", +" -varlist Generates a list of the names of the variables ", +" the are recorded in the Trick binary data file. ", +"----------------------------------------------------------------------------"}; +#define N_USAGE_LINES (sizeof(usage_doc)/sizeof(usage_doc[0])) + +void print_doc(char *doc[], int nlines) { + int i; + for (i=0; i < nlines; i++) { + std::cerr << doc[i] << '\n'; + } + std::cerr.flush(); +} + +void usage() { + print_doc((char **)usage_doc,N_USAGE_LINES); +} + +int main(int argc, char* argv[]) { + + std::string programName = argv[0]; + std::string trkFilePath; + std::string trkBaseName; + std::string outputName; + FILE *fp; + + CSV_Formatter csv_formatter; + LogFormatter* logFormatter = &csv_formatter; // default formatter. + Varlist_Formatter varlist_formatter; + + if (argc <= 1 ) { + std::cerr << programName << ": No arguments were supplied.\n"; + std::cerr.flush(); + usage(); + exit(1); + } else { + int i = 1; + std::string arg; + while ( i < argc ) { + arg = argv[i]; + + if (arg.find("-") == 0) { + if (arg == "-help" | arg == "--help" ) { + usage(); + exit(0); + } else if (arg == "-csv") { + logFormatter = &csv_formatter; + } else if (arg == "-varlist") { + logFormatter = &varlist_formatter; + } else if (arg == "-o") { + i++; + if (iextension(); + } + + std::cout << programName << ": Input = \"" << trkFilePath << "\"." << std::endl; + std::cout << programName << ": Output = \"" << outputName << "\"." << std::endl; + + DataLog* datalog = new DataLog(trkFilePath); + datalog->selectAllParameters(); + + if (( fp = fopen(outputName.c_str(), "w") ) != NULL) { + datalog->formattedWrite(fp, logFormatter); + return 0; + } + return 1; +} diff --git a/trick_source/data_products/DPX/DPC/DPC_curve.hh b/trick_source/data_products/DPX/DPC/DPC_curve.hh index dca08f23..d37687ed 100644 --- a/trick_source/data_products/DPX/DPC/DPC_curve.hh +++ b/trick_source/data_products/DPX/DPC/DPC_curve.hh @@ -94,7 +94,7 @@ public: * Get the next (X, Y) pair for the curve. * @return 1 if data was returned in x_value and y_value, 0 if there is no more data. */ - virtual int getXY(double *x_value, double *y_value) { + virtual int getXY(double *, double *) { return 0; } diff --git a/trick_source/data_products/DPX/DPM/DPM_parse_tree.cpp b/trick_source/data_products/DPX/DPM/DPM_parse_tree.cpp index ead513c7..c98d2692 100644 --- a/trick_source/data_products/DPX/DPM/DPM_parse_tree.cpp +++ b/trick_source/data_products/DPX/DPM/DPM_parse_tree.cpp @@ -1,5 +1,6 @@ #include +#include int DPM_parse_tree::Initialize(const char *XMLFileName) { @@ -23,7 +24,16 @@ int DPM_parse_tree::Initialize(const char *XMLFileName) { exit(0); } - doc = xmlCtxtReadFile( parser_context, XMLFileName, NULL, XML_PARSE_DTDVALID ); + const char* xml_catalog_files = getenv("XML_CATALOG_FILES"); + if (xml_catalog_files != NULL) { + doc = xmlCtxtReadFile( parser_context, XMLFileName, NULL, XML_PARSE_DTDVALID ); + } else { + std::cerr << std::endl + << "The XML_CATALOG_FILES environment variable is not set." << std::endl + << "So, \"" << XMLFileName << "\" cannot be validated against it's DTD." << std::endl + << "It will therefore be parsed without validation." << std::endl << std::endl; + doc = xmlCtxtReadFile( parser_context, XMLFileName, NULL, 0 ); + } if (doc == NULL) { std::cerr << "ERROR: Parse of XML file \"" << XMLFileName << "\"" << " failed." << std::endl; diff --git a/trick_source/data_products/DPX/DPV/DPV_view.hh b/trick_source/data_products/DPX/DPV/DPV_view.hh index 47d6de06..96b4e7bd 100644 --- a/trick_source/data_products/DPX/DPV/DPV_view.hh +++ b/trick_source/data_products/DPX/DPV/DPV_view.hh @@ -30,7 +30,7 @@ public: * @param product is a pointer to the instance of DPC_product, for which a * representation is to be rendered. */ - virtual DPV_pointer render_product(DPC_product* product) { + virtual DPV_pointer render_product( DPC_product* ) { return ( (DPV_pointer)NULL); }; @@ -42,7 +42,7 @@ public: * @param page is a pointer to the instance of DPC_page, for which a * viewable representation is to be rendered. */ - virtual DPV_pointer render_page( DPV_pointer parent_data, DPC_page* page) { + virtual DPV_pointer render_page( DPV_pointer, DPC_page* ) { return ( (DPV_pointer)NULL); }; @@ -54,7 +54,7 @@ public: * @param plot is a pointer to the instance of DPC_plot, for which a * viewable representation is to be rendered. */ - virtual DPV_pointer render_plot( DPV_pointer parent_data, DPC_plot* plot) { + virtual DPV_pointer render_plot( DPV_pointer, DPC_plot* ) { return ( (DPV_pointer)NULL); }; @@ -66,7 +66,7 @@ public: * @param plot is a pointer to the instance of DPC_table, for which a * viewable representation is to be rendered. */ - virtual DPV_pointer render_table( DPV_pointer parent_data, DPC_table *table) { + virtual DPV_pointer render_table( DPV_pointer, DPC_table* ) { return ( (DPV_pointer)NULL); }; @@ -78,7 +78,7 @@ public: * @param curve is a pointer to the instance of DPC_curve, for which * a viewable representation is to be rendered. */ - virtual DPV_pointer render_curve( DPV_pointer parent_data, DPC_curve* curve) { + virtual DPV_pointer render_curve( DPV_pointer, DPC_curve* ) { return ( (DPV_pointer)NULL); }; @@ -86,29 +86,29 @@ public: * Override this member function to perform product view processing after all of * the subordinate page views have been rendered (by render_page). */ - virtual void finalize_product_view( DPV_pointer product_view ) {}; + virtual void finalize_product_view( DPV_pointer ) {}; /** * Override this member function to perform page view processing after all of * the subordinate plot views have been rendered (by render_plot_view). */ - virtual void finalize_page_view( DPV_pointer page_view ) {}; + virtual void finalize_page_view( DPV_pointer ) {}; /** */ - virtual void finalize_table_view( DPV_pointer table_view ) {}; + virtual void finalize_table_view( DPV_pointer ) {}; /** * Override this member function to perform plot view processing after all of * the subordinate curve views have been rendered (by render_curve_view). */ - virtual void finalize_plot_view( DPV_pointer plot_view ) {}; + virtual void finalize_plot_view( DPV_pointer ) {}; - virtual void notify_product( DPV_pointer product_view, DPV_message msg) {}; - virtual void notify_page( DPV_pointer page_view, DPV_message msg) {}; - virtual void notify_table( DPV_pointer table_view, DPV_message msg) {}; - virtual void notify_plot( DPV_pointer plot_view, DPV_message msg) {}; - virtual void notify_curve( DPV_pointer curve_view, DPV_message msg) {}; + virtual void notify_product( DPV_pointer, DPV_message ) {}; + virtual void notify_page( DPV_pointer, DPV_message ) {}; + virtual void notify_table( DPV_pointer, DPV_message ) {}; + virtual void notify_plot( DPV_pointer, DPV_message ) {}; + virtual void notify_curve( DPV_pointer, DPV_message ) {}; }; #endif diff --git a/trick_source/data_products/DPX/test/unit_test/DS_test.cpp b/trick_source/data_products/DPX/test/unit_test/DS_test.cpp index 885b9f68..fb2fc4dd 100644 --- a/trick_source/data_products/DPX/test/unit_test/DS_test.cpp +++ b/trick_source/data_products/DPX/test/unit_test/DS_test.cpp @@ -44,8 +44,8 @@ class DSTest : public :: testing::Test { std::string run(char ch); - char* RUN_dir; - char* VarName; + const char* RUN_dir; + const char* VarName; std::string output; int result; @@ -342,8 +342,8 @@ TEST_F(DSTest, DataStream_Delta) { RUN_dir = NULL; char DeltaName[1000]; - char* a = "sun_predictor.sun.solar_azimuth:../TEST_DATA/BUNCHORUNS/RUN1"; - char* b = "sun_predictor.sun.solar_azimuth:../TEST_DATA/BUNCHORUNS/RUN2"; + const char* a = "sun_predictor.sun.solar_azimuth:../TEST_DATA/BUNCHORUNS/RUN1"; + const char* b = "sun_predictor.sun.solar_azimuth:../TEST_DATA/BUNCHORUNS/RUN2"; sprintf(DeltaName, "delta(%s, %s)", a, b); diff --git a/trick_source/data_products/DPX/test/unit_test/test_view.cpp b/trick_source/data_products/DPX/test/unit_test/test_view.cpp index ae3d099c..3449d90e 100644 --- a/trick_source/data_products/DPX/test/unit_test/test_view.cpp +++ b/trick_source/data_products/DPX/test/unit_test/test_view.cpp @@ -28,7 +28,7 @@ DPV_pointer Test_view::render_product( DPC_product* product){ DPV_pointer Test_view::render_page( DPV_pointer parent_data, DPC_page* page) { const char *temp_cstr; - + (void)parent_data; s << "PAGE VIEW:" << std::endl; if ((temp_cstr = page->getTitle()) != NULL) { s << "Page title: " << page->getTitle() << std::endl; @@ -70,7 +70,7 @@ DPV_pointer Test_view::render_page( DPV_pointer parent_data, DPC_page* page) { DPV_pointer Test_view::render_plot( DPV_pointer parent_data, DPC_plot* plot) { const char *temp_cstr; - + (void)parent_data; s << "PLOT VIEW:" << std::endl; if ((temp_cstr = plot->getTitle()) != NULL) { s << "Plot title: " << plot->getTitle() << std::endl; @@ -117,7 +117,8 @@ DPV_pointer Test_view::render_plot( DPV_pointer parent_data, DPC_plot* plot) { } DPV_pointer Test_view::render_table( DPV_pointer parent_data, DPC_table *table) { - const char *temp_cstr; + const char *temp_cstr; + (void)parent_data; int n_columns, colix; int i,j; double time; @@ -189,7 +190,7 @@ DPV_pointer Test_view::render_table( DPV_pointer parent_data, DPC_table *table) DPV_pointer Test_view::render_curve( DPV_pointer parent_data, DPC_curve* curve) { int i; const char *temp_cstr; - + (void)parent_data; s << "CURVE VIEW:" << std::endl; s << "X Var Name: " << curve->getXVarName() << std::endl; s << "X Units: " << curve->getXUnits() << std::endl; @@ -254,18 +255,21 @@ DPV_pointer Test_view::render_curve( DPV_pointer parent_data, DPC_curve* curve) void Test_view::finalize_product_view( DPV_pointer product_view ) { s << "FINALIZE PRODUCT VIEW." << std::endl; - + (void)product_view; } void Test_view::finalize_page_view( DPV_pointer page_view ) { - s << "FINALIZE PAGE VIEW." << std::endl; + s << "FINALIZE PAGE VIEW." << std::endl; + (void)page_view; } void Test_view::finalize_plot_view( DPV_pointer plot_view ) { - s << "FINALIZE PLOT VIEW." << std::endl; + s << "FINALIZE PLOT VIEW." << std::endl; + (void)plot_view; } void Test_view::finalize_table_view( DPV_pointer table_view ) { - s << "FINALIZE TABLE VIEW." << std::endl; + s << "FINALIZE TABLE VIEW." << std::endl; + (void)table_view; } diff --git a/trick_source/data_products/DPX/test/unit_test/test_view.hh b/trick_source/data_products/DPX/test/unit_test/test_view.hh index df435598..579b07b1 100644 --- a/trick_source/data_products/DPX/test/unit_test/test_view.hh +++ b/trick_source/data_products/DPX/test/unit_test/test_view.hh @@ -26,11 +26,11 @@ class Test_view: public DPV_view { /** * The following functions are unused from abstract class DPV_view */ - void notify_product( DPV_pointer product_view, DPV_message msg) {}; - void notify_page( DPV_pointer page_view, DPV_message msg) {}; - void notify_table( DPV_pointer table_view, DPV_message msg) {}; - void notify_plot( DPV_pointer plot_view, DPV_message msg) {}; - void notify_curve( DPV_pointer curve_view, DPV_message msg) {}; + void notify_product( DPV_pointer, DPV_message) {}; + void notify_page( DPV_pointer, DPV_message) {}; + void notify_table( DPV_pointer, DPV_message) {}; + void notify_plot( DPV_pointer, DPV_message) {}; + void notify_curve( DPV_pointer, DPV_message) {}; std::string getOutput(); diff --git a/trick_source/data_products/makefile b/trick_source/data_products/makefile index f9514b33..85b39c45 100644 --- a/trick_source/data_products/makefile +++ b/trick_source/data_products/makefile @@ -18,6 +18,7 @@ LIBDIRS += fermi-ware endif APPDIRS = DPX \ + Apps/trkConvert \ Apps/Trk2csv \ Apps/ExternalPrograms diff --git a/trick_source/er7_utils/integration/beeman/src/beeman_integrator_constructor.cc b/trick_source/er7_utils/integration/beeman/src/beeman_integrator_constructor.cc index 02877bf7..72d2bf71 100644 --- a/trick_source/er7_utils/integration/beeman/src/beeman_integrator_constructor.cc +++ b/trick_source/er7_utils/integration/beeman/src/beeman_integrator_constructor.cc @@ -24,7 +24,7 @@ Purpose: () // Integration includes #include "er7_utils/integration/core/include/integrator_constructor_utils.hh" #include "er7_utils/integration/core/include/priming_integration_controls.hh" -#include "er7_utils/integration/rk2_heun/include/rk2_heun_integrator_constructor.hh" +#include "er7_utils/integration/rk2_heun/include/rk2_heun_first_order_ode_integrator.hh" // Model includes #include "../include/beeman_integrator_constructor.hh" diff --git a/trick_source/er7_utils/integration/core/include/generalized_position_derivative.hh b/trick_source/er7_utils/integration/core/include/generalized_position_derivative.hh index 5a31d532..71aec3a9 100644 --- a/trick_source/er7_utils/integration/core/include/generalized_position_derivative.hh +++ b/trick_source/er7_utils/integration/core/include/generalized_position_derivative.hh @@ -68,7 +68,7 @@ public: const double * ER7_UTILS_RESTRICT position, const double * ER7_UTILS_RESTRICT velocity, const double * ER7_UTILS_RESTRICT acceleration, - double * ER7_UTILS_RESTRICT position_second_derivative); + double * ER7_UTILS_RESTRICT position_2nd_derivative); // Constructors and destructor @@ -106,13 +106,17 @@ public: // Member data - FirstDerivative first_deriv_fun; /**< trick_io(**) @n - Function that computes the first time derivative of - generalized position. */ + /** + * Function that computes the first time derivative of + * generalized position. + */ + FirstDerivative first_deriv_fun; //!< trick_io(**) - SecondDerivative second_deriv_fun; /**< trick_io(**) @n - Function that computes the second time derivative of - generalized position. */ + /** + * Function that computes the second time derivative of + * generalized position. + */ + SecondDerivative second_deriv_fun; //!< trick_io(**) }; diff --git a/trick_source/er7_utils/integration/core/include/integration_controls.hh b/trick_source/er7_utils/integration/core/include/integration_controls.hh index 0fb403fd..927a05ef 100644 --- a/trick_source/er7_utils/integration/core/include/integration_controls.hh +++ b/trick_source/er7_utils/integration/core/include/integration_controls.hh @@ -228,7 +228,7 @@ protected: * IntegrationControls copy constructor. * @param[in] source The IntegrationControls to be copied. */ - IntegrationControls (const IntegrationControls &); + IntegrationControls (const IntegrationControls & source); /** * IntegrationControls non-default constructor. diff --git a/trick_source/er7_utils/integration/rkn4/include/rkn4_second_order_ode_integrator.hh b/trick_source/er7_utils/integration/rkn4/include/rkn4_second_order_ode_integrator.hh index 9ca9092e..00eb84f6 100644 --- a/trick_source/er7_utils/integration/rkn4/include/rkn4_second_order_ode_integrator.hh +++ b/trick_source/er7_utils/integration/rkn4/include/rkn4_second_order_ode_integrator.hh @@ -77,7 +77,7 @@ protected: * for a simple second order ODE, one in which generalized velocity * is time derivative of generalized position. * @param[in] size State size - * @param[in,out] controls_in Integration controls + * @param[in,out] controls Integration controls */ RKNystrom4SecondOrderODEIntegrator ( unsigned int size, diff --git a/trick_source/er7_utils/interface/include/alloc.hh b/trick_source/er7_utils/interface/include/alloc.hh index a3de577d..0bfa174e 100644 --- a/trick_source/er7_utils/interface/include/alloc.hh +++ b/trick_source/er7_utils/interface/include/alloc.hh @@ -173,7 +173,6 @@ namespace er7_utils { * Destruct and deallocate a previously allocated object. * @tparam T Type of the object to be deallocated. * @param obj Object to be destructed, as a reference to a pointer. - * @return Array of allocated objects. */ template inline void delete_object (T*& obj) { @@ -540,7 +539,7 @@ namespace er7_utils { /** * Deallocate an array of some primitive type - * @tparam T + * @tparam T Array type. * @param arr Array to be deallocated. */ template @@ -632,7 +631,7 @@ namespace er7_utils { * Allocate contents of a 2D array, where the array is declared as * @code T ** array @endcode * @tparam T Array type - * @tparam outer Array outer dimension + * @param outer Array outer dimension * @param inner Array inner dimension * @return Allocated 2D array. */ @@ -680,7 +679,6 @@ namespace er7_utils { /** * Specialization of replicate_2D_array for double. - * @tparam T Array type * @tparam M Array outer dimension * @param[in] size Array inner dimension * @param[in] src Source 2D array @@ -752,7 +750,6 @@ namespace er7_utils { /** * Specialization of deallocate_2D_array for double. - * @tparam T Array type * @tparam M Array outer dimension * @param[in,out] arr Array to be deallocated */ @@ -768,12 +765,11 @@ namespace er7_utils { /** * Deallocate a 2D array. * @tparam T Array type - * @tparam outer Array outer dimension * @param[in,out] arr Array to be deallocated */ template inline void deallocate_2D_array ( - unsigned int outer ER7_UTILS_UNUSED, + unsigned int, T **& arr) { if (arr != NULL) { diff --git a/trick_source/er7_utils/interface/include/type_traits.hh b/trick_source/er7_utils/interface/include/type_traits.hh index 92720711..667568ce 100644 --- a/trick_source/er7_utils/interface/include/type_traits.hh +++ b/trick_source/er7_utils/interface/include/type_traits.hh @@ -163,7 +163,8 @@ namespace er7_utils { * uses dynamic_cast. * @tparam T Type to be deduced. * This parameter is a polymorphic class in this base implementation. - * @tparam is_class True if T is a polymorphic class, false otherwise. + * @tparam is_polymorphic True if T is a polymorphic class, + * false otherwise. * This parameter is true in this base implementation. */ template diff --git a/trick_source/er7_utils/math/include/n_choose_m.hh b/trick_source/er7_utils/math/include/n_choose_m.hh index e996b0df..2686af55 100644 --- a/trick_source/er7_utils/math/include/n_choose_m.hh +++ b/trick_source/er7_utils/math/include/n_choose_m.hh @@ -76,7 +76,7 @@ public: /** * Resize the triangle if the current number of rows is less than the * specified size. - * @param new_triangle_nrows Requested number of rows in the triangle. + * @param new_size Requested number of rows in the triangle. * @throw std::overflow_error if new_triangle_nrows > 68. */ void resize (unsigned int new_size); diff --git a/trick_source/er7_utils/math/include/ratio128.hh b/trick_source/er7_utils/math/include/ratio128.hh index 17208034..107467f9 100644 --- a/trick_source/er7_utils/math/include/ratio128.hh +++ b/trick_source/er7_utils/math/include/ratio128.hh @@ -410,12 +410,12 @@ public: // Comparison operators. /** - * Returns a friend bool operator< (T a, const Ratio128 & b) @@ -424,7 +424,7 @@ public: } /** - * Returns a friend bool operator< (const Ratio128 & a, T b) diff --git a/trick_source/java/build.xml b/trick_source/java/build.xml deleted file mode 100644 index ee1a1269..00000000 --- a/trick_source/java/build.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - Build file for Trick JAVA resources - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/trick_source/java/makefile b/trick_source/java/makefile index a78a47a7..c9c65760 100644 --- a/trick_source/java/makefile +++ b/trick_source/java/makefile @@ -5,6 +5,17 @@ include ${TRICK_HOME}/share/trick/makefiles/Makefile.common JAVAC ?= javac JAVAC_FLAGS = -g -Xlint:unchecked -Xlint:deprecation +# delineate 'javac -version' for version number +JAVAC_VERSION := $(shell ${JAVAC} -version 2>&1 | perl -ne 'print /(\d+)/') + +# include java.se.ee for JAXB xml annotations (for trick-tv) in java version 9 +ifeq ($(JAVAC_VERSION),9) + JAVAC_FLAGS += --add-modules java.se.ee +endif + +ifeq ($(JAVAC_VERSION),10) + JAVAC_FLAGS += --add-modules java.se.ee +endif SRC_DIR = src SRC_FILES = $(shell find ${SRC_DIR} -type f -name \*.java) diff --git a/trick_source/java/src/trick/common/TrickApplication.java b/trick_source/java/src/trick/common/TrickApplication.java index c27ac1fa..e5696a7e 100644 --- a/trick_source/java/src/trick/common/TrickApplication.java +++ b/trick_source/java/src/trick/common/TrickApplication.java @@ -110,9 +110,9 @@ public abstract class TrickApplication extends SingleFrameApplication implements // if we want to put the properties into a different location, change here. static { try { - propDirectory = System.getProperty("user.home") + System.getProperty("file.separator") + ".trick"; + propDirectory = System.getProperty("user.home") + java.io.File.separator + ".trick"; } catch (Exception e) { - propDirectory = System.getenv("TRICK_USER_HOME") + System.getProperty("file.separator") + ".trick"; + propDirectory = System.getenv("TRICK_USER_HOME") + java.io.File.separator + ".trick"; } } @@ -319,7 +319,7 @@ public abstract class TrickApplication extends SingleFrameApplication implements applicationName = getContext().getApplicationClass().getSimpleName(); // set directory for session storage - getContext().getLocalStorage().setDirectory(new File(propDirectory + System.getProperty("file.separator") + "." + applicationName)); + getContext().getLocalStorage().setDirectory(new File(propDirectory + java.io.File.separator + "." + applicationName)); // register property for JToggleButton class so that its state can be saved getContext().getSessionStorage().putProperty(JToggleButton.class, this); @@ -330,7 +330,7 @@ public abstract class TrickApplication extends SingleFrameApplication implements // Load any saved user settable properties from properties file trickProperties = new Properties(); try { - FileInputStream in = new FileInputStream(propDirectory + System.getProperty("file.separator") + applicationName + ".properties"); + FileInputStream in = new FileInputStream(propDirectory + java.io.File.separator + applicationName + ".properties"); trickProperties.load(in); in.close(); } @@ -384,7 +384,7 @@ public abstract class TrickApplication extends SingleFrameApplication implements // Save any user settable properties to properties file in user's home directory in .trick dir try { - FileOutputStream out = new FileOutputStream(propDirectory + System.getProperty("file.separator") + applicationName +".properties"); + FileOutputStream out = new FileOutputStream(propDirectory + java.io.File.separator + applicationName +".properties"); trickProperties.store(out, "--- Trick User Properties ---"); out.close(); } catch (IOException e) { diff --git a/trick_source/java/src/trick/common/ui/UIUtils.java b/trick_source/java/src/trick/common/ui/UIUtils.java index c1f419a4..4dbeed51 100644 --- a/trick_source/java/src/trick/common/ui/UIUtils.java +++ b/trick_source/java/src/trick/common/ui/UIUtils.java @@ -748,11 +748,11 @@ public class UIUtils { ImageIcon imgIcon = null; // if the fileName is a full path - if (fileName.indexOf(System.getProperty("file.separator")) != -1) { + if (fileName.indexOf(java.io.File.separator) != -1) { imgIcon = new ImageIcon(fileName); } else { // if only a file name specified, try to find it at common resources folder - URL imgURL = TrickApplication.class.getResource("resources" + System.getProperty("file.separator") + fileName); + URL imgURL = TrickApplication.class.getResource("resources" + java.io.File.separator + fileName); if (imgURL != null) { imgIcon = new ImageIcon(imgURL); } @@ -778,11 +778,11 @@ public class UIUtils { try { InputStream ins = null; // if the fileName is a full path - if (fileName.indexOf(System.getProperty("file.separator")) != -1) { + if (fileName.indexOf(java.io.File.separator) != -1) { ins = new FileInputStream(fileName); } else { // if only a file name, then find it at common resources area - ins = TrickApplication.class.getResourceAsStream("resources" + System.getProperty("file.separator") + fileName); + ins = TrickApplication.class.getResourceAsStream("resources" + java.io.File.separator + fileName); } return ins; } catch (NullPointerException npe) { diff --git a/trick_source/java/src/trick/dataproducts/trickdp/TrickDPApplication.java b/trick_source/java/src/trick/dataproducts/trickdp/TrickDPApplication.java index 71b14453..603401d4 100644 --- a/trick_source/java/src/trick/dataproducts/trickdp/TrickDPApplication.java +++ b/trick_source/java/src/trick/dataproducts/trickdp/TrickDPApplication.java @@ -356,7 +356,7 @@ public class TrickDPApplication extends DataProductsApplication { while (!simFilePath.getName().startsWith("SIM_")) { simFilePath = simFilePath.getParentFile(); } - String simExeArg = eachItem+System.getProperty("file.separator")+"input.py"; + String simExeArg = eachItem+java.io.File.separator+"input.py"; ProcessBuilder pb = new ProcessBuilder(simExe, simExeArg); pb.directory(simFilePath); printStatusMessage("cd " + simFilePath.getPath() + "\n"); @@ -869,7 +869,7 @@ public class TrickDPApplication extends DataProductsApplication { // TODO: use TrickFileFilter FilenameFilter simFilter = new FilenameFilter() { public boolean accept(File path, String filename) { - File myFullPath = new File(path + System.getProperty("file.separator") + filename); + File myFullPath = new File(path + java.io.File.separator + filename); if ( myFullPath.isDirectory() && filename.contains("SIM") ) { return true; } else { @@ -894,7 +894,7 @@ public class TrickDPApplication extends DataProductsApplication { */ private String appendDirsFromPropertyFile(String simDirs) { // prevent the duplicate ones - File myDpPropFile = new File(propDirectory + System.getProperty("file.separator") + applicationName + ".properties"); + File myDpPropFile = new File(propDirectory + java.io.File.separator + applicationName + ".properties"); if ( myDpPropFile.exists() ) { String dpSimDirsProperty = trickProperties.getProperty("TRICK_DP_SIM_DIRS"); // if the property doesn't exist, return the original string diff --git a/trick_source/java/src/trick/dataproducts/trickdp/utils/PDFBooklet.java b/trick_source/java/src/trick/dataproducts/trickdp/utils/PDFBooklet.java index fc1d8cb9..12855e9a 100644 --- a/trick_source/java/src/trick/dataproducts/trickdp/utils/PDFBooklet.java +++ b/trick_source/java/src/trick/dataproducts/trickdp/utils/PDFBooklet.java @@ -300,7 +300,7 @@ public class PDFBooklet extends JDialog implements ActionListener, ListSelection // For PS view private void psView() { - File selectedFirstFile = new File(fileDir + System.getProperty("file.separator") + selectedPSFileList.getSelectedFirstData().toString()); + File selectedFirstFile = new File(fileDir + java.io.File.separator + selectedPSFileList.getSelectedFirstData().toString()); try { if (selectedFirstFile.exists() && Desktop.isDesktopSupported()) { Desktop.getDesktop().open(selectedFirstFile); @@ -324,7 +324,7 @@ public class PDFBooklet extends JDialog implements ActionListener, ListSelection for (Object obj : selectedData) { commandBuf.append(" "); commandBuf.append(fileDir); - commandBuf.append(System.getProperty("file.separator")); + commandBuf.append(java.io.File.separator); commandBuf.append(obj.toString()); } @@ -357,7 +357,7 @@ public class PDFBooklet extends JDialog implements ActionListener, ListSelection for (Object obj : selectedData) { commandBuf.append(" "); commandBuf.append(fileDir); - commandBuf.append(System.getProperty("file.separator")); + commandBuf.append(java.io.File.separator); commandBuf.append(obj.toString()); } diff --git a/trick_source/java/src/trick/dataproducts/trickdp/utils/TrickDPActionController.java b/trick_source/java/src/trick/dataproducts/trickdp/utils/TrickDPActionController.java index 91e7a314..d1c911ae 100644 --- a/trick_source/java/src/trick/dataproducts/trickdp/utils/TrickDPActionController.java +++ b/trick_source/java/src/trick/dataproducts/trickdp/utils/TrickDPActionController.java @@ -408,7 +408,7 @@ public class TrickDPActionController { public void launchQP(String[] initialArgs) { // the command variable program command name and arguments List command = new ArrayList(); - String fileSeparator = System.getProperty("file.separator"); + String fileSeparator = java.io.File.separator; String pathSeparator = System.getProperty("path.separator"); String javaPath = UIUtils.getTrickHome() + fileSeparator + "libexec/trick" + fileSeparator + "java"; diff --git a/trick_source/java/src/trick/dataproducts/trickqp/utils/TrickQPActionController.java b/trick_source/java/src/trick/dataproducts/trickqp/utils/TrickQPActionController.java index cd999380..5096df25 100644 --- a/trick_source/java/src/trick/dataproducts/trickqp/utils/TrickQPActionController.java +++ b/trick_source/java/src/trick/dataproducts/trickqp/utils/TrickQPActionController.java @@ -351,7 +351,7 @@ public class TrickQPActionController { for (int i = 0; i < selectedVars.length; i++) { LogVar varFrom = (LogVar)selectedVars[i]; - if (varFrom.getName().matches("-(?!>)")) { + if ((varFrom.getName().indexOf('-') != -1) || (varFrom.getName().matches("-(?!>)"))) { List vars = get_components_from_array(varFrom.getName()); // expand variable if ( (selectedTreeNodes!=null) && (selectedTreeNodes.size()>0) && (((CommonTreeNode)selectedTreeNodes.get(0)).getNodeType()!=CommonTreeNode.PLOTS_NODE) ) { diff --git a/trick_source/java/src/trick/dre/DreApplication.java b/trick_source/java/src/trick/dre/DreApplication.java index f3da41b3..b31151a5 100644 --- a/trick_source/java/src/trick/dre/DreApplication.java +++ b/trick_source/java/src/trick/dre/DreApplication.java @@ -7,41 +7,6 @@ package trick.dre; //======================================== // Imports //======================================== -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Collection; -import java.util.Vector; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.swing.Box; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.JSeparator; -import javax.swing.JSplitPane; -import javax.swing.JTextField; -import javax.swing.JToolBar; -import javax.swing.tree.TreePath; -import javax.xml.parsers.ParserConfigurationException; import org.jdesktop.application.Action; import org.jdesktop.application.Application; @@ -49,381 +14,416 @@ import org.jdesktop.application.View; import org.jdesktop.swingx.JXLabel; import org.xml.sax.InputSource; import org.xml.sax.SAXException; - import trick.common.TrickApplication; import trick.common.ui.UIUtils; import trick.common.ui.components.NumberTextField; import trick.common.ui.panels.ListPanel; -import trick.sie.utils.SearchPanel; -import trick.sie.utils.SieResourceDomParser; -import trick.sie.utils.SieTemplate; -import trick.sie.utils.SieTreeModel; -import trick.sie.utils.SieVariableTree; +import trick.sie.utils.*; + +import javax.swing.*; +import javax.swing.tree.TreePath; +import javax.xml.parsers.ParserConfigurationException; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.*; +import java.util.Collection; +import java.util.StringTokenizer; +import java.util.Vector; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Dre - data recording editor application. * - * @author Hong Chen + * @author Hong Chen + * @author Scott Fennell * @since Trick 10 + * @since Trick 17 */ public class DreApplication extends TrickApplication { - //======================================== - // Public data - //======================================== - - - //======================================== - // Protected data - //======================================== - protected static String sieResourcePath = null; - - //======================================== - // Private Data - //======================================== - private String single_prec_only; - private String frequency; - private String format; - private String buffering; - private Vector variables = new Vector(); - - /** The menu check box for Single Precision. */ - private JCheckBoxMenuItem singlePrecisionCheckBox; - - /** Popup window for clicking a tree node **/ + //======================================== + // Public data + //======================================== + + + //======================================== + // Protected data + //======================================== + protected static String sieResourcePath = null; + + //======================================== + // Private Data + //======================================== + private String single_prec_only; + private String frequency; + private String format; + private String buffering; + private Vector variables = new Vector(); + + /** + * The menu check box for Single Precision. + */ + private JCheckBoxMenuItem singlePrecisionCheckBox; + + /** + * Popup window for clicking a tree node + **/ private JPopupMenu treePopup = null; - + /** S_sie.resource xml parser */ //private SieResourceXMLParser sieXMLParser; - - /** The sim objects top level instances */ + + /** + * The sim objects top level instances + */ private Collection rootTemplates; - - /** The variable (sim objects) tree */ + + /** + * The variable (sim objects) tree + */ private SieVariableTree varTree; - - /** The search panel for the variable tree */ + + /** + * The search panel for the variable tree + */ private SearchPanel searchPanel; - - /** The selected variable list */ - private ListPanel selectedVarList; - - /** The text field that contains the group name */ + + /** + * The selected variable list + */ + private ListPanel selectedVarList; + + /** + * The text field that contains the group name + */ private JTextField nameField; - - /** The text field that contains the cycle frequency for recording */ + + /** + * The text field that contains the cycle frequency for recording + */ private NumberTextField cycleField; - + + /** + * The text field that contains the max file size for the group + */ + private NumberTextField maxFileSizeField; + + private JComboBox sizeUnitsBox; + + private JCheckBox unlimitedSizeBox; + private JRadioButtonMenuItem DRAscii_item; private JRadioButtonMenuItem DRBinary_item; private JRadioButtonMenuItem DRHDF5_item; - + private JRadioButtonMenuItem DRBuffer_item; private JRadioButtonMenuItem DRNoBuffer_item; private JRadioButtonMenuItem DRRingBuffer_item; //private JRadioButtonMenuItem DRThreadBuffer_item; - + private JRadioButtonMenuItem DRAlways_item; private JRadioButtonMenuItem DRChanges_item; private JRadioButtonMenuItem DRStepChanges_item; - + private boolean isSinglePrecision; - + /** * Vectors to contain the information on the variable * being added to the recording list. */ Vector nameSegment = new Vector(); Vector fullName = new Vector(); - - //======================================== - // Constructors - //======================================== - + + //======================================== + // Constructors + //======================================== + //======================================== // Actions //======================================== @Action public void openDR() { - File file = UIUtils.chooseOpenFile(null, null, "dr", getMainFrame()); - if (file != null) { - openFile(file); - } + File file = UIUtils.chooseOpenFile(null, null, "dr", getMainFrame()); + if (file != null) { + openFile(file); + } } - + @Action public void saveDR() { if (nameField.getText().trim().compareTo("") == 0) { - JOptionPane.showMessageDialog(getMainFrame(), "A group name must be entered!", - "Error", JOptionPane.ERROR_MESSAGE); - return; + JOptionPane.showMessageDialog(getMainFrame(), "A group name must be entered!", + "Error", JOptionPane.ERROR_MESSAGE); + return; } else if (nameField.getText().trim().contains(" ")) { - JOptionPane.showMessageDialog(getMainFrame(), "A group name can not have whitespace!", - "Error", JOptionPane.ERROR_MESSAGE); - return; + JOptionPane.showMessageDialog(getMainFrame(), "A group name can not have whitespace!", + "Error", JOptionPane.ERROR_MESSAGE); + return; } File file = UIUtils.chooseSaveFile(null, null, "dr", getMainFrame()); if (file != null) { - saveFile(file); + saveFile(file); } } - + @Action public void selectDRBinary() { - format = "DRBinary"; - DRAscii_item.setSelected(false); - DRBinary_item.setSelected(true); - DRHDF5_item.setSelected(false); + format = "DRBinary"; + DRAscii_item.setSelected(false); + DRBinary_item.setSelected(true); + DRHDF5_item.setSelected(false); } - + @Action public void selectDRAscii() { - format = "DRAscii"; - DRAscii_item.setSelected(true); - DRBinary_item.setSelected(false); - DRHDF5_item.setSelected(false); + format = "DRAscii"; + DRAscii_item.setSelected(true); + DRBinary_item.setSelected(false); + DRHDF5_item.setSelected(false); } - + @Action public void selectDRHDF5() { - format = "DRHDF5"; - DRAscii_item.setSelected(false); - DRBinary_item.setSelected(false); - DRHDF5_item.setSelected(true); - } - + format = "DRHDF5"; + DRAscii_item.setSelected(false); + DRBinary_item.setSelected(false); + DRHDF5_item.setSelected(true); + } + @Action public void selectDRAlways() { - frequency = "DR_Always"; - DRAlways_item.setSelected(true); - DRChanges_item.setSelected(false); - DRStepChanges_item.setSelected(false); + frequency = "DR_Always"; + DRAlways_item.setSelected(true); + DRChanges_item.setSelected(false); + DRStepChanges_item.setSelected(false); } - + @Action public void selectDRChanges() { - frequency = "DR_Changes"; - DRAlways_item.setSelected(false); - DRChanges_item.setSelected(true); - DRStepChanges_item.setSelected(false); + frequency = "DR_Changes"; + DRAlways_item.setSelected(false); + DRChanges_item.setSelected(true); + DRStepChanges_item.setSelected(false); } - + @Action public void selectDRStepChanges() { - frequency = "DR_Step_Changes"; - DRAlways_item.setSelected(false); - DRChanges_item.setSelected(false); - DRStepChanges_item.setSelected(true); - } - + frequency = "DR_Step_Changes"; + DRAlways_item.setSelected(false); + DRChanges_item.setSelected(false); + DRStepChanges_item.setSelected(true); + } + @Action public void toggleSinglePrecision() { - isSinglePrecision = singlePrecisionCheckBox.getState(); - if (isSinglePrecision) { - single_prec_only = "True"; - } else { - single_prec_only = "False"; - } + isSinglePrecision = singlePrecisionCheckBox.getState(); + if (isSinglePrecision) { + single_prec_only = "True"; + } else { + single_prec_only = "False"; + } } - + @Action public void selectDRBuffer() { - buffering = "DR_Buffer"; - DRBuffer_item.setSelected(true); - DRNoBuffer_item.setSelected(false); - DRRingBuffer_item.setSelected(false); - //DRThreadBuffer_item.setSelected(false); + buffering = "DR_Buffer"; + DRBuffer_item.setSelected(true); + DRNoBuffer_item.setSelected(false); + DRRingBuffer_item.setSelected(false); + //DRThreadBuffer_item.setSelected(false); } - + @Action public void selectDRNoBuffer() { - buffering = "DR_No_Buffer"; - DRBuffer_item.setSelected(false); - DRNoBuffer_item.setSelected(true); - DRRingBuffer_item.setSelected(false); - //DRThreadBuffer_item.setSelected(false); + buffering = "DR_No_Buffer"; + DRBuffer_item.setSelected(false); + DRNoBuffer_item.setSelected(true); + DRRingBuffer_item.setSelected(false); + //DRThreadBuffer_item.setSelected(false); } - + @Action public void selectDRRingBuffer() { - buffering = "DR_Ring_Buffer"; - DRBuffer_item.setSelected(false); - DRNoBuffer_item.setSelected(false); - DRRingBuffer_item.setSelected(true); - //DRThreadBuffer_item.setSelected(false); + buffering = "DR_Ring_Buffer"; + DRBuffer_item.setSelected(false); + DRNoBuffer_item.setSelected(false); + DRRingBuffer_item.setSelected(true); + //DRThreadBuffer_item.setSelected(false); } - + @Action public void selectDRThreadBuffer() { - buffering = "DR_Thread_Buffer"; - DRBuffer_item.setSelected(false); - DRNoBuffer_item.setSelected(false); - DRRingBuffer_item.setSelected(false); - //DRThreadBuffer_item.setSelected(true); + buffering = "DR_Thread_Buffer"; + DRBuffer_item.setSelected(false); + DRNoBuffer_item.setSelected(false); + DRRingBuffer_item.setSelected(false); + //DRThreadBuffer_item.setSelected(true); } - + @Action public void removeSelected() { - Object[] values = selectedVarList.getSelectedData(); - for (int i = 0; i < values.length; i++) { - variables.remove(values[i]); - } - selectedVarList.removeSelectedData(); + Object[] values = selectedVarList.getSelectedData(); + for (int i = 0; i < values.length; i++) { + variables.remove(values[i]); + } + selectedVarList.removeSelectedData(); } - + @Action public void removeAll() { - selectedVarList.removeAllData(); - variables.clear(); + selectedVarList.removeAllData(); + variables.clear(); } - + @Action public void addVariables() { for (SieTemplate thisValue : searchPanel.getSelectedValues()) { addVariable(thisValue.toString()); } } - - //======================================== - // Set/Get methods - //======================================== - - - - //======================================== - // Methods - //======================================== - /** + + + //======================================== + // Set/Get methods + //======================================== + + + //======================================== + // Methods + //======================================== + + /** * Main method for this application. + * * @param args command line arguments */ public static void main(String[] args) { Application.launch(DreApplication.class, args); } - + /** * Makes initialization as needed. This is called before startup(). - * + * * @see #startup - */ + */ @Override protected void initialize(String[] args) { super.initialize(args); File resourceFile = null; if (sieResourcePath == null) { - resourceFile = new File(resourceMap.getString("sie.resource.file")); + resourceFile = new File(resourceMap.getString("sie.resource.file")); } else { - resourceFile = new File(sieResourcePath); + resourceFile = new File(sieResourcePath); } //sieXMLParser = null; - if (resourceFile != null && !resourceFile.exists()) { + if (!resourceFile.exists()) { System.out.println(resourceFile.getName() + " file does not exist. Exit!!!"); System.exit(0); } - + try { - rootTemplates = SieResourceDomParser.parse(new InputSource(new FileInputStream(resourceFile))); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (ParserConfigurationException e) { - e.printStackTrace(); - } catch (SAXException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - - /*try { - sieXMLParser = new SieResourceXMLParser(resourceFile.getCanonicalPath()); + rootTemplates = SieResourceDomParser.parse(new InputSource(new FileInputStream(resourceFile))); + } catch (ParserConfigurationException | SAXException | IOException e) { + e.printStackTrace(); + } + + /*try { + sieXMLParser = new SieResourceXMLParser(resourceFile.getCanonicalPath()); sieXMLParser.runParser(); } catch (Exception e) { System.out.println("Failed to parse " + resourceFile.getName() + "!"); System.exit(0); }*/ - + treePopup = new JPopupMenu(); - + varTree = new SieVariableTree(); varTree.setRootInstances(rootTemplates); - - varTree.setShowsRootHandles(true); + + varTree.setShowsRootHandles(true); } - + /** - * Starts building GUI. This is called after initialize. + * Starts building GUI. This is called after initialize. * Once startup() is done, ready() is called. - * + * * @see #initialize * @see #ready */ @Override protected void startup() { super.startup(); - + View view = getMainView(); view.setComponent(createMainPanel()); view.setMenuBar(createMenuBar()); view.setToolBar(createToolBar()); - + getMainFrame().setMinimumSize(getMainFrame().getPreferredSize()); show(view); + + } /** * Creates the main panel. This is required by TrickApplication. - * + * * @return a {@link JComponent} as the main panel. */ @Override - protected JComponent createMainPanel() { - JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); - JSplitPane treeSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); - - searchPanel = new SearchPanel(); - + protected JComponent createMainPanel() { + JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + JSplitPane treeSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); + + searchPanel = new SearchPanel(); + searchPanel.setAction(actionMap.get("addVariables")); - + searchPanel.setRootTemplates(rootTemplates); - + treeSplitPane.add(UIUtils.createSearchableTitledPanel("Variables", varTree, null)); treeSplitPane.add(searchPanel); - + splitPane.add(treeSplitPane); - splitPane.add(UIUtils.createSearchableTitledPanel("Selected Variables", createSelectedVariablesPanel(), null)); - - // create a mouse listener and add to tree + splitPane.add(UIUtils.createSearchableTitledPanel("Selected Variables", createSelectedVariablesPanel(), null)); + + // create a mouse listener and add to tree TreeMouseListener mouser = new TreeMouseListener(); - varTree.addMouseListener(mouser); - + varTree.addMouseListener(mouser); + return splitPane; } - + /** * Helper method for creating the variables tab. */ private JComponent createSelectedVariablesPanel() { - JPanel panel = new JPanel(); - panel.setLayout(new BorderLayout()); - panel.add(new JSeparator(), BorderLayout.NORTH); - selectedVarList = new ListPanel(); - String[] popupMenuActions = { "removeSelected", "removeAll"}; + JPanel panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.add(new JSeparator(), BorderLayout.NORTH); + selectedVarList = new ListPanel(); + String[] popupMenuActions = {"removeSelected", "removeAll"}; selectedVarList.setPopup(createPopupMenu(popupMenuActions), 0); - panel.add(selectedVarList, BorderLayout.CENTER); - return panel; + panel.add(selectedVarList, BorderLayout.CENTER); + return panel; } - + /** - * Create the JMenuBar for this application. + * Create the JMenuBar for this application. */ @Override - protected JMenuBar createMenuBar() { - JMenuBar menuBar = super.createMenuBar(); - JMenu menu = menuBar.getMenu(0); + protected JMenuBar createMenuBar() { + JMenuBar menuBar = super.createMenuBar(); + JMenu menu = menuBar.getMenu(0); menu.add(new JSeparator(), 0); menu.add(new JMenuItem(getAction("saveDR")), 0); menu.add(new JMenuItem(getAction("openDR")), 0); - + menuBar.add(createOptionsMenu(), 1); - + return menuBar; } @@ -431,267 +431,385 @@ public class DreApplication extends TrickApplication { * Helper method for creating Options menu. */ private JMenu createOptionsMenu() { - JMenu optionsMenu = new JMenu(); - optionsMenu.setName("optionsMenu"); - - optionsMenu.add(new JLabel("Format ")); - - DRBinary_item = new JRadioButtonMenuItem(); + JMenu optionsMenu = new JMenu(); + optionsMenu.setName("optionsMenu"); + + optionsMenu.add(new JLabel("Format ")); + + DRBinary_item = new JRadioButtonMenuItem(); optionsMenu.add(DRBinary_item); DRBinary_item.setAction(getAction("selectDRBinary")); - - DRAscii_item = new JRadioButtonMenuItem(); + + DRAscii_item = new JRadioButtonMenuItem(); optionsMenu.add(DRAscii_item); DRAscii_item.setAction(getAction("selectDRAscii")); - - DRHDF5_item = new JRadioButtonMenuItem(); + + DRHDF5_item = new JRadioButtonMenuItem(); optionsMenu.add(DRHDF5_item); DRHDF5_item.setAction(getAction("selectDRHDF5")); - + selectDRBinary(); // by default, DR_Binary optionsMenu.addSeparator(); - + optionsMenu.add(new JLabel("Freq")); - - DRAlways_item = new JRadioButtonMenuItem(); + + DRAlways_item = new JRadioButtonMenuItem(); optionsMenu.add(DRAlways_item); DRAlways_item.setAction(getAction("selectDRAlways")); - - DRChanges_item = new JRadioButtonMenuItem(); + + DRChanges_item = new JRadioButtonMenuItem(); optionsMenu.add(DRChanges_item); DRChanges_item.setAction(getAction("selectDRChanges")); - - DRStepChanges_item = new JRadioButtonMenuItem(); + + DRStepChanges_item = new JRadioButtonMenuItem(); optionsMenu.add(DRStepChanges_item); DRStepChanges_item.setAction(getAction("selectDRStepChanges")); - + selectDRAlways(); // by default, DR_Always - + optionsMenu.addSeparator(); - + singlePrecisionCheckBox = new JCheckBoxMenuItem(getAction("toggleSinglePrecision")); toggleSinglePrecision(); - + optionsMenu.add(singlePrecisionCheckBox); optionsMenu.addSeparator(); - + optionsMenu.add(new JXLabel("Buffering")); - DRBuffer_item = new JRadioButtonMenuItem(); + DRBuffer_item = new JRadioButtonMenuItem(); optionsMenu.add(DRBuffer_item); DRBuffer_item.setAction(getAction("selectDRBuffer")); - - DRNoBuffer_item = new JRadioButtonMenuItem(); + + DRNoBuffer_item = new JRadioButtonMenuItem(); optionsMenu.add(DRNoBuffer_item); DRNoBuffer_item.setAction(getAction("selectDRNoBuffer")); - - DRRingBuffer_item = new JRadioButtonMenuItem(); + + DRRingBuffer_item = new JRadioButtonMenuItem(); optionsMenu.add(DRRingBuffer_item); - DRRingBuffer_item.setAction(getAction("selectDRRingBuffer")); - - //DRThreadBuffer_item = new JRadioButtonMenuItem("selectDRThreadBuffer"); + DRRingBuffer_item.setAction(getAction("selectDRRingBuffer")); + + //DRThreadBuffer_item = new JRadioButtonMenuItem("selectDRThreadBuffer"); //optionsMenu.add(DRThreadBuffer_item); //DRThreadBuffer_item.setAction(getAction("selectDRThreadBuffer")); - + selectDRBuffer(); // by default, DR_Buffer - - return optionsMenu; + + return optionsMenu; } - + /** * Creates the tool bar for the application. - * + * * @return a {@link JToolBar} for the application. */ @Override protected JToolBar createToolBar() { + + JToolBar toolBar = new JToolBar(); + + // add buttons String[] toolbarActionNames = {"openDR", "saveDR"}; - JToolBar toolBar = new JToolBar(); for (String actionName : toolbarActionNames) { if (actionName.equals("---")) { toolBar.addSeparator(); } else { toolBar.add(createButton(actionName, false)); } - } - toolBar.addSeparator(); - toolBar.add(new JLabel("DR Name (NO SPACE): ")); + } + + nameFieldInit(); + cycleFieldInit(); + maxFileSizeFieldInit(); + sizeUnitsBoxInit(); + unlimitedSizeBoxInit(); + + toolBar.addSeparator(); + toolBar.add(new JLabel("DR Name (NO SPACE): ")); + toolBar.add(nameField); + toolBar.add(Box.createHorizontalStrut(10)); + toolBar.add(new JLabel("DR Cycle: ")); + toolBar.add(cycleField); + toolBar.addSeparator(); + toolBar.add(new JLabel(" Max File Size: ")); + toolBar.add(maxFileSizeField); + toolBar.add(sizeUnitsBox); + toolBar.addSeparator(); + toolBar.add(unlimitedSizeBox); + toolBar.setSize(toolBar.getPreferredSize()); + toolBar.addSeparator(); + + return toolBar; + } + + private void nameFieldInit() { nameField = new JTextField(15); nameField.setMinimumSize(nameField.getPreferredSize()); nameField.setPreferredSize(nameField.getPreferredSize()); - nameField.setMaximumSize(nameField.getPreferredSize()); - toolBar.add(nameField); - - toolBar.add(Box.createHorizontalStrut(10)); - - toolBar.add(new JLabel("DR Cycle: ")); - cycleField= new NumberTextField("0.1", 5); - cycleField.setMinimumSize(cycleField.getPreferredSize()); - toolBar.add(cycleField); - - return toolBar; + nameField.setMaximumSize(nameField.getPreferredSize()); } - + + private void cycleFieldInit() { + cycleField = new NumberTextField("0.1", 5); + cycleField.setMinimumSize(cycleField.getPreferredSize()); + } + + private void maxFileSizeFieldInit() { + maxFileSizeField = new NumberTextField("1", 10); + maxFileSizeField.setMinimumSize((maxFileSizeField.getPreferredSize())); + } + + private void sizeUnitsBoxInit() { + String[] units = {"B", "KiB", "MiB", "GiB"}; + sizeUnitsBox = new JComboBox<>(units); + sizeUnitsBox.setSelectedItem(sizeUnitsBox.getItemAt(3)); + } + + private void unlimitedSizeBoxInit() { + unlimitedSizeBox = new JCheckBox("Unlimited File Size", false); + unlimitedSizeBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + updateUnlimited(); + } + }); + } + /** * routine to read the Frequency from the opened file. - * + * * @param string String the string read in from the opened file. */ private void readFrequency(String string) { - if (string.indexOf("trick.DR_Always") != -1) { - selectDRAlways(); - } else if (string.indexOf("trick.DR_Changes") != -1) { - selectDRChanges(); - } else if (string.indexOf("trick.DR_Step_Changes") != -1) { - selectDRStepChanges(); - } else { - System.out.println("Frequency Type is not recognized, defaulting to DR_Always"); - selectDRAlways(); - } + if (string.contains("trick.DR_Always")) { + selectDRAlways(); + } else if (string.contains("trick.DR_Changes")) { + selectDRChanges(); + } else if (string.contains("trick.DR_Step_Changes")) { + selectDRStepChanges(); + } else { + System.out.println("Frequency Type is not recognized, defaulting to DR_Always"); + selectDRAlways(); + } } - + /** * routine to read the Buffering from the opened file. - * + * * @param string String the string read in from the opened file. */ private void readBuffering(String string) { - if (string.indexOf("trick.DR_Buffer") != -1) { - selectDRBuffer(); - } else if (string.indexOf("trick.DR_No_Buffer") != -1) { - selectDRNoBuffer(); - } else if (string.indexOf("trick.DR_Ring_Buffer") != -1) { - selectDRRingBuffer(); - } else if (string.indexOf("trick.DR_Thread_Buffer") != -1) { - selectDRThreadBuffer(); - } else { - System.out.println("Buffering Type is not recognized, defaulting to DR_Buffer"); - selectDRBuffer(); - } + if (string.contains("trick.DR_Buffer")) { + selectDRBuffer(); + } else if (string.contains("trick.DR_No_Buffer")) { + selectDRNoBuffer(); + } else if (string.contains("trick.DR_Ring_Buffer")) { + selectDRRingBuffer(); + } else if (string.contains("trick.DR_Thread_Buffer")) { + selectDRThreadBuffer(); + } else { + System.out.println("Buffering Type is not recognized, defaulting to DR_Buffer"); + selectDRBuffer(); + } } - + /** * routine to read the Format from the opened file. - * + * * @param string String the string read in from the opened file. */ private void readFormat(String string) { - if (string.indexOf("DRBinary") != -1) { - selectDRBinary(); - } else if (string.indexOf("DRAscii") != -1) { - selectDRAscii(); - } else if (string.indexOf("DRHDF5") != -1) { - selectDRHDF5(); - } else { - System.out.println("Format Type is not recognized, defaulting to DR_Binary"); - selectDRBinary(); - } + if (string.contains("DRBinary")) { + selectDRBinary(); + } else if (string.contains("DRAscii")) { + selectDRAscii(); + } else if (string.contains("DRHDF5")) { + selectDRHDF5(); + } else { + System.out.println("Format Type is not recognized, defaulting to DR_Binary"); + selectDRBinary(); + } } - + + /** + * routine to read the Max File Size from the opened file. + * + * @param subs String the string read in from the opened file. + */ + private void readFileSize(String subs) { + StringTokenizer st = new StringTokenizer(subs); + String quantity = st.nextToken("*").trim(); + maxFileSizeField.setText(quantity); + if (maxFileSizeField.getText().equals("0")) { + unlimitedSizeBox.setSelected(true); + updateUnlimited(); + } else { + unlimitedSizeBox.setSelected(false); + maxFileSizeField.setEnabled(true); + sizeUnitsBox.setEnabled(true); + } + if (st.hasMoreElements()) { + String shift = st.nextToken("*").trim(); + switch (shift) { + case "1024": + sizeUnitsBox.setSelectedItem("KiB"); + break; + case "1048576": + sizeUnitsBox.setSelectedItem("MiB"); + break; + case "1073741824": + sizeUnitsBox.setSelectedItem("GiB"); + break; + } + } else { + sizeUnitsBox.setSelectedItem("B"); + } + } + + /** + * helper method to update GUI after unlimited file size is checked. + */ + private static String previousFileSize; + private static int previousUnitIndex; + + private void updateUnlimited() { + if (unlimitedSizeBox.isSelected()) { + previousFileSize = maxFileSizeField.getText(); + previousUnitIndex = sizeUnitsBox.getSelectedIndex(); + maxFileSizeField.setText("0"); + maxFileSizeField.setEnabled(false); + sizeUnitsBox.setSelectedIndex(0); + sizeUnitsBox.setEnabled(false); + } else { + maxFileSizeField.setEnabled(true); + sizeUnitsBox.setEnabled(true); + maxFileSizeField.setText(previousFileSize); + sizeUnitsBox.setSelectedIndex(previousUnitIndex); + } + } + /** * routine to read the contents of the opened file - * + * * @param file File the name of the file to open. */ private void openFile(File file) { - try { - variables.clear(); - selectedVarList.removeAllData(); - BufferedReader reader = new BufferedReader(new FileReader(file)); - try { - for (String line = reader.readLine(); line != null; line = reader.readLine()) { - if (line.indexOf("append") != -1) { - String[] segment = line.split("\""); - readFormat(line); - nameField.setText(segment[1]); - } else if (line.indexOf("add_data_record_group") != -1) { - readBuffering(line); - } else if (line.indexOf("drg[DR_GROUP_ID]") != -1) { - int indx = line.indexOf("("); - int len = line.length(); - if (line.indexOf("set_freq") != -1) { - readFrequency(line); - } else if (line.indexOf("enable") != -1) { - ; - } else if (line.indexOf("set_cycle") != -1) { - cycleField.setText(line.substring(indx+1,len-1)); - } else if (line.indexOf("add_variable") != -1) { - selectedVarList.addData(line.substring(indx+2,len-2)); - variables.add(line.substring(indx+2,len-2)); - } else if (line.indexOf("set_single_prec_only") != -1) { - if (line.substring(indx+1,len-1).equals("True")) { - singlePrecisionCheckBox.setState(true); - } else { - singlePrecisionCheckBox.setState(false); - } - - } - } - } - } - finally { - if (reader != null) { - reader.close(); - } - } - } - catch (Exception e) { - JOptionPane.showMessageDialog(getMainFrame(), e.toString(), "Error Reading File", JOptionPane.ERROR_MESSAGE); - } + try { + variables.clear(); + selectedVarList.removeAllData(); + BufferedReader reader = new BufferedReader(new FileReader(file)); + try { + for (String line = reader.readLine(); line != null; line = reader.readLine()) { + if (line.contains("append")) { + String[] segment = line.split("\""); + readFormat(line); + nameField.setText(segment[1]); + } else if (line.contains("add_data_record_group")) { + readBuffering(line); + } else if (line.contains("drg[DR_GROUP_ID]")) { + int indx = line.indexOf("("); + int len = line.length(); + if (line.contains("set_freq")) { + readFrequency(line); + } else if (line.contains("enable")) { + ; + } else if (line.contains("set_cycle")) { + cycleField.setText(line.substring(indx + 1, len - 1)); + } else if (line.contains("add_variable")) { + selectedVarList.addData(line.substring(indx + 2, len - 2)); + variables.add(line.substring(indx + 2, len - 2)); + } else if (line.contains("set_single_prec_only")) { + if (line.substring(indx + 1, len - 1).equals("True")) { + singlePrecisionCheckBox.setState(true); + } else { + singlePrecisionCheckBox.setState(false); + } + + } else if (line.contains("set_max_file_size")) { + readFileSize(line.substring(line.indexOf("(") + 1, line.indexOf(")"))); + } + } + } + } finally { + reader.close(); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(getMainFrame(), e.toString(), "Error Reading File", JOptionPane.ERROR_MESSAGE); + } } - + /** * routine to write the saved options for data recording to a file. - * + * * @param file File the name of the file to save */ private void saveFile(File file) { - try { - BufferedWriter writer = new BufferedWriter(new FileWriter(file)); - try { - writer.write("global DR_GROUP_ID\n"); - writer.write("global drg\n"); - writer.write("try:\n"); - writer.write(" if DR_GROUP_ID >= 0:\n"); - writer.write(" DR_GROUP_ID += 1\n"); - writer.write("except NameError:\n"); - writer.write(" DR_GROUP_ID = 0\n" + - " drg = []\n\n"); - writer.write("drg.append(trick." + format + "(\"" + nameField.getText().trim() + "\"))\n"); - writer.write("drg[DR_GROUP_ID].set_freq(trick." + frequency + ")\n"); - writer.write("drg[DR_GROUP_ID].set_cycle(" + cycleField.getText() + ")\n"); - writer.write("drg[DR_GROUP_ID].set_single_prec_only(" + single_prec_only + ")\n"); + try { + BufferedWriter writer = new BufferedWriter(new FileWriter(file)); + try { + writer.write("global DR_GROUP_ID\n"); + writer.write("global drg\n"); + writer.write("try:\n"); + writer.write(" if DR_GROUP_ID >= 0:\n"); + writer.write(" DR_GROUP_ID += 1\n"); + writer.write("except NameError:\n"); + writer.write(" DR_GROUP_ID = 0\n" + + " drg = []\n\n"); + writer.write("drg.append(trick." + format + "(\"" + nameField.getText().trim() + "\"))\n"); + writer.write("drg[DR_GROUP_ID].set_freq(trick." + frequency + ")\n"); + writer.write("drg[DR_GROUP_ID].set_cycle(" + cycleField.getText() + ")\n"); + writer.write("drg[DR_GROUP_ID].set_single_prec_only(" + single_prec_only + ")\n"); + + for (String variable : variables) { + writer.write("drg[DR_GROUP_ID].add_variable(\"" + variable + "\")\n"); + } + writer.write("drg[DR_GROUP_ID].set_max_file_size(" + maxFileSizeField.getText().trim() + getMultiplier((String) sizeUnitsBox.getSelectedItem())); + writer.write("trick.add_data_record_group(drg[DR_GROUP_ID], trick." + buffering + ")\n"); + writer.write("drg[DR_GROUP_ID].enable()\n"); + } finally { + writer.close(); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(getMainFrame(), e.toString(), + "Error Saving File", JOptionPane.ERROR_MESSAGE); + } + } + + + /** + * helper method to convert ComboBox index to a multiplier for filesize units + */ + private String getMultiplier(String unit) { + String multiplier = null; + switch (unit) { + case "B": + multiplier = ")\n"; + break; + case "KiB": + multiplier = " * 1024) # multiply converts KiB to B --Dr. Dre\n"; + break; + case "MiB": + multiplier = " * 1048576) # multiply converts MiB to B --Dr. Dre\n"; + break; + case "GiB": + multiplier = " * 1073741824) # multiply converts GiB to B --Dr. Dre\n"; + break; + } + return multiplier; + } - for (int i = 0; i < variables.size(); i++) { - writer.write("drg[DR_GROUP_ID].add_variable(\"" + variables.get(i) + "\")\n"); - } - writer.write("trick.add_data_record_group(drg[DR_GROUP_ID], trick." + buffering + ")\n"); - writer.write("drg[DR_GROUP_ID].enable()\n"); - } - finally { - if (writer != null) { - writer.close(); - } - } - } - catch (Exception e) { - JOptionPane.showMessageDialog(getMainFrame(), e.toString(), - "Error Saving File", JOptionPane.ERROR_MESSAGE); - } - } - /** * routine to add the subscripts to the variable name being created - * + * * @param index int the size of the segments array. */ private void addSubscript(int index) { if (nameSegment.get(index).dimensions.size() != 0) { - for (int j=0; j dimensions = new Vector(); } - + /** * Using an inner class to define MouseListener to help organize code better. * The goal of this class is to handle mouse calls and forward them * to the interested parties. */ private class TreeMouseListener extends MouseAdapter { - - + + //======================================== // MouseListener methods //======================================== + /** * Invoked when the mouse button has been clicked (pressed * and released) on a component. @@ -779,60 +900,59 @@ public class DreApplication extends TrickApplication { * @param e MouseEvent sent from system. */ @Override - public void mouseClicked(MouseEvent e) - { - SieTemplate clickedNode = null; - if (UIUtils.isDoubleClick(e) || UIUtils.isRightMouseClick(e)) { - TreePath clickedPath = varTree.getClosestPathForLocation(e.getX(), e.getY()); - - clickedNode = (SieTemplate)clickedPath.getLastPathComponent(); - + public void mouseClicked(MouseEvent e) { + SieTemplate clickedNode = null; + if (UIUtils.isDoubleClick(e) || UIUtils.isRightMouseClick(e)) { + TreePath clickedPath = varTree.getClosestPathForLocation(e.getX(), e.getY()); + + clickedNode = (SieTemplate) clickedPath.getLastPathComponent(); + if (UIUtils.isRightMouseClick(e)) { - if (clickedNode != null && clickedNode.isTrickManaged()) { + if (clickedNode != null && clickedNode.isTrickManaged()) { if (treePopup.getComponentCount() > 0) { treePopup.removeAll(); } - + JMenuItem firstItem = new JMenuItem(SieTreeModel.getPathName(clickedPath) + clickedNode); - if (clickedNode != null && varTree.getModel().isLeaf(clickedNode) && clickedNode.isTrickManaged()) { - firstItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - addVariable(e.getActionCommand()); - } - }); - treePopup.add(firstItem); - } else { - treePopup.add(new JLabel(" " + SieTreeModel.getPathName(clickedPath) + clickedNode)); - } - - treePopup.addSeparator(); - - if (clickedNode.enumeration != null) { - JMenu subMenu = new JMenu("Type: " + clickedNode.typeName); - for (final Object eachLabel : clickedNode.enumeration.pairs.keySet()) { - subMenu.add((String)eachLabel); - } - treePopup.add(subMenu); - } else { - treePopup.add("Type: " + clickedNode.typeName); + if (varTree.getModel().isLeaf(clickedNode) && clickedNode.isTrickManaged()) { + firstItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + addVariable(e.getActionCommand()); + } + }); + treePopup.add(firstItem); + } else { + treePopup.add(new JLabel(" " + SieTreeModel.getPathName(clickedPath) + clickedNode)); + } + + treePopup.addSeparator(); + + if (clickedNode.enumeration != null) { + JMenu subMenu = new JMenu("Type: " + clickedNode.typeName); + for (final Object eachLabel : clickedNode.enumeration.pairs.keySet()) { + subMenu.add((String) eachLabel); } - treePopup.add("Units: " + clickedNode.units); - - if (!treePopup.isVisible()) { + treePopup.add(subMenu); + } else { + treePopup.add("Type: " + clickedNode.typeName); + } + treePopup.add("Units: " + clickedNode.units); + + if (!treePopup.isVisible()) { treePopup.show(e.getComponent(), e.getX(), e.getY()); - } - } - } else if (clickedNode != null && varTree.getModel().isLeaf(clickedNode) && clickedNode.isTrickManaged()) { - addVariable(SieTreeModel.getPathName(clickedPath) + clickedNode); + } + } + } else if (clickedNode != null && varTree.getModel().isLeaf(clickedNode) && clickedNode.isTrickManaged()) { + addVariable(SieTreeModel.getPathName(clickedPath) + clickedNode); } - } - - if (!UIUtils.isRightMouseClick(e)) { - if (treePopup.isVisible()) { + } + + if (!UIUtils.isRightMouseClick(e)) { + if (treePopup.isVisible()) { treePopup.setVisible(false); } - } - } + } + } } - - } + +} diff --git a/trick_source/java/src/trick/mtv/MtvView.java b/trick_source/java/src/trick/mtv/MtvView.java index 3b152bc7..6221f2f1 100644 --- a/trick_source/java/src/trick/mtv/MtvView.java +++ b/trick_source/java/src/trick/mtv/MtvView.java @@ -1202,7 +1202,7 @@ public class MtvView extends FrameView { comboBox.addItem("Manual OFF"); mode_selected = false; - event_table_rows = new Vector(); + event_table_rows = new Vector(); event_table_cols = new Vector(); String[] col_names = {"Active", "Name", "Fired Time", "Fired Count", "Ran Time", "Ran Count", "Hold", "Mode", "Added"}; for (int ii=0; ii(); + edit_table_rows = new Vector(); edit_table_cols = new Vector(); user_text = new JTextArea(); String[] col_names2 = {"Event Syntax", "", "User Data", ""}; @@ -1944,13 +1944,13 @@ public class MtvView extends FrameView { private javax.swing.JTable edit_table; private javax.swing.table.DefaultTableModel model; private JTextArea user_text; - public Vector edit_table_rows; + public Vector edit_table_rows; private Vector edit_table_cols; private javax.swing.JTextField eventTextField; public ButtonGroup cycle_group; public javax.swing.JComboBox comboBox; // Mode public javax.swing.JTable event_table; - public Vector event_table_rows; + public Vector event_table_rows; public Vector event_table_cols; public boolean mode_selected; // user clicked a row's Mode combobox public javax.swing.JTextField host_field; diff --git a/trick_source/java/src/trick/simcontrol/SimControlApplication.java b/trick_source/java/src/trick/simcontrol/SimControlApplication.java index 7c6d059e..525e0c64 100644 --- a/trick_source/java/src/trick/simcontrol/SimControlApplication.java +++ b/trick_source/java/src/trick/simcontrol/SimControlApplication.java @@ -487,7 +487,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC for (int i = 0; i < simRunDirField.length; i++) { if (i==0) { - simRunDirField[i] = new JTextField(results[4] + System.getProperty("file.separator") + results[5] + " " + results[6]); + simRunDirField[i] = new JTextField(results[4] + java.io.File.separator + results[5] + " " + results[6]); } else { simRunDirField[i] = new JTextField(); } @@ -495,7 +495,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC overrunField[i].setPreferredSize( new Dimension(60, overrunField[i].getHeight()) ); } simRunDir = results[7]; - simRunDir = results[4] + System.getProperty("file.separator") + simRunDir; + simRunDir = results[4] + java.io.File.separator + simRunDir; simState.setRunPath(simRunDir); @@ -510,7 +510,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC "trick.sim_serives.var_send( ) \n" + "trick.sim_services.var_clear( ) \n"); results = commandSimcom.get().split("\t"); - simRunDirField[i].setText(results[1] + System.getProperty("file.separator") + results[2] + " " + results[2]);*/ + simRunDirField[i].setText(results[1] + java.io.File.separator + results[2] + " " + results[2]);*/ simRunDirField[i].setText("Slave " + i); } @@ -736,7 +736,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC */ private void printSendHS() { if (simState != null) { - File sendHS = new File(simState.getRunPath() + System.getProperty("file.separator") + "send_hs"); + File sendHS = new File(simState.getRunPath() + java.io.File.separator + "send_hs"); if (!sendHS.exists()) { return; } diff --git a/trick_source/java/test/Makefile b/trick_source/java/test/Makefile new file mode 100644 index 00000000..cce524e7 --- /dev/null +++ b/trick_source/java/test/Makefile @@ -0,0 +1,87 @@ +# To run new unit tests, add new tests to the "test" target + +TRICK_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../../..) + +# Get JAVAC definition +include ${TRICK_HOME}/share/trick/makefiles/Makefile.common + +JAVAC ?= javac +JAVAC_FLAGS = -g -Xlint:unchecked -Xlint:deprecation +# delineate 'javac -version' for version number +JAVAC_VERSION := $(shell ${JAVAC} -version 2>&1 | perl -ne 'print /(\d+)/') + +# include java.se.ee for JAXB xml annotations (for trick-tv) in java version 9 +ifeq ($(JAVAC_VERSION),9) + JAVAC_FLAGS += --add-modules java.se.ee +endif +ifeq ($(JAVAC_VERSION),10) + JAVAC_FLAGS += --add-modules java.se.ee +endif + +SRC_DIR = src +SRC_FILES = $(shell find ${SRC_DIR} -type f -name \*.java) +BUILD_DIR = build +DEST_DIR = ${BUILD_DIR}/classes +LIB_DIR = ${TRICK_HOME}/$(LIBEXEC)/trick/java/lib +DIST_DIR = ${TRICK_HOME}/$(LIBEXEC)/trick/java/dist +TEST_DIR = ${TRICK_HOME}/$(LIBEXEC)/trick/java/test +TRICK_TEST = ${TRICK_HOME}/trick_test + +empty := +space := $(empty) $(empty) +CLASS_PATH = $(subst $(space),:,$(wildcard ${LIB_DIR}/*.jar):${DIST_DIR}/trick.jar) + +RESOURCES = $(subst src/,,$(shell find src/trick -name resources)) +RESOURCES += $(subst src/,,$(shell find src/trick -name jaxb.index)) + +all: test + @echo "Java test successful" +test: ${TEST_DIR}/test.jar ${TRICK_TEST} + @echo "trick.common.RunTimeTrickApplicationTest" + @java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_RunTimeTrickApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.common.RunTimeTrickApplicationTest + @echo "trick.common.TrickApplicationTest" + @java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_TrickApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.common.TrickApplicationTest + @echo "trick.common.utils.LogHeaderReaderTest" + @java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_LogHeaderReaderTest.xml barrypitman.junitXmlFormatter.Runner trick.common.utils.LogHeaderReaderTest + @# Error with UnitTypeTest + @# java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_UnitTypeTest.xml barrypitman.junitXmlFormatter.Runner trick.common.utils.UnitTypeTest + @echo "trick.dataproducts.trickdp.TrickDPApplicationTest" + @java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_TrickDPApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.dataproducts.trickdp.TrickDPApplicationTest + @echo "trick.dataproducts.trickqp.TrickQPApplicationTest" + @java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_TrickQPApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.dataproducts.trickqp.TrickQPApplicationTest + @echo "trick.dre.DreApplicationTest" + @java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_DreApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.dre.DreApplicationTest + @echo "trick.montemonitor.MonteMonitorApplicationTest" + @java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_MonteMonitorApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.montemonitor.MonteMonitorApplicationTest + @echo "trick.mtv.MtvApplicationTest" + @java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_MtvApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.mtv.MtvApplicationTest + @# SieApplicationTest needs to be updated + @# java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_SieApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.sie.SieApplicationTest + @echo "trick.sniffer.SnifferApplicationTest" + @java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_SnifferApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.sniffer.SnifferApplicationTest + @echo "trick.tv.TrickApplicationTest" + @java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_TVApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.tv.TVApplicationTest + @echo "trick.simcontrol.SimControlApplicationTest" + @echo "CLICK OK ON GUI TO CONTINUE" + @java -cp "${LIB_DIR}/*:${DIST_DIR}/*:${TEST_DIR}/*" -Dorg.schmant.task.junit4.target=${TRICK_HOME}/trick_test/Java_SimControlApplicationTest.xml barrypitman.junitXmlFormatter.Runner trick.simcontrol.SimControlApplicationTest + +${DEST_DIR} ${TEST_DIR} ${TRICK_TEST}: + mkdir -p $@ + +${TEST_DIR}/test.jar: compile ${TEST_DIR} + @echo "Creating jar file..." + @jar cf ${TEST_DIR}/test.jar -C ${DEST_DIR} . + +trick_guis: + @ $(MAKE) -C .. + +compile: ${DEST_DIR} trick_guis + @echo "Building Trick GUI tests .." + @${JAVAC} ${JAVAC_FLAGS} -classpath ${CLASS_PATH} -d ${DEST_DIR} -sourcepath ${SRC_DIR} ${SRC_FILES} + +clean: + rm -rf ${BUILD_DIR} + rm -rf ${TEST_DIR} + +clean_obj: + rm -rf ${BUILD_DIR} diff --git a/trick_source/java/test/src/trick/common/TrickApplicationTest.java b/trick_source/java/test/src/trick/common/TrickApplicationTest.java index 47983ab9..bb9f7e61 100644 --- a/trick_source/java/test/src/trick/common/TrickApplicationTest.java +++ b/trick_source/java/test/src/trick/common/TrickApplicationTest.java @@ -43,8 +43,8 @@ public class TrickApplicationTest { public void testPropertyLocation() { application(); application(); - boolean rightLocation = (TrickApplication.propDirectory.equals(System.getenv("HOME") + System.getProperty("file.separator") + ".trick")) - || (TrickApplication.propDirectory.equals(System.getenv("TRICK_USER_HOME") + System.getProperty("file.separator") + ".trick")); + boolean rightLocation = (TrickApplication.propDirectory.equals(System.getenv("HOME") + java.io.File.separator + ".trick")) + || (TrickApplication.propDirectory.equals(System.getenv("TRICK_USER_HOME") + java.io.File.separator + ".trick")); assertTrue("The default property location is not at ../.trick!", rightLocation); } diff --git a/trick_source/java/test/src/trick/common/utils/LogHeaderReaderTest.java b/trick_source/java/test/src/trick/common/utils/LogHeaderReaderTest.java index 5de6ddd4..e7b41ecc 100644 --- a/trick_source/java/test/src/trick/common/utils/LogHeaderReaderTest.java +++ b/trick_source/java/test/src/trick/common/utils/LogHeaderReaderTest.java @@ -33,7 +33,7 @@ public class LogHeaderReaderTest { @Test(expected = FileNotFoundException.class) public void testGetContentsWithNotFoundFile() throws FileNotFoundException, IOException { - DataReader reader = new LogHeaderReader("test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "unknowFile.header"); + DataReader reader = new LogHeaderReader("resources" + java.io.File.separator + "unknowFile.header"); reader.processHeader(); } @@ -61,15 +61,15 @@ public class LogHeaderReaderTest { expectedVarList[8].setUnits("N"); // ASCII - DataReader reader = new LogHeaderReader("test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "log_Ball.header"); + DataReader reader = new LogHeaderReader("resources" + java.io.File.separator + "log_Ball.header"); assertArrayEquals("Error in getContents for ASCII in DataReader.java", expectedVarList, reader.getRecordedVarList().toArray()); // HDF5 - reader = new LogHeaderReader("test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "log_Ball2.header"); + reader = new LogHeaderReader("resources" + java.io.File.separator + "log_Ball2.header"); assertArrayEquals("Error in getContents for HDF5 in DataReader.java", expectedVarList, reader.getRecordedVarList().toArray()); // little_endian - reader = new LogHeaderReader("test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "log_Ball3.header"); + reader = new LogHeaderReader("resources" + java.io.File.separator + "log_Ball3.header"); assertArrayEquals("Error in getContents for little_endian in DataReader.java", expectedVarList, reader.getRecordedVarList().toArray()); } diff --git a/trick_source/java/test/src/trick/dre/WaitForDreApplication.java b/trick_source/java/test/src/trick/dre/WaitForDreApplication.java index bb007657..f501f018 100644 --- a/trick_source/java/test/src/trick/dre/WaitForDreApplication.java +++ b/trick_source/java/test/src/trick/dre/WaitForDreApplication.java @@ -29,7 +29,7 @@ public class WaitForDreApplication extends DreApplication { */ public static void launchAndWait(Class applicationClass) { synchronized(lock) { - sieResourcePath = "test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "S_sie.resource"; + sieResourcePath ="resources" + java.io.File.separator + "S_sie.resource"; Application.launch(applicationClass, new String[]{}); while(true) { try { diff --git a/trick_source/java/test/src/trick/sie/WaitForSieApplication.java b/trick_source/java/test/src/trick/sie/WaitForSieApplication.java index dc1309c3..87799b16 100644 --- a/trick_source/java/test/src/trick/sie/WaitForSieApplication.java +++ b/trick_source/java/test/src/trick/sie/WaitForSieApplication.java @@ -29,7 +29,7 @@ public class WaitForSieApplication extends SieApplication { */ public static void launchAndWait(Class applicationClass) { synchronized(lock) { - sieResourcePath = "test" + System.getProperty("file.separator") + "resources" + System.getProperty("file.separator") + "S_sie.resource"; + sieResourcePath = "resources" + java.io.File.separator + "S_sie.resource"; Application.launch(applicationClass, new String[]{}); while(true) { try { diff --git a/trick_source/java/test/src/trick/stripchart/StripchartApplicationTest.java b/trick_source/java/test/src/trick/stripchart/StripchartApplicationTest.java deleted file mode 100644 index e793ddbe..00000000 --- a/trick_source/java/test/src/trick/stripchart/StripchartApplicationTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package trick.stripchart; - -import static org.junit.Assert.assertTrue; - -import org.jdesktop.application.Application; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import trick.common.CheckApplicationProperties; - -/** - * - * Test StripchartApplication life cycle. - * - * @author hchen - * - */ -public class StripchartApplicationTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - WaitForStripchartApplication.launchAndWait(WaitForStripchartApplication.class); - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testReady() { - assertTrue("StripchartApplicationTest is not ready yet!", application().isReady()); - } - - /** - * Verify that all implemented actions exist as well as their text, shortDescription properties. - */ - @Test - public void testDefinedActions() { - String[] actionNames = {"toggle_xrange", "start_stop", "legend_onoff", "postscript"}; - String[] actionTexts = {"Toggle Range", "Toggle Start/Stop", "Legend On/Off", "Postscript..."}; - String[] actionShortDescriptions = {"Set x-axis range to automatic scaling (All), or fixed-width (Strip).", - "Start/Stop graph refreshing.", - "Hide/Display the graph's Legend.", - "Save a copy of the graph to postscript file."}; - for (int i = 0; i < actionNames.length; i++) { - CheckApplicationProperties.checkAction(application().actionMap, actionNames[i]); - CheckApplicationProperties.checkActionText(application().actionMap, actionNames[i], actionTexts[i]); - CheckApplicationProperties.checkActionShortDescription(application().actionMap, actionNames[i], actionShortDescriptions[i]); - } - } - - @Test - public void testDefinedKeyText() { - CheckApplicationProperties.checkKeyText(application().resourceMap, "fileMenu.text", "&File"); - CheckApplicationProperties.checkKeyText(application().resourceMap, "settingsMenu.text", "&Settings"); - } - - @Test - public void testExit() { - application().removeExitListener(application().exitListener); - application().exit(); - assertTrue(application().isEnded); - } - - private static WaitForStripchartApplication application() { - return Application.getInstance(WaitForStripchartApplication.class); - } -} diff --git a/trick_source/java/test/src/trick/stripchart/WaitForStripchartApplication.java b/trick_source/java/test/src/trick/stripchart/WaitForStripchartApplication.java deleted file mode 100644 index eb93845d..00000000 --- a/trick_source/java/test/src/trick/stripchart/WaitForStripchartApplication.java +++ /dev/null @@ -1,57 +0,0 @@ -package trick.stripchart; - - -import org.jdesktop.application.Application; - - -public class WaitForStripchartApplication extends StripchartApplication { - static Object lock = new Object(); - - boolean isEnded; - - @Override - protected void end() { - isEnded = true; - } - - @Override - protected void ready() { - super.ready(); - synchronized(lock) { - lock.notifyAll(); - } - } - - - /** - * Launch the specified subclsas of StripchartApplication and block - * (wait) until it's startup() method has run. - */ - public static void launchAndWait(Class applicationClass) { - synchronized(lock) { - String[] args = new String[] {"-demo"}; - try { - Application.launch(applicationClass, args); - } catch (Exception e) { - lock.notifyAll(); - return; - } - - while(true) { - try { - lock.wait(); - } - catch (InterruptedException e) { - System.err.println("launchAndWait interrupted!"); - break; - } - Application app = Application.getInstance(WaitForStripchartApplication.class); - if (app instanceof WaitForStripchartApplication) { - if (((WaitForStripchartApplication)app).isReady()) { - break; - } - } - } - } - } -} diff --git a/trick_source/sim_services/CheckPointAgent/input_parser.y b/trick_source/sim_services/CheckPointAgent/input_parser.y index d781c354..c69addaf 100644 --- a/trick_source/sim_services/CheckPointAgent/input_parser.y +++ b/trick_source/sim_services/CheckPointAgent/input_parser.y @@ -452,9 +452,9 @@ param: NAME { $$.num_index_left--; } - /* Check to see if previous parameter specified enough dimensions. */ - if ($$.num_index != $$.attr->num_index) { - message_publish(MSG_ERROR, "Checkpoint Agent - input_parser ERROR.\n"); + /* Check to see if previous parameter specified too many dimensions. */ + if ($$.num_index > $$.attr->num_index) { + message_publish(MSG_ERROR, "Checkpoint Agent ERROR. Invalid Reference: \"%s->%s\".\n", $$.reference, $3); $$.ref_type = REF_INVALID; } diff --git a/trick_source/sim_services/Clock/test/BC635Clock_test.cpp b/trick_source/sim_services/Clock/test/BC635Clock_test.cpp index aa8e13de..fdadbed4 100644 --- a/trick_source/sim_services/Clock/test/BC635Clock_test.cpp +++ b/trick_source/sim_services/Clock/test/BC635Clock_test.cpp @@ -22,7 +22,7 @@ #include "trick/JobData.hh" // Stub for message_publish -extern "C" int message_publish(int level, const char * format_msg, ...) { return 0; } +extern "C" int message_publish(int level, const char * format_msg, ...) { (void)level; (void)format_msg; return 0; } class BC635ClockTest : public ::testing::Test { diff --git a/trick_source/sim_services/Clock/test/GetTimeOfDayClock_test.cpp b/trick_source/sim_services/Clock/test/GetTimeOfDayClock_test.cpp index 190fb1e8..b73cfbae 100644 --- a/trick_source/sim_services/Clock/test/GetTimeOfDayClock_test.cpp +++ b/trick_source/sim_services/Clock/test/GetTimeOfDayClock_test.cpp @@ -17,7 +17,7 @@ #define TICS_PER_SEC 1000000 // Stub for message_publish -extern "C" int message_publish(int level, const char * format_msg, ...) { return 0; } +extern "C" int message_publish(int level, const char * format_msg, ...) { (void)level; (void)format_msg; return 0; } class GetTimeOfDayClockTest : public ::testing::Test { diff --git a/trick_source/sim_services/Clock/test/TPROCTEClock_test.cpp b/trick_source/sim_services/Clock/test/TPROCTEClock_test.cpp index 0f6f5d75..76c19992 100644 --- a/trick_source/sim_services/Clock/test/TPROCTEClock_test.cpp +++ b/trick_source/sim_services/Clock/test/TPROCTEClock_test.cpp @@ -26,7 +26,7 @@ // Stub for message_publish -extern "C" int message_publish(int level, const char * format_msg, ...) { return 0; } +extern "C" int message_publish(int level, const char * format_msg, ...) { (void)level; (void)format_msg; return 0; } class TPROCTEClockTest : public ::testing::Test { diff --git a/trick_source/sim_services/CommandLineArguments/CommandLineArguments.cpp b/trick_source/sim_services/CommandLineArguments/CommandLineArguments.cpp index 053884c6..ac94142d 100644 --- a/trick_source/sim_services/CommandLineArguments/CommandLineArguments.cpp +++ b/trick_source/sim_services/CommandLineArguments/CommandLineArguments.cpp @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "trick/CommandLineArguments.hh" #include "trick/memorymanager_c_intf.h" @@ -163,13 +165,18 @@ int Trick::CommandLineArguments::process_sim_args(int nargs , char **args) { } else { run_dir = "." ; } + /* check existence of run directory */ + if (access(run_dir.c_str(), F_OK) != 0) { + std::cerr << "\nERROR: while accessing input file directory \"" << run_dir << "\" : " << std::strerror(errno) << std::endl ; + exit(1); + } output_dir = run_dir ; for (ii = 2; ii < argc; ii++) { if (!strncmp("-OO", argv[ii], (size_t) 3) || !strncmp("-O", argv[ii], (size_t) 2)) { if (ii == ( argc - 1 )) { - std::cerr << "\nERROR: No directory specified after -O or -OO argument. Exiting!" << std::endl ; + std::cerr << "\nERROR: No directory specified after -O or -OO argument" << std::endl ; exit(1) ; } /* Output data directory */ @@ -182,13 +189,13 @@ int Trick::CommandLineArguments::process_sim_args(int nargs , char **args) { /* Create output directory if necessary. */ if (access(output_dir.c_str(), F_OK) != 0) { if (mkdir(output_dir.c_str(), 0775) == -1) { - std::cerr << "\nERROR: While trying to create dir \"" << output_dir << "\" Exiting!" << std::endl ; + std::cerr << "\nERROR: While trying to create output directory \"" << output_dir << "\" : " << std::strerror(errno) << std::endl ; exit(1) ; } } else { /* check permissions on output directory */ if (access(output_dir.c_str(), (W_OK|X_OK) ) == -1) { - std::cerr << "\nERROR: Unable to write to \"" << output_dir << "\" Exiting!" << std::endl ; + std::cerr << "\nERROR: while writing to output directory \"" << output_dir << "\" : " << std::strerror(errno) << std::endl ; exit(2) ; } } diff --git a/trick_source/sim_services/DataRecord/DRAscii.cpp b/trick_source/sim_services/DataRecord/DRAscii.cpp index 1a28cf58..6635c6f6 100644 --- a/trick_source/sim_services/DataRecord/DRAscii.cpp +++ b/trick_source/sim_services/DataRecord/DRAscii.cpp @@ -1,4 +1,4 @@ - + /* PURPOSE: (Data record in ascii format.) @@ -46,6 +46,7 @@ int Trick::DRAscii::format_specific_header( std::fstream & out_st ) { int Trick::DRAscii::format_specific_init() { unsigned int jj ; + std::streampos before_write; /* Store log information in csv/txt file */ if ( ! delimiter.empty() && delimiter.compare(",") != 0 ) { @@ -70,7 +71,7 @@ int Trick::DRAscii::format_specific_init() { record = false ; return -1 ; } - + before_write = out_stream.tellp(); // Write out the title line of the recording file /* Start with the 1st item in the buffer which should be "sys.exec.out.time" */ out_stream << rec_buffer[0]->ref->reference ; @@ -81,6 +82,7 @@ int Trick::DRAscii::format_specific_init() { out_stream << " {" << rec_buffer[0]->ref->attr->units << "}" ; } } + /* Write out specified recorded parameters */ for (jj = 1; jj < rec_buffer.size() ; jj++) { out_stream << delimiter << rec_buffer[jj]->ref->reference ; @@ -94,7 +96,7 @@ int Trick::DRAscii::format_specific_init() { } } out_stream << std::endl ; - + total_bytes_written += out_stream.tellp() - before_write; return(0) ; } @@ -105,6 +107,7 @@ int Trick::DRAscii::format_specific_init() { -# Write out each of the other parameter values preceded by the delimiter to the temporary #writer_buff -# Write #writer_buff to the output file -# Flush the output file stream +-# Return the number of bytes written */ int Trick::DRAscii::format_specific_write_data(unsigned int writer_offset) { unsigned int ii ; @@ -128,8 +131,8 @@ int Trick::DRAscii::format_specific_write_data(unsigned int writer_offset) { /*! Flush the output */ out_stream.flush() ; - - return(0) ; + /*! +1 for endl */ + return(strlen(writer_buff) + 1) ; } /** diff --git a/trick_source/sim_services/DataRecord/DRBinary.cpp b/trick_source/sim_services/DataRecord/DRBinary.cpp index f42af3f4..eaa8f314 100644 --- a/trick_source/sim_services/DataRecord/DRBinary.cpp +++ b/trick_source/sim_services/DataRecord/DRBinary.cpp @@ -53,6 +53,8 @@ int Trick::DRBinary::format_specific_init() { unsigned int jj ; int write_value ; + /* number of bytes written to data record */ + int bytes = 0 ; union { long l; @@ -72,45 +74,48 @@ int Trick::DRBinary::format_specific_init() { writer_buff[record_size * rec_buffer.size() - 1] = 1 ; /* start header information in trk file */ - if ((fp = creat(file_name.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1) { + if ((fd = creat(file_name.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1) { record = false ; return (-1) ; } + + /* Check to see if data is being recorded in little endian * byte order, and add little endian line if so. */ byte_order_union.l = 1 ; if (byte_order_union.c[sizeof(long)-1] != 1) { - write( fp , "Trick-10-L", (size_t)10 ) ; + bytes += write( fd , "Trick-10-L", (size_t)10 ) ; + } else { - write( fp , "Trick-10-B", (size_t)10 ) ; + bytes += write( fd , "Trick-10-B", (size_t)10 ) ; } write_value = rec_buffer.size() ; - write( fp , &write_value , sizeof(int) ) ; + bytes += write( fd , &write_value , sizeof(int) ) ; for (jj = 0; jj < rec_buffer.size(); jj++) { /* name */ write_value = strlen(rec_buffer[jj]->ref->reference) ; - write( fp , &write_value , sizeof(int)) ; - write( fp , rec_buffer[jj]->ref->reference , write_value ) ; + bytes += write( fd , &write_value , sizeof(int)) ; + bytes += write( fd , rec_buffer[jj]->ref->reference , write_value ) ; /* units */ if ( rec_buffer[jj]->ref->attr->mods & TRICK_MODS_UNITSDASHDASH ) { write_value = strlen("--") ; - write( fp , &write_value , sizeof(int)) ; - write( fp , "--" , write_value ) ; + bytes += write( fd , &write_value , sizeof(int)) ; + bytes += write( fd , "--" , write_value ) ; } else { write_value = strlen(rec_buffer[jj]->ref->attr->units) ; - write( fp , &write_value , sizeof(int)) ; - write( fp , rec_buffer[jj]->ref->attr->units , write_value ) ; + bytes += write( fd , &write_value , sizeof(int)) ; + bytes += write( fd , rec_buffer[jj]->ref->attr->units , write_value ) ; } write_value = rec_buffer[jj]->ref->attr->type ; - write( fp , &write_value , sizeof(int)) ; + bytes += write( fd , &write_value , sizeof(int)) ; - write( fp , &rec_buffer[jj]->ref->attr->size , sizeof(int)) ; + bytes += write( fd , &rec_buffer[jj]->ref->attr->size , sizeof(int)) ; } - + total_bytes_written += bytes; return(0) ; } @@ -119,6 +124,7 @@ int Trick::DRBinary::format_specific_init() { -# While there is data in memory that has not been written to disk -# Write out each of the other parameter values to the temporary #writer_buff -# Write #writer_buff to the output file +-# return the number of bytes written */ int Trick::DRBinary::format_specific_write_data(unsigned int writer_offset) { @@ -171,9 +177,7 @@ int Trick::DRBinary::format_specific_write_data(unsigned int writer_offset) { } - write( fp , writer_buff , len) ; - - return(0) ; + return write( fd , writer_buff , len) ; } /** @@ -183,8 +187,7 @@ int Trick::DRBinary::format_specific_write_data(unsigned int writer_offset) { int Trick::DRBinary::format_specific_shutdown() { if ( inited ) { - close(fp) ; + close(fd) ; } return(0) ; -} - +} \ No newline at end of file diff --git a/trick_source/sim_services/DataRecord/DRHDF5.cpp b/trick_source/sim_services/DataRecord/DRHDF5.cpp index ecf64254..8f70f196 100644 --- a/trick_source/sim_services/DataRecord/DRHDF5.cpp +++ b/trick_source/sim_services/DataRecord/DRHDF5.cpp @@ -270,10 +270,10 @@ int Trick::DRHDF5::write_data(bool must_write) { pthread_mutex_unlock(&buffer_mutex) ; } +#else + (void)must_write; #endif - return 0 ; - } /** diff --git a/trick_source/sim_services/DataRecord/DataRecordDispatcher.cpp b/trick_source/sim_services/DataRecord/DataRecordDispatcher.cpp index 5bb0838f..4e9f923f 100644 --- a/trick_source/sim_services/DataRecord/DataRecordDispatcher.cpp +++ b/trick_source/sim_services/DataRecord/DataRecordDispatcher.cpp @@ -313,6 +313,23 @@ int Trick::DataRecordDispatcher::record_now_group( const char * in_name ) { return 0 ; } +int Trick::DataRecordDispatcher::set_group_max_file_size(const char * in_name, uint64_t bytes){ + unsigned int ii ; + for ( ii = 0 ; ii < groups.size() ; ii++ ) { + if ( in_name == NULL or !groups[ii]->get_group_name().compare(in_name) ) + groups[ii]->set_max_file_size(bytes) ; + } + return 0 ; +} + +int Trick::DataRecordDispatcher::set_max_file_size(uint64_t bytes) { + unsigned int ii ; + for ( ii = 0 ; ii < groups.size() ; ii++ ) { + groups[ii]->set_max_file_size(bytes) ; + } + return 0 ; +} + /** @details -# Call every group's init job - only needed when restoring checkpoint @@ -325,3 +342,4 @@ int Trick::DataRecordDispatcher::init_groups() { } return 0 ; } + diff --git a/trick_source/sim_services/DataRecord/DataRecordGroup.cpp b/trick_source/sim_services/DataRecord/DataRecordGroup.cpp index 3b6e4b82..13118098 100644 --- a/trick_source/sim_services/DataRecord/DataRecordGroup.cpp +++ b/trick_source/sim_services/DataRecord/DataRecordGroup.cpp @@ -71,6 +71,8 @@ Trick::DataRecordGroup::DataRecordGroup( std::string in_name ) : max_num(100000), buffer_num(0), writer_num(0), + max_file_size(1<<30), // 1 GB + total_bytes_written(0), writer_buff(NULL), single_prec_only(false), buffer_type(DR_Buffer), @@ -193,6 +195,15 @@ int Trick::DataRecordGroup::set_buffer_type( int in_buffer_type ) { return(0) ; } +int Trick::DataRecordGroup::set_max_file_size( uint64_t bytes ) { + if(bytes == 0) { + max_file_size = UINT64_MAX ; + } else { + max_file_size = bytes ; + } + return(0) ; +} + int Trick::DataRecordGroup::set_single_prec_only( bool in_single_prec_only ) { single_prec_only = in_single_prec_only ; return(0) ; @@ -248,7 +259,7 @@ int Trick::DataRecordGroup::add_variable( std::string in_name , std::string alia } void Trick::DataRecordGroup::remove_variable( std::string in_name ) { - // Trim leading spaces + // Trim leading spaces++ in_name.erase( 0, in_name.find_first_not_of( " \t" ) ); // Trim trailing spaces in_name.erase( in_name.find_last_not_of( " \t" ) + 1); @@ -342,7 +353,7 @@ int Trick::DataRecordGroup::init() { int ret ; // reset counter here so we can "re-init" our recording - buffer_num = writer_num = 0 ; + buffer_num = writer_num = total_bytes_written = 0 ; output_dir = command_line_args_get_output_dir() ; /* this is the common part of the record file name, the format specific will add the correct suffix */ @@ -632,7 +643,7 @@ int Trick::DataRecordGroup::write_data(bool must_write) { unsigned int num_to_write ; unsigned int writer_offset ; - if ( record and inited and (buffer_type == DR_No_Buffer or must_write)) { + if ( record and inited and (buffer_type == DR_No_Buffer or must_write) and (total_bytes_written <= max_file_size)) { // buffer_mutex is used in this one place to prevent forced calls of write_data // to not overwrite data being written by the asynchronous thread. @@ -649,7 +660,8 @@ int Trick::DataRecordGroup::write_data(bool must_write) { while ( writer_num != local_buffer_num ) { writer_offset = writer_num % max_num ; - format_specific_write_data(writer_offset) ; + //! keep record of bytes written to file. Default max is 1GB + total_bytes_written += format_specific_write_data(writer_offset) ; writer_num++ ; } diff --git a/trick_source/sim_services/DataRecord/data_record_utilities.cpp b/trick_source/sim_services/DataRecord/data_record_utilities.cpp index ffb883ff..d5e4e469 100644 --- a/trick_source/sim_services/DataRecord/data_record_utilities.cpp +++ b/trick_source/sim_services/DataRecord/data_record_utilities.cpp @@ -78,3 +78,17 @@ extern "C" Trick::DataRecordGroup * get_data_record_group( std::string in_name ) } return NULL ; } + +extern "C" int set_max_size_record_group (const char * in_name, uint64_t bytes ) { + if ( the_drd != NULL ) { + return the_drd->set_group_max_file_size(in_name, bytes ) ; + } + return -1 ; +} + +extern "C" int dr_set_max_file_size ( uint64_t bytes ) { + if ( the_drd != NULL ) { + return the_drd->set_max_file_size( bytes ) ; + } + return -1 ; +} diff --git a/trick_source/sim_services/EventManager/EventManager.cpp b/trick_source/sim_services/EventManager/EventManager.cpp index 53c5c6fe..a3d18565 100644 --- a/trick_source/sim_services/EventManager/EventManager.cpp +++ b/trick_source/sim_services/EventManager/EventManager.cpp @@ -23,7 +23,11 @@ Trick::EventManager * the_em ; -Trick::EventManager::EventManager() { the_em = this ; } +Trick::EventManager::EventManager() : + active_events(NULL), + num_active_events(0), + num_allocated(0) +{ the_em = this ; } //Command to get the event object given the event's name Trick::Event * Trick::EventManager::get_event(std::string event_name) { @@ -52,9 +56,14 @@ int Trick::EventManager::add_to_active_events(Trick::Event * in_event) { } num_active_events++; if (num_active_events == 1) { - active_events = (Trick::Event **)TMM_declare_var_s("Trick::Event* [1]"); - } else { - active_events = (Trick::Event **)TMM_resize_array_1d_a(active_events, num_active_events); + active_events = (Trick::Event **)TMM_declare_var_s("Trick::Event* [100]"); + num_allocated = 100 ; + } else if ( num_active_events >= num_allocated ) { + num_allocated += 100 ; + active_events = (Trick::Event **)TMM_resize_array_1d_a(active_events, num_allocated); + for ( unsigned int ii = num_active_events ; ii < num_allocated ; ii++ ) { + active_events[ii] = NULL ; + } } active_events[num_active_events-1] = in_event ; return (0) ; @@ -178,6 +187,10 @@ int Trick::EventManager::remove_event(Trick::Event * in_event) { unsigned int ii , jj ; + if ( ! in_event ) { + return 0 ; + } + if ( in_event->get_before_after() == Trick::EVENT_NOTARGET ) { /* If the event is cyclic, remove the event from the event processor on the event's thread */ event_processors[in_event->get_thread()]->remove_event(in_event) ; @@ -205,18 +218,18 @@ int Trick::EventManager::remove_event(Trick::Event * in_event) { active_events[jj - 1] = active_events[jj] ; } num_active_events-- ; + if (num_active_events == 0) { + TMM_delete_var_a(active_events); + active_events = NULL; + } + else { + active_events[num_active_events] = NULL ; + } + break ; } } - if (num_active_events == 0) { - TMM_delete_var_a(active_events); - active_events = NULL; - } - else { - active_events = (Trick::Event **)TMM_resize_array_1d_a(active_events, num_active_events); - } - if ( in_event->get_free_on_removal() ) { TMM_delete_var_a(in_event) ; } diff --git a/trick_source/sim_services/Executive/Executive_advance_sim_time.cpp b/trick_source/sim_services/Executive/Executive_advance_sim_time.cpp index 30961b27..8d3b9574 100644 --- a/trick_source/sim_services/Executive/Executive_advance_sim_time.cpp +++ b/trick_source/sim_services/Executive/Executive_advance_sim_time.cpp @@ -42,14 +42,16 @@ int Trick::Executive::advance_sim_time() { /* Adjust time_tics if one of the threads has a job or async cycle time less than the main thread's next job */ for (ii = 1; ii < threads.size() ; ii++) { Threads * curr_thread = threads[ii] ; - if ( (curr_thread->process_type == PROCESS_TYPE_SCHEDULED) && - (curr_thread->job_queue.get_next_job_call_time() < time_tics) ) { - time_tics = curr_thread->job_queue.get_next_job_call_time() ; - } - if ( (curr_thread->process_type == PROCESS_TYPE_AMF_CHILD ) && - (curr_thread->amf_cycle_tics > 0 ) && - (curr_thread->amf_next_tics < time_tics) ) { - time_tics = curr_thread->amf_next_tics ; + if ( curr_thread->enabled ) { + if ( (curr_thread->process_type == PROCESS_TYPE_SCHEDULED) && + (curr_thread->job_queue.get_next_job_call_time() < time_tics) ) { + time_tics = curr_thread->job_queue.get_next_job_call_time() ; + } + if ( (curr_thread->process_type == PROCESS_TYPE_AMF_CHILD ) && + (curr_thread->amf_cycle_tics > 0 ) && + (curr_thread->amf_next_tics < time_tics) ) { + time_tics = curr_thread->amf_next_tics ; + } } } diff --git a/trick_source/sim_services/Executive/Executive_isThreadReadyToRun.cpp b/trick_source/sim_services/Executive/Executive_isThreadReadyToRun.cpp index 5af3238f..043fbafa 100644 --- a/trick_source/sim_services/Executive/Executive_isThreadReadyToRun.cpp +++ b/trick_source/sim_services/Executive/Executive_isThreadReadyToRun.cpp @@ -8,28 +8,30 @@ -# ASYNC threads are ready to run if their complete flag is set and either they have no cycle time or their previous frame just finished. */ -bool Trick::Executive::isThreadReadyToRun( Trick::Threads * curr_thread , long long time_tics) { +bool Trick::Executive::isThreadReadyToRun( Trick::Threads * curr_thread , long long time_ticks) { bool ret = false ; - switch ( curr_thread->process_type ) { - case Trick::PROCESS_TYPE_SCHEDULED: - ret = true ; - break ; - case Trick::PROCESS_TYPE_AMF_CHILD: - if ( curr_thread->amf_next_tics == time_tics ) { + if ( curr_thread->enabled ) { + switch ( curr_thread->process_type ) { + case Trick::PROCESS_TYPE_SCHEDULED: ret = true ; - } - break ; - case Trick::PROCESS_TYPE_ASYNC_CHILD: - if ( curr_thread->child_complete == true ) { - if (curr_thread->amf_cycle_tics == 0 ) { + break ; + case Trick::PROCESS_TYPE_AMF_CHILD: + if ( curr_thread->amf_next_tics == time_ticks ) { ret = true ; - } else { - if ( curr_thread->amf_next_tics == time_tics ) { + } + break ; + case Trick::PROCESS_TYPE_ASYNC_CHILD: + if ( curr_thread->child_complete == true ) { + if (curr_thread->amf_cycle_tics == 0 ) { ret = true ; + } else { + if ( curr_thread->amf_next_tics == time_ticks ) { + ret = true ; + } } } - } - break ; + break ; + } } return ret ; } diff --git a/trick_source/sim_services/Executive/Executive_scheduled_thread_sync.cpp b/trick_source/sim_services/Executive/Executive_scheduled_thread_sync.cpp index e3044d08..59f631e2 100644 --- a/trick_source/sim_services/Executive/Executive_scheduled_thread_sync.cpp +++ b/trick_source/sim_services/Executive/Executive_scheduled_thread_sync.cpp @@ -16,7 +16,7 @@ int Trick::Executive::scheduled_thread_sync() { /* Wait for synchronous threads to finish before testing for adjusting time_tics */ for (ii = 1; ii < threads.size() ; ii++) { Threads * curr_thread = threads[ii] ; - if ( curr_thread->process_type == PROCESS_TYPE_SCHEDULED) { + if ( curr_thread->enabled and curr_thread->process_type == PROCESS_TYPE_SCHEDULED) { while (curr_thread->child_complete == false ) { if (rt_nap == true) { RELEASE(); diff --git a/trick_source/sim_services/Executive/test/Executive_test.cpp b/trick_source/sim_services/Executive/test/Executive_test.cpp index eb59ed04..1a5b203f 100644 --- a/trick_source/sim_services/Executive/test/Executive_test.cpp +++ b/trick_source/sim_services/Executive/test/Executive_test.cpp @@ -391,9 +391,8 @@ TEST_F(ExecutiveTest , AddDepends) { TEST_F(ExecutiveTest , UnhandledJobs) { //req.add_requirement("r_exec_jobs"); //"The Executive Scheduler shall provide the capability to list jobs not handled by any scheduler." - Trick::JobData * curr_job ; - curr_job = so1.add_job(0, 100, "unhandled", NULL, 1, "unhandled_job", "") ; + so1.add_job(0, 100, "unhandled", NULL, 1, "unhandled_job", "") ; exec_add_sim_object(&so1 , "so1") ; EXPECT_EQ(exec.check_all_jobs_handled() , 1 ) ; } diff --git a/trick_source/sim_services/FrameLog/FrameLog.cpp b/trick_source/sim_services/FrameLog/FrameLog.cpp index 23e8ed94..7ff87b6c 100644 --- a/trick_source/sim_services/FrameLog/FrameLog.cpp +++ b/trick_source/sim_services/FrameLog/FrameLog.cpp @@ -11,7 +11,6 @@ #include "trick/FrameDataRecordGroup.hh" #include "trick/exec_proto.hh" #include "trick/exec_proto.h" -#include "trick/clock_proto.h" #include "trick/data_record_proto.h" #include "trick/command_line_protos.h" #include "trick/message_proto.h" @@ -20,7 +19,7 @@ Trick::FrameLog * the_fl = NULL ; //Constructor. -Trick::FrameLog::FrameLog() { +Trick::FrameLog::FrameLog(Trick::Clock & in_clock) : clock(in_clock) { frame_log_flag = false ; drg_trick = NULL ; drg_frame = NULL ; @@ -342,7 +341,7 @@ int Trick::FrameLog::frame_clock_start(Trick::JobData * curr_job ) { /** @par Detailed Design: */ if ( target_job != NULL ) { /** @li Set target job's start time. */ - target_job->rt_start_time = clock_time() ; + target_job->rt_start_time = clock.clock_time() ; } return(0) ; @@ -359,7 +358,7 @@ int Trick::FrameLog::frame_clock_stop(Trick::JobData * curr_job) { if ( target_job != NULL ) { if ( target_job->rt_start_time >= 0 ) { /** @li Set current job's stop time and frame time. */ - target_job->rt_stop_time = clock_time() ; + target_job->rt_stop_time = clock.clock_time() ; target_job->frame_time += (target_job->rt_stop_time - target_job->rt_start_time); thread = target_job->thread; @@ -678,6 +677,11 @@ int Trick::FrameLog::shutdown() { return(0) ; } + +void Trick::FrameLog::set_clock(Trick::Clock & in_clock) { + clock = in_clock ; +} + //Call all the Create routines for the DP directory and all DP files. int Trick::FrameLog::create_DP_files() { int ret=0; diff --git a/trick_source/sim_services/InputProcessor/IPPython.cpp b/trick_source/sim_services/InputProcessor/IPPython.cpp index 5217afe6..96c3c9df 100644 --- a/trick_source/sim_services/InputProcessor/IPPython.cpp +++ b/trick_source/sim_services/InputProcessor/IPPython.cpp @@ -110,7 +110,7 @@ int Trick::IPPython::init() { "import struct\n" "import binascii\n" "sys.path.append(os.getcwd())\n" - "sys.path.append(os.path.join(os.environ['TRICK_HOME'], 'pymods'))\n" + "sys.path.append(os.path.join(os.environ['TRICK_HOME'], 'share/trick/pymods'))\n" "sys.path += map(str.strip, os.environ['TRICK_PYTHON_PATH'].split(':'))\n" "import trick\n" "sys.path.append(os.getcwd() + \"/Modified_data\")\n" diff --git a/trick_source/sim_services/InputProcessor/IPPythonEvent.cpp b/trick_source/sim_services/InputProcessor/IPPythonEvent.cpp index cb2d6478..2af24187 100644 --- a/trick_source/sim_services/InputProcessor/IPPythonEvent.cpp +++ b/trick_source/sim_services/InputProcessor/IPPythonEvent.cpp @@ -66,11 +66,21 @@ Trick::IPPythonEvent::IPPythonEvent() { fired = false ; hold = false ; ran = false ; - act = NULL; - cond = NULL; + action_list = NULL; + condition_list = NULL; } Trick::IPPythonEvent::~IPPythonEvent() { + + for (int ii=0; iicond_type==1) { // condition variable + condition_list[jj]->ref = ref_attributes((char*)condition_list[jj]->str.c_str()); } - if (cond[jj].cond_type==2) { // condition job - cond[jj].job = exec_get_job(cond[jj].str.c_str(),1); + if (condition_list[jj]->cond_type==2) { // condition job + condition_list[jj]->job = exec_get_job(condition_list[jj]->str.c_str(),1); } } for (jj=0; jjact_type!=0) { // action job + action_list[jj]->job = exec_get_job(action_list[jj]->str.c_str(),1); } } @@ -204,39 +214,39 @@ int Trick::IPPythonEvent::condition(int num, std::string str, std::string commen /** @li Add a new condition when num is sequential, i.e. it is equal to condition_count */ condition_count++; if (condition_count == 1) { - cond = (Trick::condition_t *)TMM_declare_var_s("Trick::condition_t[1]"); + condition_list = + (Trick::condition_t **)TMM_declare_var_s("Trick::condition_t*[1]"); } else { - cond = (Trick::condition_t *)TMM_resize_array_1d_a(cond, condition_count); + condition_list = + (Trick::condition_t **)TMM_resize_array_1d_a(condition_list, condition_count); } - cond[num].fired_count = 0; - cond[num].fired_time = -1.0; + condition_list[num] = + (Trick::condition_t *)TMM_declare_var_s("Trick::condition_t"); + + condition_list[num]->fired_count = 0; + condition_list[num]->fired_time = -1.0; } if ((num >=0) && (num < condition_count)) { /** @li This is either a new condition or user is changing the condition. */ /** @li Initialize condition variables - default as enabled. */ - cond[num].ref = ref ; - cond[num].job = job ; - cond[num].enabled = true; - cond[num].hold = false; - cond[num].fired = false; + condition_list[num]->ref = ref ; + condition_list[num]->job = job ; + condition_list[num]->enabled = true; + condition_list[num]->hold = false; + condition_list[num]->fired = false; if (ref != NULL) { - cond[num].cond_type = 1; + condition_list[num]->cond_type = 1; } else if (job != NULL) { - cond[num].cond_type = 2; - } else cond[num].cond_type = 0; - cond[num].str = str; + condition_list[num]->cond_type = 2; + } else condition_list[num]->cond_type = 0; + condition_list[num]->str = str; // comment is for display in mtv, if not supplied create a comment containing up to 50 characters of cond string if (comment.empty()) { - cond[num].comment = str.substr(0,50); + condition_list[num]->comment = str.substr(0,50); } else { - cond[num].comment = comment; + condition_list[num]->comment = comment; } // dummy must contain max conditions used in any event so it can replace any event in mtv when deleted -#if 0 - if (num == ip->dummy_event.condition_count) { - ip->dummy_event.condition(num, "XXX_DELETED_COND"); - } -#endif } else { /** @li Emit an error if specified index num is not sequential. */ message_publish(MSG_WARNING, "Event condition not added: condition number %d is not sequential.\n", num) ; @@ -248,7 +258,7 @@ int Trick::IPPythonEvent::condition(int num, std::string str, std::string commen int Trick::IPPythonEvent::condition_hold_on(int num) { if ((num >=0) && (num < condition_count)) { - cond[num].hold = true ; + condition_list[num]->hold = true ; } else { message_publish(MSG_WARNING, "Event condition hold not set. Condition number %d is invalid.\n", num) ; } @@ -259,7 +269,7 @@ int Trick::IPPythonEvent::condition_hold_on(int num) { int Trick::IPPythonEvent::condition_hold_off(int num) { if ((num >=0) && (num < condition_count)) { - cond[num].hold = false ; + condition_list[num]->hold = false ; } else { message_publish(MSG_WARNING, "Event condition hold not set. Condition number %d is invalid.\n", num) ; } @@ -270,7 +280,7 @@ int Trick::IPPythonEvent::condition_hold_off(int num) { int Trick::IPPythonEvent::condition_enable(int num) { if ((num >=0) && (num < condition_count)) { - cond[num].enabled = true ; + condition_list[num]->enabled = true ; } else { message_publish(MSG_WARNING, "Event condition not enabled. Condition number %d is invalid.\n", num) ; } @@ -281,7 +291,7 @@ int Trick::IPPythonEvent::condition_enable(int num) { int Trick::IPPythonEvent::condition_disable(int num) { if ((num >=0) && (num < condition_count)) { - cond[num].enabled = false ; + condition_list[num]->enabled = false ; } else { message_publish(MSG_WARNING, "Event condition not disabled. Condition number %d is invalid.\n", num) ; } @@ -292,7 +302,7 @@ int Trick::IPPythonEvent::condition_disable(int num) { bool Trick::IPPythonEvent::condition_fired(int num) { if ((num >=0) && (num < condition_count)) { - return (cond[num].fired ? true : false) ; + return (condition_list[num]->fired ? true : false) ; } else { message_publish(MSG_WARNING, "Event condition fired state not returned. Condition number %d is invalid.\n", num) ; } @@ -303,7 +313,7 @@ bool Trick::IPPythonEvent::condition_fired(int num) { int Trick::IPPythonEvent::condition_fired_count(int num) { if ((num >=0) && (num < condition_count)) { - return (cond[num].fired_count) ; + return (condition_list[num]->fired_count) ; } else { message_publish(MSG_WARNING, "Event condition fired count not returned. Condition number %d is invalid.\n", num) ; } @@ -314,7 +324,7 @@ int Trick::IPPythonEvent::condition_fired_count(int num) { double Trick::IPPythonEvent::condition_fired_time(int num) { if ((num >=0) && (num < condition_count)) { - return (cond[num].fired_time) ; + return (condition_list[num]->fired_time) ; } else { message_publish(MSG_WARNING, "Event condition fired time not returned. Condition number %d is invalid.\n", num) ; } @@ -325,7 +335,7 @@ double Trick::IPPythonEvent::condition_fired_time(int num) { std::string Trick::IPPythonEvent::condition_string(int num) { if ((num >=0) && (num < condition_count)) { - return (cond[num].str) ; + return (condition_list[num]->str) ; } else { message_publish(MSG_WARNING, "Event condition string not returned. Condition number %d is invalid.\n", num) ; } @@ -386,26 +396,29 @@ int Trick::IPPythonEvent::action(int num, std::string str, std::string comment, /** @li Add a new action when num is sequential, i.e. it is equal to action_count */ action_count++; if (action_count == 1) { - act = (Trick::action_t *)TMM_declare_var_s("Trick::action_t[1]"); + action_list = (Trick::action_t **)TMM_declare_var_s("Trick::action_t*[1]"); } else { - act = (Trick::action_t *)TMM_resize_array_1d_a(act, action_count); + action_list = (Trick::action_t **)TMM_resize_array_1d_a(action_list, action_count); } - act[num].ran_count = 0; - act[num].ran_time = -1.0; + action_list[num] = + (Trick::action_t *)TMM_declare_var_s("Trick::action_t"); + + action_list[num]->ran_count = 0; + action_list[num]->ran_time = -1.0; } if ((num >=0) && (num < action_count)) { /** @li This is either a new action or user is changing the action. */ /** @li Initialize action variables - default as enabled. */ - act[num].job = job ; - act[num].act_type = act_type ; - act[num].enabled = true; - act[num].ran = false; - act[num].str = str; + action_list[num]->job = job ; + action_list[num]->act_type = act_type ; + action_list[num]->enabled = true; + action_list[num]->ran = false; + action_list[num]->str = str; // comment is for display in mtv, if not supplied create a comment containing up to 50 characters of act string if (comment.empty()) { - act[num].comment = str.substr(0,50); + action_list[num]->comment = str.substr(0,50); } else { - act[num].comment = comment; + action_list[num]->comment = comment; } // dummy must contain max actions used in any event so it can replace any event in mtv when deleted #if 0 @@ -424,7 +437,7 @@ int Trick::IPPythonEvent::action(int num, std::string str, std::string comment, int Trick::IPPythonEvent::action_enable(int num) { if ((num >=0) && (num < action_count)) { - act[num].enabled = true ; + action_list[num]->enabled = true ; } else { message_publish(MSG_WARNING, "Event action not enabled. Action number %d is invalid.\n", num) ; } @@ -435,7 +448,7 @@ int Trick::IPPythonEvent::action_enable(int num) { int Trick::IPPythonEvent::action_disable(int num) { if ((num >=0) && (num < action_count)) { - act[num].enabled = false ; + action_list[num]->enabled = false ; } else { message_publish(MSG_WARNING, "Event action not disabled. Action number %d is invalid.\n", num) ; } @@ -446,7 +459,7 @@ int Trick::IPPythonEvent::action_disable(int num) { bool Trick::IPPythonEvent::action_ran(int num) { if ((num >=0) && (num < action_count)) { - return (act[num].ran ? true : false) ; + return (action_list[num]->ran ? true : false) ; } else { message_publish(MSG_WARNING, "Event action ran state not returned. Action number %d is invalid.\n", num) ; } @@ -457,7 +470,7 @@ bool Trick::IPPythonEvent::action_ran(int num) { int Trick::IPPythonEvent::action_ran_count(int num) { if ((num >=0) && (num < action_count)) { - return (act[num].ran_count) ; + return (action_list[num]->ran_count) ; } else { message_publish(MSG_WARNING, "Event action ran count not returned. Action number %d is invalid.\n", num) ; } @@ -468,7 +481,7 @@ int Trick::IPPythonEvent::action_ran_count(int num) { double Trick::IPPythonEvent::action_ran_time(int num) { if ((num >=0) && (num < action_count)) { - return (act[num].ran_time) ; + return (action_list[num]->ran_time) ; } else { message_publish(MSG_WARNING, "Event action ran time not returned. Action number %d is invalid.\n", num) ; } @@ -486,16 +499,16 @@ int Trick::IPPythonEvent::process( long long curr_time ) { } else { // it's a read event active = false ; - ip->parse(act[0].str) ; + ip->parse(action_list[0]->str) ; // keep stats so mtv will show when it ran fired_count++ ; fired_time = curr_time ; ran = true ; ran_count++ ; ran_time = curr_time ; - act[0].ran = true ; - act[0].ran_count++ ; - act[0].ran_time = curr_time ; + action_list[0]->ran = true ; + action_list[0]->ran_count++ ; + action_list[0]->ran_time = curr_time ; } } return 0 ; @@ -515,54 +528,54 @@ bool Trick::IPPythonEvent::process_user_event( long long curr_time ) { /** @li Loop thru all conditions. */ for (ii=0; iienabled ) { + condition_list[ii]->fired = false ; continue ; } /** @li No need to evaluate condition if previously fired and hold is on. */ - if (cond[ii].hold && cond[ii].fired) { + if (condition_list[ii]->hold && condition_list[ii]->fired) { ; } else { /** @li Evaluate the condition and set its fired state. */ - cond[ii].fired = false ; + condition_list[ii]->fired = false ; return_val = 0 ; - if (cond[ii].ref != NULL) { + if (condition_list[ii]->ref != NULL) { // if it's a variable, get it as a boolean - if ( cond[ii].ref->pointer_present ) { - cond[ii].ref->address = follow_address_path(cond[ii].ref) ; + if ( condition_list[ii]->ref->pointer_present ) { + condition_list[ii]->ref->address = follow_address_path(condition_list[ii]->ref) ; } - if ( cond[ii].ref->address != NULL ) { - return_val = *(bool *)cond[ii].ref->address ; + if ( condition_list[ii]->ref->address != NULL ) { + return_val = *(bool *)condition_list[ii]->ref->address ; } - } else if (cond[ii].job != NULL) { + } else if (condition_list[ii]->job != NULL) { // if it's a job, get its return value - bool save_disabled_state = cond[ii].job->disabled; - cond[ii].job->disabled = false; - return_val = cond[ii].job->call(); - cond[ii].job->disabled = save_disabled_state; + bool save_disabled_state = condition_list[ii]->job->disabled; + condition_list[ii]->job->disabled = false; + return_val = condition_list[ii]->job->call(); + condition_list[ii]->job->disabled = save_disabled_state; } else { // otherwise use python to evaluate string std::string full_in_string ; - ip->parse_condition(cond[ii].str, return_val) ; + ip->parse_condition(condition_list[ii]->str, return_val) ; } if (return_val) { //TODO: write to log/send_hs that trigger fired - cond[ii].fired = true ; - cond[ii].fired_count++ ; - cond[ii].fired_time = curr_time ; + condition_list[ii]->fired = true ; + condition_list[ii]->fired_count++ ; + condition_list[ii]->fired_time = curr_time ; } } // end evaluate condition /** @li If cond_all is true, only set event fired/hold after all enabled conditions evaluated. */ if (ii==0) { - fired = cond[ii].fired ; - hold = cond[ii].hold ; + fired = condition_list[ii]->fired ; + hold = condition_list[ii]->hold ; } else { if (cond_all) { - fired &= cond[ii].fired ; - hold &= cond[ii].hold ; + fired &= condition_list[ii]->fired ; + hold &= condition_list[ii]->hold ; } else { - fired |= cond[ii].fired ; - hold |= cond[ii].hold ; + fired |= condition_list[ii]->fired ; + hold |= condition_list[ii]->hold ; } } } //end condition loop @@ -586,37 +599,37 @@ bool Trick::IPPythonEvent::process_user_event( long long curr_time ) { /** @li Loop thru all actions. */ for (ii=0; iienabled ) { + action_list[ii]->ran = false ; continue ; } /** @li Run the action and set its ran state. */ - if (act[ii].job != NULL) { + if (action_list[ii]->job != NULL) { // if it's a job, do what the action type tells you - switch (act[ii].act_type) { + switch (action_list[ii]->act_type) { case 0 : // python, should not get here break; case 1 : // On - act[ii].job->disabled = false; + action_list[ii]->job->disabled = false; break; case 2 : // Off - act[ii].job->disabled = true; + action_list[ii]->job->disabled = true; break; case 3 : // Call - bool save_disabled_state = act[ii].job->disabled; - act[ii].job->disabled = false; - act[ii].job->call(); - act[ii].job->disabled = save_disabled_state; + bool save_disabled_state = action_list[ii]->job->disabled; + action_list[ii]->job->disabled = false; + action_list[ii]->job->call(); + action_list[ii]->job->disabled = save_disabled_state; break; } } else { // otherwise use python to evaluate string - ip->parse(act[ii].str) ; + ip->parse(action_list[ii]->str) ; } it_ran = true ; - act[ii].ran = true ; - act[ii].ran_count++ ; - act[ii].ran_time = curr_time ; + action_list[ii]->ran = true ; + action_list[ii]->ran_count++ ; + action_list[ii]->ran_time = curr_time ; ran = true ; } /** @li Leave event fired state on if hold is on. */ diff --git a/trick_source/sim_services/Integrator/test/Integrator_unittest.cc b/trick_source/sim_services/Integrator/test/Integrator_unittest.cc index 5308db08..d9fc9fe0 100644 --- a/trick_source/sim_services/Integrator/test/Integrator_unittest.cc +++ b/trick_source/sim_services/Integrator/test/Integrator_unittest.cc @@ -161,12 +161,11 @@ void deriv(BALL *B) { B->acc[1] = 0; } -void init(BALL *B, long *tick) { +void init(BALL *B) { const double initial_speed = 50.0 ; const double initial_angle = 30.0 ; - tick = 0; B->pos[0] = 0.0; B->pos[1] = 0.0; B->vel[0] = initial_speed * sin(initial_angle * RAD_PER_DEG); @@ -176,11 +175,11 @@ void init(BALL *B, long *tick) { BALL Ball_sim( Trick::Integrator *integrator) { BALL ball; - long tick; + long tick = 0; double sim_time; // Initialization - init(&ball, &tick); + init(&ball); // Simulation Loop do { @@ -202,11 +201,11 @@ BALL Ball_sim( Trick::Integrator *integrator) { BALL Ball_eulercromer_sim( Trick::Euler_Cromer_Integrator *integrator ) { BALL ball; - long tick; + long tick = 0; double sim_time; // Initialization - init(&ball, &tick); + init(&ball); // Simulation Loop do { diff --git a/trick_source/sim_services/JSONVariableServer/JSONVariableServer.cpp b/trick_source/sim_services/JSONVariableServer/JSONVariableServer.cpp index 01d270fe..75e46daf 100644 --- a/trick_source/sim_services/JSONVariableServer/JSONVariableServer.cpp +++ b/trick_source/sim_services/JSONVariableServer/JSONVariableServer.cpp @@ -24,12 +24,8 @@ Trick::JSONVariableServer::JSONVariableServer() : } Trick::JSONVariableServer::~JSONVariableServer() { - if ( listen_dev.hostname != NULL ) { free(listen_dev.hostname) ; - } - if ( listen_dev.error_handler != NULL ) { free(listen_dev.error_handler) ; - } } const char * Trick::JSONVariableServer::get_hostname() { diff --git a/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp b/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp index ed95c93b..ce220a47 100644 --- a/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp +++ b/trick_source/sim_services/MemoryManager/MemoryManager_delete_var.cpp @@ -9,9 +9,11 @@ int Trick::MemoryManager::delete_var(void* address, bool destroy ) { if (address == 0) { - std::stringstream message; - message << "Cannot delete memory at NULL."; - emitError(message.str()); + if (debug_level) { + std::stringstream message; + message << "Cannot delete memory at NULL."; + emitWarning(message.str()); + } return 1; } diff --git a/trick_source/sim_services/MemoryManager/test/MM_user_defined_types.hh b/trick_source/sim_services/MemoryManager/test/MM_user_defined_types.hh index 868ff6ec..54a3aab8 100644 --- a/trick_source/sim_services/MemoryManager/test/MM_user_defined_types.hh +++ b/trick_source/sim_services/MemoryManager/test/MM_user_defined_types.hh @@ -60,7 +60,7 @@ class UDT2 { double A; double B; double C; - char* ss; + const char* ss; UDT1 udt1; UDT1* udt1_p; }; diff --git a/trick_source/sim_services/MemoryManager/test/MM_write_checkpoint.cc b/trick_source/sim_services/MemoryManager/test/MM_write_checkpoint.cc index f619dba6..04223293 100644 --- a/trick_source/sim_services/MemoryManager/test/MM_write_checkpoint.cc +++ b/trick_source/sim_services/MemoryManager/test/MM_write_checkpoint.cc @@ -959,3 +959,90 @@ TEST_F(MM_write_checkpoint, Compressed_2d_char_arrays ) { EXPECT_EQ(result, 0); } +TEST_F(MM_write_checkpoint, ptr_to_array_of_ptrs_to_objects ) { + + // This test is associated with Issue: https://github.com/nasa/trick/issues/587 + + // A possible fix to issue 587, involves aggregating condition_t and action_t + // objects using a resizable list of pointers rather than a resizable array + // of those objects. This is a test explores how this approach woud be + // check-pointed. + + std::stringstream ss; + + // Allocate object with a double ptr member, that is + // a pointer to an array of pointers to some (3 in this case) objects. + UDT7 *udt7_p = (UDT7*)memmgr->declare_var("UDT7 udt7"); + + // Initialize the object, and its aggregation. + udt7_p->A = 2.71828; + UDT3** pp = (UDT3**)memmgr->declare_var("UDT3* udt3p[3]"); + udt7_p->udt3pp = pp; + pp[0] = (UDT3*)memmgr->declare_var("UDT3 udt3A"); + pp[1] = (UDT3*)memmgr->declare_var("UDT3 udt3B"); + pp[2] = (UDT3*)memmgr->declare_var("UDT3 udt3C"); + pp[0]->a = 1; + pp[0]->b = 2; + pp[1]->a = 4; + pp[1]->b = 5; + pp[2]->a = 7; + pp[2]->b = 8; + + memmgr->set_expanded_arrays(false); + // Write the checkpoint. + memmgr->write_checkpoint( ss, "udt7"); + + // Verify it's what we expected. + int result = strcmp_IgnoringWhiteSpace( + "// Variable Declarations." + "UDT7 udt7;" + "UDT3* udt3p[3];" + "UDT3 udt3A;" + "UDT3 udt3B;" + "UDT3 udt3C;" + "// Clear all allocations to 0." + "clear_all_vars();" + "// Variable Assignments." + "udt7.A = 2.71828;" + "udt7.udt3pp = &udt3p[0].a;" + "udt3p[0] = &udt3A;" + "udt3p[1] = &udt3B;" + "udt3p[2] = &udt3C;" + "udt3A.a = 1;" + "udt3A.b = 2;" + "udt3B.a = 4;" + "udt3B.b = 5;" + "udt3C.a = 7;" + "udt3C.b = 8;" + , ss.str().c_str()); + + EXPECT_EQ(result, 0); + + // Delete all of the objects that we created. + memmgr->delete_var("udt3A"); + memmgr->delete_var("udt3B"); + memmgr->delete_var("udt3C"); + memmgr->delete_var("udt3p"); + memmgr->delete_var("udt7"); + udt7_p = (UDT7*)NULL; + pp = (UDT3**)NULL; + + // Re-create the objects from a checkpoint. + memmgr->read_checkpoint_from_string(ss.str().c_str()); + + EXPECT_EQ(result, 0); + + // Get the address of the object we just restored. + REF2* ref = memmgr->ref_attributes("udt7"); + udt7_p = (UDT7*)ref->address; + + // Verify that the values are what they should be. + EXPECT_NEAR(udt7_p->A, 2.71828, 0.000001); + EXPECT_EQ( udt7_p->udt3pp[0]->a , 1); + EXPECT_EQ( udt7_p->udt3pp[0]->b , 2); + EXPECT_EQ( udt7_p->udt3pp[1]->a , 4); + EXPECT_EQ( udt7_p->udt3pp[1]->b , 5); + EXPECT_EQ( udt7_p->udt3pp[2]->a , 7); + EXPECT_EQ( udt7_p->udt3pp[2]->b , 8); +} + diff --git a/trick_source/sim_services/MemoryManager/test/MM_write_checkpoint.hh b/trick_source/sim_services/MemoryManager/test/MM_write_checkpoint.hh index 94ba8c2e..8a21cec2 100644 --- a/trick_source/sim_services/MemoryManager/test/MM_write_checkpoint.hh +++ b/trick_source/sim_services/MemoryManager/test/MM_write_checkpoint.hh @@ -36,3 +36,9 @@ class UDT6 { char A[128][4]; char B[128][4]; }; + +class UDT7 { + public: + double A; + UDT3** udt3pp; +}; diff --git a/trick_source/sim_services/Message/MessagePublisher.cpp b/trick_source/sim_services/Message/MessagePublisher.cpp index d5e9f0b2..3e108084 100644 --- a/trick_source/sim_services/Message/MessagePublisher.cpp +++ b/trick_source/sim_services/Message/MessagePublisher.cpp @@ -71,9 +71,7 @@ int Trick::MessagePublisher::publish(int level , std::string message) { // multithreaded sims from interleaving header and message elements. std::ostringstream oss; oss << header << message ; - std::cout << oss.str() << std::flush ; - } - return(0) ; + std::cout << oss.str() << std::flush ; } return(0) ; } diff --git a/trick_source/sim_services/Message/MessageTCDevice.cpp b/trick_source/sim_services/Message/MessageTCDevice.cpp index ea75de6a..60ca4e64 100644 --- a/trick_source/sim_services/Message/MessageTCDevice.cpp +++ b/trick_source/sim_services/Message/MessageTCDevice.cpp @@ -26,7 +26,7 @@ Trick::MessageTCDeviceListenThread::MessageTCDeviceListenThread(MessageTCDevice Trick::MessageTCDeviceListenThread::~MessageTCDeviceListenThread() { free(listen_dev.error_handler) ; if ( listen_dev.hostname ) { - free(listen_dev.hostname) ; + free((char*)listen_dev.hostname) ; } close(listen_dev.socket) ; } diff --git a/trick_source/sim_services/Message/MessageThreadedCout.cpp b/trick_source/sim_services/Message/MessageThreadedCout.cpp new file mode 100644 index 00000000..b833e570 --- /dev/null +++ b/trick_source/sim_services/Message/MessageThreadedCout.cpp @@ -0,0 +1,102 @@ + +#include "trick/MessageThreadedCout.hh" +#include "trick/message_type.h" +#include "trick/release.h" + +#include + +Trick::MessageThreadedCout::MessageThreadedCout() : + max_buffer_items(400), + max_buffer_size(4000) , + print_immediate(false) , + copy_ptr(NULL), + write_ptr(NULL) { + /** By default, this subscriber is enabled when it is created. */ + Trick::MessageSubscriber::name = "threadedcout" ; + Trick::ThreadBase::name = "threadedcout" ; + color_code.reserve(6) ; + StringNode * temp = new StringNode(max_buffer_size) ; + write_ptr = copy_ptr = temp ; + for ( unsigned int ii = 1 ; ii < max_buffer_items ; ii++ ) { + temp = new StringNode(max_buffer_size) ; + copy_ptr->next = temp ; + copy_ptr = temp ; + } + copy_ptr->next = write_ptr ; + copy_ptr = write_ptr ; + + pthread_mutex_init(&write_mutex, NULL); +} + +int Trick::MessageThreadedCout::init() { + create_thread() ; + return 0 ; +} + +void Trick::MessageThreadedCout::update( unsigned int level , std::string header , std::string message ) { + + /** @li Prints the received message to the standard output stream. */ + if (enabled && level < 100 ) { + switch (level) { + case MSG_NORMAL : + color_code = "\033[00m" ; // normal + break ; + case MSG_INFO : + color_code = "\033[32m" ; // green + break ; + case MSG_WARNING : + color_code = "\033[33m" ; // yellow + break ; + case MSG_ERROR : + color_code = "\033[31m" ; // red + break ; + case MSG_DEBUG : + color_code = "\033[36m" ; // cyan + break ; + default : + color_code = "\033[00m" ; // normal + break ; + } + + if ( copy_ptr->next != write_ptr ) { + copy_ptr->copy(header, color_code, message) ; + copy_ptr = copy_ptr->next ; + // After shutdown the sim sends a termination message. print it now. + if ( print_immediate ) { + write_pending_messages() ; + } + } + } +} + +void * Trick::MessageThreadedCout::thread_body() { + while(1) { + write_pending_messages() ; + RELEASE() ; + } +} + +void Trick::MessageThreadedCout::write_pending_messages() { + pthread_mutex_lock(&write_mutex) ; + while ( write_ptr != copy_ptr ) { + std::cout << write_ptr->buffer << std::flush ; + write_ptr = write_ptr->next ; + } + pthread_mutex_unlock(&write_mutex) ; +} + +int Trick::MessageThreadedCout::shutdown() { + + write_pending_messages() ; + // After shutdown print any late incoming messages immediately. + print_immediate = true ; + + //TODO: delete memory + + return 0 ; +} + +void Trick::MessageThreadedCout::dump( std::ostream & oss ) { + Trick::ThreadBase::dump(oss) ; +} + diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp index de6e421e..5132ab82 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp @@ -40,7 +40,7 @@ void Trick::MonteCarlo::dispatch_run_to_slave(MonteRun *run, MonteSlave *slave) tc_write(&connection_device, (char*)&num_bytes, (int)sizeof(num_bytes)); tc_write(&connection_device, (char*)buffer.c_str(), (int)buffer.length()); - if (verbosity >= INFORMATIONAL) { + if (verbosity >= ALL) { message_publish(MSG_INFO, "Parameterization of run %d :\n%s\n", run->id, buffer.c_str()) ; } diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp index 107ae65d..c6597608 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_funcs.cpp @@ -397,24 +397,15 @@ Trick::MonteRun *Trick::MonteCarlo::get_next_dispatch() { /**
  • While there are remaining runs: */ while (!runs.empty()) { MonteRun *curr_run = runs.front(); - /**
    • If this run hasn't been dispatched before: */ - if (curr_run->num_tries == 0) { - /**
    • If it is in range, return it.
    */ - if (in_range(curr_run)) { - return curr_run; - /**
  • Otherwise, run the pre run jobs and dequeue it. */ - } else { - if (verbosity >= ALL) { - message_publish(MSG_WARNING, "Monte [Master] Run %d is out of range and has been skipped.\n", curr_run->id) ; - } - prepare_run(curr_run); - } - /** - *
  • If this run has been dispatched before, it may have been requeued due to a slave timeout for which the slave - * later returned results. In such a case, do not dispatch it again (return NULL). Otherwise, return it. - */ - } else if (curr_run->exit_status == MonteRun::INCOMPLETE) { + /**
  • If it is in range, return it.
*/ + if (in_range(curr_run)) { return curr_run; + /**
  • Otherwise, run the pre run jobs and dequeue it. */ + } else { + if (verbosity >= ALL) { + message_publish(MSG_WARNING, "Monte [Master] Run %d is out of range and has been skipped.\n", curr_run->id) ; + } + prepare_run(curr_run); } } return NULL; diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_receive_results.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_receive_results.cpp index 613889c2..998ff55c 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_receive_results.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_receive_results.cpp @@ -81,7 +81,14 @@ void Trick::MonteCarlo::handle_run_data(Trick::MonteSlave& slave) { } /** - *
    • This run may have already been resolved by another slave if + *
      • Try to remove this run from the queue in case it was requeue by #check_timeouts. + * This covers the case in which the master determines that a slave has timed out, requeues + * the run, and then the slave reports results. + */ + dequeue_run(slave.current_run); + + /** + *
      • This run may have already been resolved by another slave if * this slave was marked as having timed out. If that is the case, * discard these results. */ diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_slave.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_slave.cpp index 2fce326b..12d54f40 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_slave.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_slave.cpp @@ -16,7 +16,7 @@ int Trick::MonteCarlo::execute_as_slave() { /**
        • On a blocking read, wait for a MonteSlave::Command from the master. */ if (tc_accept(&listen_device, &connection_device) != TC_SUCCESS) { if (verbosity >= ERROR) { - message_publish(MSG_ERROR, "Monte [%s:%d] Lost connection to Master.\nShutting down.\n", + message_publish(MSG_ERROR, "Monte [%s:%d] Lost connection to Master. Shutting down.\n", machine_name.c_str(), slave_id) ; } slave_shutdown(); @@ -24,7 +24,7 @@ int Trick::MonteCarlo::execute_as_slave() { int command; if (tc_read(&connection_device, (char *)&command, (int)sizeof(command)) != (int)sizeof(command)) { if (verbosity >= ERROR) { - message_publish(MSG_ERROR, "Monte [%s:%d] Lost connection to Master while receiving instructions.\nShutting down.\n", + message_publish(MSG_ERROR, "Monte [%s:%d] Lost connection to Master while receiving instructions. Shutting down.\n", machine_name.c_str(), slave_id) ; } slave_shutdown(); @@ -44,7 +44,7 @@ int Trick::MonteCarlo::execute_as_slave() { case MonteSlave::SHUTDOWN: /**
        • MonteSlave::SHUTDOWN: Call #slave_shutdown. */ if (verbosity >= INFORMATIONAL) { - message_publish(MSG_INFO, "Monte [%s:%d] Shutdown command received from Master.\nShutting down.\n", + message_publish(MSG_INFO, "Monte [%s:%d] Shutdown command received from Master. Shutting down.\n", machine_name.c_str(), slave_id) ; } slave_shutdown(); @@ -60,7 +60,7 @@ int Trick::MonteCarlo::execute_as_slave() { default: /**
        • default: Call #slave_shutdown. */ if (verbosity >= ERROR) { - message_publish(MSG_ERROR, "Monte [%s:%d] Unrecognized command %d received from Master.\nShutting down.\n", + message_publish(MSG_ERROR, "Monte [%s:%d] Unrecognized command %d received from Master. Shutting down.\n", machine_name.c_str(), slave_id, command) ; } slave_shutdown(); diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_spawn_slaves.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_spawn_slaves.cpp index 676ef6de..3279781d 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_spawn_slaves.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_spawn_slaves.cpp @@ -40,7 +40,7 @@ void Trick::MonteCarlo::initialize_slave(Trick::MonteSlave* slave_to_init) { } if (!slave_to_init->S_main_name.compare("")) { - slave_to_init->S_main_name = "./S_main_${TRICK_HOST_CPU}.exe"; + slave_to_init->S_main_name = "./S_main_*.exe"; } /**
        • Append the S_main executable and slave-specific arguments. */ diff --git a/trick_source/sim_services/MonteCarlo/MonteVarFile.cpp b/trick_source/sim_services/MonteCarlo/MonteVarFile.cpp index d9f6a4a4..b763926e 100644 --- a/trick_source/sim_services/MonteCarlo/MonteVarFile.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteVarFile.cpp @@ -45,8 +45,12 @@ std::string Trick::MonteVarFile::get_next_value() { std::getline(*input_file_stream, line); if(input_file_stream->eof()) { - input_file_stream->close(); - return "EOF"; + if (line.empty()) { + input_file_stream->close(); + return "EOF"; + } else { + input_file_stream->seekg(0, input_file_stream->end); + } } } while(line[0] == '#' || line[0] == '\0'); @@ -103,7 +107,7 @@ std::string Trick::MonteVarFile::get_next_value() { void Trick::MonteVarFile::set_file_name(std::string in_file_name) { delete input_file_stream; - input_file_stream = new std::ifstream(); + input_file_stream = new std::ifstream(in_file_name.c_str(), std::ifstream::in); if (input_file_stream->fail()) { std::stringstream string_stream; @@ -112,6 +116,7 @@ void Trick::MonteVarFile::set_file_name(std::string in_file_name) { exec_terminate_with_return(-1, __FILE__, __LINE__, string_stream.str().c_str()); } + input_file_stream->close(); file_name = in_file_name; } diff --git a/trick_source/sim_services/MonteCarlo/test/MonteCarlo_eof_line b/trick_source/sim_services/MonteCarlo/test/MonteCarlo_eof_line new file mode 100644 index 00000000..23be7f23 --- /dev/null +++ b/trick_source/sim_services/MonteCarlo/test/MonteCarlo_eof_line @@ -0,0 +1 @@ +0 1.0000 1.5000 diff --git a/trick_source/sim_services/MonteCarlo/test/MonteCarlo_line_ended_eof b/trick_source/sim_services/MonteCarlo/test/MonteCarlo_line_ended_eof new file mode 100644 index 00000000..e1ed5117 --- /dev/null +++ b/trick_source/sim_services/MonteCarlo/test/MonteCarlo_line_ended_eof @@ -0,0 +1 @@ +0 1.0000 1.5000 \ No newline at end of file diff --git a/trick_source/sim_services/MonteCarlo/test/MonteCarlo_test.cpp b/trick_source/sim_services/MonteCarlo/test/MonteCarlo_test.cpp index 18879e65..f17e8d9c 100644 --- a/trick_source/sim_services/MonteCarlo/test/MonteCarlo_test.cpp +++ b/trick_source/sim_services/MonteCarlo/test/MonteCarlo_test.cpp @@ -319,8 +319,6 @@ TEST_F(MonteCarloTest, TestSlaves) { } TEST_F(MonteCarloTest, MonteVarFile) { - std::string buffer; - std::string buffer2; //req.add_requirement("3932595803"); // Test MonteVarFile @@ -331,6 +329,24 @@ TEST_F(MonteCarloTest, MonteVarFile) { EXPECT_EQ(exec.variables.size(), 1) ; } +TEST_F(MonteCarloTest, MonteVarFileWithEOFLine) { + Trick::MonteVarFile var0("time_to_fire_1", "MonteCarlo_eof_line", 2) ; + EXPECT_EQ(exec.variables.size(), 0) ; + exec.add_variable(&var0) ; + EXPECT_EQ(var0.get_next_value(), "time_to_fire_1 = 1.0000") ; + EXPECT_EQ(exec.variables.size(), 1) ; + EXPECT_EQ(var0.get_next_value(), "EOF") ; +} + +TEST_F(MonteCarloTest, MonteVarFileWithLineEndedEOF) { + Trick::MonteVarFile var0("time_to_fire_1", "MonteCarlo_line_ended_eof", 2) ; + EXPECT_EQ(exec.variables.size(), 0) ; + exec.add_variable(&var0) ; + EXPECT_EQ(var0.get_next_value(), "time_to_fire_1 = 1.0000") ; + EXPECT_EQ(exec.variables.size(), 1) ; + EXPECT_EQ(var0.get_next_value(), "EOF") ; +} + TEST_F(MonteCarloTest, MonteVarRandom_Gaussian) { std::string str; double value; diff --git a/trick_source/sim_services/RealtimeSync/RealtimeSync.cpp b/trick_source/sim_services/RealtimeSync/RealtimeSync.cpp index f79500ea..c2835b56 100644 --- a/trick_source/sim_services/RealtimeSync/RealtimeSync.cpp +++ b/trick_source/sim_services/RealtimeSync/RealtimeSync.cpp @@ -489,7 +489,7 @@ int Trick::RealtimeSync::shutdown() { os << "\n" << " REALTIME SHUTDOWN STATS:\n" ; if ( active ) { - os << " REALTIME TOTAL OVERRUNS: " << std::setw(12) << frame_overrun_cnt << "\n" ; + os << " REALTIME TOTAL OVERRUNS: " << std::setw(12) << total_overrun << "\n" ; } if ( sim_end_init_time != 0 ) { double init_time = (sim_end_init_time - sim_start_time) / (double)default_clock->clock_tics_per_sec ; diff --git a/trick_source/sim_services/ThreadBase/Makefile b/trick_source/sim_services/ThreadBase/Makefile index a181cedf..16b26fbc 100644 --- a/trick_source/sim_services/ThreadBase/Makefile +++ b/trick_source/sim_services/ThreadBase/Makefile @@ -1,5 +1,4 @@ - +TRICK_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../../..) include ${TRICK_HOME}/share/trick/makefiles/Makefile.common include ${TRICK_HOME}/share/trick/makefiles/Makefile.tricklib -include Makefile_deps - diff --git a/trick_source/sim_services/ThreadBase/ThreadBase.cpp b/trick_source/sim_services/ThreadBase/ThreadBase.cpp index 0873f770..b6ca3761 100644 --- a/trick_source/sim_services/ThreadBase/ThreadBase.cpp +++ b/trick_source/sim_services/ThreadBase/ThreadBase.cpp @@ -1,7 +1,7 @@ - #include #include #include +#include #if __linux #include @@ -159,8 +159,7 @@ int Trick::ThreadBase::execute_priority() { if ( rt_priority > 0 ) { if (sched_getparam((pid_t) 0, &sparams)) { - perror("Error getting process scheduling parameters."); - message_publish(MSG_ERROR, "Error %d when getting process scheduling parameters.\n", errno); + message_publish(MSG_ERROR, "Failed to get process scheduling parameters: %s\n", std::strerror(errno)); } else { /* Get maximum and minimum RT priority */ @@ -183,17 +182,13 @@ int Trick::ThreadBase::execute_priority() { if (pthread_getschedparam(pthread_self(), &sched_policy, &sparams)) { - perror("Error getting non-degrading priority."); - message_publish(MSG_ERROR, "Error %d when getting non-degrading priority.\n", errno); + message_publish(MSG_ERROR, "Failed to get process scheduling parameters: %s\n", std::strerror(errno)); } /* Set the process priority. */ sparams.sched_priority = proc_priority; if (pthread_setschedparam(pthread_self(), SCHED_FIFO, &sparams)) { - perror("Error setting non-degrading priority."); - message_publish(MSG_ERROR, "Error %d when setting non-degrading priority.\n", errno); - } else { - message_publish(MSG_INFO, "Thread %d: Using non degrading priority = %d.\n", pid, sparams.sched_priority); + message_publish(MSG_ERROR, "Failed to set thread priority: %s\n", std::strerror(errno)); } } } @@ -257,9 +252,7 @@ int Trick::ThreadBase::execute_priority() { ret = pthread_setschedparam(pthread_self(), sched_policy, ¶m); if (ret != 0) { - perror("Error setting Darwin thread priority."); - - message_publish(MSG_ERROR, "Error %d: Problem setting Darwin thread priority to %d.\n", errno, param.sched_priority); + message_publish(MSG_ERROR, "Failed to set Darwin thread priority to %d: %s\n", param.sched_priority, std::strerror(errno)); message_publish(MSG_ERROR, "This should correspond to a Trick CPU priority of %d.\n", (max_priority - proc_priority) + 1); message_publish(MSG_ERROR, "The current Darwin thread priority is %d.\n", prev_priority); message_publish(MSG_ERROR, "The Darwin thread priority range is %d:%d (min:max).\n", min_priority, max_priority); diff --git a/trick_source/sim_services/Timer/test/ITimer_test.cpp b/trick_source/sim_services/Timer/test/ITimer_test.cpp index cccb5df2..ffb7049c 100644 --- a/trick_source/sim_services/Timer/test/ITimer_test.cpp +++ b/trick_source/sim_services/Timer/test/ITimer_test.cpp @@ -60,13 +60,12 @@ TEST_F(ITimerTest, TimerNotEnabled) { //"The ITimer shall start if and only if the ITimer is enabled to do so."); - bool active_ch, enable_ch; + bool active_ch; Trick::ITimer *iTim; iTim = new Trick::ITimer; active_ch = iTim->active; - enable_ch = iTim->get_enabled(); sec = 0.05; iTim->init(); diff --git a/trick_source/sim_services/UdUnits/UdUnits.cpp b/trick_source/sim_services/UdUnits/UdUnits.cpp index 856bef63..12885216 100644 --- a/trick_source/sim_services/UdUnits/UdUnits.cpp +++ b/trick_source/sim_services/UdUnits/UdUnits.cpp @@ -21,6 +21,7 @@ int Trick::UdUnits::read_default_xml() { } int Trick::UdUnits::read_user_xml(std::string file_name) { + (void)file_name; return 0 ; } diff --git a/trick_source/sim_services/UnitTest/UnitTest.cpp b/trick_source/sim_services/UnitTest/UnitTest.cpp index f99e3860..07137f80 100644 --- a/trick_source/sim_services/UnitTest/UnitTest.cpp +++ b/trick_source/sim_services/UnitTest/UnitTest.cpp @@ -3,6 +3,7 @@ #include #include "trick/UnitTest.hh" +#include "trick/exec_proto.h" #include "trick/message_proto.h" #include "trick/message_type.h" @@ -55,6 +56,7 @@ void Trick::TestSuite::delete_test_results() { Trick::UnitTest::UnitTest() { the_unit_test_output = this ; enabled = false ; + exit_code_enabled = false ; file_name = std::string("test_details.xml") ; name = std::string("AllTests") ; } @@ -93,6 +95,11 @@ bool Trick::UnitTest::enable() { return(true) ; } +int Trick::UnitTest::set_exit_code_enabled(bool in_enable) { + exit_code_enabled = in_enable ; + return 0 ; +} + int Trick::UnitTest::set_test_name(std::string in_name) { name = in_name ; return 0 ; @@ -149,6 +156,10 @@ int Trick::UnitTest::write_output() { out << " " << std::endl ; } out << "" << std::endl ; + + if ( exit_code_enabled && num_failures > 0 ) { + exec_terminate_with_return( 1 , __FILE__ , __LINE__ , "Unit Test failure detected." ) ; + } } return(0) ; diff --git a/trick_source/sim_services/UnitTest/UnitTest_c_intf.cpp b/trick_source/sim_services/UnitTest/UnitTest_c_intf.cpp index dffc4cab..784ca603 100644 --- a/trick_source/sim_services/UnitTest/UnitTest_c_intf.cpp +++ b/trick_source/sim_services/UnitTest/UnitTest_c_intf.cpp @@ -6,6 +6,21 @@ extern Trick::UnitTest * the_unit_test_output ; +extern "C" int trick_test_enable() { + the_unit_test_output->enable() ; + return(0) ; +} + +extern "C" int trick_test_set_file_name( const char * in_file_name ) { + the_unit_test_output->set_file_name(in_file_name) ; + return(0) ; +} + +extern "C" int trick_test_set_test_name( const char * in_test_name ) { + the_unit_test_output->set_test_name(in_test_name) ; + return(0) ; +} + extern "C" int add_test_result( const char * in_test_suite_name , const char * in_test_case , const char * in_failure_string ) { if ( in_failure_string == NULL ) { in_failure_string = "" ; diff --git a/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp b/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp index f3137aaf..ed4fd5c3 100644 --- a/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp +++ b/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp @@ -26,12 +26,8 @@ Trick::VariableServerListenThread::VariableServerListenThread() : } Trick::VariableServerListenThread::~VariableServerListenThread() { - if ( listen_dev.hostname != NULL ) { free(listen_dev.hostname) ; - } - if ( listen_dev.error_handler != NULL ) { free(listen_dev.error_handler) ; - } } const char * Trick::VariableServerListenThread::get_hostname() { @@ -122,6 +118,7 @@ void * Trick::VariableServerListenThread::thread_body() { int mcast_socket ; struct sockaddr_in mcast_addr ; + struct sockaddr_in mcast_addr_legacy ; version = std::string(exec_get_current_version()) ; version.erase(version.find_last_not_of(" \t\f\v\n\r")+1); @@ -158,6 +155,11 @@ void * Trick::VariableServerListenThread::thread_body() { mcast_addr.sin_family = AF_INET; mcast_addr.sin_addr.s_addr = inet_addr("239.3.14.15"); mcast_addr.sin_port = htons((uint16_t) 9265); + + memset(&mcast_addr_legacy, 0, sizeof(mcast_addr_legacy)); + mcast_addr_legacy.sin_family = AF_INET; + mcast_addr_legacy.sin_addr.s_addr = inet_addr("224.3.14.15"); + mcast_addr_legacy.sin_port = htons((uint16_t) 9265); } while (1) { @@ -182,6 +184,7 @@ void * Trick::VariableServerListenThread::thread_body() { command_line_args_get_input_file() , version.c_str() , user_tag.c_str(), (unsigned short)listen_dev.port ) ; sendto(mcast_socket , buf1 , strlen(buf1) , 0 , (struct sockaddr *)&mcast_addr , (socklen_t)sizeof(mcast_addr)) ; + sendto(mcast_socket , buf1 , strlen(buf1) , 0 , (struct sockaddr *)&mcast_addr_legacy , (socklen_t)sizeof(mcast_addr)) ; } } diff --git a/trick_source/trick_swig/sim_services.i b/trick_source/trick_swig/sim_services.i index 9a4360d3..96e24547 100644 --- a/trick_source/trick_swig/sim_services.i +++ b/trick_source/trick_swig/sim_services.i @@ -115,11 +115,13 @@ #include "trick/AttributesMap.hh" #include "trick/sie_c_intf.h" #include "trick/MessageCout.hh" +#include "trick/MessageThreadedCout.hh" #include "trick/MessageFile.hh" #include "trick/MessageLCout.hh" #include "trick/MessagePublisher.hh" #include "trick/MessageSubscriber.hh" #include "trick/MessageTCDevice.hh" +#include "trick/Message_proto.hh" #include "trick/message_proto.h" #include "trick/MonteCarlo.hh" #include "trick/montecarlo_c_intf.h" diff --git a/trick_source/trick_utils/comm/Makefile b/trick_source/trick_utils/comm/Makefile index d684d29f..9284c570 100644 --- a/trick_source/trick_utils/comm/Makefile +++ b/trick_source/trick_utils/comm/Makefile @@ -1,3 +1,5 @@ +TRICK_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))../../..) + # set CONFIG_MK to allow compilation without running configure CONFIG_MK = 1 diff --git a/trick_source/trick_utils/comm/src/tc_connect.c b/trick_source/trick_utils/comm/src/tc_connect.c index c066af4d..3851afb5 100644 --- a/trick_source/trick_utils/comm/src/tc_connect.c +++ b/trick_source/trick_utils/comm/src/tc_connect.c @@ -3,6 +3,8 @@ * Establish a connection with a communications server */ +#include + #ifndef __WIN32__ #include #include @@ -86,7 +88,7 @@ int tc_connect_(TCDevice * device, const char *file, int line) the_socket = socket( TRICKCOMM_SOCKET_FAMILY, SOCK_STREAM, TRICKCOMM_SOCKET_PROTO ); if ( the_socket == TRICKCOMM_INVALID_SOCKET){ - trick_error_report(device->error_handler,TRICK_ERROR_ALERT, file, line, "%s: could not open socket\n", client_str); + trick_error_report(device->error_handler,TRICK_ERROR_ALERT, file, line, "%s: could not open socket: %s\n", client_str, strerror(errno)); return (TC_COULD_NOT_OPEN_SOCKET); } @@ -141,7 +143,7 @@ int tc_connect_(TCDevice * device, const char *file, int line) #endif if ( ret < 0) { - trick_error_report(device->error_handler,TRICK_ERROR_ALERT, file, line, "%s: could not connect to host\n", client_str); + trick_error_report(device->error_handler,TRICK_ERROR_ALERT, file, line, "%s: could not connect to host: %s\n", client_str, strerror(errno)); CLOSE_SOCKET(the_socket); return (TC_COULD_NOT_CONNECT); } diff --git a/trick_source/trick_utils/comm/src/tc_init.c b/trick_source/trick_utils/comm/src/tc_init.c index 164ce7d3..a82b628d 100644 --- a/trick_source/trick_utils/comm/src/tc_init.c +++ b/trick_source/trick_utils/comm/src/tc_init.c @@ -3,6 +3,8 @@ * Set up a device on which to listen for connections */ #include +#include +#include #ifndef __WIN32__ #include @@ -61,7 +63,7 @@ int tc_init_with_connection_info( TCDevice * listen_device, if (listen_socket == TRICKCOMM_INVALID_SOCKET) { trick_error_report(listen_device->error_handler, TRICK_ERROR_ALERT, __FILE__, __LINE__, - "could not open socket on port %d\n", (listen_device->port)); + "could not open socket on port %d: %s\n", listen_device->port, strerror(errno)); return (TC_COULD_NOT_OPEN_SOCKET); } @@ -105,7 +107,7 @@ int tc_init_with_connection_info( TCDevice * listen_device, if (bind(listen_socket, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) { trick_error_report(listen_device->error_handler, TRICK_ERROR_ADVISORY, __FILE__, __LINE__, - "could not bind socket for port %d\n", (listen_device->port)); + "could not bind socket for port %d: %s\n", listen_device->port, strerror(errno)); return (TC_COULD_NOT_BIND_SOCKET); } @@ -122,7 +124,7 @@ int tc_init_with_connection_info( TCDevice * listen_device, /* listen can get EADDRINUSE when server & client are same machine */ trick_error_report(listen_device->error_handler, TRICK_ERROR_ADVISORY, __FILE__, __LINE__, - "could not listen on port %d\n", (listen_device->port)); + "could not listen on port %d: %s\n", listen_device->port, strerror(errno)); return (TC_COULD_NOT_LISTEN_SOCKET); } } diff --git a/trick_source/trick_utils/comm/test/TCConnectTest.cpp b/trick_source/trick_utils/comm/test/TCConnectTest.cpp index d05e9719..e2cb8964 100644 --- a/trick_source/trick_utils/comm/test/TCConnectTest.cpp +++ b/trick_source/trick_utils/comm/test/TCConnectTest.cpp @@ -20,7 +20,7 @@ class TCConnectTest : public testing::Test { /* device */ device = (TCDevice *) malloc(sizeof(TCDevice)); memset( (void *)device,'\0',sizeof(TCDevice) ); - device->hostname = "127.0.0.1"; + device->hostname = strdup("127.0.0.1"); device->disabled = TC_COMM_FALSE; device->disable_handshaking = TC_COMM_DISABLED; strcpy(device->client_tag, ""); @@ -29,6 +29,7 @@ class TCConnectTest : public testing::Test { void TearDown(){ + free(device->hostname); free(device); } }; diff --git a/trick_source/trick_utils/math/src/RodriguesRotation.c b/trick_source/trick_utils/math/src/RodriguesRotation.c new file mode 100644 index 00000000..1ee0a705 --- /dev/null +++ b/trick_source/trick_utils/math/src/RodriguesRotation.c @@ -0,0 +1,45 @@ +#include +#include +#include + +void RotAboutLineByAngle(double R_out[3][3], double k[3], double theta) { + + double c = cos(theta); + double a = 1.0 - c; + double b = sin(theta); + double n[3]; + + V_NORM(n, k); + + /* Calculate the rotation matrix using the Rodrigues formula. */ + R_out[0][0] = c + 0 + n[0]*n[0]*a; + R_out[0][1] = 0 - n[2]*b + n[0]*n[1]*a; + R_out[0][2] = 0 + n[1]*b + n[0]*n[2]*a; + + R_out[1][0] = 0 + n[2]*b + n[0]*n[1]*a; + R_out[1][1] = c + 0 + n[1]*n[1]*a; + R_out[1][2] = 0 - n[0]*b + n[1]*n[2]*a; + + R_out[2][0] = 0 - n[1]*b + n[0]*n[2]*a; + R_out[2][1] = 0 + n[0]*b + n[1]*n[2]*a; + R_out[2][2] = c + 0 + n[2]*n[2]*a; + +} + +#define SMALL_NUMBER 1e-10 + +void RotVectorToNewOrientation(double R_out[3][3], double v[3], double w[3]) { + + double a = V_DOT(v,v); + double b = V_DOT(v,w); + double theta = acos(b/a); + + if ( fabs(theta) < SMALL_NUMBER ) { + M_IDENT(R_out); + } else { + double k[3],n[3]; + V_CROSS(k, v, w); + V_NORM(n, k); + RotAboutLineByAngle(R_out, n, theta); + } +} diff --git a/trick_source/trick_utils/math/src/deuler_123_quat.c b/trick_source/trick_utils/math/src/deuler_123_quat.c index b83ed6b0..5e0a3eab 100644 --- a/trick_source/trick_utils/math/src/deuler_123_quat.c +++ b/trick_source/trick_utils/math/src/deuler_123_quat.c @@ -1,6 +1,6 @@ /* PURPOSE: - (Generate a LELF_HANDED quaternion using an Euler ROLL_PITCH_YAW sequence + (Generate a LEFT_HANDED quaternion using an Euler ROLL_PITCH_YAW sequence OR generate an Euler ROLL_PITCH_YAW sequence using a quaternion.) PROGRAMMERS: @@ -19,7 +19,7 @@ int euler123_quat( double *prev) /* In: r Previous values of euler angles. */ { - double haft_angle[3]; + double half_angle[3]; double mat00, mat01, mat10, mat11, mat20, mat21, mat22; double s1; double c1; @@ -34,13 +34,13 @@ int euler123_quat( if (method == 0){ /* Compute sines and cosines of 0.5*eulers */ - V_SCALE(haft_angle, angle, 0.5); - s1 = sin(haft_angle[0]); - c1 = cos(haft_angle[0]); - s2 = sin(haft_angle[1]); - c2 = cos(haft_angle[1]); - s3 = sin(haft_angle[2]); - c3 = cos(haft_angle[2]); + V_SCALE(half_angle, angle, 0.5); + s1 = sin(half_angle[0]); + c1 = cos(half_angle[0]); + s2 = sin(half_angle[1]); + c2 = cos(half_angle[1]); + s3 = sin(half_angle[2]); + c3 = cos(half_angle[2]); quat[0] = c1*c2*c3 - s1*s2*s3; quat[1] = -c1*s2*s3 - s1*c2*c3; diff --git a/trick_source/trick_utils/math/src/deuler_132_quat.c b/trick_source/trick_utils/math/src/deuler_132_quat.c index efcac9c0..7b4c65d4 100644 --- a/trick_source/trick_utils/math/src/deuler_132_quat.c +++ b/trick_source/trick_utils/math/src/deuler_132_quat.c @@ -1,7 +1,7 @@ /* PURPOSE: - (Generate a LELF_HANDED quaternion using an Euler ROLL_YAW_PITCH sequence + (Generate a LEFT_HANDED quaternion using an Euler ROLL_YAW_PITCH sequence OR generate an Euler ROLL_YAW_PITCH sequence using a quaternion.) PROGRAMMERS: @@ -20,7 +20,7 @@ int euler132_quat( double *prev) /* In: r Previous values of euler angles. */ { - double haft_angle[3]; + double half_angle[3]; double mat00, mat01, mat02, mat10, mat11, mat12, mat20; double s1; double c1; @@ -34,13 +34,13 @@ int euler132_quat( if (method == 0){ /* Compute sines and cosines of 0.5*eulers */ - V_SCALE(haft_angle, angle, 0.5); - s1 = sin(haft_angle[0]); - c1 = cos(haft_angle[0]); - s2 = sin(haft_angle[1]); - c2 = cos(haft_angle[1]); - s3 = sin(haft_angle[2]); - c3 = cos(haft_angle[2]); + V_SCALE(half_angle, angle, 0.5); + s1 = sin(half_angle[0]); + c1 = cos(half_angle[0]); + s2 = sin(half_angle[1]); + c2 = cos(half_angle[1]); + s3 = sin(half_angle[2]); + c3 = cos(half_angle[2]); quat[0] = c1*c2*c3 + s1*s2*s3; quat[1] = -s1*c2*c3 + c1*s2*s3; diff --git a/trick_source/trick_utils/math/src/deuler_213_quat.c b/trick_source/trick_utils/math/src/deuler_213_quat.c index 79e66b24..ce90b5cc 100644 --- a/trick_source/trick_utils/math/src/deuler_213_quat.c +++ b/trick_source/trick_utils/math/src/deuler_213_quat.c @@ -1,6 +1,6 @@ /* PURPOSE: - (Generate a LELF_HANDED quaternion using an Euler PITCH_ROLL_YAW sequence + (Generate a LEFT_HANDED quaternion using an Euler PITCH_ROLL_YAW sequence OR generate an Euler PITCH_ROLL_YAW sequence using a quaternion.) PROGRAMMERS: @@ -19,7 +19,7 @@ int euler213_quat( double *prev) /* In: r Previous values of euler angles. */ { - double haft_angle[3]; + double half_angle[3]; double mat00, mat01, mat10, mat11, mat20, mat21, mat22; double s1; double c1; @@ -33,13 +33,13 @@ int euler213_quat( if (method == 0){ /* Compute sines and cosines of 0.5*eulers */ - V_SCALE(haft_angle, angle, 0.5); - s1 = sin(haft_angle[0]); - c1 = cos(haft_angle[0]); - s2 = sin(haft_angle[1]); - c2 = cos(haft_angle[1]); - s3 = sin(haft_angle[2]); - c3 = cos(haft_angle[2]); + V_SCALE(half_angle, angle, 0.5); + s1 = sin(half_angle[0]); + c1 = cos(half_angle[0]); + s2 = sin(half_angle[1]); + c2 = cos(half_angle[1]); + s3 = sin(half_angle[2]); + c3 = cos(half_angle[2]); quat[0] = c1*c2*c3 + s1*s2*s3; quat[1] = -c1*s2*c3 - s1*c2*s3; diff --git a/trick_source/trick_utils/math/src/deuler_231_quat.c b/trick_source/trick_utils/math/src/deuler_231_quat.c index 7925139b..54bb5fbf 100644 --- a/trick_source/trick_utils/math/src/deuler_231_quat.c +++ b/trick_source/trick_utils/math/src/deuler_231_quat.c @@ -1,6 +1,6 @@ /* PURPOSE: - (Generate a LELF_HANDED quaternion using an Euler PITCH_YAW_ROLL sequence + (Generate a LEFT_HANDED quaternion using an Euler PITCH_YAW_ROLL sequence OR generate an Euler PITCH_YAW_ROLL sequence using a quaternion.) PROGRAMMERS: @@ -19,7 +19,7 @@ int euler231_quat( double *prev) /* In: r Previous values of euler angles. */ { - double haft_angle[3]; + double half_angle[3]; double mat00, mat01, mat02, mat11, mat20, mat21, mat22; double s1; double c1; @@ -33,13 +33,13 @@ int euler231_quat( if (method == 0){ /* Compute sines and cosines of 0.5*eulers */ - V_SCALE(haft_angle, angle, 0.5); - s1 = sin(haft_angle[0]); - c1 = cos(haft_angle[0]); - s2 = sin(haft_angle[1]); - c2 = cos(haft_angle[1]); - s3 = sin(haft_angle[2]); - c3 = cos(haft_angle[2]); + V_SCALE(half_angle, angle, 0.5); + s1 = sin(half_angle[0]); + c1 = cos(half_angle[0]); + s2 = sin(half_angle[1]); + c2 = cos(half_angle[1]); + s3 = sin(half_angle[2]); + c3 = cos(half_angle[2]); quat[0] = c1*c2*c3 - s1*s2*s3; quat[1] = -c1*c2*s3 - s1*s2*c3; diff --git a/trick_source/trick_utils/math/src/deuler_312_quat.c b/trick_source/trick_utils/math/src/deuler_312_quat.c index 68072674..3e1bb2f1 100644 --- a/trick_source/trick_utils/math/src/deuler_312_quat.c +++ b/trick_source/trick_utils/math/src/deuler_312_quat.c @@ -1,6 +1,6 @@ /* PURPOSE: - (Generate a LELF_HANDED quaternion using an Euler YAW_ROLL_PITCH sequence + (Generate a LEFT_HANDED quaternion using an Euler YAW_ROLL_PITCH sequence OR generate an Euler YAW_ROLL_PITCH sequence using a quaternion.) PROGRAMMERS: @@ -19,7 +19,7 @@ int euler312_quat( double *prev) /* In: r Previous values of euler angles. */ { - double haft_angle[3]; + double half_angle[3]; double mat00, mat01, mat02, mat10, mat11, mat12, mat22; double s1; double c1; @@ -34,13 +34,13 @@ int euler312_quat( if (method == 0){ /* Compute sines and cosines of 0.5*eulers */ - V_SCALE(haft_angle, angle, 0.5); - s1 = sin(haft_angle[0]); - c1 = cos(haft_angle[0]); - s2 = sin(haft_angle[1]); - c2 = cos(haft_angle[1]); - s3 = sin(haft_angle[2]); - c3 = cos(haft_angle[2]); + V_SCALE(half_angle, angle, 0.5); + s1 = sin(half_angle[0]); + c1 = cos(half_angle[0]); + s2 = sin(half_angle[1]); + c2 = cos(half_angle[1]); + s3 = sin(half_angle[2]); + c3 = cos(half_angle[2]); quat[0] = c1*c2*c3 - s1*s2*s3; quat[1] = -c1*s2*c3 + s1*c2*s3; diff --git a/trick_source/trick_utils/math/src/deuler_321_quat.c b/trick_source/trick_utils/math/src/deuler_321_quat.c index 82ccba2a..c1d295dc 100644 --- a/trick_source/trick_utils/math/src/deuler_321_quat.c +++ b/trick_source/trick_utils/math/src/deuler_321_quat.c @@ -1,6 +1,6 @@ /* PURPOSE: - (Generate a LELF_HANDED quaternion using an Euler YAW_PITCH_ROLL sequence + (Generate a LEFT_HANDED quaternion using an Euler YAW_PITCH_ROLL sequence OR generate an Euler YAW_PITCH_ROLL sequence using a quaternion.) PROGRAMMERS: @@ -19,7 +19,7 @@ int euler321_quat( double *prev) /* In: r Previous values of euler angles. */ { - double haft_angle[3]; + double half_angle[3]; double mat00, mat01, mat02, mat12, mat20, mat21, mat22; double s1; double c1; @@ -34,13 +34,13 @@ int euler321_quat( if (method == 0){ /* Compute sines and cosines of 0.5*yaw, .5*pitch, and .5*roll */ - V_SCALE(haft_angle, angle, 0.5); - s1 = sin(haft_angle[0]); - c1 = cos(haft_angle[0]); - s2 = sin(haft_angle[1]); - c2 = cos(haft_angle[1]); - s3 = sin(haft_angle[2]); - c3 = cos(haft_angle[2]); + V_SCALE(half_angle, angle, 0.5); + s1 = sin(half_angle[0]); + c1 = cos(half_angle[0]); + s2 = sin(half_angle[1]); + c2 = cos(half_angle[1]); + s3 = sin(half_angle[2]); + c3 = cos(half_angle[2]); quat[0] = c3*c2*c1 + s3*s2*s1; quat[1] = -s3*c2*c1 + c3*s2*s1; diff --git a/trick_source/trick_utils/math/src/dm_invert.c b/trick_source/trick_utils/math/src/dm_invert.c index 76cbf6a0..6a4e0d3a 100644 --- a/trick_source/trick_utils/math/src/dm_invert.c +++ b/trick_source/trick_utils/math/src/dm_invert.c @@ -1,7 +1,7 @@ /* PURPOSE: (Invert a 3X3 matrix.) - ASSUMPTIONS AND LIMITATIONS: ((Determinate is non-zero)) + ASSUMPTIONS AND LIMITATIONS: ((Determinant is non-zero)) PROGRAMMERS: (((Robert W. Bailey) (LinCom Corporation) (4/1/91) (Trick-CR-00004) (Gravity / Inertial Frame Models))) */ @@ -10,30 +10,30 @@ int dm_invert(double inv[3][3], /* Out: The 3X3 inverse of matrix 'm' */ double m[3][3]) { /* In: A 3X3 matrix */ - double determinate; /* The determinate of the input 'm' matrix */ + double determinant; /* The determinant of the input 'm' matrix */ - /* Calculate the determinate and test it */ + /* Calculate the determinant and test it */ /* (Save the intermediate calculations in 'inv' for later use) */ inv[0][0] = m[1][1] * m[2][2] - m[2][1] * m[1][2]; inv[0][1] = m[2][1] * m[0][2] - m[0][1] * m[2][2]; inv[0][2] = m[0][1] * m[1][2] - m[1][1] * m[0][2]; - determinate = m[0][0] * inv[0][0] + m[1][0] * inv[0][1] + m[2][0] * inv[0][2]; - if (determinate == 0.0) { - fprintf(stderr, "trick_utils/math/dm_invert.c: 3x3 matrix has zero determinate\n"); + determinant = m[0][0] * inv[0][0] + m[1][0] * inv[0][1] + m[2][0] * inv[0][2]; + if (determinant == 0.0) { + fprintf(stderr, "trick_utils/math/dm_invert.c: 3x3 matrix has zero determinant\n"); return (TM_ZERO_DET); } /* Calculate the inverse matrix */ - inv[0][0] /= determinate; - inv[0][1] /= determinate; - inv[0][2] /= determinate; - inv[1][0] = (m[2][0] * m[1][2] - m[1][0] * m[2][2]) / determinate; - inv[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]) / determinate; - inv[1][2] = (m[1][0] * m[0][2] - m[0][0] * m[1][2]) / determinate; - inv[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]) / determinate; - inv[2][1] = (m[2][0] * m[0][1] - m[0][0] * m[2][1]) / determinate; - inv[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]) / determinate; + inv[0][0] /= determinant; + inv[0][1] /= determinant; + inv[0][2] /= determinant; + inv[1][0] = (m[2][0] * m[1][2] - m[1][0] * m[2][2]) / determinant; + inv[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]) / determinant; + inv[1][2] = (m[1][0] * m[0][2] - m[0][0] * m[1][2]) / determinant; + inv[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]) / determinant; + inv[2][1] = (m[2][0] * m[0][1] - m[0][0] * m[2][1]) / determinant; + inv[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]) / determinant; return (TM_SUCCESS); } diff --git a/trick_source/trick_utils/math/src/dm_invert_symm.c b/trick_source/trick_utils/math/src/dm_invert_symm.c index bdba9cad..8e04e84c 100644 --- a/trick_source/trick_utils/math/src/dm_invert_symm.c +++ b/trick_source/trick_utils/math/src/dm_invert_symm.c @@ -1,7 +1,7 @@ /* PURPOSE: (Invert a symmetric 3X3 matrix.) - ASSUMPTIONS AND LIMITATIONS: ((Matrix is symmetric) (Determinate is non-zero)) + ASSUMPTIONS AND LIMITATIONS: ((Matrix is symmetric) (Determinant is non-zero)) PROGRAMMERS: (((Robert W. Bailey) (LinCom Corporation) (4/1/91) (Trick-CR-00004) (Gravity / Inertial Frame Models))) */ @@ -11,30 +11,30 @@ int dm_invert_symm(double inv[3][3], /* Out: The 3X3 inverse of matrix 'm' */ double m[3][3]) { /* In: A 3X3 matrix */ - double determinate; /* The determinate of 'm' */ + double determinant; /* The determinant of 'm' */ - /* Calculate the determinate and test it */ + /* Calculate the determinant and test it */ inv[0][0] = m[1][1] * m[2][2] - m[2][1] * m[1][2]; inv[0][1] = m[2][1] * m[0][2] - m[0][1] * m[2][2]; inv[0][2] = m[0][1] * m[1][2] - m[1][1] * m[0][2]; - determinate = m[0][0] * inv[0][0] + m[1][0] * inv[0][1] + m[2][0] * inv[0][2]; + determinant = m[0][0] * inv[0][0] + m[1][0] * inv[0][1] + m[2][0] * inv[0][2]; - if (determinate == 0.0) { - fprintf(stderr, "trick_utils/math/dm_invert_symm.c: Tried to invert " "a 3x3 matrix with a zero determinate."); + if (determinant == 0.0) { + fprintf(stderr, "trick_utils/math/dm_invert_symm.c: Tried to invert " "a 3x3 matrix with a zero determinant."); return (TM_ZERO_DET); } /* Calculate the inverse matrix, and return '1' */ - inv[0][0] /= determinate; - inv[0][1] /= determinate; - inv[0][2] /= determinate; + inv[0][0] /= determinant; + inv[0][1] /= determinant; + inv[0][2] /= determinant; inv[1][0] = inv[0][1]; - inv[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]) / determinate; - inv[1][2] = (m[1][0] * m[0][2] - m[0][0] * m[1][2]) / determinate; + inv[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]) / determinant; + inv[1][2] = (m[1][0] * m[0][2] - m[0][0] * m[1][2]) / determinant; inv[2][0] = inv[0][2]; inv[2][1] = inv[1][2]; - inv[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]) / determinate; + inv[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]) / determinant; return (TM_SUCCESS); } diff --git a/trick_source/trick_utils/math/src/tm_print_error.c b/trick_source/trick_utils/math/src/tm_print_error.c index 0cc402f0..acf0eb85 100644 --- a/trick_source/trick_utils/math/src/tm_print_error.c +++ b/trick_source/trick_utils/math/src/tm_print_error.c @@ -23,7 +23,7 @@ static char *trick_math_errors[] = { /* 13 */ "WARNING: Passed value is beyond the range of the asin function, Euler angles set to NANs", /* 14 */ "ERROR: Invalid Euler Rotation Sequence Option", /* 15 */ "ERROR: Diagonal Element is too small", - /* 16 */ "ERROR: 3x3 matrix has zero determinate" + /* 16 */ "ERROR: 3x3 matrix has zero determinant" }; /* ENTRY POINT: */ diff --git a/trick_source/trick_utils/units/src/units_conv.c b/trick_source/trick_utils/units/src/units_conv.c index a5eafe7d..66d3b607 100644 --- a/trick_source/trick_utils/units/src/units_conv.c +++ b/trick_source/trick_utils/units/src/units_conv.c @@ -462,10 +462,10 @@ struct { { Mass , "Tg", "kg", "tera-grams", 7,Metric, {{ 0.0 , MILLI * TERA }} }, { Mass , "mt", "kg", "metric-tons", 1,Metric, {{ 0.0 , 1000.0 }} }, { Mass , "t", "kg", "metric-tons", 1,Metric, {{ 0.0 , 1000.0 }} }, - { Mass , "sl", "kg", "slugs", 1,English, {{ 0.0 , 14.5939029372064 }} }, - { Mass , "slug", "kg", "slugs", 1,English, {{ 0.0 , 14.5939029372064 }} }, - { Mass , "lbm", "kg", "pound(mass)", 1,English, {{ 0.0 , 0.4535923697760192 }} }, - { Mass , "lb", "kg", "pound(mass)", 1,English, {{ 0.0 , 0.4535923697760192 }} }, + { Mass , "sl", "kg", "slugs", 1,English, {{ 0.0 , 14.59390 }} }, + { Mass , "slug", "kg", "slugs", 1,English, {{ 0.0 , 14.59390 }} }, + { Mass , "lbm", "kg", "pound(mass)", 1,English, {{ 0.0 , 0.45359237 }} }, + { Mass , "lb", "kg", "pound(mass)", 1,English, {{ 0.0 , 0.45359237 }} }, { Force , "N", "N", "newtons", 1,Metric, {{ 0.0 , 1.0 }} }, { Force , "pN", "N", "pico-newtons", 7,Metric, {{ 0.0 , PICO }} }, @@ -480,9 +480,9 @@ struct { { Force , "MN", "N", "mega-newtons", 7,Metric, {{ 0.0 , MEGA }} }, { Force , "GN", "N", "giga-newtons", 7,Metric, {{ 0.0 , GIGA }} }, { Force , "TN", "N", "tera-newtons", 7,Metric, {{ 0.0 , TERA }} }, - { Force , "oz", "N", "ounces", 1,English, {{ 0.0 , 0.27801385 }} }, - { Force , "ozf", "N", "ounces", 1,English, {{ 0.0 , 0.27801385 }} }, - { Force , "lbf", "N", "pound(force)", 1,English, {{ 0.0 , 4.4482216152605 }} }, + { Force , "oz", "N", "ounces", 1,English, {{ 0.0 , 0.2780139 }} }, + { Force , "ozf", "N", "ounces", 1,English, {{ 0.0 , 0.2780139 }} }, + { Force , "lbf", "N", "pound(force)", 1,English, {{ 0.0 , 4.4482216152605 }} }, { Voltage , "v", "v", "volts", 1,Standard, {{ 0.0 , 1.0 }} }, { Voltage , "V", "v", "volts", 1,Standard, {{ 0.0 , 1.0 }} }, diff --git a/trick_source/trick_utils/units/test/UnitConvTestSuite.cpp b/trick_source/trick_utils/units/test/UnitConvTestSuite.cpp index 8db70784..931c2a55 100644 --- a/trick_source/trick_utils/units/test/UnitConvTestSuite.cpp +++ b/trick_source/trick_utils/units/test/UnitConvTestSuite.cpp @@ -2,7 +2,7 @@ #include #include "trick/units_conv.h" -#define TOL 1e-13 +#define TOL 1e-7 /* double tolerance(int exp) { @@ -65,7 +65,7 @@ TEST(UnitsInterface, Newton_to_Pound) pounds = convert_units(1.0, &Newton_to_Pound); - ASSERT_NEAR((1.0/(0.4535923697760192*0.3048)), pounds, TOL); + ASSERT_NEAR((1.0/(0.45359237*0.3048)), pounds, TOL); clean_up_Units_t(&Newton); clean_up_Units_t(&Pound); diff --git a/trick_source/trick_utils/units/test/UnitTestSuite.cpp b/trick_source/trick_utils/units/test/UnitTestSuite.cpp index 5a37dc77..901142f9 100644 --- a/trick_source/trick_utils/units/test/UnitTestSuite.cpp +++ b/trick_source/trick_utils/units/test/UnitTestSuite.cpp @@ -41,7 +41,7 @@ * **********************************************************************************************************/ -#define TOL 1e-13 +#define TOL 1e-7 #define PI 3.14159265358979323846 namespace Trick { @@ -364,12 +364,12 @@ TEST_F(UnitConversion, KilogramToKilogram) TEST_F(UnitConversion, KilogramToSlug) { - test_conversion_no_throw("kg", "sl", 0.0, (1.0/14.5939029372064), TOL); + test_conversion_no_throw("kg", "sl", 0.0, (1.0/14.59390), TOL); } TEST_F(UnitConversion, KilogramToPoundMass) { - test_conversion_no_throw("kg", "lbm", 0.0, (1.0/0.4535923697760192), TOL); + test_conversion_no_throw("kg", "lbm", 0.0, (1.0/0.45359237), TOL); } TEST_F(UnitConversion, KilogramToGram) @@ -401,12 +401,12 @@ TEST_F(UnitConversion, NewtonToKiloNewton) TEST_F(UnitConversion, NewtonToOunce) { - test_conversion_no_throw("N", "oz", 0.0, (16.0/4.4482216152605), tolerance(-7)); + test_conversion_no_throw("N", "oz", 0.0, 3.596944, tolerance(-5)); } TEST_F(UnitConversion, NewtonToPoundForce) { - test_conversion_no_throw("N", "lbf", 0.0, (1.0/4.4482216152605), TOL); + test_conversion_no_throw("N", "lbf", 0.0, 0.224809, TOL); } //Voltage Conversions @@ -634,12 +634,12 @@ TEST_F(UnitConversion, FahrenheitPerSecondToCelsiusPerMinute) TEST_F(UnitConversion, CompositeNewtonToCompositePoundForce) { - test_conversion_no_throw("kg*m/s2", "lbm*ft/s*s", 0.0, (1/(0.4535923697760192*0.3048)) , TOL); + test_conversion_no_throw("kg*m/s2", "lbm*ft/s*s", 0.0, (1/(0.45359237*0.3048)) , TOL); } TEST_F(UnitConversion, CompositePoundForceToCompositeNewton) { - test_conversion_no_throw("lbm*ft/s2", "kg*m/s*s", 0.0, (0.4535923697760192*0.3048), TOL); + test_conversion_no_throw("lbm*ft/s2", "kg*m/s*s", 0.0, (0.45359237*0.3048), TOL); } TEST_F(UnitConversion, FootPoundsToNewtonMeters) @@ -662,12 +662,12 @@ TEST_F(UnitConversion, FootPoundsToNewtonMetersWithConvertTo) TEST_F(UnitConversion, CompositePoundForceToCompositeNewtonCommutative) { - test_conversion_no_throw("lbm*ft/s*s", "m*kg/s2", 0.0, (0.4535923697760192*0.3048), TOL); + test_conversion_no_throw("lbm*ft/s*s", "m*kg/s2", 0.0, (0.45359237*0.3048), TOL); } TEST_F(UnitConversion, CompositeNewtonToCompositePoundForceCommutative) { - test_conversion_no_throw("m*kg/s2", "lbm*ft/s*s", 0.0, (1/(0.4535923697760192*0.3048)), TOL); + test_conversion_no_throw("m*kg/s2", "lbm*ft/s*s", 0.0, (1/(0.45359237*0.3048)), TOL); } //Collection of Denominators