rllib  1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
rlCanNode Class Reference

class to manage one node of a CanOpenMaster board in a CanOpen network More...

#include <rlcannode.h>

Collaboration diagram for rlCanNode:
Collaboration graph
[legend]

Public Member Functions

 rlCanNode ()
 
 rlCanNode (int boardnr, int nodeid, RCS_MESSAGETELEGRAM_10 &_telegramm)
 initializes a new cannode by means of SyCon-pre-configurated parameters
 
 ~rlCanNode ()
 calls destructors of rlinifile obj and objdir
 
int objecttype (int objindex, int subindex)
 returns the type of a specific entry in the object directory
 
void showConfiguration ()
 prints out the configuration of the node
 
int getNodeID ()
 returns the current node ID of the node
 
int getBoardID ()
 returns the board ID the node is connected to.
 
int getPdoCount ()
 returns the current number of all installed PDOs (Process Data Objects)
 
int getReceivePdoCount ()
 returns the current number of all installed reiceive PDOs
 
int getTransmitPdoCount ()
 returns the current number of all installed transmit PDOs
 
bool hasMapping ()
 indicates if a node available mapping
 

Public Attributes

QPtrVector< rlCanPDOpdoList [2]
 contains transmit PDOs
 

Private Member Functions

rlIniFilegetEDS (const char *_productstr)
 finds the eds file matching the product string in [DeviceInfo] ProductName
 
void readConfigurationMessage (RCS_MESSAGETELEGRAM_10 &_message)
 reads out the configuration of a node from the CanOpenMaster board
 

Private Attributes

int nodeID
 current node ID (1-127)
 
int boardID
 curent board ID (0-3)
 
rlIniFileini
 
ObjDir * objdir
 
unsigned short usIdentNumber
 Unique device number if available.
 
unsigned char usVendorIdent
 Unique vendor number if available.
 
QString abVendorName
 specific node informations. extracted from message telegramm
 
QString abDeviceName
 
QString abDescription
 
QString edslocation
 
unsigned char pdocount
 
unsigned char bMasterAddress
 
unsigned char bSettings
 

Detailed Description

class to manage one node of a CanOpenMaster board in a CanOpen network

Definition at line 48 of file rlcannode.h.

Constructor & Destructor Documentation

rlCanNode::rlCanNode ( )

Definition at line 21 of file rlcannode.cpp.

{
rlDebugPrintf("\n Constructer clear");
}
rlCanNode::rlCanNode ( int  boardnr,
int  nodeid,
RCS_MESSAGETELEGRAM_10 &  _telegramm 
)

initializes a new cannode by means of SyCon-pre-configurated parameters

initializes a new node obj. node is defined by boardid, nodeid and a telegram which contains node specific information from device's dual ported memory

Definition at line 28 of file rlcannode.cpp.

{
nodeID = nodeid;
boardID = boardnr;
rlDebugPrintf("Initialising new node...\n BoardNr. %d NodeId %d Productstr %s ...",
boardnr, nodeid, abDeviceName.ascii());
if (ini!=0){
rlDebugPrintf(" SUCCESS! \n ");
rlDebugPrintf(" ProductName=%s \n ", ini->text("DeviceInfo","ProductName"));
rlDebugPrintf(" Filename=%s \n ", ini->text("FileInfo","FileName"));
rlDebugPrintf("Lege Objektverzeichnis an: ");
objdir = new ObjDir(ini);
}
else
{
rlDebugPrintf("ERROR!\n NO EDS FILE FOUND FOR \"%s\"!\n", abDeviceName.ascii());
objdir = 0;
}
if (objdir){
// observe the adress for pdo mapping in OV
unsigned int i,adr;
rlDebugPrintf(" PDO Gr�en:transmit PDOs: %d receive PDOs: %d\n",
for (i = 0; i< pdoList[DIRECTION_TRANSMIT].size();i++)
{
while(objdir->OVAdressExists(adr,0) == 0)
{
adr++;
adr=0;
rlDebugPrintf("ERROR IN EDS FILE: errorous number of Mapping entries\n");
break;
}
}
pdoList[DIRECTION_TRANSMIT][i]->mappingOvAdress = adr;
adr++;
}
for (i = 0; i< pdoList[DIRECTION_RECEIVE].size();i++)
{
while(objdir->OVAdressExists(adr,0) == 0)
{
adr++;
adr=0;
rlDebugPrintf("ERROR IN EDS FILE: errorous number of Mapping entries\n");
break;
}
}
pdoList[DIRECTION_RECEIVE][i]->mappingOvAdress = adr;
adr++;
}
}
}
rlCanNode::~rlCanNode ( )

