コード例 #1
0
ファイル: slave.c プロジェクト: geoffchu/chuffed
void Slave::solve() {

        thread_no = so.thread_no;

        srand(thread_no+1);
        
        
        clauseSizeLimits.resize(so.num_threads, so.maxClSz);
        goodClausesFrom.resize(so.num_threads, 0);
        numClausesFrom.resize(so.num_threads, 0);
        
        
        checks = rand()%int(report_freq/check_freq);

        MPI_Buffer_attach(malloc(MPI_BUFFER_SIZE), MPI_BUFFER_SIZE);

        if (FULL_DEBUG) fprintf(stderr, "Solving\n");
        sendReport();
        while (receiveJob()) {
                real_time -= wallClockTime();
//              cpu_time -= cpuTime();
                status = engine.search();
                real_time += wallClockTime();
//              cpu_time += cpuTime();
                sendReport();
        }

        sendStats();
}
コード例 #2
0
ファイル: AssignmentClient.cpp プロジェクト: DaveDubUK/hifi
void AssignmentClient::sendStatsPacketToACM() {
    // tell the assignment client monitor what this assignment client is doing (if anything)
    QJsonObject statsObject;
    auto nodeList = DependencyManager::get<NodeList>();

    if (_currentAssignment) {
        statsObject["assignment_type"] = _currentAssignment->getTypeName();
    } else {
        statsObject["assignment_type"] = "none";
    }
    nodeList->sendStats(statsObject, _assignmentClientMonitorSocket);
}
コード例 #3
0
void Slave::readStats(void)
{
    qDebug() << "in" << __FUNCTION__;

    // Empty stats
    stats->clear();

    // Push slave status bits
    stats->push_back(status);

    // Send the latest stats
    sendStats();
}
コード例 #4
0
ファイル: Stats.cpp プロジェクト: mtdxc/licode
  void Stats::processRtcpPacket(char* buf, int length) {
    boost::recursive_mutex::scoped_lock lock(mapMutex_);
    char* movingBuf = buf;
    int rtcpLength = 0;
    int totalLength = 0;

    do {
      movingBuf += rtcpLength;
      RtcpHeader *chead = reinterpret_cast<RtcpHeader*>(movingBuf);
      rtcpLength = (ntohs(chead->length) + 1) * 4;
      totalLength += rtcpLength;
      this->processRtcpPacket(chead);
    } while (totalLength < length);
    sendStats();
  }
