xdl_int XdevLBluetoothMacOSXImpl::readInfoFromXMLFile() { if(getMediator()->getXmlFilename() == NULL) return ERR_ERROR; TiXmlDocument xmlDocument; if(!xmlDocument.LoadFile(getMediator()->getXmlFilename())) { XDEVL_MODULE_ERROR("Could not parse xml file: " << getMediator()->getXmlFilename() << std::endl); return ERR_ERROR; } TiXmlHandle docHandle(&xmlDocument); TiXmlElement* root = docHandle.FirstChild(XdevLCorePropertiesName.c_str()).FirstChildElement("XdevLBluetooth").ToElement(); if (!root) { XDEVL_MODULE_WARNING("<XdevLBluetooth> section not found. Using default values for the device.\n"); return ERR_OK; } while(root != NULL) { if(root->Attribute("id")) { XdevLID id(root->Attribute("id")); if(getID() == id) { if (root->Attribute("device")) { m_deviceName = root->Attribute("device"); } } root = root->NextSiblingElement(); } else XDEVL_MODULE_ERROR("No 'id' attribute specified. Using default values for the device\n"); } return ERR_OK; }
void XdevLJoystickServerMac::sendButtonEvent(const XdevLJoystickId& joystickid, xdl_int buttonID, xdl_bool pressed) { XdevLEvent ev; ev.common.timestamp = getMediator()->getTimer().getTime64(); ev.type = pressed ? JoystickButtonPressed.getHashCode() : JoystickButtonReleased.getHashCode(); ev.jbutton.joystickid = wrapJoystickIdToInteger(joystickid); ev.jbutton.buttonid = buttonID; getMediator()->fireEvent(ev); }
void XdevLJoystickServerMac::sendAxisEvent(const XdevLJoystickId& joystickid, xdl_uint8 axisID, xdl::xdl_int16 value) { XdevLEvent ev; ev.common.timestamp = getMediator()->getTimer().getTime64(); ev.type = JoystickMotion.getHashCode(); ev.jbutton.joystickid = wrapJoystickIdToInteger(joystickid); ev.jaxis.axisid = axisID; ev.jaxis.value = (xdl_int32)value; getMediator()->fireEvent(ev); }
xdl_int XdevLCudaImpl::init() { TiXmlDocument xmlDocument; if (!xmlDocument.LoadFile(getMediator()->getXmlFilename())) { XDEVL_MODULE_ERROR("Could not parse xml file: " << getMediator()->getXmlFilename() << std::endl); return ERR_ERROR; } if (readModuleInformation(&xmlDocument) != ERR_OK) return ERR_ERROR; cudaGetDevice(&m_devID); cudaGetDeviceProperties(&m_prop, m_devID); return ERR_OK; }
xdl_int XdevLFTDI::readInfoFromXMLFile() { if(getMediator()->getXmlFilename() == nullptr) return RET_FAILED; TiXmlDocument xmlDocument; if(!xmlDocument.LoadFile(getMediator()->getXmlFilename())) { XDEVL_MODULE_ERROR("Could not parse xml file: " << getMediator()->getXmlFilename() << std::endl); return RET_FAILED; } TiXmlHandle docHandle(&xmlDocument); TiXmlElement* root = docHandle.FirstChild(XdevLCorePropertiesName.c_str()).FirstChildElement("XdevLSerial").ToElement(); if(!root) { XDEVL_MODULE_WARNING("<XdevLSerial> section not found. Using default values for the device.\n"); return RET_SUCCESS; } while(root != nullptr) { if(root->Attribute("id")) { XdevLID id(root->Attribute("id")); if(getID() == id) { if(root->Attribute("device")) { m_deviceName = XdevLString(root->Attribute("device")); } if(root->Attribute("usb_in_size")) { std::istringstream ss(root->Attribute("usb_in_size")); ss >> m_usbInSize; } if(root->Attribute("usb_out_size")) { std::istringstream ss(root->Attribute("usb_out_size")); ss >> m_usbOutSize; } if(root->Attribute("latency_timer")) { std::istringstream ss(root->Attribute("latency_timer")); ss >> m_latencyTimer; }
void ConcreteColleagueA::someOperation() { //在需要跟其他同事通信的时候,通知中介者对象 getMediator()->changed(this); }