//
// Created by zx on 2023/10/7.
//
#include <iostream>
#include "log/log.h"
#include "vzense/device_tof3d.h"
#include "communication/rabbitmq_communication.h"

int main(int argc, char * argv[]) {
    // 初始化日志系统
    ZX::InitGlog(PROJECT_NAME, ETC_PATH PROJECT_NAME "/LogInfo/");

    // 初始化相机处理程序
    tof3dManagerParams tof3d_etc;
    if (loadProtobufFile(ETC_PATH PROJECT_NAME "/tof3d_manager.json", tof3d_etc) == SUCCESS) {
        LOG(INFO) << tof3d_etc.DebugString();
    } else {
        LOG(WARNING) << "tof3dManager read param form %s error.", ETC_PATH PROJECT_NAME "/tof3d_manager.json";
        return EXIT_FAILURE;
    }

    auto list = tof3d_etc.vzense_tof3d_devices();
    std::map<std::string, tof3dVzenseEtc> device_mp;
    for (auto &device: tof3d_etc.vzense_tof3d_devices()) {
        device_mp.insert(std::pair<std::string, tof3dVzenseEtc>(device.ip(), device));
    }

    DeviceTof3D::iter()->Init(device_mp, true);

    /*LOG(INFO) << "begain init rabbitmq.";
    auto ret = RabbitmqCommunicationTof3D::get_instance_references().rabbitmq_init_from_protobuf(ETC_PATH"Tof3d/rabbitmq.prototxt");
    if (ret != SUCCESS) {
        LOG(ERROR) << "system communication mq init failed: " << ret.to_string();
        return -1;
    }
    RabbitmqCommunicationTof3D::get_instance_references().set_encapsulate_status_cycle_time(100);
*/

    while (1) {
        usleep(2000 * 1000);
    }
    return EXIT_SUCCESS;
}
