OpcUaCanOpen
CANopen OPC-UA server
CanBusAccess.cpp
Go to the documentation of this file.
1 
2 #include "CanBusAccess.h"
3 
5 {
6  ScanManagers.erase(cInter->getBusName());
7  delete cInter;
8 }
9 
10 CCanAccess* CanBusAccess::openCanBus(string name,string parameters)
11 {
12  map<string,dlcanbus *>::iterator itcomponent;
13  map<string,CCanAccess *>::iterator it;
14  dlcanbus *dlcan;
15 
16  string nameComponent,nameOfCh;
17 
18  it = ScanManagers.find(name);
19  if (! ( it == ScanManagers.end() ) ) {
20  return (*it).second;
21  }
22 
23  nameComponent = name.substr(0,name.find_first_of(':'));
24 
25  itcomponent = Component.find(nameComponent);
26 
27  if (! (itcomponent == Component.end() )) {
28  dlcan = (*itcomponent).second;
29  }
30  else {
31  dlcan = new CanLibComponenet((char *)nameComponent.c_str());
32  if (dlcan->openInterface())
33  Component.insert(map<string,dlcanbus *>::value_type(nameComponent,dlcan));
34  else return 0;
35  }
36 
37  CCanAccess *tcca = dlcan->maker_CanAccessObj();
38  if (tcca != NULL) {
39  const char * pa = parameters.c_str();
40  bool c = tcca->createBUS( name.c_str(), pa);
41  if (c) {
42  tcca->setBusName(name);
44  return tcca;
45  }
46  }
47  return 0;
48 }