Пример #1
0
void play(pthread_cond_t *cond, struct service *service, struct horse *horses, size_t horse_num) {
	init_race(service);

	while(run) {
		_pthread_mutex_lock(service->mfinished);
		if (service->finished) {
			_pthread_mutex_unlock(service->mfinished);

			// send if someone is waiting
			_pthread_cond_broadcast(cond);
check_for_horses:
			_pthread_mutex_lock(service->mcur_run);
			if (!service->cur_run) {
				_pthread_mutex_unlock(service->mcur_run);	
				break;
			}
			else {
				_pthread_mutex_unlock(service->mcur_run);
				_sleep(1, 0);
				goto check_for_horses;
			}
		}
		_pthread_mutex_unlock(service->mfinished);	
		_sleep(1, 0);
		_pthread_cond_broadcast(cond);
	}

	post_race(service, horses, horse_num);
} 
Пример #2
0
Файл: drive.c Проект: ymah/TP5-2
void dmps(int piste,int secteur){
  int i;
  for(i=0;i<16;i++)
    IRQVECTOR[i]= empty_it;


  /* chargement des donnée concernant la piste */
  _out(HDA_DATAREGS,piste>>8);
  _out(HDA_DATAREGS+1,piste & 0x00FF);

  /* chargement des donnée concernant le secteur  */
  _out(HDA_DATAREGS+2,secteur>>8);
  _out(HDA_DATAREGS+3,secteur & 0x00FF);

  /*commande pour positionner la tete de lecture */
  _out(HDA_CMDREG,CMD_SEEK);
  _sleep(HDA_IRQ);

  _out(HDA_DATAREGS,0);
  _out(HDA_DATAREGS+1,1);
  _out(HDA_CMDREG,CMD_READ);
  _sleep(HDA_IRQ);


  for(i=0;i<HDA_SECTORSIZE;i++)
    printf("%x ",MASTERBUFFER[i]);

  return ;
}
Пример #3
0
void zombie()

{
	int s;
	srand((unsigned)time(0));
	s=rand()%4+1;
	switch(s)
	{
	case 1:
		{
			printf("Oh no!You are bitten.You should probably leave now...\nThe zombie seems statified that his job well done and.....\n");
			_sleep(2000);
			printf("Now he's leaving.\n");
			_sleep(2000);
			_pick(uObj_zombie,-1);
			player.health=1;
			condition[Condi_Fakezombiebite]=0;
			break;
		}
	default:
		{
			printf("You alomst got bitten.Thankfully not,you need to go.Like,right now!\n");
			break;
		}
	}
	
}
Пример #4
0
void
do_baud_rate(int argc, char *argv[])
{
    int new_rate, ret, old_rate;
    bool new_rate_set;
    hal_virtual_comm_table_t *__chan;
    struct option_info opts[1];
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
    struct config_option opt;
#endif

    init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, 
              (void **)&new_rate, (bool *)&new_rate_set, "new baud rate");
    if (!scan_opts(argc, argv, 1, opts, 1, 0, 0, "")) {
        return;
    }
    __chan = CYGACC_CALL_IF_CONSOLE_PROCS();
    if (new_rate_set) {
        diag_printf("Baud rate will be changed to %d - update your settings\n", new_rate);
        _sleep(500);  // Give serial time to flush
        old_rate = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_GETBAUD);
        ret = set_console_baud_rate(new_rate);
        if (ret < 0) {
            if (old_rate > 0) {
                // Try to restore
                set_console_baud_rate(old_rate);
                _sleep(500);  // Give serial time to flush
                diag_printf("\nret = %d\n", ret);
            }
            return;  // Couldn't set the desired rate
        }
        old_rate = ret;
        // Make sure this new rate works or back off to previous value
        // Sleep for a few seconds, then prompt to see if it works
        _sleep(3000);  // Give serial time to flush
        if (!verify_action_with_timeout(5000, "Baud rate changed to %d", new_rate)) {
            _sleep(500);  // Give serial time to flush
            set_console_baud_rate(old_rate);
            _sleep(500);  // Give serial time to flush
            return;
        }
#ifdef CYGSEM_REDBOOT_FLASH_CONFIG
        opt.type = CONFIG_INT;
        opt.enable = (char *)0;
        opt.enable_sense = 1;
        opt.key = "console_baud_rate";
        opt.dflt = new_rate;
        flash_add_config(&opt, true);
