IEventSink * MSPKinectARTTransformation::getEventSink(const std::string & name) { map<string, IEventSink *>::iterator iter = this->eventSinkMap.find(name); if (iter != this->eventSinkMap.end()) { return (*iter).second; } TFERROR(""); return 0; }
void MSPKinectARTTransformation::registerEventSink(const std::string & name, IEventSink * eventSink) { map<string, IEventSink *>::iterator iter = this->registeredEventSinkMap.find(name); if (iter != this->registeredEventSinkMap.end()) { (*iter).second = eventSink; } else { TFERROR(""); // TODO exception } }
AnalogToDigitalMSP::AnalogToDigitalMSP(const MSPConfig & config) : config(config), out(0) { this->eventDelegate.setReceiver(this, &AnalogToDigitalMSP::handleEvent); try { this->threshold = static_cast<float>(config.getParameterGroup().getDouble("Convert|Threshold")); TFDEBUG("Threshold = " << this->threshold); } catch(Exception & e) { TFERROR(e.getFormattedString()); } }
DigitalToAnalogMSP::DigitalToAnalogMSP(const MSPConfig & config) : config(config), out(0) { this->eventDelegate.setReceiver(this, &DigitalToAnalogMSP::handleEvent); try { this->value0 = config.getParameterGroup().getDouble("Convert|Value_0"); this->value1 = config.getParameterGroup().getDouble("Convert|Value_1"); TFDEBUG("Value_0 = " << this->value0); TFDEBUG("Value_1 = " << this->value1); } catch(Exception & e) { TFERROR(e.getFormattedString()); } }
void TUIServerApp::createEntityGraph(const map<string, TUIObjectInstance> & tuiObjectInstanceMap, const vector<Connector> & connectorVector) { try { vector<Connector>::const_iterator i = connectorVector.begin(); vector<Connector>::const_iterator e = connectorVector.end(); while (i != e) { TFINFO("Connector: " << "(from: " << (*i).getSrcAddress().getOwnerType() << " " << (*i).getSrcAddress().getName() << " " << (*i).getSrcAddress().getPortName() << ") " << "(to: " << (*i).getDstAddress().getOwnerType() << " " << (*i).getDstAddress().getName() << " " << (*i).getDstAddress().getPortName() << ") "); IEventSink * sink; switch ((*i).getDstAddress().getOwnerType()) { case PortAddress::DEVICE: { int dstDeviceID = this->deviceContainer.getEntityIDByName( (*i).getDstAddress().getName()); int dstChannelNr = this->deviceContainer.getChannelIDByName( dstDeviceID, (*i).getDstAddress().getPortName()); std::map<int, IEventSink *>::iterator iter = this->eventSinkMap.find(dstDeviceID); if (iter == this->eventSinkMap.end()) { throw Exception(TFSTR(""), __FILE__, __LINE__); // TODO Throw Exception TFERROR(""); } // int eID = -1, int chNr = -1, IEventSink * eventSink = 0 EPAddressTranslator * at = new EPAddressTranslator( dstDeviceID, dstChannelNr, (*iter).second); this->addressTranslatorVector.push_back(at); sink = at; break; } case PortAddress::MSP: { sink = this->mspContainer.getEventSink( (*i).getDstAddress().getName(), (*i).getDstAddress().getPortName()); break; } case PortAddress::TUIOBJECT: { std::map<std::string, TUIObjectInstance>::const_iterator iter = tuiObjectInstanceMap.find((*i).getDstAddress().getName()); if (iter == tuiObjectInstanceMap.end()) { // TODO throw Exception TFERROR(""); } int tuiObjectID = (*iter).second.getID(); //TFDEBUG("Searching port: " << (*i).getDstAddress().getPortName()); map<string, int>::const_iterator iter2 = (*iter).second.getNameChannelNrMap().find( (*i).getDstAddress().getPortName()); if (iter2 == (*iter).second.getNameChannelNrMap().end()) { // TODO throw Exception TFERROR("Size: " << (*iter).second.getNameChannelNrMap().size()); } int tuiChannelNr = (*iter2).second; IEventSink * es; if (this->usingMulticast) { es = &this->mcEventQueue; } else { es = &this->outEventQueue; } EPAddressTranslator * at = new EPAddressTranslator( tuiObjectID, tuiChannelNr, es); this->addressTranslatorVector.push_back(at); sink = at; break; } default: { // TODO Throw Exception TFERROR(""); break; } } switch ((*i).getSrcAddress().getOwnerType()) { case PortAddress::DEVICE: { int srcDeviceID = this->deviceContainer.getEntityIDByName( (*i).getSrcAddress().getName()); int srcChannelNr = this->deviceContainer.getChannelIDByName( srcDeviceID, (*i).getSrcAddress().getPortName()); std::map<int, EventMsgRouter<EPAddress, IEventSink, EPAddress::CompareByChannelNr> *>::iterator iter = this->deviceChannelRouterMap.find(srcDeviceID); if (iter == this->deviceChannelRouterMap.end()) { // TODO Throw Exception TFERROR(""); } (*iter).second->addRoutingTableEntry(EPAddress(-1, srcChannelNr), sink); break; } case PortAddress::MSP: { this->mspContainer.registerEventSink((*i).getSrcAddress().getName(), (*i).getSrcAddress().getPortName(), sink); break; } case PortAddress::TUIOBJECT: { std::map<std::string, TUIObjectInstance>::const_iterator iter = tuiObjectInstanceMap.find((*i).getSrcAddress().getName()); if (iter == tuiObjectInstanceMap.end()) { // TODO throw Exception TFERROR(""); } int tuiObjectID = (*iter).second.getID(); map<string, int>::const_iterator iter2 = (*iter).second.getNameChannelNrMap().find( (*i).getSrcAddress().getPortName()); if (iter2 == (*iter).second.getNameChannelNrMap().end()) { // TODO throw Exception TFERROR(""); } int tuiChannelNr = (*iter2).second; std::map<int, EventMsgRouter<EPAddress, IEventSink, EPAddress::CompareByChannelNr> *>::iterator iter3 = this->tuiChannelRouterMap.find(tuiObjectID); if (iter3 == this->tuiChannelRouterMap.end()) { // TODO Throw Exception TFERROR(""); } (*iter3).second->addRoutingTableEntry(EPAddress(-1, tuiChannelNr), sink); break; } default: { // TODO Throw Exception TFERROR(""); break; } } ++i; } } catch (Exception & e) { TFERROR(e.getFormattedString()); //this->tuiServerExit(); } }