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