• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sleep_seconds函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sleep_seconds函数的典型用法代码示例。如果您正苦于以下问题:C++ sleep_seconds函数的具体用法?C++ sleep_seconds怎么用?C++ sleep_seconds使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sleep_seconds函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: while

void Meteostick::Do_PollWork()
{
	bool bFirstTime = true;
	while (!m_stoprequestedpoller)
	{
		sleep_seconds(1);

		time_t atime = mytime(NULL);
		struct tm ltime;
		localtime_r(&atime, &ltime);


		if (ltime.tm_sec % 12 == 0) {
			mytime(&m_LastHeartbeat);
		}

		if (!isOpen())
		{
			if (m_retrycntr == 0)
			{
				_log.Log(LOG_STATUS, "Meteostick: serial setup retry in %d seconds...", RETRY_DELAY);
			}
			m_retrycntr++;
			if (m_retrycntr >= RETRY_DELAY)
			{
				m_retrycntr = 0;
				if (OpenSerialDevice())
					bFirstTime = true;
			}
		}
	}
	_log.Log(LOG_STATUS, "Meteostick: Worker stopped...");
}
开发者ID:ZaaaV,项目名称:domoticz,代码行数:33,代码来源:Meteostick.cpp


示例2: while

void DomoticzTCP::Do_Work()
{
	char buf[100];
	int sec_counter = 0;
	while (!m_stoprequested)
	{
		if (
			(m_socket == INVALID_SOCKET)&&
			(!m_stoprequested)
			)
		{
			sleep_seconds(1);
			sec_counter++;

			if (sec_counter % 12 == 0) {
				mytime(&m_LastHeartbeat);
			}

			if (m_stoprequested)
				break;
			m_retrycntr++;
			if (m_retrycntr>=RETRY_DELAY)
			{
				m_retrycntr=0;
				if (!ConnectInternal())
				{
					_log.Log(LOG_STATUS,"Domoticz: retrying in %d seconds...",RETRY_DELAY);
				}
			}
		}
		else
		{
			//this could take a long time... maybe there will be no data received at all,
			//so it's no good to-do the heartbeat timing here
			m_LastHeartbeat = mytime(NULL);

			int bread=recv(m_socket,(char*)&buf,sizeof(buf),0);
			if (m_stoprequested)
				break;
			if (bread<=0) {
				_log.Log(LOG_ERROR,"Domoticz: TCP/IP connection closed! %s",m_szIPAddress.c_str());
				closesocket(m_socket);
				m_socket=INVALID_SOCKET;
				if (!m_stoprequested)
				{
					_log.Log(LOG_STATUS,"Domoticz: retrying in %d seconds...",RETRY_DELAY);
					m_retrycntr=0;
					continue;
				}
			}
			else
			{
				boost::lock_guard<boost::mutex> l(readQueueMutex);
				onRFXMessage((const unsigned char *)&buf,bread);
			}
		}
		
	}
	_log.Log(LOG_STATUS,"Domoticz: TCP/IP Worker stopped...");
} 
开发者ID:AbsolutK,项目名称:domoticz,代码行数:60,代码来源:DomoticzTCP.cpp


示例3: while

void FritzboxTCP::Do_Work()
{
	bool bFirstTime=true;
	int sec_counter = 0;
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;

		if (sec_counter  % 12 == 0) {
			m_LastHeartbeat=mytime(NULL);
		}

		if (bFirstTime)
		{
			bFirstTime=false;
			connect(m_szIPAddress,m_usIPPort);
		}
		else
		{
			if ((m_bDoRestart) && (sec_counter % 30 == 0))
			{
				connect(m_szIPAddress,m_usIPPort);
			}
			update();
		}
	}
	_log.Log(LOG_STATUS,"Fritzbox: TCP/IP Worker stopped...");
} 
开发者ID:CZ-NIC,项目名称:domoticz-turris-gadgets,代码行数:29,代码来源:FritzboxTCP.cpp


示例4: while

void KMTronicSerial::Do_Work()
{
	int sec_counter = 0;
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;
		if (sec_counter % 12 == 0) {
			m_LastHeartbeat=mytime(NULL);
		}

		if (m_stoprequested)
			break;
		if (!isOpen())
		{
			if (m_retrycntr == 0)
			{
				_log.Log(LOG_STATUS, "KMTronic: retrying in %d seconds...", RETRY_DELAY);
			}
			m_retrycntr++;
			if (m_retrycntr >= RETRY_DELAY)
			{
				m_retrycntr = 0;
				if (OpenSerialDevice())
				{
					GetRelayStates();
				}
			}
		}
	}
	_log.Log(LOG_STATUS, "KMTronic: Serial Worker stopped...");
}
开发者ID:remb0,项目名称:domoticz,代码行数:32,代码来源:KMTronicSerial.cpp


