This commit is contained in:
Derek Bankieris 2015-04-02 14:14:16 -05:00
commit df39400847
52 changed files with 811 additions and 338 deletions

View File

@ -3,7 +3,6 @@
use File::Basename ;
use Cwd ;
use strict ;
use Data::Dumper ;
use Getopt::Long ;
use Pod::Usage ;
use Pod::Text ;
@ -230,24 +229,11 @@ undef %temp_hash ;
@all_src_files = grep ++$temp_hash{$_} < 2, @all_src_files ;
@all_src_files = grep !/trick_source|\.a$|^\-/ , @all_src_files ;
# TODO: Add back at some time before release
#trick_print($sim{fh}, "MIS-ing all src files... ", "title_cyan" , $sim{args}{v}) ;
#trick_print($sim{fh}, "\n" , "title_white" , $sim{args}{v}) if ( $sim{args}{v} != 1 ) ;
#mis_all_c(\@all_src_files , \%sim ) ;
if ( $sim{args}{v} == 1 ) {
print " Complete\n" ;
}
trick_print($sim{fh}, "\nMIS complete\n\n" , "normal_green" , $sim{args}{v}) ;
if ( $sim{args}{v} > 3 ) {
chdir ($cwd) ;
$Data::Dumper::Indent = 1 ;
open FILE, ">sim_info" or die "Couldn't open sim_info\n";
print FILE Data::Dumper->Dump([\%sim], ["*sim_info"]) , "\n" ;
close FILE ;
}
#--------------------------------------------------------------
# Make Default Data

View File

@ -7,7 +7,6 @@ use Getopt::Long ;
use Pod::Usage ;
use Pod::Text ;
use File::Basename ;
use Data::Dumper ;
use Cwd ;
use Cwd 'abs_path' ;
use mis_dep ;

View File

