示例#1
0
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...");
}
示例#2
0
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...");
} 
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...");
} 
示例#4
0
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...");
}
示例#5
0
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...");
} 
示例#6
0
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...");
}
示例#7
0
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...");
}
示例#8
0
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...");
}
示例#9
0
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...");
} 
示例#10
0
/*---------------------------------------------------------------------------*/
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();
}
示例#11
0
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...");
} 
示例#12
0
//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;
}
示例#13
0
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();
}
示例#14
0
void C1Wire::Do_Work()
{
	int pCounter = Wire1_POLL_INTERVAL-2;
	while (!m_stoprequested)
	{
		sleep_seconds(1);

		pCounter++;
		if (pCounter % Wire1_POLL_INTERVAL == 0)
		{
			GetDeviceDetails();
		}
	}
}
示例#15
0
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);
        }
    }
}
示例#16
0
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...");
}
示例#17
0
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...");
} 
示例#18
0
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...");
} 
示例#19
0
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...");
}
示例#20
0
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...");
}
示例#21
0
void CHttpPoller::Do_Work()
{
	int sec_counter = 300 - 5;
	_log.Log(LOG_STATUS, "Http: Worker started...");
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		if (m_stoprequested)
			break;
		sec_counter++;
		if (sec_counter % m_refresh == 0) {
			GetScript();
		}
	}
	_log.Log(LOG_STATUS,"Http: Worker stopped...");
}
void CJabloDongle::Do_Work() {
	int sec_counter=30-5;
	_log.Log(LOG_STATUS,"JabloDongle: Worker started...");
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;
		if (sec_counter%12==0)
		{
			m_LastHeartbeat=mytime(NULL);
		}

		if (sec_counter%30==0)
		{
			//poll status
		}

		if(!isOpen()) {
			OpenSerialDevice();
			if(ProbeDongle()) {
				m_stoprequested = true;
			}
			ReadSlots();
			SendSwitchIfNotExists(0x1000000, SUBSWITCH_PGX, 0, false, 0, "PGX");
			SendSwitchIfNotExists(0x1000000, SUBSWITCH_PGY, 0, false, 0, "PGY");
			if(!SendSwitchIfNotExists(0x1000001, 0, 0, false, 0, "SIREN_LOUD")) {
				SetSwitchIcon(0x1000001, 0, 13); //Set wonderful red light icon in web gui
			}
			if(!SendSwitchIfNotExists(0x1000002, 0, 0, false, 0, "SIREN_BEEP")) {
				SetSwitchType(0x1000002, 0, STYPE_Dimmer);
			}
			if(!SendSwitchIfNotExists(0x1000003, 0, 0, false, 0, "ENROLL")) {
				SetSwitchIcon(0x1000003, 0, 9);
			}

			//add smoke detectors at startup (they are difficult to activate :-) )
			for(std::vector<Ja_device*>::iterator i = slots.begin(); i != slots.end(); i++) {
				if((*i)->model == JDEV_JA85ST) {
					std::stringstream dev_desc;
					dev_desc << (*i)->ModelAsString() << "_" << std::setfill('0') << (*i)->id << "_SENSOR";
					SendSwitchIfNotExists((*i)->id, SUBSWITCH_SENSOR, 0, false, 0, dev_desc.str());
				}
			}
		}
	}
	_log.Log(LOG_STATUS,"JabloDongle: Worker stopped...");
}
示例#23
0
void CWunderground::Do_Work()
{
	int sec_counter = 590;
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;
		if (sec_counter % 10 == 0) {
			m_LastHeartbeat=mytime(NULL);
		}
		if (sec_counter % 600 == 0)
		{
			GetMeterDetails();
		}
	}
	_log.Log(LOG_STATUS,"Wunderground: Worker stopped...");
}
示例#24
0
void CEcoDevices::Do_Work()
{
	int sec_counter = 0;
	_log.Log(LOG_STATUS,"EcoDevices: Worker started...");
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;
		if (sec_counter % 12 == 0) {
			mytime(&m_LastHeartbeat);
		}
		if (sec_counter%ECODEVICES_POLL_INTERVAL == 0)
		{
			GetMeterDetails();
		}
	}
	_log.Log(LOG_STATUS,"EcoDevices: Worker stopped...");
}
示例#25
0
void CThermosmart::Do_Work()
{
	_log.Log(LOG_STATUS,"Thermosmart: Worker started...");
	int sec_counter = THERMOSMART_POLL_INTERVAL-5;
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;
		if (sec_counter % 12 == 0) {
			m_LastHeartbeat=mytime(NULL);
		}
		if (sec_counter % THERMOSMART_POLL_INTERVAL == 0)
		{
			GetMeterDetails();
		}
	}
	_log.Log(LOG_STATUS,"Thermosmart: Worker stopped...");
}
void CToonThermostat::Do_Work()
{
	int sec_counter = TOON_POLL_INTERVAL-5;
	_log.Log(LOG_STATUS,"ToonThermostat: Worker started...");
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;
		if (sec_counter % 12 == 0) {
			mytime(&m_LastHeartbeat);
		}
		if (sec_counter % TOON_POLL_INTERVAL == 0)
		{
			GetMeterDetails();
		}
	}
	_log.Log(LOG_STATUS,"ToonThermostat: Worker stopped...");
}
示例#27
0
void CDarkSky::Do_Work()
{
	_log.Log(LOG_STATUS, "DarkSky: Started...");

	int sec_counter = 290;
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;
		if (sec_counter % 12 == 0) {
			m_LastHeartbeat = mytime(NULL);
		}
		if (sec_counter % 300 == 0)
		{
			GetMeterDetails();
		}
	}
	_log.Log(LOG_STATUS,"DarkSky: Worker stopped...");
}
示例#28
0
void CVolcraftCO20::Do_Work()
{
	int sec_counter=VolcraftCO20_POLL_INTERVAL-5;
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;
		if (sec_counter%12==0)
		{
			m_LastHeartbeat=mytime(NULL);
		}

		if (sec_counter%VolcraftCO20_POLL_INTERVAL==0)
		{
			GetSensorDetails();
		}
	}
	_log.Log(LOG_STATUS,"Voltcraft CO-20: Worker stopped...");
}
示例#29
0
文件: YouLess.cpp 项目: n326/domoticz
void CYouLess::Do_Work()
{
	int sec_counter = YOULESS_POLL_INTERVAL - 2;

	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;

		if (sec_counter % 12 == 0) {
			m_LastHeartbeat=mytime(NULL);
		}
		if (sec_counter % YOULESS_POLL_INTERVAL == 0)
		{
			GetMeterDetails();
		}
	}
	_log.Log(LOG_STATUS,"YouLess: Worker stopped...");
}
示例#30
0
void S0MeterTCP::Do_Work()
{
	bool bFirstTime=true;
	int sec_counter = 0;
	while (!m_stoprequested)
	{
		sleep_seconds(1);
		sec_counter++;

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

		if (bFirstTime)
		{
			bFirstTime=false;
			if (mIsConnected)
			{
				try {
					disconnect();
					close();
				}
				catch (...)
				{
					//Don't throw from a Stop command
				}
			}
			_log.Log(LOG_ERROR, "S0 Meter: trying to connect to %s:%d", m_szIPAddress.c_str(), m_usIPPort);
			connect(m_szIPAddress,m_usIPPort);
		}
		else
		{
			if ((m_bDoRestart) && (sec_counter % 30 == 0))
			{
				_log.Log(LOG_ERROR, "S0 Meter: trying to connect to %s:%d", m_szIPAddress.c_str(), m_usIPPort);
				connect(m_szIPAddress,m_usIPPort);
			}
			update();
		}
	}
	_log.Log(LOG_STATUS,"S0 Meter: TCP/IP Worker stopped...");
}