Ejemplo n.º 1
0
//---------------------------------------------------------------------------
//! reads out the configuration of a node from the CanOpenMaster board
void rlCanNode::readConfigurationMessage(RCS_MESSAGETELEGRAM_10& _message)
{
   
  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].resize(pdoList[DIRECTION_TRANSMIT].size()+1);
     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].resize(pdoList[DIRECTION_RECEIVE].size()+1);
      pdoList[DIRECTION_RECEIVE].insert(rpdocounter-1,tempPDO);
   } 
   k=k+5;
  } 

}                                                                 
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
//! calls destructors of rlinifile obj and objdir 
rlCanNode::~rlCanNode(){
  rlDebugPrintf("Destructor rlCanNode\n");
  if (ini!=0){
    delete ini;
  }
  if (objdir!=0){
    delete objdir;
  }
}
Ejemplo n.º 3
0
//! produce an invalid-type-warning to stdout. used by nearly all getter functions
void  rlCanOpenTypes::invalidTypeError(int _typenr){
  char* curTypeStr; 
  char* usrTypeStr;
  curTypeStr = type2str(typenumber);
  usrTypeStr = type2str(_typenr);
  rlDebugPrintf("Warning! %s invalid type! current data type is: %s \n"
         , usrTypeStr, curTypeStr);
  delete curTypeStr;
  delete usrTypeStr;
}
Ejemplo n.º 4
0
//! main constructor builds object directory.
ObjDir::ObjDir(rlIniFile* _ini){
  itemcount=0;
  ini= _ini;
  objstorage.setAutoDelete(true);
  int mobj = atoi(_ini->text("MandatoryObjects","SupportedObjects"));
  int obobj = atoi(_ini->text("OptionalObjects","SupportedObjects"));
  
  // calculate sum off all objects and subobjects in EDS FILE
  int sumobj = 
     countobj("MandatoryObjects", mobj) + countobj("OptionalObjects", obobj);
     
  objstorage.resize(sumobj);
  // extrakt all objects and subobjects from EDS file into objstorage
  extraktobj("MandatoryObjects", mobj);
  extraktobj("OptionalObjects", obobj);
  rlDebugPrintf("  calculated count obj: %d\n", sumobj);
}
Ejemplo n.º 5
0
//! prints error message to StdOut
void rlCanOpenTypes::rlMsgErrOut(){
  char* errOut = rlMsgErrStr();
  rlDebugPrintf("ERROR: \"%s\" \n", errOut);
  delete errOut;
}
Ejemplo n.º 6
0
//---------------------------------------------------------------------------
//! initializes a new cannode by means of SyCon-pre-configurated parameters
rlCanNode::rlCanNode
           (int boardnr, int nodeid, RCS_MESSAGETELEGRAM_10& _telegramm){
  nodeID = nodeid;
  boardID = boardnr;
  readConfigurationMessage(_telegramm);    
  rlDebugPrintf("Initialising new node...\n BoardNr. %d NodeId %d Productstr %s ...",
    boardnr, nodeid, abDeviceName.ascii());
    
  ini = getEDS(abDeviceName);

  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;
    adr = TRANSMIT_PDO_MAPPING_STARTADRESS;
    
    rlDebugPrintf(" PDO Gr�en:transmit PDOs: %d     receive PDOs: %d\n",
             pdoList[DIRECTION_TRANSMIT].size(),pdoList[DIRECTION_RECEIVE].size());
             
    for (i = 0; i< pdoList[DIRECTION_TRANSMIT].size();i++)
    {
      while(objdir->OVAdressExists(adr,0) == 0)
      {
        adr++;
        
        if (adr>TRANSMIT_PDO_MAPPING_MAXADRESS) {
          adr=0;
          rlDebugPrintf("ERROR IN EDS FILE: errorous number of Mapping entries\n");
          break;
        }
      }
      pdoList[DIRECTION_TRANSMIT][i]->mappingOvAdress = adr;
    
      adr++;
    }
    
    adr = RECEIVE_PDO_MAPPING_STARTADRESS ;
    for (i = 0; i< pdoList[DIRECTION_RECEIVE].size();i++)
    {
      while(objdir->OVAdressExists(adr,0) == 0)
      {
        adr++;
        
        if (adr>RECEIVE_PDO_MAPPING_MAXADRESS) {
          adr=0;
          rlDebugPrintf("ERROR IN EDS FILE: errorous number of Mapping entries\n");
          break;
        }
      }
      pdoList[DIRECTION_RECEIVE][i]->mappingOvAdress = adr;
      adr++;
    
    }
  }
                  
}   
Ejemplo n.º 7
0
//---------------------------------------------------------------------------
rlCanNode::rlCanNode()
{
  rlDebugPrintf("\n Constructer clear");
}
Ejemplo n.º 8
0
//! destructor has nothing to do. QPtrVector Destructor performs memory cleanup
ObjDir::~ObjDir(){
  rlDebugPrintf("ObjDir destructor\n");
}
Ejemplo n.º 9
0
//! empty constructor not yet implemented
ObjDir::ObjDir(){
  rlDebugPrintf("YOUR OBJDIR CTOR CODE!!!\n");
  objstorage.setAutoDelete(true);
}