/*************************************************************************** TITLE: ls_init.c ---------------------------------------------------------------------------- FUNCTION: Initializes simulation ---------------------------------------------------------------------------- MODULE STATUS: incomplete ---------------------------------------------------------------------------- GENEALOGY: Written 921230 by Bruce Jackson ---------------------------------------------------------------------------- DESIGNED BY: EBJ CODED BY: EBJ MAINTAINED BY: EBJ ---------------------------------------------------------------------------- MODIFICATION HISTORY: DATE PURPOSE BY 950314 Added get_set, put_set, and init routines. EBJ CURRENT RCS HEADER: $Header$ $Log$ Revision 1.1 1999/06/17 18:07:34 curt Initial revision Revision 1.1.1.1 1999/04/05 21:32:45 curt Start of 0.6.x branch. Revision 1.5 1998/07/12 03:11:03 curt Removed some printf()'s. Fixed the autopilot integration so it should be able to update it's control positions every time the internal flight model loop is run, and not just once per rendered frame. Added a routine to do the necessary stuff to force an arbitrary altitude change. Gave the Navion engine just a tad more power. Revision 1.4 1998/01/19 18:40:26 curt Tons of little changes to clean up the code and to remove fatal errors when building with the c++ compiler. Revision 1.3 1998/01/05 22:19:25 curt #ifdef'd out some unused code that was problematic for MSVC++ to compile. Revision 1.2 1997/05/29 22:39:58 curt Working on incorporating the LaRCsim flight model. Revision 1.1 1997/05/29 00:09:57 curt Initial Flight Gear revision. * Revision 1.4 1995/03/15 12:15:23 bjax * Added ls_init_get_set() and ls_init_put_set() and ls_init_init() * routines. EBJ * * Revision 1.3 1994/01/11 19:09:44 bjax * Fixed header includes. * * Revision 1.2 1992/12/30 14:04:53 bjax * Added call to ls_step(0, 1). * * Revision 1.1 92/12/30 14:02:19 bjax * Initial revision * * Revision 1.1 92/12/30 13:21:21 bjax * Initial revision * * Revision 1.3 93/12/31 10:34:11 bjax * Added $Log marker as well. * ---------------------------------------------------------------------------- REFERENCES: ---------------------------------------------------------------------------- CALLED BY: ---------------------------------------------------------------------------- CALLS TO: ---------------------------------------------------------------------------- INPUTS: ---------------------------------------------------------------------------- OUTPUTS: --------------------------------------------------------------------------*/ static char rcsid[] = "$Id$"; #include #include #include "ls_types.h" #include "ls_sym.h" #include "ls_step.h" #include "ls_init.h" #include "navion_init.h" /* temp */ #include "ls_generic.h" #define MAX_NUMBER_OF_CONTINUOUS_STATES 100 #define MAX_NUMBER_OF_DISCRETE_STATES 20 #define HARDWIRED 13 #define NIL_POINTER 0L #define FACILITY_NAME_STRING "init" #define CURRENT_VERSION 10 typedef struct { symbol_rec Symbol; double value; } cont_state_rec; typedef struct { symbol_rec Symbol; long value; } disc_state_rec; extern SCALAR Simtime; /* static int Symbols_loaded = 0; */ static int Number_of_Continuous_States = 0; static int Number_of_Discrete_States = 0; static cont_state_rec Continuous_States[ MAX_NUMBER_OF_CONTINUOUS_STATES ]; static disc_state_rec Discrete_States[ MAX_NUMBER_OF_DISCRETE_STATES ]; void ls_init_init( void ) { int i; /* int error; */ if (Number_of_Continuous_States == 0) { Number_of_Continuous_States = HARDWIRED; for (i=0;i bufptr)) { bufptr = strtok( 0L, "\n"); if (bufptr == 0) return 0L; if (strncasecmp( bufptr, "end", 3) == 0) break; sscanf( bufptr, "%s", line ); if (line[0] != '#') /* ignore comments */ { switch (looking_for) { case cont_states_header: { if (strncasecmp( line, "continuous_states", 17) == 0) { n = sscanf( bufptr, "%s%d", line, &Number_of_Continuous_States ); if (n != 2) abrt = 1; looking_for = cont_states; i = 0; } break; } case cont_states: { n = sscanf( bufptr, "%s%s%le", Continuous_States[i].Symbol.Mod_Name, Continuous_States[i].Symbol.Par_Name, &Continuous_States[i].value ); if (n != 3) abrt = 1; Continuous_States[i].Symbol.Addr = NIL_POINTER; i++; if (i >= Number_of_Continuous_States) looking_for = disc_states_header; break; } case disc_states_header: { if (strncasecmp( line, "discrete_states", 15) == 0) { n = sscanf( bufptr, "%s%d", line, &Number_of_Discrete_States ); if (n != 2) abrt = 1; looking_for = disc_states; i = 0; } break; } case disc_states: { n = sscanf( bufptr, "%s%s%ld", Discrete_States[i].Symbol.Mod_Name, Discrete_States[i].Symbol.Par_Name, &Discrete_States[i].value ); if (n != 3) abrt = 1; Discrete_States[i].Symbol.Addr = NIL_POINTER; i++; if (i >= Number_of_Discrete_States) looking_for = done; } case done: { break; } } } } Symbols_loaded = !abrt; return bufptr; } #endif /* COMPILE_THIS_CODE_THIS_USELESS_CODE */ void ls_init_put_set( FILE *fp ) { int i; if (fp==0) return; fprintf(fp, "\n"); fprintf(fp, "#============================== %s\n", FACILITY_NAME_STRING); fprintf(fp, "\n"); fprintf(fp, FACILITY_NAME_STRING); fprintf(fp, "\n"); fprintf(fp, "%04d\n", CURRENT_VERSION); fprintf(fp, " continuous_states: %d\n", Number_of_Continuous_States); fprintf(fp, "# module parameter value\n"); for (i=0; i