コード例 #1
0
ファイル: InterpIR.c プロジェクト: dmpots/lambdachine
Word
restoreValue(Fragment *F, Word *vals, IRRef ref)
{
  IRIns *ir = IR(ref);
  HeapInfo *hp;
  Closure *cl;
  int j;

  // We only need to treat allocations specially.
  if (ir->o != IR_NEW)
    return vals[ref];

  hp = &F->heap[ir->op2];
  // Store has *not* been sunken, i.e., allocation occurred on-trace
  if (!ir_issunken(ir))
    return vals[ref];

  // Otherwise we need to do the allocation now, possibly recursively
  //
  // TODO: Can we have mutually recursive sunken refs?
  recordEvent(EV_ALLOC, 1 + hp->nfields);
  cl = allocClosure(wordsof(ClosureHeader) + hp->nfields);
  setInfo(cl, (InfoTable*)vals[ir->op1]);
  DBG_PR("(alloc[%lu])", wordsof(ClosureHeader) + hp->nfields);

  for (j = 0; j < hp->nfields; j++)
    cl->payload[j] = restoreValue(F, vals, getHeapInfoField(F, hp, j));

  return (Word)cl;
}
コード例 #2
0
ファイル: events.cpp プロジェクト: eastebry/osquery
Status EventSubscriberPlugin::add(Row& r, EventTime event_time) {
  std::shared_ptr<DBHandle> db = nullptr;
  try {
    db = DBHandle::getInstance();
  } catch (const std::runtime_error& e) {
    return Status(1, e.what());
  }

  // Get and increment the EID for this module.
  EventID eid = getEventID();
  // Without encouraging a missing event time, do not support a 0-time.
  r["time"] = std::to_string((event_time == 0) ? getUnixTime() : event_time);

  // Serialize and store the row data, for query-time retrieval.
  std::string data;
  auto status = serializeRowJSON(r, data);
  if (!status.ok()) {
    return status;
  }

  // Store the event data.
  std::string event_key = "data." + dbNamespace() + "." + eid;
  status = db->Put(kEvents, event_key, data);
  // Record the event in the indexing bins, using the index time.
  recordEvent(eid, event_time);
  return status;
}
コード例 #3
0
Status EventSubscriberPlugin::add(Row& r, EventTime event_time) {
  // Get and increment the EID for this module.
  EventID eid = getEventID();
  // Without encouraging a missing event time, do not support a 0-time.
  r["time"] = std::to_string((event_time == 0) ? getUnixTime() : event_time);
  // Serialize and store the row data, for query-time retrieval.
  std::string data;
  auto status = serializeRowJSON(r, data);
  if (!status.ok()) {
    return status;
  }
  // Then remove the newline.
  if (data.size() > 0 && data.back() == '\n') {
    data.pop_back();
  }

  // Use the last EventID and a checkpoint bucket size to periodically apply
  // buffer eviction. Eviction occurs if the total count exceeds events_max.
  if (last_eid_ % EVENTS_CHECKPOINT == 0) {
    expireCheck();
  }

  // Store the event data.
  std::string event_key = "data." + dbNamespace() + "." + eid;
  status = setDatabaseValue(kEvents, event_key, data);
  // Record the event in the indexing bins, using the index time.
  recordEvent(eid, event_time);
  return status;
}
コード例 #4
0
ファイル: tm.c プロジェクト: BackupTheBerlios/openimscore-svn
static void tmcb_func( struct cell* t, int type, struct tmcb_params *ps )
{
        if (type&TMCB_RESPONSE_OUT) {
                DBG("osp:tmcb: on-RESPONSE_OUT-out\n");
        } else if (type&TMCB_E2EACK_IN) {
                DBG("osp:tmcb: on-E2EACK_IN\n");
        } else if (type&TMCB_ON_FAILURE_RO) {
                DBG("osp:tmcb: on-FAILURE_RO\n");
        } else if (type&TMCB_RESPONSE_IN) {
                DBG("osp:tmcb: on-RESPONSE_IN\n");
        } else if (type&TMCB_REQUEST_FWDED) {
                DBG("osp:tmcb: on-REQUEST_FWDED\n");
        } else if (type&TMCB_RESPONSE_FWDED) {
                DBG("osp:tmcb: on-RESPONSE_FWDED\n");
        } else if (type&TMCB_ON_FAILURE) {
                DBG("osp:tmcb: on-FAILURE\n");
        } else if (type&TMCB_LOCAL_COMPLETED) {
                DBG("osp:tmcb: on-COMPLETED\n");
        } else {
                DBG("osp:tmcb: on-something-else: %d\n",type);
        }

	if (t) {
		recordEvent(t->uac[t->nr_of_outgoings-1].last_received,t->uas.status);
	} else {
                DBG("osp:tmcb: cell is empty\n");
	}
}
コード例 #5
0
ファイル: events.cpp プロジェクト: erdincay/osquery
Status EventSubscriberPlugin::add(Row& r, EventTime event_time) {
  std::shared_ptr<DBHandle> db = nullptr;
  try {
    db = DBHandle::getInstance();
  } catch (const std::runtime_error& e) {
    return Status(1, e.what());
  }

  // Get and increment the EID for this module.
  EventID eid = getEventID();
  // Without encouraging a missing event time, do not support a 0-time.
  r["time"] = std::to_string((event_time == 0) ? getUnixTime() : event_time);

  // Serialize and store the row data, for query-time retrieval.
  std::string data;
  auto status = serializeRowJSON(r, data);
  if (!status.ok()) {
    return status;
  }

  // Use the last EventID and a checkpoint bucket size to periodically apply
  // buffer eviction. Eviction occurs if the total count exceeds events_max.
  if (last_eid_ % EVENTS_CHECKPOINT == 0) {
    expireCheck();
  }

  // Store the event data.
  std::string event_key = "data." + dbNamespace() + "." + eid;
  status = db->Put(kEvents, event_key, data);
  // Record the event in the indexing bins, using the index time.
  recordEvent(eid, event_time);
  return status;
}
コード例 #6
0
// ----------------------------------------------------------------------------
void qMRMLTreeViewEventTranslator::onDecorationClicked(const QModelIndex& index)
{
  if(index.isValid())
    {
    emit recordEvent(this->CurrentObject, "decorationClicked", this->getIndexAsString(index));
    }
}
コード例 #7
0
ファイル: events.cpp プロジェクト: JessicaWhite17/osquery
Status EventSubscriberPlugin::add(const Row& r, EventTime time) {
  Status status;

  std::shared_ptr<DBHandle> db;
  try {
    db = DBHandle::getInstance();
  } catch (const std::runtime_error& e) {
    return Status(1, e.what());
  }

  // Get and increment the EID for this module.
  EventID eid = getEventID();

  std::string event_key = "data." + dbNamespace() + "." + eid;
  std::string data;

  status = serializeRowJSON(r, data);
  if (!status.ok()) {
    return status;
  }

  // Store the event data.
  status = db->Put(kEvents, event_key, data);
  // Record the event in the indexing bins.
  recordEvent(eid, time);
  return status;
}
コード例 #8
0
//-----------------------------------------------------------------------------
void qMRMLTreeViewEventTranslator::onAboutToReparentByDnD(vtkMRMLNode* node , vtkMRMLNode* newParent )
{
  if (node)
    {
    QString parentID = newParent ? QString::fromLatin1(newParent->GetID()) : 0;
    QString args = QString("%1.%2").arg(
        QString::fromLatin1(node->GetID()),
        parentID);
    emit recordEvent(this->CurrentObject, "reParentByDragnDrop", args);
    }
}
コード例 #9
0
ファイル: llmetrics.cpp プロジェクト: 9skunks/imprudence
void LLMetricsImpl::recordEventDetails(const std::string& location, 
									const std::string& mesg, 
									bool success, 
									LLSD stats)
{
	recordEvent(location,mesg,success);

	LLSD metrics = LLSD::emptyMap();
	metrics["location"] = location;
	metrics["stats"]  = stats;
	
	llinfos << "LLMETRICS: " << LLSDNotationStreamer(metrics) << llendl; 
}
コード例 #10
0
speech_recognize::speech_recognize(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags)
{
	connect(this, SIGNAL(REG()), this, SLOT(recordEvent()));
	ui.setupUi(this);

	this->setWindowTitle(tr("简单语音识别软件"));
	this->setFixedWidth(this->width());
	this->setFixedHeight(this->height());

	m_SREngine.InitializeSapi((HWND)this->winId(), WM_RECORD_INFO);
	m_SREngine.LoadCmdFromFile("Resources\\CmdCtrl.xml");
	m_SREngine.SetRuleState(NULL,NULL,TRUE);

	m_SREngine.m_pVoice->Speak(L"这是一个简单语音识别软件", SPF_ASYNC, NULL);

	initUI();
	this->ui.statusBar->addWidget(&m_toolLabel);
	cmdBegin();
}
コード例 #11
0
ファイル: FakeVMeModel.cpp プロジェクト: chisomiloks/vme-nmpc
up_VMeCommand FakeVMeModel::retrieveCommand(int) const {
  recordEvent('C');
  return up_VMeCommand{new VMeV{0, 0, 0}};
}
コード例 #12
0
ファイル: FakeVMeModel.cpp プロジェクト: chisomiloks/vme-nmpc
void FakeVMeModel::computeGradient() noexcept { recordEvent('G'); }
コード例 #13
0
ファイル: FakeVMeModel.cpp プロジェクト: chisomiloks/vme-nmpc
void FakeVMeModel::computePathPotentialGradient(
    ObstacleContainer&) noexcept {
  recordEvent('P');
}
コード例 #14
0
ファイル: FakeMinimizer.cpp プロジェクト: wuyou33/vme-nmpc
MinimizerCode FakeMinimizer::solveOptimalControlHorizon() noexcept {
  recordEvent('O');
  return MinimizerCode::success;
}
コード例 #15
0
ファイル: InterpIR.c プロジェクト: dmpots/lambdachine
int
irEngine(Capability *cap, Fragment *F)
{
  static Inst disp[] = {
#define IRIMPL(name, f, o1, o2)  &&op_##name,
    IRDEF(IRIMPL)
#undef IRIMPL
    &&stop
  };

  
  IRRef ref;
  Thread *T = cap->T;
  Word nphis = F->nphis;
  Word *base = T->base - 1;
  Word szins = F->nins - F->nk;
  Word vals_[szins + nphis];
  Word *phibuf = &vals_[szins]; /* For parallel copy of PHI nodes */
  Word *vals = vals_ - (int)F->nk;
       
  IRIns *pc = F->ir + REF_FIRST;
  IRRef pcref = REF_FIRST;
  IRIns *pcmax = F->ir + F->nins;
  IRIns *pcloop = F->nloop ? F->ir + F->nloop + 1 : pc;
  //int count = 100;

  DBG_PR("*** Executing trace.\n"
         "***   base  = %p\n"
         "***   pc    = %p\n"
         "***   pcmax = %p (%d)\n"
         "***   loop  = %p (%d)\n",
         base, pc, pcmax, (int)(pcmax - pc), pcloop, (int)(pcloop - pc));

  for (ref = F->nk; ref < REF_BIAS; ref++) {
    switch (IR(ref)->o) {
    case IR_KINT:   vals[ref] = (Word)IR(ref)->i; break;
    case IR_KBASEO: vals[ref] = (Word)(T->base + IR(ref)->i); break;
    case IR_KWORD:  vals[ref] = (Word)(F->kwords[IR(ref)->u]); break;
    default:
      LC_ASSERT(0); break;
    }
    DBG_LVL(2, "%d, %" FMT_WordX "\n", ref - REF_BIAS, vals[ref]);
  }
  vals[REF_BASE] = (Word)base;

  goto *disp[pc->o];

# define DISPATCH_NEXT \
  if (irt_type(pc->t) != IRT_VOID && pc->o != IR_PHI) { \
    if (irt_type(pc->t) == IRT_I32) \
      DBG_LVL(2, "         ===> %" FMT_Int "\n", vals[pcref]); \
    else \
      DBG_LVL(2, "         ===> 0x%" FMT_WordX "\n", vals[pcref]); } \
  ++pc; ++pcref; \
  if (LC_UNLIKELY(pc >= pcmax)) { pc = pcloop; pcref = F->nloop + 1; } \
  if (pc->o != IR_NOP) { \
    DBG_LVL(2, "[%d] ", pcref - REF_BIAS); \
    IF_DBG_LVL(2, printIR(F, *pc)); } \
  goto *disp[pc->o]

 op_NOP:
 op_FRAME:
 op_RET:
 op_LOOP:
  DISPATCH_NEXT;

 op_PHI:
  {
    /* PHI nodes represent parallel assignments, so as soon as we
       discover the first PHI node, we perform all assignments in
       parallel. */
    LC_ASSERT(nphis > 0);
    u2 i;
    DBG_LVL(3, "             ( ");
    for (i = 0; i < nphis; i++) {
      DBG_LVL(3, "%d ", irref_int(pc[i].op2));
      phibuf[i] = vals[pc[i].op2];
    }
    DBG_LVL(3, ") --> ( ");
    for (i = 0; i < nphis; i++) {
      DBG_LVL(3, "%d ", irref_int(pc[i].op1));
      vals[pc[i].op1] = phibuf[i];
    }
    DBG_LVL(3, ")  [%d phis]\n", (int)nphis);
    pc += nphis - 1;
    //vals[pc->op1] = vals[pc->op2];
    DISPATCH_NEXT;
  }

 op_LT:
  recordEvent(EV_CMP, 0);
  if (!((WordInt)vals[pc->op1] < (WordInt)vals[pc->op2]))
    goto guard_failed;
  DISPATCH_NEXT;

 op_GE:
  recordEvent(EV_CMP, 0);
  if (!((WordInt)vals[pc->op1] >= (WordInt)vals[pc->op2]))
    goto guard_failed;
  DISPATCH_NEXT;

 op_LE:
  recordEvent(EV_CMP, 0);
  if (!((WordInt)vals[pc->op1] <= (WordInt)vals[pc->op2]))
    goto guard_failed;
  DISPATCH_NEXT;

 op_GT:
  recordEvent(EV_CMP, 0);
  if (!((WordInt)vals[pc->op1] > (WordInt)vals[pc->op2]))
    goto guard_failed;
  DISPATCH_NEXT;

 op_EQ:
  recordEvent(EV_CMP, 0);
  if (!((WordInt)vals[pc->op1] == (WordInt)vals[pc->op2])) {
    goto guard_failed;
  }
  DISPATCH_NEXT;

 op_NE:
  recordEvent(EV_CMP, 0);
  if (!((WordInt)vals[pc->op1] != (WordInt)vals[pc->op2]))
    goto guard_failed;
  DISPATCH_NEXT;

 op_ADD:
  recordEvent(EV_ALU, 0);
  vals[pcref] = vals[pc->op1] + vals[pc->op2];
  DISPATCH_NEXT;

 op_SUB:
  recordEvent(EV_ALU, 0);
  vals[pcref] = vals[pc->op1] - vals[pc->op2];
  DISPATCH_NEXT;

 op_MUL:
  recordEvent(EV_MUL, 0);
  vals[pcref] = (WordInt)vals[pc->op1] * (WordInt)vals[pc->op2];
  DISPATCH_NEXT;

 op_DIV:
  recordEvent(EV_REMDIV, 0);
  if (LC_LIKELY(vals[pc->op2] != 0))
    vals[pcref] = (WordInt)vals[pc->op1] / (WordInt)vals[pc->op2];
  else
    LC_ASSERT(0);
  DISPATCH_NEXT;

 op_REM:
  recordEvent(EV_REMDIV, 0);
  if (LC_LIKELY(vals[pc->op2] != 0))
    vals[pcref] = (WordInt)vals[pc->op1] % (WordInt)vals[pc->op2];
  else
    LC_ASSERT(0);
  DISPATCH_NEXT;

 op_FREF:
  vals[pcref] = (Word)(((Closure*)vals[pc->op1])->payload + (pc->op2 - 1));
  DISPATCH_NEXT;

 op_FLOAD:
  recordEvent(EV_LOAD, 0);
  vals[pcref] = *((Word*)vals[pc->op1]);
  DISPATCH_NEXT;

 op_SLOAD:
  recordEvent(EV_LOAD, 0);
  vals[pcref] = base[pc->op1];
  DISPATCH_NEXT;

 op_ILOAD:
  recordEvent(EV_LOAD, 0);
  vals[pcref] = (Word)getInfo(vals[pc->op1]);
  DISPATCH_NEXT;

 op_NEW:
  if (!ir_issunken(pc)) {
    // do actual allocation on trace
    HeapInfo *hp = &F->heap[pc->op2];
    int j;
    recordEvent(EV_ALLOC, hp->nfields + 1);
    Closure *cl = allocClosure(wordsof(ClosureHeader) + hp->nfields);
    setInfo(cl, (InfoTable*)vals[pc->op1]);
    for (j = 0; j < hp->nfields; j++) {
      cl->payload[j] = vals[getHeapInfoField(F, hp, j)];
    }
    vals[pcref] = (Word)cl;
  } else {
    vals[pcref] = 0;  // to trigger an error if accessed
  }
  DISPATCH_NEXT;

 op_UPDATE:
  {
    recordEvent(EV_UPDATE, 0);
    Closure *oldnode = (Closure *)vals[pc->op1];
    Closure *newnode = (Closure *)base[pc->op2];
    setInfo(oldnode, (InfoTable*)&stg_IND_info);
    oldnode->payload[0] = (Word)newnode;
    DISPATCH_NEXT;
  }

 op_RLOAD:
 op_FSTORE:
 op_RENAME:


 op_BNOT: op_BAND: op_BOR: op_BXOR:
 op_BSHL: op_BSHR: op_BSAR:
 op_BROL: op_BROR:

  // These should never be executed.
 op_BASE:
 op_KINT:
 op_KWORD:
 op_KBASEO:
  LC_ASSERT(0);

 guard_failed:
  DBG_PR("Exiting at %d\n", pcref - REF_BIAS);

  {
    int i;
    SnapShot *snap = 0;
    SnapEntry *se;
    for (i = 0; i < F->nsnap; i++) {
      if (F->snap[i].ref == pcref) {
        snap = &F->snap[i];
        break;
      }
    }
    LC_ASSERT(snap != 0);
    snap->count++;
    se = F->snapmap + snap->mapofs;
    DBG_PR("Snapshot: %d, Snap entries: %d, slots = %d\n",
           i, snap->nent, snap->nslots);
    recordEvent(EV_EXIT, snap->nent);
    for (i = 0; i < snap->nent; i++, se++) {
      BCReg s = snap_slot(*se);
      IRRef r = snap_ref(*se);

      DBG_PR("base[%d] = ", s - 1);
      base[s] = restoreValue(F, vals, r);

      IF_DBG_LVL(1, printSlot(stderr, base + s); fprintf(stderr, "\n"));
      //DBG_PR("0x%" FMT_WordX "\n", base[s]);
    }
    DBG_PR("Base slot: %d\n", se[1]);
    //    se[1] = 
    T->pc = (BCIns *)F->startpc + (int)se[0];
    T->base = base + se[1];
    T->top = base + snap->nslots;
    //printFrame(T->base, T->top);
    return 0;
  }

 stop:
  return 1;
}
コード例 #16
0
ファイル: FakeVMeModel.cpp プロジェクト: chisomiloks/vme-nmpc
void FakeVMeModel::seed(xyth) { recordEvent('S'); }
コード例 #17
0
ファイル: FakeVMeModel.cpp プロジェクト: chisomiloks/vme-nmpc
fptype FakeVMeModel::getTargetDistance() const noexcept {
  recordEvent('D');
  return distanceToTarget;
}
コード例 #18
0
ファイル: robert.cpp プロジェクト: barzooka/robert
int main(int argc, char* argv[])
{
    if (argc > 6)
    {
        print_usage();
        return 2; 
    }

    char* eventFilePath = NULL;

    int repeat = 1;
    int interval = -1;

    int repeatInterval = 1000;

    for (int i = 1; i < argc; i++)
    {
        char* arg = *(argv + i);
        if (!strncmp(arg, "-r:", 3))
        {
            repeat = atoi(arg + 3);
        }
        else if (!strncmp(arg, "-i:", 3))
        {
            interval = atoi(arg + 3) * 1000;
        }
        else if (!strncmp(arg, "-ri:", 4))
        {
            repeatInterval = atoi(arg + 4) * 1000;
        }
        else if (!strcmp(arg, "-d"))
        {
            gDebug = 1;
        }
        else if (!strcmp(arg, "-h"))
        {
            print_usage();
            return 0;
        }
        else if (!strcmp(arg, "-rec"))
        {
            return recordEvent("./event_queue");
        }
        else if (!strncmp(arg, "-rec:", 5))
        {
            return recordEvent(arg + 5);
        }
        else
        {
            if (i == 1 && strncmp(arg, "-", 1))
            {
                eventFilePath = argv[1];
            }
            else
            {
                printf("Unkown parameter %s\n", arg);
                print_usage();
                return 2;
            }
        }
    }

    memset(gFds, 0, sizeof(device_fd_map_t) * MAX_FD);

    if (repeat >= MAX_REPEAT)
    {
        printf("Repeat times %d limit exceed.\n", MAX_REPEAT - 1);
    }

    printf("Play with REPEATE=%d, INTERVAL=%d\n", repeat, interval);

    // control the repeat
    for (int r = 0; r != repeat; r = (r + 1) % MAX_REPEAT)
    {
        // open recorded event queue.
        FILE* file = NULL;

        if (eventFilePath)
        {
            file = fopen(eventFilePath, "rt");
            if (!file)
            {
                printf("Can not open file %s, is it exists?\n", eventFilePath);
                return 1;
            }
        }
        else
        {
            printf(">> No event file specified. Using stdin instead. <<\n");
            file = stdin;
            if (repeat != 1)
            {
                printf("WARNING: -r parameters can not be used while using stdin.\n");
                printf("         Reseting to -r:1\n");
                repeat = 1;
            }
        }

        char* first,* last;
        char buffer[1024];
        int sec = 0, usec = 0;
        char devicePath[256];
        unsigned int type = 0, code = 0, arg = 0;
        usecs_t timeOffset = 0;
        bool timeOffsetSet = false;
        usecs_t lastEventTime = 0;

        // starts playback
        while (fgets(buffer, 1024, file) != NULL)
        {
            sec = usec = -1;
            PRINT_IF(gDebug, "Parsing %s\n", buffer);
            splite(buffer, &first, &last);

            // try android 4.0 output style
            sscanf(first, "%d-%d: %s", &sec, &usec, devicePath);

            if (sec == -1 || usec == -1)
            {
                //try android 4.1 & 4.2 output style
                sscanf(first, "[%d.%d] %s", &sec, &usec, devicePath);
                if (sec == -1 || usec == -1)
                {
                    printf("Skiping invalid line: %s\n", buffer);
                    continue;  // This line is not a valid event record
                }
            }

            sscanf(last, "%x %x %x", &type, &code, &arg);

            PRINT_IF(gDebug, "Event Timestamp=%d.%ds\n", sec, usec);
            int fd = getOrOpenFd(devicePath);
            // Calculating times to sleep
            usecs_t sleepTime = 0;

            // event time stamp
            usecs_t time = combineTime(sec, usec);

            if (!timeOffsetSet)
            {
                timeOffsetSet = true;
                timeOffset = systemTime() - time;
            }

            sleepTime = (time + timeOffset) - systemTime();

            if (interval > 0)
            {
                usleep(interval);
            }
            else if (interval == 0)
            {
            }
            else if (sleepTime > 0)
            {
                PRINT_IF(gDebug || sleepTime > 1000000 /* 1s */, "Sleep %lld.%llds\n", sleepTime / 1000000, sleepTime % 1000000);
                usleep(sleepTime);
            }

            PRINT_IF(gDebug, "-> %s: %d, %d, %d\n", devicePath, type, code, arg);

            if (sendevent(fd, type ,code, arg) != 0)
                exit(0);
        }
        fclose(file);
        if (repeat < 0)
            printf ("Done playback [ %d / Forever ]\n", r + 1);
        else
            printf ("Done playback [ %d / %d ]\n", r + 1, repeat);
        if (repeatInterval > 0 && r + 1 != repeat)
            usleep(repeatInterval);
    }
    clearFds();
    printf("All done\n");
    exit(0);
}
コード例 #19
0
// ----------------------------------------------------------------------------
bool qMRMLTreeViewEventTranslator::translateEvent(QObject *Object,
                                             QEvent *Event,
                                             int EventType,
                                             bool &Error)
{
  Q_UNUSED(Error);
  
  qMRMLTreeView* treeView = NULL;
  for(QObject* test = Object; treeView == NULL && test != NULL; test = test->parent())
    {
    treeView = qobject_cast<qMRMLTreeView*>(test);
    }
//  qMRMLTreeView* treeView = qobject_cast<qMRMLTreeView*>(Object);
  if(!treeView)
    {
    return false;
    }

  // For the custom action when we have a right click
  QMenu* menu = NULL;
  for(QObject* test = Object; menu == NULL && test != NULL ; test = test->parent())
    {
    menu = qobject_cast<QMenu*>(test);
    }
  if (menu)
    {
    if(Event->type() == QEvent::KeyPress)
      {
      QKeyEvent* e = static_cast<QKeyEvent*>(Event);
      if(e->key() == Qt::Key_Enter)
        {
        QAction* action = menu->activeAction();
        if(action)
          {
          QString which = action->objectName();
          if(which == QString::null)
            {
            which = action->text();
            }
          if (which != "Rename" && which != "Delete" )
            {
            emit recordEvent(menu, "activate", which);
            }
          }
        }
      }
    if(Event->type() == QEvent::MouseButtonRelease)
      {
      QMouseEvent* e = static_cast<QMouseEvent*>(Event);
      if(e->button() == Qt::LeftButton)
        {
        QAction* action = menu->actionAt(e->pos());
        if (action && !action->menu())
          {
          QString which = action->objectName();
          if(which == QString::null)
            {
            which = action->text();
            }
          if (which != "Rename" && which != "Delete" )
            {
            emit recordEvent(menu, "activate", which);
            }
          }
        }
      }
    return true;
    }

  // We want to stop the action on the QDialog when we are renaming
  // and let passed the action for the "set_current".
  QInputDialog* dialog = NULL;
  for(QObject* test = Object; dialog == NULL && test != NULL; test = test->parent())
    {
    dialog = qobject_cast<QInputDialog*>(test);
    if(dialog)
      {
      // block actions on the QInputDialog
      return true;
      }
    }

  if(Event->type() == QEvent::Enter && Object == treeView)
    {
    if(this->CurrentObject != Object)
      {
      if(this->CurrentObject)
        {
        disconnect(this->CurrentObject, 0, this, 0);
        }
      this->CurrentObject = Object;

      connect(treeView, SIGNAL(destroyed(QObject*)),
              this, SLOT(onDestroyed(QObject*)));
      connect(treeView, SIGNAL(currentNodeRenamed(QString)),
              this, SLOT(onCurrentNodeRenamed(QString)));

      // Can be better to do it on the model to recover the QModelIndex
      connect(treeView, SIGNAL(currentNodeDeleted(const QModelIndex&)),
              this, SLOT(onCurrentNodeDeleted(const QModelIndex&)));
      connect(treeView, SIGNAL(decorationClicked(QModelIndex)),
              this, SLOT(onDecorationClicked(QModelIndex)));

      connect(treeView->sceneModel(), SIGNAL(aboutToReparentByDragAndDrop(vtkMRMLNode*,vtkMRMLNode*)),
              this, SLOT(onAboutToReparentByDnD(vtkMRMLNode*,vtkMRMLNode*)));
      }
    return this->Superclass::translateEvent(Object, Event, EventType, Error);
    }

  return this->Superclass::translateEvent(Object, Event, EventType, Error);
}
コード例 #20
0
ファイル: FakeVMeModel.cpp プロジェクト: chisomiloks/vme-nmpc
void FakeVMeModel::seed(xyth position, fp_point2d target) {
  auto displacement = target - fp_point2d{position.x, position.y};
  distanceToTarget = std::sqrt(dot(displacement, displacement));
  recordEvent('S');
}
コード例 #21
0
// ----------------------------------------------------------------------------
void qMRMLTreeViewEventTranslator::onCurrentNodeRenamed(const QString & newName)
{
  emit recordEvent(this->CurrentObject, "currentNodeRenamed", newName);
}
コード例 #22
0
ファイル: FakeVMeModel.cpp プロジェクト: chisomiloks/vme-nmpc
void FakeVMeModel::computeForecast() noexcept { recordEvent('F'); }
コード例 #23
0
ファイル: FakeVMeModel.cpp プロジェクト: chisomiloks/vme-nmpc
void FakeVMeModel::computeTrackingErrors() noexcept { recordEvent('E'); }
コード例 #24
0
ファイル: jackmidi.cpp プロジェクト: ViktorNova/los
void MidiJackDevice::eventReceived(jack_midi_event_t* ev)/*{{{*/
{
    MidiRecordEvent event;
    event.setB(0);

    // NOTE: From LOS-2. Not done here in LOS-1 (yet).
    // move all events 2*segmentSize into the future to get
    // jitterfree playback
    //
    //  cycle   n-1         n          n+1
    //          -+----------+----------+----------+-
    //               ^          ^          ^
    //               catch      process    play
    //
    //      const SeqTime* st = audio->seqTime();

    unsigned pos = audio->pos().frame();

    event.setTime(pos + ev->time);

    event.setChannel(*(ev->buffer) & 0xf);
    int type = *(ev->buffer) & 0xf0;
    int a = *(ev->buffer + 1) & 0x7f;
    int b = *(ev->buffer + 2) & 0x7f;
    event.setType(type);
    switch (type)
    {
        case ME_NOTEON:
        case ME_NOTEOFF:
        case ME_CONTROLLER:
            event.setA(*(ev->buffer + 1));
            event.setB(*(ev->buffer + 2));
            break;
        case ME_PROGRAM:
        case ME_AFTERTOUCH:
            event.setA(*(ev->buffer + 1));
            break;

        case ME_PITCHBEND:
            event.setA(((b << 7) + a) - 8192);
            break;

        case ME_SYSEX:
        {
            int type = *(ev->buffer) & 0xff;
            switch (type)
            {
                case ME_SYSEX:

                    // TODO: Deal with large sysex, which are broken up into chunks!
                    // For now, do not accept if the last byte is not EOX, meaning it's a chunk with more chunks to follow.
                    if (*(((unsigned char*) ev->buffer) + ev->size - 1) != ME_SYSEX_END)
                    {
                        printf("MidiJackDevice::eventReceived sysex chunks not supported!\n");
                        return;
                    }

                    //event.setTime(0);      // mark as used
                    event.setType(ME_SYSEX);
                    event.setData((unsigned char*) (ev->buffer + 1), ev->size - 2);
                    break;
                case ME_MTC_QUARTER:
                case ME_SONGPOS:
                case ME_CLOCK:
                case ME_TICK:
                case ME_START:
                case ME_CONTINUE:
                case ME_STOP:
                    return;
                default:
                    printf("MidiJackDevice::eventReceived unsupported system event 0x%02x\n", type);
                    return;
            }
        }
            break;
        default:
            printf("MidiJackDevice::eventReceived unknown event 0x%02x\n", type);
            //printf("MidiJackDevice::eventReceived unknown event 0x%02x size:%d buf:0x%02x 0x%02x 0x%02x ...0x%02x\n", type, ev->size, *(ev->buffer), *(ev->buffer + 1), *(ev->buffer + 2), *(ev->buffer + (ev->size - 1)));
            return;
    }

    if (midiInputTrace)
    {
        printf("MidiInput<%s>: ", name().toLatin1().constData());
        event.dump();
    }

#ifdef JACK_MIDI_DEBUG
    printf("MidiJackDevice::eventReceived time:%d type:%d ch:%d A:%d B:%d\n", event.time(), event.type(), event.channel(), event.dataA(), event.dataB());
#endif

    // Let recordEvent handle it from here, with timestamps, filtering, gui triggering etc.
    recordEvent(event);
}/*}}}*/
コード例 #25
0
// ----------------------------------------------------------------------------
void ctkTreeComboBoxEventTranslator::onCurrentIndexChanged(const QString& text)
{
  emit recordEvent(this->CurrentObject, "indexChanged", text);
}