Beispiel #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    qDebug() << "MainWindow::MainWindow() - ThreadId: " << QThread::currentThreadId();

    x1 = new QVector<double>(INIT_DATA_SIZE);
    y1 = new QVector<double>(INIT_DATA_SIZE);
    y2 = new QVector<double>(INIT_DATA_SIZE);
    y3 = new QVector<double>(INIT_DATA_SIZE);
    y4 = new QVector<double>(INIT_DATA_SIZE);

    ui->setupUi(this);
    m_kldatabase = new KLDatabase(this);

    m_updatePlotTimer = new QTimer(this);
    m_updatePlotTimer->setInterval(5000);

    m_startAquisitionTimer = new QTimer(this);
    m_startAquisitionTimer->setSingleShot(true);


    m_acquisitionThread = new QThread(this);
    m_reader = new ReadDataWorker(m_kldatabase);

    m_reader->moveToThread(m_acquisitionThread);

    QObject::connect(m_startAquisitionTimer, SIGNAL(timeout()), this, SLOT(startAquisition()) );

    QObject::connect(m_acquisitionThread, SIGNAL(started()), m_reader, SLOT(process()) );
    QObject::connect(m_acquisitionThread, SIGNAL(finished()), m_reader, SLOT(deleteLater()) );
    QObject::connect(m_acquisitionThread, SIGNAL(finished()), m_acquisitionThread, SLOT(deleteLater()));

    QObject::connect(m_reader, SIGNAL(newData()), this, SLOT(newData()) );
    QObject::connect(m_reader, SIGNAL(readErrno(int)), this, SLOT(handleErrNo(int)) );

    QObject::connect(m_updatePlotTimer, SIGNAL(timeout()), this, SLOT(onDrawPlot()) );

    QObject::connect(ui->pushButton_1, SIGNAL(clicked()), this, SLOT(selectLongTimespan()) );
    QObject::connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(selectMediumTimespan()) );
    QObject::connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(selectShortTimespan()) );
    QObject::connect(this,SIGNAL(drawPlot()),this,SLOT(onDrawPlot()) );

    QObject::connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(onMenuExit()) );

    m_initKl = new InitWidget(this);
    m_initKl->show();
    m_pressUsb = new PressUsb(this);
    m_pressUsb->hide();
    m_timeInterval = TimeInterval::LONG;
    m_tickSpacing = TickSpacing::DAYS;

    setButtonActive(ui->pushButton_1);

    // initialize plot
    makePlot();

    m_startAquisitionTimer->start(500);

}
Beispiel #2
0
bool Core::loadEncryptedSave(QByteArray& data)
{
    if (!Settings::getInstance().getEncryptTox())
        GUI::showWarning(tr("Encryption error"), tr("The .tox file is encrypted, but encryption was not checked, continuing regardless."));

    size_t fileSize = data.size();
    int error = -1;
    QString a(tr("Please enter the password for the %1 profile.", "used in load() when no pw is already set").arg(Settings::getInstance().getCurrentProfile()));
    QString b(tr("The previous password is incorrect; please try again:", "used on retries in load()"));
    QString dialogtxt;

    if (pwsaltedkeys[ptMain]) // password set, try it
    {
        QByteArray newData(fileSize-TOX_PASS_ENCRYPTION_EXTRA_LENGTH, 0);
        if (tox_pass_key_decrypt((uint8_t*)data.data(), fileSize, pwsaltedkeys[ptMain],
                                 (uint8_t*)newData.data(), nullptr))
        {
            data = newData;
            Settings::getInstance().setEncryptTox(true);
            return true;
        }

        dialogtxt = tr("The profile password failed. Please try another?", "used only when pw set before load() doesn't work");
    }
    else
    {
        dialogtxt = a;
    }

    uint8_t salt[TOX_PASS_SALT_LENGTH];
    tox_get_salt(reinterpret_cast<uint8_t *>(data.data()), salt);

    do
    {
        QString pw = GUI::passwordDialog(tr("Change profile"), dialogtxt);

        if (pw.isEmpty())
        {
            clearPassword(ptMain);
            return false;
        }
        else
        {
            setPassword(pw, ptMain, salt);
        }

        QByteArray newData(fileSize-TOX_PASS_ENCRYPTION_EXTRA_LENGTH, 0);
        error = !tox_pass_key_decrypt((uint8_t*)data.data(), data.size(), pwsaltedkeys[ptMain],
                                 (uint8_t*)newData.data(), nullptr);
        if (!error)
            data = newData;

        dialogtxt = a + "\n" + b;
    } while (error != 0);

    Settings::getInstance().setEncryptTox(true);
    return true;
}
void SerialPort::readFromFile(void)
{
    static void *pointer = nullptr;

    char data[50];
    std::memset(data, '\0', 50);

    pointer = memchr(buffer+offsetR, '\n', offsetW);

    if(pointer != NULL){
        std::memcpy((void*)data, (void*)(buffer+offsetR), ((char*)pointer-(buffer+offsetR)));
        offsetR += (char*)pointer-(buffer+offsetR) + 1;

        QString tmp = QString::fromUtf8(data);
        //DEBUG("recv : " + tmp);

        float t,d,f;
        d = tmp.section(' ', 0, 0).toFloat();
        t = tmp.section(' ', 1, 1).toFloat();
        f = tmp.section(' ', 2, 2).toFloat();

        emit newData(t,d,f);
    }

}
Beispiel #4
0
bool WorldServer::loadNPCData() {
	for (unsigned int i = 0; i < this->npcFile->getRowCount(); i++) {
		NPCData newData(this->npcFile, i);
		this->npcData.push_back(newData);
	}
	return true;
}
Beispiel #5
0
void ServerSktTcp::newConnection()
{
	QTcpServer* server = qobject_cast<QTcpServer*>(sender());
	if (!server) return;

	QTcpSocket* client = server->nextPendingConnection();
	while (client)
	{
		Conn* conn = new Conn;
		if (!conn)
		{
			client->deleteLater();
		}
		else
		{
			client->setProperty(PROP_CONN, qVariantFromValue((void*)conn));

			conn->client = client;
			conn->key = TK::ipstr(client->peerAddress(),client->peerPort(), true);

			connect(client, SIGNAL(readyRead()), this, SLOT(newData()));
			connect(client, SIGNAL(destroyed(QObject*)), this, SLOT(close(QObject*)));
			connect(client, SIGNAL(disconnected()), client, SLOT(deleteLater()));
			connect(client, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error()));

			setCookie(conn->key, conn);
		}
		client = server->nextPendingConnection();
	}
}
void QxrdDataProcessorThreaded::idleInt16Image(QcepInt16ImageDataPtr image, bool liveView)
{
  QcepMutexLocker lock(__FILE__, __LINE__, image->mutex());
  int height = image->get_Height();
  int width  = image->get_Width();
  int nres = image-> get_SummedExposures();
  int npixels = width*height;
  if (nres <= 0) nres = 1;
  double avgraw = 0;
  quint16 *img = image->data();

  for (int i=0; i<npixels; i++) {
    avgraw += *img++;
  }

  set_AverageRaw(avgraw/npixels/nres);
  set_Average(get_AverageRaw() - get_AverageDark());

  if (liveView) {
    if (qcepDebug(DEBUG_PROCESS)) {
      printMessage("Image Live View");
    }

    QcepDoubleImageDataPtr corrected = takeNextFreeImage(image->get_Width(), image->get_Height());
    QcepDoubleImageDataPtr dark      = darkImage();

    corrected->copyFrom(image);
    subtractDarkImage(corrected, dark);

    newData(corrected, QcepMaskDataPtr());

    m_LiveData = corrected;
  }
}
InterpolatingGraph::InterpolatingGraph(QCustomPlot *plot, const DoubleSeries &d, PlotSettings::ScalingMode scalingMode, PlotSettings::ScaleType scaleType) :
    Graph(plot),
    series(d),
    plot(plot),
    lastUpdate(-1),
    currentMin(std::numeric_limits<double>::max()),
    currentMax(std::numeric_limits<double>::min()),
    currentScalingMode(PlotSettings::NOSCALING),
    currentScaleType(PlotSettings::LINSCALE)
{
    setObjectName("InterpolatingGraph");
    connect(&series, SIGNAL(newData(qint64)), this, SLOT(onNewData(qint64)));
    connect(&series, SIGNAL(offsetChanged()), this, SLOT(onOffsetChanged()));

    graph = plot->addGraph();
    // Ensure value axis is visible.
    plot->yAxis->setVisible(true);
    plot->yAxis->setGrid(true);

    configureAppearance(graph);
    initialize(graph, series);
    rescale(scalingMode, scaleType);

    updatePlot(scalingMode);
}
int NetScanningController::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: newData((*reinterpret_cast< const QList<Device*>(*)>(_a[1]))); break;
        case 1: infInformation((*reinterpret_cast< SVT_NotifyType(*)>(_a[1]))); break;
        case 2: deviceCountChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: newDeviceNotify((*reinterpret_cast< SVT_NotifyType(*)>(_a[1]))); break;
        case 4: routerTypeChanged(); break;
        case 5: gatewayChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 6: onNewData((*reinterpret_cast< SVT_NotifyType(*)>(_a[1]))); break;
        case 7: onInfInformation((*reinterpret_cast< SVT_NotifyType(*)>(_a[1]))); break;
        case 8: onCountChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 9: onNode2Device((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Device*(*)>(_a[2]))); break;
        case 10: onDeviceDataChanged((*reinterpret_cast< const Device(*)>(_a[1]))); break;
        case 11: onRefresh(); break;
        case 12: onSubscribeData((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 13: startScan(); break;
        default: ;
        }
        _id -= 14;
    }
    return _id;
}
Beispiel #9
0
/*!
 * \brief Operator -
 */
