mirror of
https://github.com/nasa/trick.git
synced 2024-12-22 14:32:24 +00:00
19025d77ad
Reorganized. Created a new top level include directory that will hold all of Trick's header files. Moved all of the Trick headers to this directory. Created a libexec directory that holds all of the executables that users don't need to execute directly. Changed all of the executables remaining in bin to start with "trick-". In the sim_services directories changed all source files to find the Trick headers in their new location. Since all of the include files are gone in sim_services, removed the src directories as well, moving all of the source files up a level. Moved the makefiles, docs, man, and other architecture independent files into a top level share directory. Renamed lib_${TRICK_HOST_CPU} to lib64 or lib depending on the platform we're currently on. refs #63
135 lines
3.5 KiB
C++
135 lines
3.5 KiB
C++
|
|
#include <iostream>
|
|
|
|
#include "trick/MTV.hh"
|
|
#include "trick/VariableServer.hh"
|
|
#include "trick/EventManager_c_intf.hh"
|
|
|
|
Trick::MTV * the_mtv ;
|
|
|
|
Trick::MTV::MTV() :
|
|
mtv_list(NULL), mtv_count(0) {
|
|
the_mtv = this ;
|
|
}
|
|
|
|
/**
|
|
@details
|
|
Adds an event to mtv list.
|
|
|
|
-# Check to see if the event is already in the mtv list, return if it is.
|
|
-# Increment the number of events in the mtv list.
|
|
-# Reallocate the mtv_list to accomodate the new event.
|
|
-# Assign the last element of mtv_list to the incoming event.
|
|
-# Increment the update ticker so mtv knows something changed.
|
|
*/
|
|
int Trick::MTV::add_event( Trick::IPPythonEvent * in_event ) {
|
|
for ( unsigned int ii = 0 ; ii < mtv_count ; ii++ ) {
|
|
if (in_event == mtv_list[ii]) {
|
|
return (0) ;
|
|
}
|
|
}
|
|
mtv_count++;
|
|
if (mtv_count == 1) {
|
|
mtv_list = (Trick::IPPythonEvent **)TMM_declare_var_s("Trick::IPPythonEvent* mtv_list[1]");
|
|
} else {
|
|
mtv_list = (Trick::IPPythonEvent **)TMM_resize_array_1d_a(mtv_list, mtv_count);
|
|
}
|
|
mtv_list[mtv_count-1] = in_event ;
|
|
mtv_update_ticker++;
|
|
|
|
return 0 ;
|
|
}
|
|
|
|
/**
|
|
@details
|
|
Delete an event from mtv list.
|
|
|
|
-# If the event is in the mtv list
|
|
-# Set the event to a dummy event.
|
|
-# Increment the update ticker so mtv knows something changed.
|
|
*/
|
|
int Trick::MTV::delete_event( Trick::IPPythonEvent * in_event ) {
|
|
unsigned int ii ;
|
|
/* Remove it from mtv's event list. */
|
|
for ( ii = 0 ; ii < mtv_count ; ii++ ) {
|
|
if (in_event == mtv_list[ii]) {
|
|
mtv_list[ii] = &dummy_event;
|
|
mtv_update_ticker++;
|
|
break ;
|
|
}
|
|
}
|
|
return 0 ;
|
|
}
|
|
|
|
/**
|
|
@details
|
|
Find an event in the mtv list.
|
|
|
|
-# If the event is in the mtv list return it
|
|
*/
|
|
Trick::IPPythonEvent * Trick::MTV::get_event(std::string event_name) {
|
|
unsigned int ii ;
|
|
Trick::IPPythonEvent* ret = NULL;
|
|
|
|
for ( ii = 0 ; ii < mtv_count ; ii++ ) {
|
|
if ( ! mtv_list[ii]->get_name().compare(event_name) ) {
|
|
ret = mtv_list[ii];
|
|
break ;
|
|
}
|
|
}
|
|
|
|
return(ret) ;
|
|
|
|
}
|
|
|
|
/**
|
|
@details
|
|
Send mtv event data through the variable server.
|
|
|
|
-# For each event in the mtv_list
|
|
-# call var_add() for all the event information
|
|
-# Send the size of list of variables we've added
|
|
-# Send the data
|
|
-# Clear the var_add list.
|
|
*/
|
|
int Trick::MTV::send_event_data() {
|
|
|
|
char varname[80];
|
|
const char *mtv_name = "trick_ip.mtv.mtv_list";
|
|
unsigned int ii ;
|
|
int jj;
|
|
|
|
for (ii=0; ii < mtv_count; ii++) {
|
|
sprintf(varname, "%s[%d][0].name", mtv_name,ii);
|
|
var_add(varname);
|
|
sprintf(varname, "%s[%d][0].active", mtv_name,ii);
|
|
var_add(varname);
|
|
sprintf(varname, "%s[%d][0].added", mtv_name,ii);
|
|
var_add(varname);
|
|
sprintf(varname, "%s[%d][0].condition_count", mtv_name,ii);
|
|
var_add(varname);
|
|
sprintf(varname, "%s[%d][0].action_count", mtv_name,ii);
|
|
var_add(varname);
|
|
sprintf(varname, "%s[%d][0].before_after", mtv_name,ii);
|
|
var_add(varname);
|
|
for (jj=0; jj< mtv_list[ii]->condition_count; jj++) {
|
|
sprintf(varname, "%s[%d][0].cond[%d].comment", mtv_name,ii,jj);
|
|
var_add(varname);
|
|
}
|
|
for (jj=0; jj< mtv_list[ii]->action_count; jj++) {
|
|
sprintf(varname, "%s[%d][0].act[%d].comment", mtv_name,ii,jj);
|
|
var_add(varname);
|
|
}
|
|
if (mtv_list[ii]->get_before_after() > 0) {
|
|
sprintf(varname, "%s[%d][0].target_name", mtv_name,ii);
|
|
var_add(varname);
|
|
}
|
|
}
|
|
var_send_list_size() ;
|
|
var_send() ;
|
|
var_clear() ;
|
|
|
|
return 0 ;
|
|
}
|
|
|