Пример #1
0
void C1Wire::GetDeviceDetails()
{
	if (!m_system)
		return;

	// Get all devices
	std::vector<_t1WireDevice> devices;
	m_system->GetDevices(devices);

	// Parse our devices (have to test m_stoprequested because it can take some time in case of big networks)
	std::vector<_t1WireDevice>::const_iterator itt;
	for (itt=devices.begin(); itt!=devices.end() && !m_stoprequested; ++itt)
	{
		const _t1WireDevice& device=*itt;

		// Manage families specificities
		switch(device.family)
		{
		case high_precision_digital_thermometer:
		case Thermachron:
		case Econo_Digital_Thermometer:
		case Temperature_memory:
		case programmable_resolution_digital_thermometer:
			{
				float temperature=m_system->GetTemperature(device);
			if (IsTemperatureValid(device.family, temperature))
			{
				ReportTemperature(device.devid, temperature);
			}
				break;
			}

		case Addresable_Switch:
		case microlan_coupler:
			{
				ReportLightState(device.devid,0,m_system->GetLightState(device,0));
				break;
			}

		case dual_addressable_switch_plus_1k_memory:
			{
				ReportLightState(device.devid,0,m_system->GetLightState(device,0));
				if (m_system->GetNbChannels(device) == 2)
					ReportLightState(device.devid,1,m_system->GetLightState(device,1));
				break;
			}

		case _8_channel_addressable_switch:
			{
				ReportLightState(device.devid,0,m_system->GetLightState(device,0));
				ReportLightState(device.devid,1,m_system->GetLightState(device,1));
				ReportLightState(device.devid,2,m_system->GetLightState(device,2));
				ReportLightState(device.devid,3,m_system->GetLightState(device,3));
				ReportLightState(device.devid,4,m_system->GetLightState(device,4));
				ReportLightState(device.devid,5,m_system->GetLightState(device,5));
				ReportLightState(device.devid,6,m_system->GetLightState(device,6));
				ReportLightState(device.devid,7,m_system->GetLightState(device,7));
				break;
			}

		case Temperature_IO:
			{
		  float temperature = m_system->GetTemperature(device);
		  if (IsTemperatureValid(device.family, temperature))
		  {
			  ReportTemperature(device.devid, temperature);
		  }
		  ReportLightState(device.devid, 0, m_system->GetLightState(device, 0));
		  ReportLightState(device.devid, 1, m_system->GetLightState(device, 1));
		  break;
			}

		case dual_channel_addressable_switch:
		case _4k_EEPROM_with_PIO:
			{
				ReportLightState(device.devid,0,m_system->GetLightState(device,0));
				ReportLightState(device.devid,1,m_system->GetLightState(device,1));
				break;
			}

		case Environmental_Monitors:
			{
		  float temperature = m_system->GetTemperature(device);
		  if (IsTemperatureValid(device.family, temperature))
		  {
			  ReportTemperatureHumidity(device.devid, temperature, m_system->GetHumidity(device));
		  }
		  break;
			}

		case _4k_ram_with_counter:
			{
				ReportCounter(device.devid,0,m_system->GetCounter(device,0));
				ReportCounter(device.devid,1,m_system->GetCounter(device,1));
				break;
			}

		case quad_ad_converter:
			{
				ReportVoltage(0,m_system->GetVoltage(device,0));
				ReportVoltage(1,m_system->GetVoltage(device,1));
				ReportVoltage(2,m_system->GetVoltage(device,2));
				ReportVoltage(3,m_system->GetVoltage(device,3));
				break;
			}

		case Serial_ID_Button:
			{
				// Nothing to do with these devices for Domoticz ==> Filtered
				break;
			}

		case smart_battery_monitor:
			{
		  float temperature = m_system->GetTemperature(device);
		  if (IsTemperatureValid(device.family, temperature))
		  {
			  ReportTemperature(device.devid, temperature);
		  }
				ReportHumidity(device.devid,m_system->GetHumidity(device));
				ReportVoltage(0,m_system->GetVoltage(device,0));   // VAD
				ReportVoltage(1,m_system->GetVoltage(device,1));   // VDD
				ReportVoltage(2,m_system->GetVoltage(device,2));   // vis
				ReportPressure(device.devid,m_system->GetPressure(device));
				// Commonly used as illuminescence sensor, see http://www.hobby-boards.com/store/products/Solar-Radiation-Detector.html
				ReportIlluminescence(m_system->GetIlluminescence(device));
				break;
			}

		case silicon_serial_number:
		{ // this is only chip with id (equal device.filename and device.devid)
			break;
		}

		default: // Device is not actually supported
			{
				_log.Log(LOG_ERROR,"1-Wire : Device family (%02x) is not actually supported", device.family);
				break;
			}
		}
	}
}
Пример #2
0
void C1Wire::PollSensors()
{
	if (!m_system)
		return;

	if (m_sensors.size() > 2)
	{
		m_system->StartSimultaneousTemperatureRead();
	}

	// Parse our devices (have to test m_stoprequested because it can take some time in case of big networks)
	std::set<_t1WireDevice>::const_iterator itt;
	for (itt=m_sensors.begin(); itt!=m_sensors.end() && !m_stoprequested; ++itt)
	{
		const _t1WireDevice& device=*itt;

		// Manage families specificities
		switch(device.family)
		{
		case high_precision_digital_thermometer:
		case Thermachron:
		case Econo_Digital_Thermometer:
		case Temperature_memory:
		case programmable_resolution_digital_thermometer:
		case Temperature_IO:
			{
				float temperature=m_system->GetTemperature(device);
				if (IsTemperatureValid(device.family, temperature))
				{
					ReportTemperature(device.devid, temperature);
				}
				break;
			}

		case Environmental_Monitors:
			{
				float temperature = m_system->GetTemperature(device);
				if (IsTemperatureValid(device.family, temperature))
				{
					ReportTemperatureHumidity(device.devid, temperature, m_system->GetHumidity(device));
				}
				ReportPressure(device.devid,m_system->GetPressure(device));
				break;
			}

		case _4k_ram_with_counter:
			{
				ReportCounter(device.devid,0,m_system->GetCounter(device,0));
				ReportCounter(device.devid,1,m_system->GetCounter(device,1));
				break;
			}

		case quad_ad_converter:
			{
				ReportVoltage(device.devid, 0, m_system->GetVoltage(device, 0));
				ReportVoltage(device.devid, 1, m_system->GetVoltage(device, 1));
				ReportVoltage(device.devid, 2, m_system->GetVoltage(device, 2));
				ReportVoltage(device.devid, 3, m_system->GetVoltage(device, 3));
				break;
			}

		case smart_battery_monitor:
			{
				float temperature = m_system->GetTemperature(device);
				if (IsTemperatureValid(device.family, temperature))
				{
					ReportTemperature(device.devid, temperature);
				}
				ReportHumidity(device.devid,m_system->GetHumidity(device));
				ReportVoltage(device.devid, 0, m_system->GetVoltage(device, 0));   // VAD
				ReportVoltage(device.devid, 1, m_system->GetVoltage(device, 1));   // VDD
				ReportVoltage(device.devid, 2, m_system->GetVoltage(device, 2));   // vis
				ReportPressure(device.devid,m_system->GetPressure(device));
				// Commonly used as Illuminance sensor, see http://www.hobby-boards.com/store/products/Solar-Radiation-Detector.html
				ReportIlluminance(device.devid, m_system->GetIlluminance(device));
				break;
			}
		default: // not a supported sensor
			break;
		}
	}
}
Пример #3
0
void C1Wire::GetDeviceDetails()
{
	if (!m_system)
		return;

	// Get all devices
	if ((m_devices.size() == 0) || (m_sql.m_bAcceptNewHardware))
	{
		_log.Log(LOG_STATUS, "1-Wire: Searching devices...");
		m_devices.clear();
		m_system->GetDevices(m_devices);
	}

	if (typeid(*m_system) == typeid(C1WireByOWFS) && (m_devices.size() > 2))
	{
		if (m_mainworker.GetVerboseLevel() == EVBL_DEBUG)
		{
			_log.Log(LOG_STATUS, "1Wire (OWFS): Sending 'Skip ROM' command");
		}
		std::ofstream file;
		file.open(OWFS_Simultaneous);
		if (file.is_open())
		{
			file << "1";
			file.close();
			if (m_mainworker.GetVerboseLevel() == EVBL_DEBUG)
			{
				_log.Log(LOG_STATUS, "1Wire (OWFS): Sent 'Skip ROM' command");
			}
		}
	}

	// Parse our devices (have to test m_stoprequested because it can take some time in case of big networks)
	std::vector<_t1WireDevice>::const_iterator itt;
	for (itt=m_devices.begin(); itt!=m_devices.end() && !m_stoprequested; ++itt)
	{
		const _t1WireDevice& device=*itt;

		// Manage families specificities
		switch(device.family)
		{
		case high_precision_digital_thermometer:
		case Thermachron:
		case Econo_Digital_Thermometer:
		case Temperature_memory:
		case programmable_resolution_digital_thermometer:
			{
				float temperature=m_system->GetTemperature(device);
			if (IsTemperatureValid(device.family, temperature))
			{
				ReportTemperature(device.devid, temperature);
			}
				break;
			}

		case Addresable_Switch:
		case microlan_coupler:
			{
				ReportLightState(device.devid,0,m_system->GetLightState(device,0));
				break;
			}

		case dual_addressable_switch_plus_1k_memory:
			{
				ReportLightState(device.devid,0,m_system->GetLightState(device,0));
				if (m_system->GetNbChannels(device) == 2)
					ReportLightState(device.devid,1,m_system->GetLightState(device,1));
				break;
			}

		case _8_channel_addressable_switch:
			{
				ReportLightState(device.devid,0,m_system->GetLightState(device,0));
				ReportLightState(device.devid,1,m_system->GetLightState(device,1));
				ReportLightState(device.devid,2,m_system->GetLightState(device,2));
				ReportLightState(device.devid,3,m_system->GetLightState(device,3));
				ReportLightState(device.devid,4,m_system->GetLightState(device,4));
				ReportLightState(device.devid,5,m_system->GetLightState(device,5));
				ReportLightState(device.devid,6,m_system->GetLightState(device,6));
				ReportLightState(device.devid,7,m_system->GetLightState(device,7));
				break;
			}

		case Temperature_IO:
			{
		  float temperature = m_system->GetTemperature(device);
		  if (IsTemperatureValid(device.family, temperature))
		  {
			  ReportTemperature(device.devid, temperature);
		  }
		  ReportLightState(device.devid, 0, m_system->GetLightState(device, 0));
		  ReportLightState(device.devid, 1, m_system->GetLightState(device, 1));
		  break;
			}

		case dual_channel_addressable_switch:
		case _4k_EEPROM_with_PIO:
			{
				ReportLightState(device.devid,0,m_system->GetLightState(device,0));
				ReportLightState(device.devid,1,m_system->GetLightState(device,1));
				break;
			}

		case Environmental_Monitors:
			{
		  float temperature = m_system->GetTemperature(device);
		  if (IsTemperatureValid(device.family, temperature))
		  {
			  ReportTemperatureHumidity(device.devid, temperature, m_system->GetHumidity(device));
		  }
		  ReportPressure(device.devid,m_system->GetPressure(device));
		  break;
			}

		case _4k_ram_with_counter:
			{
				ReportCounter(device.devid,0,m_system->GetCounter(device,0));
				ReportCounter(device.devid,1,m_system->GetCounter(device,1));
				break;
			}

		case quad_ad_converter:
			{
				ReportVoltage(device.devid, 0, m_system->GetVoltage(device, 0));
				ReportVoltage(device.devid, 1, m_system->GetVoltage(device, 1));
				ReportVoltage(device.devid, 2, m_system->GetVoltage(device, 2));
				ReportVoltage(device.devid, 3, m_system->GetVoltage(device, 3));
				break;
			}

		case Serial_ID_Button:
			{
				// Nothing to do with these devices for Domoticz ==> Filtered
				break;
			}

		case smart_battery_monitor:
			{
				float temperature = m_system->GetTemperature(device);
				if (IsTemperatureValid(device.family, temperature))
				{
					ReportTemperature(device.devid, temperature);
				}
				ReportHumidity(device.devid,m_system->GetHumidity(device));
				ReportVoltage(device.devid, 0, m_system->GetVoltage(device, 0));   // VAD
				ReportVoltage(device.devid, 1, m_system->GetVoltage(device, 1));   // VDD
				ReportVoltage(device.devid, 2, m_system->GetVoltage(device, 2));   // vis
				ReportPressure(device.devid,m_system->GetPressure(device));
				// Commonly used as Illuminance sensor, see http://www.hobby-boards.com/store/products/Solar-Radiation-Detector.html
				ReportIlluminance(device.devid, m_system->GetIlluminance(device));
				break;
			}

		case silicon_serial_number:
		{ // this is only chip with id (equal device.filename and device.devid)
			break;
		}

		default: // Device is not actually supported
			{
				_log.Log(LOG_ERROR,"1-Wire : Device family (%02x) is not actually supported", device.family);
				break;
			}
		}
	}
}
Пример #4
0
void C1Wire::GetDeviceDetails()
{
    if (!m_system)
        return;

    // Get all devices
    std::vector<_t1WireDevice> devices;
    m_system->GetDevices(devices);

    // Parse our devices (have to test m_stoprequested because it can take some time in case of big networks)
    std::vector<_t1WireDevice>::const_iterator itt;
    for (itt=devices.begin(); itt!=devices.end() && !m_stoprequested; ++itt)
    {
        const _t1WireDevice& device=*itt;

        // Manage families specificities
        switch(device.family)
        {
        case high_precision_digital_thermometer:
        case Thermachron:
        case Econo_Digital_Thermometer:
        case Temperature_memory:
        case programmable_resolution_digital_thermometer:
        {
            float temperature=m_system->GetTemperature(device);

            // Filter invalid temperature
            if (IsTemperatureValid(device.family,temperature))
                ReportTemperature(device.devid,temperature);

            break;
        }

        case Addresable_Switch:
        case microlan_coupler:
        {
            ReportLightState(device.devid,0,m_system->GetLightState(device,0));
            break;
        }

        case dual_addressable_switch_plus_1k_memory:
        {
            ReportLightState(device.devid,0,m_system->GetLightState(device,0));
            if (m_system->GetNbChannels(device) == 2)
                ReportLightState(device.devid,1,m_system->GetLightState(device,1));
            break;
        }

        case _8_channel_addressable_switch:
        {
            ReportLightState(device.devid,0,m_system->GetLightState(device,0));
            ReportLightState(device.devid,1,m_system->GetLightState(device,1));
            ReportLightState(device.devid,2,m_system->GetLightState(device,2));
            ReportLightState(device.devid,3,m_system->GetLightState(device,3));
            ReportLightState(device.devid,4,m_system->GetLightState(device,4));
            ReportLightState(device.devid,5,m_system->GetLightState(device,5));
            ReportLightState(device.devid,6,m_system->GetLightState(device,6));
            ReportLightState(device.devid,7,m_system->GetLightState(device,7));
            break;
        }

        case Temperature_IO:
        {
            ReportTemperature(device.devid,m_system->GetTemperature(device));
            ReportLightState(device.devid,0,m_system->GetLightState(device,0));
            ReportLightState(device.devid,1,m_system->GetLightState(device,1));
            break;
        }

        case dual_channel_addressable_switch:
        case _4k_EEPROM_with_PIO:
        {
            ReportLightState(device.devid,0,m_system->GetLightState(device,0));
            ReportLightState(device.devid,1,m_system->GetLightState(device,1));
            break;
        }

        case Environmental_Monitors:
        {
            ReportTemperatureHumidity(device.devid,m_system->GetTemperature(device),m_system->GetHumidity(device));
            break;
        }

        case _4k_ram_with_counter:
        {
            ReportCounter(device.devid,0,m_system->GetCounter(device,0));
            ReportCounter(device.devid,1,m_system->GetCounter(device,1));
            break;
        }

        case quad_ad_converter:
        {
            ReportVoltage(0,m_system->GetVoltage(device,0));
            ReportVoltage(1,m_system->GetVoltage(device,1));
            ReportVoltage(2,m_system->GetVoltage(device,2));
            ReportVoltage(3,m_system->GetVoltage(device,3));
            break;
        }

        case Serial_ID_Button:
        {
            // Nothing to do with these devices for Domoticz ==> Filtered
            break;
        }

        default: // Device is not actually supported
        {
            _log.Log(LOG_NORM,"1-Wire : Device family (%02x) is not actualy supported", device.family);
            break;
        }
        }
    }
}