rllib  1
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 More...
 
 ~rlCanNode ()
 calls destructors of rlinifile obj and objdir More...
 
int objecttype (int objindex, int subindex)
 returns the type of a specific entry in the object directory More...
 
void showConfiguration ()
 prints out the configuration of the node More...
 
int getNodeID ()
 returns the current node ID of the node More...
 
int getBoardID ()
 returns the board ID the node is connected to. More...
 
int getPdoCount ()
 returns the current number of all installed PDOs (Process Data Objects) More...
 
int getReceivePdoCount ()
 returns the current number of all installed reiceive PDOs More...
 
int getTransmitPdoCount ()
 returns the current number of all installed transmit PDOs More...
 
bool hasMapping ()
 indicates if a node available mapping More...
 

Public Attributes

QPtrVector< rlCanPDOpdoList [2]
 contains transmit PDOs More...
 

Private Member Functions

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

Private Attributes

int nodeID
 current node ID (1-127) More...
 
int boardID
 curent board ID (0-3) More...
 
rlIniFileini
 
ObjDir * objdir
 
unsigned short usIdentNumber
 Unique device number if available. More...
 
unsigned char usVendorIdent
 Unique vendor number if available. More...
 
QString abVendorName
 specific node informations. extracted from message telegramm More...
 
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() [1/2]

rlCanNode::rlCanNode ( )

Definition at line 21 of file rlcannode.cpp.

22 {
23  rlDebugPrintf("\n Constructer clear");
24 }
int rlDebugPrintf(const char *format,...)
Definition: rlcutil.cpp:61

◆ rlCanNode() [2/2]

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.

28  {
29  nodeID = nodeid;
30  boardID = boardnr;
31  readConfigurationMessage(_telegramm);
32  rlDebugPrintf("Initialising new node...\n BoardNr. %d NodeId %d Productstr %s ...",
33  boardnr, nodeid, abDeviceName.ascii());
34 
36 
37  if (ini!=0){
38  rlDebugPrintf(" SUCCESS! \n ");
39  rlDebugPrintf(" ProductName=%s \n ", ini->text("DeviceInfo","ProductName"));
40  rlDebugPrintf(" Filename=%s \n ", ini->text("FileInfo","FileName"));
41  rlDebugPrintf("Lege Objektverzeichnis an: ");
42  objdir = new ObjDir(ini);
43  }
44  else
45  {
46  rlDebugPrintf("ERROR!\n NO EDS FILE FOUND FOR \"%s\"!\n", abDeviceName.ascii());
47  objdir = 0;
48  }
49 
50  if (objdir){
51  // observe the adress for pdo mapping in OV
52  unsigned int i,adr;
54 
55  rlDebugPrintf(" PDO Gr�en:transmit PDOs: %d receive PDOs: %d\n",
57 
58  for (i = 0; i< pdoList[DIRECTION_TRANSMIT].size();i++)
59  {
60  while(objdir->OVAdressExists(adr,0) == 0)
61  {
62  adr++;
63 
65  adr=0;
66  rlDebugPrintf("ERROR IN EDS FILE: errorous number of Mapping entries\n");
67  break;
68  }
69  }
70  pdoList[DIRECTION_TRANSMIT][i]->mappingOvAdress = adr;
71 
72  adr++;
73  }
74 
76  for (i = 0; i< pdoList[DIRECTION_RECEIVE].size();i++)
77  {
78  while(objdir->OVAdressExists(adr,0) == 0)
79  {
80  adr++;
81 
83  adr=0;
84  rlDebugPrintf("ERROR IN EDS FILE: errorous number of Mapping entries\n");
85  break;
86  }
87  }
88  pdoList[DIRECTION_RECEIVE][i]->mappingOvAdress = adr;
89  adr++;
90 
91  }
92  }
93 
94 }
int rlDebugPrintf(const char *format,...)
Definition: rlcutil.cpp:61
#define DIRECTION_RECEIVE
definition of CanOpen structs for CanOpen Deamon
QString abDeviceName
Definition: rlcannode.h:128
int nodeID
current node ID (1-127)
Definition: rlcannode.h:98
#define TRANSMIT_PDO_MAPPING_MAXADRESS
const char * text(const char *section, const char *name)
Definition: rlinifile.cpp:208
#define DIRECTION_TRANSMIT
#define TRANSMIT_PDO_MAPPING_STARTADRESS
QPtrVector< rlCanPDO > pdoList[2]
contains transmit PDOs
Definition: rlcannode.h:94
ObjDir * objdir
Definition: rlcannode.h:114
int boardID
curent board ID (0-3)
Definition: rlcannode.h:101
rlIniFile * ini
Definition: rlcannode.h:110
#define RECEIVE_PDO_MAPPING_MAXADRESS
rlIniFile * getEDS(const char *_productstr)
finds the eds file matching the product string in [DeviceInfo] ProductName
Definition: rlcannode.cpp:109
void readConfigurationMessage(RCS_MESSAGETELEGRAM_10 &_message)
reads out the configuration of a node from the CanOpenMaster board
Definition: rlcannode.cpp:142
#define RECEIVE_PDO_MAPPING_STARTADRESS

