tdebatterydevice.cpp
00001 /* This file is part of the TDE libraries 00002 Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net> 00003 (C) 2013 Golubev Alexander <fatzer2@gmail.com> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include "tdebatterydevice.h" 00021 00022 #include "config.h" 00023 00024 TDEBatteryDevice::TDEBatteryDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : 00025 m_currentVoltage(0), m_minimumVoltage(0), m_maximumVoltage(0), m_maximumDesignVoltage(0), 00026 m_alarmEnergy(0), m_currentEnergy(0), m_maximumEnergy(0), m_maximumDesignEnergy(0), 00027 m_dischargeRate(0), m_timeRemaining(0), 00028 m_technology(TQString::null), 00029 m_status(TDEBatteryStatus::Unknown), 00030 m_installed(0), 00031 TDEGenericDevice(dt, dn) { 00032 } 00033 00034 TDEBatteryDevice::~TDEBatteryDevice() { 00035 } 00036 00037 double TDEBatteryDevice::voltage() { 00038 return m_currentVoltage; 00039 } 00040 00041 void TDEBatteryDevice::internalSetVoltage(double vt) { 00042 m_currentVoltage = vt; 00043 } 00044 00045 double TDEBatteryDevice::maximumVoltage() { 00046 return m_maximumVoltage; 00047 } 00048 00049 void TDEBatteryDevice::internalSetMaximumVoltage(double vt) { 00050 m_maximumVoltage = vt; 00051 } 00052 00053 double TDEBatteryDevice::minimumVoltage() { 00054 return m_minimumVoltage; 00055 } 00056 00057 void TDEBatteryDevice::internalSetMinimumVoltage(double vt) { 00058 m_minimumVoltage = vt; 00059 } 00060 00061 double TDEBatteryDevice::maximumDesignVoltage() { 00062 return m_maximumDesignVoltage; 00063 } 00064 00065 void TDEBatteryDevice::internalSetMaximumDesignVoltage(double vt) { 00066 m_maximumDesignVoltage = vt; 00067 } 00068 00069 double TDEBatteryDevice::energy() { 00070 return m_currentEnergy; 00071 } 00072 00073 void TDEBatteryDevice::internalSetEnergy(double vt) { 00074 m_currentEnergy = vt; 00075 } 00076 00077 double TDEBatteryDevice::alarmEnergy() { 00078 return m_alarmEnergy; 00079 } 00080 00081 void TDEBatteryDevice::internalSetAlarmEnergy(double vt) { 00082 m_alarmEnergy = vt; 00083 } 00084 00085 double TDEBatteryDevice::maximumEnergy() { 00086 return m_maximumEnergy; 00087 } 00088 00089 void TDEBatteryDevice::internalSetMaximumEnergy(double vt) { 00090 m_maximumEnergy = vt; 00091 } 00092 00093 double TDEBatteryDevice::maximumDesignEnergy() { 00094 return m_maximumDesignEnergy; 00095 } 00096 00097 void TDEBatteryDevice::internalSetMaximumDesignEnergy(double vt) { 00098 m_maximumDesignEnergy = vt; 00099 } 00100 00101 double TDEBatteryDevice::dischargeRate() { 00102 return m_dischargeRate; 00103 } 00104 00105 void TDEBatteryDevice::internalSetDischargeRate(double vt) { 00106 m_dischargeRate = vt; 00107 } 00108 00109 double TDEBatteryDevice::timeRemaining() { 00110 return m_timeRemaining; 00111 } 00112 00113 void TDEBatteryDevice::internalSetTimeRemaining(double tr) { 00114 m_timeRemaining = tr; 00115 } 00116 00117 TQString TDEBatteryDevice::technology() { 00118 return m_technology; 00119 } 00120 00121 void TDEBatteryDevice::internalSetTechnology(TQString tc) { 00122 m_technology = tc; 00123 } 00124 00125 TDEBatteryStatus::TDEBatteryStatus TDEBatteryDevice::status() { 00126 return m_status; 00127 } 00128 00129 void TDEBatteryDevice::internalSetStatus(TQString tc) { 00130 tc = tc.lower(); 00131 00132 if (tc == "charging") { 00133 m_status = TDEBatteryStatus::Charging; 00134 } 00135 else if (tc == "discharging") { 00136 m_status = TDEBatteryStatus::Discharging; 00137 } 00138 else if (tc == "full") { 00139 m_status = TDEBatteryStatus::Full; 00140 } 00141 else { 00142 m_status = TDEBatteryStatus::Unknown; 00143 } 00144 } 00145 00146 bool TDEBatteryDevice::installed() { 00147 return m_installed; 00148 } 00149 00150 void TDEBatteryDevice::internalSetInstalled(bool tc) { 00151 m_installed = tc; 00152 } 00153 00154 double TDEBatteryDevice::chargePercent() { 00155 return (m_currentEnergy/m_maximumEnergy)*100.0; 00156 } 00157 00158 #include "tdebatterydevice.moc"