Commit 6d05efa7 authored by Claes Sjofors's avatar Claes Sjofors

Input and output area length added to datafile

parent 052a024d
......@@ -1862,6 +1862,52 @@ int pn_gsdml::string_to_datavalue( gsdml_eValueDataType datatype, void *value,
return 1;
}
//
// Get the length of an IO type specified in a data item
//
int pn_gsdml::get_datavalue_length( gsdml_eValueDataType datatype, int strlength, unsigned int *len)
{
switch ( datatype) {
case gsdml_eValueDataType_Integer8:
case gsdml_eValueDataType_Unsigned8:
*len = 1;
break;
case gsdml_eValueDataType_Integer16:
case gsdml_eValueDataType_Unsigned16:
*len = 2;
break;
case gsdml_eValueDataType_Integer32:
case gsdml_eValueDataType_Unsigned32:
case gsdml_eValueDataType_Float32:
*len = 4;
break;
case gsdml_eValueDataType_Integer64:
case gsdml_eValueDataType_Unsigned64:
case gsdml_eValueDataType_Float64:
*len = 8;
break;
case gsdml_eValueDataType_VisibleString:
case gsdml_eValueDataType_OctetString:
*len = strlength;
break;
case gsdml_eValueDataType_Date:
case gsdml_eValueDataType_TimeOfDayWithDate:
case gsdml_eValueDataType_TimeOfDayWithoutDate:
case gsdml_eValueDataType_TimeDiffWithDate:
case gsdml_eValueDataType_TimeDiffWithoutDate:
case gsdml_eValueDataType_NetworkTime:
case gsdml_eValueDataType_NetworkTimeDiff:
// TODO
return PB__NYI;
*len = 0;
break;
default:
return PB__NYI;
*len = 0;
}
return PB__SUCCESS;
}
int pn_gsdml::set_default_values( gsdml_eTag id, void *data, unsigned int size)
{
for ( unsigned int i = 0; i < sizeof(attrlist)/sizeof(attrlist[0]); i++) {
......
......@@ -1466,6 +1466,7 @@ class pn_gsdml {
unsigned int size, char *str, unsigned int strsize);
int string_to_datavalue( gsdml_eValueDataType datatype, void *value,
unsigned int size, char *str);
int get_datavalue_length( gsdml_eValueDataType datatype, int strlength, unsigned int *len);
void set_classes( gsdml_sModuleClass *mclist) { module_classlist = mclist;}
int set_par_record_default( unsigned char *data, int size,
gsdml_ParameterRecordDataItem *par_record);
......
......@@ -1345,6 +1345,7 @@ int GsdmlAttrNav::init_brow_cb( FlowCtx *fctx, void *client_data)
int GsdmlAttrNav::save( const char *filename)
{
int sts;
dev_data.device_num = device_num;
......@@ -1389,12 +1390,154 @@ int GsdmlAttrNav::save( const char *filename)
cd->error_type = gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]->Body.ErrorType;
strncpy( cd->name, (char *)gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]->
Body.Name.p, sizeof(cd->name));
strncpy( cd->help, (char *)gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]->
Body.Help.p, sizeof(cd->help));
if ( gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]->Body.Help.p)
strncpy( cd->help, (char *)gsdml->ApplicationProcess->ChannelDiagList->ChannelDiagItem[i]->
Body.Help.p, sizeof(cd->help));
dev_data.channel_diag.push_back( cd);
}
}
// Calculate subslot IO length
for ( unsigned int i = 0; i < dev_data.slot_data.size(); i++) {
if ( i == 0) {
// Device access point
gsdml_DeviceAccessPointItem *mi = device_item;
for ( unsigned int j = 0; j < dev_data.slot_data[i]->subslot_data.size(); j++) {
GsdmlSubslotData *ssd = dev_data.slot_data[i]->subslot_data[j];
ssd->io_input_length = 0;
ssd->io_output_length = 0;
if ( mi->VirtualSubmoduleList->VirtualSubmoduleItem.size() == 0)
continue;
gsdml_VirtualSubmoduleItem *vsd = 0;
if ( mi->VirtualSubmoduleList->VirtualSubmoduleItem.size() == 1)
vsd = mi->VirtualSubmoduleList->VirtualSubmoduleItem[0];
else {
for ( unsigned int k = 0; k < mi->VirtualSubmoduleList->VirtualSubmoduleItem.size(); k++) {
if ( mi->VirtualSubmoduleList->VirtualSubmoduleItem[k]->Body.SubmoduleIdentNumber ==
ssd->submodule_ident_number) {
vsd = mi->VirtualSubmoduleList->VirtualSubmoduleItem[k];
break;
}
}
}
if ( !vsd) {
continue;
}
if ( !vsd->IOData)
continue;
if ( vsd->IOData->Input) {
for ( unsigned k = 0; k < vsd->IOData->Input->DataItem.size(); k++) {
gsdml_DataItem *di = vsd->IOData->Input->DataItem[k];
gsdml_eValueDataType datatype;
gsdml->string_to_value_datatype( di->Body.DataType, &datatype);
unsigned int len;
sts = gsdml->get_datavalue_length( datatype, di->Body.Length, &len);
if ( EVEN(sts)) printf( "GSDML-Error, Datatype %s not yet implemented\n", di->Body.DataType);
ssd->io_input_length += len;
}
}
if ( vsd->IOData->Output) {
for ( unsigned k = 0; k < vsd->IOData->Output->DataItem.size(); k++) {
gsdml_DataItem *di = vsd->IOData->Output->DataItem[k];
gsdml_eValueDataType datatype;
gsdml->string_to_value_datatype( di->Body.DataType, &datatype);
unsigned int len;
sts = gsdml->get_datavalue_length( datatype, di->Body.Length, &len);
if ( EVEN(sts)) printf( "GSDML-Error, Datatype %s not yet implemented\n", di->Body.DataType);
ssd->io_output_length += len;
}
}
}
}
else {
if ( dev_data.slot_data[i]->module_enum_number == 0)
continue;
gsdml_UseableModules *um = device_item->UseableModules;
if ( !um)
continue;
gsdml_ModuleItem *mi = (gsdml_ModuleItem *)um->
ModuleItemRef[dev_data.slot_data[i]->module_enum_number-1]->Body.ModuleItemTarget.p;
for ( unsigned int j = 0; j < dev_data.slot_data[i]->subslot_data.size(); j++) {
GsdmlSubslotData *ssd = dev_data.slot_data[i]->subslot_data[j];
ssd->io_input_length = 0;
ssd->io_output_length = 0;
if ( mi->VirtualSubmoduleList->VirtualSubmoduleItem.size() == 0)
continue;
gsdml_VirtualSubmoduleItem *vsd = 0;
if ( mi->VirtualSubmoduleList->VirtualSubmoduleItem.size() == 1)
vsd = mi->VirtualSubmoduleList->VirtualSubmoduleItem[0];
else {
for ( unsigned int k = 0; k < mi->VirtualSubmoduleList->VirtualSubmoduleItem.size(); k++) {
if ( mi->VirtualSubmoduleList->VirtualSubmoduleItem[k]->Body.SubmoduleIdentNumber ==
ssd->submodule_ident_number) {
vsd = mi->VirtualSubmoduleList->VirtualSubmoduleItem[k];
break;
}
}
}
if ( !vsd) {
printf( "GSDML-Error, subslot number not found\n");
continue;
}
if ( !vsd->IOData)
continue;
if ( vsd->IOData->Input) {
for ( unsigned k = 0; k < vsd->IOData->Input->DataItem.size(); k++) {
gsdml_DataItem *di = vsd->IOData->Input->DataItem[k];
gsdml_eValueDataType datatype;
gsdml->string_to_value_datatype( di->Body.DataType, &datatype);
unsigned int len;
sts = gsdml->get_datavalue_length( datatype, di->Body.Length, &len);
if ( EVEN(sts)) printf( "GSDML-Error, Datatype %s not yet implemented\n", di->Body.DataType);
ssd->io_input_length += len;
}
}
if ( vsd->IOData->Output) {
for ( unsigned k = 0; k < vsd->IOData->Output->DataItem.size(); k++) {
gsdml_DataItem *di = vsd->IOData->Output->DataItem[k];
gsdml_eValueDataType datatype;
gsdml->string_to_value_datatype( di->Body.DataType, &datatype);
unsigned int len;
sts = gsdml->get_datavalue_length( datatype, di->Body.Length, &len);
if ( EVEN(sts)) printf( "GSDML-Error, Datatype %s not yet implemented\n", di->Body.DataType);
ssd->io_output_length += len;
}
}
}
}
}
return dev_data.print( filename);
// Unload channel diag
......@@ -1780,12 +1923,17 @@ int ItemPnSlot::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd = new GsdmlSubslotData();
ssd->subslot_number = subslot_number;
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number =
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i]->Body.SubmoduleIdentNumber;
slotdata->subslot_data.push_back(ssd);
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number =
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i]->Body.SubmoduleIdentNumber;
if ( ssd->subslot_number != subslot_number) {
ssd->subslot_number = subslot_number;
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
}
}
......@@ -1811,12 +1959,17 @@ int ItemPnSlot::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd = new GsdmlSubslotData();
ssd->subslot_number = subslot_number;
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number =
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i]->Body.SubmoduleIdentNumber;
slotdata->subslot_data.push_back(ssd);
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number =
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i]->Body.SubmoduleIdentNumber;
if ( ssd->subslot_number != subslot_number) {
ssd->subslot_number = subslot_number;
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
}
}
......@@ -2020,12 +2173,17 @@ int ItemPnDAP::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd = new GsdmlSubslotData();
ssd->subslot_number = subslot_number;
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number =
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i]->Body.SubmoduleIdentNumber;
slotdata->subslot_data.push_back(ssd);
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number =
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i]->Body.SubmoduleIdentNumber;
if ( ssd->subslot_number != subslot_number) {
ssd->subslot_number = subslot_number;
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
}
}
......@@ -2052,12 +2210,17 @@ int ItemPnDAP::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd = new GsdmlSubslotData();
ssd->subslot_number = subslot_number;
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number =
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i]->Body.SubmoduleIdentNumber;
slotdata->subslot_data.push_back(ssd);
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number =
mi->VirtualSubmoduleList->VirtualSubmoduleItem[i]->Body.SubmoduleIdentNumber;
if ( ssd->subslot_number != subslot_number) {
ssd->subslot_number = subslot_number;
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
}
}
......@@ -2093,12 +2256,15 @@ int ItemPnDAP::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd = new GsdmlSubslotData();
ssd->subslot_number = ii->Body.SubslotNumber;
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number = ii->Body.SubmoduleIdentNumber;
slotdata->subslot_data.push_back(ssd);
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number = ii->Body.SubmoduleIdentNumber;
if ( ssd->subslot_number != ii->Body.SubslotNumber) {
ssd->subslot_number = ii->Body.SubslotNumber;
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
}
}
......@@ -2126,12 +2292,15 @@ int ItemPnDAP::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd = new GsdmlSubslotData();
ssd->subslot_number = pi->Body.SubslotNumber;
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number = pi->Body.SubmoduleIdentNumber;
slotdata->subslot_data.push_back(ssd);
}
else {
ssd = slotdata->subslot_data[subslot_index];
ssd->subslot_idx = subslot_index;
ssd->submodule_ident_number = pi->Body.SubmoduleIdentNumber;
if ( ssd->subslot_number != pi->Body.SubslotNumber) {
ssd->subslot_number = pi->Body.SubslotNumber;
printf( "GSML-Error, datafile corrupt, unexpected subslot number\n");
}
}
......
......@@ -74,7 +74,10 @@ int GsdmlDataRecord::print( ofstream& fp)
int GsdmlSubslotData::print( ofstream& fp)
{
fp <<
" <Subslot SubslotNumber=\"" << subslot_number << "\" >" << endl;
" <Subslot SubslotNumber=\"" << subslot_number << "\"" << endl <<
" SubmoduleIdentNumber=\"" << submodule_ident_number << "\"" << endl <<
" IOInputLength=\"" << io_input_length << "\"" << endl <<
" IOOutputLength=\"" << io_output_length << "\" >" << endl;
for ( unsigned int i = 0; i < data_record.size(); i++) {
data_record[i]->print( fp);
......@@ -431,6 +434,12 @@ int GsdmlDataReader::tag_attribute( const char *name, const char *value)
if ( strcmp( name, "SubslotNumber") == 0)
sscanf( value, "%u", &sd->subslot_number);
else if ( strcmp( name, "SubmoduleIdentNumber") == 0)
sscanf( value, "%u", &sd->submodule_ident_number);
else if ( strcmp( name, "IOInputLength") == 0)
sscanf( value, "%u", &sd->io_input_length);
else if ( strcmp( name, "IOOutputLength") == 0)
sscanf( value, "%u", &sd->io_output_length);
break;
}
case gsdmldata_eTag_DataRecord: {
......
......@@ -64,11 +64,15 @@ class GsdmlIOCRData {
class GsdmlSubslotData {
public:
GsdmlSubslotData() : subslot_number(0), subslot_idx(0) {}
GsdmlSubslotData() : subslot_number(0), subslot_idx(0), submodule_ident_number(0),
io_input_length(0), io_output_length(0) {}
vector<GsdmlDataRecord *> data_record;
unsigned int subslot_number;
unsigned int subslot_idx;
unsigned int submodule_ident_number;
unsigned int io_input_length;
unsigned int io_output_length;
~GsdmlSubslotData() {
for ( unsigned int i = 0; i < data_record.size(); i++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment