void createGNSSSensor(Poco::SharedPtr<Poco::Serial::SerialPort> pSerialPort) { typedef Poco::RemotingNG::ServerHelper<IoT::Devices::GNSSSensor> ServerHelper; Poco::SharedPtr<GNSSSensorImpl> pGNSSSensor = new GNSSSensorImpl(pSerialPort); std::string type = pGNSSSensor->getPropertyString("type"); Poco::RemotingNG::Identifiable::ObjectId oid = pGNSSSensor->getPropertyString("symbolicName"); oid += "#0"; ServerHelper::RemoteObjectPtr pGNSSSensorRemoteObject = ServerHelper::createRemoteObject(pGNSSSensor, oid); Properties props; props.set("io.macchina.deviceType", type); props.set("io.macchina.device", oid); props.set("io.macchina.serialport.device", pSerialPort->device()); _serviceRef = _pContext->registry().registerService(oid, pGNSSSensorRemoteObject, props); }
void createSerialDevice(const std::string& uid, SerialDeviceImpl::SerialPortPtr pSerialPort) { typedef Poco::RemotingNG::ServerHelper<IoT::Devices::SerialDevice> ServerHelper; Poco::SharedPtr<IoT::Devices::SerialDevice> pDevice = new SerialDeviceImpl(pSerialPort); std::string symbolicName = pDevice->getPropertyString("symbolicName"); Poco::RemotingNG::Identifiable::ObjectId oid = symbolicName; oid += '#'; oid += uid; ServerHelper::RemoteObjectPtr pDeviceRemoteObject = ServerHelper::createRemoteObject(pDevice, oid); Properties props; props.set("io.macchina.device", oid); props.set("io.macchina.serialport.device", pSerialPort->device()); ServiceRef::Ptr pServiceRef = _pContext->registry().registerService(oid, pDeviceRemoteObject, props); _serviceRefs.push_back(pServiceRef); }