mirror of
https://github.com/nasa/trick.git
synced 2025-06-21 16:39:37 +00:00
Output "--" if that was specified in the header file.
Used the mods field in the attributes to indicate of "--" was specified in the header file. We still save the units as "1" to keep it compatible with udunits. When outputting the variable in data recording or variable server we check to see if the mods field for "--" is set. We output "--" if the mods field is set. Also allowed "--" to persist in data products. refs #254
This commit is contained in:
@ -8,6 +8,7 @@
|
|||||||
#define TRICK_VAR_INPUT 0x02
|
#define TRICK_VAR_INPUT 0x02
|
||||||
#define TRICK_CHKPNT_OUTPUT 0x04
|
#define TRICK_CHKPNT_OUTPUT 0x04
|
||||||
#define TRICK_CHKPNT_INPUT 0x08
|
#define TRICK_CHKPNT_INPUT 0x08
|
||||||
|
#define TRICK_MODS_UNITSDASHDASH 0x04
|
||||||
|
|
||||||
#define TRICK_MAX_INDEX 8
|
#define TRICK_MAX_INDEX 8
|
||||||
|
|
||||||
@ -89,12 +90,10 @@ typedef struct ATTRIBUTES_tag {
|
|||||||
double range_max; /**< -- Minimum allowable value for parameter */
|
double range_max; /**< -- Minimum allowable value for parameter */
|
||||||
Language language; /**< -- Native language of parameter. */
|
Language language; /**< -- Native language of parameter. */
|
||||||
int mods; /**< -- Modification bits.
|
int mods; /**< -- Modification bits.
|
||||||
|
|
||||||
bit 0 = c++ reference var
|
bit 0 = c++ reference var
|
||||||
|
|
||||||
bit 1 = c++ static var
|
bit 1 = c++ static var
|
||||||
|
bit 2 = "--" units
|
||||||
bit 32 = deprecated var */
|
bit 31 = deprecated var */
|
||||||
|
|
||||||
long offset; /**< -- Offset in bytes of this parameter from beginning of data structure */
|
long offset; /**< -- Offset in bytes of this parameter from beginning of data structure */
|
||||||
void *attr; /**< -- Address to next level parameter attributes
|
void *attr; /**< -- Address to next level parameter attributes
|
||||||
|
@ -41,6 +41,7 @@ FieldDescription::FieldDescription(
|
|||||||
field_width(0) ,
|
field_width(0) ,
|
||||||
inherited(false) ,
|
inherited(false) ,
|
||||||
units("1") ,
|
units("1") ,
|
||||||
|
is_dashdash(false) ,
|
||||||
line_no(0) ,
|
line_no(0) ,
|
||||||
io(3) ,
|
io(3) ,
|
||||||
type_enum_string("TRICK_VOID") ,
|
type_enum_string("TRICK_VOID") ,
|
||||||
@ -233,6 +234,7 @@ void FieldDescription::parseComment(std::string comment) {
|
|||||||
units.erase(remove_if(units.begin(), units.end(), isspace), units.end());
|
units.erase(remove_if(units.begin(), units.end(), isspace), units.end());
|
||||||
if ( !units.compare("--") ) {
|
if ( !units.compare("--") ) {
|
||||||
units = "1" ;
|
units = "1" ;
|
||||||
|
is_dashdash = true ;
|
||||||
} else {
|
} else {
|
||||||
// map old unit names to new names
|
// map old unit names to new names
|
||||||
std::string new_units = map_trick_units_to_udunits(units) ;
|
std::string new_units = map_trick_units_to_udunits(units) ;
|
||||||
@ -367,6 +369,10 @@ std::string FieldDescription::getUnits() {
|
|||||||
return units ;
|
return units ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FieldDescription::isDashDashUnits() {
|
||||||
|
return is_dashdash ;
|
||||||
|
}
|
||||||
|
|
||||||
void FieldDescription::setIO(unsigned int in_io) {
|
void FieldDescription::setIO(unsigned int in_io) {
|
||||||
io = in_io ;
|
io = in_io ;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ class FieldDescription : public ConstructValues {
|
|||||||
void setMangledTypeName( std::string in_val ) ;
|
void setMangledTypeName( std::string in_val ) ;
|
||||||
std::string getMangledTypeName() ;
|
std::string getMangledTypeName() ;
|
||||||
std::string getUnits() ;
|
std::string getUnits() ;
|
||||||
|
bool isDashDashUnits() ;
|
||||||
void setIO(unsigned int) ;
|
void setIO(unsigned int) ;
|
||||||
unsigned int getIO() ;
|
unsigned int getIO() ;
|
||||||
std::string getDescription() ;
|
std::string getDescription() ;
|
||||||
@ -117,6 +118,9 @@ class FieldDescription : public ConstructValues {
|
|||||||
/** Units specified of the field */
|
/** Units specified of the field */
|
||||||
std::string units ;
|
std::string units ;
|
||||||
|
|
||||||
|
/** was -- used as units */
|
||||||
|
bool is_dashdash ;
|
||||||
|
|
||||||
/** io restrictions */
|
/** io restrictions */
|
||||||
unsigned int io ;
|
unsigned int io ;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ void PrintFileContents10::print_field_attr(std::ofstream & outfile , FieldDescr
|
|||||||
outfile << ",sizeof(" << fdes->getTypeName() << ")" ;
|
outfile << ",sizeof(" << fdes->getTypeName() << ")" ;
|
||||||
}
|
}
|
||||||
outfile << ",0,0,Language_CPP" ; // range_min, range_max, language
|
outfile << ",0,0,Language_CPP" ; // range_min, range_max, language
|
||||||
outfile << "," << (fdes->isStatic() << 1 ) << "," << std::endl ; // mods
|
outfile << "," << (fdes->isStatic() << 1) + (fdes->isDashDashUnits() << 2) << "," << std::endl ; // mods
|
||||||
if ( fdes->isBitField() ) {
|
if ( fdes->isBitField() ) {
|
||||||
// For bitfields we need the offset to start on 4 byte boundaries because that is what our
|
// For bitfields we need the offset to start on 4 byte boundaries because that is what our
|
||||||
// insert and extract bitfield routines work with.
|
// insert and extract bitfield routines work with.
|
||||||
|
@ -51,7 +51,11 @@ Csv::Csv(char * file_name , char * param_name ) {
|
|||||||
unitTimeStr_ = start_unit + 1 ;
|
unitTimeStr_ = start_unit + 1 ;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unitStr_ = map_trick_units_to_udunits(start_unit + 1) ;
|
if ( !strcmp(start_unit + 1,"--") ) {
|
||||||
|
unitStr_ = strdup(start_unit + 1) ;
|
||||||
|
} else {
|
||||||
|
unitStr_ = map_trick_units_to_udunits(start_unit + 1) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
|
@ -154,7 +154,11 @@ TrickBinary::TrickBinary(char * file_name , char * param_name ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ! strcmp( name_ptr , param_name )) {
|
if ( ! strcmp( name_ptr , param_name )) {
|
||||||
unitStr_ = map_trick_units_to_udunits(units_ptr) ;
|
if ( !strcmp(units_ptr,"--") ) {
|
||||||
|
unitStr_ = strdup(units_ptr) ;
|
||||||
|
} else {
|
||||||
|
unitStr_ = map_trick_units_to_udunits(units_ptr) ;
|
||||||
|
}
|
||||||
record_offset_ = record_size_ ;
|
record_offset_ = record_size_ ;
|
||||||
type_ = type ;
|
type_ = type ;
|
||||||
size_ = size ;
|
size_ = size ;
|
||||||
|
@ -54,7 +54,11 @@ TrickHDF5::TrickHDF5(char *file_name , char *parameter_name , char *time_name) {
|
|||||||
H5PTget_next(parameter_units, 1, units_buf);
|
H5PTget_next(parameter_units, 1, units_buf);
|
||||||
// the specified parameter_name is found, set the units
|
// the specified parameter_name is found, set the units
|
||||||
if (strcmp(parameter_name, name_buf) == 0) {
|
if (strcmp(parameter_name, name_buf) == 0) {
|
||||||
unitStr_ = map_trick_units_to_udunits(units_buf) ;
|
if ( !strcmp(units_ptr,"--") ) {
|
||||||
|
unitStr_ = strdup(units_buf) ;
|
||||||
|
} else {
|
||||||
|
unitStr_ = map_trick_units_to_udunits(units_buf) ;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,11 @@ int LogGroup::parseLogHeaders()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize Unit class
|
// Initialize Unit class
|
||||||
currVar->setUnit(map_trick_units_to_udunits(str3));
|
if ( ! strcmp(str3,"--")) {
|
||||||
|
currVar->setUnit(str3);
|
||||||
|
} else {
|
||||||
|
currVar->setUnit(map_trick_units_to_udunits(str3));
|
||||||
|
}
|
||||||
|
|
||||||
// Set Var Name
|
// Set Var Name
|
||||||
currVar->setVarName(str4) ;
|
currVar->setVarName(str4) ;
|
||||||
|
@ -75,14 +75,22 @@ int Trick::DRAscii::format_specific_init() {
|
|||||||
/* Start with the 1st item in the buffer which should be "sys.exec.out.time" */
|
/* Start with the 1st item in the buffer which should be "sys.exec.out.time" */
|
||||||
out_stream << rec_buffer[0]->ref->reference ;
|
out_stream << rec_buffer[0]->ref->reference ;
|
||||||
if ( rec_buffer[0]->ref->attr->units != NULL ) {
|
if ( rec_buffer[0]->ref->attr->units != NULL ) {
|
||||||
out_stream << " {" << rec_buffer[0]->ref->attr->units << "}" ;
|
if ( rec_buffer[0]->ref->attr->mods & TRICK_MODS_UNITSDASHDASH ) {
|
||||||
|
out_stream << " {--}" ;
|
||||||
|
} else {
|
||||||
|
out_stream << " {" << rec_buffer[0]->ref->attr->units << "}" ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Write out specified recorded parameters */
|
/* Write out specified recorded parameters */
|
||||||
for (jj = 1; jj < rec_buffer.size() ; jj++) {
|
for (jj = 1; jj < rec_buffer.size() ; jj++) {
|
||||||
out_stream << delimiter << rec_buffer[jj]->ref->reference ;
|
out_stream << delimiter << rec_buffer[jj]->ref->reference ;
|
||||||
|
|
||||||
if ( rec_buffer[jj]->ref->attr->units != NULL ) {
|
if ( rec_buffer[jj]->ref->attr->units != NULL ) {
|
||||||
out_stream << " {" << rec_buffer[jj]->ref->attr->units << "}" ;
|
if ( rec_buffer[jj]->ref->attr->mods & TRICK_MODS_UNITSDASHDASH ) {
|
||||||
|
out_stream << " {--}" ;
|
||||||
|
} else {
|
||||||
|
out_stream << " {" << rec_buffer[jj]->ref->attr->units << "}" ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out_stream << std::endl ;
|
out_stream << std::endl ;
|
||||||
|
@ -95,9 +95,15 @@ int Trick::DRBinary::format_specific_init() {
|
|||||||
write( fp , rec_buffer[jj]->ref->reference , write_value ) ;
|
write( fp , rec_buffer[jj]->ref->reference , write_value ) ;
|
||||||
|
|
||||||
/* units */
|
/* units */
|
||||||
write_value = strlen(rec_buffer[jj]->ref->attr->units) ;
|
if ( rec_buffer[jj]->ref->attr->mods & TRICK_MODS_UNITSDASHDASH ) {
|
||||||
write( fp , &write_value , sizeof(int)) ;
|
write_value = strlen("--") ;
|
||||||
write( fp , rec_buffer[jj]->ref->attr->units , write_value ) ;
|
write( fp , &write_value , sizeof(int)) ;
|
||||||
|
write( fp , "--" , write_value ) ;
|
||||||
|
} else {
|
||||||
|
write_value = strlen(rec_buffer[jj]->ref->attr->units) ;
|
||||||
|
write( fp , &write_value , sizeof(int)) ;
|
||||||
|
write( fp , rec_buffer[jj]->ref->attr->units , write_value ) ;
|
||||||
|
}
|
||||||
|
|
||||||
write_value = rec_buffer[jj]->ref->attr->type ;
|
write_value = rec_buffer[jj]->ref->attr->type ;
|
||||||
write( fp , &write_value , sizeof(int)) ;
|
write( fp , &write_value , sizeof(int)) ;
|
||||||
|
@ -185,7 +185,11 @@ int Trick::DRHDF5::format_specific_init() {
|
|||||||
buf = type_string(rec_buffer[ii]->ref->attr->type, rec_buffer[ii]->ref->attr->size );
|
buf = type_string(rec_buffer[ii]->ref->attr->type, rec_buffer[ii]->ref->attr->size );
|
||||||
H5PTappend( param_types_id, 1, buf.c_str() );
|
H5PTappend( param_types_id, 1, buf.c_str() );
|
||||||
/* Param Units */
|
/* Param Units */
|
||||||
H5PTappend( param_units_id, 1, rec_buffer[ii]->ref->attr->units );
|
if ( rec_buffer[ii]->ref->attr->mods & TRICK_MODS_UNITSDASHDASH ) {
|
||||||
|
H5PTappend( param_units_id, 1, "--" );
|
||||||
|
} else {
|
||||||
|
H5PTappend( param_units_id, 1, rec_buffer[ii]->ref->attr->units );
|
||||||
|
}
|
||||||
/* Param Name */
|
/* Param Name */
|
||||||
H5PTappend( param_names_id, 1, rec_buffer[ii]->ref->reference );
|
H5PTappend( param_names_id, 1, rec_buffer[ii]->ref->reference );
|
||||||
|
|
||||||
|
@ -484,8 +484,14 @@ int Trick::DataRecordGroup::write_header() {
|
|||||||
out_stream << "log_" << group_name << "\t"
|
out_stream << "log_" << group_name << "\t"
|
||||||
<< type_string(rec_buffer[jj]->ref->attr->type,
|
<< type_string(rec_buffer[jj]->ref->attr->type,
|
||||||
rec_buffer[jj]->ref->attr->size) << "\t"
|
rec_buffer[jj]->ref->attr->size) << "\t"
|
||||||
<< std::setw(6)<<rec_buffer[jj]->ref->attr->units << "\t"
|
<< std::setw(6) ;
|
||||||
<< rec_buffer[jj]->ref->reference << std::endl ;
|
|
||||||
|
if ( rec_buffer[jj]->ref->attr->mods & TRICK_MODS_UNITSDASHDASH ) {
|
||||||
|
out_stream << "--" ;
|
||||||
|
} else {
|
||||||
|
out_stream << rec_buffer[jj]->ref->attr->units ;
|
||||||
|
}
|
||||||
|
out_stream << "\t" << rec_buffer[jj]->ref->reference << std::endl ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send all unwritten characters in the buffer to its output/file.
|
// Send all unwritten characters in the buffer to its output/file.
|
||||||
|
@ -72,7 +72,15 @@ void Trick::AttributesMap::print_xml(std::ofstream & sie_out ) {
|
|||||||
std::replace(type_name.begin(), type_name.end(), ':', '_');
|
std::replace(type_name.begin(), type_name.end(), ':', '_');
|
||||||
sie_out << std::endl << " type=\"" << type_remove_dims(type_name) << "\"" ;
|
sie_out << std::endl << " type=\"" << type_remove_dims(type_name) << "\"" ;
|
||||||
sie_out << std::endl << " io_attributes=\"" << attr->io << "\"" ;
|
sie_out << std::endl << " io_attributes=\"" << attr->io << "\"" ;
|
||||||
sie_out << std::endl << " units=\"" << attr->units << "\"" ;
|
sie_out << std::endl << " units=\"" ;
|
||||||
|
// If the mods bit is set for using -- as the units
|
||||||
|
if ( attr->mods & TRICK_MODS_UNITSDASHDASH ) {
|
||||||
|
sie_out << "--" ;
|
||||||
|
} else {
|
||||||
|
sie_out << attr->units ;
|
||||||
|
}
|
||||||
|
sie_out << "\"" ;
|
||||||
|
|
||||||
std::string description = attr->des;
|
std::string description = attr->des;
|
||||||
if ( ! description.empty() ) {
|
if ( ! description.empty() ) {
|
||||||
sie_out << std::endl << " description=\"" << replace_special_chars(description) << "\"" ;
|
sie_out << std::endl << " description=\"" << replace_special_chars(description) << "\"" ;
|
||||||
|
@ -28,6 +28,7 @@ static std::map< std::string, std::string> init_map_old_to_ud() {
|
|||||||
init_map["gal"] = "gallon" ;
|
init_map["gal"] = "gallon" ;
|
||||||
init_map["one"] = "1" ;
|
init_map["one"] = "1" ;
|
||||||
init_map["cnt"] = "count" ;
|
init_map["cnt"] = "count" ;
|
||||||
|
init_map["--"] = "1" ;
|
||||||
|
|
||||||
return init_map ;
|
return init_map ;
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,9 @@ int Trick::VariableServerThread::var_units(std::string var_name, std::string uni
|
|||||||
if (!units_name.compare("xx")) {
|
if (!units_name.compare("xx")) {
|
||||||
vars[ii]->ref->units = strdup(vars[ii]->ref->attr->units);
|
vars[ii]->ref->units = strdup(vars[ii]->ref->attr->units);
|
||||||
}
|
}
|
||||||
|
else if (!units_name.compare("--")) {
|
||||||
|
vars[ii]->ref->units = strdup("1");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
std::string new_units = map_trick_units_to_udunits(units_name) ;
|
std::string new_units = map_trick_units_to_udunits(units_name) ;
|
||||||
if ( units_name.compare(new_units) ) {
|
if ( units_name.compare(new_units) ) {
|
||||||
|
@ -178,7 +178,11 @@ int vs_format_ascii(Trick::VariableReference * var, char *value) {
|
|||||||
} //end while
|
} //end while
|
||||||
|
|
||||||
if (ref->units) {
|
if (ref->units) {
|
||||||
sprintf(value, "%s {%s}", value, ref->units);
|
if ( ref->attr->mods & TRICK_MODS_UNITSDASHDASH ) {
|
||||||
|
sprintf(value, "%s {--}", value);
|
||||||
|
} else {
|
||||||
|
sprintf(value, "%s {%s}", value, ref->units);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
Reference in New Issue
Block a user