@ -2974,6 +2974,9 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
TQDir valuesdir ( valuesnodename ) ;
TQDir valuesdir ( valuesnodename ) ;
valuesdir . setFilter ( TQDir : : All ) ;
valuesdir . setFilter ( TQDir : : All ) ;
TQString nodename ;
TQString nodename ;
double bdevice_capacity = 0 ;
bool bdevice_has_energy = false ;
bool bdevice_has_time_to_empty = false ;
const TQFileInfoList * dirlist = valuesdir . entryInfoList ( ) ;
const TQFileInfoList * dirlist = valuesdir . entryInfoList ( ) ;
if ( dirlist ) {
if ( dirlist ) {
TQFileInfoListIterator valuesdirit ( * dirlist ) ;
TQFileInfoListIterator valuesdirit ( * dirlist ) ;
@ -3043,6 +3046,9 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
if ( nodename = = " alarm " ) {
if ( nodename = = " alarm " ) {
bdevice - > internalSetAlarmEnergy ( line . toDouble ( ) / 1000000.0 ) ;
bdevice - > internalSetAlarmEnergy ( line . toDouble ( ) / 1000000.0 ) ;
}
}
else if ( nodename = = " capacity " ) {
bdevice_capacity = line . toDouble ( ) ;
}
else if ( nodename = = " charge_full " | | nodename = = " energy_full " ) {
else if ( nodename = = " charge_full " | | nodename = = " energy_full " ) {
bdevice - > internalSetMaximumEnergy ( line . toDouble ( ) / 1000000.0 ) ;
bdevice - > internalSetMaximumEnergy ( line . toDouble ( ) / 1000000.0 ) ;
}
}
@ -3051,6 +3057,7 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
}
}
else if ( nodename = = " charge_now " | | nodename = = " energy_now " ) {
else if ( nodename = = " charge_now " | | nodename = = " energy_now " ) {
bdevice - > internalSetEnergy ( line . toDouble ( ) / 1000000.0 ) ;
bdevice - > internalSetEnergy ( line . toDouble ( ) / 1000000.0 ) ;
bdevice_has_energy = true ;
}
}
else if ( nodename = = " manufacturer " ) {
else if ( nodename = = " manufacturer " ) {
bdevice - > internalSetVendorName ( line . stripWhiteSpace ( ) ) ;
bdevice - > internalSetVendorName ( line . stripWhiteSpace ( ) ) ;
@ -3073,6 +3080,11 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
else if ( nodename = = " technology " ) {
else if ( nodename = = " technology " ) {
bdevice - > internalSetTechnology ( line ) ;
bdevice - > internalSetTechnology ( line ) ;
}
}
else if ( nodename = = " time_to_empty_now " ) {
// Convert from minutes to seconds
bdevice - > internalSetTimeRemaining ( line . toDouble ( ) * 60 ) ;
bdevice_has_time_to_empty = true ;
}
else if ( nodename = = " voltage_min_design " ) {
else if ( nodename = = " voltage_min_design " ) {
bdevice - > internalSetMinimumVoltage ( line . toDouble ( ) / 1000000.0 ) ;
bdevice - > internalSetMinimumVoltage ( line . toDouble ( ) / 1000000.0 ) ;
}
}
@ -3085,7 +3097,13 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
}
}
}
}
// Calculate current energy if missing
if ( ! bdevice_has_energy ) {
bdevice - > internalSetEnergy ( bdevice_capacity * bdevice - > maximumEnergy ( ) / 100 ) ;
}
// Calculate time remaining
// Calculate time remaining
if ( bdevice - > dischargeRate ( ) > 0 ) {
// Discharge/charge rate is in watt-hours
// Discharge/charge rate is in watt-hours
// Energy is in watt-hours
// Energy is in watt-hours
// Therefore, energy/rate = time in hours
// Therefore, energy/rate = time in hours
@ -3093,10 +3111,11 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
if ( bdevice - > status ( ) = = TDEBatteryStatus : : Charging ) {
if ( bdevice - > status ( ) = = TDEBatteryStatus : : Charging ) {
bdevice - > internalSetTimeRemaining ( ( ( bdevice - > maximumEnergy ( ) - bdevice - > energy ( ) ) / bdevice - > dischargeRate ( ) ) * 60 * 60 ) ;
bdevice - > internalSetTimeRemaining ( ( ( bdevice - > maximumEnergy ( ) - bdevice - > energy ( ) ) / bdevice - > dischargeRate ( ) ) * 60 * 60 ) ;
}
}
else {
else if ( ! bdevice_has_time_to_empty ) {
bdevice - > internalSetTimeRemaining ( ( bdevice - > energy ( ) / bdevice - > dischargeRate ( ) ) * 60 * 60 ) ;
bdevice - > internalSetTimeRemaining ( ( bdevice - > energy ( ) / bdevice - > dischargeRate ( ) ) * 60 * 60 ) ;
}
}
}
}
}
if ( device - > type ( ) = = TDEGenericDeviceType : : PowerSupply ) {
if ( device - > type ( ) = = TDEGenericDeviceType : : PowerSupply ) {
// Populate all power supply values
// Populate all power supply values