#endif
    } else {
        ret = CYGACC_COMM_IF_CONTROL(*__chan, __COMMCTL_GETBAUD);
        diag_printf("Baud rate = ");
        if (ret <= 0) {
            diag_printf("unknown\n");
        } else {
            diag_printf("%d\n", ret);
        }
    }
}
Пример #5
0
/*                              requirement is also satisfied.               */
void waitTime(long microsec)
{
    static long tckCyclesPerMicrosec    = 1; /* must be at least 1 */
    long        tckCycles   = microsec * tckCyclesPerMicrosec;
    long        i;


    for(i=0;i<microsec;i++){
        setPort(TCK,0);  /* set the TCK port to low  */
        //usleep(USLEEPTIME);
        setPort(TCK,1);  /* set the TCK port to high */
        //usleep(USLEEPTIME);
    }

    /* This implementation is highly recommended!!! */
    /* This implementation requires you to tune the tckCyclesPerMicrosec 
       variable (above) to match the performance of your embedded system
       in order to satisfy the microsec wait time requirement. */
    //for ( i = 0; i < tckCycles; ++i )
    //{
    //   pulseClock();
    //}

#if 0
    /* Alternate implementation */
    /* For systems with TCK rates << 1 MHz;  Consider this implementation. */
    /* This implementation does not work with Spartan-3AN or indirect flash
       programming. */
    if ( microsec >= 50L )
    {
        /* Make sure TCK is low during wait for XC18V00/XCFxxS */
        /* Or, a running TCK implementation as shown above is an OK alternate */
        setPort( TCK, 0 );

        /* Use Windows Sleep().  Round up to the nearest millisec */
        _sleep( ( microsec + 999L ) / 1000L );
    }
    else    /* Satisfy FPGA JTAG configuration, startup TCK cycles */
    {
        for ( i = 0; i < microsec;  ++i )
        {
            pulseClock();
        }
    }
#endif

#if 0
    /* Alternate implementation */
    /* This implementation is valid for only XC9500/XL/XV, CoolRunner/II CPLDs, 
       XC18V00 PROMs, or Platform Flash XCFxxS/XCFxxP PROMs.  
       This implementation does not work with FPGAs JTAG configuration. */
    /* Make sure TCK is low during wait for XC18V00/XCFxxS PROMs */
    /* Or, a running TCK implementation as shown above is an OK alternate */
    setPort( TCK, 0 );
    /* Use Windows Sleep().  Round up to the nearest millisec */
    _sleep( ( microsec + 999L ) / 1000L );
#endif
}
Пример #6
0
 /* init node */
