Przeglądaj źródła

20200427,hl恢复成laser专用代码。

huli 5 lat temu
rodzic
commit
b66057cb5d

+ 54 - 34
CMakeLists.txt

@@ -11,52 +11,72 @@ FIND_PACKAGE(PCL REQUIRED)
 FIND_PACKAGE(Protobuf REQUIRED)
 FIND_PACKAGE(Glog REQUIRED)
 set(CMAKE_MODULE_PATH "/usr/local/share/")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-as-needed")
-set(CMAKE_CXX_FLAGS "-std=c++11 -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2")
-set(CMAKE_BUILD_TYPE "RELEASE")
 
+set(CMAKE_CXX_FLAGS "-std=c++11 -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2")
+#set(CMAKE_BUILD_TYPE "RELEASE")
+set(CMAKE_BUILD_TYPE Debug)
 
 #find_package(Eigen3 REQUIRED)
 
 include_directories(
         laser
-        plc
+#        plc
         src
-        Locate
-        /usr/local/include
-        /usr/local/include/modbus
-        /usr/local/include/snap7
-  ${PCL_INCLUDE_DIRS}
-  ${OpenCV_INCLUDE_DIRS}
+#        Locate
+
+        error_code
+        tool
+        #        /usr/local/include/modbus
+        ${PCL_INCLUDE_DIRS}
+        ${OpenCV_INCLUDE_DIRS}
 )
 link_directories("/usr/local/lib")
 
-aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/task TASK_MANAGER_SRC )
-aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/error_code ERROR_SRC )
-aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/tool TOOL_SRC )
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/laser LASER_SRC )
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/plc PLC_SRC )
-aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/locate LOCATE_SRC )
+aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/Locate LOCATE_SRC )
 aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/terminor TERMINOR_SRC )
-aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/verify VERIFY_SRC )
-aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/system_manager SYS_SRC )
-aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/wj_lidar WJLIDAR_SRC )
-
-
-# plc test module
-add_executable(plc_test  ./test/plc_test.cpp ${PLC_SRC} ${TASK_MANAGER_SRC} ${TOOL_SRC} ${ERROR_CODE_SRC})
-target_link_libraries(plc_test ${OpenCV_LIBS}
-        ${GLOG_LIBRARIES} ${PCL_LIBRARIES} ${PROTOBUF_LIBRARIES} ipopt modbus libnanomsg.so libnnxx.a libglog.a libgflags.a)
-add_executable(fence_debug  test/plc_s7.cpp wj_lidar/wj_lidar_msg.pb.cc)
-target_link_libraries(fence_debug ${GLOG_LIBRARIES} ${PROTOBUF_LIBRARIES} /usr/local/lib/libglog.a
-        /usr/local/lib/libgflags.a nnxx nanomsg)
-
-
-add_executable(locate  main.cpp ${LOCATE_SRC} ${PLC_SRC} ${TERMINOR_SRC} ${TASK_MANAGER_SRC} ${LASER_SRC} ${ERROR_SRC}
-        ${TOOL_SRC} ${SYS_SRC} ${VERIFY_SRC} ${WJLIDAR_SRC})
-target_link_libraries(locate ${OpenCV_LIBS}
-        ${GLOG_LIBRARIES} ${PCL_LIBRARIES} ${PROTOBUF_LIBRARIES} ipopt libtensorflow_cc.so
-        tf_3dcnn_api.so pointSIFT_API.so dark.so /usr/local/lib/libmodbus.so /usr/local/lib/libglog.a
-        /usr/local/lib/libgflags.a /usr/local/lib/liblivox_sdk_static.a /usr/local/apr/lib/libapr-1.a snap7 nnxx nanomsg)
+aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/task TASK_MANAGER_SRC )
+aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/tool TOOL_SRC )
+
+
+add_executable(LidarMeasure ./main.cpp ./error_code/error_code.cpp
+#        ./src/StdCondition.cpp ./src/CalibParam.pb.cc
+        ./tool/StdCondition.cpp
+        ./globalmsg.pb.cc
+        ./MeasureTopicPublisher.cpp
+        ./laser/laser_task_command
+        ${LASER_SRC}
+#        ${PLC_SRC}
+#        ${TERMINOR_SRC}
+        ${LOCATE_SRC}
+        ${TASK_MANAGER_SRC}
+#        ${TOOL_SRC}
+        ./tool/binary_buf.cpp
+        ./tool/thread_condition.h ./tool/thread_condition.cpp
+        ./tool/thread_safe_queue.h ./tool/thread_safe_queue.cpp
+
+        )
+
+
+
+
+target_link_libraries(LidarMeasure
+        #${OpenCV_LIBS}
+        ${GLOG_LIBRARIES}
+        ${PCL_LIBRARIES}
+        ${PROTOBUF_LIBRARIES}
+        #ipopt libtensorflow_cc.so
+        #tf_3dcnn_api.so
+        #pointSIFT_API.so
+        #dark.so
+        /usr/local/lib/libglog.a
+        ##/usr/local/lib/libmodbus.so
+        /usr/local/lib/libgflags.a
+        /usr/local/lib/liblivox_sdk_static.a
+        /usr/local/apr/lib/libapr-1.a
+        nnxx
+        nanomsg
+        )
 
 

+ 14 - 2
laser/Laser.cpp

@@ -239,15 +239,27 @@ Error_manager Laser_base::set_open_save_path(std::string save_path,bool is_save)
 	}
 	else
 	{
+		time_t nowTime;
+		nowTime = time(NULL);
+		struct tm* sysTime = localtime(&nowTime);
+		char time_string[256] = { 0 };
+		sprintf(time_string, "%04d%02d%02d_%02d%02d%02d",
+				sysTime->tm_year + 1900, sysTime->tm_mon + 1, sysTime->tm_mday, sysTime->tm_hour, sysTime->tm_min, sysTime->tm_sec);
+
 		m_save_path = save_path;
 		char pts_file[255] = { 0 };
-		sprintf(pts_file, "%s/pts%d.txt", save_path.c_str(), m_laser_id+1);
+//		sprintf(pts_file, "%s/pts%d.txt", save_path.c_str(), m_laser_id+1);
+		sprintf(pts_file, "%s/pst%s__%d.txt", save_path.c_str(), time_string,m_laser_id+1);
+		cout<<"pts_file " << pts_file <<endl;
 		m_points_log_tool.open(pts_file);
 		std::cout << "huli m_points_log_tool path "<< pts_file << std::endl;
 
 		char bin_file[255] = { 0 };
-		sprintf(bin_file, "%s/laser%d.data", save_path.c_str(), m_laser_id+1);
+//		sprintf(bin_file, "%s/laser%d.data", save_path.c_str(), m_laser_id+1);
+		sprintf(bin_file, "%s/laser%slaser%d.data", save_path.c_str(),time_string, m_laser_id+1);
 		m_binary_log_tool.open(bin_file,true);
+		std::cout << "huli m_binary_log_tool path "<< bin_file << std::endl;
+
 		return Error_code::SUCCESS;
 	}
 }

+ 182 - 82
main.cpp

@@ -1,17 +1,17 @@
 //
 // Created by zx on 2019/12/28.
 //
-#include <fcntl.h>
 #include <iostream>
-#include "plc/plc_communicator.h"
-#include "laser/Laser.h"
-#include "plc/plc_communicator.h"
-#include "locate/locater.h"
-#include "terminor/terminal_command_executor.h"
-#include "system_manager/System_Manager.h"
-#include "tool/pathcreator.h"
-#include <glog/logging.h>
 
+#include "./laser/Laser.h"
+#include "./laser/LivoxLaser.h"
+#include "./error_code/error_code.h"
+#include "LogFiles.h"
+#include <string.h>
+#include <fcntl.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/text_format.h>
+//#include </usr/local/include/google/protobuf/io/zero_copy_stream_impl.h>
 using google::protobuf::io::FileInputStream;
 using google::protobuf::io::FileOutputStream;
 using google::protobuf::io::ZeroCopyInputStream;
@@ -19,83 +19,183 @@ using google::protobuf::io::CodedInputStream;
 using google::protobuf::io::ZeroCopyOutputStream;
 using google::protobuf::io::CodedOutputStream;
 using google::protobuf::Message;
-GOOGLE_GLOG_DLL_DECL void shut_down_logging(const char* data, int size)
-{
-    time_t tt;
-    time( &tt );
-    tt = tt + 8*3600;  // transform the time zone
-    tm* t= gmtime( &tt );
-    char buf[255]={0};
-    sprintf(buf,"./%d%02d%02d-%02d%02d%02d-dump.txt",
-            t->tm_year + 1900,
-            t->tm_mon + 1,
-            t->tm_mday,
-            t->tm_hour,
-            t->tm_min,
-            t->tm_sec);
-
-    FILE* tp_file=fopen(buf,"w");
-    fprintf(tp_file,data,strlen(data));
-    fclose(tp_file);
 
-}
+#define O_RDONLY	     00
 
-void init_glog()
+#define LIVOX_NUMBER	     2
+
+//读取protobuf 配置文件
+//file:文件
+//parameter:要读取的配置
+bool read_proto_param(std::string file, ::google::protobuf::Message& parameter)
 {
-    time_t tt = time(0);//时间cuo
-    struct tm* t = localtime(&tt);
-
-    char strYear[255]={0};
-    char strMonth[255]={0};
-    char strDay[255]={0};
-
-    sprintf(strYear,"%04d", t->tm_year+1900);
-    sprintf(strMonth,"%02d", t->tm_mon+1);
-    sprintf(strDay,"%02d", t->tm_mday);
-
-    char buf[255]={0};
-    getcwd(buf,255);
-    char strdir[255]={0};
-    sprintf(strdir,"%s/log/%s/%s/%s", buf,strYear,strMonth,strDay);
-    PathCreator creator;
-    creator.Mkdir(strdir);
-
-    char logPath[255] = { 0 };
-    sprintf(logPath, "%s/", strdir);
-    FLAGS_max_log_size = 100;
-    FLAGS_logbufsecs = 0;
-    google::InitGoogleLogging("LidarMeasurement");
-    google::SetStderrLogging(google::INFO);
-    google::SetLogDestination(0, logPath);
-    google::SetLogFilenameExtension("zxlog");
-    google::InstallFailureSignalHandler();
-    google::InstallFailureWriter(&shut_down_logging);
-    FLAGS_colorlogtostderr = true;        // Set log color
-    FLAGS_logbufsecs = 0;                // Set log output speed(s)
-    FLAGS_max_log_size = 1024;            // Set max log file size(GB)
-    FLAGS_stop_logging_if_full_disk = true;
+	int fd = open(file.c_str(), O_RDONLY);
+	if (fd == -1) return false;
+	FileInputStream* input = new FileInputStream(fd);
+	bool success = google::protobuf::TextFormat::Parse(input, &parameter);
+	delete input;
+	close(fd);
+	return success;
 }
 
+
+
 int main(int argc,char* argv[])
 {
-    Error_manager code;
-    //初始化日志
-    init_glog();
-    //创建system实例
-    System_Manager system_manager;
-    //初始化实例,包括雷达,plc,locater,terminal的创建及初始化
-    code=system_manager.init();
-    if(code!=SUCCESS)
-    {
-        LOG(ERROR)<<code.to_string();
-        printf("print ctrl-c to quite");
-    }
-    else
-    {
-        LOG(INFO)<<"SYSTEM Init OK !!!!";
-    }
-
-    getchar();
-
-    return 0;
-}
+
+
+	std::cout << "huli 101 main start!" << std::endl;
+
+
+	Laser_base * m_laser_vector_array[LIVOX_NUMBER];
+	Error_manager err;
+
+	for (int i = 0; i < LIVOX_NUMBER; ++i)
+	{
+		Laser_base *m_laser_vector;
+
+		Laser_proto::laser_parameter laser_param;
+		laser_param.set_frame_num(1000);
+		laser_param.set_type("Livox");
+		if ( i==0 )
+		{
+			laser_param.set_sn("0TFDFG700601881");
+		}
+		else if ( i==1 )
+		{
+			laser_param.set_sn("0TFDFCE00502001");
+		}
+
+//	int i = 0;
+		m_laser_vector_array[i] = m_laser_vector = LaserRegistory::CreateLaser(laser_param.type(), i,
+																			   laser_param);
+
+
+		if (m_laser_vector != NULL)
+		{
+			err = m_laser_vector->connect_laser();
+			if ( err != Error_code::SUCCESS)
+			{
+				char description[255] = {0};
+				sprintf(description, "Laser %d connect failed...", i);
+				err.error_manager_reset(LASER_CONNECT_FAILED, NORMAL, description);
+
+			}
+			else
+			{
+				std::cout << "huli 301 connect_laser Error_code::SUCCESS" << std::endl;
+			}
+
+			cout << "huli 311 " << err.to_string() << endl;
+
+
+
+
+		}
+		else
+		{
+			cout << "huli: 601 :" << err.to_string() << endl;
+
+		}
+
+	}
+
+
+	if (!Start()) {
+		Uninit();
+		printf("Livox-SDK init fail!\n");
+	}
+	else
+	{
+		std::cout << "huli 201 Livox-SDK start" << std::endl;
+	}
+
+
+
+	while(1)
+	{
+		pcl::PointCloud<pcl::PointXYZ>::Ptr scan_cloud(new pcl::PointCloud<pcl::PointXYZ>);
+		std::mutex cloud_lock;
+
+		Laser_task *laser_task = new Laser_task();
+		//
+		laser_task->task_init(TASK_CREATED, scan_cloud, &cloud_lock);
+		laser_task->set_task_frame_maxnum(1000);
+
+//		//保存文件初始化
+//		char time_string[256] = { 0 };
+//		sprintf(time_string, "../data/%d/", 0);
+//
+//		laser_task->set_task_save_path(time_string);
+
+		std::cout << "huli 401 connect_laser Error_code::SUCCESS" << std::endl;
+
+		std::cout << " press to start" << std::endl;
+		char ch ;
+//		= getchar();
+		std::cin >> ch ;
+		if ( ch == 'b' )
+		{
+			std::cout << "  end scan ------------" << std::endl;
+			break;
+		}
+		std::cout << "  start scan ------------" << std::endl;
+
+//		err = m_laser_vector_array[0]->execute_task(laser_task);
+//		usleep(3000 * 1000);
+//		cout << "huli: 501 :" << err.to_string() << endl;
+		int n = 5;
+		while(n)
+		{
+			n--;
+
+			for (int i = 0; i < LIVOX_NUMBER; ++i)
+			{
+				char time_string[256] = { 0 };
+				sprintf(time_string, "../data/%d/", i);
+				laser_task->set_task_save_path(time_string);
+
+				err = m_laser_vector_array[i]->execute_task(laser_task);
+//				usleep(3000 * 1000);
+			}
+
+			usleep(3000 * 1000);
+			cout << "huli: 501 :" << err.to_string() << endl;
+			cout << "huli: 501 :" << err.to_string() << endl;
+		}
+
+		cout << "huli: 601 :" << err.to_string() << endl;
+		//发送任务单给雷达
+		std::this_thread::sleep_for(std::chrono::seconds(5));
+
+	}
+
+
+
+
+	for (int i = 0; i < LIVOX_NUMBER; ++i)
+	{
+		std::this_thread::sleep_for(std::chrono::seconds(5));
+		cout << "huli: 701 :" << err.to_string() << endl;
+
+		m_laser_vector_array[i]->disconnect_laser();
+		cout << "huli: 801 :" << err.to_string() << endl;
+
+		m_laser_vector_array[i]->close_save_path();
+		cout << "huli: 901 :" << err.to_string() << endl;
+
+		std::this_thread::sleep_for(std::chrono::seconds(2));
+
+	}
+
+	Uninit();
+
+	cout << "huli 1234 main end" << endl;
+}
+
+
+
+
+
+
+

+ 0 - 116
plc/LibmodbusWrapper.cpp

@@ -1,116 +0,0 @@
-
-#include "LibmodbusWrapper.h"
-
-namespace modbus
-{
-    CLibmodbusWrapper::CLibmodbusWrapper()
-        :_ctx(NULL)
-        , _ip("")
-        ,_port(-1)
-        ,_slave_id(-1)
-    {
-    }
-
-
-    CLibmodbusWrapper::~CLibmodbusWrapper()
-    {
-        deinitialize();
-    }
-
-    void CLibmodbusWrapper::deinitialize()
-    {
-        if (_ctx)
-        {
-            modbus_close(_ctx);
-            modbus_free(_ctx);
-            _ctx = NULL;
-            _ip = "";
-            _port = -1;
-            _slave_id = -1;
-        }
-    }
-    int CLibmodbusWrapper::initialize(const char *ip, int port, int slave_id)
-    {
-        int rc = 0;
-
-        this->deinitialize();
-
-        _ctx = modbus_new_tcp(ip, port);
-        if (_ctx == NULL)
-        {
-            //����ʧ��
-            fprintf(stderr, "CLibmodbusWrapper: Unable to allocate libmodbus context\n");
-            return -3;
-        }
-
-        // ���õ���ģʽ
-        modbus_set_debug(_ctx, FALSE);
-
-        // �������ӵ�slave�ţ��˴�Ϊ1
-        rc = modbus_set_slave(_ctx, slave_id);
-        if (rc == -1)
-        {
-            fprintf(stderr, "CLibmodbusWrapper: Invalid slave ID\n");
-            modbus_free(_ctx);
-            _ctx = NULL;
-            return -2;
-        }
-
-        rc = modbus_connect(_ctx);
-        if (rc == -1)
-        {
-            fprintf(stderr, "CLibmodbusWrapper: Connection failed: %s\n", modbus_strerror(errno));
-            modbus_free(_ctx);
-            _ctx = NULL;
-            return -1;
-        }
-
-        _ip = ip;
-        _port = port;
-        _slave_id = slave_id;
-
-        return 0;
-    }
-
-    int CLibmodbusWrapper::read_registers(int addr, int nb, uint16_t *dest)
-    {
-        if (modbus_read_registers(_ctx, addr, nb, dest) == -1)
-        {
-            fprintf(stderr, "CLibmodbusWrapper: Read registers failed: %s\n", modbus_strerror(errno));
-            // printf("%s---%s, %d\n", modbus_strerror(errno), "Broken pipe", strcmp(modbus_strerror(errno), "Broken pipe")==0?1:0);
-            return -1;
-        }
-        return 0;
-    }
-
-    int CLibmodbusWrapper::write_registers(int addr, int nb, uint16_t *dest)
-    {
-        if (modbus_write_registers(_ctx, addr, nb, dest) == -1)
-        {
-            fprintf(stderr, "CLibmodbusWrapper: Write registers failed: %s\n", modbus_strerror(errno));
-            return -1;
-        }
-        return 0;
-    }
-
-
-    int CLibmodbusWrapper::read_register(int addr, uint16_t *dest)
-    {
-        if (modbus_read_registers(_ctx, addr, 1, dest) == -1)
-        {
-            fprintf(stderr, "CLibmodbusWrapper: Read registers failed: %s\n", modbus_strerror(errno));
-            return -1;
-        }
-        return 0;
-    }
-
-    int CLibmodbusWrapper::write_register(int addr, uint16_t *dest)
-    {
-        if (modbus_write_registers(_ctx, addr, 1, dest) == -1)
-        {
-            fprintf(stderr, "CLibmodbusWrapper: Write registers failed: %s\n", modbus_strerror(errno));
-            return -1;
-        }
-        return 0;
-    }
-}

+ 0 - 37
plc/LibmodbusWrapper.h

@@ -1,37 +0,0 @@
-#pragma once
-#include <stdio.h>
-#include <errno.h>
-#include <string>
-#include <string.h>
-#include "modbus.h"
-
-namespace modbus
-{
-    class CLibmodbusWrapper
-    {
-    public:
-        CLibmodbusWrapper();
-        virtual ~CLibmodbusWrapper();
-        int initialize(const char *ip, int port, int slave_id);
-        void deinitialize();
-
-    public:
-        int read_registers(int addr, int nb, uint16_t *dest);
-        int write_registers(int addr, int nb, uint16_t *dest);
-
-        int read_register(int addr, uint16_t *dest);
-        int write_register(int addr, uint16_t *dest);
-
-        inline bool is_connected() { return (0 == _ctx) ? false : true; };
-        inline std::string getIP() { return _ip; };
-        inline int getPort() { return _port; };
-        inline int getSlave() { return _slave_id; };
-
-    private:
-        modbus_t* _ctx;
-    private:
-        std::string _ip;
-        int _port;
-        int _slave_id;
-    };
-};

+ 0 - 444
plc/plc_communicator.cpp

