mirror of
https://github.com/nasa/trick.git
synced 2025-02-25 18:51:23 +00:00
Merge github.com/trick 17.3.0 updates to developer.nasa.gov/trick
This commit is contained in:
commit
8bba7ac30f
.gitignoreMakefile
autoconf
bin
configureinclude/trick
ClassicCheckPointAgent.hhDRBinary.hhDataRecordDispatcher.hhDataRecordGroup.hhEventManager.hhFrameLog.hhIPPythonEvent.hhIntegLoopManager.hhIntegLoopScheduler.hhJobData.hhMemoryManager.hhMessageFile.hhMessageSubscriber.hhMessageTCDevice.hhMessageThreadedCout.hhRodriguesRotation.hScheduledJobQueue.hhScheduler.hhSimObject.hhUnitTest.hhcheckpoint_map.hhcheckpoint_pair.hhcheckpoint_queue.hhcheckpoint_sequence_stl.hhcheckpoint_stack.hhconstant.hdata_record_proto.hfiles_to_ICG.hhmessage_type.hparameter_types.hrelease.hsim_mode.htrick_math_proto.htrick_tests.h
libexec/trick
share
doc/trick
trick
makefiles
pymods/trick
sim_objects
test
trick_sims
Cannon/models
cannon/gravity/src
graphics
SIM_msd
Modified_data
README.mdRUN_critdamp
RUN_nodamp
RUN_overdamp
RUN_test
RUN_underdamp
S_defineS_overrides.mkimages
models
trick_source
codegen/Interface_Code_Gen
FieldDescription.cppFieldVisitor.cppFindTrickICG.cppFindTrickICG.hhPrintAttributes.cppPrintAttributes.hhPrintFileContentsBase.cppmain.cpp
data_products
1
.gitignore
vendored
1
.gitignore
vendored
@ -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
|
||||
|
13
Makefile
13
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
|
||||
|
@ -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([])
|
||||
|
18
bin/trick-CP
18
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 [32mTrick Build Process Complete[00m)
|
||||
@ -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 = [36m$(TRICK_CFLAGS)[0m)
|
||||
$(info TRICK_CXXFLAGS = [36m$(TRICK_CXXFLAGS)[0m)
|
||||
endif
|
||||
endif
|
||||
|
||||
else
|
||||
all:
|
||||
|
@ -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.
|
||||
|
@ -117,7 +117,7 @@ namespace Trick {
|
||||
|
||||
private:
|
||||
/** The log file.\n */
|
||||
int fp ; /**< trick_io(**) trick_units(--) */
|
||||
int fd ; /**< trick_io(**) trick_units(--) */
|
||||
|
||||
} ;
|
||||
|
||||
|
@ -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 ) ;
|
||||
|
||||
|
@ -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 <dr_group>.set_max_file_size(<buffer_type>) @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:
|
||||
|
@ -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(**) */
|
||||
|
||||
|
@ -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<std::string> trick_jobs; // ** vector containing all trick job names
|
||||
std::vector<std::string> 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 &) {};
|
||||
|
||||
} ;
|
||||
|
||||
} ;
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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<const char*>& 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<const char*>& 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);
|
||||
|
||||
|
@ -59,7 +59,7 @@ namespace Trick {
|
||||
@brief Initializes this subscriber.
|
||||
@return always 0
|
||||
*/
|
||||
int init() ;
|
||||
virtual int init() ;
|
||||
|
||||
protected:
|
||||
/** The output file stream. \n */
|
||||
|
@ -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 ; } ;
|
||||
|
||||
} ;
|
||||
|
||||
}
|
||||
|
@ -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(--) */
|
||||
|
78
include/trick/MessageThreadedCout.hh
Normal file
78
include/trick/MessageThreadedCout.hh
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
PURPOSE:
|
||||
(Print messages to std::cout on a seperate thread)
|
||||
*/
|
||||
|
||||
#ifndef MESSAGETHREADEDCOUT_HH
|
||||
#define MESSAGETHREADEDCOUT_HH
|
||||
|
||||
#include <iostream>
|
||||
#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
|
||||
|
32
include/trick/RodriguesRotation.h
Normal file
32
include/trick/RodriguesRotation.h
Normal file
@ -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
|
@ -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) ;
|
||||
|
@ -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 ;
|
||||
|
@ -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
|
||||
|
@ -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() ;
|
||||
} ;
|
||||
|
||||
|
@ -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<typename STL::key_type &>(iter->first) ,
|
||||
object_name + "_" + var_name + "_keys", index_string.str() ) ;
|
||||
std::ostringstream index_string ;
|
||||
index_string << ii ;
|
||||
checkpoint_stl( const_cast<typename STL::key_type &>(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<typename STL::key_type &>(iter->first) ,
|
||||
object_name + "_" + var_name + "_keys", index_string.str() ) ;
|
||||
std::ostringstream index_string ;
|
||||
index_string << ii ;
|
||||
checkpoint_stl( const_cast<typename STL::key_type &>(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 ;
|
||||
|
@ -38,17 +38,21 @@ int checkpoint_stl(std::pair<FIRST , SECOND> & 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<FIRST , SECOND> & 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 ;
|
||||
}
|
||||
|
@ -47,12 +47,14 @@ int checkpoint_stl(std::queue<ITEM_TYPE,_Sequence> & 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<ITEM_TYPE,_Sequence> & 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<ITEM_TYPE, _Container, _Compare> & 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<ITEM_TYPE, _Container, _Compare> & 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() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 ;
|
||||
|
@ -44,12 +44,14 @@ int checkpoint_stl(std::stack<ITEM_TYPE,_Sequence> & 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<ITEM_TYPE,_Sequence> & 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() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 ) ;
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -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 <stdint.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:
|
||||
|
@ -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.
|
||||
*/
|
||||
|
||||
|
@ -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" {
|
||||
|
@ -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 ) ;
|
||||
|
@ -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" ;
|
||||
|
BIN
libexec/trick/java/lib/JUnitXmlFormatter.jar
Normal file
BIN
libexec/trick/java/lib/JUnitXmlFormatter.jar
Normal file
Binary file not shown.
@ -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}
|
||||
|
@ -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 ;
|
||||
|
@ -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 "[95mSWIG Skip[39m TRICK_EXCLUDE: [4m$path[24m$1\n" if $verbose_build ;
|
||||
next outer ;
|
||||
}
|
||||
if ( abs_path($word) =~ /^\Q$path\E(.*)/ ) {
|
||||
print "[95mSWIG Skip[39m TRICK_EXCLUDE: [4m$path[24m$1\n" if $verbose_build ;
|
||||
next outer ;
|
||||
}
|
||||
}
|
||||
|
||||
# skip paths in TRICK_SWIG_EXCLUDE
|
||||
@ -103,6 +107,10 @@ sub read_files_to_process() {
|
||||
print "[95mSWIG Skip[39m TRICK_SWIG_EXCLUDE: [4m$path[24m$1\n" if $verbose_build ;
|
||||
next outer ;
|
||||
}
|
||||
if ( abs_path($word) =~ /^\Q$path\E(.*)/ ) {
|
||||
print "[95mSWIG Skip[39m TRICK_SWIG_EXCLUDE: [4m$path[24m$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
|
||||
|
@ -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"} = "" ;
|
||||
|
@ -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 ;
|
||||
|
@ -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/ ) {
|
||||
|
BIN
share/doc/trick/Trick17_Tutorial_Review.pdf
Normal file
BIN
share/doc/trick/Trick17_Tutorial_Review.pdf
Normal file
Binary file not shown.
BIN
share/doc/trick/Trick17_Tutorial_Review.pptx
Normal file
BIN
share/doc/trick/Trick17_Tutorial_Review.pptx
Normal file
Binary file not shown.
@ -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)
|
||||
|
@ -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@
|
||||
|
0
pymods/trick/tests/test_variable_server.py → share/trick/pymods/trick/tests/test_variable_server.py
0
pymods/trick/tests/test_variable_server.py → share/trick/pymods/trick/tests/test_variable_server.py
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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 ;
|
||||
|
@ -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) ;
|
||||
}
|
||||
|
@ -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"
|
||||
|
BIN
trick_sims/Cannon/models/graphics/resources/CannonBoom.wav
Normal file
BIN
trick_sims/Cannon/models/graphics/resources/CannonBoom.wav
Normal file
Binary file not shown.
BIN
trick_sims/Cannon/models/graphics/resources/Explosion.wav
Normal file
BIN
trick_sims/Cannon/models/graphics/resources/Explosion.wav
Normal file
Binary file not shown.
@ -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:
|
||||
|
7
trick_sims/SIM_msd/Modified_data/realtime.py
Normal file
7
trick_sims/SIM_msd/Modified_data/realtime.py
Normal file
@ -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)
|
84
trick_sims/SIM_msd/README.md
Normal file
84
trick_sims/SIM_msd/README.md
Normal file
@ -0,0 +1,84 @@
|
||||
# SIM_MSD
|
||||
|
||||
SIM\_MSD is a simulator for a mass-spring-damper system.
|
||||
|
||||