Data2D Data2D::operator-(const Data2D& source) const
{
	// Construct copy of current data
	Data2D newData(*this);
	
	// Check array sizes
	if (x_.nItems() != source.x_.nItems())
	{
		msg.print("Can't - these Data2D together, since they are of differing sizes (%i vs %i).\n", x_.nItems(), source.x_.nItems());
		return newData;
	}

	// Subtact source data from this data
	for (int n=0; n<x_.nItems(); ++n)
	{
		// Check x values
		if (fabs(x_.value(n) - source.x_.value(n)) > OPTOLERANCE)
		{
			msg.print("Can't - these Data2D, since the x axes are different.\n");
			return newData;
		}
		newData.y_[n] -= source.y_.value(n);
	}
	
	newData.splineInterval_ = -1;
	
	return newData;
}
Beispiel #10
0
// Get slices for storage based on needed size of display
void TumblerWindow::setSlice(TumblerStruct *xtum)
{
  int xsize, ysize;
  if (xtum->slice)
    sliceFree(xtum->slice);
  if (xtum->stslice)
    sliceFree(xtum->stslice);
  if (xtum->bwslice)
    sliceFree(xtum->bwslice);
  if (xtum->count)
    sliceFree(xtum->count);
  if (xtum->highres){
    xsize = ysize = xtum->ms * xtum->zoom;
    if (xtum->stereo && xsize > xtum->width / 2)
	xsize = xtum->width / 2;
  }else{
    xsize = ysize = xtum->ms;
  }

  xtum->slice   = sliceCreate(xsize, ysize, SLICE_MODE_SHORT);
  xtum->stslice = sliceCreate(xsize, ysize, SLICE_MODE_SHORT);
  xtum->bwslice = sliceCreate(xsize, ysize, xtum->vi->rawImageStore);
  xtum->count   = sliceCreate(xsize, ysize, SLICE_MODE_SHORT);
  newData(xtum);
  return;
}
Beispiel #11
0
      /**
       *  Post-condition: size of capacity is at least 'requiredCapacity'
       */
      void ensureCapacity(size_t requiredCapacity)
      {
        // Check if we have to resize our capacity.
        if (m_capacity < requiredCapacity)
        {
          // suppose, the capacity will be doubled
          size_t newCapacity = m_capacity * 2;
          // But, if it's not enough:
          if (requiredCapacity > m_capacity * 2)
            newCapacity = requiredCapacity;

          // Let's allocate the new buffer
          std::unique_ptr<T[]> newData(new T[newCapacity]);

          // Copy the old buffer's content.
          // memcpy can be used, since we don't need the copy constructors
          std::memcpy(newData.get(), m_data.get(), m_capacity * sizeof(T));

          // Set the new buffer.
          // We must not free the old buffer, unique_ptr takes care.
          // Both reset() and release() are noexcept functions, so exception-safety is ok.
          m_data = std::move(newData);

          // At last, update to our new capacity.
          m_capacity = newCapacity;
        }
      }
