void AudioParamTimeline::insertEvent(const ParamEvent& event, ExceptionState& exceptionState) { ASSERT(isMainThread()); // Sanity check the event. Be super careful we're not getting infected with NaN or Inf. These // should have been handled by the caller. bool isValid = event.type() < ParamEvent::LastType && std::isfinite(event.value()) && std::isfinite(event.time()) && std::isfinite(event.timeConstant()) && std::isfinite(event.duration()) && event.duration() >= 0; ASSERT(isValid); if (!isValid) return; MutexLocker locker(m_eventsLock); unsigned i = 0; double insertTime = event.time(); for (i = 0; i < m_events.size(); ++i) { if (event.type() == ParamEvent::SetValueCurve) { // If this event is a SetValueCurve, make sure it doesn't overlap any existing // event. It's ok if the SetValueCurve starts at the same time as the end of some other // duration. double endTime = event.time() + event.duration(); if (m_events[i].time() > event.time() && m_events[i].time() < endTime) { exceptionState.throwDOMException( NotSupportedError, eventToString(event) + " overlaps " + eventToString(m_events[i])); return; } } else { // Otherwise, make sure this event doesn't overlap any existing SetValueCurve event. if (m_events[i].type() == ParamEvent::SetValueCurve) { double endTime = m_events[i].time() + m_events[i].duration(); if (event.time() >= m_events[i].time() && event.time() < endTime) { exceptionState.throwDOMException( NotSupportedError, eventToString(event) + " overlaps " + eventToString(m_events[i])); return; } } } // Overwrite same event type and time. if (m_events[i].time() == insertTime && m_events[i].type() == event.type()) { m_events[i] = event; return; } if (m_events[i].time() > insertTime) break; } m_events.insert(i, event); }
void EPoller::update(int opt, Channel *pChannel) { struct epoll_event ev; bzero(&ev, sizeof(struct epoll_event)); ev.events = pChannel->events(); ev.data.ptr = pChannel; //ev.events |= EPOLLET; int fd = pChannel->fd(); if(::epoll_ctl(_epfd, opt, fd, &ev) < 0) { std::string strlog = createlogger(strlog, pChannel); LOGGER_STREAM(Logger::getLogger(LOGGER_NAME)) << "epoll update is failed:" << "opt = " << eventToString(opt) << ","<<strlog << "\n"; } }
std::string eventsToString(Events events) { if (events == 0) { return "<NONE>"; } std::string ret; for (unsigned int i = 0; i<32; ++i) { Events event = 1u << i; if (events & event) { if (!ret.empty()) { ret.append(", "); } ret.append(eventToString(event)); } } return ret; }
int StateMachine::processEventsInGetAndProcessQueriesState(int ev, broker::message msg) { int statusCode = 0; switch(ev) { case SIG_KILL_EVENT: { statusCode = doActionsForKillSignalEvent(); return statusCode; } case HOST_SUBSCRIBE_EVENT: { doActionsForHostSubscribeEvent(msg); break; } case HOST_UNSUBSCRIBE_EVENT: { doActionsForHostUnSubscribeEvent(msg); break; } case CONNECTION_BROKEN_EVENT: { doActionsForConnectionBrokenEvent(); break; } case TIMER_EVENT: { doActionsForTimerEvent(); break; } default: { std::ostringstream stringStream; stringStream << eventToString(ev) << " is not allowed in " << "GET_AND_PROCESS_QUERIES " << "expecting subscription events"; LOG(WARNING) << stringStream; ptBCM->getQueryManagerPointer()-> sendErrortoBro(stringStream.str()); } }; }
int StateMachine::processEventsInWaitForTopicState(int ev, broker::message msg) { int statusCode = 0; switch(ev) { case TOPIC_RECEIVED_EVENT: { statusCode = doActionsForGroupTopicEvent(msg); setNextState(statusCode); break; } case SIG_KILL_EVENT: { statusCode = doActionsForKillSignalEvent(); return statusCode; } case TIMER_EVENT: { //stop the timer.In this state timer is not allowed. StateMachine::isTimerEvent = false; break; } case CONNECTION_BROKEN_EVENT: { doActionsForConnectionBrokenEvent(); break; } default: { std::ostringstream stringStream; stringStream << eventToString(ev) << " is not allowed in " << "WAIT_FOR_TOPIC" << "expecting group topic events"; LOG(WARNING) << stringStream; ptBCM->getQueryManagerPointer()-> sendErrortoBro(stringStream.str()); } }; }
ret = "Snapshot"; break; } break; } return ret; } static int myDomainEventCallback1(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainPtr dom, int event, int detail, void *opaque ATTRIBUTE_UNUSED) { printf("%s EVENT: Domain %s(%d) %s %s\n", __func__, virDomainGetName(dom), virDomainGetID(dom), eventToString(event), eventDetailToString(event, detail)); return 0; } static int myDomainEventCallback2(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainPtr dom, int event, int detail, void *opaque ATTRIBUTE_UNUSED) { printf("%s EVENT: Domain %s(%d) %s %s\n", __func__, virDomainGetName(dom), virDomainGetID(dom), eventToString(event), eventDetailToString(event, detail)); return 0; }
bool StatCache::handleEvent(const struct inotify_event* event) { if (event->mask & IN_Q_OVERFLOW) { // The event queue overflowed, so all bets are off. Start over. TRACE(0, "StatCache: event queue overflowed\n"); reset(); return true; } assertx(event->wd != -1); NodePtr node = folly::get_default(m_watch2Node, event->wd); if (!node.get()) { TRACE(1, "StatCache: inotify event (obsolete) %s\n", eventToString(event).c_str()); return false; } TRACE(1, "StatCache: inotify event for '%s': %s\n", node->path().c_str(), eventToString(event).c_str()); if (event->mask & (IN_MODIFY|IN_ATTRIB)) { bool touched = false; NodePtr child = node->getChild(event->name, true); if (child.get() != nullptr) { if ((event->mask & IN_MODIFY) && child->isLink()) { // A modified link is logically equivalent to IN_MOVED_FROM. child->expirePaths(); node->removeChild(event->name); } else { child->touch(); } touched = true; } child = node->getChild(event->name, false); if (child.get() != nullptr) { // The follow=false child is equivalent to the follow=true child unless // it's a link. Avoid duplicate invalidations for non-links. child->touch(!touched || child->isLink()); } } if (event->mask & (IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE)) { // The directory itself was modified, so invalidate its cached stat // structure. node->touch(); // Recursively invalidate the cached paths rooted at "node/name". bool expired = false; NodePtr child = node->getChild(event->name, true); if (child.get() != nullptr) { child->expirePaths(); expired = true; } child = node->getChild(event->name, false); if (child.get() != nullptr) { // The follow=false child is equivalent to the follow=true child unless // it's a link. Avoid duplicate invalidations for non-links. child->expirePaths(!expired || child->isLink()); expired = true; } if (expired) { node->removeChild(event->name); } } if (event->mask & IN_IGNORED) { // The kernel removed the directory watch, either as a side effect of // directory deletion, or because inotify_rm_watch() was explicitly called // during Node destruction. Delete the corresponding entry from // m_watch2Node. Removal should always succeed here because no other code // performs removal. m_watch2Node.erase(event->wd); } return false; }
void main() { uint8_t guid[16]; char buf[512]; int i,j,k; int rv; printf("GUID test 1\n"); const char *strGUID0 = ""; memset( guid, 0xff, 16 ); rv = parseGuid( strGUID0, NULL, guid ); if ( rv ) printf("GUID="" fail\n"); for ( i=0; i<16; i++ ) { if ( 0 != guid[i] ) { printf("GUID="" fail. Index=%d\n", i); } } printf("GUID test 2\n"); const char *strGUID1 = "-"; memset( guid, 0xff, 16 ); rv = parseGuid( strGUID1, NULL, guid ); if ( rv ) printf("GUID='-' fail\n"); for ( int i=0; i<16; i++ ) { if ( 0 != guid[i] ) { printf("GUID='-' fail. Index=%d\n", i); } } printf("GUID test 3\n"); const char *strGUID2 = "00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF"; const uint8_t GUID2_array[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF}; memset( guid, 0xff, 16 ); rv = parseGuid( strGUID2, NULL, guid ); if ( VSCP_ERROR_SUCCESS != rv ) printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' parser return fail\n"); for ( i=0; i<16; i++ ) { if ( GUID2_array[i] != guid[i] ) { printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i); } } printf("GUID test 4\n"); const char *strGUID3 = "00:11:22:33:44:55:66:77:88:99:AA:BB:CC:"; const uint8_t GUID3_array[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0x00,0x00,0x00}; memset( guid, 0xff, 16 ); rv = parseGuid( strGUID3, NULL, guid ); if ( VSCP_ERROR_SUCCESS != rv ) printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:' parser return fail\n"); for ( i=0; i<16; i++ ) { if ( GUID3_array[i] != guid[i] ) { printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:' fail. Index=%d\n", i); } } printf("GUID test 5\n"); const char *strGUID4 = "00:11:22:33:44:55:66:77:88:99:AA:BB:CC"; const uint8_t GUID4_array[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0x00,0x00,0x00}; memset( guid, 0xff, 16 ); rv = parseGuid( strGUID4, NULL, guid ); if ( VSCP_ERROR_SUCCESS != rv ) printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC' parser return fail\n"); for ( i=0; i<16; i++ ) { if ( GUID4_array[i] != guid[i] ) { printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC' fail. Index=%d\n", i); } } printf("GUID test 6\n"); const char *strGUID5 = "00:11:22:33:44:YW:66:77:88:99:AA:BB:CC:01:02:03"; const uint8_t GUID5_array[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0x01,0x02,0x03}; memset( guid, 0xff, 16 ); rv = parseGuid( strGUID5, NULL, guid ); if ( VSCP_ERROR_SUCCESS == rv ) printf("GUID='00:11:22:33:44:YW:66:77:88:99:AA:BB:CC:01:02:03' parser return success but should have returned failure.\n"); printf("GUID test 7\n"); const char *strGUID6 = "00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,22,33,44,55"; const uint8_t GUID6_array[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF}; memset( guid, 0xff, 16 ); rv = parseGuid( strGUID6, NULL, guid ); if ( VSCP_ERROR_SUCCESS != rv ) printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,22,33,44,55' parser return fail\n"); for ( i=0; i<16; i++ ) { if ( GUID6_array[i] != guid[i] ) { printf("GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,22,33,44,55' fail. Index=%d\n", i); } } // ------------------------------------------------------------------------ printf("Filter test 1 (filter)\n"); vscpEventFilter evfilter; memset( &evfilter, 0, sizeof(vscpEventFilter) ); if ( VSCP_ERROR_SUCCESS != parseFilter( "2,0x20,6,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF", &evfilter ) ) { printf("Failed on filter test 1\n"); } if ( evfilter.filter_priority != 2 ) printf("Filter test 1 - filter_priority fail.\n"); if ( evfilter.filter_class != 32 ) printf("Filter test 1 - filter_class fail.\n"); if ( evfilter.filter_type != 6 ) printf("Filter test 1 - filter_type fail.\n"); for ( i=0; i<16; i++ ) { if ( GUID2_array[i] != evfilter.filter_GUID[i] ) { printf("Filter test 1 GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i); } } // ------------------------------------------------------------------------ printf("Filter test 2 (mask)\n"); memset( &evfilter, 0, sizeof(vscpEventFilter) ); if ( VSCP_ERROR_SUCCESS != parseMask( "0x22,1,077,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF", &evfilter ) ) { printf("Failed on filter test 2\n"); } if ( evfilter.mask_priority != 34 ) printf("Filter test 2 - mask_priority fail.\n"); if ( evfilter.mask_class != 1 ) printf("Filter test 2 - mask_class fail.\n"); if ( evfilter.mask_type != 63 ) printf("Filter test 2 - mask_type fail.\n"); for ( i=0; i<16; i++ ) { if ( GUID2_array[i] != evfilter.mask_GUID[i] ) { printf("Filter test 1 GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i); } } // ------------------------------------------------------------------------ printf("Event test 1 (standard)\n"); vscpEvent ev; memset( &ev, 0, sizeof(vscpEvent) ); if ( VSCP_ERROR_SUCCESS != parseEvent( "1,0x21,3,1234567,2062-11-17T19:32:44,7654321,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,0x22,33,0x44,55", &ev ) ) { printf("Failed on event test 1\n"); } if ( ev.head != 1 ) printf("Event test 1, head failed.\n"); if ( ev.vscp_class != 0x21 ) printf("Event test 1, vscp_class failed.\n"); if ( ev.vscp_type != 3 ) printf("Event test 1, vscp_type failed.\n"); if ( ev.obid != 1234567 ) printf("Event test 1, obid failed.\n"); if ( ev.year != 2062 ) printf("Event test 1, year failed.\n"); if ( ev.month != 11 ) printf("Event test 1, month failed.\n"); if ( ev.day != 17 ) printf("Event test 1, day failed.\n"); if ( ev.hour != 19 ) printf("Event test 1, hour failed.\n"); if ( ev.minute != 32 ) printf("Event test 1, minute failed.\n"); if ( ev.second != 44 ) printf("Event test 1, second failed.\n"); if ( ev.timestamp != 7654321 ) printf("Event test 1, timestamp failed.\n"); if ( ev.sizeData != 5 ) printf("Event test 1, sizeData failed (%d).\n", (int)ev.sizeData ); for ( i=0; i<16; i++ ) { if ( GUID2_array[i] != ev.GUID[i] ) { printf("Event test 1, GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i); } } if ( NULL == ev.pdata ) { printf("Event test 1, pdata == NULL, Failure\n"); } else { if ( ev.pdata[0] != 11 ) printf("Event test 1, Data byte 0 failed.\n"); if ( ev.pdata[1] != 0x22 ) printf("Event test 1, Data byte 1 failed.\n"); if ( ev.pdata[2] != 33 ) printf("Event test 1, Data byte 2 failed.\n"); if ( ev.pdata[3] != 0x44 ) printf("Event test 1, Data byte 3 failed.\n"); if ( ev.pdata[4] != 55 ) printf("Event test 1, Data byte 4 failed.\n"); } // ------------------------------------------------------------------------ printf("Event test 2 (standard)\n"); memset( &ev, 0, sizeof(vscpEvent) ); if ( VSCP_ERROR_SUCCESS != parseEvent( "1,0x21,3,,,,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,0x22,33,0x44,55", &ev ) ) { printf("Failed on event test 2\n"); } if ( ev.head != 1 ) printf("Event test 2, head failed.\n"); if ( ev.vscp_class != 0x21 ) printf("Event test 2, vscp_class failed.\n"); if ( ev.vscp_type != 3 ) printf("Event test 2, vscp_type failed.\n"); if ( ev.obid != 0 ) printf("Event test 2, obid failed.\n"); if ( ev.year != 0 ) printf("Event test 2, year failed.\n"); if ( ev.month != 0 ) printf("Event test 2, month failed.\n"); if ( ev.day != 0 ) printf("Event test 2, day failed.\n"); if ( ev.hour != 0 ) printf("Event test 2, hour failed.\n"); if ( ev.minute != 0 ) printf("Event test 2, minute failed.\n"); if ( ev.second != 0 ) printf("Event test 2, second failed.\n"); if ( ev.timestamp != 0 ) printf("Event test 2, timestamp failed.\n"); if ( ev.sizeData != 5 ) printf("Event test 2, sizeData failed (%d).\n", (int)ev.sizeData ); for ( i=0; i<16; i++ ) { if ( GUID2_array[i] != ev.GUID[i] ) { printf("Event test 2, GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i); } } if ( NULL == ev.pdata ) { printf("Event test 2, pdata == NULL, Failure\n"); } else { if ( ev.pdata[0] != 11 ) printf("Event test 2, Data byte 0 failed.\n"); if ( ev.pdata[1] != 0x22 ) printf("Event test 2, Data byte 1 failed.\n"); if ( ev.pdata[2] != 33 ) printf("Event test 2, Data byte 2 failed.\n"); if ( ev.pdata[3] != 0x44 ) printf("Event test 2, Data byte 3 failed.\n"); if ( ev.pdata[4] != 55 ) printf("Event test 2, Data byte 4 failed.\n"); } // ------------------------------------------------------------------------ printf("EventEx test 1 (extended)\n"); vscpEventEx evex; memset( &evex, 0, sizeof(vscpEventEx) ); if ( VSCP_ERROR_SUCCESS != parseEventEx( "1,0x21,3,1234567,2062-11-17T19:32:44,7654321,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,11,0x22,33,0x44,55", &evex ) ) { printf("Failed on eventex test 1\n"); } if ( evex.head != 1 ) printf("EventEx test 1, head failed.\n"); if ( evex.vscp_class != 0x21 ) printf("EventEx test 1, vscp_class failed.\n"); if ( evex.vscp_type != 3 ) printf("EventEx test 1, vscp_type failed.\n"); if ( evex.obid != 1234567 ) printf("EventEx test 1, obid failed.\n"); if ( evex.year != 2062 ) printf("EventEx test 1, year failed.\n"); if ( evex.month != 11 ) printf("EventEx test 1, month failed.\n"); if ( evex.day != 17 ) printf("EventEx test 1, day failed.\n"); if ( evex.hour != 19 ) printf("EventEx test 1, hour failed.\n"); if ( evex.minute != 32 ) printf("EventEx test 1, minute failed.\n"); if ( evex.second != 44 ) printf("EventEx test 1, second failed.\n"); if ( evex.timestamp != 7654321 ) printf("EventEx test 1, timestamp failed.\n"); if ( evex.sizeData != 5 ) printf("EventEx test 1, sizeData failed (%d).\n", (int)evex.sizeData ); for ( i=0; i<16; i++ ) { if ( GUID2_array[i] != evex.GUID[i] ) { printf("EventEx test 1, GUID='00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF' fail. Index=%d\n", i); } } if ( evex.data[0] != 11 ) printf("EventEx test 1, Data byte 0 failed.\n"); if ( evex.data[1] != 0x22 ) printf("EventEx test 1, Data byte 1 failed.\n"); if ( evex.data[2] != 33 ) printf("EventEx test 1, Data byte 2 failed.\n"); if ( evex.data[3] != 0x44 ) printf("EventEx test 1, Data byte 3 failed.\n"); if ( evex.data[4] != 55 ) printf("EventEx test 1, Data byte 4 failed.\n"); // ------------------------------------------------------------------------ printf("Event to string test\n"); if ( VSCP_ERROR_SUCCESS != parseEvent( "1,0x21,3,1234567,2062-11-17T19:32:44,7654321,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,011,0x22,33,0x44,55", &ev ) ) { printf("Event to string test failed creating event\n"); } if ( VSCP_ERROR_SUCCESS != eventToString( &ev, buf, sizeof( buf ) ) ) { printf("Failed to convert event to string\n"); } else { printf("IN :%s\n", "1,0x21,3,1234567,2062-11-17T19:32:44,7654321,00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF,011,0x22,33,0x44,55" ); printf("OUT:%s\n", buf ); } }