mirror of
https://github.com/nasa/trick.git
synced 2025-02-20 17:22:52 +00:00
Merge branch 'master' into MakefileCleanup
This commit is contained in:
commit
9643311f4c
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
|
||||
|
@ -260,13 +260,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 +276,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:
|
||||
|
@ -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 &) {};
|
||||
|
||||
} ;
|
||||
|
||||
} ;
|
||||
|
@ -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 & color_code, std::string & message ) {
|
||||
buffer.assign(header, 0, max_len) ;
|
||||
buffer.append(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
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -45,6 +45,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:
|
||||
|
@ -19,6 +19,17 @@ extern "C" {
|
||||
$TRICK_HOME/trick_source/trick_utils/math/include/trick_math_proto.h
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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
|
||||
* Invert matrix using LU Decomposition method.
|
||||
|
@ -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" ;
|
||||
|
@ -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
|
||||
@ -161,7 +169,7 @@ sub write_makefile_swig() {
|
||||
print PY_LINK_LIST "build/init_swig_modules.o\n" ;
|
||||
print PY_LINK_LIST "build/top.o\n" ;
|
||||
|
||||
print MAKEFILE "SWIG_CFLAGS := -I../include \${PYTHON_INCLUDES} -Wno-shadow -Wno-missing-field-initializers
|
||||
print MAKEFILE "SWIG_CFLAGS := -I../include \${PYTHON_INCLUDES} -Wno-shadow -Wno-missing-field-initializers -Wno-unused-but-set-variable
|
||||
|
||||
ifeq (\$(IS_CC_CLANG), 1)
|
||||
SWIG_CFLAGS += -Wno-self-assign -Wno-sometimes-uninitialized -Wno-deprecated-register
|
||||
|
@ -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"} = "" ;
|
||||
|
@ -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@
|
||||
|
@ -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
|
||||
|
@ -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 Width: | Height: | 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 Width: | Height: | 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 Width: | Height: | 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 Width: | Height: | 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;
|
||||
}
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -164,6 +164,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,"%ud", 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,"%ud", 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,"%ud", 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
|
32
trick_source/data_products/Apps/trkConvert/LogFormatter.hh
Normal file
32
trick_source/data_products/Apps/trkConvert/LogFormatter.hh
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef LOG_FORMATTER
|
||||
#define LOG_FORMATTER
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class LogFormatter {
|
||||
|
||||
public:
|
||||
virtual void writeHeader(FILE* out_fp,
|
||||
int version,
|
||||
int endianness) = 0;
|
||||
|
||||
virtual void writeColumnLabel(FILE* out_fp,
|
||||
const char* name,
|
||||
const char* units) = 0;
|
||||
|
||||
virtual void writeColumnLabelSeparator(FILE* out_fp) = 0;
|
||||
virtual void writeDatumSeparator( FILE* out_fp) = 0;
|
||||
virtual void writeRecordSeparator(FILE* out_fp) = 0;
|
||||
virtual void writeDatum(FILE* out_fp, int8_t datum) = 0;
|
||||
virtual void writeDatum(FILE* out_fp, uint8_t datum) = 0;
|
||||
virtual void writeDatum(FILE* out_fp, int16_t datum) = 0;
|
||||
virtual void writeDatum(FILE* out_fp, uint16_t datum) = 0;
|
||||
virtual void writeDatum(FILE* out_fp, int32_t datum) = 0;
|
||||
virtual void writeDatum(FILE* out_fp, uint32_t datum) = 0;
|
||||
virtual void writeDatum(FILE* out_fp, int64_t datum) = 0;
|
||||
virtual void writeDatum(FILE* out_fp, uint64_t datum) = 0;
|
||||
virtual void writeDatum(FILE* out_fp, float datum) = 0;
|
||||
virtual void writeDatum(FILE* out_fp, double datum) = 0;
|
||||
virtual const char* extension() = 0;
|
||||
};
|
||||
#endif
|
@ -0,0 +1,25 @@
|
||||
#include "Varlist_Formatter.hh"
|
||||
/* ================================================================================
|
||||
* CLASS: Varlist_Formatter isa LogFormatter.
|
||||
* ================================================================================
|
||||
*/
|
||||
|
||||
void Varlist_Formatter::writeHeader(FILE* out_fp, int version, int endianness) {};
|
||||
void Varlist_Formatter::writeColumnLabel(FILE* out_fp, const char* name, const char* units) {
|
||||
fprintf(out_fp,"%s {%s}", name, units);
|
||||
}
|
||||
void Varlist_Formatter::writeColumnLabelSeparator(FILE* out_fp) { fprintf(out_fp,"\n"); }
|
||||
void Varlist_Formatter::writeDatumSeparator(FILE* out_fp __attribute__((unused))) {}
|
||||
void Varlist_Formatter::writeRecordSeparator(FILE* out_fp __attribute__((unused))) {}
|
||||
void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), int8_t datum __attribute__((unused))) {}
|
||||
void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), uint8_t datum __attribute__((unused))) {}
|
||||
void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), int16_t datum __attribute__((unused))) {}
|
||||
void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), uint16_t datum __attribute__((unused))) {}
|
||||
void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), int32_t datum __attribute__((unused))) {}
|
||||
void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), uint32_t datum __attribute__((unused))) {}
|
||||
void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), int64_t datum __attribute__((unused))) {}
|
||||
void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), uint64_t datum __attribute__((unused))) {}
|
||||
void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), float datum __attribute__((unused))) {}
|
||||
void Varlist_Formatter::writeDatum(FILE* out_fp __attribute__((unused)), double datum __attribute__((unused))) {}
|
||||
|
||||
const char* Varlist_Formatter::extension() { return ".varlist"; };
|
@ -0,0 +1,28 @@
|
||||
#ifndef VARLIST_FORMATTER
|
||||
#define VARLIST_FORMATTER
|
||||
|
||||
#include "LogFormatter.hh"
|
||||
/* ================================================================================
|
||||
* CLASS: Varlist_Formatter isa LogFormatter.
|
||||
* ================================================================================
|
||||
*/
|
||||
class Varlist_Formatter: public LogFormatter {
|
||||
public:
|
||||
void writeHeader(FILE* out_fp, int version, int endianness);
|
||||
void writeColumnLabel(FILE* out_fp, const char* name, const char* units);
|
||||
void writeColumnLabelSeparator(FILE* out_fp);
|
||||
void writeDatumSeparator(FILE* out_fp);
|
||||
void writeRecordSeparator(FILE* out_fp);
|
||||
void writeDatum(FILE* out_fp, int8_t datum);
|
||||
void writeDatum(FILE* out_fp, uint8_t datum);
|
||||
void writeDatum(FILE* out_fp, int16_t datum);
|
||||
void writeDatum(FILE* out_fp, uint16_t datum);
|
||||
void writeDatum(FILE* out_fp, int32_t datum);
|
||||
void writeDatum(FILE* out_fp, uint32_t datum);
|
||||
void writeDatum(FILE* out_fp, int64_t datum);
|
||||
void writeDatum(FILE* out_fp, uint64_t datum);
|
||||
void writeDatum(FILE* out_fp, float datum);
|
||||
void writeDatum(FILE* out_fp, double datum);
|
||||
const char* extension();
|
||||
};
|
||||
#endif
|
26
trick_source/data_products/Apps/trkConvert/makefile
Normal file
26
trick_source/data_products/Apps/trkConvert/makefile
Normal file
@ -0,0 +1,26 @@
|
||||
CPP = g++
|
||||
CC = gcc
|
||||
|
||||
CXXFLAGS =
|
||||
|
||||
MAIN = trkConvert
|
||||
|
||||
OBJECTS = CSV_Formatter.o Varlist_Formatter.o trkConvert.o
|
||||
|
||||
.c.o:
|
||||
${CC} ${CFLAGS} ${INCDIRS} -c $<
|
||||
|
||||
.cpp.o:
|
||||
${CPP} ${CFLAGS} ${INCDIRS} -c $<
|
||||
|
||||
all: install
|
||||
|
||||
trkConvert: $(OBJECTS)
|
||||
$(CPP) -o trkConvert $(OBJECTS)
|
||||
|
||||
install: trkConvert
|
||||
cp trkConvert $${TRICK_HOME}/bin/trick-trkConvert
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f trkConvert
|
395
trick_source/data_products/Apps/trkConvert/trkConvert.cpp
Normal file
395
trick_source/data_products/Apps/trkConvert/trkConvert.cpp
Normal file
@ -0,0 +1,395 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h> // Requires C99
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "LogFormatter.hh"
|
||||
#include "CSV_Formatter.hh"
|
||||
#include "Varlist_Formatter.hh"
|
||||
|
||||
typedef enum {
|
||||
TRICK_VOID = 0, /* No type */
|
||||
TRICK_CHARACTER = 1, /* (char) */
|
||||
TRICK_UNSIGNED_CHARACTER = 2, /* (unsigned char) */
|
||||
TRICK_STRING = 3, /* (char *) */
|
||||
TRICK_SHORT = 4, /* (short) */
|
||||
TRICK_UNSIGNED_SHORT = 5, /* (unsigned short) */
|
||||
TRICK_INTEGER = 6, /* (int) */
|
||||
TRICK_UNSIGNED_INTEGER = 7, /* (unsigned int) */
|
||||
TRICK_LONG = 8, /* (long) */
|
||||
TRICK_UNSIGNED_LONG = 9, /* (unsigned long) */
|
||||
TRICK_FLOAT = 10, /* (float) */
|
||||
TRICK_DOUBLE = 11, /* (double) */
|
||||
TRICK_BITFIELD = 12, /* (signed int : 1) */
|
||||
TRICK_UNSIGNED_BITFIELD = 13, /* (unsigned int : 1) */
|
||||
TRICK_LONG_LONG = 14, /* (long long) */
|
||||
TRICK_UNSIGNED_LONG_LONG = 15, /* (long long) */
|
||||
TRICK_FILE_PTR = 16, /* (file *) */
|
||||
TRICK_BOOLEAN = 17, /* (C++ boolean) */
|
||||
TRICK_WCHAR = 18, /* (wchar_t) */
|
||||
TRICK_WSTRING = 19, /* (wchar_t *) */
|
||||
TRICK_VOID_PTR = 20, /* an arbitrary address */
|
||||
TRICK_ENUMERATED = 21, /* User defined type (enumeration) */
|
||||
TRICK_STRUCTURED = 22, /* User defined type (struct/class) */
|
||||
TRICK_OPAQUE_TYPE = 23, /* User defined type (where type details are as yet unknown) */
|
||||
TRICK_STL = 24, /* Standard template library type */
|
||||
TRICK_NUMBER_OF_TYPES
|
||||
} TRICK_TYPE ;
|
||||
|
||||
class ReadException: public std::exception {
|
||||
virtual const char* what() const throw() {
|
||||
return "fread() failed.";
|
||||
}
|
||||
} readException;
|
||||
|
||||
/* ================================================================================
|
||||
* CLASS: ParamDescription
|
||||
* ================================================================================
|
||||
*/
|
||||
class ParamDescription {
|
||||
public:
|
||||
char* parameterName;
|
||||
char* unitsName;
|
||||
int32_t dataType;
|
||||
int32_t dataSize;
|
||||
|
||||
ParamDescription(){}
|
||||
ParamDescription(FILE* fp);
|
||||
};
|
||||
|
||||
ParamDescription::ParamDescription(FILE* in_fp){
|
||||
|
||||
int32_t nameStringLength;
|
||||
if ( fread( &nameStringLength, 1, 4, in_fp) != 4) throw readException;
|
||||
|
||||
parameterName = new char[nameStringLength+1];
|
||||
if ( fread( parameterName, 1, nameStringLength, in_fp) != (size_t)nameStringLength) throw readException;
|
||||
parameterName[nameStringLength] = 0;
|
||||
|
||||
int32_t unitsStringLength;
|
||||
if ( fread( &unitsStringLength, 1, 4 , in_fp) != 4) throw readException;
|
||||
|
||||
unitsName = new char[unitsStringLength+1];
|
||||
if ( fread( unitsName, 1, unitsStringLength, in_fp) != (size_t)unitsStringLength) throw readException;
|
||||
unitsName[unitsStringLength] = 0;
|
||||
|
||||
if ( fread( &dataType, 1, 4, in_fp) != 4) throw readException;
|
||||
if ( fread( &dataSize, 1, 4, in_fp) != 4) throw readException;
|
||||
}
|
||||
|
||||
/* ================================================================================
|
||||
* CLASS: DataLog
|
||||
* ================================================================================
|
||||
*/
|
||||
class DataLog {
|
||||
|
||||
public:
|
||||
std::string fileName;
|
||||
FILE* in_fp;
|
||||
int version;
|
||||
int endianness;
|
||||
uint32_t N_params;
|
||||
fpos_t dataPosition;
|
||||
int dataRecordSize;
|
||||
char* dataRecord;
|
||||
|
||||
static const int LittleEndian;
|
||||
static const int BigEndian;
|
||||
|
||||
std::vector<ParamDescription*> paramDescriptions;
|
||||
std::vector<int> paramOffsets;
|
||||
std::vector<bool> paramSelected;
|
||||
|
||||
DataLog(){}
|
||||
DataLog(std::string fileName);
|
||||
void selectAllParameters();
|
||||
void selectParameter(unsigned int index);
|
||||
void selectParameter(const char * paramName);
|
||||
void deselectParameter(unsigned int index);
|
||||
void formattedWrite(FILE* out_fp, LogFormatter* formatter);
|
||||
};
|
||||
|
||||
const int DataLog::LittleEndian = 1;
|
||||
const int DataLog::BigEndian = 2;
|
||||
|
||||
DataLog::DataLog(std::string file_name) {
|
||||
|
||||
fileName = file_name;
|
||||
in_fp = fopen(fileName.c_str(), "rb");
|
||||
|
||||
if (in_fp != NULL) {
|
||||
|
||||
char trick_header_string[11];
|
||||
if (fread( trick_header_string, 1, 10, in_fp) != 10) throw readException;
|
||||
trick_header_string[10] = 0;
|
||||
|
||||
if (!strncmp( trick_header_string, "Trick-", 6)) {
|
||||
|
||||
char version_txt[3];
|
||||
memcpy(version_txt, &trick_header_string[6], 2) ;
|
||||
version_txt[2] = 0;
|
||||
version = atoi(version_txt);
|
||||
|
||||
char endian_txt[2];
|
||||
memcpy(endian_txt, &trick_header_string[9], 1) ;
|
||||
endian_txt[1] = 0;
|
||||
|
||||
if (!strncmp( endian_txt, "L", 1)) {
|
||||
endianness = LittleEndian;
|
||||
} else if (!strncmp( endian_txt, "B", 1)) {
|
||||
endianness = BigEndian;
|
||||
} else {
|
||||
fprintf (stderr, "Trick header error. Endianness should be \"L\" or \"B\".");
|
||||
}
|
||||
|
||||
if (fread( &N_params, 1, 4, in_fp) != 4) throw readException;
|
||||
|
||||
dataRecordSize = 0;
|
||||
for (int ii = 0 ; ii < (int)N_params ; ii++ ) {
|
||||
ParamDescription* paramDescription = new ParamDescription(in_fp);
|
||||
paramDescriptions.push_back(paramDescription);
|
||||
paramOffsets.push_back(dataRecordSize);
|
||||
paramSelected.push_back(false);
|
||||
|
||||
dataRecordSize += paramDescription->dataSize;
|
||||
}
|
||||
dataRecord = new char[dataRecordSize];
|
||||
|
||||
// Time should always be selected.
|
||||
paramSelected[0] = true;
|
||||
|
||||
if (fgetpos(in_fp, &dataPosition) != 0) {
|
||||
fprintf (stderr, "fgetpos failure.\n");
|
||||
}
|
||||
} else {
|
||||
std::cerr << "File \"" << fileName << "\" isn't a Trick binary log file." << std::endl;
|
||||
}
|
||||
} else {
|
||||
std::cerr << "File \"" << fileName << "\" failed to open." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DataLog::selectAllParameters() {
|
||||
for (int ii = 1 ; ii < (int)N_params ; ii++ ) {
|
||||
paramSelected[ii] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DataLog::selectParameter(unsigned int index) {
|
||||
if ((index > 0) && (index < N_params)) {
|
||||
paramSelected[index] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DataLog::selectParameter(const char * paramName) {
|
||||
bool found = false;
|
||||
int ii = 1;
|
||||
while ((ii < (int)N_params) && (found == false)) {
|
||||
if ( !strcmp( paramName, paramDescriptions[ii]->parameterName )) {
|
||||
paramSelected[ii] = true;
|
||||
found = true;
|
||||
}
|
||||
ii ++;
|
||||
}
|
||||
}
|
||||
|
||||
void DataLog::deselectParameter(unsigned int index) {
|
||||
if ((index > 0) && (index < N_params)) {
|
||||
paramSelected[index] = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DataLog::formattedWrite(FILE* out_fp, LogFormatter* formatter) {
|
||||
|
||||
formatter->writeHeader(out_fp, version, endianness);
|
||||
formatter->writeColumnLabel(out_fp, paramDescriptions[0]->parameterName, paramDescriptions[0]->unitsName);
|
||||
for (int ii = 1; ii < (int)N_params ; ii++) {
|
||||
if (paramSelected[ii])
|
||||
formatter->writeColumnLabelSeparator(out_fp);
|
||||
formatter->writeColumnLabel(out_fp, paramDescriptions[ii]->parameterName, paramDescriptions[ii]->unitsName);
|
||||
}
|
||||
|
||||
if ( fsetpos(in_fp, &dataPosition) != 0 ) {
|
||||
fprintf(stderr,"fsetpos() error.\n");
|
||||
}
|
||||
while ( fread( dataRecord, 1, dataRecordSize, in_fp) == (size_t)dataRecordSize) {
|
||||
formatter->writeRecordSeparator(out_fp);
|
||||
formatter->writeDatum(out_fp, *(double*)&dataRecord[0]); // Time is always selected.
|
||||
for (int ii = 1 ; ii < (int)N_params ; ii++ ) {
|
||||
if (paramSelected[ii]) {
|
||||
formatter->writeDatumSeparator(out_fp);
|
||||
switch (paramDescriptions[ii]->dataType) {
|
||||
case TRICK_CHARACTER: { /*1*/
|
||||
formatter->writeDatum(out_fp, *(int8_t*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
case TRICK_UNSIGNED_CHARACTER: { /*2*/
|
||||
formatter->writeDatum(out_fp, *(uint8_t*)&dataRecord[paramOffsets[ii]]) ;
|
||||
} break;
|
||||
case TRICK_SHORT: { /*4*/
|
||||
formatter->writeDatum(out_fp, *(int16_t*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
case TRICK_UNSIGNED_SHORT: { /*5*/
|
||||
formatter->writeDatum(out_fp, *(uint16_t*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
case TRICK_INTEGER: {/*6*/
|
||||
formatter->writeDatum(out_fp, *(int32_t*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
case TRICK_UNSIGNED_INTEGER: {/*7*/
|
||||
formatter->writeDatum(out_fp, *(uint32_t*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
case TRICK_LONG: { /*8*/
|
||||
formatter->writeDatum(out_fp, *(int64_t*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
case TRICK_UNSIGNED_LONG: { /*9*/
|
||||
formatter->writeDatum(out_fp, *(uint64_t*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
case TRICK_FLOAT: {/*10*/
|
||||
formatter->writeDatum(out_fp, *(float*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
case TRICK_DOUBLE: {/*11*/
|
||||
formatter->writeDatum(out_fp, *(double*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
case TRICK_LONG_LONG: { /*14*/
|
||||
formatter->writeDatum(out_fp, *(int64_t*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
case TRICK_UNSIGNED_LONG_LONG: { /*15*/
|
||||
formatter->writeDatum(out_fp, *(uint64_t*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
case TRICK_BOOLEAN: { /*17*/
|
||||
formatter->writeDatum(out_fp, *(uint8_t*)&dataRecord[paramOffsets[ii]]);
|
||||
} break;
|
||||
default: {
|
||||
fprintf(stdout, "Unknown Data Type [%d] of size [%d] bytes.",
|
||||
paramDescriptions[ii]->dataType,
|
||||
paramDescriptions[ii]->dataSize);
|
||||
fflush(stdout);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
formatter->writeRecordSeparator(out_fp);
|
||||
}
|
||||
|
||||
static const char *usage_doc[] = {
|
||||
"----------------------------------------------------------------------------",
|
||||
" trkConvert - ",
|
||||
" ",
|
||||
" USAGE: trkConvert -help ",
|
||||
" trkConvert [-csv|-varlist] [-o <outfile>] <trk_file_name> ",
|
||||
" Options: ",
|
||||
" -help Print this message and exit. ",
|
||||
" -csv (the default) Generates a comma-separated value (CSV) file from ",
|
||||
" a Trick binary data file. CSV files are a common ",
|
||||
" means of sharing data between applications. ",
|
||||
" -varlist Generates a list of the names of the variables ",
|
||||
" the are recorded in the Trick binary data file. ",
|
||||
"----------------------------------------------------------------------------"};
|
||||
#define N_USAGE_LINES (sizeof(usage_doc)/sizeof(usage_doc[0]))
|
||||
|
||||
void print_doc(char *doc[], int nlines) {
|
||||
int i;
|
||||
for (i=0; i < nlines; i++) {
|
||||
std::cerr << doc[i] << '\n';
|
||||
}
|
||||
std::cerr.flush();
|
||||
}
|
||||
|
||||
void usage() {
|
||||
print_doc((char **)usage_doc,N_USAGE_LINES);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
std::string programName = argv[0];
|
||||
std::string trkFilePath;
|
||||
std::string trkBaseName;
|
||||
std::string outputName;
|
||||
FILE *fp;
|
||||
|
||||
CSV_Formatter csv_formatter;
|
||||
LogFormatter* logFormatter = &csv_formatter; // default formatter.
|
||||
Varlist_Formatter varlist_formatter;
|
||||
|
||||
if (argc <= 1 ) {
|
||||
std::cerr << programName << ": No arguments were supplied.\n";
|
||||
std::cerr.flush();
|
||||
usage();
|
||||
exit(1);
|
||||
} else {
|
||||
int i = 1;
|
||||
std::string arg;
|
||||
while ( i < argc ) {
|
||||
arg = argv[i];
|
||||
|
||||
if (arg.find("-") == 0) {
|
||||
if (arg == "-help" | arg == "--help" ) {
|
||||
usage();
|
||||
exit(0);
|
||||
} else if (arg == "-csv") {
|
||||
logFormatter = &csv_formatter;
|
||||
} else if (arg == "-varlist") {
|
||||
logFormatter = &varlist_formatter;
|
||||
} else if (arg == "-o") {
|
||||
i++;
|
||||
if (i<argc) {
|
||||
arg = argv[i];
|
||||
outputName = arg;
|
||||
} else {
|
||||
std::cerr << programName << ": -o option requires a filename." << std::endl;
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
std::cerr << programName << ": Invalid option \"" << arg << "\"." << std::endl;
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
} else if (arg.substr(arg.find_last_of(".")) == ".trk") {
|
||||
size_t pos;
|
||||
std::string trkFileName;
|
||||
trkFilePath = arg;
|
||||
if ((pos = trkFilePath.find_last_of("/")) != std::string::npos) {
|
||||
trkFileName = trkFilePath.substr(pos+1);
|
||||
} else {
|
||||
trkFileName = trkFilePath;
|
||||
}
|
||||
trkBaseName = trkFileName.substr(0, trkFileName.length()-4);
|
||||
} else {
|
||||
std::cerr << programName << ": Invalid argument \"" << arg << "\"." << std::endl;
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (trkFilePath.empty()) {
|
||||
std::cerr << programName << ": Missing .trk filename." << std::endl;
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (outputName.empty()) {
|
||||
|
||||
outputName = trkBaseName + logFormatter->extension();
|
||||
}
|
||||
|
||||
std::cout << programName << ": Input = \"" << trkFilePath << "\"." << std::endl;
|
||||
std::cout << programName << ": Output = \"" << outputName << "\"." << std::endl;
|
||||
|
||||
DataLog* datalog = new DataLog(trkFilePath);
|
||||
datalog->selectAllParameters();
|
||||
|
||||
if (( fp = fopen(outputName.c_str(), "w") ) != NULL) {
|
||||
datalog->formattedWrite(fp, logFormatter);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -18,6 +18,7 @@ LIBDIRS += fermi-ware
|
||||
endif
|
||||
|
||||
APPDIRS = DPX \
|
||||
Apps/trkConvert \
|
||||
Apps/Trk2csv \
|
||||
Apps/ExternalPrograms
|
||||
|
||||
|
@ -351,7 +351,7 @@ public class TrickQPActionController {
|
||||
|
||||
for (int i = 0; i < selectedVars.length; i++) {
|
||||
LogVar varFrom = (LogVar)selectedVars[i];
|
||||
if (varFrom.getName().matches("-(?!>)")) {
|
||||
if ((varFrom.getName().indexOf('-') != -1) || (varFrom.getName().matches("-(?!>)"))) {
|
||||
List<String> vars = get_components_from_array(varFrom.getName()); // expand variable
|
||||
if ( (selectedTreeNodes!=null) && (selectedTreeNodes.size()>0)
|
||||
&& (((CommonTreeNode)selectedTreeNodes.get(0)).getNodeType()!=CommonTreeNode.PLOTS_NODE) ) {
|
||||
|
@ -23,7 +23,11 @@
|
||||
|
||||
Trick::EventManager * the_em ;
|
||||
|
||||
Trick::EventManager::EventManager() { the_em = this ; }
|
||||
Trick::EventManager::EventManager() :
|
||||
active_events(NULL),
|
||||
num_active_events(0),
|
||||
num_allocated(0)
|
||||
{ the_em = this ; }
|
||||
|
||||
//Command to get the event object given the event's name
|
||||
Trick::Event * Trick::EventManager::get_event(std::string event_name) {
|
||||
@ -52,9 +56,14 @@ int Trick::EventManager::add_to_active_events(Trick::Event * in_event) {
|
||||
}
|
||||
num_active_events++;
|
||||
if (num_active_events == 1) {
|
||||
active_events = (Trick::Event **)TMM_declare_var_s("Trick::Event* [1]");
|
||||
} else {
|
||||
active_events = (Trick::Event **)TMM_resize_array_1d_a(active_events, num_active_events);
|
||||
active_events = (Trick::Event **)TMM_declare_var_s("Trick::Event* [100]");
|
||||
num_allocated = 100 ;
|
||||
} else if ( num_active_events >= num_allocated ) {
|
||||
num_allocated += 100 ;
|
||||
active_events = (Trick::Event **)TMM_resize_array_1d_a(active_events, num_allocated);
|
||||
for ( unsigned int ii = num_active_events ; ii < num_allocated ; ii++ ) {
|
||||
active_events[ii] = NULL ;
|
||||
}
|
||||
}
|
||||
active_events[num_active_events-1] = in_event ;
|
||||
return (0) ;
|
||||
@ -178,6 +187,10 @@ int Trick::EventManager::remove_event(Trick::Event * in_event) {
|
||||
|
||||
unsigned int ii , jj ;
|
||||
|
||||
if ( ! in_event ) {
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
if ( in_event->get_before_after() == Trick::EVENT_NOTARGET ) {
|
||||
/* If the event is cyclic, remove the event from the event processor on the event's thread */
|
||||
event_processors[in_event->get_thread()]->remove_event(in_event) ;
|
||||
@ -205,18 +218,18 @@ int Trick::EventManager::remove_event(Trick::Event * in_event) {
|
||||
active_events[jj - 1] = active_events[jj] ;
|
||||
}
|
||||
num_active_events-- ;
|
||||
if (num_active_events == 0) {
|
||||
TMM_delete_var_a(active_events);
|
||||
active_events = NULL;
|
||||
}
|
||||
else {
|
||||
active_events[num_active_events] = NULL ;
|
||||
}
|
||||
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
if (num_active_events == 0) {
|
||||
TMM_delete_var_a(active_events);
|
||||
active_events = NULL;
|
||||
}
|
||||
else {
|
||||
active_events = (Trick::Event **)TMM_resize_array_1d_a(active_events, num_active_events);
|
||||
}
|
||||
|
||||
if ( in_event->get_free_on_removal() ) {
|
||||
TMM_delete_var_a(in_event) ;
|
||||
}
|
||||
|
@ -42,14 +42,16 @@ int Trick::Executive::advance_sim_time() {
|
||||
/* Adjust time_tics if one of the threads has a job or async cycle time less than the main thread's next job */
|
||||
for (ii = 1; ii < threads.size() ; ii++) {
|
||||
Threads * curr_thread = threads[ii] ;
|
||||
if ( (curr_thread->process_type == PROCESS_TYPE_SCHEDULED) &&
|
||||
(curr_thread->job_queue.get_next_job_call_time() < time_tics) ) {
|
||||
time_tics = curr_thread->job_queue.get_next_job_call_time() ;
|
||||
}
|
||||
if ( (curr_thread->process_type == PROCESS_TYPE_AMF_CHILD ) &&
|
||||
(curr_thread->amf_cycle_tics > 0 ) &&
|
||||
(curr_thread->amf_next_tics < time_tics) ) {
|
||||
time_tics = curr_thread->amf_next_tics ;
|
||||
if ( curr_thread->enabled ) {
|
||||
if ( (curr_thread->process_type == PROCESS_TYPE_SCHEDULED) &&
|
||||
(curr_thread->job_queue.get_next_job_call_time() < time_tics) ) {
|
||||
time_tics = curr_thread->job_queue.get_next_job_call_time() ;
|
||||
}
|
||||
if ( (curr_thread->process_type == PROCESS_TYPE_AMF_CHILD ) &&
|
||||
(curr_thread->amf_cycle_tics > 0 ) &&
|
||||
(curr_thread->amf_next_tics < time_tics) ) {
|
||||
time_tics = curr_thread->amf_next_tics ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,26 +10,28 @@
|
||||
*/
|
||||
bool Trick::Executive::isThreadReadyToRun( Trick::Threads * curr_thread , long long time_ticks) {
|
||||
bool ret = false ;
|
||||
switch ( curr_thread->process_type ) {
|
||||
case Trick::PROCESS_TYPE_SCHEDULED:
|
||||
ret = true ;
|
||||
break ;
|
||||
case Trick::PROCESS_TYPE_AMF_CHILD:
|
||||
if ( curr_thread->amf_next_tics == time_ticks ) {
|
||||
if ( curr_thread->enabled ) {
|
||||
switch ( curr_thread->process_type ) {
|
||||
case Trick::PROCESS_TYPE_SCHEDULED:
|
||||
ret = true ;
|
||||
}
|
||||
break ;
|
||||
case Trick::PROCESS_TYPE_ASYNC_CHILD:
|
||||
if ( curr_thread->child_complete == true ) {
|
||||
if (curr_thread->amf_cycle_tics == 0 ) {
|
||||
break ;
|
||||
case Trick::PROCESS_TYPE_AMF_CHILD:
|
||||
if ( curr_thread->amf_next_tics == time_ticks ) {
|
||||
ret = true ;
|
||||
} else {
|
||||
if ( curr_thread->amf_next_tics == time_ticks ) {
|
||||
}
|
||||
break ;
|
||||
case Trick::PROCESS_TYPE_ASYNC_CHILD:
|
||||
if ( curr_thread->child_complete == true ) {
|
||||
if (curr_thread->amf_cycle_tics == 0 ) {
|
||||
ret = true ;
|
||||
} else {
|
||||
if ( curr_thread->amf_next_tics == time_ticks ) {
|
||||
ret = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
return ret ;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ int Trick::Executive::scheduled_thread_sync() {
|
||||
/* Wait for synchronous threads to finish before testing for adjusting time_tics */
|
||||
for (ii = 1; ii < threads.size() ; ii++) {
|
||||
Threads * curr_thread = threads[ii] ;
|
||||
if ( curr_thread->process_type == PROCESS_TYPE_SCHEDULED) {
|
||||
if ( curr_thread->enabled and curr_thread->process_type == PROCESS_TYPE_SCHEDULED) {
|
||||
while (curr_thread->child_complete == false ) {
|
||||
if (rt_nap == true) {
|
||||
RELEASE();
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "trick/FrameDataRecordGroup.hh"
|
||||
#include "trick/exec_proto.hh"
|
||||
#include "trick/exec_proto.h"
|
||||
#include "trick/clock_proto.h"
|
||||
#include "trick/data_record_proto.h"
|
||||
#include "trick/command_line_protos.h"
|
||||
#include "trick/message_proto.h"
|
||||
@ -20,7 +19,7 @@
|
||||
Trick::FrameLog * the_fl = NULL ;
|
||||
|
||||
//Constructor.
|
||||
Trick::FrameLog::FrameLog() {
|
||||
Trick::FrameLog::FrameLog(Trick::Clock & in_clock) : clock(in_clock) {
|
||||
frame_log_flag = false ;
|
||||
drg_trick = NULL ;
|
||||
drg_frame = NULL ;
|
||||
@ -342,7 +341,7 @@ int Trick::FrameLog::frame_clock_start(Trick::JobData * curr_job ) {
|
||||
/** @par Detailed Design: */
|
||||
if ( target_job != NULL ) {
|
||||
/** @li Set target job's start time. */
|
||||
target_job->rt_start_time = clock_time() ;
|
||||
target_job->rt_start_time = clock.clock_time() ;
|
||||
}
|
||||
|
||||
return(0) ;
|
||||
@ -359,7 +358,7 @@ int Trick::FrameLog::frame_clock_stop(Trick::JobData * curr_job) {
|
||||
if ( target_job != NULL ) {
|
||||
if ( target_job->rt_start_time >= 0 ) {
|
||||
/** @li Set current job's stop time and frame time. */
|
||||
target_job->rt_stop_time = clock_time() ;
|
||||
target_job->rt_stop_time = clock.clock_time() ;
|
||||
target_job->frame_time += (target_job->rt_stop_time - target_job->rt_start_time);
|
||||
thread = target_job->thread;
|
||||
|
||||
@ -678,6 +677,11 @@ int Trick::FrameLog::shutdown() {
|
||||
return(0) ;
|
||||
|
||||
}
|
||||
|
||||
void Trick::FrameLog::set_clock(Trick::Clock & in_clock) {
|
||||
clock = in_clock ;
|
||||
}
|
||||
|
||||
//Call all the Create routines for the DP directory and all DP files.
|
||||
int Trick::FrameLog::create_DP_files() {
|
||||
int ret=0;
|
||||
|
@ -71,9 +71,7 @@ int Trick::MessagePublisher::publish(int level , std::string message) {
|
||||
// multithreaded sims from interleaving header and message elements.
|
||||
std::ostringstream oss;
|
||||
oss << header << message ;
|
||||
std::cout << oss.str() << std::flush ;
|
||||
}
|
||||
return(0) ;
|
||||
std::cout << oss.str() << std::flush ; } return(0) ;
|
||||
|
||||
}
|
||||
|
||||
|
102
trick_source/sim_services/Message/MessageThreadedCout.cpp
Normal file
102
trick_source/sim_services/Message/MessageThreadedCout.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
|
||||
#include "trick/MessageThreadedCout.hh"
|
||||
#include "trick/message_type.h"
|
||||
#include "trick/release.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
Trick::MessageThreadedCout::MessageThreadedCout() :
|
||||
max_buffer_items(400),
|
||||
max_buffer_size(4000) ,
|
||||
print_immediate(false) ,
|
||||
copy_ptr(NULL),
|
||||
write_ptr(NULL) {
|
||||
/** By default, this subscriber is enabled when it is created. */
|
||||
Trick::MessageSubscriber::name = "threadedcout" ;
|
||||
Trick::ThreadBase::name = "threadedcout" ;
|
||||
color_code.reserve(6) ;
|
||||
StringNode * temp = new StringNode(max_buffer_size) ;
|
||||
write_ptr = copy_ptr = temp ;
|
||||
for ( unsigned int ii = 1 ; ii < max_buffer_items ; ii++ ) {
|
||||
temp = new StringNode(max_buffer_size) ;
|
||||
copy_ptr->next = temp ;
|
||||
copy_ptr = temp ;
|
||||
}
|
||||
copy_ptr->next = write_ptr ;
|
||||
copy_ptr = write_ptr ;
|
||||
|
||||
pthread_mutex_init(&write_mutex, NULL);
|
||||
}
|
||||
|
||||
int Trick::MessageThreadedCout::init() {
|
||||
create_thread() ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
void Trick::MessageThreadedCout::update( unsigned int level , std::string header , std::string message ) {
|
||||
|
||||
/** @li Prints the received message to the standard output stream. */
|
||||
if (enabled && level < 100 ) {
|
||||
switch (level) {
|
||||
case MSG_NORMAL :
|
||||
color_code = "\033[00m" ; // normal
|
||||
break ;
|
||||
case MSG_INFO :
|
||||
color_code = "\033[32m" ; // green
|
||||
break ;
|
||||
case MSG_WARNING :
|
||||
color_code = "\033[33m" ; // yellow
|
||||
break ;
|
||||
case MSG_ERROR :
|
||||
color_code = "\033[31m" ; // red
|
||||
break ;
|
||||
case MSG_DEBUG :
|
||||
color_code = "\033[36m" ; // cyan
|
||||
break ;
|
||||
default :
|
||||
color_code = "\033[00m" ; // normal
|
||||
break ;
|
||||
}
|
||||
|
||||
if ( copy_ptr->next != write_ptr ) {
|
||||
copy_ptr->copy(header, color_code, message) ;
|
||||
copy_ptr = copy_ptr->next ;
|
||||
// After shutdown the sim sends a termination message. print it now.
|
||||
if ( print_immediate ) {
|
||||
write_pending_messages() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void * Trick::MessageThreadedCout::thread_body() {
|
||||
while(1) {
|
||||
write_pending_messages() ;
|
||||
RELEASE() ;
|
||||
}
|
||||
}
|
||||
|
||||
void Trick::MessageThreadedCout::write_pending_messages() {
|
||||
pthread_mutex_lock(&write_mutex) ;
|
||||
while ( write_ptr != copy_ptr ) {
|
||||
std::cout << write_ptr->buffer << std::flush ;
|
||||
write_ptr = write_ptr->next ;
|
||||
}
|
||||
pthread_mutex_unlock(&write_mutex) ;
|
||||
}
|
||||
|
||||
int Trick::MessageThreadedCout::shutdown() {
|
||||
|
||||
write_pending_messages() ;
|
||||
// After shutdown print any late incoming messages immediately.
|
||||
print_immediate = true ;
|
||||
|
||||
//TODO: delete memory
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
void Trick::MessageThreadedCout::dump( std::ostream & oss ) {
|
||||
Trick::ThreadBase::dump(oss) ;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ void Trick::MonteCarlo::dispatch_run_to_slave(MonteRun *run, MonteSlave *slave)
|
||||
tc_write(&connection_device, (char*)&num_bytes, (int)sizeof(num_bytes));
|
||||
tc_write(&connection_device, (char*)buffer.c_str(), (int)buffer.length());
|
||||
|
||||
if (verbosity >= INFORMATIONAL) {
|
||||
if (verbosity >= ALL) {
|
||||
message_publish(MSG_INFO, "Parameterization of run %d :\n%s\n", run->id, buffer.c_str()) ;
|
||||
}
|
||||
|
||||
|
@ -397,24 +397,15 @@ Trick::MonteRun *Trick::MonteCarlo::get_next_dispatch() {
|
||||
/** <ul><li> While there are remaining runs: */
|
||||
while (!runs.empty()) {
|
||||
MonteRun *curr_run = runs.front();
|
||||
/** <ul><li> If this run hasn't been dispatched before: */
|
||||
if (curr_run->num_tries == 0) {
|
||||
/** <li> If it is in range, return it. </ul>*/
|
||||
if (in_range(curr_run)) {
|
||||
return curr_run;
|
||||
/** <li> Otherwise, run the pre run jobs and dequeue it. */
|
||||
} else {
|
||||
if (verbosity >= ALL) {
|
||||
message_publish(MSG_WARNING, "Monte [Master] Run %d is out of range and has been skipped.\n", curr_run->id) ;
|
||||
}
|
||||
prepare_run(curr_run);
|
||||
}
|
||||
/**
|
||||
* <li> If this run has been dispatched before, it may have been requeued due to a slave timeout for which the slave
|
||||
* later returned results. In such a case, do not dispatch it again (return NULL). Otherwise, return it.
|
||||
*/
|
||||
} else if (curr_run->exit_status == MonteRun::INCOMPLETE) {
|
||||
/** <li> If it is in range, return it. </ul>*/
|
||||
if (in_range(curr_run)) {
|
||||
return curr_run;
|
||||
/** <li> Otherwise, run the pre run jobs and dequeue it. */
|
||||
} else {
|
||||
if (verbosity >= ALL) {
|
||||
message_publish(MSG_WARNING, "Monte [Master] Run %d is out of range and has been skipped.\n", curr_run->id) ;
|
||||
}
|
||||
prepare_run(curr_run);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
@ -81,7 +81,14 @@ void Trick::MonteCarlo::handle_run_data(Trick::MonteSlave& slave) {
|
||||
}
|
||||
|
||||
/**
|
||||
* <ul><li> This run may have already been resolved by another slave if
|
||||
* <ul><li> Try to remove this run from the queue in case it was requeue by #check_timeouts.
|
||||
* This covers the case in which the master determines that a slave has timed out, requeues
|
||||
* the run, and then the slave reports results.
|
||||
*/
|
||||
dequeue_run(slave.current_run);
|
||||
|
||||
/**
|
||||
* <li> This run may have already been resolved by another slave if
|
||||
* this slave was marked as having timed out. If that is the case,
|
||||
* discard these results.
|
||||
*/
|
||||
|
@ -16,7 +16,7 @@ int Trick::MonteCarlo::execute_as_slave() {
|
||||
/** <ul><li> On a blocking read, wait for a MonteSlave::Command from the master. */
|
||||
if (tc_accept(&listen_device, &connection_device) != TC_SUCCESS) {
|
||||
if (verbosity >= ERROR) {
|
||||
message_publish(MSG_ERROR, "Monte [%s:%d] Lost connection to Master.\nShutting down.\n",
|
||||
message_publish(MSG_ERROR, "Monte [%s:%d] Lost connection to Master. Shutting down.\n",
|
||||
machine_name.c_str(), slave_id) ;
|
||||
}
|
||||
slave_shutdown();
|
||||
@ -24,7 +24,7 @@ int Trick::MonteCarlo::execute_as_slave() {
|
||||
int command;
|
||||
if (tc_read(&connection_device, (char *)&command, (int)sizeof(command)) != (int)sizeof(command)) {
|
||||
if (verbosity >= ERROR) {
|
||||
message_publish(MSG_ERROR, "Monte [%s:%d] Lost connection to Master while receiving instructions.\nShutting down.\n",
|
||||
message_publish(MSG_ERROR, "Monte [%s:%d] Lost connection to Master while receiving instructions. Shutting down.\n",
|
||||
machine_name.c_str(), slave_id) ;
|
||||
}
|
||||
slave_shutdown();
|
||||
@ -44,7 +44,7 @@ int Trick::MonteCarlo::execute_as_slave() {
|
||||
case MonteSlave::SHUTDOWN:
|
||||
/** <li> MonteSlave::SHUTDOWN: Call #slave_shutdown. */
|
||||
if (verbosity >= INFORMATIONAL) {
|
||||
message_publish(MSG_INFO, "Monte [%s:%d] Shutdown command received from Master.\nShutting down.\n",
|
||||
message_publish(MSG_INFO, "Monte [%s:%d] Shutdown command received from Master. Shutting down.\n",
|
||||
machine_name.c_str(), slave_id) ;
|
||||
}
|
||||
slave_shutdown();
|
||||
@ -60,7 +60,7 @@ int Trick::MonteCarlo::execute_as_slave() {
|
||||
default:
|
||||
/** <li> default: Call #slave_shutdown. */
|
||||
if (verbosity >= ERROR) {
|
||||
message_publish(MSG_ERROR, "Monte [%s:%d] Unrecognized command %d received from Master.\nShutting down.\n",
|
||||
message_publish(MSG_ERROR, "Monte [%s:%d] Unrecognized command %d received from Master. Shutting down.\n",
|
||||
machine_name.c_str(), slave_id, command) ;
|
||||
}
|
||||
slave_shutdown();
|
||||
|
@ -40,7 +40,7 @@ void Trick::MonteCarlo::initialize_slave(Trick::MonteSlave* slave_to_init) {
|
||||
}
|
||||
|
||||
if (!slave_to_init->S_main_name.compare("")) {
|
||||
slave_to_init->S_main_name = "./S_main_${TRICK_HOST_CPU}.exe";
|
||||
slave_to_init->S_main_name = "./S_main_*.exe";
|
||||
}
|
||||
|
||||
/** <li> Append the S_main executable and slave-specific arguments. */
|
||||
|
@ -45,8 +45,12 @@ std::string Trick::MonteVarFile::get_next_value() {
|
||||
std::getline(*input_file_stream, line);
|
||||
|
||||
if(input_file_stream->eof()) {
|
||||
input_file_stream->close();
|
||||
return "EOF";
|
||||
if (line.empty()) {
|
||||
input_file_stream->close();
|
||||
return "EOF";
|
||||
} else {
|
||||
input_file_stream->seekg(0, input_file_stream->end);
|
||||
}
|
||||
}
|
||||
}
|
||||
while(line[0] == '#' || line[0] == '\0');
|
||||
|
@ -0,0 +1 @@
|
||||
0 1.0000 1.5000
|
@ -0,0 +1 @@
|
||||
0 1.0000 1.5000
|
@ -319,8 +319,6 @@ TEST_F(MonteCarloTest, TestSlaves) {
|
||||
}
|
||||
|
||||
TEST_F(MonteCarloTest, MonteVarFile) {
|
||||
std::string buffer;
|
||||
std::string buffer2;
|
||||
//req.add_requirement("3932595803");
|
||||
|
||||
// Test MonteVarFile
|
||||
@ -331,6 +329,24 @@ TEST_F(MonteCarloTest, MonteVarFile) {
|
||||
EXPECT_EQ(exec.variables.size(), 1) ;
|
||||
}
|
||||
|
||||
TEST_F(MonteCarloTest, MonteVarFileWithEOFLine) {
|
||||
Trick::MonteVarFile var0("time_to_fire_1", "MonteCarlo_eof_line", 2) ;
|
||||
EXPECT_EQ(exec.variables.size(), 0) ;
|
||||
exec.add_variable(&var0) ;
|
||||
EXPECT_EQ(var0.get_next_value(), "time_to_fire_1 = 1.0000") ;
|
||||
EXPECT_EQ(exec.variables.size(), 1) ;
|
||||
EXPECT_EQ(var0.get_next_value(), "EOF") ;
|
||||
}
|
||||
|
||||
TEST_F(MonteCarloTest, MonteVarFileWithLineEndedEOF) {
|
||||
Trick::MonteVarFile var0("time_to_fire_1", "MonteCarlo_line_ended_eof", 2) ;
|
||||
EXPECT_EQ(exec.variables.size(), 0) ;
|
||||
exec.add_variable(&var0) ;
|
||||
EXPECT_EQ(var0.get_next_value(), "time_to_fire_1 = 1.0000") ;
|
||||
EXPECT_EQ(exec.variables.size(), 1) ;
|
||||
EXPECT_EQ(var0.get_next_value(), "EOF") ;
|
||||
}
|
||||
|
||||
TEST_F(MonteCarloTest, MonteVarRandom_Gaussian) {
|
||||
std::string str;
|
||||
double value;
|
||||
|
@ -489,7 +489,7 @@ int Trick::RealtimeSync::shutdown() {
|
||||
os << "\n" <<
|
||||
" REALTIME SHUTDOWN STATS:\n" ;
|
||||
if ( active ) {
|
||||
os << " REALTIME TOTAL OVERRUNS: " << std::setw(12) << frame_overrun_cnt << "\n" ;
|
||||
os << " REALTIME TOTAL OVERRUNS: " << std::setw(12) << total_overrun << "\n" ;
|
||||
}
|
||||
if ( sim_end_init_time != 0 ) {
|
||||
double init_time = (sim_end_init_time - sim_start_time) / (double)default_clock->clock_tics_per_sec ;
|
||||
|
@ -6,6 +6,21 @@
|
||||
|
||||
extern Trick::UnitTest * the_unit_test_output ;
|
||||
|
||||
extern "C" int trick_test_enable() {
|
||||
the_unit_test_output->enable() ;
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
extern "C" int trick_test_set_file_name( const char * in_file_name ) {
|
||||
the_unit_test_output->set_file_name(in_file_name) ;
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
extern "C" int trick_test_set_test_name( const char * in_test_name ) {
|
||||
the_unit_test_output->set_test_name(in_test_name) ;
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
extern "C" int add_test_result( const char * in_test_suite_name , const char * in_test_case , const char * in_failure_string ) {
|
||||
if ( in_failure_string == NULL ) {
|
||||
in_failure_string = "" ;
|
||||
|
@ -118,6 +118,7 @@ void * Trick::VariableServerListenThread::thread_body() {
|
||||
|
||||
int mcast_socket ;
|
||||
struct sockaddr_in mcast_addr ;
|
||||
struct sockaddr_in mcast_addr_legacy ;
|
||||
|
||||
version = std::string(exec_get_current_version()) ;
|
||||
version.erase(version.find_last_not_of(" \t\f\v\n\r")+1);
|
||||
@ -154,6 +155,11 @@ void * Trick::VariableServerListenThread::thread_body() {
|
||||
mcast_addr.sin_family = AF_INET;
|
||||
mcast_addr.sin_addr.s_addr = inet_addr("239.3.14.15");
|
||||
mcast_addr.sin_port = htons((uint16_t) 9265);
|
||||
|
||||
memset(&mcast_addr_legacy, 0, sizeof(mcast_addr_legacy));
|
||||
mcast_addr_legacy.sin_family = AF_INET;
|
||||
mcast_addr_legacy.sin_addr.s_addr = inet_addr("224.3.14.15");
|
||||
mcast_addr_legacy.sin_port = htons((uint16_t) 9265);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
@ -178,6 +184,7 @@ void * Trick::VariableServerListenThread::thread_body() {
|
||||
command_line_args_get_input_file() , version.c_str() , user_tag.c_str(), (unsigned short)listen_dev.port ) ;
|
||||
|
||||
sendto(mcast_socket , buf1 , strlen(buf1) , 0 , (struct sockaddr *)&mcast_addr , (socklen_t)sizeof(mcast_addr)) ;
|
||||
sendto(mcast_socket , buf1 , strlen(buf1) , 0 , (struct sockaddr *)&mcast_addr_legacy , (socklen_t)sizeof(mcast_addr)) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,11 +115,13 @@
|
||||
#include "trick/AttributesMap.hh"
|
||||
#include "trick/sie_c_intf.h"
|
||||
#include "trick/MessageCout.hh"
|
||||
#include "trick/MessageThreadedCout.hh"
|
||||
#include "trick/MessageFile.hh"
|
||||
#include "trick/MessageLCout.hh"
|
||||
#include "trick/MessagePublisher.hh"
|
||||
#include "trick/MessageSubscriber.hh"
|
||||
#include "trick/MessageTCDevice.hh"
|
||||
#include "trick/Message_proto.hh"
|
||||
#include "trick/message_proto.h"
|
||||
#include "trick/MonteCarlo.hh"
|
||||
#include "trick/montecarlo_c_intf.h"
|
||||
|
@ -19,7 +19,7 @@ class TCConnectTest : public testing::Test {
|
||||
|
||||
/* device */
|
||||
device = (TCDevice *) malloc(sizeof(TCDevice));
|
||||
memset( (void *)device,'\0',sizeof(device) );
|
||||
memset( (void *)device,'\0',sizeof(TCDevice) );
|
||||
device->hostname = strdup("127.0.0.1");
|
||||
device->disabled = TC_COMM_FALSE;
|
||||
device->disable_handshaking = TC_COMM_DISABLED;
|
||||
@ -29,6 +29,7 @@ class TCConnectTest : public testing::Test {
|
||||
|
||||
void TearDown(){
|
||||
|
||||
free(device->hostname);
|
||||
free(device);
|
||||
}
|
||||
};
|
||||
|
26
trick_source/trick_utils/math/src/RodriquesRotation.c
Normal file
26
trick_source/trick_utils/math/src/RodriquesRotation.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <math.h>
|
||||
|
||||
void RotAboutLineByAngle(double C_out[3][3], double k[3], double theta) {
|
||||
|
||||
double c = cos(theta);
|
||||
double a = 1.0 - c;
|
||||
double b = sin(theta);
|
||||
|
||||
/* Normalize the rotation axis vector */
|
||||
double length = sqrt(k[0]*k[0] + k[1]*k[1] + k[2]*k[2]);
|
||||
double n[3] = {k[0]/length, k[1]/length, k[2]/length};
|
||||
|
||||
/* Calculate the rotation matrix using the Rodrigues formula. */
|
||||
C_out[0][0] = c + 0 + n[0]*n[0]*a;
|
||||
C_out[0][1] = 0 - n[2]*b + n[0]*n[1]*a;
|
||||
C_out[0][2] = 0 + n[1]*b + n[0]*n[2]*a;
|
||||
|
||||
C_out[1][0] = 0 + n[2]*b + n[0]*n[1]*a;
|
||||
C_out[1][1] = c + 0 + n[1]*n[1]*a;
|
||||
C_out[1][2] = 0 - n[0]*b + n[1]*n[2]*a;
|
||||
|
||||
C_out[2][0] = 0 - n[1]*b + n[0]*n[2]*a;
|
||||
C_out[2][1] = 0 + n[0]*b + n[1]*n[2]*a;
|
||||
C_out[2][2] = c + 0 + n[2]*n[2]*a;
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
PURPOSE:
|
||||
(Generate a LELF_HANDED quaternion using an Euler ROLL_PITCH_YAW sequence
|
||||
(Generate a LEFT_HANDED quaternion using an Euler ROLL_PITCH_YAW sequence
|
||||
OR generate an Euler ROLL_PITCH_YAW sequence using a quaternion.)
|
||||
|
||||
PROGRAMMERS:
|
||||
@ -19,7 +19,7 @@ int euler123_quat(
|
||||
double *prev) /* In: r Previous values of euler angles. */
|
||||
{
|
||||
|
||||
double haft_angle[3];
|
||||
double half_angle[3];
|
||||
double mat00, mat01, mat10, mat11, mat20, mat21, mat22;
|
||||
double s1;
|
||||
double c1;
|
||||
@ -34,13 +34,13 @@ int euler123_quat(
|
||||
if (method == 0){
|
||||
|
||||
/* Compute sines and cosines of 0.5*eulers */
|
||||
V_SCALE(haft_angle, angle, 0.5);
|
||||
s1 = sin(haft_angle[0]);
|
||||
c1 = cos(haft_angle[0]);
|
||||
s2 = sin(haft_angle[1]);
|
||||
c2 = cos(haft_angle[1]);
|
||||
s3 = sin(haft_angle[2]);
|
||||
c3 = cos(haft_angle[2]);
|
||||
V_SCALE(half_angle, angle, 0.5);
|
||||
s1 = sin(half_angle[0]);
|
||||
c1 = cos(half_angle[0]);
|
||||
s2 = sin(half_angle[1]);
|
||||
c2 = cos(half_angle[1]);
|
||||
s3 = sin(half_angle[2]);
|
||||
c3 = cos(half_angle[2]);
|
||||
|
||||
quat[0] = c1*c2*c3 - s1*s2*s3;
|
||||
quat[1] = -c1*s2*s3 - s1*c2*c3;
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
/*
|
||||
PURPOSE:
|
||||
(Generate a LELF_HANDED quaternion using an Euler ROLL_YAW_PITCH sequence
|
||||
(Generate a LEFT_HANDED quaternion using an Euler ROLL_YAW_PITCH sequence
|
||||
OR generate an Euler ROLL_YAW_PITCH sequence using a quaternion.)
|
||||
|
||||
PROGRAMMERS:
|
||||
@ -20,7 +20,7 @@ int euler132_quat(
|
||||
double *prev) /* In: r Previous values of euler angles. */
|
||||
{
|
||||
|
||||
double haft_angle[3];
|
||||
double half_angle[3];
|
||||
double mat00, mat01, mat02, mat10, mat11, mat12, mat20;
|
||||
double s1;
|
||||
double c1;
|
||||
@ -34,13 +34,13 @@ int euler132_quat(
|
||||
|
||||
if (method == 0){
|
||||
/* Compute sines and cosines of 0.5*eulers */
|
||||
V_SCALE(haft_angle, angle, 0.5);
|
||||
s1 = sin(haft_angle[0]);
|
||||
c1 = cos(haft_angle[0]);
|
||||
s2 = sin(haft_angle[1]);
|
||||
c2 = cos(haft_angle[1]);
|
||||
s3 = sin(haft_angle[2]);
|
||||
c3 = cos(haft_angle[2]);
|
||||
V_SCALE(half_angle, angle, 0.5);
|
||||
s1 = sin(half_angle[0]);
|
||||
c1 = cos(half_angle[0]);
|
||||
s2 = sin(half_angle[1]);
|
||||
c2 = cos(half_angle[1]);
|
||||
s3 = sin(half_angle[2]);
|
||||
c3 = cos(half_angle[2]);
|
||||
|
||||
quat[0] = c1*c2*c3 + s1*s2*s3;
|
||||
quat[1] = -s1*c2*c3 + c1*s2*s3;
|
||||
|
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