@@ -1,444 +0,0 @@
-#include "plc_communicator.h"
-#include <glog/logging.h>
-
-// ××××××××××× 构造与析构 ×××××××××××
-Plc_Communicator::Plc_Communicator(plc_module::plc_connection_params connection_params) : mb_plc_initialized(false),
-                                                                             mb_plc_is_connected(false),
-                                                                             mb_plc_is_updating(false),
-                                                                             mp_plc_owner(0),
-                                                                             m_plc_thread(0),
-                                                                             m_plc_message_thread(0)
-{
-    m_plc_ip_str = connection_params.ip();
-    m_plc_port = connection_params.port();
-    m_plc_slave_id = connection_params.slave_id();
-    m_plc_current_error = Error_manager(Error_code::SUCCESS, Error_level::NORMAL, "初始状态正常");
-    m_plc_status_update_timeout = 10000;
-    for (size_t i = 0; i < PLC_REGION_NUM; i++)
-    {
-        m_plc_region_status[i].last_time_point = std::chrono::steady_clock::now();
-        m_plc_region_status[i].current_status = 255;
-        m_plc_region_status[i].cmd = 0;
-    }
-
-    m_plc_data.resize(PLC_REGION_NUM * PLC_SIGNAL_NUM_PER_REGION);
-    m_plc_current_error = connect();
-    m_plc_cond_exit.Notify(false);
-    m_plc_thread = new std::thread(plc_update_thread, this);
-    m_plc_message_thread=new std::thread(plc_publish_message, this);
-    mb_plc_initialized = true;
-}
-
-Plc_Communicator::~Plc_Communicator()
-{
-    m_plc_cond_exit.Notify(true);
-    if (m_plc_thread)
-    {
-        if (m_plc_thread->joinable())
-            m_plc_thread->join();
-        delete m_plc_thread;
-        m_plc_thread = 0;
-    }
-
-    if (m_plc_message_thread)
-    {
-        if (m_plc_message_thread->joinable())
-            m_plc_message_thread->join();
-        delete m_plc_message_thread;
-        m_plc_message_thread = 0;
-    }
-    disconnect();
-}
-
-// ××××××××××× getters setters ×××××××××××
-bool Plc_Communicator::get_connection()
-{
-    return mb_plc_is_connected;
-}
-
-Error_manager Plc_Communicator::get_error(){
-    if(mb_plc_is_connected){
-        return Error_manager(Error_code::SUCCESS, Error_level::NORMAL, "连接正常");
-    }else{
-        return Error_manager(Error_code::PLC_CONNECTION_FAILED, Error_level::NEGLIGIBLE_ERROR, "连接失败");
-    }
-}
-
-bool Plc_Communicator::get_initialize_status()
-{
-    return mb_plc_initialized;
-}
-
-Error_manager Plc_Communicator::set_plc_callback(Command_Callback callback, void *p_owner)
-{
-    if (callback == 0 || p_owner == 0)
-        return Error_manager(Error_code::PARAMETER_ERROR, Error_level::MINOR_ERROR, "回调设置参数错误");
-    m_plc_callback = callback;
-    mp_plc_owner = p_owner;
-    return Error_manager(Error_code::SUCCESS, Error_level::NORMAL, "回调设置参数正确");
-}
-
-Error_manager Plc_Communicator::set_status_update_timeout(int millisecond)
-{
-    m_plc_status_update_timeout = millisecond;
-    return Error_manager(Error_code::SUCCESS, Error_level::NORMAL, "设置状态更新超时时间成功");
-}
-
-// ××××××××××× 内部调用连接与重连 ×××××××××××
-Error_manager Plc_Communicator::connect()
-{
-    m_plc_mutex.lock();
-    int rc = m_plc_wrapper.initialize(m_plc_ip_str.c_str(), m_plc_port, m_plc_slave_id);
-    m_plc_mutex.unlock();
-    switch (rc)
-    {
-    case 0:
-        mb_plc_is_connected = true;
-        return Error_manager(Error_code::SUCCESS, Error_level::NORMAL, "plc连接成功");
-    case -1:
-        mb_plc_is_connected = false;
-        return Error_manager(Error_code::PLC_CONNECTION_FAILED, Error_level::MINOR_ERROR, "plc掉线");
-    case -2:
-        mb_plc_is_connected = false;
-        return Error_manager(Error_code::PLC_SLAVE_ID_ERROR, Error_level::MINOR_ERROR, "plc的从站id错误");
-    case -3:
-        mb_plc_is_connected = false;
-        return Error_manager(Error_code::PLC_IP_PORT_ERROR, Error_level::MINOR_ERROR, "plc的ip或端口设置错误");
-    default:
-        mb_plc_is_connected = false;
-        return Error_manager(Error_code::PLC_UNKNOWN_ERROR, Error_level::MINOR_ERROR, "plc连接时出现未知返回值");
-    }
-}
-
-Error_manager Plc_Communicator::disconnect()
-{
-    m_plc_mutex.lock();
-    m_plc_wrapper.deinitialize();
-    mb_plc_is_connected = false;
-    m_plc_mutex.unlock();
-    return Error_manager(Error_code::SUCCESS);
-}
-
-// ××××××××××× 外部调用执行任务单 ×××××××××××
-Error_manager Plc_Communicator::execute_task(Task_Base *task)
-{
-    if (task == 0)
-        return Error_manager(Error_code::PARAMETER_ERROR, Error_level::NEGLIGIBLE_ERROR, "传入空任务");
-    if (task->get_task_type() != Task_type::PLC_TASK)
-    {
-        return Error_manager(Error_code::PARAMETER_ERROR, Error_level::NEGLIGIBLE_ERROR, "传入非plc任务");
-    }
-    Plc_Task *plc_task_temp = (Plc_Task *)task;
-    plc_task_temp->update_statu(Task_statu::TASK_SIGNED, "received by plc_communicator.");
-
-    struct measure_result measure_result_temp;
-    Error_manager err = plc_task_temp->get_result(measure_result_temp);
-    if (err.is_equal_error_manager(Error_manager(Error_code::SUCCESS)))
-    {
-        Error_manager write_err = write_result_to_plc(measure_result_temp);
-        plc_task_temp->update_statu(Task_statu::TASK_OVER, "executed by plc_communicator.");
-        return write_err;
-    }
-    else
-    {
-        return err;
-    }
-}
-
-// ××××××××××× 外部调用获取数据, 终端id[1-6], -1则获取所有数据 ×××××××××××
-Error_manager Plc_Communicator::get_plc_data(std::vector<uint16_t> &plc_data, int terminal_id)
-{
-    std::lock_guard<std::mutex> lck(m_plc_mutex);
-    plc_data.clear();
-    if (terminal_id == -1)
-    {
-        plc_data.operator=(m_plc_data);
-    }
-    else if (terminal_id <= PLC_REGION_NUM && terminal_id * PLC_SIGNAL_NUM_PER_REGION <= m_plc_data.size())
-    {
-        for (size_t i = (terminal_id - 1) * PLC_SIGNAL_NUM_PER_REGION; i < terminal_id * PLC_SIGNAL_NUM_PER_REGION; i++)
-        {
-            plc_data.push_back(m_plc_data[i]);
-        }
-        return Error_manager(Error_code::SUCCESS);
-    }
-    else
-        return Error_manager(Error_code::PLC_NOT_ENOUGH_DATA_ERROR);
-}
-
-Error_manager Plc_Communicator::write_result_to_plc(struct measure_result result){
-    // std::cout<<" write result 000 "<<result.terminal_id<<std::endl;
-    if(result.terminal_id<=0 || result.terminal_id>PLC_REGION_NUM){
-        Error_manager(Error_code::PARAMETER_ERROR, Error_level::MINOR_ERROR, "写plc传入参数错误");
-    }
-    // std::cout<<" write result 111 "<<std::endl;
-    int offset = PLC_SIGNAL_BEGIN_OFFSET + PLC_LASER_STATUS_ADDR + (result.terminal_id-1) * PLC_SIGNAL_NUM_PER_REGION;
-    int result_length = PLC_LASER_WHEELBASE_ADDR - PLC_LASER_STATUS_ADDR + 1;
-    uint16_t result_info_temp[result_length];
-    memset(result_info_temp, 0, result_length * sizeof(uint16_t));
-
-    // 之后设置正确位,先将数据写入,状态写2
-    if(result.correctness){
-        m_plc_region_status[result.terminal_id - 1].current_status = 3;
-        result_info_temp[PLC_LASER_STATUS_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(2);
-        result_info_temp[PLC_LASER_X_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(result.x + 0.5f);
-        result_info_temp[PLC_LASER_Y_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(result.y + 0.5f);
-        result_info_temp[PLC_LASER_ANGLE_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(result.angle * 100);
-        result_info_temp[PLC_LASER_LENGTH_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(result.length + 0.5f);
-        result_info_temp[PLC_LASER_WIDTH_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(result.width + 0.5f);
-        result_info_temp[PLC_LASER_HEIGHT_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(result.height + 0.5f);
-        result_info_temp[PLC_LASER_CORRECTNESS_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(0);
-        result_info_temp[PLC_LASER_WHEELBASE_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(result.wheel_base + 0.5f);
-    }else{
-        m_plc_region_status[result.terminal_id-1].current_status = 4;
-        result_info_temp[PLC_LASER_STATUS_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(2);
-        result_info_temp[PLC_LASER_CORRECTNESS_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(0);
-    }
-    if(!m_plc_wrapper.is_connected()){
-        return Error_manager(Error_code::PLC_CONNECTION_FAILED);
-    }
-    else{
-        // std::cout<<" write result start "<<std::endl;
-        int retry_times = 3;
-        int plc_write_return_code = -1;
-        while(retry_times-->0 && plc_write_return_code<0) {
-            // 写入数据
-            m_plc_mutex.lock();
-            plc_write_return_code = m_plc_wrapper.write_registers(offset, result_length, result_info_temp);
-            m_plc_mutex.unlock();
-            if(plc_write_return_code<0)
-                continue;
-            usleep(1000* 100);
-            // 写入状态
-            if(result.correctness)
-            {
-                result_info_temp[PLC_LASER_STATUS_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(3);
-                result_info_temp[PLC_LASER_CORRECTNESS_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(1);
-            }else
-            {
-                result_info_temp[PLC_LASER_STATUS_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(4);
-                result_info_temp[PLC_LASER_CORRECTNESS_ADDR - PLC_LASER_STATUS_ADDR] = uint16_t(0);
-            }
-            m_plc_mutex.lock();
-            plc_write_return_code = m_plc_wrapper.write_registers(offset, result_length, result_info_temp);
-            m_plc_mutex.unlock();
-            usleep(1000* 100);
-            // std::cout<<" write result end "<<rc<<std::endl;
-        }
-        if(retry_times <=0 || plc_write_return_code != 0)
-            return Error_manager(Error_code::PLC_WRITE_FAILED);
-        else
-            return Error_manager(Error_code::SUCCESS);
-    }
-}
-/*
- *
- */
-
-void Plc_Communicator::plc_publish_message(Plc_Communicator* plc)
-{
-    if(plc==0)
-    {
-        LOG(ERROR)<<"";
-    }
-    while(plc->m_plc_cond_exit.WaitFor(100)==false) {
-        plc_message::plcMsg msg;
-        for(int i=0;i<PLC_SIGNAL_BEGIN_OFFSET;++i)
-        {
-            msg.add_plc_values(0);
-        }
-        for (int i = 0; i < plc->m_plc_data.size(); ++i) {
-            msg.add_plc_values(plc->m_plc_data[i]);
-        }
-        plc_message::plcStatus status;
-        if (plc->mb_plc_is_connected)
-            status = plc_message::ePLCConnected;
-        else
-            status = plc_message::ePLCDisconnected;
-        msg.set_plc_status(status);
-        MeasureTopicPublisher::GetInstance()->Publish(msg.SerializeAsString());
-    }
-
-}
-
-// ××××××××××× 更新线程静态函数 ×××××××××××
-void Plc_Communicator::plc_update_thread(Plc_Communicator *plc_communicator)
-{
-    if (plc_communicator == 0)
-        return;
-    while (!plc_communicator->m_plc_cond_exit.WaitFor(100))
-    {
-        // std::cout<<" thread 000 "<<std::endl;
-
-        // 断线重连
-        if (!plc_communicator->mb_plc_is_connected)
-        {
-            Error_manager code=plc_communicator->connect();
-            if(code!=SUCCESS)
-            {
-                LOG(ERROR)<<code.to_string();
-            }
-            usleep(1000 * 200);
-        }
-        else
-        {
-            // std::cout<<" thread 111 "<<std::endl;
-            // 读取所有数据,更新本地并发布消息到UI
-            int plc_length_temp = PLC_REGION_NUM * PLC_SIGNAL_NUM_PER_REGION;
-            uint16_t plc_data_temp[plc_length_temp];
-            int rc = plc_communicator->m_plc_wrapper.read_registers(PLC_SIGNAL_BEGIN_OFFSET, plc_length_temp, plc_data_temp);
-            if(rc <0)
-            {
-                std::cout<<"find plc disconnected while read. try to reconnect."<<std::endl;
-                plc_communicator->mb_plc_is_connected = false;
-                continue;
-            }
-            else if (rc == 0)
-            {
-                plc_communicator->m_plc_mutex.lock();
-                int terminal_id_temp = 0;
-                for (size_t i = 0; i < plc_length_temp; i++)
-                {
-                    terminal_id_temp = i / PLC_SIGNAL_NUM_PER_REGION;
-                    plc_communicator->m_plc_data[i] = plc_data_temp[i];
-                    // 读取后检查是否存在差异, 存在则赋值。调用回调函数启动外部扫描
-                    if (i % PLC_SIGNAL_NUM_PER_REGION == PLC_LASER_START_ADDR && plc_data_temp[i] != plc_communicator->m_plc_region_status[terminal_id_temp].cmd)
-                    {
-                        plc_communicator->m_plc_region_status[terminal_id_temp].cmd = plc_data_temp[i];
-                        bool modified = false;
-                        // 判断指令存在
-                        // std::cout<<" thread 222 "<<std::endl;
-                        if (plc_data_temp[i] == 1)
-                        {
-                            // 判空
-                            if (plc_communicator->m_plc_callback != 0 && plc_communicator->mp_plc_owner != 0)
-                            {
-                                Error_manager ec = plc_communicator->m_plc_callback(terminal_id_temp + 1, plc_communicator->mp_plc_owner);
-                                if (ec.is_equal_error_manager(Error_manager(Error_code::SUCCESS)))
-                                {
-                                    plc_communicator->m_plc_region_status[terminal_id_temp].current_status = 1;
-                                    // 更新时间
-                                    plc_communicator->m_plc_region_status[terminal_id_temp].last_time_point = std::chrono::steady_clock::now();
-                                    modified = true;
-                                }
-                                else{
-                                    LOG(ERROR)<<ec.to_string();
-                                }
-                            }
-                        }
-                        // 指令清空,暂不恢复心跳
-                        else if (plc_data_temp[i] == 0)
-                        {
-                            // int status_temp = plc_communicator->m_plc_region_status[terminal_id_temp].current_status;
-                            // if (status_temp != 254 && status_temp != 255)
-                            // {
-                            //     plc_communicator->m_plc_region_status[terminal_id_temp].current_status = 255;
-                            //     // 更新时间
-                            //     plc_communicator->m_plc_region_status[terminal_id_temp].last_time_point = std::chrono::steady_clock::now();
-                            //     modified = true;
-                            // }
-                        }
-                        // 写入plc
-                        if (modified)
-                        {
-                            int address_temp = PLC_SIGNAL_BEGIN_OFFSET + PLC_SIGNAL_NUM_PER_REGION * terminal_id_temp + PLC_LASER_STATUS_ADDR;
-                            uint16_t value_temp = plc_communicator->m_plc_region_status[terminal_id_temp].current_status;
-                            int rc = plc_communicator->m_plc_wrapper.write_registers(address_temp, 1, &value_temp);
-                            if (rc != 0)
-                                plc_communicator->m_plc_current_error = Error_manager(Error_code::PLC_WRITE_FAILED, Error_level::MINOR_ERROR, "写入状态1失败");
-                        }
-                    }
-                }
-                plc_communicator->m_plc_mutex.unlock();
-            }
-            else
-            {
-                plc_communicator->m_plc_current_error = Error_manager(Error_code::PLC_READ_FAILED, Error_level::MINOR_ERROR, "循环读plc失败");
-            }
-            // std::cout<<" thread 333 "<<std::endl;
-
-            // 写入心跳或当前运行状态
-            for (size_t i = 0; i < PLC_REGION_NUM; i++)
-            {
-                int time_interval = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - plc_communicator->m_plc_region_status[i].last_time_point).count();
-                // 判断超时且非心跳,则转回心跳
-                bool modified = false;
-                if (time_interval > plc_communicator->m_plc_status_update_timeout && plc_communicator->m_plc_region_status[i].current_status < 5)
-                {
-                    plc_communicator->m_plc_region_status[i].current_status = 255;
-                    modified = true;
-                }
-                else
-                {
-                    // 状态切换后写入plc
-                    switch (plc_communicator->m_plc_region_status[i].current_status)
-                    {
-                    case 254:
-                        if (time_interval > 1000)
-                        {
-                            plc_communicator->m_plc_region_status[i].current_status = 255;
-                            modified = true;
-                        }
-                        break;
-                    case 255:
-                        if (time_interval > 1000)
-                        {
-                            plc_communicator->m_plc_region_status[i].current_status = 254;
-                            modified = true;
-                        }
-                        break;
-                    case 0:
-                        plc_communicator->m_plc_region_status[i].current_status = 254;
-                        modified = true;
-                        break;
-                    case 1:
-                        if (time_interval > 1000)
-                        {
-                            plc_communicator->m_plc_region_status[i].current_status = 2;
-                            modified = true;
-                        }
-                        break;
-                    case 2:
-                        break;
-                    case 3:
-                        if (time_interval > 3000)
-                        {
-                            plc_communicator->m_plc_region_status[i].current_status = 254;
-                            modified = true;
-                        }
-                        break;
-                    case 4:
-                        if (time_interval > 8000)
-                        {
-                            plc_communicator->m_plc_region_status[i].current_status = 254;
-                            modified = true;
-                        }
-                        break;
-                    case 5:
-                        break;
-                    default:
-                        break;
-                    }
-                }
-                
-                if (modified && plc_communicator->mb_plc_is_connected)
-                {
-                    plc_communicator->m_plc_mutex.lock();
-                    // std::cout<<" thread 444 "<<std::endl;
-                    // 更新时间
-                    plc_communicator->m_plc_region_status[i].last_time_point = std::chrono::steady_clock::now();
-                    // 写入plc
-                    int address_temp = PLC_SIGNAL_BEGIN_OFFSET + PLC_SIGNAL_NUM_PER_REGION * i + PLC_LASER_STATUS_ADDR;
-                    uint16_t value_temp = plc_communicator->m_plc_region_status[i].current_status;
-                    int rc = plc_communicator->m_plc_wrapper.write_registers(address_temp, 1, &value_temp);
-                    if (rc != 0)
-                        plc_communicator->m_plc_current_error = Error_manager(Error_code::PLC_WRITE_FAILED, Error_level::MINOR_ERROR, "写入当前状态失败");
-                    plc_communicator->m_plc_mutex.unlock();
-                    // std::cout<<" thread 555 "<<std::endl;
-                }
-            }
-        }
-
-        usleep(1000 * PLC_SLEEP_IN_MILLISECONDS);
-    }
-}

+ 0 - 135
plc/plc_communicator.h

@@ -1,135 +0,0 @@
-#ifndef PLC_COMMUNICATOR_HH
-#define PLC_COMMUNICATOR_HH
-
-#include <iostream>
-#include <string.h>
-#include <mutex>
-#include <vector>
-#include <thread>
-#include <unistd.h>
-#include <chrono>
-#include <cmath>
-// #include <fstream>
-// #include <stdint.h>
-// #include <unistd.h>
-// #include <sys/types.h>
-// #include <sys/stat.h>
-// #include <fcntl.h>
-
-// #include "../error.h"
-#include "../task/task_command_manager.h"
-#include "../error_code/error_code.h"
-#include "plc_task.h"
-#include "LibmodbusWrapper.h"
-#include "../tool/StdCondition.h"
-#include "../tool/MeasureTopicPublisher.h"
-#include "plc_module.pb.h"
-#include "plc_message.pb.h"
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/text_format.h>
-using google::protobuf::io::FileInputStream;
-using google::protobuf::io::FileOutputStream;
-using google::protobuf::io::ZeroCopyInputStream;
-using google::protobuf::io::CodedInputStream;
-using google::protobuf::io::ZeroCopyOutputStream;
-using google::protobuf::io::CodedOutputStream;
-using google::protobuf::Message;
-#include "glog/logging.h"
-
-#include <nnxx/message.h>
-#include <nnxx/message_control.h>
-#include <nnxx/socket.h>
-#include <nnxx/reqrep.h>
-//#include <nnxx/unittest.h>
-#include <nnxx/timeout.h>
-#include <nnxx/error.h>
-#include <cstring>
-#include <nnxx/message.h>
-
-const int PLC_SIGNAL_BEGIN_OFFSET=2;
-const int PLC_REGION_NUM=6;
-const int PLC_SIGNAL_NUM_PER_REGION=12;
-const int PLC_SLEEP_IN_MILLISECONDS=200;
-
-const int PLC_LASER_START_ADDR = 0;
-const int PLC_LASER_STATUS_ADDR = 1;
-const int PLC_LASER_X_ADDR = 2;
-const int PLC_LASER_Y_ADDR = 3;
-const int PLC_LASER_ANGLE_ADDR = 4;
-const int PLC_LASER_LENGTH_ADDR = 5;
-const int PLC_LASER_WIDTH_ADDR = 6;
-const int PLC_LASER_HEIGHT_ADDR = 7;
-const int PLC_LASER_CORRECTNESS_ADDR = 8;
-const int PLC_LASER_WHEELBASE_ADDR = 9;
-
-typedef Error_manager(*Command_Callback)(int terminal_id, void * p_owner);
-
-// plc通信类,modbus通信
-class Plc_Communicator
-{
-    
-public:
-    Plc_Communicator(plc_module::plc_connection_params connection_params);
-    ~Plc_Communicator();
-
-    // get set 方法
-    bool get_initialize_status();
-    bool get_connection();
-    Error_manager get_error();
-
-    // 设置plc检测到指令后外部回调函数
-    Error_manager set_plc_callback(Command_Callback callback, void * p_owner);
-    // 执行任务单
-    Error_manager execute_task(Task_Base* task);
-    // 获取实时数据
-    Error_manager get_plc_data(std::vector<uint16_t> &plc_data,int terminal_id=-1);
-    // 设置plc状态更新超时时间
-    Error_manager set_status_update_timeout(int millisecond);
-
-    struct plc_region_status{
-        std::chrono::steady_clock::time_point last_time_point;
-        int current_status;
-        int cmd;
-    };
-
-private:
-    // 读写线程函数
-    Error_manager ReadProtoParam(std::string path);
-    static void plc_update_thread(Plc_Communicator* plc_communicator);
-    static void plc_publish_message(Plc_Communicator* plc);
-    Error_manager write_result_to_plc(struct measure_result result);
-    // 连接函数
-    Error_manager connect();
-    Error_manager disconnect();
-
-private:
-    bool                mb_plc_is_connected;     // 指示plc连接状态
-    bool                mb_plc_initialized;      // 指示plc是否初始化
-    bool                mb_plc_is_updating;      // 指示plc线程在运行
-    void*               mp_plc_owner;            // 回调函数所有者句柄
-    Command_Callback    m_plc_callback;         // 回调函数
-
-    std::thread*        m_plc_message_thread;           // plc
-    std::thread*        m_plc_thread;           // plc更新线程句柄
-    StdCondition        m_plc_cond_exit;        // plc更新线程退出条件控制变量
-
-    std::mutex          m_plc_mutex;            // plc更新互斥锁,锁住与wrapper相关的所有操作
-    modbus::CLibmodbusWrapper   m_plc_wrapper;  // plc连接与读写封装实例
-
-    std::string         m_plc_ip_str;               // plc连接ip
-    int                 m_plc_port;             // plc连接端口
-    int                 m_plc_slave_id;         // plc连接id
-    int                 m_plc_status_update_timeout;    // plc状态更新超时时间
-
-    std::vector<uint16_t>   m_plc_data;         // 从plc获取的实时数据
-    Error_manager       m_plc_current_error;    // 当前plc出现的错误
-    // 当前系统状态,实时更新到plc。状态254-255每1秒互换,状态1从收到指令开始,紧接着改为状态2,
-    // 之后根据外部传入的task,决定写入3或4,默认3保留3秒,4持续保留直到新指令
-    plc_region_status   m_plc_region_status[PLC_REGION_NUM];   
-
-    // plc_module::plc_connection_params m_connection_params; // 连接参数
-};
-
-#endif // !PLC_COMMUNICATOR_HH

+ 0 - 432
plc/plc_message.pb.cc

@@ -1,432 +0,0 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: plc_message.proto
-
-#include "plc_message.pb.h"
-
-#include <algorithm>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/port.h>
-#include <google/protobuf/stubs/once.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/wire_format_lite_inl.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
-// @@protoc_insertion_point(includes)
-namespace plc_message {
-class plcMsgDefaultTypeInternal {
- public:
-  ::google::protobuf::internal::ExplicitlyConstructed<plcMsg>
-      _instance;
-} _plcMsg_default_instance_;
-}  // namespace plc_message
-namespace protobuf_plc_5fmessage_2eproto {
-void InitDefaultsplcMsgImpl() {
-  GOOGLE_PROTOBUF_VERIFY_VERSION;
-
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
-#else
-  ::google::protobuf::internal::InitProtobufDefaults();
-#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-  {
-    void* ptr = &::plc_message::_plcMsg_default_instance_;
-    new (ptr) ::plc_message::plcMsg();
-    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
-  }
-  ::plc_message::plcMsg::InitAsDefaultInstance();
-}
-
-void InitDefaultsplcMsg() {
-  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsplcMsgImpl);
-}
-
-::google::protobuf::Metadata file_level_metadata[1];
-const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1];
-
-const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_message::plcMsg, _has_bits_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_message::plcMsg, _internal_metadata_),
-  ~0u,  // no _extensions_
-  ~0u,  // no _oneof_case_
-  ~0u,  // no _weak_field_map_
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_message::plcMsg, plc_status_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_message::plcMsg, plc_values_),
-  0,
-  ~0u,
-};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
-  { 0, 7, sizeof(::plc_message::plcMsg)},
-};
-
-static ::google::protobuf::Message const * const file_default_instances[] = {
-  reinterpret_cast<const ::google::protobuf::Message*>(&::plc_message::_plcMsg_default_instance_),
-};
-
-void protobuf_AssignDescriptors() {
-  AddDescriptors();
-  ::google::protobuf::MessageFactory* factory = NULL;
-  AssignDescriptors(
-      "plc_message.proto", schemas, file_default_instances, TableStruct::offsets, factory,
-      file_level_metadata, file_level_enum_descriptors, NULL);
-}
-
-void protobuf_AssignDescriptorsOnce() {
-  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
-}
-
-void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
-void protobuf_RegisterTypes(const ::std::string&) {
-  protobuf_AssignDescriptorsOnce();
-  ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1);
-}
-
-void AddDescriptorsImpl() {
-  InitDefaults();
-  static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
-      "\n\021plc_message.proto\022\013plc_message\"H\n\006plcM"
-      "sg\022*\n\nplc_status\030\001 \001(\0162\026.plc_message.plc"
-      "Status\022\022\n\nplc_values\030\002 \003(\005*V\n\tplcStatus\022"
-      "\021\n\rePLCConnected\020\000\022\024\n\020ePLCDisconnected\020\001"
-      "\022\017\n\013ePLCRefused\020\002\022\017\n\013ePLCUnknown\020\003"
-  };
-  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 194);
-  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
-    "plc_message.proto", &protobuf_RegisterTypes);
-}
-
-void AddDescriptors() {
-  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
-}
-// Force AddDescriptors() to be called at dynamic initialization time.
-struct StaticDescriptorInitializer {
-  StaticDescriptorInitializer() {
-    AddDescriptors();
-  }
-} static_descriptor_initializer;
-}  // namespace protobuf_plc_5fmessage_2eproto
-namespace plc_message {
-const ::google::protobuf::EnumDescriptor* plcStatus_descriptor() {
-  protobuf_plc_5fmessage_2eproto::protobuf_AssignDescriptorsOnce();
-  return protobuf_plc_5fmessage_2eproto::file_level_enum_descriptors[0];
-}
-bool plcStatus_IsValid(int value) {
-  switch (value) {
-    case 0:
-    case 1:
-    case 2:
-    case 3:
-      return true;
-    default:
-      return false;
-  }
-}
-
-
-// ===================================================================
-
-void plcMsg::InitAsDefaultInstance() {
-}
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int plcMsg::kPlcStatusFieldNumber;
-const int plcMsg::kPlcValuesFieldNumber;
-#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-plcMsg::plcMsg()
-  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
-  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    ::protobuf_plc_5fmessage_2eproto::InitDefaultsplcMsg();
-  }
-  SharedCtor();
-  // @@protoc_insertion_point(constructor:plc_message.plcMsg)
-}
-plcMsg::plcMsg(const plcMsg& from)
-  : ::google::protobuf::Message(),
-      _internal_metadata_(NULL),
-      _has_bits_(from._has_bits_),
-      _cached_size_(0),
-      plc_values_(from.plc_values_) {
-  _internal_metadata_.MergeFrom(from._internal_metadata_);
-  plc_status_ = from.plc_status_;
-  // @@protoc_insertion_point(copy_constructor:plc_message.plcMsg)
-}
-
-void plcMsg::SharedCtor() {
-  _cached_size_ = 0;
-  plc_status_ = 0;
-}
-
-plcMsg::~plcMsg() {
-  // @@protoc_insertion_point(destructor:plc_message.plcMsg)
-  SharedDtor();
-}
-
-void plcMsg::SharedDtor() {
-}
-
-void plcMsg::SetCachedSize(int size) const {
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* plcMsg::descriptor() {
-  ::protobuf_plc_5fmessage_2eproto::protobuf_AssignDescriptorsOnce();
-  return ::protobuf_plc_5fmessage_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
-}
-
-const plcMsg& plcMsg::default_instance() {
-  ::protobuf_plc_5fmessage_2eproto::InitDefaultsplcMsg();
-  return *internal_default_instance();
-}
-
-plcMsg* plcMsg::New(::google::protobuf::Arena* arena) const {
-  plcMsg* n = new plcMsg;
-  if (arena != NULL) {
-    arena->Own(n);
-  }
-  return n;
-}
-
-void plcMsg::Clear() {
-// @@protoc_insertion_point(message_clear_start:plc_message.plcMsg)
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  // Prevent compiler warnings about cached_has_bits being unused
-  (void) cached_has_bits;
-
-  plc_values_.Clear();
-  plc_status_ = 0;
-  _has_bits_.Clear();
-  _internal_metadata_.Clear();
-}
-
-bool plcMsg::MergePartialFromCodedStream(
-    ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
-  ::google::protobuf::uint32 tag;
-  // @@protoc_insertion_point(parse_start:plc_message.plcMsg)
-  for (;;) {
-    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
-    tag = p.first;
-    if (!p.second) goto handle_unusual;
-    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
-      // optional .plc_message.plcStatus plc_status = 1;
-      case 1: {
-        if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
-          int value;
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
-                 input, &value)));
-          if (::plc_message::plcStatus_IsValid(value)) {
-            set_plc_status(static_cast< ::plc_message::plcStatus >(value));
-          } else {
-            mutable_unknown_fields()->AddVarint(
-                1, static_cast< ::google::protobuf::uint64>(value));
-          }
-        } else {
-          goto handle_unusual;
-        }
-        break;
-      }
-
-      // repeated int32 plc_values = 2;
-      case 2: {
-        if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
-          DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 1, 16u, input, this->mutable_plc_values())));
-        } else if (
-            static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, this->mutable_plc_values())));
-        } else {
-          goto handle_unusual;
-        }
-        break;
-      }
-
-      default: {
-      handle_unusual:
-        if (tag == 0) {
-          goto success;
-        }
-        DO_(::google::protobuf::internal::WireFormat::SkipField(
-              input, tag, _internal_metadata_.mutable_unknown_fields()));
-        break;
-      }
-    }
-  }
-success:
-  // @@protoc_insertion_point(parse_success:plc_message.plcMsg)
-  return true;
-failure:
-  // @@protoc_insertion_point(parse_failure:plc_message.plcMsg)
-  return false;
-#undef DO_
-}
-
-void plcMsg::SerializeWithCachedSizes(
-    ::google::protobuf::io::CodedOutputStream* output) const {
-  // @@protoc_insertion_point(serialize_start:plc_message.plcMsg)
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  (void) cached_has_bits;
-
-  cached_has_bits = _has_bits_[0];
-  // optional .plc_message.plcStatus plc_status = 1;
-  if (cached_has_bits & 0x00000001u) {
-    ::google::protobuf::internal::WireFormatLite::WriteEnum(
-      1, this->plc_status(), output);
-  }
-
-  // repeated int32 plc_values = 2;
-  for (int i = 0, n = this->plc_values_size(); i < n; i++) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(
-      2, this->plc_values(i), output);
-  }
-
-  if (_internal_metadata_.have_unknown_fields()) {
-    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
-        _internal_metadata_.unknown_fields(), output);
-  }
-  // @@protoc_insertion_point(serialize_end:plc_message.plcMsg)
-}
-
-::google::protobuf::uint8* plcMsg::InternalSerializeWithCachedSizesToArray(
-    bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
-  // @@protoc_insertion_point(serialize_to_array_start:plc_message.plcMsg)
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  (void) cached_has_bits;
-
-  cached_has_bits = _has_bits_[0];
-  // optional .plc_message.plcStatus plc_status = 1;
-  if (cached_has_bits & 0x00000001u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
-      1, this->plc_status(), target);
-  }
-
-  // repeated int32 plc_values = 2;
-  target = ::google::protobuf::internal::WireFormatLite::
-    WriteInt32ToArray(2, this->plc_values_, target);
-
-  if (_internal_metadata_.have_unknown_fields()) {
-    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
-        _internal_metadata_.unknown_fields(), target);
-  }
-  // @@protoc_insertion_point(serialize_to_array_end:plc_message.plcMsg)
-  return target;
-}
-
-size_t plcMsg::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:plc_message.plcMsg)
-  size_t total_size = 0;
-
-  if (_internal_metadata_.have_unknown_fields()) {
-    total_size +=
-      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
-        _internal_metadata_.unknown_fields());
-  }
-  // repeated int32 plc_values = 2;
-  {
-    size_t data_size = ::google::protobuf::internal::WireFormatLite::
-      Int32Size(this->plc_values_);
-    total_size += 1 *
-                  ::google::protobuf::internal::FromIntSize(this->plc_values_size());
-    total_size += data_size;
-  }
-
-  // optional .plc_message.plcStatus plc_status = 1;
-  if (has_plc_status()) {
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::EnumSize(this->plc_status());
-  }
-
-  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = cached_size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-  return total_size;
-}
-
-void plcMsg::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:plc_message.plcMsg)
-  GOOGLE_DCHECK_NE(&from, this);
-  const plcMsg* source =
-      ::google::protobuf::internal::DynamicCastToGenerated<const plcMsg>(
-          &from);
-  if (source == NULL) {
-  // @@protoc_insertion_point(generalized_merge_from_cast_fail:plc_message.plcMsg)
-    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
-  } else {
-  // @@protoc_insertion_point(generalized_merge_from_cast_success:plc_message.plcMsg)
-    MergeFrom(*source);
-  }
-}
-
-void plcMsg::MergeFrom(const plcMsg& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:plc_message.plcMsg)
-  GOOGLE_DCHECK_NE(&from, this);
-  _internal_metadata_.MergeFrom(from._internal_metadata_);
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  (void) cached_has_bits;
-
-  plc_values_.MergeFrom(from.plc_values_);
-  if (from.has_plc_status()) {
-    set_plc_status(from.plc_status());
-  }
-}
-
-void plcMsg::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:plc_message.plcMsg)
-  if (&from == this) return;
-  Clear();
-  MergeFrom(from);
-}
-
-void plcMsg::CopyFrom(const plcMsg& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:plc_message.plcMsg)
-  if (&from == this) return;
-  Clear();
-  MergeFrom(from);
-}
-
-bool plcMsg::IsInitialized() const {
-  return true;
-}
-
-void plcMsg::Swap(plcMsg* other) {
-  if (other == this) return;
-  InternalSwap(other);
-}
-void plcMsg::InternalSwap(plcMsg* other) {
-  using std::swap;
-  plc_values_.InternalSwap(&other->plc_values_);
-  swap(plc_status_, other->plc_status_);
-  swap(_has_bits_[0], other->_has_bits_[0]);
-  _internal_metadata_.Swap(&other->_internal_metadata_);
-  swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata plcMsg::GetMetadata() const {
-  protobuf_plc_5fmessage_2eproto::protobuf_AssignDescriptorsOnce();
-  return ::protobuf_plc_5fmessage_2eproto::file_level_metadata[kIndexInFileMessages];
-}
-
-
-// @@protoc_insertion_point(namespace_scope)
-}  // namespace plc_message
-
-// @@protoc_insertion_point(global_scope)