コード例 #5
0
ファイル: torrent.cpp プロジェクト: pigApp/pig
void Torrent::stats()
{
    if (!isAborted) {
        handle.flush_cache();

        const qint64 kb_writen = (session.get_cache_status().blocks_written)*16; //((session->get_cache_status().blocks_written)*16)/KB

        emit sendStats((handle.status(2).download_rate/KB), handle.status(2).num_peers,
                       kb_writen, kb_required, n_kb);
        
        if (isDump) {
            if ((kb_writen-kb_skip_global) >= kb_required) {
                isDump = false;
                
                //handle.flush_cache(); //TODO: Recibirlo con un Alert.
               
                QString path_trucho;
                path_trucho = "The.Martian.2015.1080p.WEB-DL.DD5.1.H264-RARBG/The.Martian.2015.1080p.WEB-DL.DD5.1.H264-RARBG.mkv";

                emit sendFile(path_trucho);
                //emit sendFile(QString::fromStdString(storage.file_path(_scene)));
            }
        }

//      if (movie != NULL) {
//          int total_sec = 6658730/1000;
//          int total_mb = 836600/1024;
//          int current_sec = libvlc_media_player_get_time(player->mediaplayer)/1000;
//          qint64 current_mb_to_sec = ((total_sec*(kb_writen/1024))/total_mb);

//          if (current_sec >= 10) {
//              if ((current_sec >= current_mb_to_sec) && libvlc_media_player_is_playing(player->mediaplayer)) {
//                  libvlc_media_player_pause(player->mediaplayer);
//                  qDebug() << "-- PAUSED";
//              } else if ((current_sec <= current_mb_to_sec) && !libvlc_media_player_is_playing(player->mediaplayer)) {
//                  libvlc_media_player_play(player->mediaplayer);
//                  qDebug() << "-- PLAY";
//              }
//          }
//      }
    }
}
コード例 #6
0
alt_u32 RS232_ISR(void* up_dev) {
	if(queue_lock == 1) return alt_ticks_per_second()/1000;
	alt_up_rs232_dev *serial_dev = ((struct alt_up_dev*)up_dev)->RS232_dev;
	unsigned char* cert;
	int i = 0;
	int len = 0;
	switch(*(com.stateMachine)) {
	case startInit:
		cert = sendStartInit();
		sendRS232(serial_dev, cert, 3);
		free(cert);
		cert = NULL;
		com.failReceive = 0;
		return alt_ticks_per_second()/20;
	case waitStart:
		i = 0;
		if((len = alt_up_rs232_get_used_space_in_read_FIFO(serial_dev)) >= 3) {
			do {
				while (alt_up_rs232_get_used_space_in_read_FIFO(serial_dev) == 0);
				alt_up_rs232_read_data(serial_dev, &com.data[i], &com.parity);
				i++;
			} while(i < 3);
			if(checkStartAck(com.data[0]) == 1) {
				setStates(sendStates);
			} else
				setStates(startInit);
		} else {
			com.failReceive++;
			if(com.failReceive > 10)
				setStates(startInit);
		}
		return alt_ticks_per_second()/20;
	case checkClient:
		i = 0;
		if((len = alt_up_rs232_get_used_space_in_read_FIFO(serial_dev)) >= 3) {
			do {
				while (alt_up_rs232_get_used_space_in_read_FIFO(serial_dev) == 0);
				alt_up_rs232_read_data(serial_dev, &com.data[i], &com.parity);
				i++;
			} while(i < 3);
			if(checkAck(com.data) == 1) {
				if(getBit(com.data[0], 1) == 1) {
					setStates(sendAck0);
					com.num_packets = ((int)(com.data[1] << 8))+(int)com.data[2];
					printf("num of packets will be receiving: %d\n", com.num_packets);
				} else
					setStates(sendStates);
			} else
				setStates(sendStates);
		} else {
			com.failReceive++;
			if(com.failReceive > 100) {
				reset(serial_dev);
			}
		}
		return alt_ticks_per_second()/20;
	case sendStates:
		cert = sendStats();
		sendRS232(serial_dev, cert, 3);
		free(cert);
		cert = NULL;
		com.failReceive = 0;
		return alt_ticks_per_second()/20;
	case sendAck0:
		cert = sendAck();
		sendRS232(serial_dev, cert, 3);
		if(cert[1] != 0)
			printf("sth is wrong");
		free(cert);
		cert = NULL;
		com.failReceive = 0;
		return alt_ticks_per_second()/20;
	case receiveData0:
		if((len = alt_up_rs232_get_used_space_in_read_FIFO(serial_dev)) > 2) {
			//read first 2 bytes for header information
			alt_up_rs232_read_data(serial_dev, &com.data[0], &com.parity);
			alt_up_rs232_read_data(serial_dev, &com.data[1], &com.parity);
			struct Packet* p = readPacketHeader(com.data[0], com.data[1]);
			i = 0;
			do {
				while (alt_up_rs232_get_used_space_in_read_FIFO(serial_dev) == 0);
				alt_up_rs232_read_data(serial_dev, &(p->data[i+HEADERSIZE]), &com.parity);
			//	printf("%c", p->data[i+HEADERSIZE]);
				i++;
			} while(p->data_size > i );
			//printf("\n");
			enqueue(com.receivePackets, (void*)p);
			com.index_packets++;
			setStates(sendAck0);
		} else {
			com.failReceive++;
			if(com.failReceive > 100) {
				reset(serial_dev);
			}
		}
		return alt_ticks_per_second()/20;
	case waitClient:
		i = 0;
		if((len = alt_up_rs232_get_used_space_in_read_FIFO(serial_dev)) >= 3) {
			do {
				while (alt_up_rs232_get_used_space_in_read_FIFO(serial_dev) == 0);
				alt_up_rs232_read_data(serial_dev, &com.data[i], &com.parity);
				i++;
			} while(i < 3);
			if(checkAck(com.data) == 1) {
				setStates(sendData0);
			} else {
				com.failReceive++;
				if(com.failReceive > 100)
					setStates(sendStates);
			}
		} else {
			com.failReceive++;
			if(com.failReceive > 100) {
				reset(serial_dev);
			}
		}
		return alt_ticks_per_second()/20;
	case sendData0:
		if(com.packetBuf == NULL) {
			if((com.packetBuf = (struct Packet*)dequeue(com.sendPackets))==NULL) {
				printf("Packet sending fail, queue is empty");
				setStates(sendStates);
				return alt_ticks_per_second()/50;
			}
		} setAck(com.packetBuf, com.host_ack);

		for(i = 0; i< com.packetBuf->data_size+HEADERSIZE; i++) {
			alt_up_rs232_write_data(serial_dev, com.packetBuf->data[i]);
		}
		setStates(waitAck0);
		com.failReceive = 0;
		return alt_ticks_per_second()/20;
	case waitAck0:
		i = 0;
		if((len = alt_up_rs232_get_used_space_in_read_FIFO(serial_dev)) >= 3) {
			do {
				while (alt_up_rs232_get_used_space_in_read_FIFO(serial_dev) == 0);
				alt_up_rs232_read_data(serial_dev, &com.data[i], &com.parity);
				i++;
			} while(i < 3);
			if(checkAck(com.data) == 1) {
				com.index_send_packets++;
				killPacket(&(com.packetBuf));
				if(com.index_send_packets < com.num_send_packets)
					setStates(sendData0);
				else {
					com.index_send_packets = com.num_send_packets = 0;
					setStates(sendStates);
					com.isRdySend = 0;
				}
			} else {
				setStates(sendData0);
			}
		} else {
			com.failReceive++;
			if(com.failReceive > 100) {
				reset(serial_dev);
			}
		}
		return alt_ticks_per_second()/20;
	default:
		break;
	}

	return alt_ticks_per_second()/20;
}
コード例 #7
0
ファイル: NodeList.cpp プロジェクト: JamesLinus/hifi
qint64 NodeList::sendStatsToDomainServer(const QJsonObject& statsObject) {
    return sendStats(statsObject, _domainHandler.getSockAddr());
}
コード例 #8
0
ファイル: protocolgamebase.cpp プロジェクト: samuel2498/nowy
void ProtocolGameBase::sendAddCreature(const Creature* creature, const Position& pos, int32_t stackpos, bool isLogin)
{
	if (!canSee(pos)) {
		return;
	}

	if (creature != player) {
		if (stackpos != -1) {
			NetworkMessage msg;
			msg.addByte(0x6A);
			msg.addPosition(pos);
			msg.addByte(stackpos);

			bool known;
			uint32_t removedKnown;
			checkCreatureAsKnown(creature->getID(), known, removedKnown);
			AddCreature(msg, creature, known, removedKnown);
			writeToOutputBuffer(msg);
		}

		if (isLogin) {
			sendMagicEffect(pos, CONST_ME_TELEPORT);
		}
		return;
	}

	NetworkMessage msg;
	msg.addByte(0x17);

	msg.add<uint32_t>(player->getID());
	msg.add<uint16_t>(0x32); // beat duration (50)

	msg.addDouble(Creature::speedA, 3);
	msg.addDouble(Creature::speedB, 3);
	msg.addDouble(Creature::speedC, 3);

	// can report bugs?
	if (player->getAccountType() >= ACCOUNT_TYPE_TUTOR) {
		msg.addByte(0x01);
	} else {
		msg.addByte(0x00);
	}

	msg.addByte(0x00); // can change pvp framing option
	msg.addByte(0x00); // expert mode button enabled
	msg.addString("http://static.tibia.com/images/store/");
	msg.addByte(3);

	writeToOutputBuffer(msg);

	sendPendingStateEntered();
	sendEnterWorld();
	sendMapDescription(pos);

	if (isLogin) {
		sendMagicEffect(pos, CONST_ME_TELEPORT);
	}

	sendInventoryItem(CONST_SLOT_HEAD, player->getInventoryItem(CONST_SLOT_HEAD));
	sendInventoryItem(CONST_SLOT_NECKLACE, player->getInventoryItem(CONST_SLOT_NECKLACE));
	sendInventoryItem(CONST_SLOT_BACKPACK, player->getInventoryItem(CONST_SLOT_BACKPACK));
	sendInventoryItem(CONST_SLOT_ARMOR, player->getInventoryItem(CONST_SLOT_ARMOR));
	sendInventoryItem(CONST_SLOT_RIGHT, player->getInventoryItem(CONST_SLOT_RIGHT));
	sendInventoryItem(CONST_SLOT_LEFT, player->getInventoryItem(CONST_SLOT_LEFT));
	sendInventoryItem(CONST_SLOT_LEGS, player->getInventoryItem(CONST_SLOT_LEGS));
	sendInventoryItem(CONST_SLOT_FEET, player->getInventoryItem(CONST_SLOT_FEET));
	sendInventoryItem(CONST_SLOT_RING, player->getInventoryItem(CONST_SLOT_RING));
	sendInventoryItem(CONST_SLOT_AMMO, player->getInventoryItem(CONST_SLOT_AMMO));

	sendStats();
	sendSkills();

	//gameworld light-settings
	LightInfo lightInfo;
	g_game.getWorldLightInfo(lightInfo);
	sendWorldLight(lightInfo);

	//player light level
	sendCreatureLight(creature);

	const std::forward_list<VIPEntry>& vipEntries = IOLoginData::getVIPEntries(player->getAccount());

	if (player->isAccessPlayer()) {
		for (const VIPEntry& entry : vipEntries) {
			VipStatus_t vipStatus;

			Player* vipPlayer = g_game.getPlayerByGUID(entry.guid);
			if (!vipPlayer) {
				vipStatus = VIPSTATUS_OFFLINE;
			} else {
				vipStatus = VIPSTATUS_ONLINE;
			}

			sendVIP(entry.guid, entry.name, entry.description, entry.icon, entry.notify, vipStatus);
		}
	} else {
		for (const VIPEntry& entry : vipEntries) {
			VipStatus_t vipStatus;

			Player* vipPlayer = g_game.getPlayerByGUID(entry.guid);
			if (!vipPlayer || vipPlayer->isInGhostMode()) {
				vipStatus = VIPSTATUS_OFFLINE;
			} else {
				vipStatus = VIPSTATUS_ONLINE;
			}

			sendVIP(entry.guid, entry.name, entry.description, entry.icon, entry.notify, vipStatus);
		}
	}

	sendBasicData();
	sendInventory();
	player->sendIcons();
}
コード例 #9
0
void setup(){
	Serial.begin(B2_SERIAL0_BOUND);
	serial0Buffer = "";
	Serial.println("");	// remove dust
	Serial.flush();

	// read pcb type	
	pinMode( PIN_B3_POWER_SENSOR, INPUT );
	boolean power = digitalRead( PIN_B3_POWER_SENSOR );
	if( power == LOW ){
		Serial.println("-chyba 2");
	}else{
		Serial.println("-chyba 3");
	}

	//pcb_type
	disableYZ();
	if(pcb_type == 2 ){		// servos + magicled
		//pinMode(PIN_B2_SERVO_Y, INPUT+INPUT_PULLUP );      // nie pozwalaj na przypadkowe machanie na starcie
		//pinMode(PIN_B2_SERVO_Z, INPUT+INPUT_PULLUP );      // nie pozwalaj na przypadkowe machanie na starcie
		pinMode(PIN_B2_SELF_RESET, INPUT );	
		pinMode(PIN_B2_HALL_X, INPUT + INPUT_PULLUP );
		pinMode(PIN_B2_HALL_Y, INPUT + INPUT_PULLUP );
		pinMode(PIN_B2_WEIGHT, INPUT);

	}else if(pcb_type == 3 ){		// actuators + magicled
		if(YZ_INPUT_ON_DISABLE){
			pinMode(PIN_B3_OUT_Y1, INPUT );		// stop Y
			pinMode(PIN_B3_OUT_Y2, INPUT );		// stop Y		
			pinMode(PIN_B3_OUT_Z1, INPUT );		// stop Z	
			pinMode(PIN_B3_OUT_Z2, INPUT );		// stop Z
		}else{
			pinMode(PIN_B3_OUT_Y1, OUTPUT);
			pinMode(PIN_B3_OUT_Y2, OUTPUT);
			pinMode(PIN_B3_OUT_Z1, OUTPUT);
			pinMode(PIN_B3_OUT_Z2, OUTPUT);
			pinMode(PIN_B3_LIGHT, INPUT );

			digitalWrite(PIN_B3_OUT_Y1, YZ_VALUE_ON_DISABLE);		// stop Y
			digitalWrite(PIN_B3_OUT_Y2, YZ_VALUE_ON_DISABLE);
			digitalWrite(PIN_B3_OUT_Z1, YZ_VALUE_ON_DISABLE);		// stop Z
			digitalWrite(PIN_B3_OUT_Z2, YZ_VALUE_ON_DISABLE);	

		}
		//pinMode(PIN_B3_POWER_SENSOR, INPUT + INPUT_PULLUP );
		pinMode(PIN_B3_POWER_SENSOR, INPUT );	
	}

	// blink led	
	pinMode(PIN_B2_STEPPER_DIR, OUTPUT );
	for(byte i =0; i<pcb_type;i++){
		digitalWrite( PIN_B2_STEPPER_DIR, HIGH );
		delay(100);
		digitalWrite( PIN_B2_STEPPER_DIR, LOW );
		delay(200);
	}
	init_leds();
	setupStepper();

	unsigned long int color = bottom_panels.Color(0,  0,  20 );	
	set_all_leds(color);
	Serial.println("");	// remove dust
	Serial.flush();
	Serial.println("BSTART");

	if(pcb_type == 2 ){		// servos + magicled
		init_hallx(PIN_B2_HALL_X);
	}else if(pcb_type == 3 ){
		init_hallx(PIN_B3_IN_X);
	}

	sendStats( true );
	Serial.flush();
}