calls destructors of rlinifile obj and objdir

Definition at line 97 of file rlcannode.cpp.

{
rlDebugPrintf("Destructor rlCanNode\n");
if (ini!=0){
delete ini;
}
if (objdir!=0){
delete objdir;
}
}

Member Function Documentation

int rlCanNode::getBoardID ( )

returns the board ID the node is connected to.

returns the board ID in witch the node is connected

Definition at line 245 of file rlcannode.cpp.

{
return boardID;
}
rlIniFile * rlCanNode::getEDS ( const char *  _productstr)
private

finds the eds file matching the product string in [DeviceInfo] ProductName

iterates through all files in eds directory. opens every eds file and returns a pointer to an ini-file object of the eds file matching the product string in [DeviceInfo] ProductName

Definition at line 109 of file rlcannode.cpp.

{
rlIniFile* _ini;
// get eds dir
QString dirname(getenv("EdsDir"));
if (dirname.isEmpty()){
dirname = "./";
}
QString productname(_productstr);
QDir edsdir(dirname);
edsdir.setNameFilter("*.EDS; *.eds");
QStringList::Iterator dirit;
QStringList dirlist;
dirlist = edsdir.entryList();
_ini = new rlIniFile();
for ( dirit = dirlist.begin(); dirit != dirlist.end(); ++dirit ) {
int searchval;
QString exportname;
edslocation = dirname + *dirit;
_ini->read(edslocation.ascii());
exportname =QString(_ini->text("DeviceInfo","ProductName"));
searchval = exportname.contains(productname, false);
if (searchval == 1){
return _ini;
}
}
delete _ini;
return 0;
}
int rlCanNode::getNodeID ( )

returns the current node ID of the node

Definition at line 239 of file rlcannode.cpp.

{
return nodeID;
}
int rlCanNode::getPdoCount ( )

returns the current number of all installed PDOs (Process Data Objects)

returns the current number of -all- installed PDOs (Process Data Objects)

Definition at line 280 of file rlcannode.cpp.

{
return pdocount;
}
int rlCanNode::getReceivePdoCount ( )

returns the current number of all installed reiceive PDOs

Definition at line 285 of file rlcannode.cpp.

{
return pdoList[DIRECTION_RECEIVE].size();
}
int rlCanNode::getTransmitPdoCount ( )

returns the current number of all installed transmit PDOs

Definition at line 290 of file rlcannode.cpp.

{
return pdoList[DIRECTION_TRANSMIT].size();
}
bool rlCanNode::hasMapping ( )

indicates if a node available mapping

indicates if node mapping is available. When mapping is active, it is possible to catch a specific Object within a PDO

Definition at line 295 of file rlcannode.cpp.

{
if (objdir==0) return false;
else return true;
}
int rlCanNode::objecttype ( int  objindex,
int  subindex 
)

returns the type of a specific entry in the object directory

Definition at line 250 of file rlcannode.cpp.

{
QString edsbuffer;
bool ok;
int typenr;
if (objdir != 0) {
edsbuffer = objdir->get_objparameter(ObjDir::DATATYPE, objindex, subindex);
}
else
{
}
if (edsbuffer == "ERROR"){
}
edsbuffer.remove("0x");
typenr = edsbuffer.toInt(&ok, 16);
if (!ok){
}
else
{
return typenr;
}
}
void rlCanNode::readConfigurationMessage ( RCS_MESSAGETELEGRAM_10 &  _message)
private

reads out the configuration of a node from the CanOpenMaster board

reads out the configuration of a node from the device. For success the device must configured by SYCon.

Definition at line 142 of file rlcannode.cpp.

{
int i;
usIdentNumber = (unsigned short) (_message.d[2]+_message.d[1]*pow(256,1));
usVendorIdent = (unsigned short) (_message.d[4]+_message.d[3]*pow(256,1));
for(i=0;i<32;i++)
{
abVendorName+=_message.d[5+i];
abDeviceName+=_message.d[37+i];
abDescription+=_message.d[69+i];
}
bMasterAddress = _message.d[101];
bSettings = _message.d[102];
pdocount = _message.d[117];
//transmit_pdoList.resize(pdocount);
int startadress=118; // start index of pdos in buffer
int k = 0;
int tpdocounter = 0;
int rpdocounter = 0;
for(i=1;i<=int(pdocount);i++)
{
rlCanPDO *tempPDO = new rlCanPDO;
tempPDO->bPDOSize = _message.d[startadress+k+1];
tempPDO->bDataPosition = _message.d[startadress+k+2];
tempPDO->usPDOAddress = (unsigned short)
(_message.d[startadress+k+3]*pow(256,0)
+ _message.d[startadress+k+4]);
if ((_message.d[startadress+k] & DATA_DIRECTION_MASK) == DIRECTION_INPUT)
{
rlDebugPrintf("\n tranceive pdo found ................\n");
tpdocounter++;
tempPDO->bPDODirection = DIRECTION_TRANSMIT; // => Tranceive PDO
pdoList[DIRECTION_TRANSMIT].insert(tpdocounter-1,tempPDO);
}
else if(
(_message.d[startadress+k] & DATA_DIRECTION_MASK) == DIRECTION_OUTPUT)
{
rlDebugPrintf("\n receive pdo found ................");
rpdocounter++;
tempPDO->bPDODirection = DIRECTION_RECEIVE; // => receive PDO
pdoList[DIRECTION_RECEIVE].insert(rpdocounter-1,tempPDO);
}
k=k+5;
}
}
void rlCanNode::showConfiguration ( )