+ 0 - 291
plc/plc_message.pb.h

@@ -1,291 +0,0 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: plc_message.proto
-
-#ifndef PROTOBUF_plc_5fmessage_2eproto__INCLUDED
-#define PROTOBUF_plc_5fmessage_2eproto__INCLUDED
-
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-
-#if GOOGLE_PROTOBUF_VERSION < 3005000
-#error This file was generated by a newer version of protoc which is
-#error incompatible with your Protocol Buffer headers.  Please update
-#error your headers.
-#endif
-#if 3005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
-#error This file was generated by an older version of protoc which is
-#error incompatible with your Protocol Buffer headers.  Please
-#error regenerate this file with a newer version of protoc.
-#endif
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>  // IWYU pragma: export
-#include <google/protobuf/extension_set.h>  // IWYU pragma: export
-#include <google/protobuf/generated_enum_reflection.h>
-#include <google/protobuf/unknown_field_set.h>
-// @@protoc_insertion_point(includes)
-
-namespace protobuf_plc_5fmessage_2eproto {
-// Internal implementation detail -- do not use these members.
-struct TableStruct {
-  static const ::google::protobuf::internal::ParseTableField entries[];
-  static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
-  static const ::google::protobuf::internal::ParseTable schema[1];
-  static const ::google::protobuf::internal::FieldMetadata field_metadata[];
-  static const ::google::protobuf::internal::SerializationTable serialization_table[];
-  static const ::google::protobuf::uint32 offsets[];
-};
-void AddDescriptors();
-void InitDefaultsplcMsgImpl();
-void InitDefaultsplcMsg();
-inline void InitDefaults() {
-  InitDefaultsplcMsg();
-}
-}  // namespace protobuf_plc_5fmessage_2eproto
-namespace plc_message {
-class plcMsg;
-class plcMsgDefaultTypeInternal;
-extern plcMsgDefaultTypeInternal _plcMsg_default_instance_;
-}  // namespace plc_message
-namespace plc_message {
-
-enum plcStatus {
-  ePLCConnected = 0,
-  ePLCDisconnected = 1,
-  ePLCRefused = 2,
-  ePLCUnknown = 3
-};
-bool plcStatus_IsValid(int value);
-const plcStatus plcStatus_MIN = ePLCConnected;
-const plcStatus plcStatus_MAX = ePLCUnknown;
-const int plcStatus_ARRAYSIZE = plcStatus_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* plcStatus_descriptor();
-inline const ::std::string& plcStatus_Name(plcStatus value) {
-  return ::google::protobuf::internal::NameOfEnum(
-    plcStatus_descriptor(), value);
-}
-inline bool plcStatus_Parse(
-    const ::std::string& name, plcStatus* value) {
-  return ::google::protobuf::internal::ParseNamedEnum<plcStatus>(
-    plcStatus_descriptor(), name, value);
-}
-// ===================================================================
-
-class plcMsg : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:plc_message.plcMsg) */ {
- public:
-  plcMsg();
-  virtual ~plcMsg();
-
-  plcMsg(const plcMsg& from);
-
-  inline plcMsg& operator=(const plcMsg& from) {
-    CopyFrom(from);
-    return *this;
-  }
-  #if LANG_CXX11
-  plcMsg(plcMsg&& from) noexcept
-    : plcMsg() {
-    *this = ::std::move(from);
-  }
-
-  inline plcMsg& operator=(plcMsg&& from) noexcept {
-    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
-      if (this != &from) InternalSwap(&from);
-    } else {
-      CopyFrom(from);
-    }
-    return *this;
-  }
-  #endif
-  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
-    return _internal_metadata_.unknown_fields();
-  }
-  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
-    return _internal_metadata_.mutable_unknown_fields();
-  }
-
-  static const ::google::protobuf::Descriptor* descriptor();
-  static const plcMsg& default_instance();
-
-  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
-  static inline const plcMsg* internal_default_instance() {
-    return reinterpret_cast<const plcMsg*>(
-               &_plcMsg_default_instance_);
-  }
-  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
-    0;
-
-  void Swap(plcMsg* other);
-  friend void swap(plcMsg& a, plcMsg& b) {
-    a.Swap(&b);
-  }
-
-  // implements Message ----------------------------------------------
-
-  inline plcMsg* New() const PROTOBUF_FINAL { return New(NULL); }
-
-  plcMsg* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
-  void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
-  void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
-  void CopyFrom(const plcMsg& from);
-  void MergeFrom(const plcMsg& from);
-  void Clear() PROTOBUF_FINAL;
-  bool IsInitialized() const PROTOBUF_FINAL;
-
-  size_t ByteSizeLong() const PROTOBUF_FINAL;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
-  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
-      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
-  int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const PROTOBUF_FINAL;
-  void InternalSwap(plcMsg* other);
-  private:
-  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
-    return NULL;
-  }
-  inline void* MaybeArenaPtr() const {
-    return NULL;
-  }
-  public:
-
-  ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // repeated int32 plc_values = 2;
-  int plc_values_size() const;
-  void clear_plc_values();
-  static const int kPlcValuesFieldNumber = 2;
-  ::google::protobuf::int32 plc_values(int index) const;
-  void set_plc_values(int index, ::google::protobuf::int32 value);
-  void add_plc_values(::google::protobuf::int32 value);
-  const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-      plc_values() const;
-  ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-      mutable_plc_values();
-
-  // optional .plc_message.plcStatus plc_status = 1;
-  bool has_plc_status() const;
-  void clear_plc_status();
-  static const int kPlcStatusFieldNumber = 1;
-  ::plc_message::plcStatus plc_status() const;
-  void set_plc_status(::plc_message::plcStatus value);
-
-  // @@protoc_insertion_point(class_scope:plc_message.plcMsg)
- private:
-  void set_has_plc_status();
-  void clear_has_plc_status();
-
-  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
-  ::google::protobuf::internal::HasBits<1> _has_bits_;
-  mutable int _cached_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::int32 > plc_values_;
-  int plc_status_;
-  friend struct ::protobuf_plc_5fmessage_2eproto::TableStruct;
-  friend void ::protobuf_plc_5fmessage_2eproto::InitDefaultsplcMsgImpl();
-};
-// ===================================================================
-
-
-// ===================================================================
-
-#ifdef __GNUC__
-  #pragma GCC diagnostic push
-  #pragma GCC diagnostic ignored "-Wstrict-aliasing"
-#endif  // __GNUC__
-// plcMsg
-
-// optional .plc_message.plcStatus plc_status = 1;
-inline bool plcMsg::has_plc_status() const {
-  return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void plcMsg::set_has_plc_status() {
-  _has_bits_[0] |= 0x00000001u;
-}
-inline void plcMsg::clear_has_plc_status() {
-  _has_bits_[0] &= ~0x00000001u;
-}
-inline void plcMsg::clear_plc_status() {
-  plc_status_ = 0;
-  clear_has_plc_status();
-}
-inline ::plc_message::plcStatus plcMsg::plc_status() const {
-  // @@protoc_insertion_point(field_get:plc_message.plcMsg.plc_status)
-  return static_cast< ::plc_message::plcStatus >(plc_status_);
-}
-inline void plcMsg::set_plc_status(::plc_message::plcStatus value) {
-  assert(::plc_message::plcStatus_IsValid(value));
-  set_has_plc_status();
-  plc_status_ = value;
-  // @@protoc_insertion_point(field_set:plc_message.plcMsg.plc_status)
-}
-
-// repeated int32 plc_values = 2;
-inline int plcMsg::plc_values_size() const {
-  return plc_values_.size();
-}
-inline void plcMsg::clear_plc_values() {
-  plc_values_.Clear();
-}
-inline ::google::protobuf::int32 plcMsg::plc_values(int index) const {
-  // @@protoc_insertion_point(field_get:plc_message.plcMsg.plc_values)
-  return plc_values_.Get(index);
-}
-inline void plcMsg::set_plc_values(int index, ::google::protobuf::int32 value) {
-  plc_values_.Set(index, value);
-  // @@protoc_insertion_point(field_set:plc_message.plcMsg.plc_values)
-}
-inline void plcMsg::add_plc_values(::google::protobuf::int32 value) {
-  plc_values_.Add(value);
-  // @@protoc_insertion_point(field_add:plc_message.plcMsg.plc_values)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-plcMsg::plc_values() const {
-  // @@protoc_insertion_point(field_list:plc_message.plcMsg.plc_values)
-  return plc_values_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-plcMsg::mutable_plc_values() {
-  // @@protoc_insertion_point(field_mutable_list:plc_message.plcMsg.plc_values)
-  return &plc_values_;
-}
-
-#ifdef __GNUC__
-  #pragma GCC diagnostic pop
-#endif  // __GNUC__
-
-// @@protoc_insertion_point(namespace_scope)
-
-}  // namespace plc_message
-
-namespace google {
-namespace protobuf {
-
-template <> struct is_proto_enum< ::plc_message::plcStatus> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::plc_message::plcStatus>() {
-  return ::plc_message::plcStatus_descriptor();
-}
-
-}  // namespace protobuf
-}  // namespace google
-
-// @@protoc_insertion_point(global_scope)
-
-#endif  // PROTOBUF_plc_5fmessage_2eproto__INCLUDED

+ 0 - 16
plc/plc_message.proto

@@ -1,16 +0,0 @@
-syntax = "proto2";
-package plc_message;
-
-enum plcStatus
-{
-    ePLCConnected=0;
-    ePLCDisconnected=1;
-    ePLCRefused=2;
-    ePLCUnknown=3;
-}
-
-message plcMsg
-{
-    optional plcStatus plc_status=1;
-    repeated int32 plc_values=2;
-}

+ 0 - 146
plc/plc_modbus_uml.wsd

@@ -1,146 +0,0 @@
-@startuml
-
-title PLC模块
-
-note top of CLibmodbusWrapper
-    ×PLC底层封装类,非线程安全
-end note
-
-class CLibmodbusWrapper
-{
-    +CLibmodbusWrapper();
-    +virtual ~CLibmodbusWrapper();
-    +int initialize(const char *ip, int port, int slave_id);
-    +void deinitialize();
-    +int read_registers(int addr, int nb, uint16_t *dest);
-    +int write_registers(int addr, int nb, uint16_t *dest);
-    +int read_register(int addr, uint16_t *dest);
-    +int write_register(int addr, uint16_t *dest);
-    +inline bool is_connected() { return (0 == _ctx) ? false : true; };
-    +inline std::string getIP() { return _ip; };
-    +inline int getPort() { return _port; };
-    +inline int getSlave() { return _slave_id; };
-
-    -modbus_t* _ctx;
-    -std::string _ip;
-    -int _port;
-    -int _slave_id;
-}
-
-note right of Plc_Communicator
-    ×PLC通信类,核心模块,线程安全,包括:
-    ×根据plc信号调用回调进行测量
-    *将测量系统实时状态与测量结果写入plc
-end note
-
-class Plc_Communicator
-{
-    +Plc_Communicator(plc_module::plc_connection_params connection_params);
-    +~Plc_Communicator();
-    +bool get_initialize_status();// 获取初始化状态
-    +bool get_connection();// 获取连接状态
-    +Error_manager get_error();// 获取历史错误信息
-    +Error_manager set_plc_callback(Command_Callback callback, void * p_owner);// 设置plc检测到指令后外部回调函数
-    +Error_manager execute_task(Task_Base* task);// 执行任务单
-    +Error_manager get_plc_data(std::vector<uint16_t> &plc_data,int terminal_id=-1);// 获取实时数据
-    +Error_manager set_status_update_timeout(int millisecond);// 设置plc状态更新超时时间
-    +struct plc_region_status // 包含时间戳、指令信息、实时状态
-    {
-        std::chrono::steady_clock::time_point last_time_point;
-        int current_status;
-        int cmd;
-    };
-    -Error_manager ReadProtoParam(std::string path);// 读配置函数
-    -static void plc_update_thread(Plc_Communicator* plc_communicator);// 读PLC各雷达模块信息线程函数
-    -static void plc_publish_message(Plc_Communicator* plc);// 发布读取结果到UI线程函数
-    -Error_manager write_result_to_plc(struct measure_result result);// 写测量数据到PLC函数
-    -Error_manager connect();// 连接函数
-    -Error_manager disconnect();// 断开连接
-
-    -bool mb_plc_is_connected;// 指示plc连接状态
-    -bool mb_plc_initialized; // 指示plc是否初始化
-    -bool mb_plc_is_updating; // 指示plc线程在运行
-    -void* mp_plc_owner;  // 回调函数所有者句柄
-    -Command_Callback    m_plc_callback; // 回调函数
-    -std::thread*   m_plc_message_thread; // plc
-    -std::thread*   m_plc_thread; // plc更新线程句柄
-    -StdCondition   m_plc_cond_exit; // plc更新线程退出条件控制变量
-    -std::mutexm_plc_mutex; // plc更新互斥锁,锁住与wrapper相关的所有操作
-    -modbus::CLibmodbusWrapper  m_plc_wrapper; // plc连接与读写封装实例
-    -std::string    m_plc_ip_str;// plc连接ip
-    -int  m_plc_port; // plc连接端口
-    -int  m_plc_slave_id; // plc连接id
-    -int  m_plc_status_update_timeout; // plc状态更新超时时间
-    -std::vector<uint16_t>   m_plc_data; // 从plc获取的实时数据
-    -Error_manager       m_plc_current_error; // 当前plc出现的错误
-    // 当前系统状态,实时更新到plc。状态254-255每1秒互换,状态1从收到指令开始,紧接着改为状态2,
-    // 之后根据外部传入的task,决定写入3或4,默认3保留3秒,4持续保留直到新指令
-    -plc_region_status   m_plc_region_status[PLC_REGION_NUM];
-}
-
-class plc_message::plcMsg << (M,#00FF77) message>>
-{
-    plcStatus plc_status=1;
-    int32 plc_values=2;
-}
-
-class plc_module::plc_connection_params << (M,#00FF77) message>>
-{
-    string ip=1;
-    int32 port=2;
-    int32 slave_id=3;
-}
-
-class plc_module::Plc_msg << (M,#00FF77) message>>
-{
-    PLC_STATUS status=1;
-    int32 plc_values=2;
-}
-
-class Plc_Task
-{
-    +virtual Error_manager init(); 
-    +Plc_Task();
-    +~Plc_Task();
-    +Error_manager set_result(struct measure_result result);// 将测量结果存入该任务单
-    +Error_manager get_result(struct measure_result &result);// 将测量结果传出
-    +bool get_result_set_flag();// 获取测量结果是否已存入该任务单的指标
-
-    -struct measure_result m_measure_result;// 存放测量结果
-    -bool mb_result_set_flag;// 已获取结果
-    -struct measure_result
-    {
-        int terminal_id;
-        float x;
-        float y;
-        float angle;
-        float length;
-        float width;
-        float height;
-        float wheel_base;
-        bool correctness;
-    };
-}
-
-class Task_Base
-{
-    +Task_Base();
-    +~Task_Base();
-    +virtual Error_manager init();//初始化任务单,初始任务单类型为 UNKONW_TASK
-    +Error_manager update_statu(Task_statu task_statu,std::string statu_information="");更新任务单; task_statu: 任务状态; statu_information:状态说明
-    +Task_type   get_task_type();//获取任务类型
-    +Task_statu  get_statu();//获取任务单状态
-    +std::string get_statu_information();//获取状态说明
-    -Task_type    m_task_type;
-    -Task_statu   m_task_statu;//任务状态
-    -std::string  m_task_statu_information;   //任务状态说明
-}
-
-Task_Base <|-- Plc_Task
-Plc_Communicator <-- Plc_Task
-Plc_Communicator <-- plc_message::plcMsg
-Plc_Communicator <-- plc_module::plc_connection_params
-Plc_Communicator <-- plc_module::Plc_msg
-Plc_Communicator <-- CLibmodbusWrapper
-
-@enduml

+ 0 - 851
plc/plc_module.pb.cc

@@ -1,851 +0,0 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: plc_module.proto
-
-#include "plc_module.pb.h"
-
-#include <algorithm>
-
-#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/stubs/port.h>
-#include <google/protobuf/stubs/once.h>
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/wire_format_lite_inl.h>
-#include <google/protobuf/descriptor.h>
-#include <google/protobuf/generated_message_reflection.h>
-#include <google/protobuf/reflection_ops.h>
-#include <google/protobuf/wire_format.h>
-// This is a temporary google only hack
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-#include "third_party/protobuf/version.h"
-#endif
-// @@protoc_insertion_point(includes)
-namespace plc_module {
-class plc_connection_paramsDefaultTypeInternal {
- public:
-  ::google::protobuf::internal::ExplicitlyConstructed<plc_connection_params>
-      _instance;
-} _plc_connection_params_default_instance_;
-class Plc_msgDefaultTypeInternal {
- public:
-  ::google::protobuf::internal::ExplicitlyConstructed<Plc_msg>
-      _instance;
-} _Plc_msg_default_instance_;
-}  // namespace plc_module
-namespace protobuf_plc_5fmodule_2eproto {
-void InitDefaultsplc_connection_paramsImpl() {
-  GOOGLE_PROTOBUF_VERIFY_VERSION;
-
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
-#else
-  ::google::protobuf::internal::InitProtobufDefaults();
-#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-  {
-    void* ptr = &::plc_module::_plc_connection_params_default_instance_;
-    new (ptr) ::plc_module::plc_connection_params();
-    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
-  }
-  ::plc_module::plc_connection_params::InitAsDefaultInstance();
-}
-
-void InitDefaultsplc_connection_params() {
-  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsplc_connection_paramsImpl);
-}
-
-void InitDefaultsPlc_msgImpl() {
-  GOOGLE_PROTOBUF_VERIFY_VERSION;
-
-#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
-#else
-  ::google::protobuf::internal::InitProtobufDefaults();
-#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
-  {
-    void* ptr = &::plc_module::_Plc_msg_default_instance_;
-    new (ptr) ::plc_module::Plc_msg();
-    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
-  }
-  ::plc_module::Plc_msg::InitAsDefaultInstance();
-}
-
-void InitDefaultsPlc_msg() {
-  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsPlc_msgImpl);
-}
-
-::google::protobuf::Metadata file_level_metadata[2];
-const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors[1];
-
-const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_module::plc_connection_params, _has_bits_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_module::plc_connection_params, _internal_metadata_),
-  ~0u,  // no _extensions_
-  ~0u,  // no _oneof_case_
-  ~0u,  // no _weak_field_map_
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_module::plc_connection_params, ip_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_module::plc_connection_params, port_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_module::plc_connection_params, slave_id_),
-  0,
-  1,
-  2,
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_module::Plc_msg, _has_bits_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_module::Plc_msg, _internal_metadata_),
-  ~0u,  // no _extensions_
-  ~0u,  // no _oneof_case_
-  ~0u,  // no _weak_field_map_
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_module::Plc_msg, status_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::plc_module::Plc_msg, plc_values_),
-  0,
-  ~0u,
-};
-static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
-  { 0, 8, sizeof(::plc_module::plc_connection_params)},
-  { 11, 18, sizeof(::plc_module::Plc_msg)},
-};
-
-static ::google::protobuf::Message const * const file_default_instances[] = {
-  reinterpret_cast<const ::google::protobuf::Message*>(&::plc_module::_plc_connection_params_default_instance_),
-  reinterpret_cast<const ::google::protobuf::Message*>(&::plc_module::_Plc_msg_default_instance_),
-};
-
-void protobuf_AssignDescriptors() {
-  AddDescriptors();
-  ::google::protobuf::MessageFactory* factory = NULL;
-  AssignDescriptors(
-      "plc_module.proto", schemas, file_default_instances, TableStruct::offsets, factory,
-      file_level_metadata, file_level_enum_descriptors, NULL);
-}
-
-void protobuf_AssignDescriptorsOnce() {
-  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
-}
-
-void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
-void protobuf_RegisterTypes(const ::std::string&) {
-  protobuf_AssignDescriptorsOnce();
-  ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 2);
-}
-
-void AddDescriptorsImpl() {
-  InitDefaults();
-  static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
-      "\n\020plc_module.proto\022\nplc_module\"C\n\025plc_co"
-      "nnection_params\022\n\n\002ip\030\001 \002(\t\022\014\n\004port\030\002 \002("
-      "\005\022\020\n\010slave_id\030\003 \002(\005\"E\n\007Plc_msg\022&\n\006status"
-      "\030\001 \001(\0162\026.plc_module.PLC_STATUS\022\022\n\nplc_va"
-      "lues\030\002 \003(\005*W\n\nPLC_STATUS\022\021\n\rePLCConnecte"
-      "d\020\000\022\024\n\020ePLCDisconnected\020\001\022\017\n\013ePLCRefused"
-      "\020\002\022\017\n\013ePLCUnknown\020\003"
-  };
-  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 259);
-  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
-    "plc_module.proto", &protobuf_RegisterTypes);
-}
-
-void AddDescriptors() {
-  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
-  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
-}
-// Force AddDescriptors() to be called at dynamic initialization time.
-struct StaticDescriptorInitializer {
-  StaticDescriptorInitializer() {
-    AddDescriptors();
-  }
-} static_descriptor_initializer;
-}  // namespace protobuf_plc_5fmodule_2eproto
-namespace plc_module {
-const ::google::protobuf::EnumDescriptor* PLC_STATUS_descriptor() {
-  protobuf_plc_5fmodule_2eproto::protobuf_AssignDescriptorsOnce();
-  return protobuf_plc_5fmodule_2eproto::file_level_enum_descriptors[0];
-}
-bool PLC_STATUS_IsValid(int value) {
-  switch (value) {
-    case 0:
-    case 1:
-    case 2:
-    case 3:
-      return true;
-    default:
-      return false;
-  }
-}
-
-
-// ===================================================================
-
-void plc_connection_params::InitAsDefaultInstance() {
-}
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int plc_connection_params::kIpFieldNumber;
-const int plc_connection_params::kPortFieldNumber;
-const int plc_connection_params::kSlaveIdFieldNumber;
-#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-plc_connection_params::plc_connection_params()
-  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
-  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    ::protobuf_plc_5fmodule_2eproto::InitDefaultsplc_connection_params();
-  }
-  SharedCtor();
-  // @@protoc_insertion_point(constructor:plc_module.plc_connection_params)
-}
-plc_connection_params::plc_connection_params(const plc_connection_params& from)
-  : ::google::protobuf::Message(),
-      _internal_metadata_(NULL),
-      _has_bits_(from._has_bits_),
-      _cached_size_(0) {
-  _internal_metadata_.MergeFrom(from._internal_metadata_);
-  ip_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-  if (from.has_ip()) {
-    ip_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.ip_);
-  }
-  ::memcpy(&port_, &from.port_,
-    static_cast<size_t>(reinterpret_cast<char*>(&slave_id_) -
-    reinterpret_cast<char*>(&port_)) + sizeof(slave_id_));
-  // @@protoc_insertion_point(copy_constructor:plc_module.plc_connection_params)
-}
-
-void plc_connection_params::SharedCtor() {
-  _cached_size_ = 0;
-  ip_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-  ::memset(&port_, 0, static_cast<size_t>(
-      reinterpret_cast<char*>(&slave_id_) -
-      reinterpret_cast<char*>(&port_)) + sizeof(slave_id_));
-}
-
-plc_connection_params::~plc_connection_params() {
-  // @@protoc_insertion_point(destructor:plc_module.plc_connection_params)
-  SharedDtor();
-}
-
-void plc_connection_params::SharedDtor() {
-  ip_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-
-void plc_connection_params::SetCachedSize(int size) const {
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* plc_connection_params::descriptor() {
-  ::protobuf_plc_5fmodule_2eproto::protobuf_AssignDescriptorsOnce();
-  return ::protobuf_plc_5fmodule_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
-}
-
-const plc_connection_params& plc_connection_params::default_instance() {
-  ::protobuf_plc_5fmodule_2eproto::InitDefaultsplc_connection_params();
-  return *internal_default_instance();
-}
-
-plc_connection_params* plc_connection_params::New(::google::protobuf::Arena* arena) const {
-  plc_connection_params* n = new plc_connection_params;
-  if (arena != NULL) {
-    arena->Own(n);
-  }
-  return n;
-}
-
-void plc_connection_params::Clear() {
-// @@protoc_insertion_point(message_clear_start:plc_module.plc_connection_params)
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  // Prevent compiler warnings about cached_has_bits being unused
-  (void) cached_has_bits;
-
-  cached_has_bits = _has_bits_[0];
-  if (cached_has_bits & 0x00000001u) {
-    GOOGLE_DCHECK(!ip_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
-    (*ip_.UnsafeRawStringPointer())->clear();
-  }
-  if (cached_has_bits & 6u) {
-    ::memset(&port_, 0, static_cast<size_t>(
-        reinterpret_cast<char*>(&slave_id_) -
-        reinterpret_cast<char*>(&port_)) + sizeof(slave_id_));
-  }
-  _has_bits_.Clear();
-  _internal_metadata_.Clear();
-}
-
-bool plc_connection_params::MergePartialFromCodedStream(
-    ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
-  ::google::protobuf::uint32 tag;
-  // @@protoc_insertion_point(parse_start:plc_module.plc_connection_params)
-  for (;;) {
-    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
-    tag = p.first;
-    if (!p.second) goto handle_unusual;
-    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
-      // required string ip = 1;
-      case 1: {
-        if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
-          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
-                input, this->mutable_ip()));
-          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
-            this->ip().data(), static_cast<int>(this->ip().length()),
-            ::google::protobuf::internal::WireFormat::PARSE,
-            "plc_module.plc_connection_params.ip");
-        } else {
-          goto handle_unusual;
-        }
-        break;
-      }
-
-      // required int32 port = 2;
-      case 2: {
-        if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
-          set_has_port();
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &port_)));
-        } else {
-          goto handle_unusual;
-        }
-        break;
-      }
-
-      // required int32 slave_id = 3;
-      case 3: {
-        if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) {
-          set_has_slave_id();
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &slave_id_)));
-        } else {
-          goto handle_unusual;
-        }
-        break;
-      }
-
-      default: {
-      handle_unusual:
-        if (tag == 0) {
-          goto success;
-        }
-        DO_(::google::protobuf::internal::WireFormat::SkipField(
-              input, tag, _internal_metadata_.mutable_unknown_fields()));
-        break;
-      }
-    }
-  }
-success:
-  // @@protoc_insertion_point(parse_success:plc_module.plc_connection_params)
-  return true;
-failure:
-  // @@protoc_insertion_point(parse_failure:plc_module.plc_connection_params)
-  return false;
-#undef DO_
-}
-
-void plc_connection_params::SerializeWithCachedSizes(
-    ::google::protobuf::io::CodedOutputStream* output) const {
-  // @@protoc_insertion_point(serialize_start:plc_module.plc_connection_params)
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  (void) cached_has_bits;
-
-  cached_has_bits = _has_bits_[0];
-  // required string ip = 1;
-  if (cached_has_bits & 0x00000001u) {
-    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
-      this->ip().data(), static_cast<int>(this->ip().length()),
-      ::google::protobuf::internal::WireFormat::SERIALIZE,
-      "plc_module.plc_connection_params.ip");
-    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
-      1, this->ip(), output);
-  }
-
-  // required int32 port = 2;
-  if (cached_has_bits & 0x00000002u) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->port(), output);
-  }
-
-  // required int32 slave_id = 3;
-  if (cached_has_bits & 0x00000004u) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->slave_id(), output);
-  }
-
-  if (_internal_metadata_.have_unknown_fields()) {
-    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
-        _internal_metadata_.unknown_fields(), output);
-  }
-  // @@protoc_insertion_point(serialize_end:plc_module.plc_connection_params)
-}
-
-::google::protobuf::uint8* plc_connection_params::InternalSerializeWithCachedSizesToArray(
-    bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
-  // @@protoc_insertion_point(serialize_to_array_start:plc_module.plc_connection_params)
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  (void) cached_has_bits;
-
-  cached_has_bits = _has_bits_[0];
-  // required string ip = 1;
-  if (cached_has_bits & 0x00000001u) {
-    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
-      this->ip().data(), static_cast<int>(this->ip().length()),
-      ::google::protobuf::internal::WireFormat::SERIALIZE,
-      "plc_module.plc_connection_params.ip");
-    target =
-      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
-        1, this->ip(), target);
-  }
-
-  // required int32 port = 2;
-  if (cached_has_bits & 0x00000002u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->port(), target);
-  }
-
-  // required int32 slave_id = 3;
-  if (cached_has_bits & 0x00000004u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->slave_id(), target);
-  }
-
-  if (_internal_metadata_.have_unknown_fields()) {
-    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
-        _internal_metadata_.unknown_fields(), target);
-  }
-  // @@protoc_insertion_point(serialize_to_array_end:plc_module.plc_connection_params)
-  return target;
-}
-
-size_t plc_connection_params::RequiredFieldsByteSizeFallback() const {
-// @@protoc_insertion_point(required_fields_byte_size_fallback_start:plc_module.plc_connection_params)
-  size_t total_size = 0;
-
-  if (has_ip()) {
-    // required string ip = 1;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::StringSize(
-        this->ip());
-  }
-
-  if (has_port()) {
-    // required int32 port = 2;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::Int32Size(
-        this->port());
-  }
-
-  if (has_slave_id()) {
-    // required int32 slave_id = 3;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::Int32Size(
-        this->slave_id());
-  }
-
-  return total_size;
-}
-size_t plc_connection_params::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:plc_module.plc_connection_params)
-  size_t total_size = 0;
-
-  if (_internal_metadata_.have_unknown_fields()) {
-    total_size +=
-      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
-        _internal_metadata_.unknown_fields());
-  }
-  if (((_has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) {  // All required fields are present.
-    // required string ip = 1;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::StringSize(
-        this->ip());
-
-    // required int32 port = 2;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::Int32Size(
-        this->port());
-
-    // required int32 slave_id = 3;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::Int32Size(
-        this->slave_id());
-
-  } else {
-    total_size += RequiredFieldsByteSizeFallback();
-  }
-  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = cached_size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-  return total_size;
-}
-
-void plc_connection_params::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:plc_module.plc_connection_params)
-  GOOGLE_DCHECK_NE(&from, this);
-  const plc_connection_params* source =
-      ::google::protobuf::internal::DynamicCastToGenerated<const plc_connection_params>(
-          &from);
-  if (source == NULL) {
-  // @@protoc_insertion_point(generalized_merge_from_cast_fail:plc_module.plc_connection_params)
-    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
-  } else {
-  // @@protoc_insertion_point(generalized_merge_from_cast_success:plc_module.plc_connection_params)
-    MergeFrom(*source);
-  }
-}
-
-void plc_connection_params::MergeFrom(const plc_connection_params& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:plc_module.plc_connection_params)
-  GOOGLE_DCHECK_NE(&from, this);
-  _internal_metadata_.MergeFrom(from._internal_metadata_);
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  (void) cached_has_bits;
-
-  cached_has_bits = from._has_bits_[0];
-  if (cached_has_bits & 7u) {
-    if (cached_has_bits & 0x00000001u) {
-      set_has_ip();
-      ip_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.ip_);
-    }
-    if (cached_has_bits & 0x00000002u) {
-      port_ = from.port_;
-    }
-    if (cached_has_bits & 0x00000004u) {
-      slave_id_ = from.slave_id_;
-    }
-    _has_bits_[0] |= cached_has_bits;
-  }
-}
-
-void plc_connection_params::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:plc_module.plc_connection_params)
-  if (&from == this) return;
-  Clear();
-  MergeFrom(from);
-}
-
-void plc_connection_params::CopyFrom(const plc_connection_params& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:plc_module.plc_connection_params)
-  if (&from == this) return;
-  Clear();
-  MergeFrom(from);
-}
-
-bool plc_connection_params::IsInitialized() const {
-  if ((_has_bits_[0] & 0x00000007) != 0x00000007) return false;
-  return true;
-}
-
-void plc_connection_params::Swap(plc_connection_params* other) {
-  if (other == this) return;
-  InternalSwap(other);
-}
-void plc_connection_params::InternalSwap(plc_connection_params* other) {
-  using std::swap;
-  ip_.Swap(&other->ip_);
-  swap(port_, other->port_);
-  swap(slave_id_, other->slave_id_);
-  swap(_has_bits_[0], other->_has_bits_[0]);
-  _internal_metadata_.Swap(&other->_internal_metadata_);
-  swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata plc_connection_params::GetMetadata() const {
-  protobuf_plc_5fmodule_2eproto::protobuf_AssignDescriptorsOnce();
-  return ::protobuf_plc_5fmodule_2eproto::file_level_metadata[kIndexInFileMessages];
-}
-
-
-// ===================================================================
-
-void Plc_msg::InitAsDefaultInstance() {
-}
-#if !defined(_MSC_VER) || _MSC_VER >= 1900
-const int Plc_msg::kStatusFieldNumber;
-const int Plc_msg::kPlcValuesFieldNumber;
-#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
-
-Plc_msg::Plc_msg()
-  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
-  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
-    ::protobuf_plc_5fmodule_2eproto::InitDefaultsPlc_msg();
-  }
-  SharedCtor();
-  // @@protoc_insertion_point(constructor:plc_module.Plc_msg)
-}
-Plc_msg::Plc_msg(const Plc_msg& from)
-  : ::google::protobuf::Message(),
-      _internal_metadata_(NULL),
-      _has_bits_(from._has_bits_),
-      _cached_size_(0),
-      plc_values_(from.plc_values_) {
-  _internal_metadata_.MergeFrom(from._internal_metadata_);
-  status_ = from.status_;
-  // @@protoc_insertion_point(copy_constructor:plc_module.Plc_msg)
-}
-
-void Plc_msg::SharedCtor() {
-  _cached_size_ = 0;
-  status_ = 0;
-}
-
-Plc_msg::~Plc_msg() {
-  // @@protoc_insertion_point(destructor:plc_module.Plc_msg)
-  SharedDtor();
-}
-
-void Plc_msg::SharedDtor() {
-}
-
-void Plc_msg::SetCachedSize(int size) const {
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-}
-const ::google::protobuf::Descriptor* Plc_msg::descriptor() {
-  ::protobuf_plc_5fmodule_2eproto::protobuf_AssignDescriptorsOnce();
-  return ::protobuf_plc_5fmodule_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
-}
-
-const Plc_msg& Plc_msg::default_instance() {
-  ::protobuf_plc_5fmodule_2eproto::InitDefaultsPlc_msg();
-  return *internal_default_instance();
-}
-
-Plc_msg* Plc_msg::New(::google::protobuf::Arena* arena) const {
-  Plc_msg* n = new Plc_msg;
-  if (arena != NULL) {
-    arena->Own(n);
-  }
-  return n;
-}
-
-void Plc_msg::Clear() {
-// @@protoc_insertion_point(message_clear_start:plc_module.Plc_msg)
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  // Prevent compiler warnings about cached_has_bits being unused
-  (void) cached_has_bits;
-
-  plc_values_.Clear();
-  status_ = 0;
-  _has_bits_.Clear();
-  _internal_metadata_.Clear();
-}
-
-bool Plc_msg::MergePartialFromCodedStream(
-    ::google::protobuf::io::CodedInputStream* input) {
-#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
-  ::google::protobuf::uint32 tag;
-  // @@protoc_insertion_point(parse_start:plc_module.Plc_msg)
-  for (;;) {
-    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
-    tag = p.first;
-    if (!p.second) goto handle_unusual;
-    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
-      // optional .plc_module.PLC_STATUS status = 1;
-      case 1: {
-        if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {
-          int value;
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
-                 input, &value)));
-          if (::plc_module::PLC_STATUS_IsValid(value)) {
-            set_status(static_cast< ::plc_module::PLC_STATUS >(value));
-          } else {
-            mutable_unknown_fields()->AddVarint(
-                1, static_cast< ::google::protobuf::uint64>(value));
-          }
-        } else {
-          goto handle_unusual;
-        }
-        break;
-      }
-
-      // repeated int32 plc_values = 2;
-      case 2: {
-        if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) {
-          DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 1, 16u, input, this->mutable_plc_values())));
-        } else if (
-            static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, this->mutable_plc_values())));
-        } else {
-          goto handle_unusual;
-        }
-        break;
-      }
-
-      default: {
-      handle_unusual:
-        if (tag == 0) {
-          goto success;
-        }
-        DO_(::google::protobuf::internal::WireFormat::SkipField(
-              input, tag, _internal_metadata_.mutable_unknown_fields()));
-        break;
-      }
-    }
-  }
-success:
-  // @@protoc_insertion_point(parse_success:plc_module.Plc_msg)
-  return true;
-failure:
-  // @@protoc_insertion_point(parse_failure:plc_module.Plc_msg)
-  return false;
-#undef DO_
-}
-
-void Plc_msg::SerializeWithCachedSizes(
-    ::google::protobuf::io::CodedOutputStream* output) const {
-  // @@protoc_insertion_point(serialize_start:plc_module.Plc_msg)
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  (void) cached_has_bits;
-
-  cached_has_bits = _has_bits_[0];
-  // optional .plc_module.PLC_STATUS status = 1;
-  if (cached_has_bits & 0x00000001u) {
-    ::google::protobuf::internal::WireFormatLite::WriteEnum(
-      1, this->status(), output);
-  }
-
-  // repeated int32 plc_values = 2;
-  for (int i = 0, n = this->plc_values_size(); i < n; i++) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(
-      2, this->plc_values(i), output);
-  }
-
-  if (_internal_metadata_.have_unknown_fields()) {
-    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
-        _internal_metadata_.unknown_fields(), output);
-  }
-  // @@protoc_insertion_point(serialize_end:plc_module.Plc_msg)
-}
-
-::google::protobuf::uint8* Plc_msg::InternalSerializeWithCachedSizesToArray(
-    bool deterministic, ::google::protobuf::uint8* target) const {
-  (void)deterministic; // Unused
-  // @@protoc_insertion_point(serialize_to_array_start:plc_module.Plc_msg)
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  (void) cached_has_bits;
-
-  cached_has_bits = _has_bits_[0];
-  // optional .plc_module.PLC_STATUS status = 1;
-  if (cached_has_bits & 0x00000001u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
-      1, this->status(), target);
-  }
-
-  // repeated int32 plc_values = 2;
-  target = ::google::protobuf::internal::WireFormatLite::
-    WriteInt32ToArray(2, this->plc_values_, target);
-
-  if (_internal_metadata_.have_unknown_fields()) {
-    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
-        _internal_metadata_.unknown_fields(), target);
-  }
-  // @@protoc_insertion_point(serialize_to_array_end:plc_module.Plc_msg)
-  return target;
-}
-
-size_t Plc_msg::ByteSizeLong() const {
-// @@protoc_insertion_point(message_byte_size_start:plc_module.Plc_msg)
-  size_t total_size = 0;
-
-  if (_internal_metadata_.have_unknown_fields()) {
-    total_size +=
-      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
-        _internal_metadata_.unknown_fields());
-  }
-  // repeated int32 plc_values = 2;
-  {
-    size_t data_size = ::google::protobuf::internal::WireFormatLite::
-      Int32Size(this->plc_values_);
-    total_size += 1 *
-                  ::google::protobuf::internal::FromIntSize(this->plc_values_size());
-    total_size += data_size;
-  }
-
-  // optional .plc_module.PLC_STATUS status = 1;
-  if (has_status()) {
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::EnumSize(this->status());
-  }
-
-  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
-  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
-  _cached_size_ = cached_size;
-  GOOGLE_SAFE_CONCURRENT_WRITES_END();
-  return total_size;
-}
-
-void Plc_msg::MergeFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_merge_from_start:plc_module.Plc_msg)
-  GOOGLE_DCHECK_NE(&from, this);
-  const Plc_msg* source =
-      ::google::protobuf::internal::DynamicCastToGenerated<const Plc_msg>(
-          &from);
-  if (source == NULL) {
-  // @@protoc_insertion_point(generalized_merge_from_cast_fail:plc_module.Plc_msg)
-    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
-  } else {
-  // @@protoc_insertion_point(generalized_merge_from_cast_success:plc_module.Plc_msg)
-    MergeFrom(*source);
-  }
-}
-
-void Plc_msg::MergeFrom(const Plc_msg& from) {
-// @@protoc_insertion_point(class_specific_merge_from_start:plc_module.Plc_msg)
-  GOOGLE_DCHECK_NE(&from, this);
-  _internal_metadata_.MergeFrom(from._internal_metadata_);
-  ::google::protobuf::uint32 cached_has_bits = 0;
-  (void) cached_has_bits;
-
-  plc_values_.MergeFrom(from.plc_values_);
-  if (from.has_status()) {
-    set_status(from.status());
-  }
-}
-
-void Plc_msg::CopyFrom(const ::google::protobuf::Message& from) {
-// @@protoc_insertion_point(generalized_copy_from_start:plc_module.Plc_msg)
-  if (&from == this) return;
-  Clear();
-  MergeFrom(from);
-}
-
-void Plc_msg::CopyFrom(const Plc_msg& from) {
-// @@protoc_insertion_point(class_specific_copy_from_start:plc_module.Plc_msg)
-  if (&from == this) return;
-  Clear();
-  MergeFrom(from);
-}
-
-bool Plc_msg::IsInitialized() const {
-  return true;
-}
-
-void Plc_msg::Swap(Plc_msg* other) {
-  if (other == this) return;
-  InternalSwap(other);
-}
-void Plc_msg::InternalSwap(Plc_msg* other) {
-  using std::swap;
-  plc_values_.InternalSwap(&other->plc_values_);
-  swap(status_, other->status_);
-  swap(_has_bits_[0], other->_has_bits_[0]);
-  _internal_metadata_.Swap(&other->_internal_metadata_);
-  swap(_cached_size_, other->_cached_size_);
-}
-
-::google::protobuf::Metadata Plc_msg::GetMetadata() const {
-  protobuf_plc_5fmodule_2eproto::protobuf_AssignDescriptorsOnce();
-  return ::protobuf_plc_5fmodule_2eproto::file_level_metadata[kIndexInFileMessages];
-}
-
-
-// @@protoc_insertion_point(namespace_scope)
-}  // namespace plc_module
-
-// @@protoc_insertion_point(global_scope)

