예제 #1
0
void EthereumMiner::processWorkPackage(QString headerHash, QString seedHash, QString boundary) {
    setCurrentStep(Mining);
    emit receivedWorkPackage(headerHash, seedHash, boundary);

    dev::h256 newHeaderHash(headerHash.toStdString());
    dev::h256 newSeedHash(seedHash.toStdString());

    if(_currentWorkPackage.seedHash != newSeedHash) {
        qDebug() << "Grabbing DAG for" << seedHash;
    }

    if(!(dag = dev::eth::EthashAux::full(newSeedHash, true, [&](unsigned progressCount) {
       emit dagCreationProgress(progressCount);
       setCurrentStep(BuildingDAG);
       return 0;
    }))) {
       emit dagCreationFailure();
    }

    if(_configuration.precomputeNextDAG) {
        dev::eth::EthashAux::computeFull(dev::sha3(newSeedHash), true);
    }

    if(newHeaderHash != _currentWorkPackage.headerHash) {
        _currentWorkPackage.headerHash = newHeaderHash;
        _currentWorkPackage.seedHash = newSeedHash;
        _currentWorkPackage.boundary = dev::h256(dev::fromHex(
                                    boundary.toStdString()
                                ), dev::h256::AlignRight);
        _powFarm.setWork(_currentWorkPackage);
    }
}
예제 #2
0
EthereumMiner::EthereumMiner(QObject *parent) :
    QObject(parent) {
    _ethereumProtocol = new EthereumProtocol(this);

    // When losing connection, handle this.
    connect(_ethereumProtocol->stratumClient(), SIGNAL(disconnectedFromServer()), this, SLOT(handleDisconnect()));
    // Once we login to the server, we want to login in right after that.
    connect(_ethereumProtocol->stratumClient(), SIGNAL(connectedToServer()), this, SLOT(login()));
    // Once we have logged in, query for work.
    connect(_ethereumProtocol, SIGNAL(eth_login(bool)), _ethereumProtocol, SLOT(eth_getWork()));
    // Evertime we receive a work package, work on it.
    connect(_ethereumProtocol, SIGNAL(eth_getWork(QString,QString,QString)), this, SLOT(processWorkPackage(QString,QString,QString)));

    setCurrentStep(Halted);
}
예제 #3
0
CCuttingSectorsDlg::CCuttingSectorsDlg(CWnd* pParent, UINT _iCurrentStep)
	: CDialogEx(CCuttingSectorsDlg::IDD, pParent)
	, m_pEditStringDATA(NULL)
	, m_strTextOut(_T(""))
	, m_pTextOutput(NULL)
	, m_pMainText(NULL)
	, m_iNumber( 0 )
	, m_iMin(0)
	, m_iMax(0)
{
	m_EditStyle = DIGIT_STYLE;
	m_strData = _T("");
	setCurrentStep(_iCurrentStep);
	m_enStateProgram = enStart;
	m_strHeader = _T("");
}
예제 #4
0
파일: game.cpp 프로젝트: nelsonbss/rubiks
//----------------------------------------------------------------------
void game::guiInput(int in){

	//any gui input resets reset timer
	//start timer to go back to inactive state
	if(step != -1){
		goToAttractStepI =  ofGetElapsedTimef();
	}

	if(in == 'b'){
		ofToggleFullscreen();
	}

	//////
	if(step == -1){
		//on attract / inactive state
		step = 0;
		goToAttractStepI =  ofGetElapsedTimef();
	}
	////////////////////////////////////////////step 0 inputs
	////////////////////////////////////////////step 0 inputs
	////////////////////////////////////////////step 0 inputs
	else if(step == 0){
		//waiting for an object to be selected
		//it cam be from the shapes on the center
		// or from the object menu on the side
		////////////////////////////////////////////////////////
		//////////////////object menu on the side
		//waiting for shape to be selected
		if(in == '1') {
			//load object recieves (object id, boolean position, display position) 
			loadObject(1,slicingPos,posP);
		}
		if(in == '2') {
			loadObject(2,slicingPos,posP);
		}
		if(in == '3') {
			loadObject(3,slicingPos,posP);
		}
		if(in == '4') {
			loadObject(4,slicingPos,posP);
		}
		if(in == '5') {
			loadObject(5,slicingPos,posP);
		}
		if(in == '6') {
			loadObject(6,slicingPos,posP);
		}
		if(in == '7') { 
			loadObject(7,slicingPos,posP);
		}
		//if(in == '8') { 
		//	loadObject(8,objectPos,posP);
		//}
		if(in == '9') {
			prepareDrawing();
		}
	}
	////////////////////////////////////////////step 1 inputs
	////////////////////////////////////////////step 1 inputs
	////////////////////////////////////////////step 1 inputs
	else if(step == 1){
		//is showing object with flat color
		//selected an object
		if(in == 'n') {
			//go to step 2
			setCurrentStep(2);
			//show armature
		} else{
			//waiting for shape to be selected
			if(in == '1') {
				//user can change the selected object
				clearDisplayedObject();
				//load object recieves (object id, boolean position, display position) 
				loadObject(1,slicingPos,posP); //pos.z its the torus radious
			}
			if(in == '2') {
				clearDisplayedObject();
				loadObject(2,slicingPos,posP);
			}
			if(in == '3') {
				clearDisplayedObject();
				loadObject(3,slicingPos,posP);
			}
			if(in == '4') {
				clearDisplayedObject();
				loadObject(4,slicingPos,posP);
			}
			if(in == '5') {
				clearDisplayedObject();
				loadObject(5,slicingPos,posP);
			}
			if(in == '6') {
				//user can change the selected object
				clearDisplayedObject();
				loadObject(6,slicingPos,posP);
			}
			if(in == '7') {
				//user can change the selected object
				clearDisplayedObject();

				loadObject(7,slicingPos,posP);
			}
			/*if(in == '8') { 
			loadObject(8,objectPos,posP);
			}*/
			if(in == '9') { 
				clearDisplayedObject();
				prepareDrawing();
			}
		}
	}
	////////////////////////////////////////////step 2 inputs
	////////////////////////////////////////////step 2 inputs
	////////////////////////////////////////////step 2 inputs
	else if(step == 2){
		//waiting for armature to be selected
		if(in == '1') {
			//select armature 1
			loadArmature(1); 
		}
		if(in == '2') {
			//select armature 2
			loadArmature(2);
		}
	}
	////////////////////////////////////////////step 3 inputs
	////////////////////////////////////////////step 3 inputs
	////////////////////////////////////////////step 3 inputs
	else if(step == 3){
		//armature was selected
		////showing armature    another armature can be selected
		if(in == '1') {
			//select armature 1
			loadArmature(1); 
		}
		if(in == '2') {
			//select armature 2
			loadArmature(2);
		}
		//////////////////////////////move all armature
		if(in == 'l') {
			ofVec3f p = ofVec3f (5,0,0);
			moveA(p);
		}
		if(in == 'j') {
			ofVec3f p = ofVec3f (-5,0,0);
			moveA(p);
		}
		if(in == 'i') {
			ofVec3f p = ofVec3f (0,-5,0);
			moveA(p);
		}
		if(in == 'k') {
			ofVec3f p = ofVec3f (0,5,0);
			moveA(p);
		}
		///z movement
		if(in == 'o') {
			ofVec3f p = ofVec3f (0,0,5);
			moveA(p);
		}
		if(in == 'p') {
			ofVec3f p = ofVec3f (0,0,-5);
			moveA(p);
		}//////////////////////////////rotate all armature
		if(in == 'c') {//rotate around y
			ofVec3f r = ofVec3f (0,5,0);
			rotateA(r);
		}
		if(in == 'x') {//rotate around y
			ofVec3f r = ofVec3f (0,-5,0);
			rotateA(r);
		}
		if(in == 'w') {//rotate around x
			ofVec3f r = ofVec3f (5,0,0); //degrees!!!
			rotateA(r);
		}
		if(in == 's') {//rotate around x
			ofVec3f r = ofVec3f (-5,0,0);
			rotateA(r);
		}
		if(in == 'e') {//rotate around z
			ofVec3f r = ofVec3f (0,0,5); //degrees!!!
			rotateA(r);
		}
		if(in == 'd') {//rotate around z
			ofVec3f r = ofVec3f (0,0,-5);
			rotateA(r);
		}
		/////////////////a puzzle can be made
		if(in == 'n') {
			//send the armature rotations to the 3dObject
			applyArmRotations();
			//now we know the offset position from the armature to create-> cutter & slicer
			createCutterSlicer();
			//do slicing
			createPuzzle(posP);//create Puzzle goes to step 4 to show the puzzle
		}
	}
	////////////////////////////////////////////step 4 inputs
	////////////////////////////////////////////step 4 inputs
	////////////////////////////////////////////step 4 inputs
	else if(step == 4){
		//showing puzzle with colors
		//waiting for color change
		if(in == '1') {
			//call color change funtion
			ofFloatColor sc = ofFloatColor (1, 1, 0); //yellow
			ofFloatColor menuColor = ofFloatColor (1, 0, 1); //this color comes from the GUI
			changeColorToColor(sc,menuColor);
		}
		//pressed NEXT
		if(in == 'n') {
			//go to step 5
			setCurrentStep(5);
		}
		///////////////////////////////move all puzzle
		if(in == 'l') {
			SG_VECTOR p = {10,0,0};
			moveP(p);
		}
		if(in == 'j') {
			SG_VECTOR p = {-10,0,0};
			moveP(p);
		}
		if(in == 'i') {
			SG_VECTOR p = {0,-10,0};
			moveP(p);
		}
		if(in == 'k') {
			SG_VECTOR p = {0,10,0};
			moveP(p);
		}
		/////////////rotate all puzzle  // two finger swipe gesture
		//if(in == 'm') {//rotate right
		//	SG_VECTOR r = {0,10,0};//{0,0.1,0};
		//	rotateP(r);
		//}
		//if(in == 'n') {//rotate left
		//	SG_VECTOR r = {0,-10,0};//{0,-0.1,0};
		//	rotateP(r);
		//}
		//if(in == 'y') {//rotate up
		//	SG_VECTOR r =  {10,0,0};// {0.1,0,0};
		//	rotateP(r);
		//}
		//if(in == 'h') {//rotate down
		//	SG_VECTOR r = {-10,0,0};//{-0.1,0,0};
		//	ofVec3f v;
		//	rotateP(r);
		//}
	}
	////////////////////////////////////////////step 5 inputs
	////////////////////////////////////////////step 5 inputs
	////////////////////////////////////////////step 5 inputs
	else if(step == 5){
		//selected color (or not, its not mandatory)
		//pressed next on color palette step
		//showing puzzle
		//now the puzzle can be played with
		int randcubie=13;//rand()%26;//to follow this cubie for now //this will be decided upon touch, or click on top of puzzle
		if(myPuzzle->isMoving() == false){ //this is to prevent from reading events while puzzle is moving
			if(in == 'u'){
				//undo last move 
				unDo();
			}
			////////////////////////////////////////////// FACE ROTATIONS //////////////////////////////
			if(in == 'z') {
				//do rotationbased ontwo cubies id
				int cubieA = 11;
				int cubieB = 10;
				rotateTwoIds(cubieA,cubieB,true);
			}
			////////////////////////////////////////////// FACE ROTATIONS //////////////////////////////
			////////  x axis  ////  x axis
			if(in == 'q') {
				//clockwise
				SG_VECTOR axis = {1,0,0};
				rotateByIDandAxis(randcubie,axis,true);
			}
			if(in == 'a') {
				//counter clockwise
				SG_VECTOR axis = {1,0,0};
				rotateByIDandAxis(randcubie,axis,false);
			}
			////////  y axis  ////  y axis
			if(in == 'w') {
				//clockwise
				SG_VECTOR axis = {0,1,0};
				rotateByIDandAxis(randcubie,axis,true);
			}if(in == 's') {
				//counter clockwise
				SG_VECTOR axis = {0,1,0};
				rotateByIDandAxis(randcubie,axis,false);
			}
			////////  z axis  ////  z axis
			if(in == 'e') {
				//clockwise
				SG_VECTOR axis = {0,0,1};
				rotateByIDandAxis(randcubie,axis,true);
			}if(in == 'd') {
				//counter clockwise
				SG_VECTOR axis = {0,0,1};
				rotateByIDandAxis(randcubie,axis,false);
			}
		}
		////////////////////////////////////move all puzzle
		if(in == 'l') {
			SG_VECTOR p = {10,0,0};
			moveP(p);
		}
		if(in == 'j') {
			SG_VECTOR p = {-10,0,0};
			moveP(p);
		}
		if(in == 'i') {
			SG_VECTOR p = {0,-10,0};
			moveP(p);
		}
		if(in == 'k') {
			SG_VECTOR p = {0,10,0};
			moveP(p);
		}
		/////////////rotate all puzzle  // two finger swipe gesture
		//if(in == 'm') {//rotate right
		//	SG_VECTOR r = {0,2,0};//{0,0.1,0};
		//	rotateP(r);
		//}
		//if(in == 'n') {//rotate left
		//	SG_VECTOR r = {0,-2,0};//{0,-0.1,0};
		//	rotateP(r);
		//}
		//if(in == 'y') {//rotate up
		//	SG_VECTOR r =  {2,0,0};// {0.1,0,0};
		//	rotateP(r);
		//}
		//if(in == 'h') {//rotate down
		//	SG_VECTOR r = {-2,0,0};//{-0.1,0,0};
		//	ofVec3f v;
		//	rotateP(r);
		//}
		//if(in == 'o') {//rotate c
		//	SG_VECTOR r =  {0,0,-2};// {0.1,0,0};
		//	rotateP(r);
		//}
		//if(in == 'p') {//rotate cc
		//	SG_VECTOR r = {0,0,2};//{-0.1,0,0};
		//	ofVec3f v;
		//	rotateP(r);
		//}
	}else if(step == 6){
		////////////////////////////extrusion
		if(in == 'e') {
			//take drawing data
			//check for existing drawing
			if(myCanvas->drawingExists()){
				//make extruded object
				if(extrudeObject(myCanvas->getPolyline())){

				}else{
					prepareDrawing();
				}
			}
		}else if(in == 's'){
			ofPolyline *draw =  new ofPolyline();
			//star
			draw->addVertex(ofVec2f(-5,-210));
			draw->addVertex(ofVec2f(60,-60));
			draw->addVertex(ofVec2f(210,-45));
			draw->addVertex(ofVec2f(105,60));
			draw->addVertex(ofVec2f(150,210));
			draw->addVertex(ofVec2f(-5,135));
			draw->addVertex(ofVec2f(-150,210));
			draw->addVertex(ofVec2f(-105,60));
			draw->addVertex(ofVec2f(-210,-45));
			draw->addVertex(ofVec2f(-60,-60));
			draw->addVertex(ofVec2f(-5,-210));

			//draw->close(); // close the shape
			extrudeObject(draw);
		}
		////////////////////////////////////////////////////////
		//////////////////object menu on the side
		//waiting for shape to be selected
		else if(in == '1') {
			clearDisplayedObject();
			//load object recieves (object id, boolean position, display position) 
			loadObject(1,slicingPos,posP);
		}
		else if(in == '2') {
			clearDisplayedObject();
			loadObject(2,slicingPos,posP);
		}
		else if(in == '3') {
			clearDisplayedObject();
			loadObject(3,slicingPos,posP);
		}
		else if(in == '4') {
			clearDisplayedObject();
			loadObject(4,slicingPos,posP);
		}
		else if(in == '5') {
			clearDisplayedObject();
			loadObject(5,slicingPos,posP);
		}
		else if(in == '6') {
			clearDisplayedObject();
			loadObject(6,slicingPos,posP);
		}
		else if(in == '7') { 
			clearDisplayedObject();
			loadObject(7,slicingPos,posP);
		}
		//if(in == '8') { 
		//	loadObject(8,objectPos,posP);
		//}
		else if(in == '9') { 
			clearDisplayedObject();
			prepareDrawing();
		}
	}

	/////////////////////////////////////////////////////////////////
	////////////////RESART button can work on any step, its not showed on step 1 (object selected)
	if(in == 'r'){
		//tell a game to restart 
		restart();
	}
}
예제 #5
0
void EthereumMiner::login() {
    setCurrentStep(LoggingIn);
    _ethereumProtocol->eth_login(_configuration.username, _configuration.password);
}
예제 #6
0
void EthereumMiner::connectToServer() {
    setCurrentStep(Connecting);
    _ethereumProtocol->stratumClient()->connectToServer(_configuration.server, _configuration.port);
}
예제 #7
0
void EthereumMiner::stopMining() {
    setCurrentStep(Halted);
    QMetaObject::invokeMethod(this, "halt");
}
예제 #8
0
void EthereumMiner::startMining() {
    setCurrentStep(Starting);
    QMetaObject::invokeMethod(this, "begin");
}