2024-04-20 01:48:14 +00:00
|
|
|
#ifndef STATE_h
|
|
|
|
#define STATE_h
|
|
|
|
|
|
|
|
#include "json/single_include/nlohmann/json.hpp"
|
|
|
|
#include <iostream>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
using json = nlohmann::json;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
enum Action {
|
|
|
|
NONE,
|
|
|
|
LOAD,
|
|
|
|
DISPLAY,
|
|
|
|
STOP
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Mode {
|
|
|
|
RGB,
|
|
|
|
BW,
|
|
|
|
|
|
|
|
INVERT,
|
|
|
|
BW_INVERT,
|
|
|
|
|
|
|
|
RGB_CHANNELS,
|
|
|
|
INVERT_CHANNELS
|
|
|
|
};
|
|
|
|
|
|
|
|
class State {
|
|
|
|
private:
|
|
|
|
Action action = STOP;
|
|
|
|
Mode mode = RGB;
|
|
|
|
string image;
|
|
|
|
vector<uint64_t> exposure = {};
|
|
|
|
uint64_t x;
|
|
|
|
uint64_t y;
|
2024-04-26 17:04:37 +00:00
|
|
|
uint64_t w;
|
|
|
|
uint64_t h;
|
2024-04-20 02:33:28 +00:00
|
|
|
bool active = false;
|
2024-04-20 01:48:14 +00:00
|
|
|
bool ERROR = false;
|
|
|
|
|
|
|
|
void error();
|
|
|
|
bool imageExists(string& image);
|
|
|
|
void setAction(json& msgData);
|
|
|
|
void setImage(json& msgData);
|
|
|
|
void setMode(json& msgData);
|
|
|
|
void setExposure(json& msgData);
|
2024-05-14 23:06:43 +00:00
|
|
|
void setNoExposure();
|
2024-04-20 01:48:14 +00:00
|
|
|
void setPosition(json& msgData);
|
2024-05-05 15:28:20 +00:00
|
|
|
void setActive () { active = true; }
|
2024-04-20 01:48:14 +00:00
|
|
|
|
|
|
|
public :
|
|
|
|
State();
|
|
|
|
void receiveMessage(string msgString);
|
2024-10-18 15:32:35 +00:00
|
|
|
string createMessage(bool success, uint64_t data);
|
2024-04-20 01:48:14 +00:00
|
|
|
Action getAction () { return action; }
|
|
|
|
Mode getMode() { return mode; }
|
|
|
|
string getImage () { return image; }
|
|
|
|
vector<uint64_t> getExposure() { return exposure; }
|
2024-04-26 17:04:37 +00:00
|
|
|
vector<uint64_t> getPosition() { return { x, y, w, h }; }
|
2024-04-20 01:48:14 +00:00
|
|
|
bool isError () { return ERROR; }
|
2024-05-05 15:28:20 +00:00
|
|
|
void setInactive () { active = false; }
|
2024-04-20 02:33:28 +00:00
|
|
|
bool isActive () { return active; }
|
2024-04-20 01:48:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|