-
Notifications
You must be signed in to change notification settings - Fork 6
/
CommunicationDataStorage.h
89 lines (67 loc) · 3.81 KB
/
CommunicationDataStorage.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
#pragma once
#include "Common/Common.h"
//GREEN - running, YELLOW - sleeping , RED - not connected
const enum COMMUNICATION_STATUS { COMM_STATUS_GREEN, COMM_STATUS_YELLOW, COMM_STATUS_RED };
class CCommunicationDataStorage
{
// ------------------- class CLinkInfo -----------------------
// --- takes care of 'remembering' the status of each link ---
class CLinkInfo {
public:
CLinkInfo();
~CLinkInfo();
novac::CDateTime m_time;
double m_downloadSpeed;
CLinkInfo& operator=(const CLinkInfo&);
};
public:
CCommunicationDataStorage(void);
~CCommunicationDataStorage(void);
// ----------------------------------------------------------------------
// ---------------------- PUBLIC DATA -----------------------------------
// ----------------------------------------------------------------------
static const int MAX_HISTORY = 1000;
// ----------------------------------------------------------------------
// ---------------------- PUBLIC METHODS --------------------------------
// ----------------------------------------------------------------------
/** Sets the status of the instrument with the given serial-ID number to
the given status value */
void SetStatus(const CString& serialID, COMMUNICATION_STATUS status);
/** Returns the status value of the instrument with the given serial-ID */
int GetStatus(const CString& serialID);
/** Returns the spectrometer index given a serial number */
int GetScannerIndex(const CString& serial);
/** Get link-speed data.
@param serial - the serial number of the spectrometer for which the data should be retrieved.
@param timeBuffer - the time-data will be copied into this buffer. The time format is the number of seconds since midnight
@param dataBuffer - the link-speed data will be copied into this buffer.
@param bufferSize - the maximum number of data points that the buffer can handle.
@return the number of data points copied into the dataBuffer*/
long GetLinkSpeedData(const CString& serial, double* timeBuffer, double* dataBuffer, long bufferSize);
/** Adds one bit of communication information to the list.
If the serial equals "FTP" then the information is
tought to be from the ftp-uploading link */
void AddDownloadData(const CString& serial, double linkSpeed, const novac::CDateTime* timeOfDownload = NULL);
/**Add one serial number into the m_serials[]array*/
int AddData(const CString& serial);
private:
// ----------------------------------------------------------------------
// ---------------------- PRIVATE DATA ----------------------------------
// ----------------------------------------------------------------------
/** How many serial numbers have been inserted */
unsigned int m_serialNum;
int m_communicationStatus[MAX_NUMBER_OF_SCANNING_INSTRUMENTS];
/** The serial numbers */
CString m_serials[MAX_NUMBER_OF_SCANNING_INSTRUMENTS];
/** Holds a list of the information we have on the data-links */
CLinkInfo m_dataLinkInformation[MAX_NUMBER_OF_SCANNING_INSTRUMENTS][MAX_HISTORY];
int m_dataLinkIndex[MAX_NUMBER_OF_SCANNING_INSTRUMENTS];
/** Holds the information about the FTP-uploading data link */
CLinkInfo m_ftpServerLinkInformation[MAX_HISTORY];
int m_nFTPServerLinkInformation;
// ----------------------------------------------------------------------
// -------------------- PRIVATE METHODS ---------------------------------
// ----------------------------------------------------------------------
/** Clear out old data from the 'm_dataLinkInformation' buffers */
void RemoveOldLinkInformation();
};