/**
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 *
 * The iWear Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation as in version 2 of the License.

 * 
 * The iWear Framework is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __IWPOWER_POWER_APM_H
#define __IWPOWER_POWER_APM_H

#ifndef __IWPOWER_POWER_BASE_H
#include <iwpower/power_base.h>
#endif

#ifndef __IWEAR_CONSTANTS_H
#include <iwear/constants.h>
#endif

#include <map>
using namespace std;

namespace iwear
{
    namespace sensor
    {
	namespace power
	{

/**
 * This is a apm class for all possible apm values we want to read. It does
 * nothing, and therefore has nothing implemented. It throws exceptions on get_
 * functions, and returns all true on has_ functions. But since they are
 * virtual, you may derive from it, and implement what you can do...
 */
class power_apm : public power_base
{
private:
protected:
    mutable int32_t design_capacity;
    mutable int32_t last_full_capacity;
    mutable int32_t design_voltage;

    mutable string model;

    mutable string battery;
    mutable string acadapter;
    mutable string thermal_zone;

    mutable energy_state estat;
    mutable battery_state bstat;

    mutable float battery_percentage;
    mutable uint32_t battery_remaining_minutes;

    mutable int32_t current;
    mutable int32_t currentvolt;
    mutable int32_t rate;
    mutable float cpu_temp;

    mutable lid_state the_lid;

    mutable time_t last_update;

public:
    power_apm( PowerManager* pman, const string& bat, const string& ac, const string& tz = "auto" );

    virtual ~power_apm();

    virtual uint32_t activate_power_state( power_state );
    virtual powersensor_type get_powersensor_type( void ) const { return local_system; }
   /**
    */
    virtual void update( void ) const;
    
    virtual energy_state get_ac_status( void ) const { return estat; }

    virtual battery_state get_bat_status( void ) const { return bstat; }

    virtual int32_t get_bat_design( void ) const { return design_capacity; }

    virtual int32_t get_bat_last( void ) const { return last_full_capacity; }

    virtual time_t get_bat_remain( void ) const {return 60*battery_remaining_minutes;}

    virtual int32_t get_bat_current( void ) const { return current; }

    virtual int32_t get_bat_rate( void ) const { if ( has_bat_rate() ) { return rate;} else { return power_base::get_bat_rate(); } }

    virtual int32_t get_bat_designvoltage( void ) const { return design_voltage; }

    virtual int32_t get_bat_currentvoltage( void ) const { return currentvolt; }

    virtual const string& get_bat_model( void ) const { return model; }

    virtual lid_state get_lid_state( void ) const { return the_lid; }
    virtual float get_cpu_temp( void ) const { return cpu_temp; }


    // More like lcd, throttle etc. will follow 
};

}
}
}

#endif