+ 0 - 555
plc/plc_module.pb.h

@@ -1,555 +0,0 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: plc_module.proto
-
-#ifndef PROTOBUF_plc_5fmodule_2eproto__INCLUDED
-#define PROTOBUF_plc_5fmodule_2eproto__INCLUDED
-
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-
-#if GOOGLE_PROTOBUF_VERSION < 3005000
-#error This file was generated by a newer version of protoc which is
-#error incompatible with your Protocol Buffer headers.  Please update
-#error your headers.
-#endif
-#if 3005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
-#error This file was generated by an older version of protoc which is
-#error incompatible with your Protocol Buffer headers.  Please
-#error regenerate this file with a newer version of protoc.
-#endif
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>  // IWYU pragma: export
-#include <google/protobuf/extension_set.h>  // IWYU pragma: export
-#include <google/protobuf/generated_enum_reflection.h>
-#include <google/protobuf/unknown_field_set.h>
-// @@protoc_insertion_point(includes)
-
-namespace protobuf_plc_5fmodule_2eproto {
-// Internal implementation detail -- do not use these members.
-struct TableStruct {
-  static const ::google::protobuf::internal::ParseTableField entries[];
-  static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
-  static const ::google::protobuf::internal::ParseTable schema[2];
-  static const ::google::protobuf::internal::FieldMetadata field_metadata[];
-  static const ::google::protobuf::internal::SerializationTable serialization_table[];
-  static const ::google::protobuf::uint32 offsets[];
-};
-void AddDescriptors();
-void InitDefaultsplc_connection_paramsImpl();
-void InitDefaultsplc_connection_params();
-void InitDefaultsPlc_msgImpl();
-void InitDefaultsPlc_msg();
-inline void InitDefaults() {
-  InitDefaultsplc_connection_params();
-  InitDefaultsPlc_msg();
-}
-}  // namespace protobuf_plc_5fmodule_2eproto
-namespace plc_module {
-class Plc_msg;
-class Plc_msgDefaultTypeInternal;
-extern Plc_msgDefaultTypeInternal _Plc_msg_default_instance_;
-class plc_connection_params;
-class plc_connection_paramsDefaultTypeInternal;
-extern plc_connection_paramsDefaultTypeInternal _plc_connection_params_default_instance_;
-}  // namespace plc_module
-namespace plc_module {
-
-enum PLC_STATUS {
-  ePLCConnected = 0,
-  ePLCDisconnected = 1,
-  ePLCRefused = 2,
-  ePLCUnknown = 3
-};
-bool PLC_STATUS_IsValid(int value);
-const PLC_STATUS PLC_STATUS_MIN = ePLCConnected;
-const PLC_STATUS PLC_STATUS_MAX = ePLCUnknown;
-const int PLC_STATUS_ARRAYSIZE = PLC_STATUS_MAX + 1;
-
-const ::google::protobuf::EnumDescriptor* PLC_STATUS_descriptor();
-inline const ::std::string& PLC_STATUS_Name(PLC_STATUS value) {
-  return ::google::protobuf::internal::NameOfEnum(
-    PLC_STATUS_descriptor(), value);
-}
-inline bool PLC_STATUS_Parse(
-    const ::std::string& name, PLC_STATUS* value) {
-  return ::google::protobuf::internal::ParseNamedEnum<PLC_STATUS>(
-    PLC_STATUS_descriptor(), name, value);
-}
-// ===================================================================
-
-class plc_connection_params : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:plc_module.plc_connection_params) */ {
- public:
-  plc_connection_params();
-  virtual ~plc_connection_params();
-
-  plc_connection_params(const plc_connection_params& from);
-
-  inline plc_connection_params& operator=(const plc_connection_params& from) {
-    CopyFrom(from);
-    return *this;
-  }
-  #if LANG_CXX11
-  plc_connection_params(plc_connection_params&& from) noexcept
-    : plc_connection_params() {
-    *this = ::std::move(from);
-  }
-
-  inline plc_connection_params& operator=(plc_connection_params&& from) noexcept {
-    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
-      if (this != &from) InternalSwap(&from);
-    } else {
-      CopyFrom(from);
-    }
-    return *this;
-  }
-  #endif
-  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
-    return _internal_metadata_.unknown_fields();
-  }
-  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
-    return _internal_metadata_.mutable_unknown_fields();
-  }
-
-  static const ::google::protobuf::Descriptor* descriptor();
-  static const plc_connection_params& default_instance();
-
-  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
-  static inline const plc_connection_params* internal_default_instance() {
-    return reinterpret_cast<const plc_connection_params*>(
-               &_plc_connection_params_default_instance_);
-  }
-  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
-    0;
-
-  void Swap(plc_connection_params* other);
-  friend void swap(plc_connection_params& a, plc_connection_params& b) {
-    a.Swap(&b);
-  }
-
-  // implements Message ----------------------------------------------
-
-  inline plc_connection_params* New() const PROTOBUF_FINAL { return New(NULL); }
-
-  plc_connection_params* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
-  void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
-  void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
-  void CopyFrom(const plc_connection_params& from);
-  void MergeFrom(const plc_connection_params& from);
-  void Clear() PROTOBUF_FINAL;
-  bool IsInitialized() const PROTOBUF_FINAL;
-
-  size_t ByteSizeLong() const PROTOBUF_FINAL;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
-  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
-      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
-  int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const PROTOBUF_FINAL;
-  void InternalSwap(plc_connection_params* other);
-  private:
-  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
-    return NULL;
-  }
-  inline void* MaybeArenaPtr() const {
-    return NULL;
-  }
-  public:
-
-  ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // required string ip = 1;
-  bool has_ip() const;
-  void clear_ip();
-  static const int kIpFieldNumber = 1;
-  const ::std::string& ip() const;
-  void set_ip(const ::std::string& value);
-  #if LANG_CXX11
-  void set_ip(::std::string&& value);
-  #endif
-  void set_ip(const char* value);
-  void set_ip(const char* value, size_t size);
-  ::std::string* mutable_ip();
-  ::std::string* release_ip();
-  void set_allocated_ip(::std::string* ip);
-
-  // required int32 port = 2;
-  bool has_port() const;
-  void clear_port();
-  static const int kPortFieldNumber = 2;
-  ::google::protobuf::int32 port() const;
-  void set_port(::google::protobuf::int32 value);
-
-  // required int32 slave_id = 3;
-  bool has_slave_id() const;
-  void clear_slave_id();
-  static const int kSlaveIdFieldNumber = 3;
-  ::google::protobuf::int32 slave_id() const;
-  void set_slave_id(::google::protobuf::int32 value);
-
-  // @@protoc_insertion_point(class_scope:plc_module.plc_connection_params)
- private:
-  void set_has_ip();
-  void clear_has_ip();
-  void set_has_port();
-  void clear_has_port();
-  void set_has_slave_id();
-  void clear_has_slave_id();
-
-  // helper for ByteSizeLong()
-  size_t RequiredFieldsByteSizeFallback() const;
-
-  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
-  ::google::protobuf::internal::HasBits<1> _has_bits_;
-  mutable int _cached_size_;
-  ::google::protobuf::internal::ArenaStringPtr ip_;
-  ::google::protobuf::int32 port_;
-  ::google::protobuf::int32 slave_id_;
-  friend struct ::protobuf_plc_5fmodule_2eproto::TableStruct;
-  friend void ::protobuf_plc_5fmodule_2eproto::InitDefaultsplc_connection_paramsImpl();
-};
-// -------------------------------------------------------------------
-
-class Plc_msg : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:plc_module.Plc_msg) */ {
- public:
-  Plc_msg();
-  virtual ~Plc_msg();
-
-  Plc_msg(const Plc_msg& from);
-
-  inline Plc_msg& operator=(const Plc_msg& from) {
-    CopyFrom(from);
-    return *this;
-  }
-  #if LANG_CXX11
-  Plc_msg(Plc_msg&& from) noexcept
-    : Plc_msg() {
-    *this = ::std::move(from);
-  }
-
-  inline Plc_msg& operator=(Plc_msg&& from) noexcept {
-    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
-      if (this != &from) InternalSwap(&from);
-    } else {
-      CopyFrom(from);
-    }
-    return *this;
-  }
-  #endif
-  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
-    return _internal_metadata_.unknown_fields();
-  }
-  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
-    return _internal_metadata_.mutable_unknown_fields();
-  }
-
-  static const ::google::protobuf::Descriptor* descriptor();
-  static const Plc_msg& default_instance();
-
-  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
-  static inline const Plc_msg* internal_default_instance() {
-    return reinterpret_cast<const Plc_msg*>(
-               &_Plc_msg_default_instance_);
-  }
-  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
-    1;
-
-  void Swap(Plc_msg* other);
-  friend void swap(Plc_msg& a, Plc_msg& b) {
-    a.Swap(&b);
-  }
-
-  // implements Message ----------------------------------------------
-
-  inline Plc_msg* New() const PROTOBUF_FINAL { return New(NULL); }
-
-  Plc_msg* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
-  void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
-  void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
-  void CopyFrom(const Plc_msg& from);
-  void MergeFrom(const Plc_msg& from);
-  void Clear() PROTOBUF_FINAL;
-  bool IsInitialized() const PROTOBUF_FINAL;
-
-  size_t ByteSizeLong() const PROTOBUF_FINAL;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
-  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
-      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
-  int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const PROTOBUF_FINAL;
-  void InternalSwap(Plc_msg* other);
-  private:
-  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
-    return NULL;
-  }
-  inline void* MaybeArenaPtr() const {
-    return NULL;
-  }
-  public:
-
-  ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // repeated int32 plc_values = 2;
-  int plc_values_size() const;
-  void clear_plc_values();
-  static const int kPlcValuesFieldNumber = 2;
-  ::google::protobuf::int32 plc_values(int index) const;
-  void set_plc_values(int index, ::google::protobuf::int32 value);
-  void add_plc_values(::google::protobuf::int32 value);
-  const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-      plc_values() const;
-  ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-      mutable_plc_values();
-
-  // optional .plc_module.PLC_STATUS status = 1;
-  bool has_status() const;
-  void clear_status();
-  static const int kStatusFieldNumber = 1;
-  ::plc_module::PLC_STATUS status() const;
-  void set_status(::plc_module::PLC_STATUS value);
-
-  // @@protoc_insertion_point(class_scope:plc_module.Plc_msg)
- private:
-  void set_has_status();
-  void clear_has_status();
-
-  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
-  ::google::protobuf::internal::HasBits<1> _has_bits_;
-  mutable int _cached_size_;
-  ::google::protobuf::RepeatedField< ::google::protobuf::int32 > plc_values_;
-  int status_;
-  friend struct ::protobuf_plc_5fmodule_2eproto::TableStruct;
-  friend void ::protobuf_plc_5fmodule_2eproto::InitDefaultsPlc_msgImpl();
-};
-// ===================================================================
-
-
-// ===================================================================
-
-#ifdef __GNUC__
-  #pragma GCC diagnostic push
-  #pragma GCC diagnostic ignored "-Wstrict-aliasing"
-#endif  // __GNUC__
-// plc_connection_params
-
-// required string ip = 1;
-inline bool plc_connection_params::has_ip() const {
-  return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void plc_connection_params::set_has_ip() {
-  _has_bits_[0] |= 0x00000001u;
-}
-inline void plc_connection_params::clear_has_ip() {
-  _has_bits_[0] &= ~0x00000001u;
-}
-inline void plc_connection_params::clear_ip() {
-  ip_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-  clear_has_ip();
-}
-inline const ::std::string& plc_connection_params::ip() const {
-  // @@protoc_insertion_point(field_get:plc_module.plc_connection_params.ip)
-  return ip_.GetNoArena();
-}
-inline void plc_connection_params::set_ip(const ::std::string& value) {
-  set_has_ip();
-  ip_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
-  // @@protoc_insertion_point(field_set:plc_module.plc_connection_params.ip)
-}
-#if LANG_CXX11
-inline void plc_connection_params::set_ip(::std::string&& value) {
-  set_has_ip();
-  ip_.SetNoArena(
-    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
-  // @@protoc_insertion_point(field_set_rvalue:plc_module.plc_connection_params.ip)
-}
-#endif
-inline void plc_connection_params::set_ip(const char* value) {
-  GOOGLE_DCHECK(value != NULL);
-  set_has_ip();
-  ip_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
-  // @@protoc_insertion_point(field_set_char:plc_module.plc_connection_params.ip)
-}
-inline void plc_connection_params::set_ip(const char* value, size_t size) {
-  set_has_ip();
-  ip_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
-      ::std::string(reinterpret_cast<const char*>(value), size));
-  // @@protoc_insertion_point(field_set_pointer:plc_module.plc_connection_params.ip)
-}
-inline ::std::string* plc_connection_params::mutable_ip() {
-  set_has_ip();
-  // @@protoc_insertion_point(field_mutable:plc_module.plc_connection_params.ip)
-  return ip_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* plc_connection_params::release_ip() {
-  // @@protoc_insertion_point(field_release:plc_module.plc_connection_params.ip)
-  clear_has_ip();
-  return ip_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void plc_connection_params::set_allocated_ip(::std::string* ip) {
-  if (ip != NULL) {
-    set_has_ip();
-  } else {
-    clear_has_ip();
-  }
-  ip_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ip);
-  // @@protoc_insertion_point(field_set_allocated:plc_module.plc_connection_params.ip)
-}
-
-// required int32 port = 2;
-inline bool plc_connection_params::has_port() const {
-  return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void plc_connection_params::set_has_port() {
-  _has_bits_[0] |= 0x00000002u;
-}
-inline void plc_connection_params::clear_has_port() {
-  _has_bits_[0] &= ~0x00000002u;
-}
-inline void plc_connection_params::clear_port() {
-  port_ = 0;
-  clear_has_port();
-}
-inline ::google::protobuf::int32 plc_connection_params::port() const {
-  // @@protoc_insertion_point(field_get:plc_module.plc_connection_params.port)
-  return port_;
-}
-inline void plc_connection_params::set_port(::google::protobuf::int32 value) {
-  set_has_port();
-  port_ = value;
-  // @@protoc_insertion_point(field_set:plc_module.plc_connection_params.port)
-}
-
-// required int32 slave_id = 3;
-inline bool plc_connection_params::has_slave_id() const {
-  return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void plc_connection_params::set_has_slave_id() {
-  _has_bits_[0] |= 0x00000004u;
-}
-inline void plc_connection_params::clear_has_slave_id() {
-  _has_bits_[0] &= ~0x00000004u;
-}
-inline void plc_connection_params::clear_slave_id() {
-  slave_id_ = 0;
-  clear_has_slave_id();
-}
-inline ::google::protobuf::int32 plc_connection_params::slave_id() const {
-  // @@protoc_insertion_point(field_get:plc_module.plc_connection_params.slave_id)
-  return slave_id_;
-}
-inline void plc_connection_params::set_slave_id(::google::protobuf::int32 value) {
-  set_has_slave_id();
-  slave_id_ = value;
-  // @@protoc_insertion_point(field_set:plc_module.plc_connection_params.slave_id)
-}
-
-// -------------------------------------------------------------------
-
-// Plc_msg
-
-// optional .plc_module.PLC_STATUS status = 1;
-inline bool Plc_msg::has_status() const {
-  return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void Plc_msg::set_has_status() {
-  _has_bits_[0] |= 0x00000001u;
-}
-inline void Plc_msg::clear_has_status() {
-  _has_bits_[0] &= ~0x00000001u;
-}
-inline void Plc_msg::clear_status() {
-  status_ = 0;
-  clear_has_status();
-}
-inline ::plc_module::PLC_STATUS Plc_msg::status() const {
-  // @@protoc_insertion_point(field_get:plc_module.Plc_msg.status)
-  return static_cast< ::plc_module::PLC_STATUS >(status_);
-}
-inline void Plc_msg::set_status(::plc_module::PLC_STATUS value) {
-  assert(::plc_module::PLC_STATUS_IsValid(value));
-  set_has_status();
-  status_ = value;
-  // @@protoc_insertion_point(field_set:plc_module.Plc_msg.status)
-}
-
-// repeated int32 plc_values = 2;
-inline int Plc_msg::plc_values_size() const {
-  return plc_values_.size();
-}
-inline void Plc_msg::clear_plc_values() {
-  plc_values_.Clear();
-}
-inline ::google::protobuf::int32 Plc_msg::plc_values(int index) const {
-  // @@protoc_insertion_point(field_get:plc_module.Plc_msg.plc_values)
-  return plc_values_.Get(index);
-}
-inline void Plc_msg::set_plc_values(int index, ::google::protobuf::int32 value) {
-  plc_values_.Set(index, value);
-  // @@protoc_insertion_point(field_set:plc_module.Plc_msg.plc_values)
-}
-inline void Plc_msg::add_plc_values(::google::protobuf::int32 value) {
-  plc_values_.Add(value);
-  // @@protoc_insertion_point(field_add:plc_module.Plc_msg.plc_values)
-}
-inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
-Plc_msg::plc_values() const {
-  // @@protoc_insertion_point(field_list:plc_module.Plc_msg.plc_values)
-  return plc_values_;
-}
-inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*
-Plc_msg::mutable_plc_values() {
-  // @@protoc_insertion_point(field_mutable_list:plc_module.Plc_msg.plc_values)
-  return &plc_values_;
-}
-
-#ifdef __GNUC__
-  #pragma GCC diagnostic pop
-#endif  // __GNUC__
-// -------------------------------------------------------------------
-
-
-// @@protoc_insertion_point(namespace_scope)
-
-}  // namespace plc_module
-
-namespace google {
-namespace protobuf {
-
-template <> struct is_proto_enum< ::plc_module::PLC_STATUS> : ::google::protobuf::internal::true_type {};
-template <>
-inline const EnumDescriptor* GetEnumDescriptor< ::plc_module::PLC_STATUS>() {
-  return ::plc_module::PLC_STATUS_descriptor();
-}
-
-}  // namespace protobuf
-}  // namespace google
-
-// @@protoc_insertion_point(global_scope)
-
-#endif  // PROTOBUF_plc_5fmodule_2eproto__INCLUDED

+ 0 - 22
plc/plc_module.proto

@@ -1,22 +0,0 @@
-syntax = "proto2";
-package plc_module;
-
-message plc_connection_params{
-    required string ip=1;
-    required int32 port=2;
-    required int32 slave_id=3;
-}
-
-enum PLC_STATUS
-{
-	ePLCConnected=0;
-	ePLCDisconnected=1;
-	ePLCRefused=2;
-	ePLCUnknown=3;
-}
-
-message Plc_msg
-{
-	optional PLC_STATUS status=1;
-	repeated int32 plc_values=2;
-}

+ 0 - 46
plc/plc_task.cpp

@@ -1,46 +0,0 @@
-#include "plc_task.h"
-
-Plc_Task::Plc_Task(){
-    m_task_type = Task_type::PLC_TASK;
-    mb_result_set_flag = false;
-}
-
-Plc_Task::~Plc_Task(){
-
-}
-
-Error_manager Plc_Task::init(){
-    m_measure_result.terminal_id = -1;
-    m_measure_result.correctness = false;
-    m_measure_result.x = 0;
-    m_measure_result.y = 0;
-    m_measure_result.angle = 0;
-    m_measure_result.length = 0;
-    m_measure_result.width = 0;
-    m_measure_result.height = 0;
-    m_measure_result.wheel_base = 0;
-    m_task_statu = Task_statu::TASK_CREATED;
-    return SUCCESS;
-}
-
-Error_manager Plc_Task::get_result(struct measure_result &result){
-    if(mb_result_set_flag)
-    {
-        memcpy(&result, &m_measure_result, sizeof(m_measure_result));
-        return Error_manager(Error_code::SUCCESS, Error_level::NORMAL, "成功获取测量结果");
-    }
-    else
-    {
-        return Error_manager(Error_code::PLC_EMPTY_TASK, Error_level::NEGLIGIBLE_ERROR, "未获得测量结果,或许是由于在set之前被调用");
-    }
-}
-
-Error_manager Plc_Task::set_result(struct measure_result result){
-    memcpy(&m_measure_result, &result, sizeof(result));
-    mb_result_set_flag = true;
-    return Error_manager(Error_code::SUCCESS, Error_level::NORMAL, "设置测量结果成功");
-}
-
-bool Plc_Task::get_result_set_flag(){
-    return mb_result_set_flag;
-}

+ 0 - 41
plc/plc_task.h

@@ -1,41 +0,0 @@
-#ifndef PLC_TASK_HH
-#define PLC_TASK_HH
-#include <string.h>
-
-#include "../task/task_command_manager.h"
-// #include "../error.h"
-#include "../error_code/error_code.h"
-
-struct measure_result
-{
-    int terminal_id;
-    float x;
-    float y;
-    float angle;
-    float length;
-    float width;
-    float height;
-    float wheel_base;
-    bool correctness;
-};
-
-class Plc_Task : public Task_Base
-{
-public:
-    virtual Error_manager init();
-    
-    Plc_Task();
-    ~Plc_Task();
-    // 将测量结果存入该任务单
-    Error_manager set_result(struct measure_result result);
-    // 将测量结果传出
-    Error_manager get_result(struct measure_result &result);
-    // 获取测量结果是否已存入该任务单的指标
-    bool get_result_set_flag();
-
-private:
-struct measure_result   m_measure_result;
-bool                    mb_result_set_flag;
-};
-
-#endif // !PLC_TASK_HH

+ 1 - 1
task/task_command_manager.cpp

@@ -3,7 +3,7 @@
 //
 
 #include "task_command_manager.h"
-#include "../error.h"
+#include "../error_code/error_code.h"
 
 Task_Base::Task_Base()
 {

+ 6 - 4
task/task_command_manager.h

@@ -10,11 +10,13 @@
 //任务类型
 enum Task_type
 {
-    LASER_TASK=0,           //雷达扫描任务
-    LOCATE_TASK,            //测量任务
-    PLC_TASK,                //上传PLC任务
+	UNKNOW_TASK             =0,				//未知任务单//初始化,默认值
+	LASER_TASK              =1,             //雷达扫描任务,
+    LOCATE_TASK             =2,             //测量任务
+    PLC_TASK                =3,             //上传PLC任务
+
     WJ_TASK,
-    UNKNOW_TASK             //未知任务单/初始化
+    
 };
 //任务状态,如果任务故障,任务状态改为TASK_OVER,然后在m_task_error_manager 补充错误码。
 enum Task_statu

+ 0 - 33
terminor/MeasureRequest.cpp

@@ -1,33 +0,0 @@
-//
-// Created by zx on 2019/12/17.
-//
-
-#include "MeasureRequest.h"
-#include <nnxx/message.h>
-#include <nnxx/message_control.h>
-#include <nnxx/socket.h>
-#include <nnxx/reqrep.h>
-#include <nnxx/timeout.h>
-#include <nnxx/error.h>
-MeasureRequest::MeasureRequest(std::string connectStr)
-{
-    m_connect_str=connectStr;
-}
-bool MeasureRequest::Request(std::string cmd,std::string& response)
-{
-    nnxx::socket sock{ nnxx::SP, nnxx::REQ };
-    sock.connect(m_connect_str);
-    sock.send(cmd);
-    nnxx::message message;
-    try { nnxx::with_recv_timeout _ { sock, std::chrono::milliseconds(1000) };
-        message=sock.recv();
-    }
-    catch (const nnxx::timeout_error &) {
-        return false;
-    }
-    catch (const std::exception &) {
-        return false;
-    }
-    response=nnxx::to_string(message);
-    return true;
-}

+ 0 - 25
terminor/MeasureRequest.h

@@ -1,25 +0,0 @@
-//
-// Created by zx on 2019/12/17.
-//
-
-#ifndef LIDARMEASURE_MEASUREREQUEST_H
-#define LIDARMEASURE_MEASUREREQUEST_H
-#include <nnxx/message.h>
-#include <nnxx/message_control.h>
-#include <nnxx/socket.h>
-#include <nnxx/pubsub.h>
-#include <nnxx/timeout.h>
-#include <nnxx/error.h>
-#include <string>
-
-class MeasureRequest {
-public:
-    MeasureRequest(std::string connectStr);
-    bool Request(std::string cmd,std::string& response);
-
-protected:
-    std::string m_connect_str;
-};
-
-
-#endif //LIDARMEASURE_MEASUREREQUEST_H

Plik diff jest za duży
+ 0 - 1671
terminor/Terminor_parameter.pb.cc


Plik diff jest za duży
+ 0 - 1060
terminor/Terminor_parameter.pb.h


+ 0 - 30
terminor/Terminor_parameter.proto

@@ -1,30 +0,0 @@
-syntax="proto2";
-package Terminal;
-
-message Area3d
-{
-    required float min_x=1;
-    required float max_x=2;
-    required float min_y=3;
-    required float max_y=4;
-    required float min_z=5;
-    required float max_z=6;
-}
-
-message Laser_parameter
-{
-    required int64 id=1;
-    optional int64 frame_count=2;
-}
-message Terminor_parameter
-{
-    required Area3d area_3d=1;
-    required int64 id=2;
-    repeated Laser_parameter laser_parameter=3;
-}
-
-message Terminor_parameter_all
-{
-    repeated Terminor_parameter terminor_parameters=1;
-    required string save_root_path=2;
-}

+ 0 - 561
terminor/terminal_command_executor.cpp

@@ -1,561 +0,0 @@
-#include "terminal_command_executor.h"
-#include <glog/logging.h>
-#include <chrono>
-#include <pcl/filters/passthrough.h>
-#include "../tool/pathcreator.h"
-///增加获取wj电子围栏模块头文件
-#include "terminor_msg.pb.h"
-#include "MeasureRequest.h"
-
-//////以下两个函数用于测试,读取指定点云
-bool string2point(std::string str,pcl::PointXYZ& point)
-{
-    std::istringstream iss;
-    iss.str(str);
-    float value;
-    float data[3]={0};
-    for(int i=0;i<3;++i)
-    {
-        if(iss>>value)
-        {
-            data[i]=value;
-        }
-        else
-        {
-            return false;
-        }
-    }
-    point.x=data[0];
-    point.y=data[1];
-    point.z=data[2];
-    return true;
-}
-
-pcl::PointCloud<pcl::PointXYZ>::Ptr ReadTxtCloud(std::string file)
-{
-    std::ifstream fin(file.c_str());
-    const int line_length=64;
-    char str[line_length]={0};
-    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
-    while(fin.getline(str,line_length))
-    {
-        pcl::PointXYZ point;
-        if(string2point(str,point))
-        {
-            cloud->push_back(point);
-        }
-    }
-    return cloud;
-}
-//////////
-
-Terminor_Command_Executor::Terminor_Command_Executor(Terminal::Terminor_parameter parameter)
-    :m_terminor_statu(TERMINOR_READY), mp_command_thread(0),m_timeout_second(15),mb_force_quit(false)
-{
-    m_terminor_parameter=parameter;
-    mp_wj_lidar=NULL;
-}
-
-Error_manager Terminor_Command_Executor::force_stop_command()
-{
-    mb_force_quit=true;
-    //等待执行线程退出
-    if(mp_command_thread!=NULL)
-    {
-        if(mp_command_thread->joinable())
-        {
-            mp_command_thread->join();
-            delete mp_command_thread;
-            mp_command_thread=NULL;
-        }
-    }
-    return SUCCESS;
-}
-
-Terminor_Command_Executor::~Terminor_Command_Executor()
-{
-    if(mp_command_thread!=0)
-    {
-        force_stop_command();
-        if(mp_command_thread->joinable())
-        {
-            mp_command_thread->join();
-            delete mp_command_thread;
-            mp_command_thread=0;
-        }
-    }
-}
-
-TerminorStatu Terminor_Command_Executor::get_terminor_statu()
-{
-    return m_terminor_statu;
-}
-
-Error_manager Terminor_Command_Executor::execute_command(std::vector<Laser_base*> lasers,Fence_controller* wj_lidar,
-    Plc_Communicator* plc,Locater* locater,Verify_result* verify_tool,float timeout)
-{
-    Error_manager code;
-    //第一步检查输入参数合法性
-    for(int i=0;i<lasers.size();++i)
-    {
-        if(lasers[i]==0)
-        {
-            char description[255]={0};
-            sprintf(description,"terminor input laser* is null index:%d, terminor id:%d",i,m_terminor_parameter.id());
-            return Error_manager(TERMINOR_INPUT_LASER_NULL,NORMAL,description);
-        }
-    }
-    if(plc==0)
-    {
-        char description[255]={0};
-        sprintf(description,"terminor input plc* is null terminor id:%d",m_terminor_parameter.id());
-        return Error_manager(TERMINOR_INPUT_PLC_NULL,NORMAL,description);
-    }
-    if(wj_lidar==NULL)
-    {
-        char description[255]={0};
-        sprintf(description,"terminor input wj_lidar* is null  terminor id:%d",m_terminor_parameter.id());
-        return Error_manager(TERMINOR_INPUT_LOCATER_NULL,NORMAL,description);
-    }
-    if(locater==0)
-    {
-        char description[255]={0};
-        sprintf(description,"terminor input locater* is null  terminor id:%d",m_terminor_parameter.id());
-        return Error_manager(TERMINOR_INPUT_LOCATER_NULL,NORMAL,description);
-    }
-    mp_verify_tool=verify_tool;
-
-    //第二步,雷达,plc以及定位模块是否能正常接收指令;
-    for(int i=0;i<lasers.size();++i)
-    {
-        code=lasers[i]->check_laser();
-        if(code!=SUCCESS)
-        {
-            LOG(ERROR)<<" terminor check laser error:"<<code.to_string()<<"   terminor id :"<<m_terminor_parameter.id();
-            return code;
-        }
-    }
-    //检查plc状态
-    code=plc->get_error();
-    if(code!=SUCCESS)
-    {
-        LOG(ERROR)<<"terminor check plc error : "<<code.to_string()<<"  terminor id:"<<m_terminor_parameter.id();
-        return code;
-    }
-    //检查测量模块状态
-    code=locater->get_error();
-    if(code!=SUCCESS)
-    {
-        LOG(ERROR)<<"terminor check locater error : "<<code.to_string()<<"  terminor id:"<<m_terminor_parameter.id();
-        return code;
-    }
-    // 检查当前终端指令执行器的状态是否空闲;如果空闲,进入测量流程,设置忙碌状态
-    std::lock_guard<std::mutex> t_lock(m_mutex_lock);
-    if(get_terminor_statu()!=TERMINOR_READY)
-    {
-        char description[255]={0};
-        sprintf(description,"terminor is not ready, terminor id:%d",m_terminor_parameter.id());
-        return Error_manager(TERMINOR_NOT_READY,NORMAL,description);
-    }
-    //检查上次线程是否退出,并等待线程退出
-    if(mp_command_thread!=0)
-    {
-        if(mp_command_thread->joinable())
-        {
-            mp_command_thread->join();
-            delete mp_command_thread;
-            mp_command_thread=0;
-        }
-    }
-    //第二步接受指令,保存输入参数,更新指令状态为TERMINOR_BUSY,启动内部工作线程.返回SUCCESS
-    mp_laser_vector=lasers;
-    mp_plc=plc;
-    mp_wj_lidar=wj_lidar;
-    mp_locater=locater;
-    m_terminor_statu=TERMINOR_BUSY;
-    m_timeout_second=timeout;
-    mp_command_thread=new std::thread(thread_command_working,this);
-    if(mp_command_thread==0)
-    {
-        return Error_manager(TERMINOR_CREATE_WORKING_THREAD_FAILED,NORMAL,"terminor create thread failed");
-    }
-    return SUCCESS;
-}
-
-void Terminor_Command_Executor::thread_command_working(Terminor_Command_Executor* terminor)
-{
-    if(terminor==NULL)
-    {
-        return ;
-    }
-    //执行指令,阻塞直到指令执行完成或者异常结束,此处如果失败,连续三次测量
-    Error_manager code;
-    int measure_times=0;
-    while(terminor->mb_force_quit==false) {
-        if (measure_times == 3)
-            break;
-        code = terminor->scanning_measuring();
-        switch (code.get_error_code()) {
-            case SUCCESS:
-                break;
-            case TERMINOR_LASER_TIMEOUT: {
-                //雷达扫描超时,代表雷达故障,此时需要重置雷达模块
-            }
-        }
-
-        if (code != SUCCESS ) {
-            if(measure_times==2)
-            {
-                LOG(ERROR) << " Measure times("<<measure_times<<")  failed : "<< code.to_string();
-            }
-            else
-            {
-                LOG(WARNING) << " Measure times("<<measure_times<<")  failed : "<< code.to_string();
-            }
-            measure_times++;
-        }
-        else {
-            LOG(INFO) << " Measure complete!!! times:"<<measure_times;
-            break;
-        }
-    }
-    //根据结果执行上传任务
-    code=terminor->post_measure_information();
-    //更新终端状态为Ready状态
-    terminor->m_terminor_statu=TERMINOR_READY;
-
-    if (code != SUCCESS) {
-        LOG(ERROR) << "Command measure execute failed : "<< code.to_string();
-    }
-    else {
-        LOG(INFO) << "Command execute complete!!!";
-    }
-}
-
-/*
-     * 执行上传plc任务
-     */
-Error_manager Terminor_Command_Executor::post_measure_information()
-{
-    //计时起点
-    auto t_start_point=std::chrono::system_clock::now();
-    Error_manager code;
-    //执行plc上传任务
-    m_terminor_statu=TERMINOR_POSTING;
-    Plc_Task* plc_task=new Plc_Task();
-
-    measure_result measure_information;
-    measure_information.x=m_measure_information.locate_x;
-    measure_information.y=m_measure_information.locate_y;
-    measure_information.angle=m_measure_information.locate_theta;
-    measure_information.length=m_measure_information.locate_length;
-    measure_information.width=m_measure_information.locate_width;
-    measure_information.height=m_measure_information.locate_hight;
-    measure_information.wheel_base=m_measure_information.locate_wheel_base;
-    //plc终端编号从1开始,因此,上传给plc的终端编号必须+1
-    measure_information.terminal_id=m_terminor_parameter.id()+1;
-    measure_information.correctness=m_measure_information.locate_correct;
-
-    plc_task->set_result(measure_information);
-    code=mp_plc->execute_task(plc_task);
-    while(code!=SUCCESS)
-    {
-        //判断是否强制退出
-        if(mb_force_quit==true)
-        {
-            char description[255]={0};
-            sprintf(description,"ternimal is force quit terminal id : %d",m_terminor_parameter.id());
-            return Error_manager(TERMINOR_FORCE_QUIT,NORMAL,description);
-        }
-        //对于上传不成功,作失败处理,重新传输
-        code=mp_plc->execute_task(plc_task);
-        ///不成功,检测本次流程是否超时
-        if(code!=SUCCESS)
-        {
-            auto t_end_point=std::chrono::system_clock::now();
-            auto duration=std::chrono::duration_cast<std::chrono::milliseconds>(t_end_point - t_start_point);
-            double second=double(duration.count()) *
-                std::chrono::milliseconds::period::num / std::chrono::milliseconds::period::den;
-            if(second>m_timeout_second)
-            {
-                //扫描超时处理
-                return Error_manager(TERMINOR_POST_PLC_TIMEOUT,NORMAL,"post plc timeout");
-            }
-            usleep(1000*100);
-        }
-
-    }
-    return code;
-}
-
-void Terminor_Command_Executor::set_save_root_path(std::string root)
-{
-    m_save_root_path=root;
-}
-
-Error_manager Terminor_Command_Executor::scanning_measuring()
-{
-    //计时起点
-    auto t_start_point=std::chrono::system_clock::now();
-
-    //准备目录
-    time_t tt;
-    time( &tt );
-    tt = tt + 8*3600;  // transform the time zone
-    tm* t= gmtime( &tt );
-    char path[255]={0};
-    sprintf(path,"%s/%4d/%02d/%02d",m_save_root_path.c_str(),
-            t->tm_year + 1900,
-            t->tm_mon + 1,
-            t->tm_mday);
-    PathCreator path_creator;
-    path_creator.CreateDatePath(path);
-    std::string project_path=path_creator.GetCurPath();
-
-    Error_manager code;
-    //第一步,启动雷达扫描点云,切换当前状态为扫描中
-    //根据配置筛选雷达
-    pcl::PointCloud<pcl::PointXYZ>::Ptr scan_cloud(new pcl::PointCloud<pcl::PointXYZ>);
-    std::mutex cloud_lock;
-    std::vector<Task_Base*> laser_task_vector;
-
-    std::vector<Laser_base*> tp_lasers;
-    for(int i=0;i<m_terminor_parameter.laser_parameter_size();++i)
-    {
-        int laser_id=m_terminor_parameter.laser_parameter(i).id();
-        int frame_count=m_terminor_parameter.laser_parameter(i).frame_count();
-        if(frame_count<=0)
-        {
-            LOG(WARNING)<<"terminal parameter laser["<<laser_id<<"] frame count is <0";
-            continue;
-        }
-        if(laser_id>=0&&laser_id<mp_laser_vector.size())
-        {
-            //判断该id的雷达是否已经添加进去, 放置配置中出现重复的雷达编号
-            bool tb_repeat=false;
-            for(int j=0;j<tp_lasers.size();++j)
-            {
-                if(tp_lasers[j]==mp_laser_vector[laser_id])
-                {
-                    tb_repeat=true;
-                    break;
-                }
-            }
-            if(tb_repeat==false)
-            {
-                tp_lasers.push_back(mp_laser_vector[laser_id]);
-                //创建扫描任务,
-                Laser_task* laser_task=new Laser_task();
-                //
-                laser_task->task_init(TASK_CREATED,scan_cloud,&cloud_lock);
-                laser_task->set_task_frame_maxnum(frame_count);
-                laser_task->set_save_path(project_path);
-                laser_task_vector.push_back(laser_task);
-                //发送任务单给雷达
-                code=tp_lasers[i]->execute_task(laser_task);
-                if(code!=SUCCESS)
-                {
-                    return code;
-                }
-            }
-        }
-    }
-    if(tp_lasers.size()==0)
-    {
-        return Error_manager(TERMINOR_NOT_CONTAINS_LASER,NORMAL,"terminal not contains laser");
-    }
-    m_terminor_statu=TERMINOR_SCANNING;
-    //等待雷达完成任务单
-    while(1)
-    {
-        //判断是否强制退出
-        if(mb_force_quit==true)
-        {
-            char description[255]={0};
-            sprintf(description,"ternimal is force quit terminal id : %d",m_terminor_parameter.id());
-            return Error_manager(TERMINOR_FORCE_QUIT,NORMAL,description);
-        }
-        //判断雷达任务单是否全部完成
-        bool tb_laser_complete=true;
-        for(int i=0;i<laser_task_vector.size();++i)
-        {
-            tb_laser_complete &=(TASK_OVER==laser_task_vector[i]->get_statu());
-        }
-        if(tb_laser_complete)
-        {
-            break;
-        }
-        //计算扫描时间,若超时,并且没有点,则返回错误.
-        auto t_end_point=std::chrono::system_clock::now();
-        auto duration=std::chrono::duration_cast<std::chrono::milliseconds>(t_end_point - t_start_point);
-        double second=double(duration.count()) *
-            std::chrono::milliseconds::period::num / std::chrono::milliseconds::period::den;
-        if(second>m_timeout_second)
-        {
-            //扫描超时,点云中没有点,则返回错误
-            if(scan_cloud->size()==0)
-            {
-                return Error_manager(TERMINOR_LASER_TIMEOUT,MAJOR_ERROR,"laser scanning timeout");
-            }
-
-
-        }
-        usleep(1000*100);
-    }
-    //检查雷达任务完成情况,是否是正常完成
-    LOG(INFO)<<" laser scanning over cloud size:"<<scan_cloud->size();
-    //释放扫描任务单
-    for(int i=0;i<laser_task_vector.size();++i)
-    {
-        if(laser_task_vector[i]!=0)
-        {
-            delete laser_task_vector[i];
-            laser_task_vector[i]=NULL;
-        }
-    }
-    //第二步,根据区域筛选点云
-    pcl::PointCloud<pcl::PointXYZ>::Ptr locate_cloud(new pcl::PointCloud<pcl::PointXYZ>);
-    pcl::PassThrough<pcl::PointXYZ> passX;
-    pcl::PassThrough<pcl::PointXYZ> passY;
-    pcl::PassThrough<pcl::PointXYZ> passZ;
-    passX.setInputCloud(scan_cloud);
-    passX.setFilterFieldName("x");
-    passX.setFilterLimits(m_terminor_parameter.area_3d().min_x(),m_terminor_parameter.area_3d().max_x());
-    passX.filter(*locate_cloud);
-
-    passY.setInputCloud(locate_cloud);
-    passY.setFilterFieldName("y");
-    passY.setFilterLimits(m_terminor_parameter.area_3d().min_y(),m_terminor_parameter.area_3d().max_y());
-    passY.filter(*locate_cloud);
-
-    passY.setInputCloud(locate_cloud);
-    passY.setFilterFieldName("z");
-    passY.setFilterLimits(m_terminor_parameter.area_3d().min_z(),m_terminor_parameter.area_3d().max_z());
-    passY.filter(*locate_cloud);
-    LOG(INFO)<<"筛选点云点数 : "<<locate_cloud->size();
-
-    //第三步,创建测量任务, 进入测量中
-    Locate_task* locate_task=new Locate_task();
-    locate_task->set_locate_cloud(locate_cloud);
-    locate_task->set_save_path(project_path);
-    m_terminor_statu=TERMINOR_MEASURING;
-    code=mp_locater->execute_task(locate_task);
-    m_measure_information.locate_correct=false;
-    //获取测量结果
-    Locate_information dj_locate_information=locate_task->get_locate_information();
-    //释放locate task
-    if(locate_task!=NULL)
-    {
-        delete locate_task;
-        locate_task=NULL;
-    }
-    if(code!=SUCCESS)
-    {
-        return code;
-    }
-
-    //进入万集雷达流程--------
-    Wj_lidar_Task* wj_task=new Wj_lidar_Task();
-    code=wj_task->init();
-    if(code!=SUCCESS)
-    {
-        return code;
-    }
-    wj_command t_wj_command;
-    t_wj_command.terminal_id=m_terminor_parameter.id();
-    t_wj_command.command_time=std::chrono::steady_clock::now();
-    t_wj_command.timeout_in_milliseconds=2000;
-    wj_task->set_command(t_wj_command);
-    code=mp_wj_lidar->execute_task(wj_task);
-    if(code!=SUCCESS)
-    {
-        return code;
-    }
-    ///万集测量正确,对比两数据
-    wj_measure_result wj_result;
-    code=wj_task->get_result(wj_result);
-    if(code!=SUCCESS)
-    {
-        return code;
-    }
-    Locate_information wj_locate_information;
-    wj_locate_information.locate_x=wj_result.x;
-    wj_locate_information.locate_y=wj_result.y;
-    wj_locate_information.locate_theta=wj_result.angle;
-    wj_locate_information.locate_wheel_base=wj_result.wheel_base;
-    wj_locate_information.locate_width=wj_result.width;
-    //对比两个数据
-    float offset_x=fabs(dj_locate_information.locate_x-wj_locate_information.locate_x);
-    float offset_y=fabs(dj_locate_information.locate_y-wj_locate_information.locate_y);
-    float offset_angle=fabs(dj_locate_information.locate_theta-wj_locate_information.locate_theta);
-    float offset_width=fabs(dj_locate_information.locate_width-wj_locate_information.locate_width);
-    float offset_wheel_base=fabs(dj_locate_information.locate_width-wj_locate_information.locate_width);
-    if(offset_x>100 ||offset_y>100 ||offset_angle>2 || offset_wheel_base>200 ||offset_width>100)
-    {
-        return Error_manager(TERMINOR_CHECK_RESULTS_ERROR,NORMAL,"check results failed ");
-    }
-    ///根据两个结果选择最优结果,中心点选择万集雷达,角度选择两值加权,轴距已以2750为基准作卡尔曼滤波
-    ///车长以大疆雷达为准,车宽以万集雷达为准,高以大疆雷达为准
-    m_measure_information.locate_x=wj_locate_information.locate_x;
-    m_measure_information.locate_y=wj_locate_information.locate_y;
-    m_measure_information.locate_theta=0.5*(wj_locate_information.locate_theta+dj_locate_information.locate_theta);
-    float dj_distance=fabs(dj_locate_information.locate_wheel_base-2750);
-    float wj_distance=fabs(wj_locate_information.locate_wheel_base-2750);
-    float weight_dj=wj_distance/(dj_distance+wj_distance);
-    float weight_wj=dj_distance/(dj_distance+wj_distance);
-    m_measure_information.locate_wheel_base=weight_dj*dj_locate_information.locate_wheel_base+
-        weight_wj*wj_locate_information.locate_wheel_base;
-    m_measure_information.locate_length=dj_locate_information.locate_length;
-    m_measure_information.locate_width=wj_locate_information.locate_width;
-    m_measure_information.locate_hight=dj_locate_information.locate_hight;
-    m_measure_information.locate_correct=true;
-    ////如果测量正确,检验结果
-    if(mp_verify_tool!=NULL) {
-
-        cv::RotatedRect rotated_rect;
-        rotated_rect.center = cv::Point2f(m_measure_information.locate_x, m_measure_information.locate_y);
-        rotated_rect.angle = m_measure_information.locate_theta;
-        float ext_length=720;
-        float robot_width=2650.0;
-        float new_length=m_measure_information.locate_length+ext_length*2.0;
-        rotated_rect=create_rotate_rect(new_length,robot_width,m_measure_information.locate_theta,
-                                        m_measure_information.locate_x, m_measure_information.locate_y);
-        code = mp_verify_tool->verify(rotated_rect,m_measure_information.locate_hight, false);
-        m_measure_information.locate_correct = (code == SUCCESS);
-        return code;
-
-    }
-
-    return code;
-}
-
-cv::RotatedRect Terminor_Command_Executor::create_rotate_rect(float length,float width,float angle,float cx,float cy)
-{
-    const double C_PI=3.14159265;
-    float theta=C_PI*(angle/180.0);
-    float a00=cos(theta);
-    float a01=-sin(theta);
-    float a10=sin(theta);
-    float a11=cos(theta);
-    cv::Point2f point[4];
-    point[0].x=-length/2.0;
-    point[0].y=-width/2.0;
-
-    point[1].x=-length/2.0;
-    point[1].y=width/2.0;
-
-    point[2].x=length/2.0;
-    point[2].y=-width/2.0;
-
-    point[3].x=length/2.0;
-    point[3].y=width/2.0;
-
-    std::vector<cv::Point2f> point_vec;
-    for(int i=0;i<4;++i)
-    {
-        float x=point[i].x*a00+point[i].y*a01+cx;
-        float y=point[i].x*a10+point[i].y*a11+cy;
-        point_vec.push_back(cv::Point2f(x,y));
-    }
-    return cv::minAreaRect(point_vec);
-}

+ 0 - 116
terminor/terminal_command_executor.h

@@ -1,116 +0,0 @@
-//
-// Created by zx on 2019/12/27.
-//
-
-#ifndef TERMINOR_H
-#define TERMINOR_H
-
-#include "../plc/plc_communicator.h"
-#include "../plc/plc_task.h"
-#include "../laser/Laser.h"
-#include "../locate/locater.h"
-#include "../verify/Verify_result.h"
-#include "../wj_lidar/fence_controller.h"
-#include "Terminor_parameter.pb.h"
-#include <thread>
-/*
- * 终端指令执行状态,枚举
- * 列举终端指令从进入流程到测量完成过程中的进度状态
- */
-enum TerminorStatu
-{
-    TERMINOR_READY=0,           //终端空闲
-    TERMINOR_BUSY,              //接收到指令/被占用
-    TERMINOR_SCANNING,          //终端指令一启动扫描,扫描中
-    TERMINOR_MEASURING,         //终端指令进入测量中
-    TERMINOR_POSTING,           //终端测量完成, 正在上传数据
-    TERMINOR_INVALID           //终端指令执行异常,当出现硬件故障,功能模块bug严重错误时,时为异常状态,
-};
-
-/*
- * 终端指令执行类,执行指令,监控指令执行进度
- * 输入雷达数组,plc对象,测量算法对象,执行扫描测量任务
- */
-class Terminor_Command_Executor
-{
-public:
-    /*
-     * 构造函数
-     * parameter:该终端指令配置参数(待定)
-     */
-    Terminor_Command_Executor(Terminal::Terminor_parameter parameter);
-    ~Terminor_Command_Executor();
-    /*
-     * 获取终端进度状态
-     */
-    TerminorStatu get_terminor_statu();
-    /*
-     * 执行扫描,测量任务,阻塞知道任务完成或超时(单位秒)
-     * 函数体只检测指令是否能执行,并启动线程执行指令,不等待指令完成.
-     *lasers:需要启动的雷达
-     * wj_lidar:万集雷达测量模块
-     * plc:上传结果工具
-     * locater:测量算法对象
-     * verify_tool:结果检验工具,当该参数为NULL时,测量结果不作检验
-     * 返回指令是否启动成功
-     */
-    Error_manager execute_command(std::vector<Laser_base*> lasers,Fence_controller* wj_lidar,
-        Plc_Communicator* plc,
-        Locater* locater,Verify_result* verify_tool,float timeout=15);
-    /*
-     * 强制正在执行的中断指令
-     */
-    Error_manager force_stop_command();
-    /*
-     * 设置保存文件的root路径
-     * 执行指令时会在此路径下,生成日期文件夹,格式为:/root_path/year/month/day/YYYYMMDD-HHMMSS文件夹
-     */
-    void set_save_root_path(std::string root);
-protected:
-
-    static void thread_command_working(Terminor_Command_Executor* terminor);
-    /*
-     * 执行指令流程函数
-     * 扫描
-     * 测量,保存测量结果到成员变量
-     */
-    Error_manager scanning_measuring();
-    /*
-     * 执行上传plc任务
-     * plc终端编号从1开始
-     */
-    Error_manager post_measure_information();
-    /*
-     * 根据长宽,角度,生成cv::RotateRect
-     */
-    static cv::RotatedRect create_rotate_rect(float length,float width,float angle,float x,float y);
-protected:
-    TerminorStatu               m_terminor_statu;
-    //指令流程线程
-    std::thread*                mp_command_thread;
-    //
-    std::mutex                  m_mutex_lock;
-    //保存输入进来的雷达指针
-    std::vector<Laser_base*>    mp_laser_vector;
-    //万集雷达测量模块
-    Fence_controller*           mp_wj_lidar;
-    //plc
-    Plc_Communicator*           mp_plc;
-    //locater*
-    Locater*                    mp_locater;
-    //配置参数
-    Terminal::Terminor_parameter    m_terminor_parameter;
-    //本次指令超时时间 单位秒
-    float                       m_timeout_second;
-    //强制退出标示
-    bool                        mb_force_quit;
-    //保存当前指令测量结果
-    Locate_information          m_measure_information;
-    //保存文件的root目录
-    std::string                 m_save_root_path;
-    //检验结果工具
-    Verify_result*              mp_verify_tool;
-
-};
-
-#endif //TERMINOR_H

Plik diff jest za duży
+ 0 - 1091
terminor/terminor_msg.pb.cc


+ 0 - 796
terminor/terminor_msg.pb.h

@@ -1,796 +0,0 @@
-// Generated by the protocol buffer compiler.  DO NOT EDIT!
-// source: terminor_msg.proto
-
-#ifndef PROTOBUF_terminor_5fmsg_2eproto__INCLUDED
-#define PROTOBUF_terminor_5fmsg_2eproto__INCLUDED
-
-#include <string>
-
-#include <google/protobuf/stubs/common.h>
-
-#if GOOGLE_PROTOBUF_VERSION < 3005000
-#error This file was generated by a newer version of protoc which is
-#error incompatible with your Protocol Buffer headers.  Please update
-#error your headers.
-#endif
-#if 3005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
-#error This file was generated by an older version of protoc which is
-#error incompatible with your Protocol Buffer headers.  Please
-#error regenerate this file with a newer version of protoc.
-#endif
-
-#include <google/protobuf/io/coded_stream.h>
-#include <google/protobuf/arena.h>
-#include <google/protobuf/arenastring.h>
-#include <google/protobuf/generated_message_table_driven.h>
-#include <google/protobuf/generated_message_util.h>
-#include <google/protobuf/metadata.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/repeated_field.h>  // IWYU pragma: export
-#include <google/protobuf/extension_set.h>  // IWYU pragma: export
-#include <google/protobuf/unknown_field_set.h>
-// @@protoc_insertion_point(includes)
-
-namespace protobuf_terminor_5fmsg_2eproto {
-// Internal implementation detail -- do not use these members.
-struct TableStruct {
-  static const ::google::protobuf::internal::ParseTableField entries[];
-  static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
-  static const ::google::protobuf::internal::ParseTable schema[2];
-  static const ::google::protobuf::internal::FieldMetadata field_metadata[];
-  static const ::google::protobuf::internal::SerializationTable serialization_table[];
-  static const ::google::protobuf::uint32 offsets[];
-};
-void AddDescriptors();
-void InitDefaultswj_locate_informationImpl();
-void InitDefaultswj_locate_information();
-void InitDefaultsTerminal_messageImpl();
-void InitDefaultsTerminal_message();
-inline void InitDefaults() {
-  InitDefaultswj_locate_information();
-  InitDefaultsTerminal_message();
-}
-}  // namespace protobuf_terminor_5fmsg_2eproto
-namespace Terminal {
-class Terminal_message;
-class Terminal_messageDefaultTypeInternal;
-extern Terminal_messageDefaultTypeInternal _Terminal_message_default_instance_;
-class wj_locate_information;
-class wj_locate_informationDefaultTypeInternal;
-extern wj_locate_informationDefaultTypeInternal _wj_locate_information_default_instance_;
-}  // namespace Terminal
-namespace Terminal {
-
-// ===================================================================
-
-class wj_locate_information : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:Terminal.wj_locate_information) */ {
- public:
-  wj_locate_information();
-  virtual ~wj_locate_information();
-
-  wj_locate_information(const wj_locate_information& from);
-
-  inline wj_locate_information& operator=(const wj_locate_information& from) {
-    CopyFrom(from);
-    return *this;
-  }
-  #if LANG_CXX11
-  wj_locate_information(wj_locate_information&& from) noexcept
-    : wj_locate_information() {
-    *this = ::std::move(from);
-  }
-
-  inline wj_locate_information& operator=(wj_locate_information&& from) noexcept {
-    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
-      if (this != &from) InternalSwap(&from);
-    } else {
-      CopyFrom(from);
-    }
-    return *this;
-  }
-  #endif
-  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
-    return _internal_metadata_.unknown_fields();
-  }
-  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
-    return _internal_metadata_.mutable_unknown_fields();
-  }
-
-  static const ::google::protobuf::Descriptor* descriptor();
-  static const wj_locate_information& default_instance();
-
-  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
-  static inline const wj_locate_information* internal_default_instance() {
-    return reinterpret_cast<const wj_locate_information*>(
-               &_wj_locate_information_default_instance_);
-  }
-  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
-    0;
-
-  void Swap(wj_locate_information* other);
-  friend void swap(wj_locate_information& a, wj_locate_information& b) {
-    a.Swap(&b);
-  }
-
-  // implements Message ----------------------------------------------
-
-  inline wj_locate_information* New() const PROTOBUF_FINAL { return New(NULL); }
-
-  wj_locate_information* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
-  void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
-  void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
-  void CopyFrom(const wj_locate_information& from);
-  void MergeFrom(const wj_locate_information& from);
-  void Clear() PROTOBUF_FINAL;
-  bool IsInitialized() const PROTOBUF_FINAL;
-
-  size_t ByteSizeLong() const PROTOBUF_FINAL;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
-  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
-      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
-  int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const PROTOBUF_FINAL;
-  void InternalSwap(wj_locate_information* other);
-  private:
-  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
-    return NULL;
-  }
-  inline void* MaybeArenaPtr() const {
-    return NULL;
-  }
-  public:
-
-  ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // required string time = 1 [default = ""];
-  bool has_time() const;
-  void clear_time();
-  static const int kTimeFieldNumber = 1;
-  const ::std::string& time() const;
-  void set_time(const ::std::string& value);
-  #if LANG_CXX11
-  void set_time(::std::string&& value);
-  #endif
-  void set_time(const char* value);
-  void set_time(const char* value, size_t size);
-  ::std::string* mutable_time();
-  ::std::string* release_time();
-  void set_allocated_time(::std::string* time);
-
-  // optional string error = 12 [default = ""];
-  bool has_error() const;
-  void clear_error();
-  static const int kErrorFieldNumber = 12;
-  const ::std::string& error() const;
-  void set_error(const ::std::string& value);
-  #if LANG_CXX11
-  void set_error(::std::string&& value);
-  #endif
-  void set_error(const char* value);
-  void set_error(const char* value, size_t size);
-  ::std::string* mutable_error();
-  ::std::string* release_error();
-  void set_allocated_error(::std::string* error);
-
-  // required bool correctness = 2;
-  bool has_correctness() const;
-  void clear_correctness();
-  static const int kCorrectnessFieldNumber = 2;
-  bool correctness() const;
-  void set_correctness(bool value);
-
-  // optional int32 park_space_id = 3;
-  bool has_park_space_id() const;
-  void clear_park_space_id();
-  static const int kParkSpaceIdFieldNumber = 3;
-  ::google::protobuf::int32 park_space_id() const;
-  void set_park_space_id(::google::protobuf::int32 value);
-
-  // optional double x = 5;
-  bool has_x() const;
-  void clear_x();
-  static const int kXFieldNumber = 5;
-  double x() const;
-  void set_x(double value);
-
-  // optional double y = 6;
-  bool has_y() const;
-  void clear_y();
-  static const int kYFieldNumber = 6;
-  double y() const;
-  void set_y(double value);
-
-  // optional double c = 7;
-  bool has_c() const;
-  void clear_c();
-  static const int kCFieldNumber = 7;
-  double c() const;
-  void set_c(double value);
-
-  // optional double wheel_base = 8;
-  bool has_wheel_base() const;
-  void clear_wheel_base();
-  static const int kWheelBaseFieldNumber = 8;
-  double wheel_base() const;
-  void set_wheel_base(double value);
-
-  // optional double length = 9;
-  bool has_length() const;
-  void clear_length();
-  static const int kLengthFieldNumber = 9;
-  double length() const;
-  void set_length(double value);
-
-  // optional double width = 10;
-  bool has_width() const;
-  void clear_width();
-  static const int kWidthFieldNumber = 10;
-  double width() const;
-  void set_width(double value);
-
-  // optional double height = 11;
-  bool has_height() const;
-  void clear_height();
-  static const int kHeightFieldNumber = 11;
-  double height() const;
-  void set_height(double value);
-
-  // optional int32 laser_ids = 4;
-  bool has_laser_ids() const;
-  void clear_laser_ids();
-  static const int kLaserIdsFieldNumber = 4;
-  ::google::protobuf::int32 laser_ids() const;
-  void set_laser_ids(::google::protobuf::int32 value);
-
-  // @@protoc_insertion_point(class_scope:Terminal.wj_locate_information)
- private:
-  void set_has_time();
-  void clear_has_time();
-  void set_has_correctness();
-  void clear_has_correctness();
-  void set_has_park_space_id();
-  void clear_has_park_space_id();
-  void set_has_laser_ids();
-  void clear_has_laser_ids();
-  void set_has_x();
-  void clear_has_x();
-  void set_has_y();
-  void clear_has_y();
-  void set_has_c();
-  void clear_has_c();
-  void set_has_wheel_base();
-  void clear_has_wheel_base();
-  void set_has_length();
-  void clear_has_length();
-  void set_has_width();
-  void clear_has_width();
-  void set_has_height();
-  void clear_has_height();
-  void set_has_error();
-  void clear_has_error();
-
-  // helper for ByteSizeLong()
-  size_t RequiredFieldsByteSizeFallback() const;
-
-  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
-  ::google::protobuf::internal::HasBits<1> _has_bits_;
-  mutable int _cached_size_;
-  ::google::protobuf::internal::ArenaStringPtr time_;
-  ::google::protobuf::internal::ArenaStringPtr error_;
-  bool correctness_;
-  ::google::protobuf::int32 park_space_id_;
-  double x_;
-  double y_;
-  double c_;
-  double wheel_base_;
-  double length_;
-  double width_;
-  double height_;
-  ::google::protobuf::int32 laser_ids_;
-  friend struct ::protobuf_terminor_5fmsg_2eproto::TableStruct;
-  friend void ::protobuf_terminor_5fmsg_2eproto::InitDefaultswj_locate_informationImpl();
-};
-// -------------------------------------------------------------------
-
-class Terminal_message : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:Terminal.Terminal_message) */ {
- public:
-  Terminal_message();
-  virtual ~Terminal_message();
-
-  Terminal_message(const Terminal_message& from);
-
-  inline Terminal_message& operator=(const Terminal_message& from) {
-    CopyFrom(from);
-    return *this;
-  }
-  #if LANG_CXX11
-  Terminal_message(Terminal_message&& from) noexcept
-    : Terminal_message() {
-    *this = ::std::move(from);
-  }
-
-  inline Terminal_message& operator=(Terminal_message&& from) noexcept {
-    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
-      if (this != &from) InternalSwap(&from);
-    } else {
-      CopyFrom(from);
-    }
-    return *this;
-  }
-  #endif
-  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
-    return _internal_metadata_.unknown_fields();
-  }
-  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
-    return _internal_metadata_.mutable_unknown_fields();
-  }
-
-  static const ::google::protobuf::Descriptor* descriptor();
-  static const Terminal_message& default_instance();
-
-  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
-  static inline const Terminal_message* internal_default_instance() {
-    return reinterpret_cast<const Terminal_message*>(
-               &_Terminal_message_default_instance_);
-  }
-  static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
-    1;
-
-  void Swap(Terminal_message* other);
-  friend void swap(Terminal_message& a, Terminal_message& b) {
-    a.Swap(&b);
-  }
-
-  // implements Message ----------------------------------------------
-
-  inline Terminal_message* New() const PROTOBUF_FINAL { return New(NULL); }
-
-  Terminal_message* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
-  void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
-  void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
-  void CopyFrom(const Terminal_message& from);
-  void MergeFrom(const Terminal_message& from);
-  void Clear() PROTOBUF_FINAL;
-  bool IsInitialized() const PROTOBUF_FINAL;
-
-  size_t ByteSizeLong() const PROTOBUF_FINAL;
-  bool MergePartialFromCodedStream(
-      ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
-  void SerializeWithCachedSizes(
-      ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
-  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
-      bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
-  int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
-  private:
-  void SharedCtor();
-  void SharedDtor();
-  void SetCachedSize(int size) const PROTOBUF_FINAL;
-  void InternalSwap(Terminal_message* other);
-  private:
-  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
-    return NULL;
-  }
-  inline void* MaybeArenaPtr() const {
-    return NULL;
-  }
-  public:
-
-  ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
-
-  // nested types ----------------------------------------------------
-
-  // accessors -------------------------------------------------------
-
-  // @@protoc_insertion_point(class_scope:Terminal.Terminal_message)
- private:
-
-  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
-  ::google::protobuf::internal::HasBits<1> _has_bits_;
-  mutable int _cached_size_;
-  friend struct ::protobuf_terminor_5fmsg_2eproto::TableStruct;
-  friend void ::protobuf_terminor_5fmsg_2eproto::InitDefaultsTerminal_messageImpl();
-};
-// ===================================================================
-
-
-// ===================================================================
-
-#ifdef __GNUC__
-  #pragma GCC diagnostic push
-  #pragma GCC diagnostic ignored "-Wstrict-aliasing"
-#endif  // __GNUC__
-// wj_locate_information
-
-// required string time = 1 [default = ""];
-inline bool wj_locate_information::has_time() const {
-  return (_has_bits_[0] & 0x00000001u) != 0;
-}
-inline void wj_locate_information::set_has_time() {
-  _has_bits_[0] |= 0x00000001u;
-}
-inline void wj_locate_information::clear_has_time() {
-  _has_bits_[0] &= ~0x00000001u;
-}
-inline void wj_locate_information::clear_time() {
-  time_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-  clear_has_time();
-}
-inline const ::std::string& wj_locate_information::time() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.time)
-  return time_.GetNoArena();
-}
-inline void wj_locate_information::set_time(const ::std::string& value) {
-  set_has_time();
-  time_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.time)
-}
-#if LANG_CXX11
-inline void wj_locate_information::set_time(::std::string&& value) {
-  set_has_time();
-  time_.SetNoArena(
-    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
-  // @@protoc_insertion_point(field_set_rvalue:Terminal.wj_locate_information.time)
-}
-#endif
-inline void wj_locate_information::set_time(const char* value) {
-  GOOGLE_DCHECK(value != NULL);
-  set_has_time();
-  time_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
-  // @@protoc_insertion_point(field_set_char:Terminal.wj_locate_information.time)
-}
-inline void wj_locate_information::set_time(const char* value, size_t size) {
-  set_has_time();
-  time_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
-      ::std::string(reinterpret_cast<const char*>(value), size));
-  // @@protoc_insertion_point(field_set_pointer:Terminal.wj_locate_information.time)
-}
-inline ::std::string* wj_locate_information::mutable_time() {
-  set_has_time();
-  // @@protoc_insertion_point(field_mutable:Terminal.wj_locate_information.time)
-  return time_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* wj_locate_information::release_time() {
-  // @@protoc_insertion_point(field_release:Terminal.wj_locate_information.time)
-  clear_has_time();
-  return time_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void wj_locate_information::set_allocated_time(::std::string* time) {
-  if (time != NULL) {
-    set_has_time();
-  } else {
-    clear_has_time();
-  }
-  time_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), time);
-  // @@protoc_insertion_point(field_set_allocated:Terminal.wj_locate_information.time)
-}
-
-// required bool correctness = 2;
-inline bool wj_locate_information::has_correctness() const {
-  return (_has_bits_[0] & 0x00000004u) != 0;
-}
-inline void wj_locate_information::set_has_correctness() {
-  _has_bits_[0] |= 0x00000004u;
-}
-inline void wj_locate_information::clear_has_correctness() {
-  _has_bits_[0] &= ~0x00000004u;
-}
-inline void wj_locate_information::clear_correctness() {
-  correctness_ = false;
-  clear_has_correctness();
-}
-inline bool wj_locate_information::correctness() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.correctness)
-  return correctness_;
-}
-inline void wj_locate_information::set_correctness(bool value) {
-  set_has_correctness();
-  correctness_ = value;
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.correctness)
-}
-
-// optional int32 park_space_id = 3;
-inline bool wj_locate_information::has_park_space_id() const {
-  return (_has_bits_[0] & 0x00000008u) != 0;
-}
-inline void wj_locate_information::set_has_park_space_id() {
-  _has_bits_[0] |= 0x00000008u;
-}
-inline void wj_locate_information::clear_has_park_space_id() {
-  _has_bits_[0] &= ~0x00000008u;
-}
-inline void wj_locate_information::clear_park_space_id() {
-  park_space_id_ = 0;
-  clear_has_park_space_id();
-}
-inline ::google::protobuf::int32 wj_locate_information::park_space_id() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.park_space_id)
-  return park_space_id_;
-}
-inline void wj_locate_information::set_park_space_id(::google::protobuf::int32 value) {
-  set_has_park_space_id();
-  park_space_id_ = value;
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.park_space_id)
-}
-
-// optional int32 laser_ids = 4;
-inline bool wj_locate_information::has_laser_ids() const {
-  return (_has_bits_[0] & 0x00000800u) != 0;
-}
-inline void wj_locate_information::set_has_laser_ids() {
-  _has_bits_[0] |= 0x00000800u;
-}
-inline void wj_locate_information::clear_has_laser_ids() {
-  _has_bits_[0] &= ~0x00000800u;
-}
-inline void wj_locate_information::clear_laser_ids() {
-  laser_ids_ = 0;
-  clear_has_laser_ids();
-}
-inline ::google::protobuf::int32 wj_locate_information::laser_ids() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.laser_ids)
-  return laser_ids_;
-}
-inline void wj_locate_information::set_laser_ids(::google::protobuf::int32 value) {
-  set_has_laser_ids();
-  laser_ids_ = value;
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.laser_ids)
-}
-
-// optional double x = 5;
-inline bool wj_locate_information::has_x() const {
-  return (_has_bits_[0] & 0x00000010u) != 0;
-}
-inline void wj_locate_information::set_has_x() {
-  _has_bits_[0] |= 0x00000010u;
-}
-inline void wj_locate_information::clear_has_x() {
-  _has_bits_[0] &= ~0x00000010u;
-}
-inline void wj_locate_information::clear_x() {
-  x_ = 0;
-  clear_has_x();
-}
-inline double wj_locate_information::x() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.x)
-  return x_;
-}
-inline void wj_locate_information::set_x(double value) {
-  set_has_x();
-  x_ = value;
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.x)
-}
-
-// optional double y = 6;
-inline bool wj_locate_information::has_y() const {
-  return (_has_bits_[0] & 0x00000020u) != 0;
-}
-inline void wj_locate_information::set_has_y() {
-  _has_bits_[0] |= 0x00000020u;
-}
-inline void wj_locate_information::clear_has_y() {
-  _has_bits_[0] &= ~0x00000020u;
-}
-inline void wj_locate_information::clear_y() {
-  y_ = 0;
-  clear_has_y();
-}
-inline double wj_locate_information::y() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.y)
-  return y_;
-}
-inline void wj_locate_information::set_y(double value) {
-  set_has_y();
-  y_ = value;
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.y)
-}
-
-// optional double c = 7;
-inline bool wj_locate_information::has_c() const {
-  return (_has_bits_[0] & 0x00000040u) != 0;
-}
-inline void wj_locate_information::set_has_c() {
-  _has_bits_[0] |= 0x00000040u;
-}
-inline void wj_locate_information::clear_has_c() {
-  _has_bits_[0] &= ~0x00000040u;
-}
-inline void wj_locate_information::clear_c() {
-  c_ = 0;
-  clear_has_c();
-}
-inline double wj_locate_information::c() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.c)
-  return c_;
-}
-inline void wj_locate_information::set_c(double value) {
-  set_has_c();
-  c_ = value;
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.c)
-}
-
-// optional double wheel_base = 8;
-inline bool wj_locate_information::has_wheel_base() const {
-  return (_has_bits_[0] & 0x00000080u) != 0;
-}
-inline void wj_locate_information::set_has_wheel_base() {
-  _has_bits_[0] |= 0x00000080u;
-}
-inline void wj_locate_information::clear_has_wheel_base() {
-  _has_bits_[0] &= ~0x00000080u;
-}
-inline void wj_locate_information::clear_wheel_base() {
-  wheel_base_ = 0;
-  clear_has_wheel_base();
-}
-inline double wj_locate_information::wheel_base() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.wheel_base)
-  return wheel_base_;
-}
-inline void wj_locate_information::set_wheel_base(double value) {
-  set_has_wheel_base();
-  wheel_base_ = value;
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.wheel_base)
-}
-
-// optional double length = 9;
-inline bool wj_locate_information::has_length() const {
-  return (_has_bits_[0] & 0x00000100u) != 0;
-}
-inline void wj_locate_information::set_has_length() {
-  _has_bits_[0] |= 0x00000100u;
-}
-inline void wj_locate_information::clear_has_length() {
-  _has_bits_[0] &= ~0x00000100u;
-}
-inline void wj_locate_information::clear_length() {
-  length_ = 0;
-  clear_has_length();
-}
-inline double wj_locate_information::length() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.length)
-  return length_;
-}
-inline void wj_locate_information::set_length(double value) {
-  set_has_length();
-  length_ = value;
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.length)
-}
-
-// optional double width = 10;
-inline bool wj_locate_information::has_width() const {
-  return (_has_bits_[0] & 0x00000200u) != 0;
-}
-inline void wj_locate_information::set_has_width() {
-  _has_bits_[0] |= 0x00000200u;
-}
-inline void wj_locate_information::clear_has_width() {
-  _has_bits_[0] &= ~0x00000200u;
-}
-inline void wj_locate_information::clear_width() {
-  width_ = 0;
-  clear_has_width();
-}
-inline double wj_locate_information::width() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.width)
-  return width_;
-}
-inline void wj_locate_information::set_width(double value) {
-  set_has_width();
-  width_ = value;
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.width)
-}
-
-// optional double height = 11;
-inline bool wj_locate_information::has_height() const {
-  return (_has_bits_[0] & 0x00000400u) != 0;
-}
-inline void wj_locate_information::set_has_height() {
-  _has_bits_[0] |= 0x00000400u;
-}
-inline void wj_locate_information::clear_has_height() {
-  _has_bits_[0] &= ~0x00000400u;
-}
-inline void wj_locate_information::clear_height() {
-  height_ = 0;
-  clear_has_height();
-}
-inline double wj_locate_information::height() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.height)
-  return height_;
-}
-inline void wj_locate_information::set_height(double value) {
-  set_has_height();
-  height_ = value;
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.height)
-}
-
-// optional string error = 12 [default = ""];
-inline bool wj_locate_information::has_error() const {
-  return (_has_bits_[0] & 0x00000002u) != 0;
-}
-inline void wj_locate_information::set_has_error() {
-  _has_bits_[0] |= 0x00000002u;
-}
-inline void wj_locate_information::clear_has_error() {
-  _has_bits_[0] &= ~0x00000002u;
-}
-inline void wj_locate_information::clear_error() {
-  error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-  clear_has_error();
-}
-inline const ::std::string& wj_locate_information::error() const {
-  // @@protoc_insertion_point(field_get:Terminal.wj_locate_information.error)
-  return error_.GetNoArena();
-}
-inline void wj_locate_information::set_error(const ::std::string& value) {
-  set_has_error();
-  error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
-  // @@protoc_insertion_point(field_set:Terminal.wj_locate_information.error)
-}
-#if LANG_CXX11
-inline void wj_locate_information::set_error(::std::string&& value) {
-  set_has_error();
-  error_.SetNoArena(
-    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
-  // @@protoc_insertion_point(field_set_rvalue:Terminal.wj_locate_information.error)
-}
-#endif
-inline void wj_locate_information::set_error(const char* value) {
-  GOOGLE_DCHECK(value != NULL);
-  set_has_error();
-  error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
-  // @@protoc_insertion_point(field_set_char:Terminal.wj_locate_information.error)
-}
-inline void wj_locate_information::set_error(const char* value, size_t size) {
-  set_has_error();
-  error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
-      ::std::string(reinterpret_cast<const char*>(value), size));
-  // @@protoc_insertion_point(field_set_pointer:Terminal.wj_locate_information.error)
-}
-inline ::std::string* wj_locate_information::mutable_error() {
-  set_has_error();
-  // @@protoc_insertion_point(field_mutable:Terminal.wj_locate_information.error)
-  return error_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline ::std::string* wj_locate_information::release_error() {
-  // @@protoc_insertion_point(field_release:Terminal.wj_locate_information.error)
-  clear_has_error();
-  return error_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
-}
-inline void wj_locate_information::set_allocated_error(::std::string* error) {
-  if (error != NULL) {
-    set_has_error();
-  } else {
-    clear_has_error();
-  }
-  error_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), error);
-  // @@protoc_insertion_point(field_set_allocated:Terminal.wj_locate_information.error)
-}
-
-// -------------------------------------------------------------------
-
-// Terminal_message
-
-#ifdef __GNUC__
-  #pragma GCC diagnostic pop
-#endif  // __GNUC__
-// -------------------------------------------------------------------
-
-
-// @@protoc_insertion_point(namespace_scope)
-
-}  // namespace Terminal
-
-// @@protoc_insertion_point(global_scope)
-
-#endif  // PROTOBUF_terminor_5fmsg_2eproto__INCLUDED

