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.
376 lines
19 KiB
376 lines
19 KiB
#pragma once
|
|
#include <fstream>
|
|
#include <functional>
|
|
#include <iostream>
|
|
#include <list>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <set>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "xsync_errcode.hpp"
|
|
#include "xsync_v2_sig_type.hpp"
|
|
namespace xsync {
|
|
using namespace std;
|
|
|
|
typedef function<void(XsyncTimecode_t *timecode_msg)> xsync_on_timecode_msg_t;
|
|
typedef function<void(uint32_t recordSig, XsyncTimecode_t *timecode_msg)> xsync_on_record_sig_change_msg_t;
|
|
typedef function<void(bool state, string targetIp)> xsync_on_connect_state_change_t;
|
|
typedef function<void(xysnc_camera_sync_data_t *timecode_msg)> xsync_on_camera_sync_msg_t;
|
|
|
|
typedef struct {
|
|
bool listenCameraSyncPacket;
|
|
} xsync_config_t;
|
|
|
|
typedef struct {
|
|
uint32_t main;
|
|
uint32_t sub;
|
|
uint32_t fix;
|
|
} version_t;
|
|
|
|
class IXsync {
|
|
public:
|
|
virtual ~IXsync() {}
|
|
|
|
public:
|
|
virtual xs_error_code_t initialize(xsync_config_t *config) = 0;
|
|
|
|
virtual bool ping() = 0;
|
|
virtual bool getConnectState() = 0;
|
|
virtual string getDeviceIp() = 0;
|
|
|
|
/*******************************************************************************
|
|
* 网络配置 *
|
|
*******************************************************************************/
|
|
|
|
/**
|
|
* @brief
|
|
* 注意事项:
|
|
* 1. 网络配置完成后需要调用storageConfig才会持久化
|
|
* 2. 网络配置,需要在设备重启后生效,设备软重启可以调用reboot方法
|
|
*/
|
|
|
|
virtual xs_error_code_t NetworkConfig_setMode(NetworkMode_t mode) = 0;
|
|
virtual xs_error_code_t NetworkConfig_getMode(NetworkMode_t &mode) = 0;
|
|
|
|
virtual xs_error_code_t NetworkConfigStaticIpMode_setIp(string ip) = 0;
|
|
virtual xs_error_code_t NetworkConfigStaticIpMode_setMask(string mask) = 0;
|
|
virtual xs_error_code_t NetworkConfigStaticIpMode_setGateway(string gateway) = 0;
|
|
|
|
virtual xs_error_code_t NetworkConfigStaticIpMode_getIp(string &ip) = 0;
|
|
virtual xs_error_code_t NetworkConfigStaticIpMode_getMask(string &mask) = 0;
|
|
virtual xs_error_code_t NetworkConfigStaticIpMode_getGateway(string &gateway) = 0;
|
|
|
|
/*******************************************************************************
|
|
* 事件回调函数注册 *
|
|
*******************************************************************************/
|
|
virtual void registerOnTimecodeMsgCallback(xsync_on_timecode_msg_t cb) = 0; // timecode 回调
|
|
virtual void registerOnCameraSyncMsgCallback(xsync_on_camera_sync_msg_t cb) = 0; // 相机同步包 回调
|
|
virtual void registerOnRecordSigChangeMsgCallback(xsync_on_record_sig_change_msg_t cb) = 0; // 录制信号变化 回调
|
|
virtual void registerOnConnectStateChangeCallback(xsync_on_connect_state_change_t cb) = 0; // 连接状态变化 回调
|
|
|
|
/*******************************************************************************
|
|
* 设备基本操作 *
|
|
*******************************************************************************/
|
|
virtual xs_error_code_t generatorNewMac() = 0;
|
|
virtual xs_error_code_t factoryReset() = 0;
|
|
virtual xs_error_code_t reboot() = 0;
|
|
virtual xs_error_code_t readSn(string &sn) = 0;
|
|
virtual xs_error_code_t readMac(string &mac) = 0;
|
|
virtual xs_error_code_t storageConfig() = 0;
|
|
|
|
virtual xs_error_code_t readSDKVersion(version_t &version) = 0;
|
|
virtual xs_error_code_t readARMSoftwareVersion(version_t &version) = 0;
|
|
virtual xs_error_code_t readFPGASoftwareVersion(version_t &version) = 0;
|
|
|
|
// virtual xs_error_code_t changeNetworkConfig(string ip, string mask, string gateway) = 0;
|
|
|
|
public:
|
|
virtual xs_error_code_t reg_write(uint32_t regadd, uint32_t regvalue, uint32_t ®backvalue, int32_t overtime_ms = 100) = 0;
|
|
virtual xs_error_code_t reg_read(uint32_t regadd, uint32_t ®value, int32_t overtime_ms = 100) = 0;
|
|
|
|
public:
|
|
/*******************************************************************************
|
|
* 延时控制 *
|
|
*******************************************************************************/
|
|
|
|
virtual xs_error_code_t DelayContrl_setInputDelay(uint32_t delay_us) = 0;
|
|
virtual xs_error_code_t DelayContrl_getInputDelay(uint32_t &delay_us) = 0;
|
|
|
|
virtual xs_error_code_t DelayContrl_setOutputDelay(uint32_t delay_us) = 0;
|
|
virtual xs_error_code_t DelayContrl_getOutputDelay(uint32_t &delay_us) = 0;
|
|
|
|
/***********************************************************************************************
|
|
* 输入组件 *
|
|
***********************************************************************************************/
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
* 概述: 输入组件一共3组,对应着设备上的3组输入接口
|
|
* TTLInputModule1_XXXXX: TTL1_IN
|
|
* TTLInputModule2_XXXXX: TTL2_IN
|
|
* TTLInputModule3_XXXXX: TTL3_IN
|
|
* TTLInputModule4_XXXXX: 隔离输入口
|
|
*
|
|
* ExternalTimecode_XXXXX : BNC时码输入口 和 耳机时码输入口
|
|
*
|
|
* ExternalGenlock_XXXXX : GENLOCK输入口
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* 使用注意事项:
|
|
* 除了外部时码使用前,需要先对其进行配置,其他输入组件均无需配置即可直接使用
|
|
*
|
|
* ExternalTimecode_setSource
|
|
* 方法说明:设置时间码输入源
|
|
* 参数范围:
|
|
* INPUT_IF_TIMECODE_BNC
|
|
* INPUT_IF_TIMECODE_HEADPHONE
|
|
*
|
|
*
|
|
* ExternalTimecode_setFormat
|
|
* 方法说明:设置时间码输入格式
|
|
* 参数范围:
|
|
* TIMECODE_FPS2398
|
|
* TIMECODE_FPS2400
|
|
* TIMECODE_FPS2500
|
|
* TIMECODE_FPS2997
|
|
* TIMECODE_FPS2997Drop
|
|
* TIMECODE_FPS3000
|
|
*
|
|
*
|
|
* TTLInputModuleX_detectFreq
|
|
* 方法说明:探测TTL输入频率
|
|
*
|
|
* ExternalGenlock_detectFreq
|
|
* 方法说明:探测GENLOCK信号频率
|
|
*
|
|
*/
|
|
|
|
virtual xs_error_code_t ExternalTimecode_readSrc(InputInterface_t &timecode) = 0;
|
|
virtual xs_error_code_t ExternalTimecode_readCode(XsyncTimecode_t &timecode) = 0;
|
|
virtual xs_error_code_t ExternalTimecode_readFreq(float &freq) = 0;
|
|
virtual xs_error_code_t ExternalTimecode_readFormat(TimecodeFormat_t &timecode) = 0;
|
|
|
|
virtual xs_error_code_t TTLInputModule1_detectFreq(float &freq) = 0;
|
|
virtual xs_error_code_t TTLInputModule2_detectFreq(float &freq) = 0;
|
|
virtual xs_error_code_t TTLInputModule3_detectFreq(float &freq) = 0;
|
|
virtual xs_error_code_t TTLInputModule4_detectFreq(float &freq) = 0;
|
|
|
|
virtual xs_error_code_t ExternalGenlock_detectFreq(float &freq) = 0;
|
|
|
|
/***********************************************************************************************
|
|
* 内部时钟源 *
|
|
***********************************************************************************************/
|
|
/**
|
|
* @brief
|
|
*
|
|
* 概述: 内部组件一共7组
|
|
* InternalTimecode_XXXXX : 内部时码
|
|
* InternalGenlock_XXXXX : 内部同步信号
|
|
* InternalClock_XXXXX : 内部时钟
|
|
*
|
|
* SysTimecode_XXXXX : 系统时码
|
|
* SysGenlock_XXXXX : 系统同步信号
|
|
* SysClock_XXXXX : 系统时钟
|
|
*
|
|
*
|
|
*
|
|
* 概念说明:
|
|
* Xsync系统中一共有三个比较重要概念,时码,Genlock,系统时钟。内部时码,内部Genlock,内部时钟是指
|
|
* 设备内部自己产生的时码,Genlock,时钟。外部时码,外部Genlock,是指设备外部输入的时码,Genlock。
|
|
* 系统时码,系统Genlock,系统时钟,和他们的关系如下。
|
|
*
|
|
*
|
|
* 外部时码 ---|1
|
|
* 内部时码 ---|0 ----> 系统时码
|
|
*
|
|
*
|
|
* 外部Genlock ---|1
|
|
* 内部Genlock ---|0 ----> 系统Genlock
|
|
*
|
|
*
|
|
* 系统时码的频率信号 ---|
|
|
* 系统Genlock ---|
|
|
* 内部时钟 ---| ----> 系统时钟
|
|
* 外部TTL输入信号 ---|
|
|
* 外部隔离输入信号 ---|
|
|
*
|
|
*
|
|
* 注意事项:
|
|
* 1. 内部时码,内部Genlock,内部时钟,默认自启动无需配置。当需要修改其制式或者频率,调用相应的API进行修改。
|
|
* 2. 系统时码,系统Genlock,系统时钟,其对应的输入源默认选择,内部时码,内部Genlock,内部时钟。所以无需配置,其默认也是生效的。
|
|
* 3. 系统时钟支持,分频,倍频,触发边沿,输入输出频率控制。
|
|
*
|
|
*
|
|
*/
|
|
|
|
virtual xs_error_code_t InternalSigSrouce_start() = 0;
|
|
virtual xs_error_code_t InternalSigSrouce_stop() = 0;
|
|
virtual xs_error_code_t InternalSigSrouce_readState(bool &en) = 0;
|
|
|
|
virtual xs_error_code_t InternalTimecode_setFormat(TimecodeFormat_t format) = 0;
|
|
virtual xs_error_code_t InternalTimecode_getFormat(TimecodeFormat_t &format) = 0;
|
|
virtual xs_error_code_t InternalTimecode_setCode(XsyncTimecode_t timecode) = 0;
|
|
virtual xs_error_code_t InternalTimecode_getCode(XsyncTimecode_t &timecode) = 0;
|
|
virtual xs_error_code_t InternalTimecode_readFreq(float &freq) = 0;
|
|
|
|
virtual xs_error_code_t InternalGenlock_setFormat(GenlockFormat_t format) = 0;
|
|
virtual xs_error_code_t InternalGenlock_getFormat(GenlockFormat_t &format) = 0;
|
|
virtual xs_error_code_t InternalGenlock_readFreq(float &freq) = 0;
|
|
|
|
virtual xs_error_code_t InternalClock_setFreq(float freq) = 0;
|
|
virtual xs_error_code_t InternalClock_getFreq(float &freq) = 0;
|
|
virtual xs_error_code_t InternalClock_readOutFreq(float &freq) = 0;
|
|
|
|
/*******************************************************************************
|
|
* 系统时钟源 *
|
|
*******************************************************************************/
|
|
|
|
virtual xs_error_code_t SysTimecode_setSource(uint32_t sig) = 0;
|
|
virtual xs_error_code_t SysTimecode_getSource(uint32_t &sig) = 0;
|
|
virtual xs_error_code_t SysTimecode_readFormat(TimecodeFormat_t &format) = 0;
|
|
virtual xs_error_code_t SysTimecode_readCode(XsyncTimecode_t &timecode) = 0;
|
|
virtual xs_error_code_t SysTimecode_readFreq(float &freq) = 0;
|
|
|
|
virtual xs_error_code_t SysGenlock_setSrc(uint32_t source) = 0;
|
|
virtual xs_error_code_t SysGenlock_getSrc(uint32_t &source) = 0;
|
|
virtual xs_error_code_t SysGenlock_readFreq(float &freq) = 0;
|
|
|
|
virtual xs_error_code_t SysClock_setSrc(SignalType_t sig) = 0;
|
|
virtual xs_error_code_t SysClock_getSrc(SignalType_t &sig) = 0;
|
|
virtual xs_error_code_t SysClock_setTriggerEdge(TriggerEdge_t edge) = 0;
|
|
virtual xs_error_code_t SysClock_getTriggerEdge(TriggerEdge_t &edge) = 0;
|
|
virtual xs_error_code_t SysClock_setFreqDivision(uint32_t div) = 0;
|
|
virtual xs_error_code_t SysClock_geFreqtDivision(uint32_t &div) = 0;
|
|
virtual xs_error_code_t SysClock_setFreqMultiplication(uint32_t muti) = 0;
|
|
virtual xs_error_code_t SysClock_getFreqMultiplication(uint32_t &muti) = 0;
|
|
virtual xs_error_code_t SysClock_readOutSigFreq(float &freq) = 0;
|
|
virtual xs_error_code_t SysClock_readInSigFreq(float &freq) = 0;
|
|
|
|
/***********************************************************************************************
|
|
* 录制信号发生器 *
|
|
***********************************************************************************************/
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
* 概述:
|
|
* 录制信号发生器可以产生,录制使能信号,拍摄曝光信号,两种信号。其启动方式支持,手动启动,
|
|
* TimeCode启动,外部TTL触发启动三种方式。通过RecordSigGenerator_setContrlMode可以设置。
|
|
*
|
|
* 手动控制:
|
|
*
|
|
* 如果是手动启动,先通过RecordSigGenerator_setContrlMode将模式配置成CONTROLMODE_MANUAL_TRIGGER,
|
|
* 然后直接调用下面两个方法即可
|
|
* RecordSigGenerator_manualStart
|
|
* RecordSigGenerator_manualStop
|
|
*
|
|
*
|
|
* Timecode控制:
|
|
*
|
|
* 如果是Timecode控制启动,先通过RecordSigGenerator_setContrlMode将模式配置成CONTROLMODE_TIMECODE_TRIGGER。
|
|
* 然后可以调用下面几个方法进行配置即可。可通过RecordSigGenerator_setTimecodeCtrlFlag方法,只使能Timecode自动控制
|
|
* 启动,或者只使能Timecode自动控制停止。
|
|
* RecordSigGenerator_setAutoStartTimecode :配置自动启动的时间点
|
|
* RecordSigGenerator_setAutoStopTimecode :配置自动停止的时间点
|
|
* RecordSigGenerator_setTimecodeCtrlFlag :配置是否使能自动启动,或者自动停止,默认配置是二者都使能的。
|
|
*
|
|
* 外部TTL控制:
|
|
*
|
|
* 如果是外部TTL触发启动,先通过RecordSigGenerator_setContrlMode将模式配置成CONTROLMODE_EXTERNALTTL_TRIGGER。
|
|
* 然后调用下面几个方法进行配置。
|
|
* RecordSigGenerator_setExternalTTLTriggerSrc : 配置外部TTL触发源(输入范围INPUT_IF_TTL1->INPUT_IF_TTL4)
|
|
* RecordSigGenerator_setExternalTTLTriggerPolarity : 配置触发电平(0:低电平,1:高电平)
|
|
*
|
|
*
|
|
* 该模块输出的拍摄曝光信号,可以通过下面两个方法,设置曝光时间,曝光偏移时间。
|
|
* RecordSigGenerator_setRecordExposureTime
|
|
* RecordSigGenerator_setRecordExposureOffsetTime
|
|
*
|
|
*
|
|
*/
|
|
|
|
virtual xs_error_code_t RecordSigGenerator_setContrlMode(ControlMode_t mode) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_getContrlMode(ControlMode_t &mode) = 0;
|
|
//------------------------------manual contrl mode-----------------------------------
|
|
virtual xs_error_code_t RecordSigGenerator_manualStart() = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_manualStop() = 0;
|
|
//------------------------------timecode contrl mode---------------------------------
|
|
virtual xs_error_code_t RecordSigGenerator_setAutoStartTimecode(XsyncTimecode_t timecode) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_setAutoStopTimecode(XsyncTimecode_t timecode) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_getAutoStartTimecode(XsyncTimecode_t &timecode) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_getAutoStopTimecode(XsyncTimecode_t &timecode) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_setTimecodeCtrlFlag(uint32_t autoStart, uint32_t autoStop) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_getTimecodeCtrlFlag(uint32_t &autoStart, uint32_t &autoStop) = 0;
|
|
//------------------------------ttl level and edge contrl mode--------------------------------------
|
|
virtual xs_error_code_t RecordSigGenerator_setExternalTTLTriggerSrc(InputInterface_t ttlPortNum) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_getExternalTTLTriggerSrc(InputInterface_t &ttlPortNum) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_setExternalTTLTriggerPolarity(uint32_t polarity) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_getExternalTTLTriggerPolarity(uint32_t &polarity) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_setTriggerEdge(TriggerEdge_t edge) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_getTriggerEdge(TriggerEdge_t &edge) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_getRecordState(uint32_t &state) = 0;
|
|
virtual xs_error_code_t RecordSigGenerator_readTimecodeSnapshot(XsyncTimecode_t &timecode) = 0;
|
|
|
|
/***********************************************************************************************
|
|
* 输出组件 *
|
|
***********************************************************************************************/
|
|
|
|
/**
|
|
* @brief 输入组件一共有4组,TTL,Timecode,Genlock,网口,其中只有TTL输出(包含隔离输出)需要对齐进行配置。
|
|
*
|
|
*
|
|
* TTL输出组件
|
|
* 信号源选择范围:
|
|
* SIGNAL_LOGIC0
|
|
* SIGNAL_LOGIC1
|
|
* SIGNAL_TTLIN1
|
|
* SIGNAL_TTLIN2
|
|
* SIGNAL_TTLIN3
|
|
* SIGNAL_TTLIN4
|
|
* SIGNAL_SYS_CLK_OUTPUT
|
|
* SIGNAL_SYS_GENLOCK_OUTPUT
|
|
* SIGNAL_SYS_TIMECODE_FREQ_OUTPUT
|
|
* SIGNAL_BUSINESS_RECORD_SIG
|
|
* SIGNAL_BUSINESS_RECORD_EXPOSURE_SIG
|
|
*
|
|
* 分频倍频:
|
|
* 当信号源是 SIGNAL_BUSINESS_RECORD_SIG 或者 SIGNAL_BUSINESS_RECORD_EXPOSURE_SIG 分频倍频不启作用,
|
|
* 直接输出原始信号。当信号源是其他信号源时,分频倍频起作用。分频输入参数为0时,为不分频,1时,为2分频。倍频
|
|
* 输入参数为0时,为不倍频,1时,为2倍频。
|
|
*
|
|
*
|
|
*/
|
|
|
|
virtual xs_error_code_t TTLOutputModule_setSrcSigType(int index, SignalType_t source) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_getSrcSigType(int index, SignalType_t &source) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_setFreqDivision(int index, uint32_t div) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_getFreqDivision(int index, uint32_t &div) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_setFreqMultiplication(int index, uint32_t multi) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_getFreqMultiplication(int index, uint32_t &multi) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_readOutFreq(int index, float &freq) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_readInFreq(int index, float &freq) = 0;
|
|
|
|
virtual xs_error_code_t TTLOutputModule_setPolarity(int index, uint32_t polarity) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_getPolarity(int index, uint32_t &polarity) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_setTriggerEdge(int index, TriggerEdge_t edge) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_getTriggerEdge(int index, TriggerEdge_t &edge) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_setPluseWidth(int index, uint32_t us) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_getPluseWidth(int index, uint32_t &us) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_setOffsetTime(int index, uint32_t us) = 0;
|
|
virtual xs_error_code_t TTLOutputModule_getOffsetTime(int index, uint32_t &us) = 0;
|
|
|
|
/*******************************************************************************
|
|
* 工具方法 *
|
|
*******************************************************************************/
|
|
|
|
virtual xs_error_code_t Utils_readSigFreq(SignalType_t sig, float &freq) = 0;
|
|
};
|
|
|
|
} // namespace xsync
|