|
Lines 70-75
Link Here
|
| 70 |
// Compile-time configuration |
70 |
// Compile-time configuration |
| 71 |
#include "config.h" |
71 |
#include "config.h" |
| 72 |
|
72 |
|
|
|
73 |
// Profiling stuff |
| 74 |
//#define CPUPROFILING |
| 75 |
//#define STATELESSPROFILING |
| 76 |
|
| 77 |
#include <time.h> |
| 78 |
timespec diff(timespec start, timespec end) |
| 79 |
{ |
| 80 |
timespec temp; |
| 81 |
if ((end.tv_nsec-start.tv_nsec)<0) { |
| 82 |
temp.tv_sec = end.tv_sec-start.tv_sec-1; |
| 83 |
temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec; |
| 84 |
} else { |
| 85 |
temp.tv_sec = end.tv_sec-start.tv_sec; |
| 86 |
temp.tv_nsec = end.tv_nsec-start.tv_nsec; |
| 87 |
} |
| 88 |
return temp; |
| 89 |
} |
| 90 |
|
| 73 |
// BEGIN BLOCK |
91 |
// BEGIN BLOCK |
| 74 |
// Copied from include/linux/genhd.h |
92 |
// Copied from include/linux/genhd.h |
| 75 |
#define GENHD_FL_REMOVABLE 1 |
93 |
#define GENHD_FL_REMOVABLE 1 |
|
Lines 199-204
Link Here
|
| 199 |
m_deviceWatchTimer = new TQTimer(this); |
217 |
m_deviceWatchTimer = new TQTimer(this); |
| 200 |
connect( m_deviceWatchTimer, SIGNAL(timeout()), this, SLOT(processStatelessDevices()) ); |
218 |
connect( m_deviceWatchTimer, SIGNAL(timeout()), this, SLOT(processStatelessDevices()) ); |
| 201 |
|
219 |
|
|
|
220 |
// Special case for battery polling (longer delay, 5 seconds) |
| 221 |
m_batteryWatchTimer = new TQTimer(this); |
| 222 |
connect( m_batteryWatchTimer, SIGNAL(timeout()), this, SLOT(processBatteryDevices()) ); |
| 223 |
|
| 202 |
// Update internal device information |
224 |
// Update internal device information |
| 203 |
queryHardwareInformation(); |
225 |
queryHardwareInformation(); |
| 204 |
} |
226 |
} |
|
Lines 207-212
Link Here
|
| 207 |
TDEHardwareDevices::~TDEHardwareDevices() { |
229 |
TDEHardwareDevices::~TDEHardwareDevices() { |
| 208 |
// Stop device scanning |
230 |
// Stop device scanning |
| 209 |
m_deviceWatchTimer->stop(); |
231 |
m_deviceWatchTimer->stop(); |
|
|
232 |
m_batteryWatchTimer->stop(); |
| 210 |
|
233 |
|
| 211 |
// [FIXME 0.01] |
234 |
// [FIXME 0.01] |
| 212 |
#if 0 |
235 |
#if 0 |
|
Lines 243-248
Link Here
|
| 243 |
if (nodezerocpufreq.exists()) { |
266 |
if (nodezerocpufreq.exists()) { |
| 244 |
m_cpuWatchTimer->start( 500, FALSE ); // 0.5 second repeating timer |
267 |
m_cpuWatchTimer->start( 500, FALSE ); // 0.5 second repeating timer |
| 245 |
} |
268 |
} |
|
|
269 |
m_batteryWatchTimer->stop(); // Battery devices are included in stateless devices |
| 246 |
m_deviceWatchTimer->start( 1000, FALSE ); // 1 second repeating timer |
270 |
m_deviceWatchTimer->start( 1000, FALSE ); // 1 second repeating timer |
| 247 |
} |
271 |
} |
| 248 |
else { |
272 |
else { |
|
Lines 251-256
Link Here
|
| 251 |
} |
275 |
} |
| 252 |
} |
276 |
} |
| 253 |
|
277 |
|
|
|
278 |
void TDEHardwareDevices::setBatteryUpdatesEnabled(bool enable) { |
| 279 |
if (enable) { |
| 280 |
TQDir nodezerocpufreq("/sys/devices/system/cpu/cpu0/cpufreq"); |
| 281 |
if (nodezerocpufreq.exists()) { |
| 282 |
m_cpuWatchTimer->start( 500, FALSE ); // 0.5 second repeating timer |
| 283 |
} |
| 284 |
m_batteryWatchTimer->start( 5000, FALSE ); // 5 second repeating timer |
| 285 |
} |
| 286 |
else { |
| 287 |
m_cpuWatchTimer->stop(); |
| 288 |
m_batteryWatchTimer->stop(); |
| 289 |
} |
| 290 |
} |
| 291 |
|
| 254 |
void TDEHardwareDevices::rescanDeviceInformation(TDEGenericDevice* hwdevice) { |
292 |
void TDEHardwareDevices::rescanDeviceInformation(TDEGenericDevice* hwdevice) { |
| 255 |
rescanDeviceInformation(hwdevice, true); |
293 |
rescanDeviceInformation(hwdevice, true); |
| 256 |
} |
294 |
} |
|
Lines 270-275
Link Here
|
| 270 |
syspath += "/"; |
308 |
syspath += "/"; |
| 271 |
} |
309 |
} |
| 272 |
TDEGenericDevice *hwdevice; |
310 |
TDEGenericDevice *hwdevice; |
|
|
311 |
|
| 273 |
// We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time |
312 |
// We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time |
| 274 |
TDEGenericHardwareList devList = listAllPhysicalDevices(); |
313 |
TDEGenericHardwareList devList = listAllPhysicalDevices(); |
| 275 |
for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) { |
314 |
for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) { |
|
Lines 281-286
Link Here
|
| 281 |
return 0; |
320 |
return 0; |
| 282 |
} |
321 |
} |
| 283 |
|
322 |
|
|
|
323 |
TDECPUDevice* TDEHardwareDevices::findCPUBySystemPath(TQString syspath, bool inCache=true) { |
| 324 |
TDECPUDevice* cdevice; |
| 325 |
|
| 326 |
// Look for the device in the cache first |
| 327 |
if(inCache && !m_cpuByPathCache.isEmpty()) { |
| 328 |
cdevice = m_cpuByPathCache.find(syspath); |
| 329 |
if(cdevice) { |
| 330 |
return cdevice; |
| 331 |
} |
| 332 |
} |
| 333 |
|
| 334 |
// If the CPU was not found in cache, we need to parse the entire device list to get it. |
| 335 |
cdevice = dynamic_cast<TDECPUDevice*>(findBySystemPath(syspath)); |
| 336 |
if(cdevice) { |
| 337 |
if(inCache) { |
| 338 |
m_cpuByPathCache.insert(syspath, cdevice); // Add the device to the cache |
| 339 |
} |
| 340 |
return cdevice; |
| 341 |
} |
| 342 |
|
| 343 |
return 0; |
| 344 |
} |
| 345 |
|
| 346 |
|
| 284 |
TDEGenericDevice* TDEHardwareDevices::findByUniqueID(TQString uid) { |
347 |
TDEGenericDevice* TDEHardwareDevices::findByUniqueID(TQString uid) { |
| 285 |
TDEGenericDevice *hwdevice; |
348 |
TDEGenericDevice *hwdevice; |
| 286 |
// We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time |
349 |
// We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time |
|
Lines 410-426
Link Here
|
| 410 |
// Detect what changed between the old cpu information and the new information, |
473 |
// Detect what changed between the old cpu information and the new information, |
| 411 |
// and emit appropriate events |
474 |
// and emit appropriate events |
| 412 |
|
475 |
|
|
|
476 |
#ifdef CPUPROFILING |
| 477 |
timespec time1, time2, time3; |
| 478 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1); |
| 479 |
time3 = time1; |
| 480 |
printf("TDEHardwareDevices::processModifiedCPUs() : begin at '%u'\n", time1.tv_nsec); |
| 481 |
#endif |
| 482 |
|
| 413 |
// Read new CPU information table |
483 |
// Read new CPU information table |
| 414 |
m_cpuInfo.clear(); |
484 |
m_cpuInfo.clear(); |
| 415 |
TQFile cpufile( "/proc/cpuinfo" ); |
485 |
TQFile cpufile( "/proc/cpuinfo" ); |
| 416 |
if ( cpufile.open( IO_ReadOnly ) ) { |
486 |
if ( cpufile.open( IO_ReadOnly ) ) { |
| 417 |
TQTextStream stream( &cpufile ); |
487 |
TQTextStream stream( &cpufile ); |
| 418 |
while ( !stream.atEnd() ) { |
488 |
// Using read() instead of readLine() inside a loop is 4 times faster ! |
| 419 |
m_cpuInfo.append(stream.readLine()); |
489 |
m_cpuInfo = TQStringList::split('\n', stream.read(), true); |
| 420 |
} |
|
|
| 421 |
cpufile.close(); |
490 |
cpufile.close(); |
| 422 |
} |
491 |
} |
| 423 |
|
492 |
|
|
|
493 |
#ifdef CPUPROFILING |
| 494 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); |
| 495 |
printf("TDEHardwareDevices::processModifiedCPUs() : checkpoint1 at %u [%u]\n", time2.tv_nsec, diff(time1,time2).tv_nsec); |
| 496 |
time1 = time2; |
| 497 |
#endif |
| 498 |
|
| 424 |
// Ensure "processor" is the first entry in each block and determine which cpuinfo type is in use |
499 |
// Ensure "processor" is the first entry in each block and determine which cpuinfo type is in use |
| 425 |
bool cpuinfo_format_x86 = true; |
500 |
bool cpuinfo_format_x86 = true; |
| 426 |
bool cpuinfo_format_arm = false; |
501 |
bool cpuinfo_format_arm = false; |
|
Lines 431-469
Link Here
|
| 431 |
TQStringList::Iterator blockBegin = m_cpuInfo.begin(); |
506 |
TQStringList::Iterator blockBegin = m_cpuInfo.begin(); |
| 432 |
for (TQStringList::Iterator cpuit1 = m_cpuInfo.begin(); cpuit1 != m_cpuInfo.end(); ++cpuit1) { |
507 |
for (TQStringList::Iterator cpuit1 = m_cpuInfo.begin(); cpuit1 != m_cpuInfo.end(); ++cpuit1) { |
| 433 |
curline1 = *cpuit1; |
508 |
curline1 = *cpuit1; |
| 434 |
curline1 = curline1.stripWhiteSpace(); |
|
|
| 435 |
if (!(*blockBegin).startsWith("processor")) { |
509 |
if (!(*blockBegin).startsWith("processor")) { |
| 436 |
bool found = false; |
510 |
bool found = false; |
| 437 |
TQStringList::Iterator cpuit2; |
511 |
TQStringList::Iterator cpuit2; |
| 438 |
for (cpuit2 = blockBegin; cpuit2 != m_cpuInfo.end(); ++cpuit2) { |
512 |
for (cpuit2 = blockBegin; cpuit2 != m_cpuInfo.end(); ++cpuit2) { |
| 439 |
curline2 = *cpuit2; |
513 |
curline2 = *cpuit2; |
| 440 |
curline2 = curline2.stripWhiteSpace(); |
|
|
| 441 |
if (curline2.startsWith("processor")) { |
514 |
if (curline2.startsWith("processor")) { |
| 442 |
found = true; |
515 |
found = true; |
| 443 |
break; |
516 |
break; |
| 444 |
} |
517 |
} |
| 445 |
else if (curline2 == "") { |
518 |
else if (curline2 == NULL || curline2 == "") { |
| 446 |
break; |
519 |
break; |
| 447 |
} |
520 |
} |
| 448 |
} |
521 |
} |
| 449 |
if (found) { |
522 |
if (found) { |
| 450 |
m_cpuInfo.insert(blockBegin, (*cpuit2)); |
523 |
m_cpuInfo.insert(blockBegin, (*cpuit2)); |
| 451 |
} |
524 |
} |
| 452 |
else { |
525 |
else if(blockNumber == 0) { |
| 453 |
m_cpuInfo.insert(blockBegin, "processor : 0"); |
526 |
m_cpuInfo.insert(blockBegin, "processor : 0"); |
| 454 |
} |
527 |
} |
| 455 |
} |
528 |
} |
| 456 |
if (curline1 == "") { |
529 |
if (curline1 == NULL || curline1 == "") { |
| 457 |
blockNumber++; |
530 |
blockNumber++; |
| 458 |
blockBegin = cpuit1; |
531 |
blockBegin = cpuit1; |
| 459 |
blockBegin++; |
532 |
blockBegin++; |
| 460 |
} |
533 |
} |
| 461 |
if (curline1.startsWith("Processor")) { |
534 |
else if (curline1.startsWith("Processor")) { |
| 462 |
cpuinfo_format_x86 = false; |
535 |
cpuinfo_format_x86 = false; |
| 463 |
cpuinfo_format_arm = true; |
536 |
cpuinfo_format_arm = true; |
| 464 |
} |
537 |
} |
| 465 |
} |
538 |
} |
| 466 |
|
539 |
|
|
|
540 |
#ifdef CPUPROFILING |
| 541 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); |
| 542 |
printf("TDEHardwareDevices::processModifiedCPUs() : checkpoint2 at %u [%u]\n", time2.tv_nsec, diff(time1,time2).tv_nsec); |
| 543 |
time1 = time2; |
| 544 |
#endif |
| 545 |
|
| 467 |
// Parse CPU information table |
546 |
// Parse CPU information table |
| 468 |
TDECPUDevice *cdevice; |
547 |
TDECPUDevice *cdevice; |
| 469 |
cdevice = 0; |
548 |
cdevice = 0; |
|
Lines 482-525
Link Here
|
| 482 |
for (cpuit = m_cpuInfo.begin(); cpuit != m_cpuInfo.end(); ++cpuit) { |
561 |
for (cpuit = m_cpuInfo.begin(); cpuit != m_cpuInfo.end(); ++cpuit) { |
| 483 |
curline = *cpuit; |
562 |
curline = *cpuit; |
| 484 |
if (curline.startsWith("processor")) { |
563 |
if (curline.startsWith("processor")) { |
| 485 |
curline.remove(0, curline.find(":")+1); |
564 |
curline.remove(0, curline.find(":")+2); |
| 486 |
curline = curline.stripWhiteSpace(); |
|
|
| 487 |
processorNumber = curline.toInt(); |
565 |
processorNumber = curline.toInt(); |
| 488 |
if (!cdevice) cdevice = dynamic_cast<TDECPUDevice*>(findBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber))); |
566 |
if (!cdevice) { |
|
|
567 |
cdevice = dynamic_cast<TDECPUDevice*>(findCPUBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber))); |
| 568 |
} |
| 489 |
if (cdevice) { |
569 |
if (cdevice) { |
| 490 |
if (cdevice->coreNumber() != processorNumber) modified = true; |
570 |
if (cdevice->coreNumber() != processorNumber) { |
| 491 |
cdevice->internalSetCoreNumber(processorNumber); |
571 |
modified = true; |
|
|
572 |
cdevice->internalSetCoreNumber(processorNumber); |
| 573 |
} |
| 492 |
} |
574 |
} |
| 493 |
} |
575 |
} |
| 494 |
if (curline.startsWith("model name")) { |
576 |
else if (cdevice && curline.startsWith("model name")) { |
| 495 |
curline.remove(0, curline.find(":")+1); |
577 |
curline.remove(0, curline.find(":")+2); |
| 496 |
curline = curline.stripWhiteSpace(); |
578 |
if (cdevice->name() != curline) { |
| 497 |
if (cdevice) { |
579 |
modified = true; |
| 498 |
if (cdevice->name() != curline) modified = true; |
|
|
| 499 |
cdevice->internalSetName(curline); |
580 |
cdevice->internalSetName(curline); |
| 500 |
} |
581 |
} |
| 501 |
} |
582 |
} |
| 502 |
if (curline.startsWith("cpu MHz")) { |
583 |
else if (cdevice && curline.startsWith("cpu MHz")) { |
| 503 |
curline.remove(0, curline.find(":")+1); |
584 |
curline.remove(0, curline.find(":")+2); |
| 504 |
curline = curline.stripWhiteSpace(); |
585 |
if (cdevice->frequency() != curline.toDouble()) { |
| 505 |
if (cdevice) { |
586 |
modified = true; |
| 506 |
if (cdevice->frequency() != curline.toDouble()) modified = true; |
|
|
| 507 |
cdevice->internalSetFrequency(curline.toDouble()); |
587 |
cdevice->internalSetFrequency(curline.toDouble()); |
| 508 |
have_frequency = true; |
|
|
| 509 |
} |
588 |
} |
|
|
589 |
have_frequency = true; |
| 510 |
} |
590 |
} |
| 511 |
if (curline.startsWith("vendor_id")) { |
591 |
else if (cdevice && curline.startsWith("vendor_id")) { |
| 512 |
curline.remove(0, curline.find(":")+1); |
592 |
curline.remove(0, curline.find(":")+2); |
| 513 |
curline = curline.stripWhiteSpace(); |
593 |
if (cdevice->vendorName() != curline) { |
| 514 |
if (cdevice) { |
594 |
modified = true; |
| 515 |
if (cdevice->vendorName() != curline) modified = true; |
|
|
| 516 |
cdevice->internalSetVendorName(curline); |
595 |
cdevice->internalSetVendorName(curline); |
| 517 |
if (cdevice->vendorEncoded() != curline) modified = true; |
596 |
} |
|
|
597 |
if (cdevice->vendorEncoded() != curline) { |
| 598 |
modified = true; |
| 518 |
cdevice->internalSetVendorEncoded(curline); |
599 |
cdevice->internalSetVendorEncoded(curline); |
| 519 |
} |
600 |
} |
| 520 |
} |
601 |
} |
| 521 |
curline = curline.stripWhiteSpace(); |
602 |
else if (curline == NULL || curline == "") { |
| 522 |
if (curline == "") { |
|
|
| 523 |
cdevice = 0; |
603 |
cdevice = 0; |
| 524 |
} |
604 |
} |
| 525 |
} |
605 |
} |
|
Lines 535-563
Link Here
|
| 535 |
for (cpuit = m_cpuInfo.begin(); cpuit != m_cpuInfo.end(); ++cpuit) { |
615 |
for (cpuit = m_cpuInfo.begin(); cpuit != m_cpuInfo.end(); ++cpuit) { |
| 536 |
curline = *cpuit; |
616 |
curline = *cpuit; |
| 537 |
if (curline.startsWith("Processor")) { |
617 |
if (curline.startsWith("Processor")) { |
| 538 |
curline.remove(0, curline.find(":")+1); |
618 |
curline.remove(0, curline.find(":")+2); |
| 539 |
curline = curline.stripWhiteSpace(); |
|
|
| 540 |
modelName = curline; |
619 |
modelName = curline; |
| 541 |
} |
620 |
} |
| 542 |
if (curline.startsWith("Hardware")) { |
621 |
else if (curline.startsWith("Hardware")) { |
| 543 |
curline.remove(0, curline.find(":")+1); |
622 |
curline.remove(0, curline.find(":")+2); |
| 544 |
curline = curline.stripWhiteSpace(); |
|
|
| 545 |
vendorName = curline; |
623 |
vendorName = curline; |
| 546 |
} |
624 |
} |
| 547 |
if (curline.startsWith("Serial")) { |
625 |
else if (curline.startsWith("Serial")) { |
| 548 |
curline.remove(0, curline.find(":")+1); |
626 |
curline.remove(0, curline.find(":")+2); |
| 549 |
curline = curline.stripWhiteSpace(); |
|
|
| 550 |
serialNumber = curline; |
627 |
serialNumber = curline; |
| 551 |
} |
628 |
} |
| 552 |
} |
629 |
} |
| 553 |
for (TQStringList::Iterator cpuit = m_cpuInfo.begin(); cpuit != m_cpuInfo.end(); ++cpuit) { |
630 |
for (TQStringList::Iterator cpuit = m_cpuInfo.begin(); cpuit != m_cpuInfo.end(); ++cpuit) { |
| 554 |
curline = *cpuit; |
631 |
curline = *cpuit; |
| 555 |
if (curline.startsWith("processor")) { |
632 |
if (curline.startsWith("processor")) { |
| 556 |
curline.remove(0, curline.find(":")+1); |
633 |
curline.remove(0, curline.find(":")+2); |
| 557 |
curline = curline.stripWhiteSpace(); |
|
|
| 558 |
processorNumber = curline.toInt(); |
634 |
processorNumber = curline.toInt(); |
| 559 |
if (!cdevice) { |
635 |
if (!cdevice) { |
| 560 |
cdevice = dynamic_cast<TDECPUDevice*>(findBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber))); |
636 |
cdevice = dynamic_cast<TDECPUDevice*>(findCPUBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber))); |
| 561 |
if (cdevice) { |
637 |
if (cdevice) { |
| 562 |
// Set up CPU information structures |
638 |
// Set up CPU information structures |
| 563 |
if (cdevice->coreNumber() != processorNumber) modified = true; |
639 |
if (cdevice->coreNumber() != processorNumber) modified = true; |
|
Lines 573-580
Link Here
|
| 573 |
} |
649 |
} |
| 574 |
} |
650 |
} |
| 575 |
} |
651 |
} |
| 576 |
curline = curline.stripWhiteSpace(); |
652 |
if (curline == NULL || curline == "") { |
| 577 |
if (curline == "") { |
|
|
| 578 |
cdevice = 0; |
653 |
cdevice = 0; |
| 579 |
} |
654 |
} |
| 580 |
} |
655 |
} |
|
Lines 582-590
Link Here
|
| 582 |
|
657 |
|
| 583 |
processorCount = processorNumber+1; |
658 |
processorCount = processorNumber+1; |
| 584 |
|
659 |
|
|
|
660 |
#ifdef CPUPROFILING |
| 661 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); |
| 662 |
printf("TDEHardwareDevices::processModifiedCPUs() : checkpoint3 at %u [%u]\n", time2.tv_nsec, diff(time1,time2).tv_nsec); |
| 663 |
time1 = time2; |
| 664 |
#endif |
| 665 |
|
| 666 |
TDECPUDevice* firstCPU; |
| 667 |
|
| 585 |
// Read in other information from cpufreq, if available |
668 |
// Read in other information from cpufreq, if available |
| 586 |
for (processorNumber=0; processorNumber<processorCount; processorNumber++) { |
669 |
for (processorNumber=0; processorNumber<processorCount; processorNumber++) { |
| 587 |
cdevice = dynamic_cast<TDECPUDevice*>(findBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber))); |
670 |
cdevice = dynamic_cast<TDECPUDevice*>(findCPUBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber))); |
| 588 |
TQDir cpufreq_dir(TQString("/sys/devices/system/cpu/cpu%1/cpufreq").arg(processorNumber)); |
671 |
TQDir cpufreq_dir(TQString("/sys/devices/system/cpu/cpu%1/cpufreq").arg(processorNumber)); |
| 589 |
TQString scalinggovernor; |
672 |
TQString scalinggovernor; |
| 590 |
TQString scalingdriver; |
673 |
TQString scalingdriver; |
|
Lines 595-701
Link Here
|
| 595 |
TQStringList frequencylist; |
678 |
TQStringList frequencylist; |
| 596 |
TQStringList governorlist; |
679 |
TQStringList governorlist; |
| 597 |
if (cpufreq_dir.exists()) { |
680 |
if (cpufreq_dir.exists()) { |
| 598 |
TQString nodename = cpufreq_dir.path(); |
681 |
TQString nodename; |
| 599 |
nodename.append("/scaling_governor"); |
682 |
if(processorNumber == 0) { |
| 600 |
TQFile scalinggovernorfile(nodename); |
683 |
// Remember the first CPU options so that we can reuse it later. |
| 601 |
if (scalinggovernorfile.open(IO_ReadOnly)) { |
684 |
firstCPU = cdevice; |
| 602 |
TQTextStream stream( &scalinggovernorfile ); |
685 |
|
| 603 |
scalinggovernor = stream.readLine(); |
686 |
nodename = cpufreq_dir.path(); |
| 604 |
scalinggovernorfile.close(); |
687 |
nodename.append("/scaling_governor"); |
| 605 |
} |
688 |
TQFile scalinggovernorfile(nodename); |
| 606 |
nodename = cpufreq_dir.path(); |
689 |
if (scalinggovernorfile.open(IO_ReadOnly)) { |
| 607 |
nodename.append("/scaling_driver"); |
690 |
TQTextStream stream( &scalinggovernorfile ); |
| 608 |
TQFile scalingdriverfile(nodename); |
691 |
scalinggovernor = stream.read(); |
| 609 |
if (scalingdriverfile.open(IO_ReadOnly)) { |
692 |
scalinggovernorfile.close(); |
| 610 |
TQTextStream stream( &scalingdriverfile ); |
693 |
} |
| 611 |
scalingdriver = stream.readLine(); |
694 |
nodename = cpufreq_dir.path(); |
| 612 |
scalingdriverfile.close(); |
695 |
nodename.append("/scaling_driver"); |
| 613 |
} |
696 |
TQFile scalingdriverfile(nodename); |
| 614 |
nodename = cpufreq_dir.path(); |
697 |
if (scalingdriverfile.open(IO_ReadOnly)) { |
| 615 |
nodename.append("/cpuinfo_min_freq"); |
698 |
TQTextStream stream( &scalingdriverfile ); |
| 616 |
TQFile minfrequencyfile(nodename); |
699 |
scalingdriver = stream.read(); |
| 617 |
if (minfrequencyfile.open(IO_ReadOnly)) { |
700 |
scalingdriverfile.close(); |
| 618 |
TQTextStream stream( &minfrequencyfile ); |
701 |
} |
| 619 |
minfrequency = stream.readLine().toDouble()/1000.0; |
702 |
nodename = cpufreq_dir.path(); |
| 620 |
minfrequencyfile.close(); |
703 |
nodename.append("/cpuinfo_min_freq"); |
| 621 |
} |
704 |
TQFile minfrequencyfile(nodename); |
| 622 |
nodename = cpufreq_dir.path(); |
705 |
if (minfrequencyfile.open(IO_ReadOnly)) { |
| 623 |
nodename.append("/cpuinfo_max_freq"); |
706 |
TQTextStream stream( &minfrequencyfile ); |
| 624 |
TQFile maxfrequencyfile(nodename); |
707 |
minfrequency = stream.read().toDouble()/1000.0; |
| 625 |
if (maxfrequencyfile.open(IO_ReadOnly)) { |
708 |
minfrequencyfile.close(); |
| 626 |
TQTextStream stream( &maxfrequencyfile ); |
709 |
} |
| 627 |
maxfrequency = stream.readLine().toDouble()/1000.0; |
710 |
nodename = cpufreq_dir.path(); |
| 628 |
maxfrequencyfile.close(); |
711 |
nodename.append("/cpuinfo_max_freq"); |
|
|
712 |
TQFile maxfrequencyfile(nodename); |
| 713 |
if (maxfrequencyfile.open(IO_ReadOnly)) { |
| 714 |
TQTextStream stream( &maxfrequencyfile ); |
| 715 |
maxfrequency = stream.read().toDouble()/1000.0; |
| 716 |
maxfrequencyfile.close(); |
| 717 |
} |
| 718 |
nodename = cpufreq_dir.path(); |
| 719 |
nodename.append("/cpuinfo_transition_latency"); |
| 720 |
TQFile trlatencyfile(nodename); |
| 721 |
if (trlatencyfile.open(IO_ReadOnly)) { |
| 722 |
TQTextStream stream( &trlatencyfile ); |
| 723 |
trlatency = stream.read().toDouble()/1000.0; |
| 724 |
trlatencyfile.close(); |
| 725 |
} |
| 726 |
nodename = cpufreq_dir.path(); |
| 727 |
nodename.append("/scaling_available_frequencies"); |
| 728 |
TQFile availfreqsfile(nodename); |
| 729 |
if (availfreqsfile.open(IO_ReadOnly)) { |
| 730 |
TQTextStream stream( &availfreqsfile ); |
| 731 |
frequencylist = TQStringList::split(" ", stream.read()); |
| 732 |
availfreqsfile.close(); |
| 733 |
} |
| 734 |
nodename = cpufreq_dir.path(); |
| 735 |
nodename.append("/scaling_available_governors"); |
| 736 |
TQFile availgvrnsfile(nodename); |
| 737 |
if (availgvrnsfile.open(IO_ReadOnly)) { |
| 738 |
TQTextStream stream( &availgvrnsfile ); |
| 739 |
governorlist = TQStringList::split(" ", stream.read()); |
| 740 |
availgvrnsfile.close(); |
| 741 |
} |
| 629 |
} |
742 |
} |
| 630 |
nodename = cpufreq_dir.path(); |
743 |
// Other CPU should have the same values as the first one. Simply copy them. |
| 631 |
nodename.append("/cpuinfo_transition_latency"); |
744 |
else { |
| 632 |
TQFile trlatencyfile(nodename); |
745 |
scalinggovernor = firstCPU->governor(); |
| 633 |
if (trlatencyfile.open(IO_ReadOnly)) { |
746 |
scalingdriver = firstCPU->scalingDriver(); |
| 634 |
TQTextStream stream( &trlatencyfile ); |
747 |
minfrequency = firstCPU->minFrequency(); |
| 635 |
trlatency = stream.readLine().toDouble()/1000.0; |
748 |
maxfrequency = firstCPU->maxFrequency(); |
| 636 |
trlatencyfile.close(); |
749 |
trlatency = firstCPU->transitionLatency(); |
|
|
750 |
frequencylist = firstCPU->availableFrequencies(); |
| 751 |
governorlist = firstCPU->availableGovernors(); |
| 637 |
} |
752 |
} |
|
|
753 |
|
| 754 |
// The following data are different on each CPU |
| 638 |
nodename = cpufreq_dir.path(); |
755 |
nodename = cpufreq_dir.path(); |
| 639 |
nodename.append("/affected_cpus"); |
756 |
nodename.append("/affected_cpus"); |
| 640 |
TQFile tiedcpusfile(nodename); |
757 |
TQFile tiedcpusfile(nodename); |
| 641 |
if (tiedcpusfile.open(IO_ReadOnly)) { |
758 |
if (tiedcpusfile.open(IO_ReadOnly)) { |
| 642 |
TQTextStream stream( &tiedcpusfile ); |
759 |
TQTextStream stream( &tiedcpusfile ); |
| 643 |
affectedcpulist = TQStringList::split(" ", stream.readLine()); |
760 |
affectedcpulist = TQStringList::split(" ", stream.read()); |
| 644 |
tiedcpusfile.close(); |
761 |
tiedcpusfile.close(); |
| 645 |
} |
762 |
} |
| 646 |
nodename = cpufreq_dir.path(); |
|
|
| 647 |
nodename.append("/scaling_available_frequencies"); |
| 648 |
TQFile availfreqsfile(nodename); |
| 649 |
if (availfreqsfile.open(IO_ReadOnly)) { |
| 650 |
TQTextStream stream( &availfreqsfile ); |
| 651 |
frequencylist = TQStringList::split(" ", stream.readLine()); |
| 652 |
availfreqsfile.close(); |
| 653 |
} |
| 654 |
nodename = cpufreq_dir.path(); |
| 655 |
nodename.append("/scaling_available_governors"); |
| 656 |
TQFile availgvrnsfile(nodename); |
| 657 |
if (availgvrnsfile.open(IO_ReadOnly)) { |
| 658 |
TQTextStream stream( &availgvrnsfile ); |
| 659 |
governorlist = TQStringList::split(" ", stream.readLine()); |
| 660 |
availgvrnsfile.close(); |
| 661 |
} |
| 662 |
|
763 |
|
|
|
764 |
// We may already have the CPU Mhz information in '/proc/cpuinfo' |
| 663 |
if (!have_frequency) { |
765 |
if (!have_frequency) { |
| 664 |
nodename = cpufreq_dir.path(); |
766 |
nodename = cpufreq_dir.path(); |
| 665 |
nodename.append("/cpuinfo_cur_freq"); |
767 |
nodename.append("/cpuinfo_cur_freq"); |
| 666 |
TQFile cpufreqfile(nodename); |
768 |
TQFile cpufreqfile(nodename); |
| 667 |
if (cpufreqfile.open(IO_ReadOnly)) { |
769 |
if (cpufreqfile.open(IO_ReadOnly)) { |
| 668 |
TQTextStream stream( &cpufreqfile ); |
770 |
TQTextStream stream( &cpufreqfile ); |
| 669 |
if (cdevice) cdevice->internalSetFrequency(stream.readLine().toDouble()/1000.0); |
771 |
if (cdevice) { |
|
|
772 |
cdevice->internalSetFrequency(stream.read().toDouble()/1000.0); |
| 773 |
} |
| 670 |
cpufreqfile.close(); |
774 |
cpufreqfile.close(); |
| 671 |
have_frequency = true; |
775 |
have_frequency = true; |
| 672 |
} |
776 |
} |
| 673 |
} |
777 |
} |
| 674 |
|
778 |
|
| 675 |
bool frequencyFound; |
779 |
bool minfrequencyFound = false; |
|
|
780 |
bool maxfrequencyFound = false; |
| 676 |
TQStringList::Iterator freqit; |
781 |
TQStringList::Iterator freqit; |
| 677 |
frequencyFound = false; |
|
|
| 678 |
for ( freqit = frequencylist.begin(); freqit != frequencylist.end(); ++freqit ) { |
782 |
for ( freqit = frequencylist.begin(); freqit != frequencylist.end(); ++freqit ) { |
| 679 |
double thisfrequency = (*freqit).toDouble()/1000.0; |
783 |
double thisfrequency = (*freqit).toDouble()/1000.0; |
| 680 |
if (thisfrequency == minfrequency) { |
784 |
if (thisfrequency == minfrequency) { |
| 681 |
frequencyFound = true; |
785 |
minfrequencyFound = true; |
|
|
786 |
} |
| 787 |
if (thisfrequency == maxfrequency) { |
| 788 |
maxfrequencyFound = true; |
| 682 |
} |
789 |
} |
|
|
790 |
|
| 683 |
} |
791 |
} |
| 684 |
if (!frequencyFound) { |
792 |
if (!minfrequencyFound) { |
| 685 |
int minFrequencyInt = (minfrequency*1000.0); |
793 |
int minFrequencyInt = (minfrequency*1000.0); |
| 686 |
frequencylist.prepend(TQString("%1").arg(minFrequencyInt)); |
794 |
frequencylist.prepend(TQString("%1").arg(minFrequencyInt)); |
| 687 |
} |
795 |
} |
| 688 |
frequencyFound = false; |
796 |
if (!maxfrequencyFound) { |
| 689 |
for ( freqit = frequencylist.begin(); freqit != frequencylist.end(); ++freqit ) { |
|
|
| 690 |
double thisfrequency = (*freqit).toDouble()/1000.0; |
| 691 |
if (thisfrequency == maxfrequency) { |
| 692 |
frequencyFound = true; |
| 693 |
} |
| 694 |
} |
| 695 |
if (!frequencyFound) { |
| 696 |
int maxfrequencyInt = (maxfrequency*1000.0); |
797 |
int maxfrequencyInt = (maxfrequency*1000.0); |
| 697 |
frequencylist.append(TQString("%1").arg(maxfrequencyInt)); |
798 |
frequencylist.append(TQString("%1").arg(maxfrequencyInt)); |
| 698 |
} |
799 |
} |
|
|
800 |
|
| 801 |
#ifdef CPUPROFILING |
| 802 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); |
| 803 |
printf("TDEHardwareDevices::processModifiedCPUs() : checkpoint3.%u at %u [%u]\n", processorNumber, time2.tv_nsec, diff(time1,time2).tv_nsec); |
| 804 |
time1 = time2; |
| 805 |
#endif |
| 699 |
} |
806 |
} |
| 700 |
else { |
807 |
else { |
| 701 |
if (have_frequency) { |
808 |
if (have_frequency) { |
|
Lines 708-740
Link Here
|
| 708 |
|
815 |
|
| 709 |
// Update CPU information structure |
816 |
// Update CPU information structure |
| 710 |
if (cdevice) { |
817 |
if (cdevice) { |
| 711 |
if (cdevice->governor() != scalinggovernor) modified = true; |
818 |
if (cdevice->governor() != scalinggovernor) { |
| 712 |
cdevice->internalSetGovernor(scalinggovernor); |
819 |
modified = true; |
| 713 |
if (cdevice->scalingDriver() != scalingdriver) modified = true; |
820 |
cdevice->internalSetGovernor(scalinggovernor); |
| 714 |
cdevice->internalSetScalingDriver(scalingdriver); |
821 |
} |
| 715 |
if (cdevice->minFrequency() != minfrequency) modified = true; |
822 |
if (cdevice->scalingDriver() != scalingdriver) { |
| 716 |
cdevice->internalSetMinFrequency(minfrequency); |
823 |
modified = true; |
| 717 |
if (cdevice->maxFrequency() != maxfrequency) modified = true; |
824 |
cdevice->internalSetScalingDriver(scalingdriver); |
| 718 |
cdevice->internalSetMaxFrequency(maxfrequency); |
825 |
} |
| 719 |
if (cdevice->transitionLatency() != trlatency) modified = true; |
826 |
if (cdevice->minFrequency() != minfrequency) { |
| 720 |
cdevice->internalSetTransitionLatency(trlatency); |
827 |
modified = true; |
| 721 |
if (cdevice->dependentProcessors().join(" ") != affectedcpulist.join(" ")) modified = true; |
828 |
cdevice->internalSetMinFrequency(minfrequency); |
| 722 |
cdevice->internalSetDependentProcessors(affectedcpulist); |
829 |
} |
| 723 |
if (cdevice->availableFrequencies().join(" ") != frequencylist.join(" ")) modified = true; |
830 |
if (cdevice->maxFrequency() != maxfrequency) { |
| 724 |
cdevice->internalSetAvailableFrequencies(frequencylist); |
831 |
modified = true; |
| 725 |
if (cdevice->availableGovernors().join(" ") != governorlist.join(" ")) modified = true; |
832 |
cdevice->internalSetMaxFrequency(maxfrequency); |
| 726 |
cdevice->internalSetAvailableGovernors(governorlist); |
833 |
} |
|
|
834 |
if (cdevice->transitionLatency() != trlatency) { |
| 835 |
modified = true; |
| 836 |
cdevice->internalSetTransitionLatency(trlatency); |
| 837 |
} |
| 838 |
if (cdevice->dependentProcessors().join(" ") != affectedcpulist.join(" ")) { |
| 839 |
modified = true; |
| 840 |
cdevice->internalSetDependentProcessors(affectedcpulist); |
| 841 |
} |
| 842 |
if (cdevice->availableFrequencies().join(" ") != frequencylist.join(" ")) { |
| 843 |
modified = true; |
| 844 |
cdevice->internalSetAvailableFrequencies(frequencylist); |
| 845 |
} |
| 846 |
if (cdevice->availableGovernors().join(" ") != governorlist.join(" ")) { |
| 847 |
modified = true; |
| 848 |
cdevice->internalSetAvailableGovernors(governorlist); |
| 849 |
} |
| 727 |
} |
850 |
} |
| 728 |
} |
851 |
} |
| 729 |
|
852 |
|
|
|
853 |
#ifdef CPUPROFILING |
| 854 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); |
| 855 |
printf("TDEHardwareDevices::processModifiedCPUs() : checkpoint4 at %u [%u]\n", time2.tv_nsec, diff(time1,time2).tv_nsec); |
| 856 |
time1 = time2; |
| 857 |
#endif |
| 858 |
|
| 730 |
if (modified) { |
859 |
if (modified) { |
| 731 |
for (processorNumber=0; processorNumber<processorCount; processorNumber++) { |
860 |
for (processorNumber=0; processorNumber<processorCount; processorNumber++) { |
| 732 |
TDEGenericDevice* hwdevice = findBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber)); |
861 |
TDEGenericDevice* hwdevice = findCPUBySystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber)); |
| 733 |
// Signal new information available |
862 |
// Signal new information available |
| 734 |
emit hardwareUpdated(hwdevice); |
863 |
emit hardwareUpdated(hwdevice); |
| 735 |
emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID()); |
864 |
emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID()); |
| 736 |
} |
865 |
} |
| 737 |
} |
866 |
} |
|
|
867 |
|
| 868 |
#ifdef CPUPROFILING |
| 869 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); |
| 870 |
printf("TDEHardwareDevices::processModifiedCPUs() : end at %u [%u]\n", time2.tv_nsec, diff(time1,time2).tv_nsec); |
| 871 |
printf("TDEHardwareDevices::processModifiedCPUs() : total time: %u\n", diff(time3,time2).tv_nsec); |
| 872 |
#endif |
| 738 |
} |
873 |
} |
| 739 |
|
874 |
|
| 740 |
void TDEHardwareDevices::processStatelessDevices() { |
875 |
void TDEHardwareDevices::processStatelessDevices() { |
|
Lines 742-747
Link Here
|
| 742 |
// So far, network cards and sensors need to be polled |
877 |
// So far, network cards and sensors need to be polled |
| 743 |
TDEGenericDevice *hwdevice; |
878 |
TDEGenericDevice *hwdevice; |
| 744 |
|
879 |
|
|
|
880 |
#ifdef STATELESSPROFILING |
| 881 |
timespec time1, time2, time3; |
| 882 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time1); |
| 883 |
printf("TDEHardwareDevices::processStatelessDevices() : begin at '%u'\n", time1.tv_nsec); |
| 884 |
time3 = time1; |
| 885 |
#endif |
| 886 |
|
| 745 |
// We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time |
887 |
// We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time |
| 746 |
TDEGenericHardwareList devList = listAllPhysicalDevices(); |
888 |
TDEGenericHardwareList devList = listAllPhysicalDevices(); |
| 747 |
for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) { |
889 |
for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) { |
|
Lines 749-758
Link Here
|
| 749 |
rescanDeviceInformation(hwdevice, false); |
891 |
rescanDeviceInformation(hwdevice, false); |
| 750 |
emit hardwareUpdated(hwdevice); |
892 |
emit hardwareUpdated(hwdevice); |
| 751 |
emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID()); |
893 |
emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID()); |
|
|
894 |
#ifdef STATELESSPROFILING |
| 895 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); |
| 896 |
printf("TDEHardwareDevices::processStatelessDevices() : '%s' finished at %u [%u]\n", (hwdevice->name()).ascii(), time2.tv_nsec, diff(time1,time2).tv_nsec); |
| 897 |
time1 = time2; |
| 898 |
#endif |
| 899 |
} |
| 900 |
} |
| 901 |
|
| 902 |
#ifdef STATELESSPROFILING |
| 903 |
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time2); |
| 904 |
printf("TDEHardwareDevices::processStatelessDevices() : end at '%u'\n", time2.tv_nsec); |
| 905 |
printf("TDEHardwareDevices::processStatelessDevices() : took '%u'\n", diff(time3,time2).tv_nsec); |
| 906 |
#endif |
| 907 |
} |
| 908 |
|
| 909 |
void TDEHardwareDevices::processBatteryDevices() { |
| 910 |
TDEGenericDevice *hwdevice; |
| 911 |
|
| 912 |
// We can't use m_deviceList directly as m_deviceList can only have one iterator active against it at any given time |
| 913 |
TDEGenericHardwareList devList = listAllPhysicalDevices(); |
| 914 |
for ( hwdevice = devList.first(); hwdevice; hwdevice = devList.next() ) { |
| 915 |
if (hwdevice->type() == TDEGenericDeviceType::Battery) { |
| 916 |
rescanDeviceInformation(hwdevice, false); |
| 917 |
emit hardwareUpdated(hwdevice); |
| 918 |
emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID()); |
| 752 |
} |
919 |
} |
| 753 |
} |
920 |
} |
| 754 |
} |
921 |
} |
| 755 |
|
922 |
|
|
|
923 |
|
| 756 |
void TDEHardwareDevices::processEventDeviceKeyPressed(unsigned int keycode, TDEEventDevice* edevice) { |
924 |
void TDEHardwareDevices::processEventDeviceKeyPressed(unsigned int keycode, TDEEventDevice* edevice) { |
| 757 |
emit eventDeviceKeyPressed(keycode, edevice); |
925 |
emit eventDeviceKeyPressed(keycode, edevice); |
| 758 |
} |
926 |
} |
|
Lines 2556-2568
Link Here
|
| 2556 |
if (nodename == "address") { |
2724 |
if (nodename == "address") { |
| 2557 |
ndevice->internalSetMacAddress(line); |
2725 |
ndevice->internalSetMacAddress(line); |
| 2558 |
} |
2726 |
} |
| 2559 |
if (nodename == "carrier") { |
2727 |
else if (nodename == "carrier") { |
| 2560 |
ndevice->internalSetCarrierPresent(line.toInt()); |
2728 |
ndevice->internalSetCarrierPresent(line.toInt()); |
| 2561 |
} |
2729 |
} |
| 2562 |
if (nodename == "dormant") { |
2730 |
else if (nodename == "dormant") { |
| 2563 |
ndevice->internalSetDormant(line.toInt()); |
2731 |
ndevice->internalSetDormant(line.toInt()); |
| 2564 |
} |
2732 |
} |
| 2565 |
if (nodename == "operstate") { |
2733 |
else if (nodename == "operstate") { |
| 2566 |
TQString friendlyState = line.lower(); |
2734 |
TQString friendlyState = line.lower(); |
| 2567 |
friendlyState[0] = friendlyState[0].upper(); |
2735 |
friendlyState[0] = friendlyState[0].upper(); |
| 2568 |
ndevice->internalSetState(friendlyState); |
2736 |
ndevice->internalSetState(friendlyState); |
|
Lines 2594-2600
Link Here
|
| 2594 |
if (family == AF_INET) { |
2762 |
if (family == AF_INET) { |
| 2595 |
ndevice->internalSetIpV4Address(address); |
2763 |
ndevice->internalSetIpV4Address(address); |
| 2596 |
} |
2764 |
} |
| 2597 |
if (family == AF_INET6) { |
2765 |
else if (family == AF_INET6) { |
| 2598 |
address.truncate(address.findRev("%")); |
2766 |
address.truncate(address.findRev("%")); |
| 2599 |
ndevice->internalSetIpV6Address(address); |
2767 |
ndevice->internalSetIpV6Address(address); |
| 2600 |
} |
2768 |
} |
|
Lines 2605-2611
Link Here
|
| 2605 |
if (family == AF_INET) { |
2773 |
if (family == AF_INET) { |
| 2606 |
ndevice->internalSetIpV4Netmask(address); |
2774 |
ndevice->internalSetIpV4Netmask(address); |
| 2607 |
} |
2775 |
} |
| 2608 |
if (family == AF_INET6) { |
2776 |
else if (family == AF_INET6) { |
| 2609 |
address.truncate(address.findRev("%")); |
2777 |
address.truncate(address.findRev("%")); |
| 2610 |
ndevice->internalSetIpV6Netmask(address); |
2778 |
ndevice->internalSetIpV6Netmask(address); |
| 2611 |
} |
2779 |
} |
|
Lines 2616-2622
Link Here
|
| 2616 |
if (family == AF_INET) { |
2784 |
if (family == AF_INET) { |
| 2617 |
ndevice->internalSetIpV4Broadcast(address); |
2785 |
ndevice->internalSetIpV4Broadcast(address); |
| 2618 |
} |
2786 |
} |
| 2619 |
if (family == AF_INET6) { |
2787 |
else if (family == AF_INET6) { |
| 2620 |
address.truncate(address.findRev("%")); |
2788 |
address.truncate(address.findRev("%")); |
| 2621 |
ndevice->internalSetIpV6Broadcast(address); |
2789 |
ndevice->internalSetIpV6Broadcast(address); |
| 2622 |
} |
2790 |
} |
|
Lines 2627-2633
Link Here
|
| 2627 |
if (family == AF_INET) { |
2795 |
if (family == AF_INET) { |
| 2628 |
ndevice->internalSetIpV4Destination(address); |
2796 |
ndevice->internalSetIpV4Destination(address); |
| 2629 |
} |
2797 |
} |
| 2630 |
if (family == AF_INET6) { |
2798 |
else if (family == AF_INET6) { |
| 2631 |
address.truncate(address.findRev("%")); |
2799 |
address.truncate(address.findRev("%")); |
| 2632 |
ndevice->internalSetIpV6Destination(address); |
2800 |
ndevice->internalSetIpV6Destination(address); |
| 2633 |
} |
2801 |
} |
|
Lines 2658-2670
Link Here
|
| 2658 |
if (nodename == "rx_bytes") { |
2826 |
if (nodename == "rx_bytes") { |
| 2659 |
ndevice->internalSetRxBytes(line.toDouble()); |
2827 |
ndevice->internalSetRxBytes(line.toDouble()); |
| 2660 |
} |
2828 |
} |
| 2661 |
if (nodename == "tx_bytes") { |
2829 |
else if (nodename == "tx_bytes") { |
| 2662 |
ndevice->internalSetTxBytes(line.toDouble()); |
2830 |
ndevice->internalSetTxBytes(line.toDouble()); |
| 2663 |
} |
2831 |
} |
| 2664 |
if (nodename == "rx_packets") { |
2832 |
else if (nodename == "rx_packets") { |
| 2665 |
ndevice->internalSetRxPackets(line.toDouble()); |
2833 |
ndevice->internalSetRxPackets(line.toDouble()); |
| 2666 |
} |
2834 |
} |
| 2667 |
if (nodename == "tx_packets") { |
2835 |
else if (nodename == "tx_packets") { |
| 2668 |
ndevice->internalSetTxPackets(line.toDouble()); |
2836 |
ndevice->internalSetTxPackets(line.toDouble()); |
| 2669 |
} |
2837 |
} |
| 2670 |
file.close(); |
2838 |
file.close(); |
|
Lines 2705-2723
Link Here
|
| 2705 |
if (sensornodetype == "label") { |
2873 |
if (sensornodetype == "label") { |
| 2706 |
sensors[sensornodename].label = line; |
2874 |
sensors[sensornodename].label = line; |
| 2707 |
} |
2875 |
} |
| 2708 |
if (sensornodetype == "input") { |
2876 |
else if (sensornodetype == "input") { |
| 2709 |
sensors[sensornodename].current = lineValue; |
2877 |
sensors[sensornodename].current = lineValue; |
| 2710 |
} |
2878 |
} |
| 2711 |
if (sensornodetype == "min") { |
2879 |
else if (sensornodetype == "min") { |
| 2712 |
sensors[sensornodename].minimum = lineValue; |
2880 |
sensors[sensornodename].minimum = lineValue; |
| 2713 |
} |
2881 |
} |
| 2714 |
if (sensornodetype == "max") { |
2882 |
else if (sensornodetype == "max") { |
| 2715 |
sensors[sensornodename].maximum = lineValue; |
2883 |
sensors[sensornodename].maximum = lineValue; |
| 2716 |
} |
2884 |
} |
| 2717 |
if (sensornodetype == "warn") { |
2885 |
else if (sensornodetype == "warn") { |
| 2718 |
sensors[sensornodename].warning = lineValue; |
2886 |
sensors[sensornodename].warning = lineValue; |
| 2719 |
} |
2887 |
} |
| 2720 |
if (sensornodetype == "crit") { |
2888 |
else if (sensornodetype == "crit") { |
| 2721 |
sensors[sensornodename].critical = lineValue; |
2889 |
sensors[sensornodename].critical = lineValue; |
| 2722 |
} |
2890 |
} |
| 2723 |
file.close(); |
2891 |
file.close(); |
|
Lines 2752-2791
Link Here
|
| 2752 |
if (nodename == "alarm") { |
2920 |
if (nodename == "alarm") { |
| 2753 |
bdevice->internalSetAlarmEnergy(line.toDouble()/1000000.0); |
2921 |
bdevice->internalSetAlarmEnergy(line.toDouble()/1000000.0); |
| 2754 |
} |
2922 |
} |
| 2755 |
if (nodename == "charge_full" || nodename == "energy_full") { |
2923 |
else if (nodename == "charge_full" || nodename == "energy_full") { |
| 2756 |
bdevice->internalSetMaximumEnergy(line.toDouble()/1000000.0); |
2924 |
bdevice->internalSetMaximumEnergy(line.toDouble()/1000000.0); |
| 2757 |
} |
2925 |
} |
| 2758 |
if (nodename == "charge_full_design" || nodename == "energy_full_design") { |
2926 |
else if (nodename == "charge_full_design" || nodename == "energy_full_design") { |
| 2759 |
bdevice->internalSetMaximumDesignEnergy(line.toDouble()/1000000.0); |
2927 |
bdevice->internalSetMaximumDesignEnergy(line.toDouble()/1000000.0); |
| 2760 |
} |
2928 |
} |
| 2761 |
if (nodename == "charge_now" || nodename == "energy_now") { |
2929 |
else if (nodename == "charge_now" || nodename == "energy_now") { |
| 2762 |
bdevice->internalSetEnergy(line.toDouble()/1000000.0); |
2930 |
bdevice->internalSetEnergy(line.toDouble()/1000000.0); |
| 2763 |
} |
2931 |
} |
| 2764 |
if (nodename == "manufacturer") { |
2932 |
else if (nodename == "manufacturer") { |
| 2765 |
bdevice->internalSetVendorName(line.stripWhiteSpace()); |
2933 |
bdevice->internalSetVendorName(line.stripWhiteSpace()); |
| 2766 |
} |
2934 |
} |
| 2767 |
if (nodename == "model_name") { |
2935 |
else if (nodename == "model_name") { |
| 2768 |
bdevice->internalSetVendorModel(line.stripWhiteSpace()); |
2936 |
bdevice->internalSetVendorModel(line.stripWhiteSpace()); |
| 2769 |
} |
2937 |
} |
| 2770 |
if (nodename == "power_now" || nodename == "current_now") { |
2938 |
else if (nodename == "power_now" || nodename == "current_now") { |
| 2771 |
bdevice->internalSetDischargeRate(line.toDouble()/1000000.0); |
2939 |
bdevice->internalSetDischargeRate(line.toDouble()/1000000.0); |
| 2772 |
} |
2940 |
} |
| 2773 |
if (nodename == "present") { |
2941 |
else if (nodename == "present") { |
| 2774 |
bdevice->internalSetInstalled(line.toInt()); |
2942 |
bdevice->internalSetInstalled(line.toInt()); |
| 2775 |
} |
2943 |
} |
| 2776 |
if (nodename == "serial_number") { |
2944 |
else if (nodename == "serial_number") { |
| 2777 |
bdevice->internalSetSerialNumber(line.stripWhiteSpace()); |
2945 |
bdevice->internalSetSerialNumber(line.stripWhiteSpace()); |
| 2778 |
} |
2946 |
} |
| 2779 |
if (nodename == "status") { |
2947 |
else if (nodename == "status") { |
| 2780 |
bdevice->internalSetStatus(line); |
2948 |
bdevice->internalSetStatus(line); |
| 2781 |
} |
2949 |
} |
| 2782 |
if (nodename == "technology") { |
2950 |
else if (nodename == "technology") { |
| 2783 |
bdevice->internalSetTechnology(line); |
2951 |
bdevice->internalSetTechnology(line); |
| 2784 |
} |
2952 |
} |
| 2785 |
if (nodename == "voltage_min_design") { |
2953 |
else if (nodename == "voltage_min_design") { |
| 2786 |
bdevice->internalSetMinimumVoltage(line.toDouble()/1000000.0); |
2954 |
bdevice->internalSetMinimumVoltage(line.toDouble()/1000000.0); |
| 2787 |
} |
2955 |
} |
| 2788 |
if (nodename == "voltage_now") { |
2956 |
else if (nodename == "voltage_now") { |
| 2789 |
bdevice->internalSetVoltage(line.toDouble()/1000000.0); |
2957 |
bdevice->internalSetVoltage(line.toDouble()/1000000.0); |
| 2790 |
} |
2958 |
} |
| 2791 |
file.close(); |
2959 |
file.close(); |
|
Lines 2823-2835
Link Here
|
| 2823 |
if (nodename == "manufacturer") { |
2991 |
if (nodename == "manufacturer") { |
| 2824 |
pdevice->internalSetVendorName(line.stripWhiteSpace()); |
2992 |
pdevice->internalSetVendorName(line.stripWhiteSpace()); |
| 2825 |
} |
2993 |
} |
| 2826 |
if (nodename == "model_name") { |
2994 |
else if (nodename == "model_name") { |
| 2827 |
pdevice->internalSetVendorModel(line.stripWhiteSpace()); |
2995 |
pdevice->internalSetVendorModel(line.stripWhiteSpace()); |
| 2828 |
} |
2996 |
} |
| 2829 |
if (nodename == "online") { |
2997 |
else if (nodename == "online") { |
| 2830 |
pdevice->internalSetOnline(line.toInt()); |
2998 |
pdevice->internalSetOnline(line.toInt()); |
| 2831 |
} |
2999 |
} |
| 2832 |
if (nodename == "serial_number") { |
3000 |
else if (nodename == "serial_number") { |
| 2833 |
pdevice->internalSetSerialNumber(line.stripWhiteSpace()); |
3001 |
pdevice->internalSetSerialNumber(line.stripWhiteSpace()); |
| 2834 |
} |
3002 |
} |
| 2835 |
file.close(); |
3003 |
file.close(); |
|
Lines 2868-2877
Link Here
|
| 2868 |
} |
3036 |
} |
| 2869 |
bdevice->internalSetPowerLevel(pl); |
3037 |
bdevice->internalSetPowerLevel(pl); |
| 2870 |
} |
3038 |
} |
| 2871 |
if (nodename == "max_brightness") { |
3039 |
else if (nodename == "max_brightness") { |
| 2872 |
bdevice->internalSetMaximumRawBrightness(line.toInt()); |
3040 |
bdevice->internalSetMaximumRawBrightness(line.toInt()); |
| 2873 |
} |
3041 |
} |
| 2874 |
if (nodename == "actual_brightness") { |
3042 |
else if (nodename == "actual_brightness") { |
| 2875 |
bdevice->internalSetCurrentRawBrightness(line.toInt()); |
3043 |
bdevice->internalSetCurrentRawBrightness(line.toInt()); |
| 2876 |
} |
3044 |
} |
| 2877 |
file.close(); |
3045 |
file.close(); |
|
Lines 2901-2910
Link Here
|
| 2901 |
if (nodename == "status") { |
3069 |
if (nodename == "status") { |
| 2902 |
mdevice->internalSetConnected(line.lower() == "connected"); |
3070 |
mdevice->internalSetConnected(line.lower() == "connected"); |
| 2903 |
} |
3071 |
} |
| 2904 |
if (nodename == "enabled") { |
3072 |
else if (nodename == "enabled") { |
| 2905 |
mdevice->internalSetEnabled(line.lower() == "enabled"); |
3073 |
mdevice->internalSetEnabled(line.lower() == "enabled"); |
| 2906 |
} |
3074 |
} |
| 2907 |
if (nodename == "modes") { |
3075 |
else if (nodename == "modes") { |
| 2908 |
TQStringList resinfo; |
3076 |
TQStringList resinfo; |
| 2909 |
TQStringList resolutionsStringList = line.upper(); |
3077 |
TQStringList resolutionsStringList = line.upper(); |
| 2910 |
while ((!stream.atEnd()) && (!line.isNull())) { |
3078 |
while ((!stream.atEnd()) && (!line.isNull())) { |
|
Lines 2921-2927
Link Here
|
| 2921 |
} |
3089 |
} |
| 2922 |
mdevice->internalSetResolutions(resolutions); |
3090 |
mdevice->internalSetResolutions(resolutions); |
| 2923 |
} |
3091 |
} |
| 2924 |
if (nodename == "dpms") { |
3092 |
else if (nodename == "dpms") { |
| 2925 |
TDEDisplayPowerLevel::TDEDisplayPowerLevel pl = TDEDisplayPowerLevel::On; |
3093 |
TDEDisplayPowerLevel::TDEDisplayPowerLevel pl = TDEDisplayPowerLevel::On; |
| 2926 |
if (line == "On") { |
3094 |
if (line == "On") { |
| 2927 |
pl = TDEDisplayPowerLevel::On; |
3095 |
pl = TDEDisplayPowerLevel::On; |