-
Notifications
You must be signed in to change notification settings - Fork 1
/
fpd.h
127 lines (99 loc) · 2.74 KB
/
fpd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
* Copyright (c) 2012 Alexandros Nikolopoulos <[email protected]>
*
* This program 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 2 of the License, or (at your
* option) any later version.
*/
#ifndef FPD_H_
#define FPD_H_
#define MAJOR_VERSION 2
#define MINOR_VERSION 7
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
// #include <time.h>
// #include <pthread.h>
#include <list>
#include <map>
#include <string>
#include <sstream>
using namespace std;
#include "CLog.h"
extern CLog Log;
extern bool debugFlag;
extern bool SigTermFlag;
typedef map<string, string> DataContainer;
typedef list<DataContainer> DataContainerList;
typedef DataContainer SettingsContainer;
typedef DataContainerList SettingsContainerList;
// Generic class of the Probes
class CProbe
{
public:
virtual ~CProbe(void){};
virtual int Start(void) = 0;
virtual int Stop(void) = 0;
virtual int GetAverage(DataContainer &AverageData) = 0;
virtual list<int> GetConnectedInverters(void) = 0;
virtual int ResetStack(void) = 0;
string output;
string cache;
};
// Generic class of the hardware interfaces
class CInterface
{
public:
virtual ~CInterface(){};
virtual int Connect(void) = 0;
virtual int Disconnect(void) = 0;
virtual int Send(uint8_t *message, int length) = 0;
virtual int Receive(uint8_t *message, int length, time_t timeout) = 0;
virtual string GetMyAddress(void) = 0;
};
// Generic class of the outputs
class COutput
{
public:
virtual ~COutput(){};
virtual int Connect(void) = 0;
virtual int Insert(DataContainer &Data) = 0;
virtual int Insert(DataContainerList &DataList) = 0;
virtual int Restore(DataContainer &Data) = 0;
virtual int Restore(DataContainerList &DataList, unsigned int maxRows) = 0;
};
// Structure that contains the data to push to the queue
struct MsgStruct
{
uint8_t Data[256]; // Message data
uint16_t DataLen; // Message length
uint32_t TimeStamp; // Timestamp of message arrival
CInterface *Iface; // The serial interface that received the message
};
struct ThreadStruct
{
CInterface *interface;
list<struct MsgStruct> *MsgQueue;
pthread_mutex_t *queueMutex;
list<int> *connected;
};
string int2string(uint8_t num);
string int2string(uint16_t num);
string int2string(uint32_t num);
string int2string(uint64_t num);
string int2string(int8_t num);
string int2string(int16_t num);
string int2string(int32_t num);
string int2string(int64_t num);
string int2string(time_t num);
string float2string(float num);
#endif /* FPD_H_ */