Exemplo n.º 1
0
void GameLogic::setupNewComputers()
{
    QRectF const scene = mView->sceneRect();
    mAgent = new WorkStation(mGenerator, stations::hacker);
    mView->setItemToScene(mAgent);
    mAgent->setPos(scene.right() - 110, scene.center().y());
    connect(this, SIGNAL(newWorkingDay()), mAgent, SLOT(dataTransfer()));

    mDevelopers = new WorkStation(mGenerator, stations::target);
    mView->setItemToScene(mDevelopers);
    mDevelopers->setPos(scene.left() + 10, scene.center().y() - scene.height() / 10);
    connect(mDevelopers, SIGNAL(secretDepartInfected()), this, SLOT(gameOver()));

    mUsersCount = (mGenerator->rand() % (maxUsers - minUsers + 1)) + minUsers;
    for (int i = 0; i < mUsersCount; i++)
    {
        WorkStation *newStation = new WorkStation(mGenerator);
        mView->setItemToScene(newStation);
        mUsers.append(newStation);
        connect(this, SIGNAL(newWorkingDay()), newStation, SLOT(dataTransfer()));

        // dbl click event filter doesnt work on graphicsview items
        connect(this, SIGNAL(energyChanged(bool)), newStation, SLOT(energyChange(bool)));
        connect(newStation, SIGNAL(updated()), this, SLOT(startReloadTime()));
    }

    trafficReloadTime = (mUsersCount < maxUsers / 2)? 2 : 1;
}
Exemplo n.º 2
0
// PRE: instr is not the halt instruction
// Behaviour: Decides which of the 4 instruction types instr is and passes it to its subsequent function
// i.e. branch(instr), dataTransfer(instr) etc.
bool decodeAndExecute(uint32_t instr) {
    bool isBranch = extractBit(instr, bit27);
    bool isDataTransfer = extractBit(instr, bit26);
    bool mulCheck = extractBit(instr, bit25);
    uint32_t pattern = extractBits(instr, PATTERN_UPPER, PATTERN_LOWER);

    if (isBranch) {
        // puts("Executing branch instruction\n");
        branch(instr);
        return true;
    }
    else if (isDataTransfer) {
        // puts("Executing data transfer instruction\n");
        dataTransfer(instr);
    }
    else if (!mulCheck && pattern == MUL_PATTERN) {
        // puts("Executing multiplier instruction\n");
        iMultiply(instr);
    }
    else {
        // puts("Executing data process instruction\n");
        dataProcess(instr);
    }

    return false;
}
Exemplo n.º 3
0
void MainWindow::dataReceive(QByteArray data)
{
    QByteArray voltage,current,resistance,time,status;// Raw data
    voltage = data.left(13);
    data.remove(0,14);
    current = data.left(13);
    data.remove(0,14);
    resistance = data.left(13);
    data.remove(0,14);
    time = data.left(13);
    data.remove(0,14);
    status = data.left(13);

    Number voltageTR,currentTR,resistanceTR,timeTR,statusTR;//Transferred data
    voltageTR = dataTransfer(voltage);
    currentTR = dataTransfer(current);
    resistanceTR = dataTransfer(resistance);


    if(voltageTR.simple)
    {
        ui->L_voltage->setText(voltageTR.numbersimple.c);
        ui->LCD_voltage->display(QString("%1").arg(voltageTR.numbersimple.base,0,'f',3));
    }
    else
    {
        float number;
        number = voltageTR.exponent.base * pow(10.0,voltageTR.exponent.power);
        ui->L_voltage->setText(" ");
        ui->LCD_voltage->display(QString("%1").arg(number,0,'E',2));
    }

    ui->L_current->setText(currentTR.numbersimple.c);
    ui->LCD_current->display(QString("%1").arg(currentTR.numbersimple.base,0,'f',3));

}
	void GeomData::initilize(pMesh theMesh){
		if (theMesh->getDim()==2){
			numElem = M_numFaces(theMesh);
			elemtype = 3;
		}
		else{
			numElem = M_numRegions(theMesh);
			elemtype = 4;
		}
		calculateNumEdges(theMesh);					// calculate number of data to be stored
		calculateNumElements(theMesh);
		calculateNumBDRYEdges(theMesh);
		calculateNumBDRYFaces(theMesh);
		calculateNumNodes(theMesh);
		calculateNumBdryNodes(theMesh);
		allocatePointers(M_numVertices(theMesh),theMesh->getDim());	// allocate storage
		calculateEdgeProperties(theMesh);							// fill storage
		dataTransfer(theMesh);
		calculate_extFaceVersor(theMesh);
		mappingNodesIds(theMesh);									// map data to find them quickly
	}