@ -12,7 +12,6 @@ use Cwd 'abs_path' ;
use gte ;
use get_headers ;
use trick_version ;
use Digest::MD5 qw(md5_hex) ;
##
## ================================================================================
@ -414,7 +413,8 @@ sub process_file($$) {
## Generate a module name and path for the SWIG interface file.
my $md5_sum = md5_hex($f) ;
my ( $dev, $inode ) = stat($f) ;
my $uniq_file_id = "${dev}_$inode" ;
my ($out_dir) = dirname($f) ;
$out_file = basename($f) ;
@ -441,7 +441,10 @@ sub process_file($$) {
open OUT, ">$out_file" ;
print OUT "\%module m$md5_sum\n\n" ;
print OUT "\%module m$uniq_file_id\n\n" ;
print OUT "\%pythoncode \%{
# Processed from $f
\%}\n" ;
print OUT "/* $in_file */\n" ;
print OUT "#include \"trick_swig/trick_swig.i\"\n\n" ;

View File

@ -14,7 +14,6 @@ use MIS ;
use html ;
use trick_print ;
use trick_version ;
use Data::Dumper ;
use Cwd 'abs_path';
##############################################################################

View File

@ -7,7 +7,6 @@ use Exporter ();
use strict ;
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
use File::Basename ;
use Data::Dumper ;
use Cwd ;
use Cwd 'abs_path' ;
use html ;

View File

@ -13,7 +13,6 @@ use gte ;
use trick_print ;
use Cwd ;
use Cwd 'abs_path';
use Digest::MD5 qw(md5_hex) ;
use strict ;
sub make_swig_makefile($$$) {
@ -36,9 +35,12 @@ sub make_swig_makefile($$$) {
my ($version, $thread, $year) ;
my ($swig_module_i, $swig_module_source, $py_wrappers) ;
my $s_source_full_path = abs_path("S_source.hh") ;
my $s_source_md5 = md5_hex($s_source_full_path) ;
my $s_library_swig = ".S_library_swig" ;
my $s_library_swig_ext = ".S_library_swig_ext" ;
my ( $dev, $inode ) ;
( $dev, $inode ) = stat($s_source_full_path) ;
my $s_source_uniq_id = "${dev}_$inode" ;
($version, $thread) = get_trick_version() ;
($year) = $version =~ /^(\d+)/ ;
@ -312,7 +314,9 @@ sub make_swig_makefile($$$) {
push @{$python_modules{"root"}} , $f ;
}
my $md5_sum = md5_hex($f) ;
( $dev, $inode ) = stat($f) ;
my $uniq_id = "${dev}_$inode" ;
# check if .sm file was accidentally ##included instead of #included
if ( rindex($swig_f,".sm") != -1 ) {
trick_print($$sim_ref{fh}, "\nError: $swig_f should be in a #include not a ##include \n\n", "title_red", $$sim_ref{args}{v}) ;
@ -326,8 +330,8 @@ sub make_swig_makefile($$$) {
$swig_dirs{$swig_dir} = 1 ;
$swig_module_i .= "\\\n $swig_f" ;
$swig_module_source .= "\\\n $swig_dir/py_${swig_file_only}.cpp\\\n $swig_dir/m${md5_sum}.py" ;
$py_wrappers .= " \\\n $swig_sim_dir/${swig_module_dir}m${md5_sum}.py" ;
$swig_module_source .= "\\\n $swig_dir/py_${swig_file_only}.cpp\\\n $swig_dir/m${uniq_id}.py" ;
$py_wrappers .= " \\\n $swig_sim_dir/${swig_module_dir}m${uniq_id}.py" ;
if ( ! exists $$sim_ref{sim_lib_swig_files}{$f} ) {
print MAKEFILE "$swig_object_dir/py_${swig_file_only}.o : $swig_f\n" ;
@ -341,14 +345,14 @@ sub make_swig_makefile($$$) {
}
if ( $swig_module_dir ne "" ) {
print MAKEFILE "$swig_sim_dir/${swig_module_dir}m${md5_sum}.py : | $swig_sim_dir/$swig_module_dir\n" ;
print MAKEFILE "$swig_sim_dir/${swig_module_dir}m${uniq_id}.py : | $swig_sim_dir/$swig_module_dir\n" ;
}
if ( ! exists $$sim_ref{sim_lib_swig_files}{$f} ) {
print MAKEFILE "$swig_sim_dir/${swig_module_dir}m${md5_sum}.py : | $swig_object_dir/py_${swig_file_only}.o\n" ;
print MAKEFILE "$swig_sim_dir/${swig_module_dir}m${uniq_id}.py : | $swig_object_dir/py_${swig_file_only}.o\n" ;
} else {
print MAKEFILE "$swig_sim_dir/${swig_module_dir}m${md5_sum}.py :\n" ;
print MAKEFILE "$swig_sim_dir/${swig_module_dir}m${uniq_id}.py :\n" ;
}
print MAKEFILE "\t/bin/cp $swig_dir/m${md5_sum}.py \$@\n\n" ;
print MAKEFILE "\t/bin/cp $swig_dir/m${uniq_id}.py \$@\n\n" ;
$ii++ ;
}
@ -466,8 +470,10 @@ clean_swig:\n" ;
print INITSWIGFILE "extern \"C\" {\n\n" ;
foreach $f ( @temp_array2 ) {
my $md5_sum = md5_hex($f) ;
print INITSWIGFILE "void init_m${md5_sum}(void) ; /* $f */\n" ;
( $dev, $inode ) = stat($f) ;
my $uniq_id = "${dev}_$inode" ;
print INITSWIGFILE "void init_m${uniq_id}(void) ; /* $f */\n" ;
}
print INITSWIGFILE "void init_sim_services(void) ;\n" ;
print INITSWIGFILE "void init_top(void) ;\n" ;
@ -478,11 +484,13 @@ clean_swig:\n" ;
print INITSWIGFILE "\nvoid init_swig_modules(void) {\n\n" ;
foreach $f ( @temp_array2 ) {
next if ( $f =~ /S_source.hh/ ) ;
my $md5_sum = md5_hex($f) ;
print INITSWIGFILE " init_m${md5_sum}() ;\n" ;
( $dev, $inode ) = stat($f) ;
my $uniq_id = "${dev}_$inode" ;
print INITSWIGFILE " init_m${uniq_id}() ;\n" ;
}
print INITSWIGFILE " init_m${s_source_md5}() ;\n" ;
print INITSWIGFILE " init_m${s_source_uniq_id}() ;\n" ;
print INITSWIGFILE " init_sim_services() ;\n" ;
print INITSWIGFILE " init_top() ;\n" ;
@ -523,17 +531,19 @@ clean_swig:\n" ;
foreach $f ( @{$python_modules{"root"}} ) {
next if ( $f =~ /S_source.hh/ ) ;
my $md5_sum = md5_hex($f) ;
( $dev, $inode ) = stat($f) ;
my $uniq_id = "${dev}_$inode" ;
print INITFILE "# $f\n" ;
print INITFILE "import _m${md5_sum}\n" ;
print INITFILE "from m${md5_sum} import *\n" ;
print INITFILE "import _m${uniq_id}\n" ;
print INITFILE "from m${uniq_id} import *\n" ;
print INITFILE "combine_cvars(all_cvars, cvar)\n" ;
print INITFILE "cvar = None\n\n" ;
}
print INITFILE "# S_source.hh\n" ;
print INITFILE "import _m${s_source_md5}\n" ;
print INITFILE "from m${s_source_md5} import *\n\n" ;
print INITFILE "import _m${s_source_uniq_id}\n" ;
print INITFILE "from m${s_source_uniq_id} import *\n\n" ;
print INITFILE "import _top\n" ;
print INITFILE "import top\n\n" ;
print INITFILE "import _swig_double\n" ;
@ -558,10 +568,12 @@ clean_swig:\n" ;
open INITFILE , ">$swig_sim_dir/$temp_str/__init__.py" or return ;
foreach $f ( @{$python_modules{$m}} ) {
next if ( $f =~ /S_source.hh/ ) ;
my $md5_sum = md5_hex($f) ;
( $dev, $inode ) = stat($f) ;
my $uniq_id = "${dev}_$inode" ;
print INITFILE "# $f\n" ;
print INITFILE "import _m${md5_sum}\n" ;
print INITFILE "from m${md5_sum} import *\n\n" ;
print INITFILE "import _m${uniq_id}\n" ;
print INITFILE "from m${uniq_id} import *\n\n" ;
}
close INITFILE ;

View File

@ -21,8 +21,6 @@ use gte ;
#use strict ;
require $ENV{"TRICK_HOME"} . "/bin/pm/XML/Parser.pm" ;
use XML::Simple ;
use Data::Dumper ;
my @element_stack;
my $record_index;

View File

@ -0,0 +1,36 @@
/*************************************************************************
PURPOSE: (Parachutist Structure)
LIBRARY DEPENDENCIES:
(
(parachutist/src/Parachutist.o)
)
**************************************************************************/
#ifndef _parachutist_hh_
#define _parachutist_hh_
#include "sim_services/Integrator/include/regula_falsi.h"
class Parachutist {
public:
double altitude ; /* m xyz-position */
double velocity ; /* m/s xyz-velocity */
double acceleration ; /* m/s2 xyz-acceleration */
double area; /* m2 */
double Cd; /* -- */
double mass; /* kg */
bool touchDown; /* -- */
REGULA_FALSI rf ;
int default_data();
int state_init();
int state_deriv();
int state_integ();
double touch_down(double groundAltitude);
};
#endif

View File

@ -0,0 +1,15 @@
#ifndef INTERPOLATE_H
#define INTERPOLATE_H
#ifdef __cplusplus
extern "C" {
#endif
double interpolate( double x, const double xa[], const double fa[], int N_elems );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,105 @@
/********************************* TRICK HEADER *******************************
PURPOSE: ( Simulate a skydiver jumping from very high altitude.)
LIBRARY DEPENDENCY:
((Parachutist.o)(interpolate.o))
PROGRAMMERS:
(((John M. Penn) (L3 Communications) (March 2015) (Trick Refresher Project)))
*******************************************************************************/
#include "../include/Parachutist.hh"
#include "../include/interpolate.h"
#include <iostream>
// The following three data arrays come from:
// http://www.engineeringtoolbox.com/standard-atmosphere-d_604.html
// U.S Standard Atmosphere Air Properties in SI Units
#define NUM_ELEMENTS 21
// Units = meters (above sea level).
const double altitude_array[NUM_ELEMENTS] = {
-1000.0, 0.0, 1000.0, 2000.0, 3000.0, 4000.0, 5000.0, 6000.0,
7000.0, 8000.0, 9000.0, 10000.0, 15000.0, 20000.0, 25000.0, 30000.0,
40000.0, 50000.0, 60000.0, 70000.0, 80000.0 };
// Units = kilograms per cubic meter.
const double air_density_array[NUM_ELEMENTS] = {
1.347, 1.225, 1.112, 1.007, 0.9093, 0.8194, 0.7364, 0.6601,
0.5900, 0.5258, 0.4671, 0.4135, 0.1948, 0.08891, 0.04008, 0.01841,
0.003996, 0.001027, 0.0003097, 0.00008283, 0.00001846 };
// Units = meters per second squared.
const double gravity_array[NUM_ELEMENTS] = {
9.810, 9.807, 9.804, 9.801, 9.797, 9.794, 9.791, 9.788,
9.785, 9.782, 9.779, 9.776, 9.761, 9.745, 9.730, 9.715,
9.684, 9.654, 9.624, 9.594, 9.564
};
int Parachutist::default_data() {
altitude = 38969.3; //38969.3 meters = 127852 feet
velocity = 0.0;
area = 0.75;
Cd = 0.75;
touchDown = false;
mass = 82.0;
return (0);
}
int Parachutist::state_init() {
return (0);
}
int Parachutist::state_deriv() {
// Calculate the forces and acceleration.
// Calculate Force of gravity.
double g = interpolate( altitude, altitude_array, gravity_array, NUM_ELEMENTS );
double Force_gravity = mass * -g;
// Calculate Force of drag.
double air_density = interpolate( altitude, altitude_array, air_density_array, NUM_ELEMENTS );
double Force_drag = Cd * 0.5 * air_density * velocity * velocity * area;
// Calculate Total Force.
double Force_total;
if ( !touchDown ) {
Force_total = Force_gravity + Force_drag ;
acceleration = Force_total / mass;
} else {
Force_total = 0.0;
velocity = 0.0;
acceleration = 0.0;
}
return(0);
}
#include "sim_services/Integrator/include/integrator_c_intf.h"
int Parachutist::state_integ() {
int integration_step;
load_state( &altitude, &velocity, (double*)0);
load_deriv ( &velocity, &acceleration, (double*)0);
integration_step = integrate();
unload_state( &altitude, &velocity, (double*)0);
return(integration_step);
}
double Parachutist::touch_down(double groundAltitude) {
double tgo ;
double now ;
/* error function: how far the skydiver is above ground */
rf.error = altitude - groundAltitude ;
now = get_integ_time() ;
tgo = regula_falsi( now, &rf ) ;
if (tgo == 0.0) {
now = get_integ_time() ;
reset_regula_falsi( now, &rf);
velocity = 0.0;
acceleration = 0.0;
touchDown = true;
std::cout << "Touchdown: time = " << now << "." << std::endl;
}
return ( tgo ) ;
}

Binary file not shown.

View File

@ -0,0 +1,22 @@
#include "../include/interpolate.h"
#include <stdio.h>
double interpolate( double x, const double xa[], const double fa[], int N_elems ) {
int ii;
for (ii=0 ; ((ii+2 < N_elems ) && (x > xa[ii+1])) ; ii++ ) ;
double x_lower = xa[ii];
double x_upper = xa[ii+1];
double f_lower = fa[ii];
double f_upper = fa[ii+1];
if (x < x_lower) {
fprintf(stderr, "Interpolation x is out of range low.\n");
return(f_lower);
}
if (x > x_upper) {
fprintf(stderr, "Interpolation x is out of range high.\n");
return(f_upper);
}
double f = (x_upper - x)/(x_upper - x_lower) * f_lower +
(x - x_lower)/(x_upper - x_lower) * f_upper ;
return(f);
}

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE product PUBLIC "-//Tricklab//DTD Product V1.0//EN" "Product.dtd">
<product version="1.0">
<tstart>-1.0E20</tstart>
<tstop>1.0E20</tstop>
<frequency>0.0</frequency>
<page hcells="0" vcells="0">
<title>Page</title>
<plot grid="Yes" grid_color="#b2b2b2">
<title>Plot</title>
<curve>
<var units="s">sys.exec.out.time</var>
<var units="m">dyn.parachutist.altitude</var>
</curve>
</plot>
</page>
<page hcells="0" vcells="0">
<title>Page</title>
<plot grid="Yes" grid_color="#b2b2b2">
<title>Plot</title>
<curve>
<var units="s">sys.exec.out.time</var>
<var units="m/s">dyn.parachutist.velocity</var>
</curve>
</plot>
</page>
<page hcells="0" vcells="0">
<title>Page</title>
<plot grid="Yes" grid_color="#b2b2b2">
<title>Plot</title>
<curve>
<var units="s">sys.exec.out.time</var>
<var units="m/s2">dyn.parachutist.acceleration</var>
</curve>
</plot>
</page>
<page hcells="0" vcells="0">
<title>Page</title>
<plot grid="Yes" grid_color="#b2b2b2">
<title>Plot</title>
<curve>
<var units="s">sys.exec.out.time</var>
<var units="--">dyn.parachutist.cooefficientOfDrag</var>
</curve>
</plot>
</page>
</product>

View File

@ -0,0 +1,20 @@
global DR_GROUP_ID
global drg
try:
if DR_GROUP_ID >= 0:
DR_GROUP_ID += 1
except NameError:
DR_GROUP_ID = 0
drg = []
drg.append(trick.DRBinary("parachutist"))
drg[DR_GROUP_ID].set_freq(trick.DR_Always)
drg[DR_GROUP_ID].set_cycle(0.1)
drg[DR_GROUP_ID].set_single_prec_only(False)
drg[DR_GROUP_ID].add_variable("dyn.parachutist.altitude")
drg[DR_GROUP_ID].add_variable("dyn.parachutist.velocity")
drg[DR_GROUP_ID].add_variable("dyn.parachutist.acceleration")
drg[DR_GROUP_ID].add_variable("dyn.parachutist.area")
drg[DR_GROUP_ID].add_variable("dyn.parachutist.Cd")
trick.add_data_record_group(drg[DR_GROUP_ID], trick.DR_Buffer)
drg[DR_GROUP_ID].enable()

View File

@ -0,0 +1,76 @@
### Background
On October 14, 2012, 43-year-old Austrian daredevel Felix Baumgartner broke the
world record for the highest-ever skydive after jumping from a balloon at an
altitude of 127,852 feet. He reached a top speed of 843.6 mph, spent approximately
4 minutes 19 seconds in free-fall, and landed safely approximately 11 minutes
after jumping.
### Simulation
The simulation only considers the forces of gravity and drag, and only motion in
the vertical. The acceleration of the skydiver is determined by summing the
forces of gravity and drag acting on him and then dividing by his mass. His
velocity is determined by integrating his acceleration over time, and his
altitude by integrating his velocity over time.
Desired outputs are:
* Plot of altitude vs. time.
* Plot of velocity vs. time.
* Time of touchdown.
##### Gravity
![Fgrav=m*g](images/force_of_gravity.png)
Where:
* m = mass of the skydiver.
* g = acceleration of gravity.
##### Drag
![Fdrag=0.5*Cdrag*rho*v^2*A](images/force_of_drag.png)
Where:
* C<sub>d</sub> = Coefficient of drag
* &#0961; = air density
* v = instantaneous velocity
* A = cross-sectional area of the jumper
#### Air Density and Gravity Data
The table at:
<http://www.engineeringtoolbox.com/standard-atmosphere-d_604.html>
provides both gravity (g) and air density (&#0961;) at various altitudes.
From these data we interpolate, to approximate the air density and gravity at
specific altitudes.
#### Parachute Deployment
Parachute deployment is modeled, using a Trick event (in input.py) that simply
increases the skydiver's
1. cross-sectional area (A) and
2. coefficient of drag (C<sub>d</sub>).
at the specified time.
### Felix Baumgartner Jump Scenario
* dyn.groundAltitude = 1000
* dyn.parachutist.altitude = 38969.6 meters
* dyn.parachutist.velocity = 0.0
* dyn.parachutist.area = 0.75
* dyn.parachutist.Cd = 0.75
* dyn.parachutist.mass = 82.0
At 4 minutes and 19 seconds, pop the chute:
* dyn.parachutist.Cd = 1.3
* dyn.parachutist.area = 30.0
#### Results
##### Altitude vs Time
![Plot of Altitude vs Time](images/plot_altitude_vs_time.png "Altitude vs. Time")
##### Velocity vs Time
![Plot of Velocity vs Time](images/plot_velocity_vs_time.png "Velocity vs. Time")

View File

@ -0,0 +1,27 @@
execfile("Modified_data/parachutist.dr")
trick.TMM_reduced_checkpoint(0)
dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 2)
# The ground is a 1000 meters above sea level.
dyn.groundAltitude = 1000
# State of the skydiver when he jumps
dyn.parachutist.altitude = 38969.6 # 127852 feet
dyn.parachutist.velocity = 0.0
dyn.parachutist.area = 0.75
dyn.parachutist.Cd = 0.75
dyn.parachutist.mass = 82.0
# At 4 minutes and 19 seconds, pop the chute.
deployChute = trick.new_event("deployChute")
deployChute.condition(0, "trick.exec_get_sim_time() >= 259.0")
deployChute.action(0, "dyn.parachutist.Cd = 1.3");
deployChute.action(1, "dyn.parachutist.area = 30.0");
deployChute.action(2, "print \"Parachute Deployed.\"");
deployChute.set_cycle(1.0)
deployChute.activate()
trick.add_event(deployChute)
# Run for 800 seconds.
trick.stop(800)

View File

@ -0,0 +1,30 @@
/************************TRICK HEADER*************************
PURPOSE:
( Simulate a skydiver jump from very high altitude. )
LIBRARY DEPENDENCIES:
((parachute/src/Parachutist.cpp))
*************************************************************/
#include "sim_objects/default_trick_sys.sm"
##include "parachute/include/Parachutist.hh"
class ParachutistSimObject : public Trick::SimObject {
public:
Parachutist parachutist;
double groundAltitude;
ParachutistSimObject() {
("default_data") parachutist.default_data() ;
("initialization") parachutist.state_init() ;
("derivative") parachutist.state_deriv() ;
("integration") trick_ret = parachutist.state_integ() ;
("dynamic_event") parachutist.touch_down(groundAltitude) ;
}
} ;
ParachutistSimObject dyn ;
IntegLoop dyn_integloop(0.02) dyn;

View File

@ -0,0 +1,4 @@
TRICK_CFLAGS += -I${TRICK_HOME}/trick_models
TRICK_CXXFLAGS += -I${TRICK_HOME}/trick_models

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -28,6 +28,23 @@ ClassValues::~ClassValues() {
void ClassValues::addFieldDescription(FieldDescription * in_fdes) {
field_descripts.push_back(in_fdes) ;
// This section creates code that clang on the Mac cannot compile.
// So, we cannot handle overloaded names on the Mac.
#ifndef __APPLE__
// Test to see if the new field overloads a field of the same name. If it does
// then fully qualify the name of the inherited field (the one already in field_name_to_info).
std::map< std::string , FieldDescription * >::iterator mit = field_name_to_info_map.find(in_fdes->getName()) ;
if ( mit != field_name_to_info_map.end() ) {
// If the matched variable is inherited, qualify it with its container class name.
if ( (*mit).second->isInherited() ) {
(*mit).second->setName( (*mit).second->getContainerClass() + "::" + (*mit).second->getName() ) ;
field_name_to_info_map[(*mit).second->getName()] = (*mit).second ;
field_name_to_info_map.erase(mit) ;
}
}
#endif
field_name_to_info_map[in_fdes->getName()] = in_fdes ;
}
@ -35,6 +52,9 @@ void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *>
// Make a copy of all of the FieldDescription variables.
field_descripts.insert(field_descripts.end(), in_fdes.begin() , in_fdes.end()) ;
// This section creates code that clang on the Mac cannot compile.
// So, we cannot handle overloaded names on the Mac.
#ifndef __APPLE__
std::vector<FieldDescription *>::iterator fdit ;
// Loop through the incoming inherited variable names
for ( fdit = in_fdes.begin() ; fdit != in_fdes.end() ; fdit++ ) {
@ -71,6 +91,7 @@ void ClassValues::addInheritedFieldDescriptions(std::vector<FieldDescription *>
}
}
}
#endif
}

View File

@ -235,15 +235,22 @@ bool FieldVisitor::VisitRecordType(clang::RecordType *rt) {
} SB ;
} ;
*/
if ( rt->getDecl()->getIdentifier() == NULL ) {
//std::cout << "hasNameForLinkage " << rt->getDecl()->hasNameForLinkage() << std::endl ;
if ( rt->getDecl()->hasNameForLinkage() ) {
if ( rt->getDecl()->getDeclName() ) {
//std::cout << "getDeclName " << rt->getDecl()->getDeclName().getAsString() << std::endl ;
fdes->setTypeName(rt->getDecl()->getQualifiedNameAsString()) ;
} else {
//std::cout << "getTypedefNameForAnonDecl " << rt->getDecl()->getTypedefNameForAnonDecl() << std::endl ;
fdes->setTypeName(rt->getDecl()->getTypedefNameForAnonDecl()->getQualifiedNameAsString()) ;
}
} else {
//rt->getDecl()->dump() ; std::cout << std::endl ;
// io_src code not possible for anonymous struct/unions. Set the I/O to 0 to ignore it.
if ( debug_level >= 3 ) {
std::cout << "FieldVisitor VisitRecordType found anonymous type, setIO = 0" << std::endl ;
}
fdes->setIO(0) ;
} else {
fdes->setTypeName(rt->getDecl()->getQualifiedNameAsString()) ;
}
fdes->setEnumString("TRICK_STRUCTURED") ;

View File

@ -21,9 +21,6 @@ namespace Trick {
int integrate();
Integrator_type get_Integrator_type() { return(ABM_Method); };
double time;
double time_0;
int counter;
int primed;

View File

@ -156,11 +156,23 @@ int Trick::JSONVariableServer::restart() {
int ret ;
if ( user_port_requested ) {
printf("user_port_requested set %d", port) ;
char hname[80];
static struct sockaddr_in s_in;
gethostname(hname, (size_t) 80);
// Test to see if the restart address is on this machine. If it is not, it's not an error, clear source address
if ( strcmp( source_address.c_str(), hname )) {
if (! inet_pton(AF_INET, source_address.c_str(), (struct in_addr *)&s_in.sin_addr.s_addr) ) {
//printf("clearing source_address\n") ;
source_address.clear() ;
}
}
printf("JSON variable server restart user_port requested set %d\n", port) ;
tc_disconnect(&listen_dev) ;
ret = tc_init_with_connection_info(&listen_dev, AF_INET, SOCK_STREAM, source_address.c_str(), port) ;
if (ret != TC_SUCCESS) {
message_publish(MSG_ERROR, "ERROR: Could not establish listen port %d for Variable Server. Aborting.\n", port);
message_publish(MSG_ERROR, "ERROR: Could not establish listen port %d for JSON Variable Server. Aborting.\n", port);
return (-1);
}
} else {

View File

@ -638,6 +638,9 @@ namespace Trick {
VARIABLE_MAP_ITER variable_map_end() { return variable_map.end() ; } ;
int debug_level; /**< -- Debug level */
static void emitMessage( std::string s);
static void emitError( std::string s);
static void emitWarning( std::string s);
private:
@ -659,6 +662,7 @@ namespace Trick {
int alloc_info_map_counter ; /**< ** counter to assign unique ids to allocations as they are added to map */
int extern_alloc_info_map_counter ; /**< ** counter to assign unique ids to allocations as they are added to map */
void write_checkpoint( std::ostream& out_s, std::vector<ALLOC_INFO*>& dependencies);
/**

View File

@ -94,3 +94,22 @@ Trick::MemoryManager::~MemoryManager() {
}
alloc_info_map.clear() ;
}
#include <sstream>
void Trick::MemoryManager::emitMessage( std::string message) {
std::cerr << "MemoryManager:" << message << std::endl;
std::cerr.flush();
}
void Trick::MemoryManager::emitError( std::string message) {
std::stringstream ss;
ss << "ERROR:" << message << std::endl;
emitMessage( ss.str() );
}
void Trick::MemoryManager::emitWarning( std::string message) {
std::stringstream ss;
ss << "WARNING:" << message << std::endl;
emitMessage( ss.str() );
}

View File

@ -2,8 +2,6 @@
#include <iostream>
#include "sim_services/MemoryManager/include/memorymanager_c_intf.h"
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
/* Global singleton pointer to the memory manager. */
extern Trick::MemoryManager* trick_MM;
@ -19,7 +17,7 @@ extern "C" void* TMM_declare_var( TRICK_TYPE type, const char*class_name, int n_
std::string svar_name = var_name;
return ( trick_MM->declare_var( type, sclass_name, n_stars, svar_name, n_cdims, cdims));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_declare_var() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_declare_var() called before MemoryManager instantiation. Returning NULL.") ;
return ( (void*)NULL);
}
}
@ -33,7 +31,7 @@ extern "C" void* TMM_declare_var_1d( const char* enh_type_spec, int e_elems) {
if (trick_MM != NULL) {
return ( trick_MM->declare_var( enh_type_spec, e_elems));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_declare_var_1d() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_declare_var_1d() called before MemoryManager instantiation. Returning NULL.\n") ;
return ( (void*)NULL);
}
}
@ -47,7 +45,7 @@ extern "C" void* TMM_declare_var_s( const char* declaration) {
if (trick_MM != NULL) {
return ( trick_MM->declare_var( declaration));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_declare_var_s() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_declare_var_s() called before MemoryManager instantiation. Returning NULL.\n") ;
return ( (void*)NULL);
}
}
@ -63,7 +61,7 @@ extern "C" void* alloc_type( int e_elems, const char* enh_type_spec) {
if (trick_MM != NULL) {
return ( trick_MM->declare_var( enh_type_spec, e_elems));
} else {
message_publish(MSG_ERROR, "ERROR: alloc_type() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("alloc_type() called before MemoryManager instantiation. Returning NULL.\n") ;
return ( (void*)NULL);
}
}
@ -77,7 +75,7 @@ extern "C" void* TMM_declare_operatornew_var( const char * class_name, unsigned
if (trick_MM != NULL) {
return trick_MM->declare_operatornew_var( std::string(class_name), alloc_size, element_size ) ;
} else {
message_publish(MSG_ERROR, "ERROR: TMM_declare_var() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_declare_var() called before MemoryManager instantiation. Returning NULL.\n") ;
return (void*)NULL ;
}
}
@ -93,7 +91,7 @@ extern "C" void* TMM_declare_ext_var( void* addr, TRICK_TYPE type, const char*cl
std::string svar_name = var_name;
return ( trick_MM->declare_extern_var( addr, type, sclass_name, n_stars, svar_name, n_cdims, cdims));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_declare_ext_var() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_declare_ext_var() called before MemoryManager instantiation. Returning NULL.\n") ;
return ( (void*)NULL);
}
}
@ -107,7 +105,7 @@ extern "C" void* TMM_declare_ext_var_1d( void* addr, const char* elem_decl, int
if (trick_MM != NULL) {
return ( trick_MM->declare_extern_var( addr, elem_decl, n_elems));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_declare_ext_var_1d() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_declare_ext_var_1d() called before MemoryManager instantiation. Returning NULL.\n") ;
return ( (void*)NULL);
}
}
@ -121,7 +119,7 @@ extern "C" void* TMM_declare_ext_var_s( void* addr, const char* declaration) {
if (trick_MM != NULL) {
return ( trick_MM->declare_extern_var(addr, declaration));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_declare_ext_var_s() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_declare_ext_var_s() called before MemoryManager instantiation. Returning NULL.\n") ;
return ( (void*)NULL);
}
}
@ -137,7 +135,7 @@ void* TMM_resize_array_a(void *address, int n_cdims, int *cdims){
if (trick_MM != NULL) {
return ( trick_MM->resize_array(address, n_cdims, cdims));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_resize_array_a() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_resize_array_a() called before MemoryManager instantiation. Returning NULL.\n") ;
return ( (void*)NULL);
}
}
@ -153,7 +151,7 @@ void* TMM_resize_array_n(const char *name, int n_cdims, int *cdims){
if (trick_MM != NULL) {
return ( trick_MM->resize_array(name, n_cdims, cdims));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_resize_array_n() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_resize_array_n() called before MemoryManager instantiation. Returning NULL.\n") ;
return ( (void*)NULL);
}
}
@ -167,7 +165,7 @@ void* TMM_resize_array_1d_a(void* address, int num){
if (trick_MM != NULL) {
return ( trick_MM->resize_array(address, num));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_resize_array_1d_a() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_resize_array_1d_a() called before MemoryManager instantiation. Returning NULL.\n") ;
return ( (void*)NULL);
}
}
@ -181,7 +179,7 @@ void* TMM_resize_array_1d_n(const char *name, int num){
if (trick_MM != NULL) {
return ( trick_MM->resize_array(name, num));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_resize_array_1d_n() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_resize_array_1d_n() called before MemoryManager instantiation. Returning NULL.\n") ;
return ( (void*)NULL);
}
}
@ -195,7 +193,7 @@ extern "C" char* TMM_strdup(char *str) {
if (trick_MM != NULL) {
return ( trick_MM->mm_strdup( str));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_strdup called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("TMM_strdup called before MemoryManager instantiation. Returning NULL.\n") ;
return( (char*)NULL);
}
}
@ -210,7 +208,7 @@ extern "C" int TMM_var_exists( const char* var_name) {
std::string svar_name = var_name;
return ( trick_MM->var_exists( svar_name));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_var_exists() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_var_exists() called before MemoryManager instantiation.\n") ;
return (0);
}
}
@ -224,7 +222,7 @@ extern "C" int TMM_is_alloced(char *addr) {
if (trick_MM != NULL) {
return ( trick_MM->is_alloced( addr));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_is_alloced() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_is_alloced() called before MemoryManager instantiation.\n") ;
return (0);
}
}
@ -238,7 +236,7 @@ extern "C" void TMM_set_debug_level(int level) {
if (trick_MM != NULL) {
trick_MM->set_debug_level( level);
} else {
message_publish(MSG_ERROR, "ERROR: TMM_set_debug_level() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_set_debug_level() called before MemoryManager instantiation.\n") ;
}
}
@ -250,7 +248,7 @@ extern "C" void TMM_reduced_checkpoint(int yesno) {
if (trick_MM != NULL) {
trick_MM->set_reduced_checkpoint( yesno!=0 );
} else {
message_publish(MSG_ERROR, "ERROR: TMM_reduced_checkpoint() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_reduced_checkpoint() called before MemoryManager instantiation.\n") ;
}
}
@ -262,7 +260,7 @@ extern "C" void TMM_hexfloat_checkpoint(int yesno) {
if (trick_MM != NULL) {
trick_MM->set_hexfloat_checkpoint( yesno!=0 );
} else {
message_publish(MSG_ERROR, "ERROR: TMM_hexfloat_checkpoint() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_hexfloat_checkpoint() called before MemoryManager instantiation.\n") ;
}
}
@ -277,7 +275,7 @@ extern "C" void TMM_clear_var_a(void *addr) {
if (trick_MM != NULL) {
trick_MM->clear_var( addr);
} else {
message_publish(MSG_ERROR, "ERROR: TMM_clear_var_a() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_clear_var_a() called before MemoryManager instantiation.\n") ;
return;
}
}
@ -290,7 +288,7 @@ extern "C" void TMM_clear_var_n( const char* name) {
if (trick_MM != NULL) {
trick_MM->clear_var( name);
} else {
message_publish(MSG_ERROR, "ERROR: TMM_clear_var_n() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_clear_var_n() called before MemoryManager instantiation.\n") ;
return;
}
}
@ -303,7 +301,7 @@ extern "C" void TMM_delete_var_a(void *addr) {
if (trick_MM != NULL) {
trick_MM->delete_var( addr);
} else {
message_publish(MSG_ERROR, "ERROR: TMM_delete_var_a() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_delete_var_a() called before MemoryManager instantiation.\n") ;
return;
}
}
@ -316,7 +314,7 @@ extern "C" void TMM_delete_var_n( const char* name) {
if (trick_MM != NULL) {
trick_MM->delete_var( name);
} else {
message_publish(MSG_ERROR, "ERROR: TMM_delete_var_n() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_delete_var_n() called before MemoryManager instantiation.\n") ;
return;
}
}
@ -329,7 +327,7 @@ extern "C" void TMM_delete_extern_var_a(void *addr) {
if (trick_MM != NULL) {
trick_MM->delete_extern_var( addr);
} else {
message_publish(MSG_ERROR, "ERROR: TMM_delete_extern_var_a() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_delete_extern_var_a() called before MemoryManager instantiation.\n") ;
return;
}
}
@ -342,7 +340,7 @@ extern "C" void TMM_delete_extern_var_n( const char* name) {
if (trick_MM != NULL) {
trick_MM->delete_extern_var( name);
} else {
message_publish(MSG_ERROR, "ERROR: TMM_delete_extern_var_n() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_delete_extern_var_n() called before MemoryManager instantiation.\n") ;
return;
}
}
@ -355,7 +353,7 @@ extern "C" void TMM_write_checkpoint(const char* filename) {
if (trick_MM != NULL) {
return ( trick_MM->write_checkpoint( filename));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_write_checkpoint_fn() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_write_checkpoint_fn() called before MemoryManager instantiation.\n") ;
return;
}
}
@ -368,7 +366,7 @@ extern "C" int TMM_read_checkpoint(const char* filename) {
if (trick_MM != NULL) {
return ( trick_MM->read_checkpoint( filename));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_read_checkpoint() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_read_checkpoint() called before MemoryManager instantiation.\n") ;
return(1);
}
}
@ -381,7 +379,7 @@ extern "C" int TMM_read_checkpoint_from_string(const char* str) {
if (trick_MM != NULL) {
return ( trick_MM->read_checkpoint_from_string( str));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_read_checkpoint_from_string() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_read_checkpoint_from_string() called before MemoryManager instantiation.\n") ;
return(1);
}
}
@ -394,7 +392,7 @@ extern "C" int TMM_init_from_checkpoint(const char* filename) {
if (trick_MM != NULL) {
return ( trick_MM->init_from_checkpoint( filename));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_init_from_checkpoint() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_init_from_checkpoint() called before MemoryManager instantiation.\n") ;
return(1);
}
}
@ -407,7 +405,7 @@ extern "C" int TMM_add_shared_library_symbols(const char* filename) {
if (trick_MM != NULL) {
return ( trick_MM->add_shared_library_symbols( filename));
} else {
message_publish(MSG_ERROR, "ERROR: TMM_add_shared_library_symbols() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("TMM_add_shared_library_symbols() called before MemoryManager instantiation.\n") ;
return(1);
}
}
@ -420,7 +418,7 @@ extern "C" void* add_var( TRICK_TYPE type, const char* stype, VAR_DECLARE* var_d
if (trick_MM != NULL) {
return( trick_MM->add_var(type, stype, var_declare, units ));
} else {
message_publish(MSG_ERROR, "ERROR: add_var() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("add_var() called before MemoryManager instantiation. Returning NULL.\n") ;
return ((void*)NULL);
}
}
@ -433,7 +431,7 @@ extern "C" int add_vars( TRICK_TYPE type, const char* stype, VAR_LIST* var_list,
if (trick_MM != NULL) {
return( trick_MM->add_vars(type, stype, var_list, units ));
} else {
message_publish(MSG_ERROR, "ERROR: add_vars() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("add_vars() called before MemoryManager instantiation.\n") ;
return (1);
}
}
@ -446,7 +444,7 @@ extern "C" int ref_allocate(REF2 *R, int num) {
if (trick_MM != NULL) {
return( trick_MM->ref_allocate( R, num));
} else {
message_publish(MSG_ERROR, "ERROR: ref_allocate() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("ref_allocate() called before MemoryManager instantiation.\n") ;
return (1);
}
}
@ -459,7 +457,7 @@ extern "C" REF2* ref_attributes( char* name) {
if (trick_MM != NULL) {
return( trick_MM->ref_attributes( name));
} else {
message_publish(MSG_ERROR, "ERROR: ref_attributes() called before MemoryManager instantiation. Returning NULL.\n") ;
Trick::MemoryManager::emitError("ref_attributes() called before MemoryManager instantiation. Returning NULL.\n") ;
return ( (REF2*)NULL);
}
}
@ -472,7 +470,7 @@ extern "C" int ref_assignment(REF2* R, V_TREE* V) {
if (trick_MM != NULL) {
return( trick_MM->ref_assignment( R, V));
} else {
message_publish(MSG_ERROR, "ERROR: ref_assignment() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("ref_assignment() called before MemoryManager instantiation.\n") ;
return (1);
}
}
@ -485,7 +483,7 @@ extern "C" int ref_var(REF2 *R, char* name) {
if (trick_MM != NULL) {
return( trick_MM->ref_var( R, name));
} else {
message_publish(MSG_ERROR, "ERROR: ref_var() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("ref_var() called before MemoryManager instantiation.\n") ;
return (1);
}
}
@ -498,7 +496,7 @@ extern "C" int get_size(void *addr) {
if (trick_MM != NULL) {
return( trick_MM->get_size( addr));
} else {
message_publish(MSG_ERROR, "ERROR: get_size() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("get_size() called before MemoryManager instantiation.\n") ;
return (0);
}
}
@ -511,7 +509,7 @@ extern "C" int get_truncated_size(void *addr) {
if (trick_MM != NULL) {
return( trick_MM->get_truncated_size( addr));
} else {
message_publish(MSG_ERROR, "ERROR: get_truncated_size() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("get_truncated_size() called before MemoryManager instantiation.\n") ;
return (0);
}
}
@ -525,8 +523,7 @@ extern "C" int io_get_fixed_truncated_size(char *ptr __attribute__ ((unused)),
char *str __attribute__ ((unused)),
int dims __attribute__ ((unused)),
ATTRIBUTES * left_type __attribute__ ((unused))) {
// FIXME
message_publish(MSG_ERROR, "Memory Manager INTERNAL-ERROR: io_get_fixed_truncated_size() is not implemented yet.\n") ;
Trick::MemoryManager::emitError("io_get_fixed_truncated_size() is not implemented yet.\n") ;
return(0);
}
@ -538,7 +535,7 @@ extern "C" ALLOC_INFO* get_alloc_info_of(void * addr) {
if (trick_MM != NULL) {
return( trick_MM->get_alloc_info_of( addr));
} else {
message_publish(MSG_ERROR, "ERROR: get_alloc_info_of() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("get_alloc_info_of() called before MemoryManager instantiation.\n") ;
return ( (ALLOC_INFO*)NULL);
}
}
@ -551,7 +548,7 @@ extern "C" ALLOC_INFO* get_alloc_info_at(void * addr) {
if (trick_MM != NULL) {
return( trick_MM->get_alloc_info_at( addr));
} else {
message_publish(MSG_ERROR, "ERROR: get_alloc_info_at() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("get_alloc_info_at() called before MemoryManager instantiation.\n") ;
return ( (ALLOC_INFO*)NULL);
}
}
@ -560,7 +557,7 @@ extern "C" int set_alloc_name_at(void * addr, const char * name ) {
if (trick_MM != NULL) {
return( trick_MM->set_name_at(addr, name));
} else {
message_publish(MSG_ERROR, "ERROR: get_alloc_info_at() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("get_alloc_info_at() called before MemoryManager instantiation.\n") ;
return ( -1 );
}
}
@ -573,7 +570,7 @@ extern "C" int get_enumerated(const char* name, V_DATA* v_data) {
if (trick_MM != NULL) {
return( trick_MM->get_enumerated(name, v_data ));
} else {
message_publish(MSG_ERROR, "ERROR: get_enumerated() called before MemoryManager instantiation.\n") ;
Trick::MemoryManager::emitError("get_enumerated() called before MemoryManager instantiation.\n") ;
return 1 ;
}
}

View File

@ -1,4 +1,5 @@
#include <iostream>
#include <sstream>
#include <algorithm>
#include <dlfcn.h>
@ -8,8 +9,6 @@
#include "sim_services/SimObject/include/SimObject.hh"
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
/**
*
@ -83,9 +82,11 @@ int Trick::MemoryManager::add_attr_info( std::string & user_type_string , ATTRIB
}
if ( size_func == NULL) {
message_publish(MSG_WARNING, "Memory Manager WARNING (%s:%d): Couldn't find an io_src_sizeof_ function for type %s [%s()].\n",
file_name , line_num ,
user_type_string.c_str(), size_func_name.c_str()) ;
std::stringstream message;
message << "(" << file_name << ":" << line_num
<< "): Couldn't find an io_src_sizeof_ function for type"
<< user_type_string.c_str() << "[" << size_func_name.c_str() << "()].";
emitWarning(message.str());
}
// Attempt to find an attributes list for the named user type.
@ -110,8 +111,10 @@ int Trick::MemoryManager::add_attr_info( std::string & user_type_string , ATTRIB
if ( init_sub_attr != NULL ) { // If the initialization function was found,
(*init_sub_attr)() ; // then call it.
} else {
message_publish(MSG_WARNING, "Memory Manager WARNING: ATTRIBUTES init routine for type \"%s\" not found.\n",
user_type_name.c_str()) ;
std::stringstream message;
message << " ATTRIBUTES init routine for type \""
<< user_type_name.c_str() << "\" not found.";
emitWarning(message.str());
return(1) ;
}
@ -139,9 +142,9 @@ int Trick::MemoryManager::add_attr_info( std::string & user_type_string , ATTRIB
// otherwise ...
} else {
// Declare an ERROR condition.
message_publish(MSG_WARNING, "Memory Manager WARNING: ATTRIBUTES for type %s not found.\n", user_type_name.c_str()) ;
std::stringstream message;
message << "ATTRIBUTES for type \"" << user_type_name.c_str() << "\" not found.";
emitWarning(message.str());
return(1) ;
}
} else {

View File

@ -6,11 +6,10 @@
*/
#include <iostream>
#include <sstream>
#include <dlfcn.h>
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
/* This routine only returns the size if ptr points to the beginning of the allocation area */
int Trick::MemoryManager::add_shared_library_symbols(const char * file_name) {
@ -21,7 +20,9 @@ int Trick::MemoryManager::add_shared_library_symbols(const char * file_name) {
if ( new_handle != NULL ) {
dlhandles.push_back(new_handle) ;
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: add_shared_library_symbols could not find library file: %s.\n", file_name) ;
std::stringstream message;
message << "add_shared_library_symbols could not find library file: \"" << file_name << "\".";
emitError(message.str());
}
return 0 ;

View File

@ -8,8 +8,6 @@
#include "sim_services/MemoryManager/include/value.h"
#include "sim_services/MemoryManager/include/vval.h"
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
void* Trick::MemoryManager::add_var( TRICK_TYPE type,
const char* class_name,
@ -36,8 +34,8 @@ void* Trick::MemoryManager::add_var( TRICK_TYPE type,
variable_pos = variable_map.find( var_declare->name);
if (variable_pos != variable_map.end()) {
std::stringstream ss;
ss << "Memory Manager: Variable \""<< var_declare->name << "\" is already declared.\n";
message_publish(MSG_ERROR, ss.str().c_str() ) ;
ss << "Variable \""<< var_declare->name << "\" is already declared.\n";
emitError(ss.str());
pthread_mutex_unlock(&mm_mutex);
return ((void*)NULL);
}
@ -54,11 +52,10 @@ void* Trick::MemoryManager::add_var( TRICK_TYPE type,
/** @li Call declare_var to create a named-allocation. */
if ((address = declare_var( type, class_name_string, n_stars, var_declare->name, n_cdims, cdims)) == NULL) {
std::stringstream ss;
ss << "Memory Manager ERROR: Declaration \"" ;
ss << "Declaration \"" ;
ss << make_decl_string( type, class_name_string, n_stars, var_declare->name, n_cdims, cdims);
ss << "\" failed.";
ss << std::endl;
message_publish(MSG_ERROR, ss.str().c_str() ) ;
emitError( ss.str()) ;
return ((void*)NULL);
}

View File

@ -1,6 +1,4 @@
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
#include <sstream>
ALLOC_INFO* Trick::MemoryManager::get_alloc_info_of( void* addr) {
@ -37,10 +35,9 @@ int Trick::MemoryManager::set_name_at( void* addr , const char * name ) {
variable_pos = variable_map.find(name);
if (variable_pos != variable_map.end()) {
std::stringstream ss;
ss << "Memory Manager ERROR: Call to set_name_at() failed because a variable named \""
<< name <<"\" already exists."
<< std::endl ;
message_publish(MSG_ERROR, ss.str().c_str() );
ss << "Call to set_name_at() failed because a variable named \""
<< name << "\" already exists.";
emitError(ss.str());
pthread_mutex_unlock(&mm_mutex);
ret = -1 ;
} else {

View File

@ -1,7 +1,6 @@
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/MemoryManager/include/bitfield_proto.h"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
#include <sstream>
void Trick::MemoryManager::clear_rvalue( void* base_address, ATTRIBUTES* attr, int curr_dim, int offset) {
@ -49,8 +48,8 @@ void Trick::MemoryManager::clear_rvalue( void* base_address, ATTRIBUTES* attr, i
final_address = (char*)base_address + offset * sizeof(short);
*(short*)final_address = 0;
} else {
message_publish(MSG_ERROR, "Memory Manager INTERNAL-ERROR: Unexpected size of ENUMERATION type.\n") ;
}
emitError("INTERNAL-ERROR - Unexpected size of ENUMERATION type.") ;
}
break;
case TRICK_LONG :
case TRICK_UNSIGNED_LONG :
@ -83,8 +82,9 @@ void Trick::MemoryManager::clear_rvalue( void* base_address, ATTRIBUTES* attr, i
*(unsigned char*)final_address = insert_bitfield_any(
*(unsigned char*)final_address, 0, attr->size, attr->index[0].start, attr->index[0].size);
} else {
message_publish(MSG_ERROR, "Memory Manager INTERNAL ERROR - Unhandled bitfield struct size (%d) "
"in bitfield assignment.\n", attr->size) ;
std::stringstream message;
message << "INTERNAL - Unhandled bitfield struct size (" << attr->size << ") in bitfield assignment.";
emitError(message.str());
}
break;
case TRICK_FILE_PTR :
@ -96,7 +96,9 @@ void Trick::MemoryManager::clear_rvalue( void* base_address, ATTRIBUTES* attr, i
*(std::string*)final_address = "";
break;
default :
message_publish(MSG_ERROR, "Memory Manager ERROR: Unhandled Type (%d).\n", (int)attr->type) ;
std::stringstream message;
message << "Unhandled Type (" << (int)attr->type << ").";
emitError(message.str());
break;
}
@ -132,7 +134,9 @@ void Trick::MemoryManager::clear_rvalue( void* base_address, ATTRIBUTES* attr, i
}
} else {
message_publish(MSG_ERROR, "Memory Manager INTERNAL-ERROR: Remaining dimensions are negative!?.\n") ;
std::stringstream message;
message << "This is bad. Remaining dimensions are negative!?.";
emitError(message.str());
}
}
@ -230,8 +234,10 @@ void Trick::MemoryManager::clear_var( void* address) {
}
free_reference_attr( reference_attr);
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot clear the variable at address %p\n"
"because memory manager knows nothing about it.\n", address) ;
std::stringstream message;
message << "Cannot clear the variable at address " << address
<< "because memory manager knows nothing about it." ;
emitError(message.str());
}
pthread_mutex_unlock(&mm_mutex);
}
@ -251,8 +257,10 @@ void Trick::MemoryManager::clear_var( const char* name) {
pthread_mutex_unlock(&mm_mutex);
clear_var( alloc_info->start);
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot clear variable \"%s\"\n"
"because it doesn't exist.\n", name) ;
std::stringstream message;
message << "Can't clear variable \"" << name
<< "\" because it doesn't exist.";
emitError(message.str());
}
pthread_mutex_unlock(&mm_mutex);
}

View File

@ -5,8 +5,6 @@
#include <dlfcn.h>
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/MemoryManager/include/ADefParseContext.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
/**
@page examples_declare_var Examples of declare_var
@ -71,9 +69,9 @@ void* Trick::MemoryManager::declare_var( TRICK_TYPE type,
pthread_mutex_lock(&mm_mutex);
variable_pos = variable_map.find( var_name);
if (variable_pos != variable_map.end()) {
std::stringstream ss;
ss << "Memory Manager ERROR: Variable \""<< var_name <<"\" already declared.\n";
message_publish(MSG_ERROR, ss.str().c_str() );
std::stringstream message;
message << "Variable \""<< var_name <<"\" already declared.\n";
emitError(message.str());
pthread_mutex_unlock(&mm_mutex);
return ((void*)NULL);
}
@ -90,26 +88,25 @@ void* Trick::MemoryManager::declare_var( TRICK_TYPE type,
n_elems = n_elems * cdims[ii];
}
if (n_elems == 0) {
std::stringstream ss;
ss << "Memory Manager ERROR: In the following declaration, ";
ss << "one or more of the constrained dimensions is zero." ;
ss << std::endl;
std::stringstream message;
message << "In the following declaration, ";
message << "one or more of the constrained dimensions is zero." ;
message << std::endl;
// Print declaration.
ss << make_decl_string( type, user_type_name, n_stars, var_name, n_cdims, cdims);
ss << std::endl;
message_publish(MSG_ERROR, ss.str().c_str() ) ;
message << make_decl_string( type, user_type_name, n_stars, var_name, n_cdims, cdims);
emitError(message.str()) ;
return ((void*)NULL);
}
/** @li From the TRICK_TYPE, user_type_name and the number of pointers (asterisks),
determine the size and the attributes of an element. */
if ( get_type_attributes(type, user_type_name, n_stars, sub_attr, size) != 0) {
std::stringstream ss;
ss << "Memory Manager ERROR: get_type_attributes failed for type: ";
ss << trickTypeCharString(type, user_type_name.c_str());
ss << std::endl;
message_publish(MSG_ERROR, ss.str().c_str() ) ;
std::stringstream message;
message << "get_type_attributes failed for type: ";
message << trickTypeCharString(type, user_type_name.c_str());
message << std::endl;
emitError(message.str()) ;
return ((void*)NULL);
}
@ -120,12 +117,11 @@ void* Trick::MemoryManager::declare_var( TRICK_TYPE type,
(n_stars == 0 ) ) {
if ((address = io_src_allocate_class( user_type_name.c_str(), n_elems)) == NULL) {
std::stringstream ss;
ss << "Memory Manager ERROR: io_src_allocate_class (";
ss << user_type_name << "," << n_elems ;
ss << ") failed to allocate any memory.";
ss << std::endl;
message_publish(MSG_ERROR, ss.str().c_str() ) ;
std::stringstream message;
message << "io_src_allocate_class (";
message << user_type_name << "," << n_elems ;
message << ") failed to allocate any memory.";
emitError(message.str()) ;
return ((void*)NULL);
}
@ -145,7 +141,7 @@ void* Trick::MemoryManager::declare_var( TRICK_TYPE type,
language = Language_CPP;
} else {
if ( (address = calloc( (size_t)n_elems, (size_t)size ) ) == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
emitError("Out of memory.") ;
return ((void*)NULL);
}
language = Language_C;
@ -194,7 +190,7 @@ void* Trick::MemoryManager::declare_var( TRICK_TYPE type,
}
pthread_mutex_unlock(&mm_mutex);
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
emitError("Out of memory.\n") ;
return ((void*)NULL);
}
@ -246,7 +242,9 @@ void* Trick::MemoryManager::declare_var( const char *alloc_definition) {
/** @li Delete the parse context. */
delete( context);
} else {
message_publish(MSG_ERROR, "Memory Manager: Invalid declaration (failed to parse): \"%s\".\n", alloc_definition) ;
std::stringstream message;
message << "Invalid declaration (failed to parse): \"" << alloc_definition << "\".";
emitError(message.str());
}
}
/** @li Return the address of the allocation. */
@ -296,7 +294,9 @@ void* Trick::MemoryManager::declare_var( const char *element_definition, int n_e
/** @li Delete the parse context. */
delete( context);
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: declare_var( \"%s\",%d).\n", element_definition, n_elems) ;
std::stringstream message;
message << "declare_var( \"" << element_definition << "\"," << n_elems <<").";
emitError(message.str());
}
}
/** @li Return the address of the allocation. */
@ -323,13 +323,15 @@ void* Trick::MemoryManager::declare_operatornew_var( std::string user_type_name,
/** @li From the TRICK_TYPE, user_type_name and the number of pointers (asterisks),
determine the size and the attributes of an element. */
if ( get_type_attributes(type, user_type_name, 0, sub_attr, size_ref ) != 0) {
message_publish(MSG_ERROR, "Memory Manager ERROR: get_type_attributes failed for type: %d %s.\n",
TRICK_STRUCTURED, user_type_name.c_str()) ;
std::stringstream message;
message << "get_type_attributes failed for type: " << TRICK_STRUCTURED
<< " " << user_type_name.c_str() << ".";
emitError(message.str());
return ((void*)NULL);
}
if ( (address = calloc( 1, alloc_size ) ) == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
emitError("Out of memory.") ;
return ((void*)NULL);
}
@ -362,7 +364,7 @@ void* Trick::MemoryManager::declare_operatornew_var( std::string user_type_name,
alloc_info_map[address] = new_alloc;
pthread_mutex_unlock(&mm_mutex);
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
emitError("Out of memory.") ;
return ((void*)NULL);
}
@ -404,7 +406,9 @@ size_t Trick::MemoryManager::sizeof_type( const char* var_definition) {
n_elems *= context->cdims[ii];
}
} else {
message_publish(MSG_ERROR, "Memory Manager: Invalid variable definition \"%s\" in sizeof_type.\n", var_definition) ;
std::stringstream message;
message << "Invalid variable definition \"" << var_definition << "\" in sizeof_type.";
emitError(message.str());
}
delete( context);
}

View File

@ -4,14 +4,14 @@
#include <sstream>
#include <dlfcn.h>
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
// MEMBER FUNCTION
int Trick::MemoryManager::delete_var(void* address, bool destroy ) {
if (address == 0) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot delete memory at NULL.\n") ;
std::stringstream message;
message << "Cannot delete memory at NULL.";
emitError(message.str());
return 1;
}
@ -64,10 +64,10 @@ int Trick::MemoryManager::delete_var(void* address, bool destroy ) {
free(alloc_info);
} else {
message_publish(MSG_WARNING,
"WARNING: The Trick MemoryManager cannot delete memory at address %p \n"
"because the MemoryManager did not allocate it, nor does the\n"
"MemoryManager know anything about it.\n", address) ;
std::stringstream message;
message << "The MemoryManager cannot delete memory at address ["
<< address << "] because it has no record of it.";
emitWarning(message.str());
return 1 ;
}
@ -89,7 +89,10 @@ int Trick::MemoryManager::delete_var( const char* name) {
pthread_mutex_unlock(&mm_mutex);
return( delete_var( alloc_info->start));
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot delete variable \"%s\" because it doesn't exist.\n", name) ;
std::stringstream message;
message << "Cannot delete variable \"" << name
<< "\" because it doesn't exist." ;
emitError(message.str());
}
pthread_mutex_unlock(&mm_mutex);
return 1;

View File

@ -1,6 +1,5 @@
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
#include <sstream>
int Trick::MemoryManager::get_type_attributes( TRICK_TYPE& type,
std::string user_type_name,
@ -68,7 +67,9 @@ int Trick::MemoryManager::get_type_attributes( TRICK_TYPE& type,
size = sizeof(void*);
} else {
if ((size = io_src_sizeof_user_type( user_type_name.c_str())) == 0) {
message_publish(MSG_ERROR, "Memory Manager ERROR: size of type \"%s\" not found.\n", user_type_name.c_str()) ;
std::stringstream message;
message << "size of type \"" << user_type_name.c_str() <<"\" not found.\n";
emitError(message.str());
return (1);
}
}
@ -86,7 +87,9 @@ int Trick::MemoryManager::get_type_attributes( TRICK_TYPE& type,
} break;
default: {
message_publish(MSG_ERROR, "Memory Manager ERROR: Unknown Trick data-type: %d.\n", type) ;
std::stringstream message;
message << "Unknown data-type \"" << type << "\"." ;
emitError(message.str());
return (1);
} break;
}

View File

@ -4,8 +4,6 @@
#include <dlfcn.h>
// Provides dlsym().
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
// MEMBER FUNCTION: void* Trick::MemoryManager::io_src_allocate_class(const char* class_name, int num);
@ -48,7 +46,10 @@ void* Trick::MemoryManager::io_src_allocate_class(const char* class_name, int nu
} else {
const char* msg = dlerror();
addr = NULL;
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't find function %s().\n%s\n", alloc_fn_name,msg);
std::stringstream message;
message << "Couldn't find function \"" << alloc_fn_name << "()\". "
<< "dlerror= " << msg;
emitError(message.str());
}
return (addr);
}
@ -80,7 +81,10 @@ void Trick::MemoryManager::io_src_destruct_class(ALLOC_INFO * alloc_info) {
(*destruct)(alloc_info->start, alloc_info->num) ;
} else {
const char* msg = dlerror();
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't find function %s().\n%s\n", destruct_fn_name,msg);
std::stringstream message;
message << "Couldn't find function \"" << destruct_fn_name << "()\". "
<< "dlerror= " << msg;
emitError(message.str());
}
}
}
@ -111,7 +115,10 @@ void Trick::MemoryManager::io_src_delete_class(ALLOC_INFO * alloc_info) {
(*delete_fn)(alloc_info->start) ;
} else {
const char* msg = dlerror();
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't find function %s().\n%s\n", delete_fn_name,msg);
std::stringstream message;
message << "Couldn't find function \"" << delete_fn_name << "()\". "
<< "dlerror= " << msg;
emitError(message.str());
}
}
}
@ -148,7 +155,10 @@ size_t Trick::MemoryManager::io_src_sizeof_user_type( const char* user_type_name
} else {
const char* msg = dlerror();
class_size = 0;
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't find function %s().\n%s\n", size_fn_name,msg);
std::stringstream message;
message << "Couldn't find function \"" << size_fn_name << "()\". "
<< "dlerror= " << msg;
emitError(message.str());
}
return (class_size);
}

View File

@ -3,8 +3,6 @@
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/MemoryManager/include/ADefParseContext.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
/**
@par Description:
@ -35,7 +33,7 @@ void* Trick::MemoryManager::
/** @li Validate Parameters. The address can't be NULL.*/
if (address == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: declare_extern_var called with NULL address.\n") ;
emitError("declare_extern_var() called with NULL address.");
return ((void*)NULL);
}
@ -44,7 +42,9 @@ void* Trick::MemoryManager::
pthread_mutex_lock(&mm_mutex);
variable_pos = variable_map.find( var_name);
if (variable_pos != variable_map.end()) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Variable \"%s\" already declared.\n", var_name.c_str()) ;
std::stringstream message;
message << "Variable \""<< var_name <<"\" already declared.";
emitError(message.str());
pthread_mutex_unlock(&mm_mutex);
return ((void*)NULL);
}
@ -62,15 +62,21 @@ void* Trick::MemoryManager::
n_elems = n_elems * cdims[ii];
}
if (n_elems == 0) {
// FIXME: This Error message needs to improved.
message_publish(MSG_ERROR, "Memory Manager ERROR: One or more of the constrained dimensions is zero.\n") ;
std::stringstream message;
message << "declare_extern_var() can't register \"" << var_name
<< "\" because one or more of its constrained dimensions "
<< "is zero, thus making its total size zero.";
emitError(message.str());
return ((void*)NULL);
}
/** @li From the TRICK_TYPE, user_type_name and the number of pointers (asterisks),
determine the size and the attributes of an element. */
if ( get_type_attributes(type, user_type_name, n_stars, sub_attr, size) != 0) {
message_publish(MSG_ERROR, "Memory Manager ERROR: get_type_attributes failed for type %d %s.\n", type, user_type_name.c_str()) ;
std::stringstream message;
message << "get_type_attributes failed for type "
<< type << " \"" << user_type_name << "\".";
emitError(message.str());
return ((void*)NULL);
}
@ -123,7 +129,7 @@ void* Trick::MemoryManager::
}
pthread_mutex_unlock(&mm_mutex);
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
emitError("Out of memory.") ;
return ((void*)NULL);
}
@ -179,7 +185,9 @@ void* Trick::MemoryManager::
/** @li Delete the parse context. */
delete( context);
} else {
message_publish(MSG_ERROR, "Memory Manager: Invalid declaration \"%s\".\n", alloc_definition) ;
std::stringstream message;
message << "Invalid declaration \"" << alloc_definition << "\".";
emitError(message.str());
}
}
/** @li Return the address. */
@ -232,7 +240,10 @@ void* Trick::MemoryManager::
/** @li Delete the parse context. */
delete( context);
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: declare_extern_var( \"%s\",%d).\n", element_definition, n_elems) ;
std::stringstream message;
message << "declare_extern_var( \"" << element_definition
<< "\"," << n_elems << ") failed.";
emitError(message.str());
}
}
/** @li Return the address of the allocation. */

View File

@ -1,8 +1,7 @@
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
#include <dlfcn.h>
#include <stdlib.h>
#include <sstream>
// PRIVATE MEMBER FUNCTION
void Trick::MemoryManager::recursive_array_copy( void *s_base,
@ -65,22 +64,23 @@ void* Trick::MemoryManager::resize_array( void *address, int n_cdims, int *cdims
alloc_info = get_alloc_info_at( address);
if (alloc_info == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Address passed to resize_array is NULL.\n") ;
emitError("Address passed to resize_array is NULL.") ;
pthread_mutex_unlock(&mm_mutex);
return ( (void*)NULL);
}
if (alloc_info->stcl != TRICK_LOCAL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot resize the array variable at address %p "
"because it did not allocate it.\n", address) ;
std::stringstream message;
message << "Cannot resize the array at [" << address << "] because it's EXTERN.";
emitError(message.str());
pthread_mutex_unlock(&mm_mutex);
return ( (void*)NULL);
}
if (alloc_info->type == TRICK_STRING) {
message_publish(MSG_ERROR, "Memory Manager resize_array ERROR: at address %p."
" Arrays of STL strings are not supported."
" Consider using a vector of strings.\n", address) ;
std::stringstream message;
message << "resize_array doesn't support STL strings.";
emitError(message.str());
pthread_mutex_unlock(&mm_mutex);
return ( (void*)NULL);
}
@ -99,13 +99,17 @@ void* Trick::MemoryManager::resize_array( void *address, int n_cdims, int *cdims
are the same as those in the proposed re-allocation.*/
if (n_cdims != pre_n_cdims) {
if (pre_n_cdims == 0) {
message_publish(MSG_ERROR, "Memory Manager resize_array ERROR: The object at address %p is not an array.\n"
"If you want to be able to resize it then\n"
"declare it as an array (of one) in the first place.\n", address) ;
std::stringstream message;
message << "resize_array: The object at address [" << address
<< "] is not an array. If you want to be able to resize "
<< "it then declare it as an array (of at least one).";
emitError(message.str());
} else {
message_publish(MSG_ERROR, "Memory Manager resize_array ERROR: The number of dimensions specified, \"%d\",\n"
"doesn't match the number of (non-pointer) dimensions of the object, \"%d\",\n"
"at address %p\n.", n_cdims, pre_n_cdims, address) ;
std::stringstream message;
message << "resize_array: The number of dimensions specified, [" << n_cdims
<< "], doesn't match the number of dimensions of the object at "
<< address <<", [" << pre_n_cdims << "].";
emitError(message.str());
}
return ( (void*)NULL);
}
@ -116,7 +120,7 @@ void* Trick::MemoryManager::resize_array( void *address, int n_cdims, int *cdims
new_n_elems = new_n_elems * cdims[ii];
}
if (new_n_elems == 0) {
message_publish(MSG_ERROR, "Memory Manager ERROR: One or more of the constrained dimensions is zero.\n") ;
emitError("One or more of the constrained dimensions is zero.");
return ((void*)NULL);
}
@ -127,8 +131,9 @@ void* Trick::MemoryManager::resize_array( void *address, int n_cdims, int *cdims
(alloc_info->num_index == n_cdims) ) {
if ((new_address = io_src_allocate_class( alloc_info->user_type_name, new_n_elems)) == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: io_src_allocate_class(%s,%d) failed to allocate any memory.\n",
alloc_info->user_type_name, new_n_elems) ;
std::stringstream message;
message << "io_src_allocate_class(" << alloc_info->user_type_name << "," << new_n_elems << ") failed to allocate any memory.";
emitError(message.str());
pthread_mutex_unlock(&mm_mutex);
return ((void*)NULL);
}
@ -140,7 +145,7 @@ void* Trick::MemoryManager::resize_array( void *address, int n_cdims, int *cdims
}
} else {
if ( (new_address = calloc( (size_t)new_n_elems, (size_t)alloc_info->size ) ) == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Out of memory.\n") ;
emitError("Out of memory.") ;
pthread_mutex_unlock(&mm_mutex);
return ((void*)NULL);
}
@ -210,7 +215,9 @@ void* Trick::MemoryManager::resize_array( const char* name, int n_cdims, int *cd
pthread_mutex_unlock(&mm_mutex);
return( resize_array( alloc_info->start, n_cdims, cdims));
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Cannot resize variable \"%s\" because it doesn't exist.\n", name) ;
std::stringstream message;
message << "Cannot resize variable \"" << name << "\" because it doesn't exist.";
emitError(message.str());
}
pthread_mutex_unlock(&mm_mutex);
return NULL ;

View File

@ -1,12 +1,11 @@
#include <iostream>
#include <sys/types.h>
#include <string.h>
#include <sstream>
#include "sim_services/MemoryManager/include/attributes.h"
#include "sim_services/MemoryManager/include/reference.h"
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
int Trick::MemoryManager::ref_allocate(REF2 * R , int num ) {
@ -16,15 +15,15 @@ int Trick::MemoryManager::ref_allocate(REF2 * R , int num ) {
/** @li Validate Parameters.*/
if (R == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: R is NULL in call to ref_allocate(R,num).\n") ;
emitError("R is NULL in call to ref_allocate(R,num).") ;
return (1);
}
if (R->attr == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: R->attr is NULL in call to ref_allocate(R,num).\n") ;
emitError("R->attr is NULL in call to ref_allocate(R,num).") ;
return (1);
}
if (num <= 0) {
message_publish(MSG_ERROR, "Memory Manager ERROR: num is <= 0 in call to ref_allocate(R,num).\n") ;
emitError("num is <= 0 in call to ref_allocate(R,num).") ;
return (1);
}

View File

@ -2,11 +2,10 @@
#include "sim_services/MemoryManager/include/bitfield_proto.h"
#include "sim_services/MemoryManager/include/vval.h"
#include "sim_services/MemoryManager/include/wcs_ext.h"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
#include "trick_utils/units/include/Unit.hh"
#include "trick_utils/units/include/UCFn.hh"
#include <limits.h>
#include <sstream>
int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, int curr_dim, int offset, V_TREE* v_tree, UCFn* cf) {
@ -18,13 +17,13 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
switch (attr->type) {
case TRICK_CHARACTER :
case TRICK_UNSIGNED_CHARACTER :
case TRICK_UNSIGNED_CHARACTER :
assign_addr = (char*)base_addr + offset * sizeof(char);
if (v_tree && v_tree->v_data) {
*(char*)assign_addr = vval_char(v_tree->v_data);
} else {
*(char*)assign_addr = '\0';
}
}
if (debug_level) {
std::cout << std::endl << "Assignment: *(char*)" << (void*)assign_addr
<< " = ";
@ -68,19 +67,12 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
case TRICK_UNSIGNED_INTEGER :
assign_addr = (char*)base_addr + offset * sizeof(int);
if (v_tree && v_tree->v_data) {
int input_value;
int input_value;
input_value = vval_int(v_tree->v_data);
if (cf == NULL) {
*(int *)assign_addr = input_value;
} else {
int assign_value;
assign_value = (int)(input_value * cf->C[1] + cf->C[0]);
if ((assign_value <= INT_MAX) && (assign_value >= INT_MIN)) {
*(int *)assign_addr = (int)assign_value;
} else {
*(int *)assign_addr = input_value;
message_publish(MSG_ERROR, "Memory Manager ERROR: Unit conversion makes value too large to be assigned. Ignoring\n") ;
}
*(int *)assign_addr = input_value * cf->C[1] + cf->C[0];
}
} else {
*(int *)assign_addr = 0;
@ -123,10 +115,12 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
std::cout.flush();
}
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Enumeration of size %d is not supported.\n", attr->size) ;
std::stringstream message;
message << "Enumeration of size " << attr->size << " is not supported.";
emitError(message.str());
}
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: v_tree data is corrupt.\n") ;
emitError("v_tree data appears to be corrupted.");
}
break;
case TRICK_LONG :
@ -138,15 +132,8 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
if (cf == NULL) {
*(long *)assign_addr = input_value;
} else {
double assign_value;
assign_value = input_value * cf->C[1] + cf->C[0];
if ((assign_value <= LONG_MAX) && (assign_value >= LONG_MIN)) {
*(long *)assign_addr = (long)assign_value;
} else {
*(long *)assign_addr = input_value;
message_publish(MSG_ERROR, "Memory Manager ERROR: Unit conversion makes value too large to be assigned. Ignoring\n") ;
}
}
*(long *)assign_addr = input_value * cf->C[1] + cf->C[0];
}
} else {
*(long *)assign_addr = 0;
}
@ -227,9 +214,10 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
*(unsigned char*)assign_addr = insert_bitfield_any(
*(unsigned char*)assign_addr, input_value, attr->size, attr->index[0].start, attr->index[0].size);
} else {
message_publish(MSG_ERROR, "Memory Manager INTERNAL ERROR:\n"
"Unhandled bitfield struct size (%d) in bitfield assignment.\n", attr->size) ;
}
std::stringstream message;
message << "Unhandled bitfield struct size (" << attr->size << ") in bitfield assignment.";
emitError(message.str());
}
if (debug_level) {
std::cout << std::endl << "Assignment: "
<< "Within the " << attr->size << " byte struct at " << (void*)assign_addr
@ -268,7 +256,9 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
}
break;
default:
message_publish(MSG_ERROR, "Memory Manager ERROR: Unhandled Type (%d) in assignment.\n", attr->type) ;
std::stringstream message;
message << "Unhandled Type (" << attr->type << ") in assignment.";
emitError(message.str());
return (1);
break;
}
@ -314,7 +304,7 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
if (rhs_len <= size_of_curr_dim ) {
strcpy((char*)assign_addr, v_tree->v_data->value.cp);
} else {
message_publish(MSG_ERROR, "Memory Manager: char array is too small for the attempted string assignment.\n") ;
emitError("Memory Manager: char array is too small for the attempted string assignment.");
return (1);
}
} else {
@ -332,7 +322,10 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
if (rhs_len <= size_of_curr_dim ) {
wcscpy((wchar_t*)assign_addr, v_tree->v_data->value.wcp);
} else {
message_publish(MSG_ERROR, "Memory Manager: wchar_t array is too small for the attempted string assignment.\n") ;
std::stringstream message;
message << "wchar_t array at [" << (void*)assign_addr
<< "] is to small for the attempted string assignment." ;
emitError(message.str());
return (1);
}
} else if ((v_tree) &&
@ -343,7 +336,10 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
if (rhs_len <= size_of_curr_dim ) {
ncs_to_wcs( v_tree->v_data->value.cp, (wchar_t*)assign_addr, rhs_len);
} else {
message_publish(MSG_ERROR, "Memory Manager: wchar_t array is too small for the attempted string assignment.\n") ;
std::stringstream message;
message << "wchar_t array at [" << (void*)assign_addr
<< "] is too small for the attempted string assignment." ;
emitError(message.str());
return (1);
}
} else {
@ -379,7 +375,7 @@ int Trick::MemoryManager::assign_recursive(void* base_addr, ATTRIBUTES* attr, in
}
}
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR - bad reference.\n") ;
emitError("This is bad. In assign_recursive(), remaining_dimensions is negative.");
return (1);
}
return (0);
@ -401,7 +397,9 @@ int Trick::MemoryManager::ref_assignment( REF2* R, V_TREE* V) {
delete from_units;
delete to_units;
} catch (Unit::CONVERSION_ERROR) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Can't convert \"%s\" to \"%s\".\n", R->units, R->attr->units) ;
std::stringstream message;
message << "Can't convert \"" << R->units << "\" to \"" << R->attr->units << "\".";
emitError(message.str());
cf = NULL;
return TRICK_UNITS_CONVERSION_ERROR ;
}