void CanNode::initCanNode(int can_idx, int node_id)
{
	/* get the channels */
    CAN_MSG msg;
    //Digit input channels
	CAN_ConfigQueue(can_idx,node_id,CAN_RX_QUE,0);
	CAN_ConfigQueue(can_idx,node_id,CAN_RX_QUE,1);
    sendSDO("40 00 60 00");
    _sleep(100);
    if(CAN_ReadMsg(can_idx, node_id,1,&msg) == CAN_OK)
        m_Channels[0] = (int)msg.a_data[4] * 4;
	/*else
		QMessageBox::warning(0,"digit","read error");*/

	 //Digit output channels
	CAN_ConfigQueue(can_idx,node_id,CAN_RX_QUE,0);
	CAN_ConfigQueue(can_idx,node_id,CAN_RX_QUE,1);
    sendSDO("40 00 62 00");
    _sleep(100);
    if(CAN_ReadMsg(can_idx, node_id,1,&msg) == CAN_OK)
        m_Channels[1] = (int)msg.a_data[4] * 4;
	/*else
		QMessageBox::warning(0,"digit","read error");*/

    //IP2302 has 4 digit input channels and 4 digit output channels
    //sendState(00,80);
    //_sleep(1000);
    //if(CAN_ReadMsg(can_idx, node_id,1,&msg) == CAN_OK)
    //{
    //    m_Channels[0] = 4;
    //    m_Channels[1] = 4;
    //}
    //Analog input channels
    CAN_ConfigQueue(can_idx,node_id,CAN_RX_QUE,0);
    CAN_ConfigQueue(can_idx,node_id,CAN_RX_QUE,1);
   sendSDO("40 01 64 00");
    _sleep(100);
    if(CAN_ReadMsg(can_idx, node_id,1,&msg) == CAN_OK)
        m_Channels[2] = (int)msg.a_data[4];
  
	//Analog output channels
    CAN_ConfigQueue(can_idx,node_id,CAN_RX_QUE,0);
    CAN_ConfigQueue(can_idx,node_id,CAN_RX_QUE,1);
    sendSDO("40 11 64 00");
    _sleep(100);
    if(CAN_ReadMsg(can_idx, node_id,1,&msg) == CAN_OK)
        m_Channels[3] = (int)msg.a_data[4];

	//QMessageBox::about(0,"channels",QString("channels:%1,%2,%3,%4").arg(m_Channels[0]).arg(m_Channels[1]).arg(m_Channels[2]).arg(m_Channels[3]));
 
	sendState(01,00);
	setHeartBeat(0);
	setEventDriver(false);
}
Пример #7
0
int ComputerPlayer::getMove(int configurationMaskSelf, int configurationMaskOpponent){
	_sleep(1000);
	//check if the player is one move away from winning
	for(int i = 0 ; i < 24 ; i++){
		if((configurationMaskSelf & OneMoveFromWinMasks[i]) == OneMoveFromWinMasks[i]){ //is the current configuration one move away from winning?
			if(((configurationMaskSelf | configurationMaskOpponent) & mask(WinningMove[i])) != mask(WinningMove[i])){ //is the winning move position unoccupied?
				return WinningMove[i];
			}
		}
	}
	for(int i = 0 ; i < 24 ; i++){
		if((configurationMaskOpponent & OneMoveFromWinMasks[i]) == OneMoveFromWinMasks[i]){ //is the current configuration one move away from winning?
			if(((configurationMaskOpponent | configurationMaskSelf) & mask(WinningMove[i])) != mask(WinningMove[i])){ //is the winning move position unoccupied?
				return WinningMove[i];
			}
		}
	}
	//otherwise just return a random space
	while(true){
		int move = 0;
		move = (rand() % 9) + 1;
		if(((configurationMaskOpponent | configurationMaskSelf) & mask(move)) != mask(move)) return move;
	}
	return 0;
}
Пример #8
0
int main(void) {
	socket_t listener;
	socket_set_t clients;

	if(false == socket_create_socket(&listener, LIBNET_PROTOCOL_TCP, LIBNET_IPV4)) {
		printf("server: failed to create socket\r\n");
		return -1;
	}

	socket_create_set(&clients);

	if(false == socket_listen(&listener, PORT)) {
		printf("server: failed to listen at %d\r\n", PORT);
		return -1;
	}

	printf("server: listening at %d..\n", PORT);

	while(socket_set_get_client_amount(&clients) < 1) {
		socket_accept(&listener, &clients);
	}

	printf("server: client connected (ip: %s)\r\n",
		"127.0.0.1");

	_sleep(2); // to make sure the client recognizes everything

	socket_release_set(&clients);

	socket_disconnect(&listener);
	socket_release_socket(&listener);
	
	return 0;
}
Пример #9
0
bool UPNPNAT::tcp_connect(const char * _host,unsigned short int _port)
{
	int ret,i;
	tcp_socket_fd=socket(AF_INET,SOCK_STREAM,0);
	struct sockaddr_in r_address;

    r_address.sin_family = AF_INET;
	r_address.sin_port=htons(_port);
    r_address.sin_addr.s_addr=inet_addr(_host);

	for(i=1;i<=time_out;i++)
	{
		if(i>1)
			_sleep(1000);

		ret=connect(tcp_socket_fd,(const struct sockaddr *)&r_address,sizeof(struct sockaddr_in) );
		if(ret==0)
		{
			status=NAT_TCP_CONNECTED;
			return true;
		}
	}

	status=NAT_ERROR;
	char temp[100];
	sprintf(temp,"Fail to connect to %s:%i (using TCP)\n",_host,_port);
	last_error=temp;

	return false;
}
Пример #10
0
Файл: vm.c Проект: kvv1/kvvmaps
int main(void) {
	FILE* file = fopen("d:/vm/code.bin", "rb");

	fread(code, sizeof(code), 1, file);
	fclose(file);

	vmInit();

	vmStart(1);
//	vmInit();

	for (;;) {
		int status;
		status = vmGetStatus();
		if (status != VMSTATUS_RUNNING) {
			printf("status = %d\n", status);
			return 1;
		}

		_sleep(VM_STEP);
		vmStep(VM_STEP);
	}

	return 0;
}
Пример #11
0
void A110x2500Radio::gdo0Isr()
{
  // Note: It is assumed that interrupts are disabled.
  
  // The GDO0 ISR will only look for the EOP edge. Therefore, if the radio
  // is not transmitting the EOP, it must be receiving an EOP signal.
  if (gDataTransmitting)
  {
    /**
     *  Note: GDO0 is issued prior to the transmitter being completely
     *  finished. The state machine will remain in TX_END until transmission
     *  completes. The following waits for TX_END to correct the hardware
     *  behavior.
     */ 
    while (CC1101GetMarcState(&gPhyInfo.cc1101) == eCC1101MarcStateTx_end);
    gDataTransmitting = false;
  }
  else
  {
    gDataReceived = true;
    readDataStream();
  }
  
  // Always go back to sleep.
  _sleep();
}
Пример #12
0
int SARRERA_aukerakAukeratu(){
	int bukatu = 0;
	int tekla = 0;
	int posizioa = 1;
	
	SARRERA_jokoarenAukerak(130, 90 + 50 * posizioa, 200, 30);

	do{
		tekla = ebentoaEntzun();
		if (tekla == TECLA_UP){
			if (posizioa > 1){
				posizioa = posizioa - 1;
			}
		}
		if (tekla == TECLA_DOWN){
			if (posizioa <AUKERAKOPURUA){
				posizioa = posizioa + 1;
			}
		}

		if ((tekla == TECLA_UP) || (tekla == TECLA_DOWN)){
			SARRERA_jokoarenAukerak(130, 90 + 50 * posizioa, 200, 30);
		}

		if (tekla == TECLA_RETURN){
			bukatu = 1;
			_sleep(100);
		}
		
	}while(bukatu==0);

	//return
	return posizioa;

}
Пример #13
0
void read_sector_n(const unsigned int cylinder, 
		   const unsigned int sector, 
		   unsigned char* buffer, 
		   const size_t n){

  int i;  


  if( !seek_sector(cylinder, sector) ){
    buffer = NULL;
    return;
  }


  /* Mettre dans MASTERBUFFER les donnees a cette emplacement */
  _out(HDA_DATAREGS, 1);
  _out(HDA_CMDREG, CMD_READ);
  _sleep(HDA_IRQ);


  /* exploiter les donnees de MASTERBUFFER */
  for(i=0; i<HDA_SECTORSIZE && i<n; i++){
    buffer[i] = (unsigned char)MASTERBUFFER[i];
  }
}
Пример #14
0
int ERREALITATE_FISIKOA_pantailaBukaeraHil(){
	int bukatu = 0;
	int tekla = 0;
	int posizioa = 1;

	do{

		tekla = ebentoaEntzun();
		if (tekla == TECLA_UP){
			if (posizioa > 1){
				posizioa = posizioa - 1;
			}
		}
		if (tekla == TECLA_DOWN){
			if (posizioa < 2){
				posizioa = posizioa + 1;
			}
		}

		ERREALITATE_FISIKOA_pantailaBukaeraHilPrintatu(130, 140 + 50 * posizioa, 200, 30);

		if (tekla == TECLA_RETURN){
			bukatu = 1;
		}

		_sleep(10);

	} while (bukatu == 0);

	//return
	return posizioa;
}
Пример #15
0
xbShort xbXBase::LockFile( int fn, xbShort LockType, xbOffT lockLen)
{

  int mode;
  int rc;
  int tries = 0;

  /* convert the xbase locking command into a windows locking command */
  if( LockType == XB_UNLOCK )
    mode = LK_UNLCK;
  else if( LockType == XB_LOCK || LockType == XB_LOCK_HOLD )
    mode = LK_NBLCK;
  else
    return XB_INVALID_LOCK_OPTION;

  do{
    rc = locking( fn, mode, lockLen );
    if( rc )
      _sleep( 1 );
  } while( rc == -1 && tries++ < GetLockRetryCount());
  
  if( rc )
    return XB_LOCK_FAILED;
  
  return 0;
}
Пример #16
0
void read_sector(unsigned int cylinder, unsigned int sector, unsigned char* buffer){

  int secteur_size;
  int tmp, i;  


  if( !seek_sector(cylinder, sector) ){
    buffer = NULL;
    return;
  }


  /* Mettre dans MASTERBUFFER les donnees a cette emplacement */
  _out(HDA_DATAREGS, 1);
  _out(HDA_CMDREG, CMD_READ);
  _sleep(HDA_IRQ);


  /* exploiter les donnees de MASTERBUFFER */
  _out(HDA_CMDREG, CMD_DSKINFO);

  tmp = _in(HDA_DATAREGS+4);
  tmp = tmp<<8;
  secteur_size = tmp + _in(HDA_DATAREGS+5);

  for(i=0; i<secteur_size; i++){
    buffer[i] = (unsigned char)MASTERBUFFER[i];
  }

  buffer[++i] = EOF;
}
Пример #17
0
void Game::StartGame()
{
	//Greeting();

	Computer *computer = new Computer();
	_sleep(500);
	Human *human = new Human();

	Player *player1 = human;
	Player *player2 = computer;

	Field *field = player2->GetPlayerField();

	player1->SetEnemyField(field);
	player2->SetEnemyField(player1->GetPlayerField());

	player1->ShowFields();
	player2->ShowFields();//for debug

	while(true)
	{
		player1->Fire();
		player2->Fire();
		if(player2->IsWinner() || player1->IsWinner()) 
			break;
		system("cls");
		player1->ShowFields();
		player2->ShowFields();//for debug
	}
}
void GxGDEW042T2_FPU::drawPaged(void (*drawCallback)(const void*, const void*), const void* p1, const void* p2)
{
  if (_current_page != -1) return;
  _using_partial_mode = false;
  _wakeUp();
  IO.writeCommandTransaction(0x13);
  for (_current_page = 0; _current_page < GxGDEW042T2_FPU_PAGES; _current_page++)
  {
    fillScreen(GxEPD_WHITE);
    drawCallback(p1, p2);
    for (int16_t y1 = 0; y1 < GxGDEW042T2_FPU_PAGE_HEIGHT; y1++)
    {
      for (int16_t x1 = 0; x1 < GxGDEW042T2_FPU_WIDTH / 8; x1++)
      {
        uint16_t idx = y1 * (GxGDEW042T2_FPU_WIDTH / 8) + x1;
        uint8_t data = (idx < sizeof(_buffer)) ? _buffer[idx] : 0x00;
        IO.writeDataTransaction(~data);
      }
    }
  }
  _current_page = -1;
  IO.writeCommandTransaction(0x12);      //display refresh
  _waitWhileBusy("drawPaged");
  _sleep();
}
Пример #19
0
//Main Function
int main (void){
	int i= 0, j = 0, temp;
	clock_t start, end , one_timer, two_timer;
	int maindata[Num];
	srand((unsigned int)(time(NULL)));
	go_first(maindata,Num);
	start = clock();
	for(i = 0; i<Num; i ++){
		for(j = Num ; j > i; j--){
			if(maindata[j] < maindata[j-1]){
				temp = maindata[j];
				maindata[j] = maindata[j-1];
				maindata[j-1] = temp;
			}
		}
	}
	end = clock();
	one_timer = end - start;
	go_first(maindata,Num);
	start = clock();
	qsort(maindata,Num,sizeof(int),int_compare);
	end = clock();
	two_timer = end - start;
	printf("Time1 takes %dclock and %d second!\n",one_timer, one_timer/CLOCKS_PER_SEC);
	printf("Time2 takes %dclock and %d second!\n",two_timer, two_timer/CLOCKS_PER_SEC);
	_sleep(10000);
}
Пример #20
0
	void dispatcher::sleep(const time::unit &time){
		auto st = time::now();
			step();
		auto elapsed = time::now() - st;

		_sleep(max(0.0f, (time.to_s() - elapsed)) * 1000.0f);
	}