示例5: while

void MySensorsTCP::Do_Work()
{
	bool bFirstTime=true;

	while (!m_stoprequested)
	{
		sleep_seconds(1);

		time_t atime = mytime(NULL);
		struct tm ltime;
		localtime_r(&atime, &ltime);


		if (ltime.tm_sec % 12 == 0) {
			mytime(&m_LastHeartbeat);
		}

		if (bFirstTime)
		{
			bFirstTime=false;
			connect(m_szIPAddress,m_usIPPort);
		}
		else
		{
			time_t atime=time(NULL);
			if ((m_bDoRestart)&&(atime%30==0))
			{
				connect(m_szIPAddress,m_usIPPort);
			}
			update();
		}
	}
	_log.Log(LOG_STATUS,"MySensors: TCP/IP Worker stopped...");
} 
开发者ID:htlinux,项目名称:domoticza,代码行数:34,代码来源:MySensorsTCP.cpp


示例6: while

void Meteostick::Do_PollWork()
{
	bool bFirstTime = true;
	int sec_counter = 0;
	while (!m_stoprequestedpoller)
	{
		sleep_seconds(1);
		sec_counter++;

		if (sec_counter % 12 == 0) {
			m_LastHeartbeat = mytime(NULL);
		}

		if (!isOpen())
		{
			if (m_retrycntr == 0)
			{
				_log.Log(LOG_STATUS, "Meteostick: serial setup retry in %d seconds...", RETRY_DELAY);
			}
			m_retrycntr++;
			if (m_retrycntr >= RETRY_DELAY)
			{
				m_retrycntr = 0;
				if (OpenSerialDevice())
					bFirstTime = true;
			}
		}
	}
	_log.Log(LOG_STATUS, "Meteostick: Worker stopped...");
}
开发者ID:karekaa,项目名称:domoticz,代码行数:30,代码来源:Meteostick.cpp


示例7: while

void MySensorsSerial::Do_Work()
{
    int sec_counter = 0;
    while (!m_stoprequested)
    {
        sleep_seconds(1);
        sec_counter++;

        if (sec_counter % 12 == 0) {
            mytime(&m_LastHeartbeat);
        }

        if (m_stoprequested)
            break;
        if (!isOpen())
        {
            if (m_retrycntr == 0)
            {
                _log.Log(LOG_STATUS, "MySensors: retrying in %d seconds...", RETRY_DELAY);
            }
            m_retrycntr++;
            if (m_retrycntr >= RETRY_DELAY)
            {
                m_retrycntr = 0;
                OpenSerialDevice();
            }
        }

    }
    _log.Log(LOG_STATUS, "MySensors: Serial Worker stopped...");
}
开发者ID:nayrnet,项目名称:domoticz,代码行数:31,代码来源:MySensorsSerial.cpp


示例8: while

void CToonThermostat::Do_Work()
{
	_log.Log(LOG_STATUS,"ToonThermostat: Worker started...");
	int sec_counter = 1;
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		m_poll_counter--;
		sec_counter++;
		if (sec_counter % 12 == 0) {
			mytime(&m_LastHeartbeat);
		}
		if (m_poll_counter<=0)
		{
			m_poll_counter = TOON_POLL_INTERVAL;
			GetMeterDetails();
			if (m_retry_counter >= 3)
			{
				m_bDoLogin = true;
				m_retry_counter = 0;
				_log.Log(LOG_ERROR, "ToonThermostat: retrieveToonState request not successful, restarting..!");
			}
		}
	}
	_log.Log(LOG_STATUS,"ToonThermostat: Worker stopped...");
}
开发者ID:sbouchex,项目名称:domoticz,代码行数:26,代码来源:ToonThermostat.cpp


示例9: while