◆ ~rlCanNode()

rlCanNode::~rlCanNode ( )

calls destructors of rlinifile obj and objdir

Definition at line 97 of file rlcannode.cpp.

97  {
98  rlDebugPrintf("Destructor rlCanNode\n");
99  if (ini!=0){
100  delete ini;
101  }
102  if (objdir!=0){
103  delete objdir;
104  }
105 }
int rlDebugPrintf(const char *format,...)
Definition: rlcutil.cpp:61
ObjDir * objdir
Definition: rlcannode.h:114
rlIniFile * ini
Definition: rlcannode.h:110

Member Function Documentation

◆ getBoardID()

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.

246 {
247  return boardID;
248 }
int boardID
curent board ID (0-3)
Definition: rlcannode.h:101

◆ getEDS()

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.

109  {
110  rlIniFile* _ini;
111  // get eds dir
112  QString dirname(getenv("EdsDir"));
113  if (dirname.isEmpty()){
114  dirname = "./";
115  }
116  QString productname(_productstr);
117  QDir edsdir(dirname);
118  edsdir.setNameFilter("*.EDS; *.eds");
119  QStringList::Iterator dirit;
120  QStringList dirlist;
121  dirlist = edsdir.entryList();
122  _ini = new rlIniFile();
123  for ( dirit = dirlist.begin(); dirit != dirlist.end(); ++dirit ) {
124  int searchval;
125 
126  QString exportname;
127 
128  edslocation = dirname + *dirit;
129  _ini->read(edslocation.ascii());
130  exportname =QString(_ini->text("DeviceInfo","ProductName"));
131  searchval = exportname.contains(productname, false);
132  if (searchval == 1){
133  return _ini;
134  }
135  }
136  delete _ini;
137  return 0;
138 }
const char * text(const char *section, const char *name)
Definition: rlinifile.cpp:208
int read(const char *filename)
Definition: rlinifile.cpp:116
QString edslocation
Definition: rlcannode.h:130

◆ getNodeID()

int rlCanNode::getNodeID ( )

returns the current node ID of the node

Definition at line 239 of file rlcannode.cpp.

240 {
241  return nodeID;
242 }
int nodeID
current node ID (1-127)
Definition: rlcannode.h:98

◆ getPdoCount()

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.

281 {
282  return pdocount;
283 }
unsigned char pdocount
Definition: rlcannode.h:131

◆ getReceivePdoCount()

int rlCanNode::getReceivePdoCount ( )

returns the current number of all installed reiceive PDOs

Definition at line 285 of file rlcannode.cpp.

286 {
287  return pdoList[DIRECTION_RECEIVE].size();
288 }
#define DIRECTION_RECEIVE
definition of CanOpen structs for CanOpen Deamon
QPtrVector< rlCanPDO > pdoList[2]
contains transmit PDOs
Definition: rlcannode.h:94

◆ getTransmitPdoCount()

int rlCanNode::getTransmitPdoCount ( )

returns the current number of all installed transmit PDOs

Definition at line 290 of file rlcannode.cpp.

291 {
292  return pdoList[DIRECTION_TRANSMIT].size();
293 }
#define DIRECTION_TRANSMIT
QPtrVector< rlCanPDO > pdoList[2]
contains transmit PDOs
Definition: rlcannode.h:94

◆ hasMapping()

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.

295  {
296  if (objdir==0) return false;
297  else return true;
298 }
ObjDir * objdir
Definition: rlcannode.h:114

◆ objecttype()

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.

