Ver código fonte

20211215, communication dispatch add bind 192.168.1.233:30030~30032

huli 3 anos atrás
pai
commit
235a3a2aff

+ 3 - 0
communication/communication_socket_base.h

@@ -35,6 +35,9 @@
 
 
 #define COMMUNICATION_PARAMETER_PATH "../setting/communication.prototxt"
+#define COMMUNICATION_PARAMETER_PATH_A "../setting/communication_a.prototxt"
+#define COMMUNICATION_PARAMETER_PATH_B "../setting/communication_b.prototxt"
+#define COMMUNICATION_PARAMETER_PATH_C "../setting/communication_c.prototxt"
 
 class Communication_socket_base
 {

+ 8 - 1
main.cpp

@@ -108,7 +108,14 @@ int main(int argc,char* argv[])
 
 	System_executor::get_instance_references().system_executor_init(10);
 	std::cout << "System_executor = " << System_executor::get_instance_references().get_system_executor_status() << std::endl;
-	System_communication::get_instance_references().communication_init();
+	if ( argc == 2 )
+	{
+		System_communication::get_instance_references().communication_init(t_id);
+	}
+	else
+	{
+		System_communication::get_instance_references().communication_init();
+	}
 	System_communication::get_instance_references().set_encapsulate_cycle_time(1000);
 
 //20210922

+ 35 - 0
system/system_communication.cpp

@@ -17,6 +17,41 @@ System_communication::~System_communication()
 
 }
 
+//初始化 通信 模块。如下三选一
+Error_manager System_communication::communication_init()
+{
+	return Communication_socket_base::communication_init();
+}
+
+//初始化 通信 模块。如下三选一
+Error_manager System_communication::communication_init(int dispatch_id)
+{
+	switch ( dispatch_id )
+	{
+		case 0:
+		{
+			return Communication_socket_base::communication_init_from_protobuf(COMMUNICATION_PARAMETER_PATH_A);
+			break;
+		}
+		case 1:
+		{
+			return Communication_socket_base::communication_init_from_protobuf(COMMUNICATION_PARAMETER_PATH_B);
+			break;
+		}
+		case 2:
+		{
+			return Communication_socket_base::communication_init_from_protobuf(COMMUNICATION_PARAMETER_PATH_C);
+			break;
+		}
+		default:
+		{
+			return Error_manager(Error_code::COMMUNICATION_READ_PROTOBUF_ERROR, Error_level::MINOR_ERROR,
+								 " System_communication::communication_init dispatch_id error ");
+			break;
+		}
+	}
+	return Error_code::SUCCESS;
+}
 
 //检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
 Error_manager System_communication::check_msg(Communication_message*  p_msg)

+ 3 - 0
system/system_communication.h

@@ -22,6 +22,9 @@ public:
     System_communication& operator =(const System_communication& other) = delete;
     ~System_communication();
 public://API functions
+	//初始化 通信 模块。如下三选一
+	virtual Error_manager communication_init();
+	virtual Error_manager communication_init(int dispatch_id);
 	//检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
 	virtual Error_manager check_msg(Communication_message* p_msg);
 	//检查执行者的状态, 判断能否处理这条消息, 需要子类重载