45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
#ifndef BELT_CONTROLLER_H_
|
|
#define BELT_CONTROLLER_H_
|
|
#include "color.h"
|
|
#include "conveyorBeltGrpcClient.hpp"
|
|
#include <cstdlib>
|
|
#include <glog/logging.h>
|
|
#include <httplib.h>
|
|
#include <iostream>
|
|
#include <json/json.h>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <shared_mutex>
|
|
#include <stdio.h>
|
|
#include <string>
|
|
|
|
typedef int ConveyorBeltStatus;
|
|
|
|
class ConveyorBeltController {
|
|
private:
|
|
std::string ip;
|
|
ConveyorBeltStatus status;
|
|
std::shared_mutex mutex_;
|
|
int IPCPort;
|
|
int abilityPort;
|
|
std::map<int, std::string> ipMap;
|
|
int stateSwitch(ConveyorBeltStatus destState, std::string cmd);
|
|
int grpcConnect(float speed, int direction);
|
|
int grpcDisconnect();
|
|
int grpcCheck();
|
|
int synchState(std::string json);
|
|
bool simpleStateCheck();
|
|
|
|
public:
|
|
int handleOpen(float speed, int direction);
|
|
int handleClose();
|
|
int handleCheck();
|
|
void init();
|
|
void setServerIp(std::string serverIp);
|
|
ConveyorBeltStatus getCurrentStatus();
|
|
ConveyorBeltController(/* args */);
|
|
~ConveyorBeltController();
|
|
};
|
|
|
|
#endif
|