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...");
}
示例#2
0
void ZWaveBase::InsertDevice(_tZWaveDevice device)
{
	device.string_id=GenerateDeviceStringID(&device);

	bool bNewDevice=(m_devices.find(device.string_id)==m_devices.end());
	
	device.lastreceived=mytime(NULL);
#ifdef _DEBUG
	if (bNewDevice)
	{
		std::cout << "New device: " << device.string_id << std::endl;
	}
	else
	{
		std::cout << "Update device: " << device.string_id << std::endl;
	}
#endif
	//insert or update device in internal record
	device.sequence_number=1;
	m_devices[device.string_id]=device;

	SendSwitchIfNotExists(&device);
}