Commit 98167b8c authored by Marcus Nordenberg's avatar Marcus Nordenberg Committed by Claes Sjöfors

profinet: honor fixedinslot attribute for the DAP

parent 8e4db86d
...@@ -6537,6 +6537,8 @@ gsdml_DeviceAccessPointItem::gsdml_DeviceAccessPointItem(pn_gsdml* g) ...@@ -6537,6 +6537,8 @@ gsdml_DeviceAccessPointItem::gsdml_DeviceAccessPointItem(pn_gsdml* g)
void gsdml_DeviceAccessPointItem::build() void gsdml_DeviceAccessPointItem::build()
{ {
Body.FixedInSlots.list = new gsdml_Valuelist(Body.FixedInSlots.str);
if (ModuleInfo) if (ModuleInfo)
ModuleInfo->build(); ModuleInfo->build();
if (SubslotList) if (SubslotList)
...@@ -6553,6 +6555,7 @@ void gsdml_DeviceAccessPointItem::build() ...@@ -6553,6 +6555,7 @@ void gsdml_DeviceAccessPointItem::build()
UseableSubmodules->build(); UseableSubmodules->build();
if (SlotList) if (SlotList)
SlotList->build(); SlotList->build();
Body.PhysicalSlots.list = new gsdml_Valuelist(Body.PhysicalSlots.str); Body.PhysicalSlots.list = new gsdml_Valuelist(Body.PhysicalSlots.str);
} }
......
...@@ -1257,25 +1257,43 @@ int GsdmlAttrNav::object_attr() ...@@ -1257,25 +1257,43 @@ int GsdmlAttrNav::object_attr()
} }
new ItemPnDAP(this, "DAP", sd, NULL, flow_eDest_IntoLast); new ItemPnDAP(this, "DAP", sd, NULL, flow_eDest_IntoLast);
slot_cnt++; slot_cnt++;
gsdml_ValuelistIterator fixed_in_slots_iter(
gsdml->ApplicationProcess->DeviceAccessPointList
->DeviceAccessPointItem[device_num - 1]
->Body.FixedInSlots.list);
// Check to see if this DAP is supposed to be fixed in a specific slot (We assume the first one).
// We also assume the DAP is never placed in more than one slot.
// FixedInSlots attribute may apply to modules and submodules aswell but is not implemented (yet)
unsigned int fixed_position = fixed_in_slots_iter.begin();
if (fixed_position > 0 && sd->dap_fixed_slot != 1)
{
sd->dap_fixed_slot = 1;
sd->slot_number = slot_cnt;
}
gsdml_ValuelistIterator iter( gsdml_ValuelistIterator iter(
gsdml->ApplicationProcess->DeviceAccessPointList gsdml->ApplicationProcess->DeviceAccessPointList
->DeviceAccessPointItem[device_num - 1] ->DeviceAccessPointItem[device_num - 1]
->Body.PhysicalSlots.list); ->Body.PhysicalSlots.list);
for (unsigned int i = iter.begin(); i != iter.end(); i = iter.next())
{ // Add all the slots, the DAP goes to the first physical slot
if (i == 0) int first_slot = iter.begin();
// DAP already created for (unsigned int physical_slot = first_slot; physical_slot != iter.end(); physical_slot = iter.next()) {
continue;
//Skip the DAP
if (first_slot == physical_slot)
physical_slot = iter.next();
char name[80]; char name[80];
sprintf(name, "Slot %u", i); sprintf(name, "Slot %u", physical_slot);
if (dev_data.slot_data.size() <= slot_cnt) if (dev_data.slot_data.size() <= slot_cnt)
{ {
sd = new GsdmlSlotData(); sd = new GsdmlSlotData();
sd->slot_number = i; sd->slot_number = physical_slot;
sd->slot_idx = slot_cnt; sd->slot_idx = slot_cnt;
dev_data.slot_data.push_back(sd); dev_data.slot_data.push_back(sd);
} }
...@@ -1283,8 +1301,7 @@ int GsdmlAttrNav::object_attr() ...@@ -1283,8 +1301,7 @@ int GsdmlAttrNav::object_attr()
{ {
sd = dev_data.slot_data[slot_cnt]; sd = dev_data.slot_data[slot_cnt];
sd->slot_idx = slot_cnt; sd->slot_idx = slot_cnt;
if (i != sd->slot_number) if (physical_slot != sd->slot_number) {
{
printf("GSML-Error, datafile corrupt, unexpected slot number\n"); printf("GSML-Error, datafile corrupt, unexpected slot number\n");
} }
} }
......
...@@ -136,7 +136,8 @@ int GsdmlSlotData::print(std::ofstream& fp, bool reverse_endianess) ...@@ -136,7 +136,8 @@ int GsdmlSlotData::print(std::ofstream& fp, bool reverse_endianess)
<< " ModuleIdentNumber=\"" << module_ident_number << "\"\n" << " ModuleIdentNumber=\"" << module_ident_number << "\"\n"
<< " ModuleClass=\"" << module_class << "\"\n" << " ModuleClass=\"" << module_class << "\"\n"
<< " ModuleText=\"" << module_text << "\"\n" << " ModuleText=\"" << module_text << "\"\n"
<< " SlotNumber=\"" << slot_number << "\" >\n"; << " SlotNumber=\"" << slot_number << "\"\n"
<< " DapFixedInSlot=\"" << dap_fixed_slot << "\" >\n";
for (unsigned int i = 0; i < subslot_data.size(); i++) for (unsigned int i = 0; i < subslot_data.size(); i++)
{ {
...@@ -610,6 +611,8 @@ int GsdmlDataReader::tag_attribute(const char* name, const char* value) ...@@ -610,6 +611,8 @@ int GsdmlDataReader::tag_attribute(const char* name, const char* value)
strncpy(sd->module_text, value, sizeof(sd->module_text)); strncpy(sd->module_text, value, sizeof(sd->module_text));
else if (streq(name, "SlotNumber")) else if (streq(name, "SlotNumber"))
sscanf(value, "%u", &sd->slot_number); sscanf(value, "%u", &sd->slot_number);
else if (streq(name, "DapFixedInSlot"))
sscanf(value, "%u", &sd->dap_fixed_slot);
break; break;
} }
case gsdmldata_eTag_Subslot: case gsdmldata_eTag_Subslot:
......
...@@ -128,17 +128,20 @@ class GsdmlSlotData ...@@ -128,17 +128,20 @@ class GsdmlSlotData
{ {
public: public:
GsdmlSlotData() GsdmlSlotData()
: module_enum_number(0), module_class(0), module_oid(pwr_cNOid), : module_enum_number(0), dap_fixed_slot(0), module_class(0), module_oid(pwr_cNOid),
slot_number(0), slot_idx(0) slot_number(0), slot_idx(0)
{ {
module_text[0] = 0; module_text[0] = 0;
} }
unsigned int module_enum_number; unsigned int module_enum_number;
unsigned int module_ident_number; unsigned int module_ident_number;
unsigned int dap_fixed_slot;
pwr_tCid module_class; pwr_tCid module_class;
pwr_tOid module_oid; pwr_tOid module_oid;
char module_text[160]; char module_text[160];
unsigned int slot_number; unsigned int slot_number;
unsigned int slot_idx; unsigned int slot_idx;
std::vector<GsdmlSubslotData*> subslot_data; std::vector<GsdmlSubslotData*> subslot_data;
......
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