2012-01-19 18:03:09 +01:00
|
|
|
/**
|
|
|
|
* Reading related functions
|
|
|
|
*
|
|
|
|
* @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 _READING_H_
|
|
|
|
#define _READING_H_
|
|
|
|
|
2012-01-19 18:20:52 +01:00
|
|
|
#include <sys/time.h>
|
|
|
|
|
2012-01-19 18:03:09 +01:00
|
|
|
#define MAX_IDENTIFIER_LEN 255
|
|
|
|
|
2012-02-10 10:04:40 +01:00
|
|
|
/* Identifiers */
|
|
|
|
class ReadingIdentifier {
|
|
|
|
|
|
|
|
public:
|
2012-03-12 01:20:04 +01:00
|
|
|
virtual bool operator==(ReadingIdentifier &cmp) = 0;
|
|
|
|
virtual void parse(const char *string) = 0;
|
|
|
|
virtual size_t unparse(char *buffer, size_t n) = 0;
|
2012-02-10 10:04:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class StringIdentifier : public ReadingIdentifier {
|
|
|
|
|
|
|
|
public:
|
2012-03-12 01:20:04 +01:00
|
|
|
bool operator==(ReadingIdentifier &cmp);
|
|
|
|
void parse(const char *string);
|
|
|
|
size_t unparse(char *buffer, size_t n);
|
|
|
|
|
|
|
|
~StringIdentifier();
|
|
|
|
|
2012-02-10 10:04:40 +01:00
|
|
|
protected:
|
2012-03-12 01:20:04 +01:00
|
|
|
char *string;
|
2012-02-10 10:04:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class ChannelIdentifier : public ReadingIdentifier {
|
2012-03-12 01:20:04 +01:00
|
|
|
|
2012-02-10 10:04:40 +01:00
|
|
|
public:
|
2012-03-12 01:20:04 +01:00
|
|
|
bool operator==(ReadingIdentifier &cmp);
|
|
|
|
void parse(const char *string);
|
|
|
|
size_t unparse(char *buffer, size_t n);
|
|
|
|
|
2012-02-10 10:04:40 +01:00
|
|
|
protected:
|
2012-01-19 18:03:09 +01:00
|
|
|
int channel;
|
2012-02-10 10:04:40 +01:00
|
|
|
};
|
2012-01-19 18:03:09 +01:00
|
|
|
|
2012-02-10 10:04:40 +01:00
|
|
|
class Reading {
|
2012-01-19 18:03:09 +01:00
|
|
|
|
2012-02-10 10:04:40 +01:00
|
|
|
public:
|
|
|
|
static double tvtod(struct timeval tv);
|
|
|
|
static struct timeval dtotv(double ts);
|
2012-01-19 18:03:09 +01:00
|
|
|
|
2012-02-10 10:04:40 +01:00
|
|
|
double value;
|
|
|
|
struct timeval time;
|
2012-03-12 01:20:04 +01:00
|
|
|
ReadingIdentifier *identifier;
|
2012-02-10 10:04:40 +01:00
|
|
|
};
|
|
|
|
|
2012-01-19 18:03:09 +01:00
|
|
|
#endif /* _READING_H_ */
|