mirror of
https://github.com/nasa/trick.git
synced 2024-12-24 15:26:41 +00:00
This commit is contained in:
parent
90c1564a0c
commit
0df631c41a
@ -25,6 +25,8 @@ public:
|
|||||||
void synchSend(); // This must be called at a frequency greater than or equal to the interval.
|
void synchSend(); // This must be called at a frequency greater than or equal to the interval.
|
||||||
void pause();
|
void pause();
|
||||||
void unpause();
|
void unpause();
|
||||||
|
void clear();
|
||||||
|
void exit();
|
||||||
int emitError(const char* fmt, ... );
|
int emitError(const char* fmt, ... );
|
||||||
|
|
||||||
static int bad_ref_int ;
|
static int bad_ref_int ;
|
||||||
|
@ -28,8 +28,6 @@ private:
|
|||||||
REF2 *varInfo;
|
REF2 *varInfo;
|
||||||
void *address;
|
void *address;
|
||||||
int size;
|
int size;
|
||||||
void *buffer_in;
|
|
||||||
void *buffer_out;
|
|
||||||
bool deref;
|
bool deref;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -99,6 +99,8 @@ void WSsession::addVariable(char* vname){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( new_ref != NULL ) {
|
if ( new_ref != NULL ) {
|
||||||
|
// This REF2 object will "belong" to the WSsessionVariable, so it has
|
||||||
|
// the right and responsibility to free() it in its destructor.
|
||||||
WSsessionVariable *sessionVariable = new WSsessionVariable( new_ref ) ;
|
WSsessionVariable *sessionVariable = new WSsessionVariable( new_ref ) ;
|
||||||
sessionVariables.push_back( sessionVariable ) ;
|
sessionVariables.push_back( sessionVariable ) ;
|
||||||
}
|
}
|
||||||
@ -131,3 +133,12 @@ void WSsession::synchSend() { // This must be called at a frequency greater than
|
|||||||
}
|
}
|
||||||
void WSsession::pause() { enabled = false;}
|
void WSsession::pause() { enabled = false;}
|
||||||
void WSsession::unpause() { enabled = true; }
|
void WSsession::unpause() { enabled = true; }
|
||||||
|
void WSsession::clear() {
|
||||||
|
std::vector<WSsessionVariable*>::iterator it;
|
||||||
|
it = sessionVariables.begin();
|
||||||
|
while (it != sessionVariables.end()) {
|
||||||
|
delete *it;
|
||||||
|
it = sessionVariables.erase(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void WSsession::exit() {}
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
#include <math.h> // for fpclassify
|
#include <math.h> // for fpclassify
|
||||||
#include <iomanip> // for setprecision
|
#include <iomanip> // for setprecision
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WSsessionVariable::WSsessionVariable(REF2 * ref ) {
|
WSsessionVariable::WSsessionVariable(REF2 * ref ) {
|
||||||
varInfo = ref;
|
varInfo = ref;
|
||||||
address = varInfo->address;
|
address = varInfo->address;
|
||||||
@ -36,21 +34,13 @@ WSsessionVariable::WSsessionVariable(REF2 * ref ) {
|
|||||||
size *= get_size((char*)address) ;
|
size *= get_size((char*)address) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle strings: set a max buffer size, the copy size may vary so will be set in copy_sim_data
|
// handle strings: set a max buffer size, the copy size may vary so will be set in copy_sim_data
|
||||||
if (( string_type == TRICK_STRING ) || ( string_type == TRICK_WSTRING )) {
|
if (( string_type == TRICK_STRING ) || ( string_type == TRICK_WSTRING )) {
|
||||||
size = MAX_ARRAY_LENGTH ;
|
size = MAX_ARRAY_LENGTH ;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_in = calloc( size, 1 ) ;
|
|
||||||
buffer_out = calloc( size, 1 ) ;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WSsessionVariable::~WSsessionVariable() {
|
WSsessionVariable::~WSsessionVariable() {
|
||||||
|
|
||||||
if (buffer_in != NULL) free( buffer_in );
|
|
||||||
if (buffer_out != NULL) free( buffer_out );
|
|
||||||
if (varInfo != NULL) free( varInfo );
|
if (varInfo != NULL) free( varInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,6 @@ int handle_JSON_var_server_msg (WSsession* session, const char* client_msg) {
|
|||||||
printf ("No \"cmd\" member found in client message.\n");
|
printf ("No \"cmd\" member found in client message.\n");
|
||||||
status = 1;
|
status = 1;
|
||||||
} else if (strcmp(cmd, "var_add") == 0) {
|
} else if (strcmp(cmd, "var_add") == 0) {
|
||||||
//const gchar* var_name = json_object_get_string_member( object, "var_name");
|
|
||||||
session->addVariable( strdup(var_name) );
|
session->addVariable( strdup(var_name) );
|
||||||
printf("session->addVariable(\"%s\")\n", var_name);
|
printf("session->addVariable(\"%s\")\n", var_name);
|
||||||
} else if ( strcmp(cmd, "var_cycle") == 0 ) {
|
} else if ( strcmp(cmd, "var_cycle") == 0 ) {
|
||||||
@ -129,9 +128,9 @@ int handle_JSON_var_server_msg (WSsession* session, const char* client_msg) {
|
|||||||
session->unpause();
|
session->unpause();
|
||||||
printf("session->unpause()\n");
|
printf("session->unpause()\n");
|
||||||
} else if ( strcmp(cmd, "var_send") == 0 ) {
|
} else if ( strcmp(cmd, "var_send") == 0 ) {
|
||||||
//TODO
|
session->sendValues();
|
||||||
} else if ( strcmp(cmd, "var_clear") == 0 ) {
|
} else if ( strcmp(cmd, "var_clear") == 0 ) {
|
||||||
//TODO
|
session->clear();
|
||||||
} else if ( strcmp(cmd, "var_exit") == 0 ) {
|
} else if ( strcmp(cmd, "var_exit") == 0 ) {
|
||||||
//TODO
|
//TODO
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user