View File

@ -1,14 +1,13 @@
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <sstream>
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/MemoryManager/include/vval.h"
#include "sim_services/MemoryManager/include/attributes.h"
#include "sim_services/MemoryManager/include/reference.h"
#include "sim_services/MemoryManager/include/parameter_types.h"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
/*
Updates R, a reference to an arrayed object, to a reference to the indexed sub-element of that arrayed object.
@ -19,54 +18,39 @@ int Trick::MemoryManager::ref_dim( REF2* R, V_DATA* V) {
int item_size;
if (R->ref_type != REF_ADDRESS) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Attempt to index into a non-address reference is bogus in ref_dim.\n") ;
emitError("Attempt to index into a non-address reference is bogus in ref_dim.") ;
return (1);
}
R->num_index_left--;
if (R->num_index_left < 0) {
/* if we have too many dimensions, flag an error */
message_publish(MSG_ERROR, "Memory Manager ERROR: Too many dimensions in ref_dim.\n") ;
emitError("Too many dimensions in ref_dim.\n") ;
return (TRICK_PARAMETER_ARRAY_SIZE);
}
/* if current dimension is a fixed dimension */
if (R->attr->index[R->num_index].size != 0) {
/* Set the size of the element we are going to parse */
if (R->attr->index[(R->attr->num_index - 1)].size == 0) {
/* last dimension is a pointer, set item_size to sizeof pointer */
/*Calculate the size of the items in this array. */
item_size = R->attr->size;
for (jj = (R->attr->num_index - 1); jj > R->num_index; jj--) {
if (R->attr->index[jj].size > 0) {
item_size *= R->attr->index[jj].size;
} else {
item_size = sizeof(void *);
R->pointer_present = 1 ;
} else {
/* all dimensions are fixed, set item_size to sizeof element */
item_size = R->attr->size;
}
/* for fixed dimensions, we can check the validity of the index value */
}
/* if current dimension is a constrained ... */
if (R->attr->index[R->num_index].size != 0) {
/* for constrained dimensions, we can check the validity of the index value */
if (vval_int(V) >= R->attr->index[R->num_index].size || vval_int(V) < 0) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Array index out of bounds.\n") ;
emitError("Memory Manager ERROR: Array index out of bounds.") ;
return (TRICK_PARAMETER_ARRAY_SIZE);
}
/* loop through all dimensions backwards, multiply the size of each dimension up to our current dimension
(R->num_index) */
for (jj = (R->attr->num_index - 1); jj > R->num_index; jj--) {
if (R->attr->index[jj].size > 0) {
item_size *= R->attr->index[jj].size;
}
}
} else {
R->pointer_present = 1 ;
// Current dimension is a pointer.
if (R->num_index == (R->attr->num_index - 1)) {
item_size = R->attr->size;
} else {
item_size = sizeof(void *);
}
if ( R->create_add_path ) {
ADDRESS_NODE * address_node ;
@ -79,13 +63,15 @@ int Trick::MemoryManager::ref_dim( REF2* R, V_DATA* V) {
// Dereference the pointer.
R->address = *(void**)R->address;
if ( R->address == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Reference (%s) address is NULL in ref_dim.\n", R->reference) ;
std::stringstream message;
message << "Reference (" << R->reference << ") address is NULL in ref_dim.";
emitError(message.str());
return(TRICK_PARAMETER_ADDRESS_NULL) ;
}
}
if ( R->create_add_path ) {
ADDRESS_NODE * address_node ;
if ( vval_int(V) > 0 ) {

View File

@ -5,14 +5,13 @@
(Initial Release.))) */
#include <string.h>
#include <sstream>
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/MemoryManager/include/attributes.h"
#include "sim_services/MemoryManager/include/reference.h"
#include "sim_services/MemoryManager/include/parameter_types.h"
#include "sim_services/MemoryManager/include/mm_error.h"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
//FIXME TODO make a error file
/////// MM_NO_ERROR 0
@ -33,9 +32,11 @@ int Trick::MemoryManager::ref_name(REF2 * R, char *name) {
}
if (R->address == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Since the value of the pointer \"%s\" is NULL,\n"
" a legitimate address can't be calculated for \"%s.%s\" in ref_name.\n",
R->reference, R->reference, name);
std::stringstream message;
message << "ref_name: Because the address of \"" << R->reference
<< "\" is NULL, a legitimate address can't be calculated for \""
<< R->reference << "." << name << "\".";
emitError(message.str());
return (MM_PARAMETER_NAME);
}

View File

@ -5,8 +5,6 @@
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/CheckPointAgent/include/ClassicCheckPointAgent.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
int Trick::MemoryManager::read_checkpoint( std::istream *is) {
@ -19,7 +17,7 @@ int Trick::MemoryManager::read_checkpoint( std::istream *is) {
}
if (currentCheckPointAgent->restore( is) !=0 ) {
message_publish(MSG_ERROR, "Memory Manager ERROR: Checkpoint restore failed.\n") ;
emitError("Checkpoint restore failed.") ;
}
// Go through all of the allocations that have been created looking
@ -60,7 +58,9 @@ int Trick::MemoryManager::read_checkpoint(const char* filename ) {
if (infile.is_open()) {
return ( read_checkpoint( &infile ));
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't open \"%s\".\n", filename) ;
std::stringstream message;
message << "Couldn't open \"" << filename << "\".";
emitError(message.str());
}
return 1;
}
@ -80,7 +80,7 @@ int Trick::MemoryManager::read_checkpoint_from_string(const char* s ) {
}
return ( read_checkpoint( &ss ));
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Checkpoint string is NULL.\n") ;
emitError("Checkpoint string is NULL.") ;
}
return 1;
}

View File

@ -1,6 +1,4 @@
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
Trick::CheckPointAgent * Trick::MemoryManager::get_CheckPointAgent() {
return currentCheckPointAgent ;
@ -11,7 +9,7 @@ void Trick::MemoryManager::set_CheckPointAgent(CheckPointAgent* agent) {
if (agent != NULL) {
currentCheckPointAgent = agent;
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Attempt to set CheckPointAgent to NULL.\n") ;
emitError("Attempt to set CheckPointAgent to NULL.\n") ;
}
return;
}

View File

@ -1,10 +1,9 @@
#include <fstream>
#include <sstream>
#include <string.h>
#include <stdlib.h> // free()
#include <algorithm> // std::sort()
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
// GreenHills stuff
#if ( __ghs )
@ -43,7 +42,7 @@ void Trick::MemoryManager::write_checkpoint( std::ostream& out_s, std::vector<AL
/** @b NOTE: We should not write declarations for external
anonymous variables, because we should not reload them.*/
} else {
message_publish(MSG_ERROR, "Memory Manager INTERNAL ERROR: Allocation storage class is messed up.\n") ;
emitError("write_checkpoint: This is bad. ALLOC_INFO object is messed up.\n") ;
}
} else {
currentCheckPointAgent->write_decl( out_s, alloc_info);
@ -111,7 +110,9 @@ void Trick::MemoryManager::write_checkpoint(const char* filename) {
if (outfile.is_open()) {
write_checkpoint( outfile);
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: Couldn't open \"%s\".\n", filename) ;
std::stringstream message;
message << "Couldn't open \"" << filename << "\".";
emitError(message.str());
}
}
@ -136,8 +137,9 @@ void Trick::MemoryManager::write_checkpoint(const char* filename, const char* va
if (out_s.is_open()) {
write_checkpoint( out_s, var_name);
} else {
std::cerr << "ERROR: Couldn't open \""<< filename <<"\"." << std::endl;
std::cerr.flush();
std::stringstream message;
message << "Couldn't open \"" << filename << "\".";
emitError(message.str());
}
}

View File

@ -1,8 +1,7 @@
#include <fstream>
#include <sstream>
#include <string.h>
#include "sim_services/MemoryManager/include/MemoryManager.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
// GreenHills stuff
#if ( __ghs )
@ -16,7 +15,7 @@ void Trick::MemoryManager::write_composite_var( std::ostream& out_s,
ATTRIBUTES* attr_list) {
if (attr_list == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: attr_list = NULL in write_composite_var.\n") ;
emitError("write_composite_var: attr_list = NULL.") ;
return;
}
@ -52,7 +51,7 @@ void Trick::MemoryManager::write_array_var( std::ostream& out_s,
int offset) {
if (attr == NULL) {
message_publish(MSG_ERROR, "Memory Manager ERROR: attr = NULL in write_array_var().\n") ;
emitError("write_array_var: attr_list = NULL.") ;
return;
}
@ -141,8 +140,9 @@ void Trick::MemoryManager::write_var( std::ostream& out_s, const char* var_name
alloc_info = pos->second;
write_var( out_s, alloc_info );
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: write_var(\"%s\") failed "
"because the given name isn't known by the MemoryManager.", var_name) ;
std::stringstream message;
message << "write_var(\"" << var_name << "\") failed. No such variable is being managed.";
emitError(message.str());
}
pthread_mutex_unlock(&mm_mutex);
}
@ -157,8 +157,9 @@ void Trick::MemoryManager::write_var( std::ostream& out_s, void* address) {
if (alloc_info != NULL) {
write_var( out_s, alloc_info );
} else {
message_publish(MSG_ERROR, "Memory Manager ERROR: write_var(%p) failed "
"because no variable is being managed at that address.\n", address) ;
std::stringstream message;
message << "write_var(" << address << ") failed. No such variable is being managed.";
emitError(message.str());
}
pthread_mutex_unlock(&mm_mutex);
}

View File

@ -18,8 +18,6 @@
#include "sim_services/MemoryManager/include/value.h"
#include "sim_services/MemoryManager/include/var.h"
#include "sim_services/MemoryManager/include/ADefParseContext.hh"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
#include "adef_parser.tab.h"
using namespace std;
@ -27,7 +25,9 @@
int ADEF_lex( YYSTYPE* lvalp, YYLTYPE* llocp, void* scanner );
void ADEF_error( YYLTYPE* locp, Trick::ADefParseContext* context, const char* err) {
message_publish(MSG_ERROR, "Memory Manager adef_parser PARSE-ERROR %d : %s\n", locp->first_line, err) ;
std::stringstream message;
message << "adef_parser PARSE-ERROR " << locp->first_line << ": " << err << ".";
Trick::MemoryManager::emitError(message.str());
}
#define scanner context->scanner

View File

@ -18,8 +18,6 @@
#include "sim_services/MemoryManager/include/vval.h"
#include "sim_services/MemoryManager/include/value.h"
#include "sim_services/MemoryManager/include/var.h"
#include "sim_services/Message/include/message_proto.h"
#include "sim_services/Message/include/message_type.h"
#include "ref_parser.tab.h"
using namespace std;
@ -27,10 +25,9 @@
int REF_lex( YYSTYPE* lvalp, YYLTYPE* llocp, void* scanner );
void REF_error( YYLTYPE* locp, RefParseContext* context __attribute__ ((unused)) , const char* err) {
std::stringstream ss;
ss << "MemoryManager ERROR: Syntax error " << locp->first_line << " : " << err
<< std::endl;
message_publish(MSG_ERROR, ss.str().c_str() );
std::stringstream message;
message << "Syntax error: " << locp->first_line << " : " << err ;
Trick::MemoryManager::emitError(message.str());
}
#define scanner context->scanner
@ -94,11 +91,9 @@ param: NAME {
$$.ref_type = REF_ADDRESS;
$$.create_add_path = 1 ;
$$.address_path = DLL_Create() ;
// Get the address and attrs of the variable.
// Get the address and attrs of the variable.
if ((ret = context->mem_mgr->ref_var( &$$, $1)) != MM_OK) {
//don't print error, because var_exists command relies on this call
//message_publish(MSG_ERROR, "Memory Manager ERROR: Call to ref_var( R, %s) failed.\n", $1);
return ( ret);
}
// save the reference attributes allocated by ref_var so we can delete it after ref_name is called.
@ -109,7 +104,7 @@ param: NAME {
}
| '&' NAME {
/*
/*
* This rule handles the first name with a preceding address character.
* Only parameters and vars are allowed to have a preceding "&" char.
*/
@ -123,13 +118,12 @@ param: NAME {
$$.ref_type = REF_ADDRESS;
$$.create_add_path = 1 ;
$$.address_path = DLL_Create() ;
// Get the address and attrs of the variable.
// Get the address and attrs of the variable.
if ((ret = context->mem_mgr->ref_var( &$$, $2)) != MM_OK) {
std::stringstream ss;
ss << "MemoryManager ERROR: Invalid reference: \"" << $2 << "\"."
<< std::endl;
message_publish(MSG_ERROR, ss.str().c_str() );
std::stringstream message;
message << "MemoryManager ERROR: Invalid reference: \"" << $2 << "\".";
Trick::MemoryManager::emitError(message.str());
return ( ret);
}
// save the reference attributes allocated by ref_var so we can delete it after ref_name is called.
@ -162,10 +156,9 @@ param: NAME {
/* Check to see if previous parameter specified enough dimensions. */
if ($$.num_index != $$.attr->num_index) {
std::stringstream ss;
ss << "Memory Manager ERROR: Dimension mismatch."
<< std::endl;
message_publish(MSG_ERROR, ss.str().c_str() );
std::stringstream message;
message << "Dimension mismatch.";
Trick::MemoryManager::emitError(message.str());
return (MM_PARAMETER_ARRAY_DIM);
}

View File

@ -184,12 +184,27 @@ void * Trick::VariableServerListenThread::thread_body() {
return NULL ;
}
#include <fcntl.h>
int Trick::VariableServerListenThread::restart() {
int ret ;
if ( user_port_requested ) {
printf("user_port_requested set %d", port) ;
char hname[80];
static struct sockaddr_in s_in;
gethostname(hname, (size_t) 80);
// Test to see if the restart address is on this machine. If it is not, it's not an error, clear source address
if ( strcmp( source_address.c_str(), hname )) {
if (! inet_pton(AF_INET, source_address.c_str(), (struct in_addr *)&s_in.sin_addr.s_addr) ) {
//printf("clearing source_address\n") ;
source_address.clear() ;
}
}
printf("variable server restart user_port requested set %d\n", port) ;
tc_disconnect(&listen_dev) ;
ret = tc_init_with_connection_info(&listen_dev, AF_INET, SOCK_STREAM, source_address.c_str(), port) ;
if (ret != TC_SUCCESS) {

View File

@ -82,6 +82,7 @@
#include "sim_services/Integrator/include/IntegLoopManager.hh"
#include "sim_services/Integrator/include/IntegLoopSimObject.hh"
#include "sim_services/Integrator/include/Integrator.hh"
#include "sim_services/Integrator/include/regula_falsi.h"
#ifdef USE_ER7_UTILS_INTEGRATORS
# include "sim_services/Integrator/er7_algorithms/ABM_Integrator.hh"