+ 0 - 24
terminor/terminor_msg.proto

@@ -1,24 +0,0 @@
-syntax="proto2";
-package Terminal;
-
-message wj_locate_information
-{
-    required string time=1 [default=""];
-    required bool correctness=2;
-    optional int32 park_space_id=3;
-    optional int32 laser_ids=4;
-
-    optional double x=5;
-    optional double y=6;
-    optional double c=7;
-    optional double wheel_base=8;
-    optional double length=9;
-    optional double width=10;
-    optional double height=11;
-    optional string error=12 [default=""];
-}
-
-message Terminal_message
-{
-
-}

+ 0 - 120
terminor/terminor_uml.wsd

@@ -1,120 +0,0 @@
-@startuml
-title 终端指令执行模块
-
-class Terminor_Command_Executor
-{
-    + * 构造函数()
-    + * parameter:该终端指令配置参数(待定)
-    +Terminor_Command_Executor(Terminal::Terminor_parameter parameter);
-    +~Terminor_Command_Executor();
- 
-    + * 获取终端进度状态()
-    +TerminorStatu get_terminor_statu();
-  
-    + * 执行扫描,测量任务,阻塞知道任务完成或超时(单位秒)()
-    + * 函数体只检测指令是否能执行,并启动线程执行指令,不等待指令完成.()
-    + *lasers:需要启动的雷达()
-    + * wj_lidar:万集雷达测量模块()
-    + * plc:上传结果工具()
-    + * locater:测量算法对象()
-    + * verify_tool:结果检验工具,当该参数为NULL时,测量结果不作检验()
-    + * 返回指令是否启动成功()
-    +Error_manager execute_command(std::vector<Laser_base*> lasers,Fence_controller* wj_lidar,Plc_Communicator* plc,Locater* locater,Verify_result* verify_tool,float timeout=15);
-    
-    + * 强制正在执行的中断指令()
-    +Error_manager force_stop_command();
- 
-    + * 设置保存文件的root路径()
-    + * 执行指令时会在此路径下,生成日期文件夹,格式为:/root_path/year/month/day/YYYYMMDD-HHMMSS文件夹()
-    +void set_save_root_path(std::string root);
-
-    -static void thread_command_working(Terminor_Command_Executor* terminor);
-
-    - * 执行指令流程函数()
-    - * 扫描()
-    - * 测量,保存测量结果到成员变量()
-    -Error_manager scanning_measuring();
-    
-    - * 执行上传plc任务()
-    - * plc终端编号从1开始()
-    
-    -Error_manager post_measure_information();
-    
-    - * 根据长宽,角度,生成cv::RotateRect()
-    -static cv::RotatedRect create_rotate_rect(float length,float width,float angle,float x,float y);
-    
-    -TerminorStatu               m_terminor_statu;
-    -//指令流程线程
-    -std::thread*                mp_command_thread;
-    -//
-    -std::mutex                  m_mutex_lock;
-    -//保存输入进来的雷达指针
-    -std::vector<Laser_base*>    mp_laser_vector;
-    -//万集雷达测量模块
-    -Fence_controller*           mp_wj_lidar;
-    -//plc
-    -Plc_Communicator*           mp_plc;
-    -//locater*
-    -Locater*                    mp_locater;
-    -//配置参数
-    -Terminal::Terminor_parameter    m_terminor_parameter;
-    -//本次指令超时时间 单位秒
-    -float                       m_timeout_second;
-    -//强制退出标示
-    -bool                        mb_force_quit;
-    -//保存当前指令测量结果
-    -Locate_information          m_measure_information;
-    -//保存文件的root目录
-    -std::string                 m_save_root_path;
-    -//检验结果工具
-    -Verify_result*              mp_verify_tool;
-
-}
-note left of Terminor_Command_Executor
-    * 终端指令执行类,
-    * 执行指令,
-    * 监控指令执行进度
-    * 输入雷达数组,plc对象,测量算法对象,执行扫描测量任务
-    * 检验测量结果合法性
-end note
-
-
-class Terminor_parameter
-{
-    +获取配置参数()
-    +从文件流获取配置()
-}
-note bottom of Terminor_parameter
-    * 终端配置类,protobuf格式
-    * 
-end note
-
-
-note bottom of Fence_controller
-    * 电子围栏雷达测量模块
-    * 详见 wj_lidar 模块
-end note
-
-note bottom of Locater
-    * 摆扫/大疆 雷达测量模块
-    * 详见 locate 模块
-end note
-
-note bottom of Plc_Communicator
-    * plc 通讯模块
-    * 详见 plc 模块
-end note
-
-note bottom of Verify_result
-    * verify : 测量结果检验模块
-    * 详见 verify 模块
-end note
-
-Terminor_Command_Executor <-- Terminor_parameter
-Terminor_Command_Executor <-- Fence_controller
-Terminor_Command_Executor <-- Locater
-Terminor_Command_Executor <-- Plc_Communicator
-Terminor_Command_Executor <-- Verify_result
-
-
-@enduml