251 {
252  QString edsbuffer;
253  bool ok;
254  int typenr;
255  if (objdir != 0) {
256  edsbuffer = objdir->get_objparameter(ObjDir::DATATYPE, objindex, subindex);
257  }
258  else
259  {
261  }
262 
263  if (edsbuffer == "ERROR"){
265  }
266  edsbuffer.remove("0x");
267  typenr = edsbuffer.toInt(&ok, 16);
268  if (!ok){
270  }
271  else
272  {
273  return typenr;
274 
275  }
276 }
ObjDir * objdir
Definition: rlcannode.h:114

◆ readConfigurationMessage()

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.

143 {
144 
145  int i;
146 
147  usIdentNumber = (unsigned short) (_message.d[2]+_message.d[1]*pow(256,1));
148  usVendorIdent = (unsigned short) (_message.d[4]+_message.d[3]*pow(256,1));
149 
150  for(i=0;i<32;i++)
151  {
152  abVendorName+=_message.d[5+i];
153  abDeviceName+=_message.d[37+i];
154  abDescription+=_message.d[69+i];
155  }
156 
157  bMasterAddress = _message.d[101];
158  bSettings = _message.d[102];
159  pdocount = _message.d[117];
160 
161  //transmit_pdoList.resize(pdocount);
162 
163  int startadress=118; // start index of pdos in buffer
164  int k = 0;
165  int tpdocounter = 0;
166  int rpdocounter = 0;
167 
168  for(i=1;i<=int(pdocount);i++)
169  {
170  rlCanPDO *tempPDO = new rlCanPDO;
171  tempPDO->bPDOSize = _message.d[startadress+k+1];
172  tempPDO->bDataPosition = _message.d[startadress+k+2];
173  tempPDO->usPDOAddress = (unsigned short)
174  (_message.d[startadress+k+3]*pow(256,0)
175  + _message.d[startadress+k+4]);
176 
177  if ((_message.d[startadress+k] & DATA_DIRECTION_MASK) == DIRECTION_INPUT)
178  {
179  rlDebugPrintf("\n tranceive pdo found ................\n");
180  tpdocounter++;
181  tempPDO->bPDODirection = DIRECTION_TRANSMIT; // => Tranceive PDO
183  pdoList[DIRECTION_TRANSMIT].insert(tpdocounter-1,tempPDO);
184  }
185  else if(
186  (_message.d[startadress+k] & DATA_DIRECTION_MASK) == DIRECTION_OUTPUT)
187  {
188  rlDebugPrintf("\n receive pdo found ................");
189  rpdocounter++;
190  tempPDO->bPDODirection = DIRECTION_RECEIVE; // => receive PDO
192  pdoList[DIRECTION_RECEIVE].insert(rpdocounter-1,tempPDO);
193  }
194  k=k+5;
195  }
196 
197 }
int rlDebugPrintf(const char *format,...)
Definition: rlcutil.cpp:61
#define DIRECTION_RECEIVE
definition of CanOpen structs for CanOpen Deamon
QString abDeviceName
Definition: rlcannode.h:128
#define DIRECTION_OUTPUT
#define DATA_DIRECTION_MASK
unsigned short usPDOAddress
fixes the PDO position in the card memory
#define DIRECTION_TRANSMIT
unsigned char pdocount
Definition: rlcannode.h:131
unsigned char bSettings
Definition: rlcannode.h:133
unsigned char usVendorIdent
Unique vendor number if available.
Definition: rlcannode.h:124
short bPDODirection
1 = receive PDO / 2 = send PDO [indicate by PDO No]
QPtrVector< rlCanPDO > pdoList[2]
contains transmit PDOs
Definition: rlcannode.h:94
unsigned char bPDOSize
size of a PDO / max 8 Bytes
unsigned char bDataPosition
if only one bit is set in a PDO, this value shows its position
#define DIRECTION_INPUT
QString abVendorName
specific node informations. extracted from message telegramm
Definition: rlcannode.h:127
unsigned char bMasterAddress
Definition: rlcannode.h:132
unsigned short usIdentNumber
Unique device number if available.
Definition: rlcannode.h:121
PDO object which is part of one of the two pdo lists in the node class.
QString abDescription
Definition: rlcannode.h:129

◆ showConfiguration()

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.