Beispiel #12
0
int main(){
	//int n;
	//printf("Please enter number of planets:\n");
	//scanf("%d", &n);
	plot = fopen("List.txt","w");
	table = fopen("Table.txt", "a");
	data1 = fopen("Data1.txt","r");
	data2 = fopen("Data2.txt", "w+");
	int i;
	planet** planetArray = (planet**)malloc(n*sizeof(planet *));
	planet** updateArray = (planet**)malloc(n*sizeof(planet *));
	for(i = 0; i < n; i++){
		//planetArray[i] = initPlanet();		//For manual input of planet data
		planetArray[i] = initPlanetFile();		//For file input of data
	}
	for(i = 0; i < n; i++){
		updateArray[i] = initPlanetArray();
	}
	int j;
#pragma acc kernels
	for(j = 0; j < n; j++){
		iterate(planetArray, updateArray, j, n);
	}
	for(i = 0; i < n; i++){
		newData(*updateArray[i]);
		printPlanet(*updateArray[i]);
	}
	return 0;
}
Beispiel #13
0
void Image::applyPalette(const Palette& palette)
{
    vector<uint8_t> newData(width_ * height_ * 4);

    const T* input = reinterpret_cast<const T*>(data_.data());
    const T* inputEnd = input + width_ * height_;

    uint8_t* output = newData.data();

    while(input < inputEnd)
    {
        T paletteIndex = *input & (palette.colors.size() - 1);
        Palette::Color color = palette.colors[paletteIndex];

        *output++ = color.blue;
        *output++ = color.green;
        *output++ = color.red;
        *output++ = color.alpha;

        input++;
    }

    data_ = move(newData);
    format_ = PixelFormat::kA8R8G8B8;
    updateHasAlpha();
}
Beispiel #14
0
void CameraDialog::newConnection()
{
    QTcpSocket* client = m_server.nextPendingConnection();
    qDebug()<< "newConnection" << client;
    while (client)
    {
//		Conn* conn = new Conn;
//		if (!conn)
//		{
//			client->deleteLater();
//		}
//		else
//		{
//			client->setProperty(PROP_CONN, qVariantFromValue((void*)conn));

//			conn->client = client;
//			conn->key = TK::ipstr(client->peerAddress(),client->peerPort(), true);

            connect(client, SIGNAL(readyRead()), this, SLOT(newData()));
//            connect(client, SIGNAL(destroyed(QObject*)), this, SLOT(close(QObject*)));
            connect(client, SIGNAL(disconnected()), client, SLOT(deleteLater()));
//			connect(client, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error()));

//			setCookie(conn->key, conn);
//		}
        client = m_server.nextPendingConnection();
    }
}
Beispiel #15
0
void PlaterCalibrator::initAll()
{
    _rx = 0.0;
    _ry = 0.0;
    _rz = 0.0;
    connect(ComModule::getInstance(), SIGNAL(newData(QByteArray)),this,SLOT(parseMCode(QByteArray)));
}
Beispiel #16
0
void PortRs232::run(){
    if(isRunning) return;
    serialPort = new QSerialPort(config->get("_setup_","port"));

    if(serialPort->open(QIODevice::ReadWrite)){;
        portSetup();  //Note: on Windows settings must be called after serialPort->open, otherwise we get garbage when device is plugged for the fist time
        isRunning = true;
        readyEmitted = false;
        serialPort->flush();
        while((isRunning || sendBytes.length() > 0 )&& serialPort && serialPort->isOpen()){
            if(!readyEmitted && isRunning && mainwindow->isPluginReady()) {emit ready(portID); readyEmitted = true;}
            //receive
            if(serialPort->bytesAvailable() > 0) emit newData(serialPort->readAll());
            //send, data is queed from the GUI thread so we need to lock this section so both threads do not modify sendBytes at same time
            sendMutex.lock();
                if(sendBytes.length()){
                    serialPort->write(sendBytes);
                    qDebug() << "sent data:" << sendBytes.length();
                    sendBytes.clear();
                }
            sendMutex.unlock();
            qApp->processEvents();
        }
    }else{
        emit message("Could not open port "+config->get("_setup_","port")+"\nMake sure the port is available and not used by other applications.","critical");
    }

    isRunning = false;
    if(serialPort->isOpen()) serialPort->close();
    delete serialPort;
    emit stopped();
}
Beispiel #17
0
// imports data in an external text file into the hash table
void CSC120Dictionary::load()
{
	char tempName[20];
	float tempPrice;
	int tempStock, tempKey;

	ifstream merchandise("input.dat");
	if (!merchandise)
	{
		cerr << "\nI need a data file";
		exit(1);
	}

	// read data and place in hash table accordingly
	while ( !merchandise.eof() )
	{
		merchandise >> tempKey;
		merchandise >> tempPrice;
		merchandise >> tempStock;
		merchandise >> tempName;

		DataRecord newData(tempPrice, tempStock, tempName);
		insert(tempKey, newData);
	}
	
	cout << "\n\tData has been loaded from an external data file\n";
	merchandise.close();
	return;
}
Beispiel #18
0
void QTermDataHandler::parseMsg(QByteArray msg, QByteArray addr)
{   //ch    lat         lng
    //2     3456 789    abcde f
    //n     hhmm.mmm    hhhmm.mmm
    qDebug() << QString("Message size: %1").arg(msg.size());
    if (msg.size() < 32)
        return;

    GasInfoItem item;
    if (msg.at(2) <= maxID && msg.at(2) >= 0)
        item.ch = msg.at(2);
    else
        return;

    int t = addr[0];
    t = (t << 8) + (unsigned char)addr[1];
    t = (t << 8) + (unsigned char)addr[2];
    if(!addrs.contains(item.ch))
        addrs[item.ch] = t;

    memcpy(&item.h2s, msg.data()+12, 4);
    memcpy(&item.so2, msg.data()+16, 4);
    memcpy(&item.fel, msg.data()+20, 4);
    memcpy(&item.o2, msg.data()+24, 4);
    memcpy(&item.co, msg.data()+28, 4);
    float flat, flng; double lat, lng;
    memcpy(&flat, msg.data()+4, 4);
    memcpy(&flng, msg.data()+8, 4);
    lat = flat; lng = flng;

    lat = nmeaDegreesToDecimal(lat); lng = nmeaDegreesToDecimal(lng);

    item.location = QGeoCoordinate(lat, lng);
    emit newData(item);
}
Beispiel #19
0
void fn_make (inode_state& state, const wordvec& words){
   DEBUGF ('c', state);
   DEBUGF ('c', words);
   if (words.size() <= 0){
      cout << "mkdir: missing operand" << endl;
      return;
   }
   wordvec newData(words.begin()+2, words.end());

   wordvec pathvec = split (words[1], "/");
   string fullpath = "";
   string filename = *(pathvec.end()-1);
   for (auto it = pathvec.begin(); it != pathvec.end()-1; ++it)
      fullpath += (*it + "/");
   inode_ptr res = resolvePath(fullpath, state.getCwd()); //resulting path before filename
   if (res == nullptr) return;
   inode_ptr file = res->getContents()->getNode(filename); //search directory for filename if existing
   if (file != nullptr && res != nullptr) {
      if(file->isDirectory()) //getContents()->getNode(words[1])
         return;
      file->getContents()->writefile(newData);
      return;
   }
   res->getContents()->mkfile(filename);
   res->getContents()->getNode(filename)->getContents()->writefile(newData);

   inode_ptr ogcwd = state.getCwd();
   //inode_ptr newFile = state.getCwd()->getContents()->mkfile(words[1]);
   //wordvec newData(words.begin()+2, words.end());
   //newFile->getContents()->writefile(newData);
}
void QRF24NetworkWorker::listenForNewData(QRF24Network *networkNode)
{
#ifdef TESTING
    struct payload_test
    {
        unsigned long ms;
        unsigned long counter;
    };
    if (networkNode->available()) {
        QRF24NetworkHeader header;
        payload_test payload;
        networkNode->read(header,&payload,sizeof(payload));
        qDebug() << QString("%1, frame #%2").arg(payload.ms).arg(payload.counter);
        Q_EMIT newData(QString("%1, frame #%2").arg(payload.ms, payload.counter), header.from_node);
    }
    delayMicroseconds(m_listeningTime * 1000 / 100);
    return;
#endif


    if (networkNode->available()) {
        qDebug() << "Data available!";
        QRF24NetworkHeader header;
        char buff[1024];
        int  size = networkNode->read(header, buff, sizeof(buff));
        if (!size) {
            Q_EMIT error(tr("Reading failed."));
        }
        //     Q_EMIT newData(QString(data), header.from_node);
    }
    delayMicroseconds(m_listeningTime * 1000 / 100);
}
Beispiel #21
0
void DisplayClient::appClientReceiveMulticast(int servicePort, SYNTRO_EHEAD *multiCast, int len)
{
	// make sure this is for us
	if (servicePort != m_receivePort) {
		logWarn(QString("Multicast received to invalid port %1").arg(servicePort));
		free(multiCast);
		return;
	}

	// and the size we expect
	if (len != (sizeof(SYNTRO_RECORD_HEADER) + sizeof(quint32))) {
		logWarn(QString("Multicast length is unexpected : %1").arg(len - sizeof(SYNTRO_RECORD_HEADER)));
		free(multiCast);
		return;
	}

	// unpack the record, first get a pointer to the SYNTRO_RECORD_HEADER
	SYNTRO_RECORD_HEADER *head = (SYNTRO_RECORD_HEADER *)(multiCast + 1);

	// the led data is immediately after the SYNTRO_RECORD_HEADER in a single quint32
	quint32 *values = (quint32 *)(head + 1);

	// the BoneLedDisplay class catches this signal
	emit newData(*values);

	// ack the data
	clientSendMulticastAck(servicePort);

	// always free the record you are given
	free(multiCast);
}
int applypatch(int argc, char * argv[]){
    if (argc!=4) {
        std::cout<<"patch command parameter:\n oldFileName diffFileName outNewFileName\n";
        return 0;
    }
    const char* oldFileName=argv[1];
    const char* diffFileName=argv[2];
    const char* outNewFileName=argv[3];
    std::cout<<"old :\"" <<oldFileName<< "\"\ndiff:\""<<diffFileName<<"\"\nout :\""<<outNewFileName<<"\"\n";
    clock_t time0=clock();
    {
        TFileStreamInput oldData(oldFileName);
        TFileStreamInput diffData(diffFileName);
        const hpatch_StreamPos_t newDataSize=readNewDataSize(diffData);
        TFileStreamOutput newData(outNewFileName,newDataSize);

        clock_t time1=clock();
        if (!patch_stream(&newData, &oldData, &diffData)){
            std::cout<<"  patch_stream run error!!!\n";
            exit(3);
        }
        clock_t time2=clock();
        std::cout<<"  patch_stream ok!\n";
        std::cout<<"oldDataSize : "<<oldData.streamSize<<"\ndiffDataSize: "<<diffData.streamSize<<"\nnewDataSize : "<<newDataSize<<"\n";
        std::cout<<"\npatch   time:"<<(time2-time1)*(1000.0/CLOCKS_PER_SEC)<<" ms\n";
    }
    clock_t time3=clock();
    std::cout<<"all run time:"<<(time3-time0)*(1000.0/CLOCKS_PER_SEC)<<" ms\n";
    return 0;
}
Beispiel #23
0
bool OBJECT_WAREHOUSE_CLASS::store(string identifier, BASE_WAREHOUSE_ITEM_DATA_CLASS* data_ptr)

