26 YARP_LOG_COMPONENT(REMOTECONTROLBOARDREMAPPER,
"yarp.device.remotecontrolboardremapper")
30 void RemoteControlBoardRemapper::closeAllRemoteControlBoards()
32 for(
auto& m_remoteControlBoardDevice : m_remoteControlBoardDevices)
34 if( m_remoteControlBoardDevice )
36 m_remoteControlBoardDevice->close();
37 delete m_remoteControlBoardDevice;
38 m_remoteControlBoardDevice =
nullptr;
42 m_remoteControlBoardDevices.resize(0);
58 closeAllRemoteControlBoards();
68 std::string localPortPrefix;
69 std::vector<std::string> remoteControlBoardsPorts;
74 localPortPrefix = prop.
find(
"localPortPrefix").
asString();
78 yCError(REMOTECONTROLBOARDREMAPPER) <<
"Parsing parameters: \"localPortPrefix\" should be a string.";
83 if(remoteControlBoards==
nullptr)
85 yCError(REMOTECONTROLBOARDREMAPPER) <<
"Parsing parameters: \"remoteControlBoards\" should be followed by a list.";
89 remoteControlBoardsPorts.resize(remoteControlBoards->
size());
90 for(
size_t ax=0; ax < remoteControlBoards->
size(); ax++)
92 remoteControlBoardsPorts[ax] = remoteControlBoards->
get(ax).
asString();
98 Bottle & optionsGroupBot = prop.
findGroup(
"REMOTE_CONTROLBOARD_OPTIONS");
99 if( !(optionsGroupBot.
isNull()) )
106 m_remoteControlBoardDevices.resize(remoteControlBoardsPorts.size(),
nullptr);
110 for(
size_t ctrlBrd=0; ctrlBrd < remoteControlBoardsPorts.size(); ctrlBrd++ )
112 std::string remote = remoteControlBoardsPorts[ctrlBrd];
114 std::string local = localPortPrefix+remote;
116 Property options = remoteControlBoardsOptions;
117 options.
put(
"device",
"remote_controlboard");
118 options.
put(
"local", local);
119 options.
put(
"remote", remote);
121 m_remoteControlBoardDevices[ctrlBrd] =
new PolyDriver();
123 bool ok = m_remoteControlBoardDevices[ctrlBrd]->open(options);
125 if( !ok || !(m_remoteControlBoardDevices[ctrlBrd]->
isValid()) )
127 yCError(REMOTECONTROLBOARDREMAPPER) <<
"Opening remote_controlboard with remote \"" << remote <<
"\", opening the device failed.";
128 closeAllRemoteControlBoards();
133 remoteControlBoardsList.
push((m_remoteControlBoardDevices[ctrlBrd]),remote.c_str());
141 yCError(REMOTECONTROLBOARDREMAPPER) <<
"Opening the controlboardremapper device, opening the device failed.";
143 closeAllRemoteControlBoards();
152 yCError(REMOTECONTROLBOARDREMAPPER) <<
"Calling attachAll in the controlboardremapper device, opening the device failed.";
154 closeAllRemoteControlBoards();