void P1MeterTCP::Do_Work()
{
	while (!m_stoprequested)
	{
		if (
			(m_socket == INVALID_SOCKET)&&
			(!m_stoprequested)
			)
		{
			sleep_seconds(1);
			time_t atime = mytime(NULL);
			struct tm ltime;
			localtime_r(&atime, &ltime);


			if (ltime.tm_sec % 12 == 0) {
				mytime(&m_LastHeartbeat);
			}

			m_retrycntr++;
			if (m_retrycntr>=RETRY_DELAY)
			{
				m_retrycntr=0;
				if (!ConnectInternal())
				{
					_log.Log(LOG_STATUS,"P1 Smart Meter: retrying in %d seconds...", RETRY_DELAY);
					continue;
				}
			}
		}
		else
		{
			unsigned char data[1028];
			int bread=recv(m_socket,(char*)&data,sizeof(data),0);
			if (m_stoprequested)
				break;
			mytime(&m_LastHeartbeat);
			if ((bread==0)||(bread<0)) {
				_log.Log(LOG_ERROR,"P1 Smart Meter: TCP/IP connection closed!");
				closesocket(m_socket);
				m_socket=INVALID_SOCKET;
				if (!m_stoprequested)
				{
					_log.Log(LOG_STATUS,"P1 Smart Meter: retrying in %d seconds...", RETRY_DELAY);
					m_retrycntr=0;
					continue;
				}
			}
			else
			{
				boost::lock_guard<boost::mutex> l(readQueueMutex);
				ParseData((const unsigned char*)&data,bread);
			}
		}
	}
	_log.Log(LOG_STATUS,"P1 Smart Meter: TCP/IP Worker stopped...");
} 
开发者ID:htlinux,项目名称:domoticza,代码行数:57,代码来源:P1MeterTCP.cpp


示例10: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_client_process, ev, data)
{
  static struct etimer et, wake_timer, periodic_timer;
  uip_ipaddr_t ipaddr;

  PROCESS_BEGIN();
  PRINTF("UDP client process started\n");

#if UIP_CONF_ROUTER
  set_global_address();
#endif

  print_local_addresses();

  set_connection_address(&ipaddr);

  /* new connection with remote host */
  client_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
  udp_bind(client_conn, UIP_HTONS(3001));

  PRINTF("Created a connection with the server ");
  PRINT6ADDR(&client_conn->ripaddr);
  PRINTF(" local/remote port %u/%u\n",
	UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport));

  etimer_set(&et, CLOCK_SECOND*10);
  PROCESS_WAIT_UNTIL(etimer_expired(&et)); // Wait for DAD and Router Discovery procedure to end.

  etimer_set(&et, SEND_INTERVAL);
  etimer_set(&wake_timer, AWAKE_INTERVAL);
  etimer_set(&periodic_timer, 1);

  while(1) {
    PROCESS_YIELD();
    if(etimer_expired(&wake_timer)){  // if timer hasn't expired do not go in deep sleep, in order to receive a response.
		printf("Sleeping...\r\n");
		sensorsPowerDown();
		sleep_seconds(SLEEP_INTERVAL_SECONDS); // Put system in deep sleep mode for a while.
		sensorsPowerUp();
		printf("Awake\r\n");
    }
    if(etimer_expired(&et)) {
      timeout_handler();
      etimer_restart(&et);
      etimer_restart(&wake_timer);
    } else if(ev == tcpip_event) {
      tcpip_handler();
    }

    /* Make the process be called almost immediately,
     * so that it can force the system to go into deep sleep. */
    etimer_restart(&periodic_timer);
  }

  PROCESS_END();
}
开发者ID:pkocsis,项目名称:contiki-mirror,代码行数:57,代码来源:udp-client.c


示例11: while

void CurrentCostMeterTCP::Do_Work()
{
	int sec_counter = 0;
	while (!m_stoprequested)
	{
		if (
			(m_socket == INVALID_SOCKET)&&
			(!m_stoprequested)
			)
		{
			sleep_seconds(1);
			sec_counter++;

			if (sec_counter % 12 == 0) {
				m_LastHeartbeat=mytime(NULL);
			}

			m_retrycntr++;
			if (m_retrycntr>=RETRY_DELAY)
			{
				m_retrycntr=0;
				if (!ConnectInternal())
				{
					_log.Log(LOG_STATUS,"CurrentCost Smart Meter: retrying in %d seconds...", RETRY_DELAY);
					continue;
				}
			}
		}
		else
		{
			char data[1028];
			int bread=recv(m_socket,data,sizeof(data),0);
			if (m_stoprequested)
				break;
			m_LastHeartbeat=mytime(NULL);
			if ((bread==0)||(bread<0)) {
				_log.Log(LOG_ERROR,"CurrentCost Smart Meter: TCP/IP connection closed!");
				closesocket(m_socket);
				m_socket=INVALID_SOCKET;
				if (!m_stoprequested)
				{
					_log.Log(LOG_STATUS,"CurrentCost Smart Meter: retrying in %d seconds...", RETRY_DELAY);
					m_retrycntr=0;
					continue;
				}
			}
			else
			{
				boost::lock_guard<boost::mutex> l(readQueueMutex);
				ParseData(data, bread);
			}
		}
	}
	_log.Log(LOG_STATUS,"CurrentCost Smart Meter: TCP/IP Worker stopped...");
} 
开发者ID:AbsolutK,项目名称:domoticz,代码行数:55,代码来源:CurrentCostMeterTCP.cpp


