Report the timing of each individual step with the data field on the fdOutgoingMessage object (as received by filmout_manager).
This commit is contained in:
parent
c73d9fe698
commit
4a9ddae1c4
|
@ -52,7 +52,7 @@ class State {
|
|||
public :
|
||||
State();
|
||||
void receiveMessage(string msgString);
|
||||
string createMessage(bool success);
|
||||
string createMessage(bool success, uint64_t data);
|
||||
Action getAction () { return action; }
|
||||
Mode getMode() { return mode; }
|
||||
string getImage () { return image; }
|
||||
|
|
26
src/main.cpp
26
src/main.cpp
|
@ -39,6 +39,7 @@ Image img;
|
|||
State state;
|
||||
|
||||
uint64_t exposureTime = 0;
|
||||
uint64_t exposureElapsedTime = 0;
|
||||
steady_clock::time_point startTime;
|
||||
bool displaying = false;
|
||||
bool completed = false;
|
||||
|
@ -72,19 +73,20 @@ void actionDisplay () {
|
|||
} // multi channel case
|
||||
}
|
||||
|
||||
void actionStop () {
|
||||
uint64_t actionStop () {
|
||||
displaying = false;
|
||||
completed = true;
|
||||
auto currentTime = steady_clock::now();
|
||||
auto elapsedTime = duration_cast<milliseconds>(currentTime - startTime).count();
|
||||
cout << "{ \"exposed\" : " << elapsedTime << ", \"exposure\" : null }" << endl;
|
||||
return elapsedTime;
|
||||
}
|
||||
|
||||
void postAction () {
|
||||
void postAction (uint64_t data) {
|
||||
if (state.isError()) {
|
||||
outgoingMessage = state.createMessage(false);
|
||||
outgoingMessage = state.createMessage(false, 0);
|
||||
} else {
|
||||
outgoingMessage = state.createMessage(true);
|
||||
outgoingMessage = state.createMessage(true, data);
|
||||
}
|
||||
const char* msg = outgoingMessage.c_str();
|
||||
int bytesSent = send(clientSocket, msg, strlen(msg), 0);
|
||||
|
@ -95,7 +97,7 @@ void postAction () {
|
|||
}
|
||||
}
|
||||
|
||||
void actionLoad () {
|
||||
uint64_t actionLoad () {
|
||||
auto localStartTime = steady_clock::now();
|
||||
string imagePath = state.getImage();
|
||||
vector<uint64_t> position = state.getPosition();
|
||||
|
@ -122,6 +124,7 @@ void actionLoad () {
|
|||
auto localElapsedTime = duration_cast<milliseconds>(localCurrentTime - localStartTime).count();
|
||||
cout << "{ \"load_time\" : " << localElapsedTime << " }" << endl;
|
||||
completed = true;
|
||||
return localElapsedTime;
|
||||
}
|
||||
|
||||
void loadBlank () {
|
||||
|
@ -150,19 +153,23 @@ void initImageTexture() {
|
|||
}
|
||||
|
||||
void display () {
|
||||
uint64_t data = 0;
|
||||
if (state.isActive()) {
|
||||
if (state.getAction() == LOAD) {
|
||||
actionLoad();
|
||||
data = actionLoad();
|
||||
} else if (state.getAction() == DISPLAY) {
|
||||
actionDisplay();
|
||||
} else if (state.getAction() == STOP) {
|
||||
actionStop();
|
||||
data = actionStop();
|
||||
}
|
||||
state.setInactive();
|
||||
}
|
||||
|
||||
if (completed) {
|
||||
postAction();
|
||||
if (timing) {
|
||||
data = exposureElapsedTime;
|
||||
}
|
||||
postAction(data);
|
||||
completed = false;
|
||||
}
|
||||
|
||||
|
@ -170,9 +177,10 @@ void display () {
|
|||
auto currentTime = steady_clock::now();
|
||||
auto elapsedTime = duration_cast<milliseconds>(currentTime - startTime).count();
|
||||
if (elapsedTime >= exposureTime) {
|
||||
exposureElapsedTime = elapsedTime;
|
||||
cout << "{ \"exposed\" : " << elapsedTime << ", \"exposure\" : " << exposureTime << " }" << endl;
|
||||
displaying = false;
|
||||
timing = false;
|
||||
//timing = false;
|
||||
completed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,9 +109,10 @@ void State::receiveMessage (string msgString) {
|
|||
setActive();
|
||||
}
|
||||
|
||||
string State::createMessage (bool success) {
|
||||
string State::createMessage (bool success, uint64_t data) {
|
||||
json msgData = {
|
||||
{ "action", action },
|
||||
{ "data", data },
|
||||
{ "success", success }
|
||||
};
|
||||
return msgData.dump();
|
||||
|
|
Loading…
Reference in New Issue