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;
|
|
|
|
uint64_t width;
|
|
|
|
uint64_t height;
|
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);
|
|
|
|
void setPosition(json& msgData);
|
|
|
|
|
|
|
|
public :
|
|
|
|
State();
|
|
|
|
void receiveMessage(string msgString);
|
|
|
|
string createMessage(bool success);
|
|
|
|
Action getAction () { return action; }
|
|
|
|
Mode getMode() { return mode; }
|
|
|
|
string getImage () { return image; }
|
|
|
|
vector<uint64_t> getExposure() { return exposure; }
|
|
|
|
vector<uint64_t> getPosition() { return { x, y, width, height }; }
|
|
|
|
bool isError () { return ERROR; }
|
2024-04-20 02:33:28 +00:00
|
|
|
void setActive () { active = true; }
|
|
|
|
bool isActive () { return active; }
|
2024-04-20 01:48:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|