示例12: mmInit

//initialization of modem - returns true if all commands completed successfully, false otherwise
bool mmInit(struct ModemInterface *interf) {
	sleep_seconds(3);
	mmSendCommand(interf, F("+++"));
	sleep_seconds(1);
	interf->dlmode = 0;
	interf->disconnectIndex = 0;
	int i = 0;				//command counter
	mmFlushBuffer(interf);
	for(i = 0; i < 3; i++){
		mmSendCommand(interf, F("AT\r"));
	}
	mmFind(interf->modem, F("OK"));
	mmFlushBuffer(interf);
	i = 0;
	int j = 0;				//retry counter
	while (i < 6 && j < 10) {
		switch(i) {
			case 0:
				(mmSendCommandCheckForOkay(interf, F("ATE1")))?i++:j++; 
				break;
			case 1:
				(mmSendCommandCheckForOkay(interf, F("AT+CMEE=0"))) ? i++ : j++;
				break;
			case 2:
				(mmSendCommandCheckForOkay(interf, F("AT+UMNOCONF=3,23"))) ? i++ : j++;
				break;
			case 3:
				(mmSendCommandCheckForOkay(interf, F("AT+CFUN=1"))) ? i++ : j++;
				break;
			case 4:
				(mmSendCommandCheckForOkay(interf, F("AT+CMGF=1"))) ? i++ : j++;
				break;
			case 5:
				(mmSendCommandCheckForOkay(interf, F("AT+CSDH=1"))) ? i++ : j++; //for text message length
				break;
		}
		#ifdef ARDUINO
			//delay(250);
		#endif
	}
	return (i == 6) ? true : false;
}
开发者ID:M2MCircuits,项目名称:makermodem,代码行数:43,代码来源:cModemInterface.c


示例13: closesocket

void DomoticzTCP::disconnectTCP()
{
	m_stoprequested=true;
	if (m_socket!=INVALID_SOCKET)
	{
		closesocket(m_socket);	//will terminate the thread
		m_socket=INVALID_SOCKET;
		sleep_seconds(1);
	}
	//m_thread-> join();
}
开发者ID:AbsolutK,项目名称:domoticz,代码行数:11,代码来源:DomoticzTCP.cpp


示例14: while

void C1Wire::Do_Work()
{
	int pCounter = Wire1_POLL_INTERVAL-2;
	while (!m_stoprequested)
	{
		sleep_seconds(1);

		pCounter++;
		if (pCounter % Wire1_POLL_INTERVAL == 0)
		{
			GetDeviceDetails();
		}
	}
}
开发者ID:gergles,项目名称:domoticz,代码行数:14,代码来源:1Wire.cpp


示例15: GetDeviceDetails

void C1Wire::Do_Work()
{
    time_t lastPollTime=mytime(NULL);
    GetDeviceDetails();
    while (!m_stoprequested)
    {
        sleep_seconds(1);
        if (mytime(NULL)-lastPollTime>=Wire1_POLL_INTERVAL)
        {
            GetDeviceDetails();
            lastPollTime=mytime(NULL);
        }
    }
}
开发者ID:G3ronim0,项目名称:domoticz,代码行数:14,代码来源:1Wire.cpp


示例16: while

void CLimitLess::Do_Work()
{
	int sec_counter = 0;
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;

		if (sec_counter % 12 == 0) {
			m_LastHeartbeat=mytime(NULL);
		}
	}
	_log.Log(LOG_STATUS,"AppLamp: Worker stopped...");
}
开发者ID:AbsolutK,项目名称:domoticz,代码行数:14,代码来源:Limitless.cpp


示例17: while