Пример #21
0
void AntiOPe20::onCallBack(UsineMessage *Message)
{
	
	if ((Message->wParam == 1) && (Message->lParam == MSG_CHANGE) && (sdkGetEvtData(m_receivedSendOrder) == 1)) // && (Message->result == 1)) //received 1 on "enable" input
	{
			m_textNew = sdkGetEvtPChar(m_textInput); //
			std::string str(m_textNew);
			int firstChar(0);
			for (unsigned i = 0; i < str.length(); ++i)
			{
				char m_simplechar = str.at(i);
				if (m_simplechar == ',') {
					std::string strToSend = str.substr(firstChar, i - (1 + firstChar)); // a string between 2 commas
					firstChar = i+1; // the index of the string to start the next subtring
					sdkSetEvtPChar(m_textOutput, (AnsiCharPtr) (strToSend.c_str()));
					sdkSetEvtData(m_SendOrderToOSCModule, 1);
					//wait one cycle here
					sdkTraceChar("sending to MINITEL");
					_sleep(160);
					sdkSetEvtData(m_SendOrderToOSCModule, 0);
					}
				else{}
			}

	}

	else{}
	
}
/* Caller must hold the device mutex. */
int kgsl_pwrctrl_sleep(struct kgsl_device *device)
{
	int status = 0;
	KGSL_PWR_INFO(device, "sleep device %d\n", device->id);

	/* Work through the legal state transitions */
	switch (device->requested_state) {
	case KGSL_STATE_NAP:
		if (device->pwrctrl.restore_slumber) {
			kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE);
			break;
		}
		status = _nap(device);
		break;
	case KGSL_STATE_SLEEP:
		if (device->pwrctrl.restore_slumber)
			status = _slumber(device);
		else
			status = _sleep(device);
		break;
	case KGSL_STATE_SLUMBER:
		status = _slumber(device);
		break;
	default:
		KGSL_PWR_INFO(device, "bad state request 0x%x\n",
				device->requested_state);
		kgsl_pwrctrl_request_state(device, KGSL_STATE_NONE);
		status = -EINVAL;
		break;
	}
	return status;
}
Пример #23
0
Файл: drive.c Проект: ymah/TP5-2
void deplacerTete(unsigned int piste,unsigned int secteur){

  int i;
  if(piste < 0 || piste > HDA_SECTORSIZE){
    printf("numero de piste incorrect");
    exit(EXIT_FAILURE);
  }
  if(secteur < 0 || piste > HDA_MAXSECTOR){
    printf("numero de secteur incorrect");
    exit(EXIT_FAILURE);
  }

  for(i=0;i<16;i++)
    IRQVECTOR[i]= empty_it;

  /* chargement des donnée concernant la piste */
  _out(HDA_DATAREGS,piste>>8);
  _out(HDA_DATAREGS+1,piste & 0x00FF);

  /* chargement des donnée concernant le secteur  */
  _out(HDA_DATAREGS+2,secteur>>8);
  _out(HDA_DATAREGS+3,secteur & 0x00FF);
  _out(HDA_CMDREG,CMD_SEEK);

  _sleep(HDA_IRQ);
}
void nServer::Close()
{
  nServerData * sd = (nServerData *) m_data;
  EnterCriticalSection(&sd->criticalSection);
  bool wait = false;

  if(sd->client != INVALID_SOCKET)
  {
    wait = true;
    closesocket(sd->client);
    sd->client = INVALID_SOCKET;
  }
  if(sd->server != INVALID_SOCKET)
  {
    closesocket(sd->server);
    sd->server = INVALID_SOCKET;
  }

  LeaveCriticalSection(&sd->criticalSection);

  // wait for the thread to die.
  while(wait && sd->threadAlive) 
  {
    _sleep(0);
  }

  WSACleanup();
}
Пример #25
0
void system_quit(st_info *buf_head,char *data_name)
{
	char check;
	system("cls");
	printf("\n");
	print_tips("       退出系统     ");
	print_star();
	if(flag_save == TURE)
		printf("\n\n OK!-----可以安全退出!");
	else
	{
		printf("\n\n Warning!-----部分修改并未保存到数据文件!是否继续退出?(确认退出请输入Y)");
		fflush(stdin);
		check = getch();
		if(check != 'Y' || check != 'y')
		{
			save_file(buf_head,data_name,N);
		}
	}
	printf("\n\n OK!-----系统将在三秒后自动退出!感谢您的使用!");
	printf("\n\n Tips:-----您对本程序有任何建议与意见都可发送邮件到[email protected]!");
	print_star();
	printf("\n\n\n\n \t\t\t 学生体检信息管理系统V1.0");
	printf("\n\n \t\t\t       2014.6.7");
	printf("\n\n \t\t\t      作者:任强\n");
	_sleep(3000);
	exit(1);
}
Пример #26
0
unsigned int login(char *local_name,char *local_password)
{
	char user_name[16],user_password[16];
	char swap;
	int i,error = 0;
	system("mode con:cols=40 lines=15");
	while(1)
	{
		memset(user_name,'\0',sizeof(user_name));
		memset(user_password,'\0',sizeof(user_password));
		printf("\n\n\n\t\t管理员登陆\n\n\t*Tips:访 客 : anonymous");
		printf("\n  用户名:");
		for(i = 0;i < 15;i++)
		{
			swap=getchar();
			if(swap == '\n')
				break;
			else 
			{
				user_name[i] = swap;
			}
			
		}
		user_name[i]='\0';
		fflush(stdin);
		printf("\n  密  码:");
		for(i = 0;i < 15;i++)
		{
			swap = getch();
			if(swap == '\r'|| swap == '\n')
				break;
			else 
			{
				user_password[i] = swap;
				printf("*");
			}
			
		}
		user_password[i]='\0';
		system("cls");
		if(strcmp(user_password,local_password) != 0 || strcmp(user_name,local_name) !=0)
		{
			system("cls");
			printf("Warning: Error!-----用户名或密码错误!\n\t还可重试%d次***",2 - error);
			++error;
			if(error == 3)
			{
				printf("\n\n Warning!-----尝试次数已到!请等待3秒后再试");
				_sleep(2000);
				return FALSE;
			}
		}
		else
		{
			break;
		}
	} 
	return TURE;
}
Пример #27
0
void CNotificationWnd::DoTransitionIn(){
	RECT rect;
	GetWindowRect(&rect);
	int src_y=rect.top;
	int dst_y=-30;
	for(int i=0;i<50;i++){
		int y=EaseOut(i, src_y, dst_y+1, 50);
		SetWindowPos(NULL, rect.left, y, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);
		CDC scrdc;
	scrdc.Attach(::GetDC(0));
		BLENDFUNCTION func;
	func.BlendOp=AC_SRC_OVER;
	func.AlphaFormat=AC_SRC_ALPHA;
	func.SourceConstantAlpha=EaseOut(i, 0, 255, 50);
	func.BlendFlags=0;
	UpdateLayeredWindow(&scrdc, &CPoint(rect.left, y), &CSize(200, 95), &bdc, &CPoint(0,0), 0, &func, ULW_ALPHA);
	::ReleaseDC(0, scrdc);

		_sleep(10);
	}

	for(int i=0;i<300;i++){
		_sleep(10);
		if(needClose)break;
	}

	while(mouseInside && !needClose){
		_sleep(10);
	}
	if(!this)return;

	for(int i=0;i<50;i++){
		CDC scrdc;
	scrdc.Attach(::GetDC(0));
		BLENDFUNCTION func;
	func.BlendOp=AC_SRC_OVER;
	func.AlphaFormat=AC_SRC_ALPHA;
	func.SourceConstantAlpha=EaseIn(i, 255, -255, 50);
	func.BlendFlags=0;
	UpdateLayeredWindow(&scrdc, &CPoint(rect.left, src_y+dst_y), &CSize(200, 95), &bdc, &CPoint(0,0), 0, &func, ULW_ALPHA);
	::ReleaseDC(0, scrdc);

		_sleep(10);
	}
	SendMessage(WM_CLOSE);
}
Пример #28
0
void WriteSharedMemory::run()
{
	while(1)
	{
		loadIntoSharedMem();
		_sleep(2);
	}
}
Пример #29
0
bool Mgr::start(){
	while(true){
		if(!ProcessCmd())
			break;
		obj->update();
		_sleep(10);
	}
	return true;
}
Пример #30
0
void
Sequencer::touch(){
  if (__time == 0) __time = clock();
  else{
	clock_t deltaT = clock() - __time;
	if (deltaT < __timestep) _sleep(__timestep-deltaT);
	__time = clock();
  }
}