12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /*
- * @Description: 测试车位分配模块通信情况
- * @Author: yct
- * @Date: 2020-07-08 15:51:46
- * @LastEditTime: 2020-07-22 14:17:07
- * @LastEditors: yct
- */
- #include "../parkspace_allocation/parkspace_allocation_communicator.h"
- #include "../parkspace_allocation/parkspace_allocator.h"
- int main()
- {
- google::InitGoogleLogging("parkspace_allocator");
- google::SetStderrLogging(google::INFO);
- google::InstallFailureSignalHandler();
- FLAGS_colorlogtostderr = true;
- Parkspace_allocation_communicator *p_parkspace_allocation_communicater = Parkspace_allocation_communicator::get_instance_pointer();
- Parkspace_allocator *p_parkspace_allocator = Parkspace_allocator::get_instance_pointer();
- parkspace_proto::database_config config;
- config.set_db_ip("127.0.0.1");
- config.set_db_port(3306);
- config.set_db_username("yct");
- config.set_db_passwd("123456");
- config.set_db_name("test");
- config.set_db_conn_pool_size(5);
- p_parkspace_allocator->parkspace_allocator_init(4, config);
- p_parkspace_allocation_communicater->communication_bind("tcp://127.0.0.1:7001");
- // p_parkspace_allocation_communicater->communication_bind("tcp://192.168.2.125:7001");
- // p_parkspace_allocation_communicater->communication_connect("tcp://127.0.0.1:7000");
- p_parkspace_allocation_communicater->communication_run();
- // // 初始化车位,创建三个车位
- // message::Parkspace_allocation_status_msg parkspace_status;
- // for (size_t i = 1; i < 1000; i++)
- // {
- // message::Parkspace_info* space = parkspace_status.add_parkspace_info();
- // space->set_parkspace_id(i);
- // space->set_index(i);
- // space->set_direction(message::Direction::eForward);
- // space->set_floor(2+i);
- // space->set_length(5.5);
- // space->set_width(2.2);
- // space->set_height(1.75);
- // space->set_parkspace_status(message::Parkspace_status::eParkspace_empty);
- // }
- // message::Base_info base_msg;
- // message::Error_manager error;
- // base_msg.set_msg_type(message::Message_type::eParkspace_allocation_response_msg);
- // base_msg.set_timeout_ms(1000);
- // base_msg.set_sender(message::Communicator::eParkspace);
- // base_msg.set_receiver(message::Communicator::eMain);
- // error.set_error_code(0);
- // parkspace_status.mutable_base_info()->CopyFrom(base_msg);
- // parkspace_status.mutable_error_manager()->CopyFrom(error);
- // p_parkspace_allocation_communicater->update_parkspace_status(parkspace_status);
- int k=1;
- while(1) {
- // message::Parkspace_info space;
- // space.set_parkspace_id(3);
- // space.set_index(k);
- // space.set_direction(message::Direction::eForward);
- // space.set_floor(k*3);
- // space.set_length(5500);
- // space.set_width(2200);
- // space.set_height(k*400);
- // space.set_parkspace_status(message::Parkspace_status::eParkspace_occupied);
- // p_parkspace_allocator->update_parkspace_status(3, space);
- usleep(1000*1000);
- k++;
- }
- p_parkspace_allocator->parkspace_allocator_uninit();
- return 0;
- }
|