void crashutils::onSelect(entry *selectedEntry, int selItemIndex) { //... switch (selectedEntry->type) { case 1: postMessage(MSG_SELECT_SVTX, (param)selectedEntry, (param)selItemIndex); break; case 3: postMessage(MSG_SELECT_WGEO, (param)selectedEntry); break; case 7: postMessage(MSG_SELECT_ZDAT, (param)selectedEntry); break; case 11: postMessage(MSG_SELECT_GOOL, (param)selectedEntry); break; } }
//--------------------------------------------------------------------------- void __fastcall TMessGen::Timer2Timer(TObject *Sender) { TBytes ab; int length; UnicodeString host = IdUDPClient1->Host; WORD port = IdUDPClient1->Port; Timer2->Enabled = 0; ab.Length = 1000; try { while ((length = IdUDPClient1->ReceiveBuffer(ab, host, port, 100)) > 0) { BYTE *data = new BYTE[length]; for (int i = 0; i <length; ++i) { data[i] = ab[i]; } // message("RX: %s:%d [%d]: %d/%d (%d) %s", // AnsiString(IdUDPClient1->Host).c_str(), IdUDPClient1->Port, length, // data[0], data[1], *(WORD*)(data+2), data + 8); switch (data[1]) { case 0: // registration response // message(" Registration response"); break; case 2: // response // message(" %04X/%d %s", *(DWORD*)(data+32), *(DWORD*)(data+32+4), data+32+8); postMessage(*(DWORD*)(data+32), *(DWORD*)(data+32+4)); break; case 90: // message(" Setup has been changed"); postMessage(2, 0); break; case 98: // message(" Message: %s", data+32); break; case 99: // message(" Error %d[%08X]", *(DWORD*)(data+32), *(DWORD*)(data+32)); break; default: // message("Unknown message type %d/%d", data[1]); break; } } } catch (...) { // message("Connection broken"); } Timer2->Enabled = 1; }
void msgWork(const Pothos::Packet &inPkt) { //calculate conversion and buffer sizes (round up) const size_t numSyms = (inPkt.payload.length + _mod - 1)/_mod; //create a new packet for output symbols Pothos::Packet outPkt; auto outPort = this->output(0); outPkt.payload = outPort->getBuffer(numSyms); //perform conversion auto in = inPkt.payload.as<const unsigned char*>(); auto out = outPkt.payload.as<unsigned char*>(); switch (_order) { case MSBit: ::bitsToSymbolsMSBit(_mod, in, out, numSyms); break; case LSBit: ::bitsToSymbolsLSBit(_mod, in, out, numSyms); break; } //copy and adjust labels for (const auto &label : inPkt.labels) { outPkt.labels.push_back(label.toAdjusted(1, _mod)); } //post the output packet outPort->postMessage(outPkt); }
// Logging functions void MainWindow::postInfoMessage(const QString& msg) { static const QString colour = QLatin1String("#3A87AD"); static const QString leader = QLatin1String("Info"); postMessage(colour, leader, msg); }
void work(void) { auto inPort = this->input(0); auto outPort = this->output(0); inPort->setReserve(_mod); //handle packet conversion if applicable if (inPort->hasMessage()) { auto msg = inPort->popMessage(); if (msg.type() == typeid(Pothos::Packet)) this->msgWork(msg.extract<Pothos::Packet>()); else outPort->postMessage(msg); return; //output buffer used, return now } //calculate work size const size_t numSyms = std::min(inPort->elements() / _mod, outPort->elements()); if (numSyms == 0) return; //perform conversion auto in = inPort->buffer().as<const unsigned char *>(); auto out = outPort->buffer().as<unsigned char *>(); switch (_order) { case MSBit: ::bitsToSymbolsMSBit(_mod, in, out, numSyms); break; case LSBit: ::bitsToSymbolsLSBit(_mod, in, out, numSyms); break; } //produce/consume inPort->consume(numSyms * _mod); outPort->produce(numSyms); }
void MainWindow::postWarningMessage(const QString& msg) { static const QString colour = QLatin1String("#C09853"); static const QString leader = QLatin1String("Warning"); postMessage(colour, leader, msg); }
// FIXME: remove this when we update the ObjC bindings (bug #28774). void Worker::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort* port, ExceptionCode& ec) { MessagePortArray ports; if (port) ports.append(port); postMessage(message, &ports, ec); }
bool Round::RemoteNode::postMessage(uHTTP::HTTPRequest *httpReq, NodeResponse *nodeRes, Error *error) { // HTTP Request JSONObject *rootObj = NULL; if (!postMessage(httpReq, &rootObj, error)) return false; if (!rootObj->isDictionary()) { RPC::JSON::ErrorCodeToError(RPC::JSON::ErrorCodeParserError, error); return false; } JSONDictionary *jsonDict = dynamic_cast<JSONDictionary *>(rootObj); if (!jsonDict) { RPC::JSON::ErrorCodeToError(RPC::JSON::ErrorCodeParserError, error); return false; } nodeRes->set(jsonDict); // Update local clock clock_t remoteTs; if (nodeRes->getTimestamp(&remoteTs)) { setRemoteClock(remoteTs); } return true; }
//============================================================================== void MainContentComponent::handleIncomingMidiMessage (MidiInput* /*source*/, const MidiMessage &message) { // This is called on the MIDI thread if (message.isNoteOnOrOff()) postMessage (new MidiCallbackMessage (message)); }
int startThread() { postMessage(0, KS_START_THREAD, 0); getMessageFrom(&temp_msg, 0, KS_START_THREAD); return temp_msg.payload; }
unsigned int getNextPid() { unsigned int return_pid = 0; if(current_process == 256) return 0; while(!return_pid) { postMessage(0, KS_PID_FROM_SLOT, current_process); getMessageFrom(&temp_msg, 0, KS_PID_FROM_SLOT); return_pid = temp_msg.payload; if(current_process == 255) { if(return_pid) { break; } else { current_process++; return 0; } } else { current_process++; } } return return_pid; }
void msgWork(const Pothos::Packet &inPkt) { //calculate conversion and buffer sizes (round up) const size_t numBytes = ((inPkt.payload.length + _reserveBytes - 1)/_reserveBytes)*_reserveBytes; const size_t numSyms = (numBytes*8)/_mod; //create a new packet for output symbols Pothos::Packet outPkt; auto outPort = this->output(0); if (outPort->elements() >= numSyms) { outPkt.payload = outPort->buffer(); outPkt.payload.length = numSyms; outPort->popBuffer(numSyms); } else outPkt.payload = Pothos::BufferChunk(outPort->dtype(), numSyms); //perform conversion auto in = inPkt.payload.as<const unsigned char*>(); auto out = outPkt.payload.as<unsigned char*>(); switch (_order) { case MSBit: ::bytesToSymbolsMSBit(_mod, in, out, numBytes); break; case LSBit: ::bytesToSymbolsLSBit(_mod, in, out, numBytes); break; } //copy and adjust labels for (const auto &label : inPkt.labels) { outPkt.labels.push_back(label.toAdjusted(8, _mod)); } //post the output packet outPort->postMessage(outPkt); }
void TaoClientTask::requestShutdown() { // Need to put a Mutex on the call stack // Pass the shut down to itself OsServerTask::requestShutdown(); yield(); if (mpConnectionSocket) { TaoMessage msg = TaoMessage(TaoMessage::REQUEST_PROVIDER, TaoMessage::SHUTDOWN, 0, 0, (TaoObjHandle)mpConnectionSocket, 0, ""); postMessage(msg); } if(mpTransport) { osPrintf("---- TaoClientTask::initInstance: stoping transport\n"); mpTransport->stopListening(); // shut down the transport task mpTransport->requestShutdown(); // shut down the transport task } }
void WindowButton::onMenuUp() { m_Flags &= ~DEPRESSED; // post message to listeners postMessage( WB_MENUUP, StringHash( name() ), 0 ); }
void context_plugin_camera_trans::onSmoothTrans(point *apr) { doTrans = true; aprX = ((float)apr->X/0x1000)*8; aprY = ((float)apr->Y/0x1000)*8; aprZ = ((float)apr->Z/0x1000)*8; dirX = (aprX - contextCamera->location.X); dirY = (aprY - contextCamera->location.Y); dirZ = (aprZ - contextCamera->location.Z); float scale = (float) sqrt((dirX*dirX) + (dirY*dirY) + (dirZ*dirZ)); dirX /= scale; dirY /= scale; dirZ /= scale; // 50 = n = number of times a constant // 'accel' needs to increasingly accumulate and then // decreasingly decumulate speed such that accumulation // of position with that updated speed each time will // reach 'scale'; approx 50 frames for a camera jump int n = 15; accel = (scale)/(n*n); max = accel*((n*(n+1))/2); speed = 0; phase = false; postMessage(GSM_INVALIDATE); }
void MainWindow::postErrorMessage(const QString& msg) { static const QString colour = QLatin1String("#B94A48"); static const QString leader = QLatin1String("Error"); postMessage(colour, leader, msg); }
//HANDLED BY context_plugin_section_select void context_plugin_zone_select::onPoint(int x, int y) { if (contextScene->getViewMode() & (SCENE_VIEWMODE_WGEOSINGLE | SCENE_VIEWMODE_SVTXSINGLE | SCENE_VIEWMODE_SPRITESINGLE)) return; bool zoneSel = false; zone_outline *curOutline; for (int lp=0; lp<zoneOutlineCount; lp++) { curOutline = &zoneOutline[lp]; zoneSel = comp_geom::pointInPolygon2d(x, y, curOutline->outline, curOutline->pointCount); if (zoneSel) break; } if (zoneSel) { entry *zone = curOutline->zone; postMessage(MSG_SELECT_ZONE, (param)zone); } }
unsigned int getCurrentPid() { postMessage(0, KS_GET_PID, 0); getMessageFrom(&temp_msg, 0, KS_GET_PID); return temp_msg.payload; }
OsStatus MprFromStream::realize(UtlString* pBuffer, int flags, StreamHandle &handle, OsNotification* pEvent) { OsStatus status = OS_INVALID ; // Create and Initialize Feeder MpStreamFeeder* pFeeder = new MpStreamFeeder(pBuffer, flags) ; if (pEvent != NULL) pFeeder->setEventHandler(pEvent) ; // Realize status = pFeeder->realize() ; // If not successful, cleanup. if (status == OS_SUCCESS) { STREAMDESC* pDesc = new STREAMDESC ; pDesc->handle = (void*) miStreamCount++ ; pDesc->pFeeder = pFeeder ; mStreamList.push(pDesc) ; handle = pDesc->handle ; } else { MpFlowGraphMsg msg(SOURCE_DESTROY, this, pFeeder, 0, 0, 0); postMessage(msg); } return status ; }
TEST(chatpresenter, test_postingMessages) { Poco::SharedPtr<MockChatService> m(new MockChatService); Mvp::Presenter::TextChatPresenter presenter(m.get()); Poco::SharedPtr<MockChatView> v(new MockChatView()); EXPECT_CALL(*v, initialize()); ON_CALL(*m, getParticipants()) .WillByDefault(Return(contacts)); ON_CALL(*m, messageHistory(_)) .WillByDefault(Return(messages)); EXPECT_CALL(*m, chatName()); EXPECT_CALL(*v, setChatTitle(_)); EXPECT_CALL(*m, messageHistory(_)); EXPECT_CALL(*m, isConsumer()); EXPECT_CALL(*v, enableControls(_)); EXPECT_CALL(*v, showLeaveAction(_)); EXPECT_CALL(*m, getParticipants()); EXPECT_CALL(*v, setParticipants(_)); presenter.setView(v.get()); EXPECT_CALL(*v, showView()); presenter.showView(); EXPECT_CALL(*m, postMessage(_)); v->triggerPostMessage(); }
extern "C" JNIEXPORT void JNICALL Java_org_skia_viewer_ViewerActivity_onSurfaceChanged( JNIEnv* env, jobject activity, jlong handle, jobject surface) { auto skiaAndroidApp = (SkiaAndroidApp*)handle; Message message(kSurfaceChanged); message.fNativeWindow = ANativeWindow_fromSurface(env, surface); skiaAndroidApp->postMessage(message); }
void work(void) { auto inputPort = this->input(0); auto outputPort = this->output(0); while (inputPort->hasMessage()) { auto m = inputPort->popMessage(); outputPort->postMessage(m); } const auto &buffer = inputPort->buffer(); if (buffer.length != 0) { outputPort->postBuffer(buffer); inputPort->consume(inputPort->elements()); for (size_t i = 0; i < inputPort->elements(); i++) { if (std::generate_canonical<double, 10>(_gen) <= _probability) { Pothos::Label label; label.index = i; label.width = buffer.dtype.size(); if (not _ids.empty()) label.id = _ids.at(_randomId(_gen)); outputPort->postLabel(label); } } } }
unsigned int getProcessCPUUsage(unsigned int pid) { postMessage(0, KS_GET_PROC_CPU_PCT, pid); getMessageFrom(&temp_msg, 0, KS_GET_PROC_CPU_PCT); return temp_msg.payload; }
void MainWindow::postSuccessMessage(const QString& msg) { static const QString colour = QLatin1String("#468847"); static const QString leader = QLatin1String("Success"); postMessage(colour, leader, msg); }
void MessagePort::postMessage(RefPtr<SerializedScriptValue>&& message, MessagePort* port, ExceptionCode& ec) { MessagePortArray ports; if (port) ports.append(port); postMessage(WTFMove(message), &ports, ec); }
void work(void) { if (once) return; once = true; auto out0 = this->output("out0"); out0->postMessage(42); }
void work(void) { auto outputPort = this->output(0); //message production if (_enableMessages) { outputPort->postMessage(Pothos::Object()); } //buffer production if (_enableBuffers) { size_t bytes = outputPort->elements(); if (_bufferMTU != 0) bytes = std::min(bytes, _bufferMTU); outputPort->produce(bytes); //label production if (_enableLabels) { Pothos::Label label; label.index = 0; outputPort->postLabel(label); } } }
OsStatus XCpCall::connect(const UtlString& sipCallId, SipDialog& sipDialog, const UtlString& toAddress, const UtlString& fromAddress, const UtlString& locationHeader, CP_CONTACT_ID contactId, SIP_TRANSPORT_TYPE transport, CP_FOCUS_CONFIG focusConfig, const UtlString& replacesField, CP_CALLSTATE_CAUSE callstateCause, const SipDialog* pCallbackSipDialog) { if (sipCallId.isNull() || toAddress.isNull() || fromAddress.isNull()) { return OS_FAILED; } m_focusConfig = focusConfig; UtlString localTag(m_sipTagGenerator.getNewTag()); sipDialog = SipDialog(sipCallId, localTag, NULL); AcConnectMsg connectMsg(sipCallId, toAddress, localTag, fromAddress, locationHeader, contactId, transport, replacesField, callstateCause, pCallbackSipDialog); return postMessage(connectMsg); }
//============================================================================== void handleBuffer (const char* data, size_t dataSize) { OSCInputStream inStream (data, dataSize); try { OSCBundle::Element content = inStream.readElementWithKnownSize (dataSize); // realtime listeners should receive the OSC content first - and immediately // on this thread: callRealtimeListeners (content); if (content.isMessage()) callRealtimeListenersWithAddress (content.getMessage()); // now post the message that will trigger the handleMessage callback // dealing with the non-realtime listeners. if (listeners.size() > 0 || listenersWithAddress.size() > 0) postMessage (new CallbackMessage (content)); } catch (OSCFormatError) { if (formatErrorHandler != nullptr) formatErrorHandler (data, (int) dataSize); } }
//--------------------------------------------------------- // Launch the secondary thread in which the Python interpreter // is executed, since this call comes from the main Application thread. // void Tart::start() { if (m_thread) return; QSemaphore sem(0); // qDebug() << QThread::currentThreadId() << "Tart: starting TartThread"; m_thread = new TartThread(&sem); this->moveToThread(m_thread); m_thread->start(); connect(m_thread, SIGNAL(finished()), this, SLOT(thread_finished())); // being able to acquire this semaphore means the Python main thread // has succesfully started, and qDebug() << QThread::currentThreadId() << "Tart: wait for sema"; sem.acquire(1); qDebug() << QThread::currentThreadId() << "Tart: got sema"; // Only make the connection here if the interpreter entered the event loop. if (m_thread->ran_loop()) { // force postMessage() to result in a QueuedConnection for now // since the default doesn't appear to be picking the right method // TODO: investigate if that's a sign of a problem connect(this, SIGNAL(postMessage(QString)), this, SLOT(do_postMessage(QString)), Qt::QueuedConnection); } }