//  DESCRIPTION     : Store given data in the warehouse.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	UINT index;

	// check for valid data
	if (data_ptr == NULL) return false;

	// wait for access to warehouse
	waitSemaphore();

	// first check if the same identifier has already been used
	if (search(identifier, data_ptr->getWidType(), &index))
	{
		// remove existing item - the new data will simply replace the old
		itemM.removeAt(index);
	}

	// store the new data
	WAREHOUSE_ITEM_CLASS newData(identifier, data_ptr);
	itemM.add(newData);

	// release access to warehouse
	postSemaphore();

	// return result
	return true;
}
Beispiel #24
0
bool MaskedImage::advect(const VectorField2D & velocity, double deltaT,
	UArray<double> & inOutX, UArray<double> & inOutY, double errorTolerance, SInt32 maximumTimeStepCount)
{
	if(deltaT == 0.0)
		return true;
	ParticleIntegrator integrator(velocity);
	double nextTimeStep = 0.1*deltaT;
	double minimumTimeStep = fabs(0.1*deltaT/maximumTimeStepCount);

	SInt32 imageSize = getXSize()*getYSize();
	if(inOutX.getSize() != imageSize || inOutY.getSize() != imageSize)
		return false;

	SInt32 maxCount = 1000000; // keeps us from allocating too much memory at a time

	UArray<double> newData(imageSize);
	UArray<bool> newMask(imageSize);

	for(SInt32 imageIndex = 0; imageIndex < imageSize; imageIndex += maxCount)
	{
		SInt32 localCount = std::min(maxCount, imageSize-imageIndex);
		// set up the points, one for each output pixel
		UArray<double> points(2*localCount);

		for(SInt32 index = 0; index < localCount; index++)
		{
			points[2*index] = inOutX[index + imageIndex];
			points[2*index+1] = inOutY[index + imageIndex];
		}

		// integrate the pixels backward in time to their locations in the original image
		if(!integrator.integrate(points, deltaT, 0, errorTolerance, nextTimeStep, minimumTimeStep, maximumTimeStepCount))
			return false;

		// interpolate the advected image at the points in the original image
		UArray<double> pixelX(localCount), pixelY(localCount), advectedPixels(localCount);
		UArray<bool> advectedMask(localCount);
		for(SInt32 index = 0; index < localCount; index++)
		{
			pixelX[index] = points[2*index];
			pixelY[index] = points[2*index+1];
			inOutX[index + imageIndex] = points[2*index];
			inOutY[index + imageIndex] = points[2*index+1];
		}

		maskedInterpolate(pixelX, pixelY, advectedPixels, advectedMask);

		// copy the advected pixels and mask back into this image
		for(SInt32 index = 0; index < localCount; index++)
		{
			newData[index + imageIndex] = advectedPixels[index];
			newMask[index + imageIndex] = advectedMask[index];
		}
	}
	getData().copy(newData);
	mask.copy(newMask);

	return true;
}
Beispiel #25
0
void ProxyTunnel::doOpen()
{
    if(m_server)
    {
        connect(m_server, SIGNAL(newData(QByteArray)), SIGNAL(dataRead(QByteArray)));
        this->SetState(st_connected);
    }
}
SIG_DESCRIPTOR *DescriptorFromPEiD(const char *Data)
{
	// This is identical to IDA, just replace '??' with '?'
	std::string newData(Data);
	StringReplace(newData, "??", "?");

	return DescriptorFromIDA(newData.c_str());
}
std::vector<Poco::SharedPtr<ContactData> >
ConvManagerService::getParticipants()
{
    std::vector<Poco::SharedPtr<ContactData> >contacts;

    ParticipantRefs participants;
    m_conversation->GetParticipants(participants,
        Conversation::OTHER_CONSUMERS);

    unsigned int size = participants.size();
    for (unsigned int i = 0; i < size; ++i) {
        // Get the SkypeParticipant.
        SkypeParticipant::Ref participant(participants[i]);

        if (m_conversationMode == Call) {
            // If the participant is live, add it to the list.
            if (participant->isLive()) {
                // Get the contact for this participant.
                SkypeContact::Ref contact =
                    Util::contactFromParticipant(participant);

                // Convert contact in ContactData structure.
                Poco::SharedPtr<ContactData>
                    newData(Util::dataFromContact(contact));

                // Add to the container.
                contacts.push_back(newData);
            }
        }
        else { // m_conversationMode == Chat.
            SkypeContact::Ref contact =
                Util::contactFromParticipant(participant);

            // Convert contact in ContactData structure.
            Poco::SharedPtr<ContactData>
                newData(Util::dataFromContact(contact));

            // Add to the container.
            contacts.push_back(newData);
        }
    }

    return contacts;
}
bool STObject::setType (const SOTemplate& type)
{
    boost::ptr_vector<SerializedType> newData (type.peek ().size ());
    bool valid = true;

    mType = &type;

    BOOST_FOREACH (const SOElement * elem, type.peek ())
    {
        bool match = false;

        for (boost::ptr_vector<SerializedType>::iterator it = mData.begin (); it != mData.end (); ++it)
            if (it->getFName () == elem->e_field)
            {
                // matching entry, move to new vector
                match = true;

                if ((elem->flags == SOE_DEFAULT) && it->isDefault ())
                {
                    WriteLog (lsWARNING, STObject) << "setType( " << getFName ().getName () << ") invalid default "
                                                   << elem->e_field.fieldName;
                    valid = false;
                }

                newData.push_back (mData.release (it).release ()); // CAUTION: This renders 'it' invalid
                break;
            }

        if (!match)
        {
            // no match found
            if (elem->flags == SOE_REQUIRED)
            {
                WriteLog (lsWARNING, STObject) << "setType( " << getFName ().getName () << ") invalid missing "
                                               << elem->e_field.fieldName;
                valid = false;
            }

            newData.push_back (makeNonPresentObject (elem->e_field).release ());
        }
    }

    BOOST_FOREACH (const SerializedType & t, mData)
    {
        // Anything left over must be discardable
        if (!t.getFName ().isDiscardable ())
        {
            WriteLog (lsWARNING, STObject) << "setType( " << getFName ().getName () << ") invalid leftover "
                                           << t.getFName ().getName ();
            valid = false;
        }
    }

    mData.swap (newData);
    return valid;
}
int MrsvrPlotCanvas::newData(int size, FXchar* str)
{
#ifdef DEBUG_MRSVR_PLOT_CANVAS
  printf("MrsvrPlotCanvas::newData()\n");
#endif // DEBUG_MRSVR_PLOT_CANVAS
  
  int r = newData(size);
  setLegend(r, str);
  return r;
}
Beispiel #30
0
void        //处理接受数据
CUdpReceive::processTheDatagram( std::size_t bytesRecvd )
{
    QByteArray tData( m_cDataBuffer , bytesRecvd );
    int id = StructId( m_cDataBuffer );
    if( id != 1057 )    emit newData( tData );
    if( id == 1003 )    emit newDISMonitor( tData );
    if( id == 1002 )    emit newMotion( tData );
    receiveData();
}