You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.4 KiB
88 lines
2.4 KiB
#pragma once
|
|
#include <fstream>
|
|
#include <functional>
|
|
#include <iostream>
|
|
#include <list>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <set>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <vector>
|
|
//
|
|
#include "i_xsync_udp.hpp"
|
|
#include "iflytop_xsync_protocol/iflytop_xsync_protocol.h"
|
|
#include "xsync_errcode.hpp"
|
|
namespace iflytop {
|
|
using namespace std;
|
|
|
|
typedef enum {
|
|
kxsync_net_state_disconnect,
|
|
kxsync_net_state_connecting,
|
|
kxsync_net_state_connected,
|
|
} xsync_net_state_t;
|
|
|
|
typedef struct {
|
|
uint8_t hour;
|
|
uint8_t minute;
|
|
uint8_t second;
|
|
uint8_t frame;
|
|
} xysnc_timecode_t;
|
|
|
|
typedef struct {
|
|
uint32_t frameIndex;
|
|
} xysnc_camera_sync_data_t;
|
|
|
|
typedef function<void(xysnc_timecode_t *timecode_msg)> xsync_on_timecode_msg_t;
|
|
typedef function<void(xysnc_camera_sync_data_t *timecode_msg)> xsync_on_camera_sync_msg_t;
|
|
|
|
class Xsync {
|
|
public:
|
|
private:
|
|
/* data */
|
|
|
|
I_XSUDPFactory *m_xsync_udp_factory = nullptr;
|
|
shared_ptr<I_XSUDP> m_xsync_reg_udp = nullptr;
|
|
shared_ptr<I_XSUDP> m_xsync_timecode_udp_listener = nullptr;
|
|
shared_ptr<I_XSUDP> m_xsync_camera_sync_udp_listener = nullptr;
|
|
|
|
string m_xsync_ip;
|
|
bool m_is_connected = false;
|
|
|
|
xsync_on_camera_sync_msg_t m_on_camera_sync_msg_cb = nullptr;
|
|
xsync_on_timecode_msg_t m_on_timecode_msg_cb = nullptr;
|
|
|
|
int txpacket_index = 0;
|
|
|
|
uint8_t m_xync_cmd_rxdata_cache[2560];
|
|
|
|
xsync_net_state_t m_net_state = kxsync_net_state_disconnect;
|
|
|
|
Xsync(/* args */);
|
|
|
|
public:
|
|
static Xsync &Ins();
|
|
|
|
void initialize(I_XSUDPFactory *xsync_udp_factory);
|
|
|
|
bool ping(string xsync_ip);
|
|
|
|
void connect(string xsync_ip);
|
|
void disConnect();
|
|
xsync_net_state_t getNetState();
|
|
|
|
void regOnTimecodeMsg(xsync_on_timecode_msg_t on_timecode_msg_cb);
|
|
void regOnCameraSyncMsg(xsync_on_camera_sync_msg_t on_camera_sync_msg_cb);
|
|
|
|
xs_error_code_t reg_write(uint32_t regadd, uint32_t regvalue);
|
|
xs_error_code_t reg_read(uint32_t regadd, uint32_t ®value);
|
|
xs_error_code_t reg_read_muti(uint32_t regadd, uint32_t nreg, vector<uint32_t> ®values);
|
|
|
|
xs_error_code_t xsync_send_cmd_block(iflytop_xsync_packet_header_t *cmd, iflytop_xsync_packet_header_t *rx_data, int32_t buffersize);
|
|
|
|
private:
|
|
void parseTimecodeMsgAndReport(XsyncNetAdd &from, uint8_t *data, size_t length);
|
|
void parseCameraSyncMsgAndReport(XsyncNetAdd &from, uint8_t *data, size_t length);
|
|
};
|
|
|
|
} // namespace iflytop
|