#include "ability_sdk/AbilityStub.hpp" #include "conveyorBeltGrpcServer.h" class ConveyorBeltAbility : public ability_sdk::AbilityStub { public: using AbilityTemplate::AbilityTemplate; void create_ability_server() { ConveyorBeltServer service_ability; ServerBuilder builder; builder.AddListeningPort("0.0.0.0:0", grpc::InsecureServerCredentials(), &g_abilityPort); cout << "add listening port" << endl; builder.RegisterService(&service_ability); cout << "register service" << endl; ability_cq = builder.AddCompletionQueue(); ability_server = builder.BuildAndStart(); std::cout << "Server listening on port: " << g_abilityPort << std::endl; sendStateMsg(); ability_server->Wait(); std::cout << "finish ipc server" << std::endl; } void runServer() { g_GLOBAL_STATUS = STATUS_INIT; std::cout << "NOW GLOBAL STATUS IS: " << global2string(g_GLOBAL_STATUS) << std::endl; std::thread heartbeat_thread(&ConveyorBeltAbility::heartbeat_loop, this); heartbeat_thread.detach(); } };