201 {
202  cout<<"\n\n******** Configuration Board "
203  <<boardID<<" Node "<<nodeID <<" ********";
204 
205  cout<<"\n IdentNumber :" << usIdentNumber;
206  cout<<"\n VendorIdent :" <<usVendorIdent;
207  cout<<"\n Vendor Name :"<<abVendorName;
208  cout<<"\n Device Name :"<<abDeviceName;
209  cout<<"\n Description :"<<abDescription;
210  cout<<"\n PDO count :"<<int(pdocount);
211  cout<<"\n Master Adress :"<<int(bMasterAddress);
212  cout<<"\n Settings :"<<int(bSettings);
213 
214  cout<<"\n\n - - - - PDOs -> - - - - -";
215  unsigned int j;
216  for (j = 1;j<=pdoList[DIRECTION_TRANSMIT].size();j++)
217  {
218  cout<<"\n+ PDO No. "<<j;
219  cout<<"\nPDO Direction :Send PDO";
220  printf("\nPDO Size :%i",pdoList[DIRECTION_TRANSMIT][j-1]->bPDOSize);
221  printf("\nData Position :%i",pdoList[DIRECTION_TRANSMIT][j-1]->bDataPosition);
222  printf("\nPDO Adress :%i",pdoList[DIRECTION_TRANSMIT][j-1]->usPDOAddress);
223  }
224 
225  for (j = 1;j<=pdoList[DIRECTION_RECEIVE].size();j++)
226  {
227  cout<<"\n+ PDO No. "<<j;
228  cout<<"\nPDO Direction :Receive PDO";
229  printf("\nPDO Size :%i",pdoList[DIRECTION_RECEIVE][j-1]->bPDOSize);
230  printf("\nData Position :%i",pdoList[DIRECTION_RECEIVE][j-1]->bDataPosition);
231  printf("\nPDO Adress :%i",pdoList[DIRECTION_RECEIVE][j-1]->usPDOAddress);
232  }
233 
234  cout<<"\n **********************************************\n\n";
235 }
#define DIRECTION_RECEIVE
definition of CanOpen structs for CanOpen Deamon
QString abDeviceName
Definition: rlcannode.h:128
int nodeID
current node ID (1-127)
Definition: rlcannode.h:98
#define DIRECTION_TRANSMIT
unsigned char pdocount
Definition: rlcannode.h:131
unsigned char bSettings
Definition: rlcannode.h:133
unsigned char usVendorIdent
Unique vendor number if available.
Definition: rlcannode.h:124
QPtrVector< rlCanPDO > pdoList[2]
contains transmit PDOs
Definition: rlcannode.h:94
int boardID
curent board ID (0-3)
Definition: rlcannode.h:101
QString abVendorName
specific node informations. extracted from message telegramm
Definition: rlcannode.h:127
unsigned char bMasterAddress
Definition: rlcannode.h:132
unsigned short usIdentNumber
Unique device number if available.
Definition: rlcannode.h:121
QString abDescription
Definition: rlcannode.h:129

Member Data Documentation

◆ abDescription

QString rlCanNode::abDescription
private

Definition at line 129 of file rlcannode.h.

◆ abDeviceName

QString rlCanNode::abDeviceName
private

Definition at line 128 of file rlcannode.h.

◆ abVendorName

QString rlCanNode::abVendorName
private

specific node informations. extracted from message telegramm

Definition at line 127 of file rlcannode.h.

◆ bMasterAddress

unsigned char rlCanNode::bMasterAddress
private

Definition at line 132 of file rlcannode.h.

◆ boardID

int rlCanNode::boardID
private

curent board ID (0-3)

Definition at line 101 of file rlcannode.h.

◆ bSettings

unsigned char rlCanNode::bSettings
private

Definition at line 133 of file rlcannode.h.

◆ edslocation

QString rlCanNode::edslocation
private

Definition at line 130 of file rlcannode.h.

◆ ini

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.

◆ nodeID

int rlCanNode::nodeID
private

current node ID (1-127)

Definition at line 98 of file rlcannode.h.

◆ objdir

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.

◆ pdocount

unsigned char rlCanNode::pdocount
private

Definition at line 131 of file rlcannode.h.

◆ pdoList

QPtrVector<rlCanPDO> rlCanNode::pdoList[2]

contains transmit PDOs

contains receive PDOs

Definition at line 94 of file rlcannode.h.

◆ usIdentNumber

unsigned short rlCanNode::usIdentNumber
private

Unique device number if available.

Definition at line 121 of file rlcannode.h.

◆ usVendorIdent

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: