@ -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,16 +3097,23 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
}
}
}
}
// Calculate time remaining
// Calculate current energy if missing
// Discharge/charge rate is in watt-hours
if ( ! bdevice_has_energy ) {
// Energy is in watt-hours
bdevice - > internalSetEnergy ( bdevice_capacity * bdevice - > maximumEnergy ( ) / 100 ) ;
// Therefore, energy/rate = time in hours
// Convert to seconds...
if ( bdevice - > status ( ) = = TDEBatteryStatus : : Charging ) {
bdevice - > internalSetTimeRemaining ( ( ( bdevice - > maximumEnergy ( ) - bdevice - > energy ( ) ) / bdevice - > dischargeRate ( ) ) * 60 * 60 ) ;
}
}
else {
bdevice - > internalSetTimeRemaining ( ( bdevice - > energy ( ) / bdevice - > dischargeRate ( ) ) * 60 * 60 ) ;
// Calculate time remaining
if ( bdevice - > dischargeRate ( ) > 0 ) {
// Discharge/charge rate is in watt-hours
// Energy is in watt-hours
// Therefore, energy/rate = time in hours
// Convert to seconds...
if ( bdevice - > status ( ) = = TDEBatteryStatus : : Charging ) {
bdevice - > internalSetTimeRemaining ( ( ( bdevice - > maximumEnergy ( ) - bdevice - > energy ( ) ) / bdevice - > dischargeRate ( ) ) * 60 * 60 ) ;
}
else if ( ! bdevice_has_time_to_empty ) {
bdevice - > internalSetTimeRemaining ( ( bdevice - > energy ( ) / bdevice - > dischargeRate ( ) ) * 60 * 60 ) ;
}
}
}
}
}