refactor example sim SIM_msd

This commit is contained in:
Scott Fennell 2018-12-21 13:48:38 -06:00
parent e47cf8d956
commit 5408b5bc44
10 changed files with 55 additions and 69 deletions

View File

@ -1,10 +1,14 @@
dyn_integloop.getIntegrator(trick.Runge_Kutta_4, 4)
trick.var_debug(3)
execfile("Modified_data/realtime.py")
#==========================================
# Start the display VarServer Client
#==========================================
varServerPort = trick.var_server_get_port();
trick.set_var_server_info_msg_on()
print(varServerPort)
MsdGui_path = "models/graphics/dist/MsdGui.jar"
if (os.path.isfile(MsdGui_path)) :

View File

@ -3,29 +3,30 @@ PURPOSE:
(This S_define works with the RUN_numeric input file)
LIBRARY DEPENDENCIES:
(
(msd/src/msd_init.cpp)
(msd/src/msd_numeric.cpp)
(msd/src/msd_shutdown.cpp)
(msd/src/msd.cpp)
(msd/src/msd_default_data.cpp)
(msd/src/msd_deriv.cpp)
(msd/src/msd_init.cpp)
(msd/src/msd_integ.cpp)
(msd/src/msd_shutdown.cpp)
)
*************************************************************/
#include "sim_objects/default_trick_sys.sm"
##include "msd/include/msd_numeric.hh"
##include "msd/include/msd.hh"
class MSDSimObject : public Trick::SimObject {
public:
MSD msd;
MSD msd ;
MSDSimObject() {
("default_data") msd_default_data( msd ) ;
("initialization") msd_init( msd ) ;
("derivative") msd.state_deriv();
("integration") trick_ret= msd.state_integ();
("default_data") MSD::default_data( msd ) ;
("initialization") msd.init() ;
("derivative") msd.state_deriv() ;
("integration") trick_ret= msd.state_integ() ;
("shutdown") msd.shutdown() ;
}
} ;

View File

@ -22,27 +22,20 @@ public:
double k; /* N/m spring constant */
double F; /* N force constant */
MSD(double _m, double _k, double _b, double _F,
double _v_0, double _x_0);
static int default_data(MSD &);
int init();
int shutdown();
int state_deriv(void);
int state_integ(void);
MSD(void); /* not used */
MSD(double _m, double _k, double _b, double _F,
double _v_0, double _x_0);
int state_deriv(void);
int state_integ(void);
};
#ifdef __cplusplus
extern "C" {
#endif
int msd_default_data(MSD &);
int msd_init(MSD &);
int msd_shutdown(const MSD &);
#ifdef __cplusplus
}
#endif
#endif /* MSD_H */

View File

@ -1,17 +0,0 @@
/************************TRICK HEADER*************************
PURPOSE: Msd Numeric model
PROGRAMMERS:
(((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project)))
*************************************************************/
#ifndef MSD_NUMERIC_H
#define MSD_NUMERIC_H
#include "msd.hh"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -4,7 +4,7 @@ PROGRAMMERS:
(((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project)))
*************************************************************/
#include <math.h>
#include "../include/msd_numeric.hh"
#include "msd.hh"
#include <float.h>
MSD::MSD(double _m, double _k, double _b, double _F, double _v_0, double _x_0) {
@ -16,4 +16,5 @@ MSD::MSD(double _m, double _k, double _b, double _F, double _v_0, double _x_0) {
x_0 = _x_0;
}
MSD::MSD(void) {/* not used */}
MSD::MSD(void) {/* not used */}

View File

@ -0,0 +1,20 @@
/************************TRICK HEADER*************************
PURPOSE: MSD default data job
PROGRAMMERS:
(((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project)))
*************************************************************/
#include "msd.hh"
/* default data job */
int MSD::default_data(MSD &M) {
M = MSD(
1.0, /* m */
2.0, /* k */
0.5, /* b */
5.0, /* F */
0.0, /* v_0 */
5.0 /* x_0 */
);
return 0;
}

View File

@ -3,8 +3,7 @@
PROGRAMMERS:
(((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project)))
*************************************************************/
#include "../include/msd_numeric.hh"
#include "../include/msd.hh"
#include "msd.hh"
#include <math.h>
int MSD::state_deriv(void) {

View File

@ -5,24 +5,9 @@ PROGRAMMERS:
*************************************************************/
/* Model Include files */
#include "../include/msd.hh"
/* default data job */
int msd_default_data(MSD &M) {
M = MSD(
1.0, /* m */
2.0, /* k */
0.5, /* b */
5.0, /* F */
0.0, /* v_0 */
5.0 /* x_0 */
);
return 0;
}
#include "msd.hh"
/* initialization job */
int msd_init(MSD &M) {
int MSD::init() {
return 0;
}

View File

@ -3,7 +3,6 @@
PROGRAMMERS:
(((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project)))
*************************************************************/
#include "../include/msd_numeric.hh"
#include "msd.hh"
#include "trick/Integrator.hh"
#include "trick/integrator_c_intf.h"
@ -24,8 +23,9 @@ int MSD::state_integ(void) {
ipass = integrate();
unload_state(
&x,
&v,
NULL);
&x,
&v,
NULL);
return(ipass);
}

View File

@ -3,15 +3,15 @@ PURPOSE: (Print the final msd state.)
PROGRAMMERS:
(((Scott P. Fennell) (CACI International Inc.) (January 2018) (Trick Learning Project)))
*************************************************************/
#include "../include/msd.hh"
#include "msd.hh"
#include "trick/exec_proto.h"
#include <stdio.h>
int msd_shutdown(const MSD &M) {
int MSD::shutdown() {
printf("========================================\n");
printf(" MSD State at Shutdown \n");
printf("pos = [%g], vel = [%g], acc = [%g]\n",
M.x, M.v, M.a);
x, v, a);
printf("========================================\n");
return 0;
}