void OTGWTCP::Do_Work()
{
	bool bFirstTime=true;
	int sec_counter = 25;
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;

		if (sec_counter % 12 == 0) {
			m_LastHeartbeat=mytime(NULL);
		}

		if (bFirstTime)
		{
			bFirstTime=false;
			connect(m_szIPAddress,m_usIPPort);
			if (mIsConnected)
			{
				GetGatewayDetails();
			}
		}
		else
		{
			if ((m_bDoRestart) && (sec_counter % 30 == 0))
			{
				connect(m_szIPAddress,m_usIPPort);
			}
			update();
			if (mIsConnected)
			{
				if ((sec_counter % 28 == 0) && (m_bRequestVersion))
				{
					m_bRequestVersion = false;
					GetVersion();
				}
				else if (sec_counter % 30 == 0)//updates every 30 seconds
				{
					bFirstTime=false;
					SendOutsideTemperature();
					SendTime();
					GetGatewayDetails();
				}
			}
		}
	}
	_log.Log(LOG_STATUS,"OTGW: TCP/IP Worker stopped...");
} 
开发者ID:AbsolutK,项目名称:domoticz,代码行数:48,代码来源:OTGWTCP.cpp


示例18: while

void OTGWTCP::Do_Work()
{
	bool bFirstTime=true;

	while (!m_stoprequested)
	{
		sleep_seconds(1);

		time_t atime = mytime(NULL);
		struct tm ltime;
		localtime_r(&atime, &ltime);


		if (ltime.tm_sec % 12 == 0) {
			mytime(&m_LastHeartbeat);
		}

		if (bFirstTime)
		{
			bFirstTime=false;
			connect(m_szIPAddress,m_usIPPort);
			if (mIsConnected)
			{
				GetGatewayDetails();
			}
		}
		else
		{
			time_t atime=time(NULL);
			if ((m_bDoRestart)&&(atime%30==0))
			{
				connect(m_szIPAddress,m_usIPPort);
			}
			update();
			if (mIsConnected)
			{
				time_t atime=time(NULL);
				if (atime%30==0)//updates every 30 seconds
				{
					bFirstTime=false;
					SendOutsideTemperature();
					GetGatewayDetails();
				}
			}
		}
	}
	_log.Log(LOG_STATUS,"OTGW: TCP/IP Worker stopped...");
} 
开发者ID:ZaaaV,项目名称:domoticz,代码行数:48,代码来源:OTGWTCP.cpp


示例19: while

void OTGWSerial::Do_PollWork()
{
	bool bFirstTime=true;
	int sec_counter = 25;
	while (!m_stoprequestedpoller)
	{
		sleep_seconds(1);

		sec_counter++;

		if (sec_counter % 12 == 0) {
			m_LastHeartbeat=mytime(NULL);
		}

		if (!isOpen())
		{
			if (m_retrycntr==0)
			{
				_log.Log(LOG_STATUS,"OTGW: serial setup retry in %d seconds...", RETRY_DELAY);
			}
			m_retrycntr++;
			if (m_retrycntr>=RETRY_DELAY)
			{
				m_retrycntr=0;
				if (OpenSerialDevice())
				{
					bFirstTime = true;
				}
			}
		}
		else
		{
			if ((sec_counter % 28 == 0) && (m_bRequestVersion))
			{
				m_bRequestVersion = false;
				GetVersion();
			}
			else if ((sec_counter % 30 == 0) || (bFirstTime))	//updates every 30 seconds
			{
				bFirstTime = false;
				SendOutsideTemperature();
				SendTime();
				GetGatewayDetails();
			}
		}
	}
	_log.Log(LOG_STATUS,"OTGW: Worker stopped...");
}
开发者ID:AbsolutK,项目名称:domoticz,代码行数:48,代码来源:OTGWSerial.cpp


示例20: while

void CWunderground::Do_Work()
{
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		time_t atime=mytime(NULL);
		struct tm ltime;
		localtime_r(&atime,&ltime);
		if ((ltime.tm_min/10!=m_LastMinute))
		{
			GetMeterDetails();
			m_LastMinute=ltime.tm_min/10;
		}
	}
	_log.Log(LOG_NORM,"Wunderground Worker stopped...");
}
开发者ID:G3ronim0,项目名称:domoticz,代码行数:16,代码来源:Wunderground.cpp



注:本文中的sleep_seconds函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sleep_us函数代码示例发布时间:2022-05-30
下一篇:
C++ sleep_on函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap