-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataManagement.h
154 lines (131 loc) · 4.34 KB
/
DataManagement.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* DataManagement.h
* ----------------
* Header file for the DataManager class. This object handles all the data storage,
* and writing to disk functionality of the HAWK.
*
* Created by John Whitworth on 8/26/14.
* Copyright 2015 Eileen Mazzochette, et al <[email protected]>
*/
#pragma once
#pragma managed(push,off)
#include <cv.h>
#pragma managed(pop)
#include <highgui.h>
#include "SafeQueue.h"
#include "Worm.h"
#define YAML_OPEN_ERROR 23
#define AVI_OPEN_ERROR 24
/* Class: DataManager
* ------------------
* The DataManager object manages the video and yaml writers. It also houses
* the SafeQueue of worm data while it is being processed.
*/
class DataManager {
//properties
public:
//object for writing the YAML file
cv::FileStorage dataWriter;
//object for writing to the fpga data file
cv::FileStorage fpgaWriter;
//object for writing the AVI file
cv::VideoWriter videoWriter;
//threadsafe queue for worm data prior to write out
SafeQueue<WormOutputData> wormDataBuffer;
//
std::string trackDataFileName;
std::string stimDataFileName;
std::string aviDataFileName;
std::string fpgaDataFileName;
private:
//incremented from 0 as soon as frames are being written
int writtenWormNumber;
//time of creation
SYSTEMTIME now;
//prototypes
public:
/* Function: setUpDataWriters
* --------------------------
* Creates the names for the output files, opens up both writers, and
* writes the initial header.
*/
int setUpDataWriters(string directory, string filename);
/* Function: appendWormFrameToDisk
* -------------------------------
* Writes a frame of video to disk and then writes the worm data to the
* YAML file.
*/
void appendWormFrameToDisk(WormOutputData data, bool printOverlays);
/* Function: closeDataWriters
* --------------------------
* Releases both the data writers.
*/
void closeDataWriters(void);
/* Function: writeStimulusDataToDisk
* -----------------------------------
* Writes the data from the current stimulus to fpga data writer object.
*/
void writeStimulusDataToDisk(int stimNum, vector<double> piezoSignalData, vector<double> actuatorPositionData, vector<double> actuatorCommandData, vector<double> desiredSignalData);
/* Function writefpgaPointToDisk
* --------------------------------------
* writes a data point from the fpga to the fpga data writer.
*/
void writefpgaPointToDisk(string title, double value);
/* Function: writeStringToDisk
* ---------------------------
* Outputs the value string with the given title.
*/
void writeStringToDisk(string title, string value);
/* Function: writeDoubleToDisk
* ---------------------------
* Outputs the value double with the given title.
*/
void writeDoubleToDisk(string title, double value);
/* Function: writeIntToDisk
* ------------------------
* Outputs the value int with the given title.
*/
void writeIntToDisk(string title, int value);
/* Function: writePointToDisk
* --------------------------
* Outputs the value Point with the given title.
*/
void writePointToDisk(string title, cv::Point value);
/* Function: writePoint2dToDisk
* ----------------------------
* Outputs the value Point2d with the given title.
*/
void writePoint2dToDisk(string title, cv::Point2d value);
/* Function: writeMovementToDisk
* -----------------------------
* Outputs the value Movement with the given title.
*/
void writeMovementToDisk(string title, Movement value);
/* Function: writeTimeToDisk
* -------------------------
* Outputs the value SYSTEMTIME with the given title.
*/
void writeTimeToDisk(string title, SYSTEMTIME value);
/* Function: startNode
* -------------------
* Begins a YAML structutre node with the given title.
*/
void startNode(string nodeTitle);
/* Function: endNode
* -----------------
* Ends a YAML structutre node.
*/
void endNode(void);
private:
/* Function: localTimeFilename
* ---------------------------
* Returns a string with the local time formatted to be put
* in the file name of the output files.
*/
string localTimeFilename(SYSTEMTIME now);
/* Function: wormTitle
* -------------------
* Returns a string combination of "WormInfo " and the given
* integer.
*/
string wormTitle(int frameNumber);
};