Commit Graph

54 Commits

Author SHA1 Message Date
Keith Vetter
f2e93ac490
Fix for assigning to non-existent variables (#1708) (#1718)
* Fix for assigning to non-existent variables (#1708)

This fix modifies Trick's convert_swig script.  It
adds a directive to not accept dynamic attributes.
The directive will ensure that modelers do not
assign to non-existent parameter in their input files.

The prior fix (issues #1288 and/or #1603) did not
cover C structures, so this commit is really an
addendum to that fix.  With this commit, the convert_swig
script will generate a non-dynamic directive foreach
class and structure.

This fix also stops generating swig interface code
for typedef structure definitions since swig only
produces an interface to the actual typedef name.
For example, with this typedef:

typedef struct StructureName {
   double  main_engine_thrust;  /* N Thrust of main engine */
   struct StructureName* next;  /* ** Next pointer */
} TypeDefName;

swig creates an interface for "TypeDefName", and not
"StructureName", so there is no need for Trick to
produce anything in regards "StructureName".

* Fix for issue with classes defined in ifndef SWIG block

convert_swig takes in the raw header and does no preprocessing,
so blocks of c/c++ header code which are meant to be skipped
by Swig are processed by convert_swig.  This causes an issue
with the generated python code that try to access classes
that are ifndef SWIGed out.

To fix this, check for class existence in the generated python
code e.g:

if 'MomMom' in globals():
    MomMom.__setattr__ = _swig_setattr_nondynamic_instance_variable(object.__setattr__)

* Fix for assignment to swig_double and swig_int primitives

The previous commit(s) on this branch fixed bad assignments
like (misspell position an attribute of BSTATE_IN):
ball.state.input.positiaaaan = 4.0

This commit fixes bad assignments to leaf/primitive attributes
like (try to add attribute to primitive/leaf double type):

ball.state.input.position.fred = 4.0

* Moved _swig_setattr_nondynamic_instance_variable to right after each class in process_class and removed duplicate _swig_setattr_nondynamic_instance_variable blocks for classes that are not in a namespace.

* Add the call for __setattr__ for class templates.

---------

Co-authored-by: Hong Chen <hong.chen-1@nasa.gov>
2024-07-16 10:34:02 -05:00
jmpenn
5065d96a15
Pre-increment (rather than post-increment) STL iterators in for loops… (#1692)
* Pre-increment (rather than post-increment) STL iterators in for loops. #1594

* Fix a goof. #1594
2024-04-18 11:41:35 -05:00
Hong Chen
73cc7aabfa
checksum enhancement for -d option (#1579)
* Added input file SHA1 info being printed on screen when running a trick sim with -d option (basically verifying the input)

* Added additional checks to exclude trace info printout for file in /opt or .trick/ or not a real file such as <xxx> as the filename.
2023-10-05 10:56:02 -05:00
Isaac Rowe
68ced2a1ad
Ensure swig target folder is created (#1533) 2023-07-13 13:44:29 -05:00
Deans
a4d49850f3 Add per-session variable server logs 2023-06-26 12:23:58 -05:00
Jacqueline Deans
6118171c01
Update swig interface to work python 3.11 (#1486) 2023-04-11 13:14:30 -05:00
ddj116
9099792947
Integrate MonteCarloGenerate capability from EG CML and associated TrickOps enhancements (#1415)
* Provide MonteCarloGenerate capability

Intermediate commit, this squash represents all of Isaac Reaves' work
during his Fall 2022 Pathways internship tour

[skip ci]

* TrickOps: Add phase, [min-max] range, and overhaul YAML verification

* Add new "phase:" mechanism to TrickOps Runs and Builds to support
  project-specific constraints on build and run ordering
  - phase defaults to zero if not specified and must be between -1000
    and 1000 if given.
  - jobs can now optionally be requested by their phase or phase range
  - See trickops/README.md for details
* Add [min-max] notation capability to run: entries and compare: entries
  - [min-max] ranges provide definition of a set of runs using a common
    numbering scheme in the YAML file, greatly reducing YAML file size
    for monte-carlo and other zero-padded run numbering use cases
  - See trickops/README.md for details
* YAML parsing changes
  - Overhaul the logic which verifies YAML files for the expected
    TrickOps format. This is now done in TrickWorkflowYamlVerifier and
    provides much more robust error checking than previous approach
  - .yaml_requirements.yml now provides the required types, ranges, and
    default values as applicable to expected entries in YAML files
  - valgrind: is now an sub-option to run: entries, not its own section
    Users should now list their runs normallly and define their flags in
    in that run's valgrind: subsection
  - parallel_safety is now a per-sim parameter and not global. Users
    should move their global config to the sim layer
  - self.config_errors is now a list of errors. Users should now
    check for empty list when using instead of True/False
* Robustify the get_koviz_report_jobs unit test to work whether koviz
  exists on PATH or not
* Adjust trickops.py to use the new phase and range features
   - Make it more configurable on the command-line via argparse
   - Move SIM_mc_generation tests into test_sims.yml

[skip ci]

* Code review and cleanup from PR #1389

Documentation:

* Adjust documentation to fit suggested symlinked approach. Also
  cleaned up duplicate images and old documentation.
* Moved the verification section out of markdown and into a PDF since it
  heavily leverages formatting not available in markdown.
* Clarify a couple points on the Darwin Trick install guide
* Update wiki to clarify that data recording strings is not supported

MCG Code:

* Replace MonteCarloVariableRandomNormal::is_near_equal with new
  Trick::dbl_is_near from trick team

MCG Testing:

* Reduce the set of SIM_mc_generation comparisons. After discussion
  the trick team, we are choosing to remove all comparisons to
  verif_data/ which contain random-generated numbers since
  these tests cannot pass across all supported trick platforms.
* Fix the wrong rule on exlcuding -Werror for Darwin builds
  of SIM_mc_generation
* Remove data recording of strings in SIM_mc_generation

Trickops:

* Replace build_command with build_args per discussion w/ Trick team
  Since we only support arguments to trick-CP, replace the build_command
  yaml entry with build_args
* Disable var server connection by default in SingleRun if TrickWorkflow.quiet
  is True
* Guard against multiple Job starts
* Remove SimulationJob inheritance layer since old monte-carlo wasn't
  and never will be supported by TrickOps
* Ignore IOError raise from variable_server that looks like "The remote
  endpoint has closed the connection". This appears to occur when
  SingleRun jobs attempt to connect to the var server for a sim that
  terminates very early

[skip ci]

* Adjust phasing of old/new MCG initialize functions

* Clarify failure message in generate_dispersions if new/old MC are both
  used.
* Adjust the phasing order of MCG intialize method to be before
  legacy MC initialized. Without this, monte-carlo dry run completes with
  success before the check in generate_dispersions() can run
* Add -Wno-stringop-truncation to S_override.mk for SIM_mc_generation
  since gcc 8+ warns about SWIG generated content in top.cpp

* Introduce MonteCarloGenerationHelper python class

This new class provides an easy-to-use interface for MCG sim-module
users:

1. Run generation
2. Getting an sbatch array job suitable for SLURM
3. Getting a list of SingleRun() instances for generated runs, to be
   executed locally if desired

---------

Co-authored-by: Dan Jordan <daniel.d.jordan@nasa.gov>
2023-03-06 09:25:50 -06:00
jmpenn
2a03ff5cf4
Replace sprintf with snprintf in all of Trick source. #1384 (#1392)
* Replace sprintf with snprintf in all of Trick source. #1384

* Don't add -Werror for MacOS because of deprecated sprintf warnings which we cant get rid of because SWIG. #1384

* Fixed an unbalanced parenthesis in S_overrides.mk. #1384
2022-11-15 15:00:05 -06:00
Penn, John M 047828115
0b373d96cf Refactor web server configuration. #1188 2021-09-29 18:00:33 -05:00
Penn, John M 047828115
e487e5609f Initial excision of DMTCP from Trick. #28 2021-08-27 19:38:56 -05:00
Penn, John M 047828115
4c52ed2753 Merge Caleb Herpins port of Trick webserver from Mongoose to CivetWeb #730. 2021-08-18 13:15:10 -05:00
Penn, John M 047828115
0b823bb6f2 Remove BC635Clock.hh and TPROCTEClock.hh from sim_services.i #87 2021-08-02 03:03:32 -05:00
Scott Fennell
6691b14e9e
1093 c str (#1119)
* update checkpoint_map.hh #1093

* #1093 update checkpoint_pair.hh

* #1093 update checkpoint_queue.hh

* #1093 update MM_write_checkpoint.cc

* #1093 update units_attach.i

* #1093 update checkpoint_sequence_stl.hh

* #1093 update checkpoint_stack.hh

* #1093 update swig_extend_str.i

* #1093 update swig_int_templates.hh

* #1093 update checkpoint_stack.hh and swig_int_typemap.i

* #1093 fix c_str issue without adding memory leaks

* #1093 fix c_str issue without adding memory leaks

* #1093 remove dangling pointers in injector sim object (without causing memory leaks)

* #1093 remove dangling pointers in injector sim object (without causing memory leaks)

* #1093 remove dangling pointers in Event Manaager sim object (without causing memory leaks)

* #1093 fix MonteCarlo_c_intf dangling pointers

Co-authored-by: Fennell, Scott P 263712616 <scott.p.fennell@nasa.gov>

closes #1093
2021-03-12 13:23:35 -06:00
Derek Bankieris
3190292cf3 Add units to swig_int and swig_double
Closes #1072
2020-11-05 09:49:02 -06:00
Scott Fennell
4f5ce7e4a1
Maven, offline mode, and --enable-mongoose (#939)
closes #938 
closes #941 
closes #943
2020-02-05 14:31:58 -06:00
Alex Lin
ce0cdc9636
Cmake merge (#901)
* Merging changes from cmake branch to master

* Fixing includes for renamed header files

* still need build rule

* Adding warning for swig code for gcc8+

* Adding CMakeLists.txt for data products

* Cmake merge #901

Making adjustments to get cmake working on the Mac (Mojave)

* Cmake merge #901

Changing string append to list append
2019-11-19 09:01:16 -06:00
jmpenn
9eed167634
Add enable flag to webserver. Default is false. Should be set to true in input file to enable. (#892) 2019-10-29 11:52:02 -05:00
Alex Lin
497f11f132
Make TRICK_CXX variable to specify c++ compiler #767 (#815)
Changed all references of TRICK_CPPC to TRICK_CXX.  Added a
warning message that TRICK_CPPC has been deprecated.
2019-06-18 11:00:08 -05:00
Alex Lin
187fa37540
Remove suppression of units conversion warnings in 19 #789 (#814)
Removed checks on dead units conversion messenger.  Units conversion
messages cannot be suppressed.  Added deprecated messages to the functions
that modified the message printouts.
2019-06-18 10:59:51 -05:00
Derek Bankieris
295b9e3285 Infer TRICK_HOME automatically
Refs #358
2019-05-23 15:09:34 -05:00
Derek Bankieris
9a04d72fd0 Add Unit.hh to files_to_ICG.hh & sim_services.i
units_conv.h was also missing from sim_services.i

Closes #718
2018-12-07 08:08:15 -06:00
dbankieris
348bbb3798
Add ExecutiveException.hh to sim_services.i (#691)
* Add ExecutiveException.hh to sim_services.i and files_to_ICG.hh
* Update version number

Fixes #690
2018-10-30 13:49:55 -05:00
Alex Lin
4bf35a9c82 Revert "Merge pull request #533 from nasa/MakefileCleanup"
This reverts commit 269ed77cb4, reversing
changes made to d97f482219.
2018-03-02 08:59:26 -06:00
Alex Lin
9dd302f4b1 Trick makefile output formatting and cleanup. #533
Removed the red from the clean rules.  We'd like to reserve red for
errors.  Ended up removing all color from the clean side.
2018-03-01 08:51:57 -06:00
Alex Lin
9643311f4c Merge branch 'master' into MakefileCleanup 2018-03-01 08:32:08 -06:00
Alex Lin
8f76605f3b Create Message client that writes to screen on a separate thread #553
Created a new message class that will copy incoming messages to a
buffer area.  The buffer area is pre allocated during simulation
initialization.  On a separate thread the buffer area is written
to std::cout.
2018-01-25 15:59:19 -06:00
Alex Lin
5285f1a72e Symbolic links rise again #530
Found more places where symbolic links cause havoc.  Also added back a #define
that was removed in parameter_types.h and added back the messaging routines to
the list swig processes.
2017-12-12 10:17:24 -06:00
Christopher LaChance
6e0fcbd947 Updated formating and replaced formating variables. 2017-12-07 15:10:39 -06:00
Christopher LaChance
1bb3ac2a06 Cleaned up 'make clean' output significantly. 2017-12-06 13:12:13 -06:00
Alex Lin
dce161ad94 Suppress units conversion messages in input file. #414
Added a routine to shoot_the_units_conversion_messenger.
2017-04-20 11:34:50 -05:00
Michael Vetter
18f0d7e871 Remove trailing whitespaces
Makes it easier to edit the files. So if we press 'end of line' we are
really at the end of line.
2016-11-08 10:25:07 +01:00
Thadeus Fleming
5027c02c51 Fix filename output in attach_units for Python 3 2016-09-11 14:21:37 -05:00
Alex Lin
4ab584ed55 Support using Python 3
Fixed the configure script to allow the user to specify using a python3
interpreter.  Had to change the the way to load the swig generated python modules.
Also had to change code dealing with python strings, oct, long, and
boolean operations.

refs #258
2016-06-28 13:44:21 -05:00
Alex Lin
fb4601734f Need to include SimTime.hh for ICG and swig processing.
Added the sim time header files to files_to_ICG.hh and sim_services.i so it will be processed.

refs #247
2016-06-15 16:11:09 -05:00
Alex Lin
a95e8e086b Use udunits package for units conversions
Copied the units_conv.c from 15 that includes the new units to master.

Swept through the code removing includes to Unit.hh and UCF.h where they
are no longer needed.  Remade makefile dependencies.

refs #231
2016-05-17 09:01:37 -05:00
Alex Lin
384519ce24 Use udunits package for units conversions
PyFrame_GetLineNumber is not present in python 2.6.  We have
to use PyCode_Addr2Line instead to get the line number.

refs #231
2016-05-11 15:14:19 -05:00
Alex Lin
26cb44e946 Use udunits package for units conversions
So our unit tests did their job, they pointed to quite a few errors.
Fixed them all on my platform (CentOS 7).

refs #231
2016-05-11 09:01:54 -05:00
Alex Lin
d72aa59fdd Use udunits package for units conversions
Converted data products to use udunits.

refs #231
2016-05-10 14:45:31 -05:00
Alex Lin
6defa99b34 Use udunits package for units conversions
Changed the include for udunits to #include <udunits2.h> to work
on all platforms.  Added the include directory /usr/include/udunits2
for Linux.

refs #231
2016-05-09 10:23:19 -05:00
Alex Lin
4f3ef64002 Use udunits package for units conversions
Changed the handling of how we handle doubles and ints allowing
more mathematical operations like multiplication, division, and
some limited exponentiation.

refs #231
2016-05-09 08:36:43 -05:00
Alex Lin
684f0e6bdc Use udunits package for units conversions
Initial checkin of using udunits for measurement units conversions.  Replaced
our conversion code in ICG and swig code to use udunits.

Also added code to convert unit symbols that we used in Trick that are different
names in udunits.

Added a sim_object that will eventually allow users to specify a custom
set of files to read units information.

refs #231
2016-05-05 14:49:49 -05:00
Alex Lin
b5b6dbe0bb Compiling with gcc 4.9 sometimes requires cstddef
It's the generated swig code that is missing cstddef.  Added some
includes to get cstdef in the swig code.

refs #212
2016-04-01 17:05:24 -05:00
Alex Lin
bb6d7f0632 Math with temperature values is not as expected.
For addition and subtraction,  we created a new routine that
only scales second units to the first.  We apply it to all
conversions when adding and subtracting, but it only changes
the temperature results, because that is the only units that
has a bias factor. The comparision conversion routines were not
changed.

refs #202
2016-03-16 16:54:25 -05:00
Alex Lin
4c3015851f Merge in the er7_utils integrators
Taking in the latest er7_utils directory and adding it into Trick in the
same location it was as an external repository.  Made one change to
the files_to_ICG.hh file in the repository to remove the CheckpointHelper
header files.  Those go in the Trick files_to_ICG.hh file.

refs #180
2016-02-10 09:32:53 -06:00
Alex Lin
ca51142553 Configure script does not set up GSL correctly
The configure script does not set up the defines for GSL correctly which causes our GSL
support code not to compile correctly. Fixed it.

refs #143
2015-11-18 08:30:21 -06:00
Alex Lin
57c76041f5 Get the value of a variable not parsed by SWIG in python
Wrote a python routine called get_value_by_ref_name that takes
a variable name string as an argument.  The string is passed to
ref_attributes to find the address and returns a REF2 structure.  The REF2
structure is passed to ref_to_value and the type and value of the variable
is returned in a structure.  We call vval_<type> to extract the raw value
from the structure and return that to python space.

Made a couple of other bug fixes in the FieldVisior and cpp input file
example found while investigating this issue.

refs #123
2015-09-18 09:03:24 -05:00
Alex Lin
b3d1a1d162 Trick should not modify TRICK_CFLAGS and TRICK_CXXFLAGS
Well sims compiled, but I forgot to test if Trick itself
would compile.  It didn't.  Added TRICK_SYSTEM_CFLAGS and
TRICK_SYSTEM_CXXFLAGS where needed.

refs #90
2015-07-22 15:34:54 -05:00
Alex Lin
733d64a250 Trick swig headers don't make it to the destination directory with make install
Moved the header files and the swig .i files to include/trick/swig.  Adjusted the
source files and the convert_swig script to find the headers in their new
location.

refs #67
2015-06-17 14:07:52 -05:00
Alex Lin
2eeb311a70 Standardize directory names
Moved the no_arch swig files to share/trick/swig and adjusted the makefiles to look for the files in the new location.  Changed the install rule to only copy the files we need for our installation.

refs #63
2015-06-11 14:40:14 -05:00
Alex Lin
19025d77ad Standardize directory names
Reorganized.  Created a new top level include directory that will hold all of Trick's header files. Moved all of the Trick headers to this directory.  Created a libexec directory that holds all of the executables that users don't need to execute directly.  Changed all of the executables remaining in bin to start with "trick-".  In the sim_services directories changed all source files to find the Trick headers in their new location.  Since all of the include files are gone in sim_services, removed the src directories as well, moving all of the source files up a level.  Moved the makefiles, docs, man, and other architecture independent files into a top level share directory.  Renamed lib_${TRICK_HOST_CPU} to lib64 or lib depending on the platform we're currently on.

refs #63
2015-06-09 08:44:42 -05:00