2
EK1101
#x1a00
ID
#x6000
1
16
ID
UINT
2
EL1819
#x1a00
Channel 1
#x6000
1
1
Input
BOOL
#x1a01
Channel 2
#x6010
1
1
Input
BOOL
#x1a02
Channel 3
#x6020
1
1
Input
BOOL
#x1a03
Channel 4
#x6030
1
1
Input
BOOL
#x1a04
Channel 5
#x6040
1
1
Input
BOOL
#x1a05
Channel 6
#x6050
1
1
Input
BOOL
#x1a06
Channel 7
#x6060
1
1
Input
BOOL
#x1a07
Channel 8
#x6070
1
1
Input
BOOL
#x1a08
Channel 9
#x6080
1
1
Input
BOOL
#x1a09
Channel 10
#x6090
1
1
Input
BOOL
#x1a0a
Channel 11
#x60a0
1
1
Input
BOOL
#x1a0b
Channel 12
#x60b0
1
1
Input
BOOL
#x1a0c
Channel 13
#x60c0
1
1
Input
BOOL
#x1a0d
Channel 14
#x60d0
1
1
Input
BOOL
#x1a0e
Channel 15
#x60e0
1
1
Input
BOOL
#x1a0f
Channel 16
#x60f0
1
1
Input
BOOL
2
EL2024
#x1600
Channel 1
#x7000
1
1
Output
BOOL
#x1601
Channel 2
#x7010
1
1
Output
BOOL
#x1602
Channel 3
#x7020
1
1
Output
BOOL
#x1603
Channel 4
#x7030
1
1
Output
BOOL
2
EL4132
#x1600
RxPDO 01 mapping
#x3001
1
16
Output
INT
#x1601
RxPDO 02 mapping
#x3002
1
16
Output
INT
2
EL3102
#x1a00
TxPDO-Map Channel 1
#x3101
1
8
Status
USINT
#x3101
2
16
Value
INT
#x1a01
TxPDO-Map Channel 2
#x3102
1
8
Status
USINT
#x3102
2
16
Value
INT
--------------------------------------------------------------------------------------------------
Vendor: 2
Type: EK1101
Product Code and revision: 72166482 #x00120000
2014/04/09 22:22:02.899 DEBUG Getting save info for pos 0
2014/04/09 22:22:02.899 DEBUG Found group 1
2014/04/09 22:22:02.899 DEBUG Sync Manager 0 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.899 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a00
2014/04/09 22:22:02.899 DEBUG PDO Entry: PDO Index 0x1a00 Entry Index: 0x6000 Entry subindex: 0x1 entry bit length: 10
2014/04/09 22:22:02.899 DEBUG DomainOffset = 0 sm idx 0 pdo pos 0 entry pos 0 bit pos 0
Vendor: 2
Type: EL1819
Product Code and revision: 119222354 #x00110000
2014/04/09 22:22:02.900 DEBUG Getting save info for pos 1
2014/04/09 22:22:02.900 DEBUG Found group 3
2014/04/09 22:22:02.900 DEBUG Sync Manager 0 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.900 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a00
2014/04/09 22:22:02.900 DEBUG PDO Entry: PDO Index 0x1a00 Entry Index: 0x6000 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.900 DEBUG DomainOffset = 2 sm idx 0 pdo pos 0 entry pos 0 bit pos 0
2014/04/09 22:22:02.900 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a01
2014/04/09 22:22:02.900 DEBUG PDO Entry: PDO Index 0x1a01 Entry Index: 0x6010 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.900 DEBUG DomainOffset = 2 sm idx 0 pdo pos 1 entry pos 0 bit pos 1
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a02
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a02 Entry Index: 0x6020 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 2 entry pos 0 bit pos 2
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a03
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a03 Entry Index: 0x6030 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 3 entry pos 0 bit pos 3
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a04
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a04 Entry Index: 0x6040 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 4 entry pos 0 bit pos 4
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a05
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a05 Entry Index: 0x6050 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 5 entry pos 0 bit pos 5
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a06
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a06 Entry Index: 0x6060 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 6 entry pos 0 bit pos 6
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a07
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a07 Entry Index: 0x6070 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 2 sm idx 0 pdo pos 7 entry pos 0 bit pos 7
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a08
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a08 Entry Index: 0x6080 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 3 sm idx 0 pdo pos 8 entry pos 0 bit pos 0
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a09
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a09 Entry Index: 0x6090 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 3 sm idx 0 pdo pos 9 entry pos 0 bit pos 1
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0a
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a0a Entry Index: 0x60a0 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 3 sm idx 0 pdo pos a entry pos 0 bit pos 2
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0b
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a0b Entry Index: 0x60b0 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 3 sm idx 0 pdo pos b entry pos 0 bit pos 3
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0c
2014/04/09 22:22:02.901 DEBUG PDO Entry: PDO Index 0x1a0c Entry Index: 0x60c0 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.901 DEBUG DomainOffset = 3 sm idx 0 pdo pos c entry pos 0 bit pos 4
2014/04/09 22:22:02.901 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0d
2014/04/09 22:22:02.902 DEBUG PDO Entry: PDO Index 0x1a0d Entry Index: 0x60d0 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.902 DEBUG DomainOffset = 3 sm idx 0 pdo pos d entry pos 0 bit pos 5
2014/04/09 22:22:02.902 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0e
2014/04/09 22:22:02.902 DEBUG PDO Entry: PDO Index 0x1a0e Entry Index: 0x60e0 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.902 DEBUG DomainOffset = 3 sm idx 0 pdo pos e entry pos 0 bit pos 6
2014/04/09 22:22:02.902 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1a0f
2014/04/09 22:22:02.902 DEBUG PDO Entry: PDO Index 0x1a0f Entry Index: 0x60f0 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.902 DEBUG DomainOffset = 3 sm idx 0 pdo pos f entry pos 0 bit pos 7
Vendor: 2
Type: EL2024
Product Code and revision: 132657234 #x00110000
2014/04/09 22:22:02.902 DEBUG Getting save info for pos 2
2014/04/09 22:22:02.902 DEBUG Found group 2
2014/04/09 22:22:02.902 DEBUG Sync Manager 0 Direction: 1 Watchdog: 1
2014/04/09 22:22:02.902 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1600
2014/04/09 22:22:02.902 DEBUG PDO Entry: PDO Index 0x1600 Entry Index: 0x7000 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.902 DEBUG DomainOffset = 3 sm idx 0 pdo pos 0 entry pos 0 bit pos 0
2014/04/09 22:22:02.902 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1601
2014/04/09 22:22:02.902 DEBUG PDO Entry: PDO Index 0x1601 Entry Index: 0x7010 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.902 DEBUG DomainOffset = 3 sm idx 0 pdo pos 1 entry pos 0 bit pos 1
2014/04/09 22:22:02.902 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1602
2014/04/09 22:22:02.903 DEBUG PDO Entry: PDO Index 0x1602 Entry Index: 0x7020 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.903 DEBUG DomainOffset = 3 sm idx 0 pdo pos 2 entry pos 0 bit pos 2
2014/04/09 22:22:02.903 DEBUG PDO: SM Index 0x0 pdoIndex: 0x1603
2014/04/09 22:22:02.903 DEBUG PDO Entry: PDO Index 0x1603 Entry Index: 0x7030 Entry subindex: 0x1 entry bit length: 1
2014/04/09 22:22:02.903 DEBUG DomainOffset = 3 sm idx 0 pdo pos 3 entry pos 0 bit pos 3
Vendor: 2
Type: EL4132
Product Code and revision: 270807122 #x03fa0000
2014/04/09 22:22:02.903 DEBUG Getting save info for pos 3
2014/04/09 22:22:02.903 DEBUG Found group 4
2014/04/09 22:22:02.903 DEBUG Sync Manager 0 Direction: 1 Watchdog: 2
2014/04/09 22:22:02.903 DEBUG Sync Manager 1 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.903 DEBUG Sync Manager 2 Direction: 1 Watchdog: 2
2014/04/09 22:22:02.903 DEBUG Sync Manager 3 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.903 DEBUG PDO: SM Index 0x2 pdoIndex: 0x1600
2014/04/09 22:22:02.903 DEBUG PDO Entry: PDO Index 0x1600 Entry Index: 0x3001 Entry subindex: 0x1 entry bit length: 10
2014/04/09 22:22:02.903 DEBUG DomainOffset = 4 sm idx 2 pdo pos 0 entry pos 0 bit pos 0
2014/04/09 22:22:02.903 DEBUG PDO: SM Index 0x2 pdoIndex: 0x1601
2014/04/09 22:22:02.903 DEBUG PDO Entry: PDO Index 0x1601 Entry Index: 0x3002 Entry subindex: 0x1 entry bit length: 10
2014/04/09 22:22:02.903 DEBUG DomainOffset = 6 sm idx 2 pdo pos 1 entry pos 0 bit pos 0
Vendor: 2
Type: EL3102
Product Code and revision: 203305042 #x00110000
2014/04/09 22:22:02.904 DEBUG Getting save info for pos 4
2014/04/09 22:22:02.904 DEBUG Found group 5
2014/04/09 22:22:02.904 DEBUG Sync Manager 0 Direction: 1 Watchdog: 2
2014/04/09 22:22:02.904 DEBUG Sync Manager 1 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.904 DEBUG Sync Manager 2 Direction: 1 Watchdog: 2
2014/04/09 22:22:02.904 DEBUG Sync Manager 3 Direction: 2 Watchdog: 2
2014/04/09 22:22:02.904 DEBUG PDO: SM Index 0x3 pdoIndex: 0x1a00
2014/04/09 22:22:02.904 DEBUG PDO Entry: PDO Index 0x1a00 Entry Index: 0x3101 Entry subindex: 0x1 entry bit length: 8
2014/04/09 22:22:02.904 DEBUG DomainOffset = 6 sm idx 3 pdo pos 0 entry pos 0 bit pos 0
2014/04/09 22:22:02.904 DEBUG PDO Entry: PDO Index 0x1a00 Entry Index: 0x3101 Entry subindex: 0x2 entry bit length: 10
2014/04/09 22:22:02.904 DEBUG DomainOffset = 7 sm idx 3 pdo pos 0 entry pos 1 bit pos 0
2014/04/09 22:22:02.904 DEBUG PDO: SM Index 0x3 pdoIndex: 0x1a01
2014/04/09 22:22:02.904 DEBUG PDO Entry: PDO Index 0x1a01 Entry Index: 0x3102 Entry subindex: 0x1 entry bit length: 8
2014/04/09 22:22:02.904 DEBUG DomainOffset = 9 sm idx 3 pdo pos 1 entry pos 0 bit pos 0
2014/04/09 22:22:02.904 DEBUG PDO Entry: PDO Index 0x1a01 Entry Index: 0x3102 Entry subindex: 0x2 entry bit length: 10
2014/04/09 22:22:02.904 DEBUG DomainOffset = a sm idx 3 pdo pos 1 entry pos 1 bit pos 0
2014/04/09 22:22:02.905 DEBUG Number of IO points: 1b
DomainDC = 0xcdf68000
-----------------------------------------------------------------------------------------------------------
bool EtherLabEtherCATMaster::parseXmlFile(const char* filename)
{
bool ret(true);
std::ifstream is;
is.open(filename);
if (!is.is_open()) {
return false;;
}
boost::property_tree::ptree pt;
boost::property_tree::read_xml(is, pt);
uint8_t syncManagerIndex(0);
LongTranslator lTrans;
ULongTranslator ulTrans;
U16Translator u16Trans;
U8Translator u8Trans;
uint16_t posCount = 0;
uint32_t vendorID;
uint32_t productCode;
ec_slave_config_t* slaveConfig;
ec_slave_info_t slaveInfo;
TIOPointType ioPointType;
unsigned pdoPos, entryPos;
BOOST_FOREACH(boost::property_tree::ptree::value_type const& v, pt.get_child("EtherCATInfoList")) {
if (v.first == "EtherCATInfo") {
BOOST_FOREACH(boost::property_tree::ptree::value_type const& v1, v.second ) {
//std::cout << v1.first << std::endl;
if (v1.first == "Vendor") {
vendorID = v1.second.get("Id");
std::cout << "Vendor: " << vendorID << std::endl;
}
if (v1.first == "Descriptions") {
boost::property_tree::ptree devTree = v1.second;
boost::property_tree::ptree devParts = devTree.get_child("Devices");
syncManagerIndex = 0;
BOOST_FOREACH(boost::property_tree::ptree::value_type const& deviceList, devParts.get_child("Device")) {
//std::cout << deviceList.first << std::endl;
if (deviceList.first == "Type") {
cout << "Type: " << deviceList.second.get_value() << std::endl;
productCode = deviceList.second.get(".ProductCode", ulTrans);
cout << "Product Code and revision: " << productCode
<< " " << deviceList.second.get(".RevisionNo") << std::endl;
slaveConfig = ecrt_master_slave_config(Master, 0, posCount, vendorID, productCode);
if (!slaveConfig) {
ret = false;
} else {
LOG4CPLUS_DEBUG(Logger, "Getting save info for pos " << posCount);
ecrt_master_get_slave(Master, posCount, &slaveInfo);
ioPointType = TranslateIOType(slaveInfo.group);
LOG4CPLUS_DEBUG(Logger, "Found group " << ioPointType);
}
}
if (deviceList.first == "Sm") {
long startAddr;
startAddr = deviceList.second.get(".StartAddress", lTrans);
uint32_t controlRegister = deviceList.second.get(".ControlByte",ulTrans);
ec_direction_t smDirection = (controlRegister & 0x4) ? EC_DIR_OUTPUT : EC_DIR_INPUT;
ec_watchdog_mode_t smWatchdogMode = (controlRegister & 0x40)? EC_WD_ENABLE : EC_WD_DISABLE;
if (0 != ecrt_slave_config_sync_manager(slaveConfig, syncManagerIndex, smDirection, smWatchdogMode)) {
ret = false;
LOG4CPLUS_ERROR(Logger, "Error during ecrt_slave_config_sync_manager()");
}
ecrt_slave_config_pdo_assign_clear(slaveConfig, syncManagerIndex);
LOG4CPLUS_DEBUG(Logger, "Sync Manager " << (int)syncManagerIndex
<< " Direction: " << smDirection
<< " Watchdog: " << smWatchdogMode);
++syncManagerIndex;
pdoPos = 0;
}
if (deviceList.first == "RxPdo" || deviceList.first == "TxPdo") {
uint8_t smIndex = deviceList.second.get(".Sm", u8Trans);
uint16_t pdoIndex = deviceList.second.get("Index", u16Trans);
if (0 != ecrt_slave_config_pdo_assign_add(slaveConfig, smIndex, pdoIndex)) {
ret = false;
LOG4CPLUS_ERROR(Logger, "Error during ecrt_slave_config_pdo_assign_add()");
}
ecrt_slave_config_pdo_mapping_clear(slaveConfig, pdoIndex);
LOG4CPLUS_DEBUG(Logger, "PDO: SM Index 0x" << std::hex << (int)smIndex
<< " pdoIndex: 0x" << std::hex << pdoIndex);
entryPos = 0;
BOOST_FOREACH(boost::property_tree::ptree::value_type const& pdoEntryList, deviceList.second) {
//cout << "Index " << pdoEntryList.second.get("Index") << std::endl;
if(pdoEntryList.first == "Entry") {
uint16_t entryIndex;
uint8_t entrySubindex;
uint8_t entryBitLength;
entryIndex = pdoEntryList.second.get("Index", u16Trans);
entrySubindex = pdoEntryList.second.get("SubIndex", u8Trans);
entryBitLength = pdoEntryList.second.get("BitLen", u8Trans);
std::string ioName = pdoEntryList.second.get("Name");
std::string ioDataTypeStr = pdoEntryList.second.get("DataType");
TECDataType ioDataType = TranslateDataType(ioDataTypeStr);
std::string ioRangeStr = pdoEntryList.second.get("DataType..DScale","");
double rangeHi, rangeLo;
TranslateRange(ioRangeStr, rangeLo, rangeHi);
LOG4CPLUS_DEBUG(Logger, "PDO Entry: PDO Index 0x" << std::hex << pdoIndex
<< " Entry Index: 0x" << std::hex << entryIndex
<< " Entry subindex: 0x" << std::hex << (int)entrySubindex
<< " entry bit length: " << (int)entryBitLength);
if (0 != ecrt_slave_config_pdo_mapping_add(slaveConfig, pdoIndex, entryIndex, entrySubindex, entryBitLength)) {
ret = false;
LOG4CPLUS_ERROR(Logger, "Error during ecrt_slave_config_pdo_mapping_add()");
}
// Now search for a domain in which this PDO entry belongs
std::vector::iterator dptr;
for (dptr = Domains.begin();dptr != Domains.end(); ++dptr) {
if (posCount >= (*dptr)->BeginSlave && posCount <= (*dptr)->EndSlave) {
IOPointRecord iop;
iop.BitSize = entryBitLength;
iop.IOType = ioPointType;
iop.Name = ioName;
iop.DataType = ioDataType;
iop.RangeHi = rangeHi;
iop.RangeLo = rangeLo;
//iop.DomainOffset = ecrt_slave_config_reg_pdo_entry(slaveConfig, entryIndex, entrySubindex, (*dptr)->Domain, &(iop.BitPosition));
iop.DomainOffset = ecrt_slave_config_reg_pdo_entry_pos(slaveConfig, smIndex, pdoPos, entryPos, (*dptr)->Domain, &(iop.BitPosition));
LOG4CPLUS_DEBUG(Logger, "DomainOffset = " << iop.DomainOffset
<< " sm idx " << (int)smIndex
<< " pdo pos " << pdoPos
<< " entry pos " << entryPos
<< " bit pos " << iop.BitPosition);
if (iop.DomainOffset < 0) {
LOG4CPLUS_ERROR(Logger, "Error obtaining domain PD offset for io point at slave position " << posCount);
} else {
(*dptr)->IOPoints.push_back(iop);
}
}
}
++entryPos;
}
}
++pdoPos;
}
}
++posCount;
}
}
}
}
return ret;
}