Esempio n. 1
0
// process a single acquisition
int RtDataViewer::process(ACE_Message_Block *mb) {
  ACE_TRACE(("RtDataViewer::process"));

  RtStreamMessage *msg = (RtStreamMessage*) mb->rd_ptr();

  // get the current time
  unsigned int time = msg->getCurrentData()->getDataID().getTimePoint();

  // debug
  getDataStore().getAvailableData();

  RtDataID id;
  // find all data requested
  for(vector<string>::iterator i = dataIds.begin(); i != dataIds.end(); i++) {
    id.setFromString(*i);

    if(id.getTimePoint() != DATAID_NUM_UNSET_VALUE
       && id.getTimePoint() != DATAID_NUM_WILDCARD_VALUE) {
      id.setTimePoint(time);
    }

    cout << "RtDataViewer::process: searching for " << id
         << " from " << *i << endl;

    // find the data with the right ID
    RtData *dat = getDataStore().getData(id);

    if(dat == NULL) {
      cout << "RtDataViewer::process: could not find " << id << endl;
      if(logOutput) {
        stringstream logs("");
        logs << "RtDataViewer::process: could not find " << id << endl;
        log(logs);
      }
    }
    else {
      cout << "RtDataViewer::process: found " << dat->getDataID() << endl;
      if(logOutput) {
        stringstream logs("");
        logs << "RtDataViewer::process: found "
             << dat->getDataID() << endl;
        log(logs);
      }
    }
  }

  return 0;
}
Esempio n. 2
0
void PlotController::handleData(QString qid) {
    RtDataID id;
    id.setFromString(qid.toStdString());

    if (id.getDataName() == NAME_DESIGN) {
        baseline_box->topLeft->setCoords(0, 10);
        baseline_box->bottomRight->setCoords(getNumDataPointsForErrEst(), -10);

        RtDesignMatrix *design =
            static_cast<RtDesignMatrix*>(getDataStore().getData(id));
        updateTRIndicators();
        plotDesign(design);

        roi_plot->xAxis->setRange(0, design->getNumRows());
        roi_plot->replot();
        motion_plot->xAxis->setRange(0, design->getNumRows());
        motion_plot->replot();
    }
    else if (id.getModuleID() == ID_ROICOMBINE) {
        map<string, int>::const_iterator it = roi_graphs.find(id.getRoiID());
        if (it == roi_graphs.end()) {
            it = roi_graphs.insert(
                     pair<string, int>(id.getRoiID(), roi_plot->graphCount())).first;
            roi_plot->addGraph();
            roi_plot->graph(it->second)->setPen(QPen(roi_colormap.getColorForName(
                                                    id.getRoiID())));
            roi_plot->graph(it->second)->setName(QString(id.getRoiID().c_str()));
            roi_plot->legend->setVisible(true);
        }

        RtActivation *val = static_cast<RtActivation*>(getDataStore().getData(id));
        roi_plot->graph(roi_graphs[id.getRoiID()])->addData(id.getTimePoint(),
                val->getPixel(0));
        roi_plot->replot();
    }
    else if (id.getModuleID() == ID_MOTION) {
        plotMotion(static_cast<RtMotion*>(getDataStore().getData(id)));
    }

    if (id.getTimePoint() != DATAID_NUM_UNSET_VALUE &&
            id.getTimePoint() > current_tr) {
        current_tr = id.getTimePoint();
        updateTRIndicators();
    }
}
Esempio n. 3
0
void RtDataStore::setAvailableData(RtDataID dataID) {

  // remove timepoint if one is set
  if(dataID.getTimePoint() != DATAID_NUM_UNSET_VALUE) {
    dataID.setTimePoint(DATAID_NUM_WILDCARD_VALUE);
  }

  // put data id into available data (insert will only add a unique value)
  // TODO will a position iterator add any efficiency here?
  availableData.insert(dataID);

}
Esempio n. 4
0
// get data by id
//
// NOTE: this function is much more efficient if the requested data is
// specified fully, i.e. there are no wildcards in the dataID (see RtDataID.h)
// avoid using wildcards if possible
RtData *RtDataStore::getData(RtDataID dataID) {

  // fill in wildcards (search through available data makes this inefficient)
  if(dataID.hasWildcards()) {
    // find corresponding full id by an exhaustive search through available
    // data
    for(set<RtDataID>::const_iterator id = availableData.begin();
        id != availableData.end(); id++) {
      RtDataID avail = (*id);

      // handle potential timepoint-less data
      unsigned int tp = avail.getTimePoint();
      if(dataID.getTimePoint() != DATAID_NUM_UNSET_VALUE) {
        avail.setTimePoint(DATAID_NUM_WILDCARD_VALUE);
      }
      else {
        avail.setTimePoint(DATAID_NUM_UNSET_VALUE);

      }

      if (avail == dataID) { // == respects wildcards
        // copy, preserving timepoint if not a timepointless datum
        unsigned int origTp = dataID.getTimePoint();
        dataID = avail;

        if(tp != DATAID_NUM_UNSET_VALUE) {
          dataID.setTimePoint(origTp);
        }
        else {
          dataID.setTimePoint(tp);
        }

        break;
      }
    }

    // finally, handle wildcard in timepoint field by using the latest timepoint
    if (dataID.getTimePoint() == DATAID_NUM_WILDCARD_VALUE) {
      dataID.setTimePoint(latestTR);
    }

    if(dataID.hasWildcards()) {
      cerr << "filling in wildcards failed. no match found." << endl;
      return NULL;
    }
  }

  // iterator for map
  map<RtDataID,RtData*,RtDataIDCompare>::const_iterator it;

  mut.acquire();
  it = store.find(dataID);

  // if not found
  if(it == store.end()) {
    mut.release();
    return NULL;
  }
  mut.release();

  return (*it).second;
}