mirror of
https://github.com/nasa/trick.git
synced 2025-06-21 08:29:39 +00:00
trying something
This commit is contained in:
@ -5,6 +5,8 @@
|
|||||||
#include <iomanip> // for setprecision
|
#include <iomanip> // for setprecision
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <exception>
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
#include "trick/VariableReference.hh"
|
#include "trick/VariableReference.hh"
|
||||||
#include "trick/memorymanager_c_intf.h"
|
#include "trick/memorymanager_c_intf.h"
|
||||||
@ -17,6 +19,7 @@
|
|||||||
#include "trick/trick_byteswap.h"
|
#include "trick/trick_byteswap.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Static variables to be addresses that are known to be the error ref address
|
// Static variables to be addresses that are known to be the error ref address
|
||||||
int Trick::VariableReference::_bad_ref_int = 0 ;
|
int Trick::VariableReference::_bad_ref_int = 0 ;
|
||||||
int Trick::VariableReference::_do_not_resolve_bad_ref_int = 0 ;
|
int Trick::VariableReference::_do_not_resolve_bad_ref_int = 0 ;
|
||||||
@ -84,6 +87,7 @@ Trick::VariableReference::VariableReference(std::string var_name, double* time)
|
|||||||
_base_units = _var_info->attr->units;
|
_base_units = _var_info->attr->units;
|
||||||
_requested_units = "s";
|
_requested_units = "s";
|
||||||
_name = _var_info->reference;
|
_name = _var_info->reference;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Trick::VariableReference::VariableReference(std::string var_name) : _staged(false), _write_ready(false) {
|
Trick::VariableReference::VariableReference(std::string var_name) : _staged(false), _write_ready(false) {
|
||||||
@ -282,6 +286,7 @@ int Trick::VariableReference::setRequestedUnits(std::string units_name) {
|
|||||||
|
|
||||||
int Trick::VariableReference::stageValue(bool validate_address) {
|
int Trick::VariableReference::stageValue(bool validate_address) {
|
||||||
_write_ready = false;
|
_write_ready = false;
|
||||||
|
std::string *str_ptr = NULL;
|
||||||
|
|
||||||
// Copy <size> bytes from <address> to staging_point.
|
// Copy <size> bytes from <address> to staging_point.
|
||||||
|
|
||||||
@ -309,7 +314,7 @@ int Trick::VariableReference::stageValue(bool validate_address) {
|
|||||||
|
|
||||||
// if this variable is a string we need to get the raw character string out of it.
|
// if this variable is a string we need to get the raw character string out of it.
|
||||||
if (( _trick_type == TRICK_STRING ) && !_deref) {
|
if (( _trick_type == TRICK_STRING ) && !_deref) {
|
||||||
std::string * str_ptr = (std::string *)_var_info->address ;
|
str_ptr = (std::string *)_var_info->address ;
|
||||||
// Get a pointer to the internal character array
|
// Get a pointer to the internal character array
|
||||||
_address = (void *)(str_ptr->c_str()) ;
|
_address = (void *)(str_ptr->c_str()) ;
|
||||||
}
|
}
|
||||||
@ -320,11 +325,16 @@ int Trick::VariableReference::stageValue(bool validate_address) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// handle c++ string and char*
|
// handle c++ string and char*
|
||||||
if ( _trick_type == TRICK_STRING ) {
|
if ( _trick_type == TRICK_STRING ){
|
||||||
|
|
||||||
if (_address == NULL) {
|
if (_address == NULL) {
|
||||||
_size = 0 ;
|
_size = 0 ;
|
||||||
} else {
|
} else {
|
||||||
_size = strlen((char*)_address) + 1 ;
|
//_size = strlen((char*)_address) + 1 ;
|
||||||
|
_size = (int )str_ptr->size();
|
||||||
|
if (_size <= 0 || _size > 4096) {
|
||||||
|
_size = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// handle c++ wstring and wchar_t*
|
// handle c++ wstring and wchar_t*
|
||||||
@ -336,7 +346,11 @@ int Trick::VariableReference::stageValue(bool validate_address) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(_address != NULL) {
|
if(_address != NULL) {
|
||||||
memcpy( _stage_buffer , _address , _size ) ;
|
if (_trick_type == TRICK_STRING ) {
|
||||||
|
str_ptr->copy((char*)_stage_buffer,_size,0);
|
||||||
|
} else {
|
||||||
|
memcpy( _stage_buffer , _address , _size ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_staged = true;
|
_staged = true;
|
||||||
@ -734,4 +748,4 @@ int Trick::VariableReference::writeValueBinary( std::ostream& out, bool byteswap
|
|||||||
std::ostream& Trick::operator<< (std::ostream& s, const Trick::VariableReference& ref) {
|
std::ostream& Trick::operator<< (std::ostream& s, const Trick::VariableReference& ref) {
|
||||||
s << " \"" << ref.getName() << "\"";
|
s << " \"" << ref.getName() << "\"";
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ int Trick::VariableServerSession::var_add(std::string in_name) {
|
|||||||
new_var = new VariableReference(in_name, &_time);
|
new_var = new VariableReference(in_name, &_time);
|
||||||
} else {
|
} else {
|
||||||
new_var = new VariableReference(in_name);
|
new_var = new VariableReference(in_name);
|
||||||
|
ALLOC_INFO * allocOf = get_alloc_info_of(new_var._address);
|
||||||
|
ALLOC_INFO * allocAt = get_alloc_info_at(new_var._address);
|
||||||
}
|
}
|
||||||
|
|
||||||
_session_variables.push_back(new_var) ;
|
_session_variables.push_back(new_var) ;
|
||||||
|
Reference in New Issue
Block a user