|
||||
|
||||
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:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### 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)
|
23
trick_sims/SIM_msd/RUN_critdamp/input.py
Normal file
23
trick_sims/SIM_msd/RUN_critdamp/input.py
Normal file
@ -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)
|
23
trick_sims/SIM_msd/RUN_nodamp/input.py
Normal file
23
trick_sims/SIM_msd/RUN_nodamp/input.py
Normal file
@ -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)
|
23
trick_sims/SIM_msd/RUN_overdamp/input.py
Normal file
23
trick_sims/SIM_msd/RUN_overdamp/input.py
Normal file
@ -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)
|
21
trick_sims/SIM_msd/RUN_test/input.py
Normal file
21
trick_sims/SIM_msd/RUN_test/input.py
Normal file
@ -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)
|
23
trick_sims/SIM_msd/RUN_underdamp/input.py
Normal file
23
trick_sims/SIM_msd/RUN_underdamp/input.py
Normal file
@ -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)
|
33
trick_sims/SIM_msd/S_define
Normal file
33
trick_sims/SIM_msd/S_define
Normal file
@ -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 ;
|
2
trick_sims/SIM_msd/S_overrides.mk
Normal file
2
trick_sims/SIM_msd/S_overrides.mk
Normal file
@ -0,0 +1,2 @@
|
||||
TRICK_CFLAGS += -Imodels
|
||||
TRICK_CXXFLAGS += -Imodels
|
BIN
trick_sims/SIM_msd/images/MSD0.png
Normal file
BIN
trick_sims/SIM_msd/images/MSD0.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 14 KiB |
BIN
trick_sims/SIM_msd/images/MSD1.png
Normal file
BIN
trick_sims/SIM_msd/images/MSD1.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 27 KiB |
BIN
trick_sims/SIM_msd/images/MSD2.png
Normal file
BIN
trick_sims/SIM_msd/images/MSD2.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 10 KiB |
BIN
trick_sims/SIM_msd/images/MSD3.png
Normal file
BIN
trick_sims/SIM_msd/images/MSD3.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 18 KiB |
200
trick_sims/SIM_msd/models/graphics/MSD/src/MsdController.java
Normal file
200
trick_sims/SIM_msd/models/graphics/MSD/src/MsdController.java
Normal file
@ -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
|
||||
|
||||
|
||||
}
|
50
trick_sims/SIM_msd/models/graphics/MSD/src/MsdDisplay.java
Normal file
50
trick_sims/SIM_msd/models/graphics/MSD/src/MsdDisplay.java
Normal file
@ -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);
|
||||
}
|
||||
|
||||
}
|
218
trick_sims/SIM_msd/models/graphics/MSD/src/MsdGui.java
Normal file
218
trick_sims/SIM_msd/models/graphics/MSD/src/MsdGui.java
Normal file
@ -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
|
||||
|
||||
}
|
||||
}
|
24
trick_sims/SIM_msd/models/graphics/MSD/src/MsdUtils.java
Normal file
24
trick_sims/SIM_msd/models/graphics/MSD/src/MsdUtils.java
Normal file
@ -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 <port-number>\n"
|
||||
+ "----------------------------------------------------------------------\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TrickSimMode {
|
||||
public static final int INIT = 0;
|
||||
public static final int FREEZE = 1;
|
||||
public static final int RUN = 5;
|
||||
}
|
183
trick_sims/SIM_msd/models/graphics/MSD/src/MsdView.java
Normal file
183
trick_sims/SIM_msd/models/graphics/MSD/src/MsdView.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
36
trick_sims/SIM_msd/models/graphics/Makefile
Normal file
36
trick_sims/SIM_msd/models/graphics/Makefile
Normal file
@ -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 "-------------------------------------------------------------------------------"
|
48
trick_sims/SIM_msd/models/msd/include/msd.hh
Normal file
48
trick_sims/SIM_msd/models/msd/include/msd.hh
Normal file
@ -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 */
|
17
trick_sims/SIM_msd/models/msd/include/msd_numeric.hh
Normal file
17
trick_sims/SIM_msd/models/msd/include/msd_numeric.hh
Normal file
@ -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
|
19
trick_sims/SIM_msd/models/msd/src/msd.cpp
Normal file
19
trick_sims/SIM_msd/models/msd/src/msd.cpp
Normal file
@ -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 <math.h>
|
||||
#include "../include/msd_numeric.hh"
|
||||
#include <float.h>
|
||||
|
||||
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 */}
|
15
trick_sims/SIM_msd/models/msd/src/msd_deriv.cpp
Normal file
15
trick_sims/SIM_msd/models/msd/src/msd_deriv.cpp
Normal file
@ -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 <math.h>
|
||||
|
||||
int MSD::state_deriv(void) {
|
||||
/* system equation for second derivitive */
|
||||
a = (F - b*v - k*x)/m;
|
||||
|
||||
return(0);
|
||||
}
|
28
trick_sims/SIM_msd/models/msd/src/msd_init.cpp
Normal file
28
trick_sims/SIM_msd/models/msd/src/msd_init.cpp
Normal file
@ -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;
|
||||
}
|
31
trick_sims/SIM_msd/models/msd/src/msd_integ.cpp
Normal file
31
trick_sims/SIM_msd/models/msd/src/msd_integ.cpp
Normal file
@ -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 <math.h>
|
||||
|
||||
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);
|
||||
}
|
17
trick_sims/SIM_msd/models/msd/src/msd_shutdown.cpp
Normal file
17
trick_sims/SIM_msd/models/msd/src/msd_shutdown.cpp
Normal file
@ -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 <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
@ -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 ) ;
|
||||
}
|
||||
|
@ -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, "<bool") ;
|
||||
}
|
||||
while ((pos = tst_string.find(" _Bool")) != std::string::npos ) {
|
||||
@ -474,6 +482,12 @@ bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
|
||||
return false ;
|
||||
}
|
||||
|
||||
// If the type is a private embedded class there will not be any io_src code for the type. Don't create attributes
|
||||
if ( CXXRecordVisitor::isPrivateEmbeddedClass(tst_string) ) {
|
||||
//std::cout << "Type is a private embedded class!" << std::endl ;
|
||||
fdes->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 */
|
||||
|
@ -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") ) {
|
||||
|
@ -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() ;
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <libgen.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@ -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<std::string>& 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;
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
2
trick_source/data_products/.gitignore
vendored
2
trick_source/data_products/.gitignore
vendored
@ -1 +1,3 @@
|
||||
fermi-ware
|
||||
Apps/trkConvert/*.o
|
||||
Apps/trkConvert/trkConvert
|
||||
|
24
trick_source/data_products/Apps/trkConvert/CSV_Formatter.cpp
Normal file
24
trick_source/data_products/Apps/trkConvert/CSV_Formatter.cpp
Normal file
@ -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"; };
|
27
trick_source/data_products/Apps/trkConvert/CSV_Formatter.hh
Normal file
27
trick_source/data_products/Apps/trkConvert/CSV_Formatter.hh
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
#ifndef CSV_FORMATTER
|
||||
#define CSV_FORMATTER
|
||||
|
||||
#include <stdio.h>
|
||||
#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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user