FakeSMCSensor *FakeSMCPlugin::addSensor(const char *abbriviation, kFakeSMCCategory category, UInt32 group, UInt32 index, float reference, float gain, float offset) { SYNCLOCK; FakeSMCSensor *sensor = NULL; if (abbriviation && strlen(abbriviation) >= 3) { for (int i = 0; FakeSMCSensorDefinitions[i].name; i++) { if (FakeSMCSensorDefinitions[i].category == category && 0 == strcasecmp(FakeSMCSensorDefinitions[i].name, abbriviation)) { if (FakeSMCSensorDefinitions[i].count) { for (int counter = 0; counter < FakeSMCSensorDefinitions[i].count; counter++) { char key[5]; snprintf(key, 5, FakeSMCSensorDefinitions[i].key, FakeSMCSensorDefinitions[i].shift + counter); if (!isKeyExists(key)) { sensor = addSensor(key, FakeSMCSensorDefinitions[i].type, FakeSMCSensorDefinitions[i].size, group, index, reference, gain, offset); break; } } } else sensor = addSensor(FakeSMCSensorDefinitions[i].key, FakeSMCSensorDefinitions[i].type, FakeSMCSensorDefinitions[i].size, group, index, reference, gain, offset); } } } SYNCUNLOCK; return sensor; }
void Sensors::createSensors() { AIBodyImpl *body = AIBodyImpl::getInstance(); Xml config = body -> getConfigService(); Xml configSensors = config.getChildNode( "sensors" ); addSensor( configSensors , Sensor::createFileSysWalker( this ) ); addSensor( configSensors , Sensor::createEye( this ) ); }
int main(int argc, char *argv[]) { SensorInfo *head = addSensor("Solar Panel", "V"); SensorInfo *node1 = addSensor("Test", "N/A"); SensorInfo *node2 = addSensor("Time",":"); SensorInfo *node3 = addSensor("Date", "\\"); addNodeToList(head, node1); addNodeToList(head, node2); addNodeToList(head, node3); printlist(head); printf("Size of SensorInfo: %lu bytes.\n\n", sizeof(*head)); SensorInfo *find = searchList("Date", head); printf("Node Found: %s\n", find->_sensorName); return 0; }
bool LPCSensors::addVoltageSensors(OSDictionary *configuration) { HWSensorsDebugLog("adding voltage sensors..."); for (int i = 0; i < voltageSensorsLimit(); i++) { char key[5]; snprintf(key, 5, "VIN%X", i); if (OSObject* node = configuration->getObject(key)) { if (!addSensor(node, kFakeSMCCategoryVoltage, kFakeSMCVoltageSensor, i)) { if (gpuIndex < 0) gpuIndex = takeVacantGPUIndex(); if (gpuIndex >= 0 && checkConfigurationNode(configuration, "GPU Core")) { snprintf(key, 5, KEY_FORMAT_GPU_VOLTAGE, gpuIndex); if (!addSensorFromConfigurationNode(node, key, TYPE_FP2E, TYPE_FPXX_SIZE, kFakeSMCVoltageSensor, i)) { releaseGPUIndex(gpuIndex); gpuIndex = -1; } } } } } return true; }
int SensorManager::requestSensor(const QString& id) { sensordLogD() << "Requesting sensor: " << id; clearError(); QString cleanId = getCleanId(id); QMap<QString, SensorInstanceEntry>::iterator entryIt = sensorInstanceMap_.find(cleanId); if ( entryIt == sensorInstanceMap_.end() ) { setError(SmIdNotRegistered, QString(tr("requested sensor id '%1' not registered")).arg(cleanId)); return INVALID_SESSION; } int sessionId = createNewSessionId(); if(!entryIt.value().sensor_) { AbstractSensorChannel* sensor = addSensor(id); if ( sensor == NULL ) { setError(SmNotInstantiated, tr("sensor has not been instantiated")); return INVALID_SESSION; } entryIt.value().sensor_ = sensor; } entryIt.value().sessions_.insert(sessionId); return sessionId; }
bool LPCSensors::addTemperatureSensors(OSDictionary *configuration) { HWSensorsDebugLog("adding temperature sensors..."); for (int i = 0; i < temperatureSensorsLimit(); i++) { char key[8]; snprintf(key, 8, "TEMPIN%X", i); if (OSObject* node = configuration->getObject(key)) { if (!addSensor(node, kFakeSMCCategoryTemperature, kFakeSMCTemperatureSensor, i)) { if (gpuIndex < 0) gpuIndex = takeVacantGPUIndex(); if (gpuIndex >= 0 && checkConfigurationNode(configuration, "GPU Die")) { snprintf(key, 5, KEY_FORMAT_GPU_DIODE_TEMPERATURE, gpuIndex); if (!addSensorFromConfigurationNode(node, key, TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCTemperatureSensor, i)) { releaseGPUIndex(gpuIndex); gpuIndex = -1; } } } } } return true; }
FakeSMCSensor *FakeSMCPlugin::addTachometer(UInt32 index, const char* name, SInt8 *fanIndex) { SInt8 vacantFanIndex = takeVacantFanIndex(); if (vacantFanIndex >= 0) { char key[5]; snprintf(key, 5, KEY_FORMAT_FAN_SPEED, vacantFanIndex); if (FakeSMCSensor *sensor = addSensor(key, TYPE_FPE2, 2, kFakeSMCTachometerSensor, index)) { if (name) { snprintf(key, 5, KEY_FORMAT_FAN_ID, vacantFanIndex); if (!setKeyValue(key, TYPE_CH8, strlen(name), name)) HWSensorsWarningLog("failed to add tachometer name for key %s", key); } if (fanIndex) *fanIndex = vacantFanIndex; return sensor; } else HWSensorsErrorLog("failed to add tachometer sensor for key %s", key); } else HWSensorsErrorLog("failed to take vacant Fan index"); return 0; }
FakeSMCSensor *FakeSMCPlugin::addSensor(OSObject *node, kFakeSMCCategory category, UInt32 group, UInt32 index) { SYNCLOCK; FakeSMCSensor *sensor = NULL; if (node) { float reference = 0, gain = 0, offset = 0; OSString *abbriviation = NULL; if (OSDictionary *dictionary = OSDynamicCast(OSDictionary, node)) { if ((abbriviation = OSDynamicCast(OSString, dictionary->getObject("name")))) { FakeSMCSensor::parseModifiers(dictionary, &reference, &gain, &offset); } } else abbriviation = OSDynamicCast(OSString, node); if (abbriviation) sensor = addSensor(abbriviation->getCStringNoCopy(), category, group, index, reference, gain, offset); } SYNCUNLOCK; return sensor; }
SuperIOSensor *SuperIOMonitor::addTachometer(unsigned long index, const char* id) { UInt8 length = 0; void * data = 0; if (kIOReturnSuccess == fakeSMC->callPlatformFunction(kFakeSMCGetKeyValue, true, (void *)KEY_FAN_NUMBER, (void *)&length, (void *)&data, 0)) { length = 0; bcopy(data, &length, 1); char name[5]; snprintf(name, 5, KEY_FORMAT_FAN_SPEED, length); if (SuperIOSensor *sensor = addSensor(name, TYPE_FPE2, 2, kSuperIOTachometerSensor, index)) { if (id) { snprintf(name, 5, KEY_FORMAT_FAN_ID, length); if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCAddKeyValue, false, (void *)name, (void *)TYPE_CH8, (void *)((UInt64)strlen(id)), (void *)id)) WarningLog("error adding tachometer id value"); } length++; if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCSetKeyValue, true, (void *)KEY_FAN_NUMBER, (void *)1, (void *)&length, 0)) WarningLog("error updating FNum value"); return sensor; } } else WarningLog("error reading FNum value"); return 0; }
bool LogFile::restoreSettings(QDomElement& element) { QFont font; QPalette cgroup = monitor->palette(); cgroup.setColor(QPalette::Active, QPalette::Text, restoreColor(element, "textColor", Qt::green)); cgroup.setColor(QPalette::Active, QPalette::Base, restoreColor(element, "backgroundColor", Qt::black)); cgroup.setColor(QPalette::Disabled, QPalette::Text, restoreColor(element, "textColor", Qt::green)); cgroup.setColor(QPalette::Disabled, QPalette::Base, restoreColor(element, "backgroundColor", Qt::black)); cgroup.setColor(QPalette::Inactive, QPalette::Text, restoreColor(element, "textColor", Qt::green)); cgroup.setColor(QPalette::Inactive, QPalette::Base, restoreColor(element, "backgroundColor", Qt::black)); monitor->setPalette(cgroup); addSensor(element.attribute("hostName"), element.attribute("sensorName"), (element.attribute("sensorType").isEmpty() ? "logfile" : element.attribute("sensorType")), element.attribute("title")); font.fromString( element.attribute( "font" ) ); monitor->setFont(font); QDomNodeList dnList = element.elementsByTagName("filter"); for (int i = 0; i < dnList.count(); i++) { QDomElement element = dnList.item(i).toElement(); filterRules.append(element.attribute("rule")); } SensorDisplay::restoreSettings(element); return true; }
void PTIDSensors::parseTemperatureName(OSString *name, UInt32 index) { if (name && readTemperature(index)) { char key[5]; char str[64]; key[0] = '\0'; if (name->isEqualTo("CPU Core Package DTS") || name->isEqualTo("CPU Package Temperature")) snprintf(key, 5, KEY_CPU_PACKAGE_TEMPERATURE); else if (name->isEqualTo("CPU Temperature")) snprintf(key, 5, KEY_CPU_PROXIMITY_TEMPERATURE); else if (name->isEqualTo("PCH Temperature") || name->isEqualTo("PCH DTS Temperature from PCH")) snprintf(key, 5, KEY_PCH_DIE_TEMPERATURE); else if (name->isEqualTo("MCH DTS Temperature from PCH")) snprintf(key, 5, KEY_MCH_DIODE_TEMPERATURE); else if (name->isEqualTo("Ambient Temperature")) snprintf(key, 5, KEY_AMBIENT_TEMPERATURE); else { for (UInt8 i = 0; i < 4; i++) { snprintf(str, 64, "TS-on-DIMM%X Temperature", i); if (name->isEqualTo(str)) { snprintf(key, 5, KEY_FORMAT_DIMM_TEMPERATURE, i); break; } snprintf(str, 64, "Channel %X DIMM Temperature", i); if (name->isEqualTo(str)) { snprintf(key, 5, KEY_FORMAT_DIMM_TEMPERATURE, i); break; } } if (key[0] == '\0') { for (UInt8 i = 0; i < 8; i++) { snprintf(str, 64, "TZ0%X _TMP", i); if (name->isEqualTo(str)) { snprintf(key, 5, KEY_FORMAT_THERMALZONE_TEMPERATURE, i + 1); break; } snprintf(str, 64, "CPU Core %X DTS", i); if (name->isEqualTo(str)) { snprintf(key, 5, KEY_FORMAT_CPU_DIODE_TEMPERATURE, i); break; } } } } if (key[0] != '\0') { HWSensorsDebugLog("adding %s sensor", name->getCStringNoCopy()); addSensor(key, TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCTemperatureSensor, index); } } }
int GeforceSensors::addTachometer(int index) { UInt8 length = 0; void * data = 0; char name[5]; if (kIOReturnSuccess == fakeSMC->callPlatformFunction(kFakeSMCGetKeyValue, false, (void *)KEY_FAN_NUMBER, (void *)&length, (void *)&data, 0)) { bcopy(data, &length, 1); snprintf(name, 5, KEY_FORMAT_FAN_SPEED, length); if (addSensor(name, TYPE_FPE2, 2, index)) { length++; if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCSetKeyValue, false, (void *)KEY_FAN_NUMBER, (void *)1, (void *)&length, 0)) WarningLog("error updating FNum value"); return length-1; } } else WarningLog("error reading FNum value"); return -1; }
bool ACPIMonitor::addTachometer(const char* method, const char* caption) { UInt8 length = 0; void * data = 0; if (kIOReturnSuccess == fakeSMC->callPlatformFunction(kFakeSMCGetKeyValue, true, (void *)KEY_FAN_NUMBER, (void *)&length, (void *)&data, 0)) { length = 0; bcopy(data, &length, 1); char name[5]; snprintf(name, 5, KEY_FORMAT_FAN_SPEED, length); if (addSensor(method, name, TYPE_FPE2, 2)) { if (caption) { snprintf(name, 5, KEY_FORMAT_FAN_ID, length); if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCAddKeyValue, false, (void *)name, (void *)TYPE_CH8, (void *)((UInt64)strlen(caption)), (void *)caption)) WarningLog("error adding tachometer id value"); } length++; if (kIOReturnSuccess != fakeSMC->callPlatformFunction(kFakeSMCSetKeyValue, true, (void *)KEY_FAN_NUMBER, (void *)1, (void *)&length, 0)) WarningLog("error updating FNum value"); return true; } } else WarningLog("error reading FNum value"); return false; }
bool X3100monitor::start(IOService * provider) { if (!super::start(provider)) return false; //Find card number SInt8 cardIndex = getVacantGPUIndex(); if (cardIndex < 0) { HWSensorsWarningLog("failed to obtain vacant GPU index"); return false; } char key[5]; snprintf(key, 5, KEY_FORMAT_GPU_PROXIMITY_TEMPERATURE, cardIndex); if (!addSensor(key, TYPE_SP78, 2, kFakeSMCTemperatureSensor, 0)) { HWSensorsWarningLog("failed to register temperature sensor"); return false; } registerService(); return true; }
bool TZSensors::start(IOService * provider) { if (!super::start(provider)) return false; acpiDevice = (IOACPIPlatformDevice *)provider; if (!acpiDevice) { HWSensorsFatalLog("ACPI device not ready"); return false; } OSObject *object = NULL; if(kIOReturnSuccess == acpiDevice->evaluateObject("_TMP", &object) && object) { for (UInt8 i = 0; i < 0xf; i++) { char key[5]; snprintf(key, 5, KEY_FORMAT_THERMALZONE_TEMPERATURE, i); if (!isKeyHandled(key)) { if (addSensor(key, TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCTemperatureSensor, 0)) { break; } } } } registerService(); HWSensorsInfoLog("started on %s", acpiDevice->getName()); return true; }
/* * addSensor (type, value) - add sensor value to frame * * Parameters: * type : Refers to the type of sensor data * value : indicates the sensor value as a float * * Returns: * 'length' of the composed frame when ok * -1 when the maximum length of the frame is reached * */ int8_t WaspFrame::addSensor(uint8_t type, double value) { // get name of sensor from table char numDecimals; numDecimals =(uint8_t)pgm_read_word(&(DECIMAL_TABLE[type])); return addSensor(type, value, numDecimals); }
void PTIDSensors::parseTemperatureName(OSString *name, UInt32 index) { if (name && readTemperature(index)) { if (name->isEqualTo("CPU Core Package DTS") || name->isEqualTo("CPU Package Temperature")) addSensor("CPU Package", kFakeSMCCategoryTemperature, kFakeSMCTemperatureSensor, index); else if (name->isEqualTo("CPU Temperature")) addSensor("CPU Proximity", kFakeSMCCategoryTemperature, kFakeSMCTemperatureSensor, index); else if (name->isEqualTo("PCH Temperature") || name->isEqualTo("PCH DTS Temperature from PCH")) addSensor("PCH Die", kFakeSMCCategoryTemperature, kFakeSMCTemperatureSensor, index); else if (name->isEqualTo("MCH DTS Temperature from PCH")) addSensor("MCH Die", kFakeSMCCategoryTemperature, kFakeSMCTemperatureSensor, index); else if (name->isEqualTo("Ambient Temperature")) addSensor("Ambient", kFakeSMCCategoryTemperature, kFakeSMCTemperatureSensor, index); else { char str[64]; for (UInt8 i = 0; i < 4; i++) { snprintf(str, 64, "TS-on-DIMM%X Temperature", i); if (name->isEqualTo(str)) { addSensor("Memory Module", kFakeSMCCategoryTemperature, kFakeSMCTemperatureSensor, index); break; } snprintf(str, 64, "Channel %X DIMM Temperature", i); if (name->isEqualTo(str)) { addSensor("Memory Proximity", kFakeSMCCategoryTemperature, kFakeSMCTemperatureSensor, index); break; } } for (UInt8 i = 0; i < 8; i++) { snprintf(str, 64, "TZ0%X _TMP", i); if (name->isEqualTo(str)) { addSensor("Thermal Zone", kFakeSMCCategoryTemperature, kFakeSMCTemperatureSensor, index); break; } snprintf(str, 64, "CPU Core %X DTS", i); if (name->isEqualTo(str)) { addSensor("CPU Core", kFakeSMCCategoryTemperature, kFakeSMCTemperatureSensor, index); break; } } } } }
void VideoBasedTracker::addSensor(LedIdentifier *identifier, DoubleVecVec const &m, std::vector<double> const &d, Point3Vector const &locations, size_t requiredInliers, size_t permittedOutliers) { addSensor(LedIdentifierPtr(identifier), m, d, locations, requiredInliers, permittedOutliers); }
Animal::Animal() : Object(OBJ_TYPE_ANIMAL) { energy = 80.0; speed = 80.0; if (!samplesInitialized) { for (int i = 0; i < 16; i++) { voiceSamples[i] = 0; } samplesInitialized = true; } voice = dna.getVoice(); RandomNumberGenerator *rng = RandomNumberGenerator::getInstance(); voiceInterval = ((double) rng->getInt(500, 5000)) / 1000.0; addSensor(dna.getSightSensor()); addSensor(dna.getDigestiveSystem()); addSensor(dna.getHearingSensor()); addSensor(dna.getNervousSystem()); }
bool GmaSensors::managedStart(IOService *provider) { IOPhysicalAddress bar = (IOPhysicalAddress)((pciDevice->configRead32(kMCHBAR)) & ~0xf); HWSensorsDebugLog("Fx3100: register space=%08lx", (long unsigned int)bar); if(IOMemoryDescriptor * theDescriptor = IOMemoryDescriptor::withPhysicalAddress (bar, 0x2000, kIODirectionOutIn)) { if ((mmio = theDescriptor->map())) { mmio_base = (volatile UInt8 *)mmio->getVirtualAddress(); /*HWSensorsDebugLog("MCHBAR mapped"); for (int i = 0; i < 0x2f; i += 16) { HWSensorsDebugLog("%04lx: ", (long unsigned int)i+0x1000); for (int j=0; j<16; j += 1) { HWSensorsDebugLog("%02lx ", (long unsigned int)INVID8(i+j+0x1000)); } HWSensorsDebugLog(""); }*/ } else { HWSensorsInfoLog("MCHBAR failed to map"); return false; } } enableExclusiveAccessMode(); //Find card number gpuIndex = takeVacantGPUIndex(); if (gpuIndex < 0) { HWSensorsFatalLog("failed to obtain vacant GPU index"); return false; } char key[5]; snprintf(key, 5, KEY_FORMAT_GPU_PROXIMITY_TEMPERATURE, gpuIndex); if (!addSensor(key, TYPE_SP78, 2, kFakeSMCTemperatureSensor, 0)) { HWSensorsFatalLog("failed to register temperature sensor"); releaseGPUIndex(gpuIndex); gpuIndex = -1; return false; } disableExclusiveAccessMode(); registerService(); return true; }
bool TZSensors::start(IOService * provider) { if (!super::start(provider)) return false; acpiDevice = (IOACPIPlatformDevice *)provider; if (!acpiDevice) { HWSensorsFatalLog("ACPI device not ready"); return false; } if (OSDictionary *configuration = getConfigurationNode()) { OSBoolean* disable = OSDynamicCast(OSBoolean, configuration->getObject("DisableDevice")); if (disable && disable->isTrue()) return false; } // On some computers (eg. RehabMan's ProBook 4530s), the system will hang on startup // if kernel cache is used, because of the early call to updateTemperatures and/or // updateTachometers. At least that is the case with an SSD and a valid pre-linked // kernel, along with kernel cache enabled. This 1000ms sleep seems to fix the problem, // enabling a clean boot with TZSensors enabled. // // On the ProBook this is the case with both TZSensors and PTIDSensors, although // PTIDSensors can be avoided by using DropSSDT=Yes (because PTID device is in an SSDT) // // And in the case of TZSensors it even happens (intermittently) without kernel cache. IOSleep(1000); OSObject *object = NULL; if(kIOReturnSuccess == acpiDevice->evaluateObject("_TMP", &object) && object) { for (UInt8 i = 0; i < 0xf; i++) { char key[5]; snprintf(key, 5, KEY_FORMAT_THERMALZONE_TEMPERATURE, i); if (!isKeyHandled(key)) { if (addSensor(key, TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCTemperatureSensor, 0)) { break; } } } } registerService(); HWSensorsInfoLog("started on %s", acpiDevice->getName()); return true; }
void INT340EMonitor::parseTemperatureName(OSString *name, UInt32 index) { if (name && readTemperature(index)) { char key[5]; char str[64]; for (UInt8 i = 0; i < 8; i++) { snprintf(str, 64, "CPU Core %x DTS", i); if (name->isEqualTo(str)) { snprintf(key, 5, KEY_FORMAT_CPU_DIODE_TEMPERATURE, i); break; } } if (name->isEqualTo("CPU Core Package DTS") || name->isEqualTo("CPU Package Temperature")) snprintf(key, 5, KEY_CPU_PACKAGE_TEMPERATURE); if (name->isEqualTo("CPU Temperature")) snprintf(key, 5, KEY_CPU_PROXIMITY_TEMPERATURE); if (name->isEqualTo("PCH Temperature") || name->isEqualTo("PCH DTS Temperature from PCH")) snprintf(key, 5, KEY_PCH_DIE_TEMPERATURE); if (name->isEqualTo("MCH DTS Temperature from PCH")) snprintf(key, 5, KEY_MCH_DIODE_TEMPERATURE); if (name->isEqualTo("Ambient Temperature")) snprintf(key, 5, KEY_AMBIENT_TEMPERATURE); for (UInt8 i = 0; i < 4; i++) { snprintf(str, 64, "TS-on-DIMM%x Temperature", i); if (name->isEqualTo(str)) { snprintf(key, 5, KEY_FORMAT_DIMM_TEMPERATURE, i); break; } } for (UInt8 i = 0; i < 8; i++) { snprintf(str, 64, "TZ0%x _TMP", i); if (name->isEqualTo(str)) { snprintf(key, 5, KEY_FORMAT_THERMALZONE_TEMPERATURE, i + 1); break; } } if (strlen(key)) addSensor(key, TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCTemperatureSensor, index); } }
bool SuperIOMonitor::addTemperatureSensors(OSDictionary *configuration) { HWSensorsDebugLog("adding temperature sensors..."); for (int i = 0; i < temperatureSensorsLimit(); i++) { char key[8]; OSString* name; float reference = 0.0f; float gain = 0.0f; float offset = 0.0f; snprintf(key, 8, "TEMPIN%X", i); if (process_sensor_entry(configuration->getObject(key), &name, &reference, &gain, &offset)) { if (name->isEqualTo("CPU")) { if (!addSensor(KEY_CPU_HEATSINK_TEMPERATURE, TYPE_SP78, TYPE_SPXX_SIZE, kSuperIOTemperatureSensor, i, reference, gain, offset)) HWSensorsWarningLog("can't add CPU temperature sensor"); } if (name->isEqualTo("CPU Proximity")) { if (!addSensor(KEY_CPU_PROXIMITY_TEMPERATURE, TYPE_SP78, TYPE_SPXX_SIZE, kSuperIOTemperatureSensor, i, reference, gain, offset)) HWSensorsWarningLog("can't add CPU Proximity temperature sensor"); } else if (name->isEqualTo("System")) { if (!addSensor(KEY_NORTHBRIDGE_TEMPERATURE, TYPE_SP78, TYPE_SPXX_SIZE, kSuperIOTemperatureSensor, i, reference, gain, offset)) HWSensorsWarningLog("can't add System temperature sensor"); } else if (name->isEqualTo("Ambient")) { if (!addSensor(KEY_AMBIENT_TEMPERATURE, TYPE_SP78, TYPE_SPXX_SIZE, kSuperIOTemperatureSensor, i, reference, gain, offset)) HWSensorsWarningLog("can't add Ambient temperature sensor"); } else if (name->isEqualTo("PCH")) { if (!addSensor(KEY_PCH_DIE_TEMPERATURE, TYPE_SP78, TYPE_SPXX_SIZE, kSuperIOTemperatureSensor, i, reference, gain, offset)) HWSensorsWarningLog("can't add PCH temperature sensor"); } } } return true; }
bool ACPISensors::addSensorToList(OSDictionary *list, OSString *configKey, OSString *acpiMethod, const char *refName, const char* smcKey, const char *type, UInt8 size, UInt32 group, UInt32 index) { if (configKey->isEqualTo(refName)) { if (addSensor(smcKey, type, size, group, index)) { list->setObject(smcKey, acpiMethod); return true; } } HWSensorsWarningLog("failed to register sensor for key %s", configKey->getCStringNoCopy()); return false; }
FakeSMCSensor *FakeSMCPlugin::addSensor(const char *key, const char *type, UInt8 size, UInt32 group, UInt32 index, float reference, float gain, float offset) { SYNCLOCK; if (FakeSMCSensor *sensor = FakeSMCSensor::withOwner(this, key, type, size, group, index, reference, gain, offset)) { if (addSensor(sensor)) { SYNCUNLOCK; return sensor; } else OSSafeRelease(sensor); } SYNCUNLOCK; return NULL; }
FakeSMCSensor *FakeSMCPlugin::addSensor(const char *key, const char *type, UInt8 size, UInt32 group, UInt32 index, float reference, float gain, float offset) { if (getSensor(key)) { HWSensorsDebugLog("will not add handler for key %s, key already handled", key); return NULL; } if (FakeSMCSensor *sensor = FakeSMCSensor::withOwner(this, key, type, size, group, index, reference, gain, offset)) { if (addSensor(sensor)) return sensor; else OSSafeRelease(sensor); } return NULL; }
FakeSMCSensor *FakeSMCPlugin::addTachometer(UInt32 index, const char* name, UInt8 *fanIndex) { UInt8 length = 0; void * data = 0; if (kIOReturnSuccess == storageProvider->callPlatformFunction(kFakeSMCGetKeyValue, true, (void *)KEY_FAN_NUMBER, (void *)&length, (void *)&data, 0)) { length = 0; bcopy(data, &length, 1); for (int i = 0; i <= 0xf; i++) { char key[5]; snprintf(key, 5, KEY_FORMAT_FAN_SPEED, i); if (!isKeyHandled(key)) { if (FakeSMCSensor *sensor = addSensor(key, TYPE_FPE2, 2, kFakeSMCTachometerSensor, index)) { if (name) { snprintf(key, 5, KEY_FORMAT_FAN_ID, i); if (!setKeyValue(key, TYPE_CH8, strlen(name), name)) HWSensorsWarningLog("failed to add tachometer name for key %s", key); } if (i + 1 > length) { length++; if (kIOReturnSuccess != storageProvider->callPlatformFunction(kFakeSMCSetKeyValue, true, (void *)KEY_FAN_NUMBER, (void *)(UInt8)1, (void *)&length, 0)) HWSensorsWarningLog("failed to update FNum value"); } if (fanIndex) *fanIndex = i; return sensor; } else HWSensorsWarningLog("failed to add tachometer sensor for key %s", key); } } } else HWSensorsWarningLog("failed to read FNum value"); return 0; }
FakeSMCSensor *FakeSMCPlugin::addTachometer(UInt32 index, const char *name, FanType type, UInt8 zone, FanLocationType location, SInt8 *fanIndex) { SYNCLOCK; SInt8 vacantFanIndex = takeVacantFanIndex(); if (vacantFanIndex >= 0) { char key[5]; snprintf(key, 5, KEY_FORMAT_FAN_SPEED, vacantFanIndex); if (FakeSMCSensor *sensor = addSensor(key, TYPE_FPE2, TYPE_FPXX_SIZE, kFakeSMCTachometerSensor, index)) { FanTypeDescStruct fds; bzero(&fds, sizeof(fds)); fds.type = type; fds.ui8Zone = zone; fds.location = location; if (name) strlcpy(fds.strFunction, name, DIAG_FUNCTION_STR_LEN); else snprintf(fds.strFunction, DIAG_FUNCTION_STR_LEN, "MB Fan %X", index); snprintf(key, 5, KEY_FORMAT_FAN_ID, vacantFanIndex); if (!setKeyValue(key, TYPE_FDS, sizeof(fds), &fds)) HWSensorsWarningLog("failed to add tachometer name for key %s", key); if (fanIndex) *fanIndex = vacantFanIndex; SYNCUNLOCK; return sensor; } else HWSensorsErrorLog("failed to add tachometer sensor for key %s", key); } else HWSensorsErrorLog("failed to take vacant Fan index"); SYNCUNLOCK; return 0; }
bool ProcessController::restoreSettings(QDomElement& element) { bool result = addSensor(element.attribute("hostName"), element.attribute("sensorName"), (element.attribute("sensorType").isEmpty() ? "table" : element.attribute("sensorType")), QString()); if(!result) return false; int version = element.attribute("version", "0").toUInt(); if(version == PROCESSHEADERVERSION) { //If the header has changed, the old settings are no longer valid. Only restore if version is the same mProcessList->restoreHeaderState(QByteArray::fromBase64(element.attribute("treeViewHeader").toLatin1())); } bool showTotals = element.attribute("showTotals", "1").toUInt(); mProcessList->setShowTotals(showTotals); int units = element.attribute("units", QString::number((int)ProcessModel::UnitsKB)).toUInt(); mProcessList->setUnits((ProcessModel::Units)units); int ioUnits = element.attribute("ioUnits", QString::number((int)ProcessModel::UnitsKB)).toUInt(); mProcessList->processModel()->setIoUnits((ProcessModel::Units)ioUnits); int ioInformation = element.attribute("ioInformation", QString::number((int)ProcessModel::ActualBytesRate)).toUInt(); mProcessList->processModel()->setIoInformation((ProcessModel::IoInformation)ioInformation); bool showCommandLineOptions = element.attribute("showCommandLineOptions", "0").toUInt(); mProcessList->processModel()->setShowCommandLineOptions(showCommandLineOptions); bool showTooltips = element.attribute("showTooltips", "1").toUInt(); mProcessList->processModel()->setShowingTooltips(showTooltips); bool normalizeCPUUsage = element.attribute("normalizeCPUUsage", "1").toUInt(); mProcessList->processModel()->setNormalizedCPUUsage(normalizeCPUUsage); int filterState = element.attribute("filterState", QString::number((int)ProcessFilter::AllProcesses)).toUInt(); mProcessList->setState((ProcessFilter::State)filterState); SensorDisplay::restoreSettings(element); return result; }
void ClientBlock::BlockMessage(QString message) { QString cmd_name = message; cmd_name.replace(QRegExp("=(.*)$"), ""); if(cmd_name.length()==message.length()) cmd_name=""; if (cmd_name.isEmpty()) return; QString cmd_param = message; cmd_param.replace(QRegExp("^([^=]*)=(.*)$"), "\\2"); if (cmd_name=="DS_INFO") { addSensor(cmd_param); } else if (cmd_name=="DC_INFO") { addAction(cmd_param); } else if (cmd_name=="DS_V") { setSensorsValues(cmd_param); } else if (cmd_name=="DS_READY") { if (cmd_param=="1") { is_ready = true; emit block_ready(); } } else if (cmd_name=="DS_GETTIME") { if (cmd_param=="1" && client_actions->contains("settime")) { QTimer::singleShot(100, this, SLOT(action_time_send())); } } else if (cmd_name=="DS_GETFORECAST") { if (cmd_param=="1" && client_actions->contains("setforecast")) { QTimer::singleShot(100, this, SLOT(action_forecast_send())); } } else if (cmd_name=="DS_WIFI_SSID") { wifi_ssid = cmd_param; } else if (cmd_name=="DS_WIFI_PASSW") { wifi_passw = cmd_param; } else if (cmd_name=="DS_SERVER") { ds_server_addr = cmd_param; } }