prints out the configuration of the node

print out the configuration of the node

Definition at line 200 of file rlcannode.cpp.

{
cout<<"\n\n******** Configuration Board "
<<boardID<<" Node "<<nodeID <<" ********";
cout<<"\n IdentNumber :" << usIdentNumber;
cout<<"\n VendorIdent :" <<usVendorIdent;
cout<<"\n Vendor Name :"<<abVendorName;
cout<<"\n Device Name :"<<abDeviceName;
cout<<"\n Description :"<<abDescription;
cout<<"\n PDO count :"<<int(pdocount);
cout<<"\n Master Adress :"<<int(bMasterAddress);
cout<<"\n Settings :"<<int(bSettings);
cout<<"\n\n - - - - PDOs -> - - - - -";
unsigned int j;
for (j = 1;j<=pdoList[DIRECTION_TRANSMIT].size();j++)
{
cout<<"\n+ PDO No. "<<j;
cout<<"\nPDO Direction :Send PDO";
printf("\nPDO Size :%i",pdoList[DIRECTION_TRANSMIT][j-1]->bPDOSize);
printf("\nData Position :%i",pdoList[DIRECTION_TRANSMIT][j-1]->bDataPosition);
printf("\nPDO Adress :%i",pdoList[DIRECTION_TRANSMIT][j-1]->usPDOAddress);
}
for (j = 1;j<=pdoList[DIRECTION_RECEIVE].size();j++)
{
cout<<"\n+ PDO No. "<<j;
cout<<"\nPDO Direction :Receive PDO";
printf("\nPDO Size :%i",pdoList[DIRECTION_RECEIVE][j-1]->bPDOSize);
printf("\nData Position :%i",pdoList[DIRECTION_RECEIVE][j-1]->bDataPosition);
printf("\nPDO Adress :%i",pdoList[DIRECTION_RECEIVE][j-1]->usPDOAddress);
}
cout<<"\n **********************************************\n\n";
}

Member Data Documentation

QString rlCanNode::abDescription
private

Definition at line 129 of file rlcannode.h.

QString rlCanNode::abDeviceName
private

Definition at line 128 of file rlcannode.h.

QString rlCanNode::abVendorName
private

specific node informations. extracted from message telegramm

Definition at line 127 of file rlcannode.h.

unsigned char rlCanNode::bMasterAddress
private

Definition at line 132 of file rlcannode.h.

int rlCanNode::boardID
private

curent board ID (0-3)

Definition at line 101 of file rlcannode.h.

unsigned char rlCanNode::bSettings
private

Definition at line 133 of file rlcannode.h.

QString rlCanNode::edslocation
private

Definition at line 130 of file rlcannode.h.

rlIniFile* rlCanNode::ini
private

pointer to inifile. object which handles access to the EDS file describing the object directory of this node

Definition at line 110 of file rlcannode.h.

int rlCanNode::nodeID
private

current node ID (1-127)

Definition at line 98 of file rlcannode.h.

ObjDir* rlCanNode::objdir
private

pointer to objdir which handles access to all items in the object directory of this node

Definition at line 114 of file rlcannode.h.

unsigned char rlCanNode::pdocount
private

Definition at line 131 of file rlcannode.h.

QPtrVector<rlCanPDO> rlCanNode::pdoList[2]

contains transmit PDOs

contains receive PDOs

Definition at line 94 of file rlcannode.h.

unsigned short rlCanNode::usIdentNumber
private

Unique device number if available.

Definition at line 121 of file rlcannode.h.

unsigned char rlCanNode::usVendorIdent
private

Unique vendor number if available.

Definition at line 124 of file rlcannode.h.


The documentation for this class was generated from the following files: