2011-09-10 00:00:26 +02:00
|
|
|
/**
|
2012-02-10 10:04:40 +01:00
|
|
|
* Meter interface
|
2011-09-10 00:00:26 +02:00
|
|
|
*
|
|
|
|
* @package vzlogger
|
|
|
|
* @copyright Copyright (c) 2011, The volkszaehler.org project
|
|
|
|
* @license http://www.gnu.org/licenses/gpl.txt GNU Public License
|
|
|
|
* @author Steffen Vogel <info@steffenvogel.de>
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* This file is part of volkzaehler.org
|
|
|
|
*
|
|
|
|
* volkzaehler.org 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, either version 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* volkzaehler.org 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 volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _METER_H_
|
|
|
|
#define _METER_H_
|
|
|
|
|
2011-11-21 00:38:05 +01:00
|
|
|
#include "list.h"
|
2012-01-19 18:04:36 +01:00
|
|
|
#include "reading.h"
|
2012-03-12 01:20:04 +01:00
|
|
|
#include "options.h"
|
|
|
|
#include "channel.h"
|
2011-09-10 00:00:26 +02:00
|
|
|
|
2012-02-05 18:14:01 +01:00
|
|
|
using namespace std;
|
2011-09-10 00:00:26 +02:00
|
|
|
|
2012-02-05 18:14:01 +01:00
|
|
|
class Meter {
|
2011-09-10 00:00:26 +02:00
|
|
|
|
2012-02-05 18:14:01 +01:00
|
|
|
public:
|
|
|
|
virtual ~Meter();
|
2011-11-21 00:38:05 +01:00
|
|
|
|
2012-02-05 18:14:01 +01:00
|
|
|
virtual int open() = 0;
|
|
|
|
virtual int close() = 0;
|
2012-03-12 01:20:04 +01:00
|
|
|
virtual size_t read(Reading *rds, size_t n);
|
2012-01-19 18:04:36 +01:00
|
|
|
|
2012-02-10 10:04:40 +01:00
|
|
|
int getInterval();
|
|
|
|
|
2012-02-05 18:14:01 +01:00
|
|
|
protected:
|
2012-02-10 10:04:40 +01:00
|
|
|
Meter(OptionList options);
|
2012-02-05 18:14:01 +01:00
|
|
|
|
2012-02-10 10:04:40 +01:00
|
|
|
static int instances;
|
2012-02-05 18:14:01 +01:00
|
|
|
int id;
|
|
|
|
|
|
|
|
int interval;
|
2012-02-10 10:04:40 +01:00
|
|
|
|
|
|
|
List<Channel> channels;
|
|
|
|
|
|
|
|
pthread_t thread;
|
2012-02-05 18:14:01 +01:00
|
|
|
};
|
2011-09-10 00:00:26 +02:00
|
|
|
|
2012-03-12 01:20:04 +01:00
|
|
|
typedef enum {
|
|
|
|
sml, d0
|
|
|
|
} meter_protocol_t;
|
|
|
|
|
2011-11-21 00:38:05 +01:00
|
|
|
typedef struct {
|
|
|
|
meter_protocol_t id;
|
|
|
|
char *name; /* short identifier for protocol */
|
|
|
|
char *desc; /* more detailed description */
|
|
|
|
size_t max_readings; /* how many readings can be read with 1 call */
|
|
|
|
int periodic:1; /* does this meter has be triggered periodically? */
|
|
|
|
} meter_details_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get list of available meter types
|
|
|
|
*/
|
|
|
|
const meter_details_t * meter_get_protocols();
|
|
|
|
const meter_details_t * meter_get_details(meter_protocol_t protocol);
|
|
|
|
|
2011-09-10 00:00:26 +02:00
|
|
|
#endif /* _METER_H_ */
|