Browse Source

update

xsync_v2
zhaohe 1 year ago
parent
commit
776c27df7f
  1. 2
      xsync.cpp
  2. 6
      xsync.hpp
  3. 0
      xsync_v2.cpp
  4. 576
      xsync_v2.hpp
  5. 576
      xsync_v2_sdk/xsync_v2.hpp
  6. 189
      xsync_v2_sdk/xsync_v2_sig_type.hpp
  7. 210
      xsync_v2_sig_type.cpp
  8. 189
      xsync_v2_sig_type.hpp

2
xsync.cpp

@ -75,7 +75,7 @@ static map<string, TriggerSigType_t> TriggerSigType2StrMap = {
{"ttlin3_module_divide", tri_ttlin3_module_divide},
{"ttlin4_module_ext", tri_ttlin4_module_ext},
{"ttlin4_module_divide", tri_ttlin4_module_divide},
{"internal_en_flag", tri_internal_en_flag},
{"recorded_sig", tri_recorded_sig},
{"genlock_frame_sync_ext", tri_genlock_frame_sync_ext},
{"genlock_frame_sync_internal", tri_genlock_frame_sync_internal},
{"timecode_frame_sync_ext", tri_timecode_frame_sync_ext},

6
xsync.hpp

@ -91,14 +91,16 @@ typedef enum {
tri_ttlin3_module_divide = 7, // ttl3输入模块分频信号
tri_ttlin4_module_ext = 8, // ttl4输入模块原始信号
tri_ttlin4_module_divide = 9, // ttl4输入模块分频信号
tri_internal_en_flag = 10, // 内部使能状态信号输出
tri_recorded_sig = 10, // 录制信号
tri_genlock_frame_sync_ext = 11, // 外部genlock帧同步信号
tri_genlock_frame_sync_internal = 12, // 内部genlock帧同步信号
tri_timecode_frame_sync_ext = 13, // 外部timecode帧同步信号
tri_timecode_frame_sync_internal = 14, // 内部timecode帧同步信号
tri_timecode_serial_data_ext = 15, // 外部timecode串行数据输入
tri_timecode_serial_data_internal = 16, // 内部timecode串行数据输入
tri_internal_100hz = 31 // 100hz测试信号
tri_internal_clk_1hz = 17, // 内部
tri_internal_100hz = 31 // 100hz测试信号
} TriggerSigType_t;
string TriggerSigType2Str(TriggerSigType_t type);

0
xsync_v2.cpp

576
xsync_v2.hpp

@ -0,0 +1,576 @@
#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 "i_xsync_udp.hpp"
#include "xsync_errcode.hpp"
#include "xsync_packet.hpp"
#include "xsync_regs.hpp"
#include "xsync_v2_sig_type.hpp"
namespace xsync {
using namespace std;
/**
* @brief
*
* :
* Basic_xxxxx
*
* :
* :
* TimecodeInputModule_XXXXX
*
*
* TTL输入模块:
* TTLInputModule_XXXXX
*
* Genlock输入模块:
* GenlockInputModule_XXXXX
*
* :
*
* InternalTimecode_xxxx
* Genlock信号发生器
* ISG_Genlock_xxxx
*
*/
typedef function<void(XsyncTimecode_t *timecode_msg)> xsync_on_timecode_msg_t;
typedef function<void(uint32_t recordSig)> xsync_on_record_sig_change_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;
xsync_on_record_sig_change_msg_t m_on_record_sig_change_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;
std::recursive_mutex lock_;
Xsync(/* args */);
public:
static Xsync &Ins();
void initialize(I_XSUDPFactory *xsync_udp_factory);
/*******************************************************************************
* *
*******************************************************************************/
bool ping(string xsync_ip);
xs_error_code_t connect(string xsync_ip);
xs_error_code_t disConnect();
xsync_net_state_t getNetState();
/*******************************************************************************
* *
*******************************************************************************/
void Basic_registerOnTimecodeMsgCallback(xsync_on_timecode_msg_t on_timecode_msg_cb);
void Basic_registerOnCameraSyncMsgCallback(xsync_on_camera_sync_msg_t on_camera_sync_msg_cb);
void Basic_registerOnRecordSigChangeMsg(xsync_on_record_sig_change_msg_t on_record_sig_change_msg_cb);
/*******************************************************************************
* *
*******************************************************************************/
xs_error_code_t reg_write(uint32_t regadd, uint32_t regvalue, uint32_t &regbackvalue, int32_t overtime_ms = 100);
xs_error_code_t reg_read(uint32_t regadd, uint32_t &regvalue, int32_t overtime_ms = 100);
xs_error_code_t reg_read_muti(uint32_t regadd, uint32_t nreg, vector<uint32_t> &regvalues, int32_t overtime_ms = 100);
/*******************************************************************************
* *
*******************************************************************************/
xs_error_code_t Basic_generatorNewMac();
xs_error_code_t Basic_factoryReset();
xs_error_code_t Basic_reboot();
xs_error_code_t Basic_changeNetworkConfig(string ip, string mask, string gateway);
xs_error_code_t Basic_clearXsyncCameraSyncIndexCount();
/***********************************************************************************************
* *
***********************************************************************************************/
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*
* @param src
* INPUT_IF_TIMECODE_BNC
* INPUT_IF_TIMECODE_HEADPHONE
*
* @return xs_error_code_t
*/
xs_error_code_t TimecodeInputModule_setSrcSelect(InputInterface_t src);
xs_error_code_t TimecodeInputModule_getSrcSelect(InputInterface_t &timecode_select);
/**
* @brief
*
* @param format
* @return xs_error_code_t
*/
xs_error_code_t TimecodeInputModule_setTimecodeFormat(TimecodeFormat_t format);
xs_error_code_t TimecodeInputModule_getTimecodeFormat(TimecodeFormat_t &format);
/*******************************************************************************
* TTL输入模块 *
*******************************************************************************/
/**
* @brief TTL输入模块的频率
*
* @param index
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t TTLInputModule1_detectFreq(uint32_t &freq);
xs_error_code_t TTLInputModule2_detectFreq(uint32_t &freq);
xs_error_code_t TTLInputModule3_detectFreq(uint32_t &freq);
xs_error_code_t TTLInputModule4_detectFreq(uint32_t &freq);
/*******************************************************************************
* GENLOCK输入配置 *
*******************************************************************************/
/**
* @brief Genlock输入模块的频率
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t GenlockInputModule_detectFreq(uint32_t &freq);
/***********************************************************************************************
* *
***********************************************************************************************/
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief Timecode信号发生器
*
* @param mode
* :
* CONTROLMODE_ALWAYS_START
* @return xs_error_code_t
*/
xs_error_code_t InternalTimecode_setContrlMode(ControlMode_t mode);
xs_error_code_t InternalTimecode_getContrlMode(ControlMode_t &mode);
/**
* @brief Timecode信号发生器Timecode格式
*
* @param format
*
* TIMECODE_FPS2398
* TIMECODE_FPS2400
* TIMECODE_FPS2500
* TIMECODE_FPS2997
* TIMECODE_FPS2997Drop
* TIMECODE_FPS3000
*
* @return xs_error_code_t
*/
xs_error_code_t InternalTimecode_setTimecodeFormat(TimecodeFormat_t format);
xs_error_code_t InternalTimecode_getTimecodeFormat(TimecodeFormat_t &format);
/**
* @brief Timecode信号发生器Timecode值
*
* @param timecode
* @return xs_error_code_t
*/
xs_error_code_t InternalTimecode_setTimecodeValue(XsyncTimecode_t timecode);
xs_error_code_t InternalTimecode_getTimecodeValue(XsyncTimecode_t &timecode);
/*******************************************************************************
* Genlock信号发生器 *
*******************************************************************************/
/**
* @brief Genlock信号发生器
*
* @param mode
* :
* CONTROLMODE_ALWAYS_START
* @return xs_error_code_t
*/
xs_error_code_t InternalGenlock_setContrlMode(ControlMode_t mode);
xs_error_code_t InternalGenlock_getContrlMode(ControlMode_t &mode);
/**
* @brief Genlock信号发生器
*
* @param format
* :
* GENLOCK_FPS2397
* GENLOCK_FPS2398
* GENLOCK_FPS2400
* GENLOCK_FPS2500
* GENLOCK_FPS2997
* GENLOCK_FPS3000
* GENLOCK_FPS5000
* GENLOCK_FPS5994
* GENLOCK_FPS6000
* @return xs_error_code_t
*/
xs_error_code_t InternalGenlock_setFormat(GenlockFormat_t format);
xs_error_code_t InternalGenlock_getFormat(GenlockFormat_t &format);
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*
* @param mode
* :
* CONTROLMODE_ALWAYS_START
* @return xs_error_code_t
*/
xs_error_code_t InternalClockGenerator_setContrlMode(ControlMode_t mode);
xs_error_code_t InternalClockGenerator_getContrlMode(ControlMode_t &mode);
xs_error_code_t InternalClockGenerator_setFreq(uint32_t freq);
xs_error_code_t InternalClockGenerator_getFreq(uint32_t &freq);
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*
* @param mode
* :
* SIGNAL_TTLIN1
* SIGNAL_TTLIN1
* SIGNAL_TTLIN2
* SIGNAL_TTLIN3
* SIGNAL_TTLIN4
* SIGNAL_INTERNAL_FREQ_SIG
* SIGNAL_SYS_GENLOCK_OUTPUT
*
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setSrc(SignalType_t sig);
xs_error_code_t SysClock_getSrc(SignalType_t &sig);
/**
* @brief 沿
*
* @param edge
* TRIGGER_EDGE_RISING
* TRIGGER_EDGE_FALLING
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setTriggerEdge(TriggerEdge_t edge);
xs_error_code_t SysClock_getTriggerEdge(TriggerEdge_t &edge);
/**
* @brief
*
* @param div
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setFreqDivision(uint32_t div);
xs_error_code_t SysClock_geFreqtDivision(uint32_t &div);
/**
* @brief
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setFreqMultiplication(uint32_t freq);
xs_error_code_t SysClock_getFreqMultiplication(uint32_t &freq);
/**
* @brief
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysClock_readFreq(uint32_t &freq);
/**
* @brief
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysClock_readInputFreq(uint32_t &freq);
/*******************************************************************************
* Genlock *
*******************************************************************************/
/**
* @brief Genlock选择时钟源
*
* @param sig
* :
* SIGNAL_EXT_GENLOCK_FREQ
* SIGNAL_INTERNAL_GENLOCK_FREQ
*
* @return xs_error_code_t
*/
xs_error_code_t SysGenlock_setSrc(SignalType_t sig);
xs_error_code_t SysGenlock_getSrc(SignalType_t &sig);
/**
* @brief Genlock频率
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysGenlock_readFreq(uint32_t &freq);
/*******************************************************************************
* Timecode *
*******************************************************************************/
/**
* @brief Timecode选择时钟源
*
* @param internal
* 0: Timecode
* 1: Timecode
* @return xs_error_code_t
*/
xs_error_code_t SysTimecode_setSrc(int32_t sig);
xs_error_code_t SysTimecode_getSrc(int32_t &sig);
/**
* @brief Timecode频率
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysTimecode_readFreq(uint32_t &freq);
/**
* @brief Timecode格式
*
* @param format
* @return xs_error_code_t
*/
xs_error_code_t SysTimecode_readFormat(TimecodeFormat_t &format);
/**
* @brief Timecode值
*
* @param timecode
* @return xs_error_code_t
*/
xs_error_code_t SysTimecode_readTimecode(XsyncTimecode_t &timecode);
/*************************************************************************************************
* *
*************************************************************************************************/
/*******************************************************************************
* *
*******************************************************************************/
/**
*
*
* :使
* timecode控制源:使timecode
* :
* 1.
*
* :
* SIGNAL_BUSINESS_RECORD_SIG
* SIGNAL_BUSINESS_RECORD_EXPOSURE_SIG
*/
/**
* @brief
*
* @param mode
* :
* CONTROLMODE_MANUAL_TRIGGER
* CONTROLMODE_TIMECODE_TRIGGER
* CONTROLMODE_EXTERNALTTL_TRIGGER
* @return xs_error_code_t
*/
xs_error_code_t RecordSigGenerator_setContrlMode(ControlMode_t mode);
xs_error_code_t RecordSigGenerator_getContrlMode(ControlMode_t &mode);
// 手动控制
xs_error_code_t RecordSigGenerator_manualStart();
xs_error_code_t RecordSigGenerator_manualStop();
// timecode控制启停
xs_error_code_t RecordSigGenerator_setAutoStartTimecode(XsyncTimecode_t timecode);
xs_error_code_t RecordSigGenerator_setAutoStopTimecode(XsyncTimecode_t timecode);
xs_error_code_t RecordSigGenerator_getAutoStartTimecode(XsyncTimecode_t &timecode);
xs_error_code_t RecordSigGenerator_getAutoStopTimecode(XsyncTimecode_t &timecode);
// 外部TTL触发控制
/**
* @brief
*
* @param ttlPortNum
* INPUT_IF_TTL1
* INPUT_IF_TTL2
* INPUT_IF_TTL3
* INPUT_IF_TTL4
* @return xs_error_code_t
*/
xs_error_code_t RecordSigGenerator_setExternalTTLTriggerSrc(InputInterface_t ttlPortNum); // 1-4
xs_error_code_t RecordSigGenerator_getExternalTTLTriggerSrc(InputInterface_t &ttlPortNum);
xs_error_code_t RecordSigGenerator_setExternalTTLTriggerPolarity(TriggerPolarity_t polarity);
xs_error_code_t RecordSigGenerator_getExternalTTLTriggerPolarity(TriggerPolarity_t &polarity);
/**
* @brief
*
* @param us
* @return xs_error_code_t
*/
xs_error_code_t RecordSigGenerator_setRecordExposureTime(uint32_t us);
/**
* @brief
*
* @param us
* @return xs_error_code_t
*/
xs_error_code_t RecordSigGenerator_setRecordExposureOffsetTime(uint32_t us);
/*************************************************************************************************
* *
*************************************************************************************************/
/**
* @brief TTLOutputModuleX_setSrcSigType TTL输出口设置信号源
*
* @param source
* :
* 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
*
* @return xs_error_code_t
*/
xs_error_code_t TTLOutputModule1_setSrcSigType(SignalType_t source);
xs_error_code_t TTLOutputModule2_setSrcSigType(SignalType_t source);
xs_error_code_t TTLOutputModule3_setSrcSigType(SignalType_t source);
xs_error_code_t TTLOutputModule4_setSrcSigType(SignalType_t source);
xs_error_code_t TTLOutputModule1_getSrcSigType(SignalType_t &source);
xs_error_code_t TTLOutputModule2_getSrcSigType(SignalType_t &source);
xs_error_code_t TTLOutputModule3_getSrcSigType(SignalType_t &source);
xs_error_code_t TTLOutputModule4_getSrcSigType(SignalType_t &source);
// 分频配置
xs_error_code_t TTLOutputModule1_setFreqDivision(uint32_t div);
xs_error_code_t TTLOutputModule2_setFreqDivision(uint32_t div);
xs_error_code_t TTLOutputModule3_setFreqDivision(uint32_t div);
xs_error_code_t TTLOutputModule4_setFreqDivision(uint32_t div);
xs_error_code_t TTLOutputModule1_getFreqDivision(uint32_t &div);
xs_error_code_t TTLOutputModule2_getFreqDivision(uint32_t &div);
xs_error_code_t TTLOutputModule3_getFreqDivision(uint32_t &div);
xs_error_code_t TTLOutputModule4_getFreqDivision(uint32_t &div);
// 倍频配置
xs_error_code_t TTLOutputModule1_setFreqMultiplication(uint32_t freq);
xs_error_code_t TTLOutputModule2_setFreqMultiplication(uint32_t freq);
xs_error_code_t TTLOutputModule3_setFreqMultiplication(uint32_t freq);
xs_error_code_t TTLOutputModule4_setFreqMultiplication(uint32_t freq);
xs_error_code_t TTLOutputModule1_getFreqMultiplication(uint32_t &freq);
xs_error_code_t TTLOutputModule2_getFreqMultiplication(uint32_t &freq);
xs_error_code_t TTLOutputModule3_getFreqMultiplication(uint32_t &freq);
xs_error_code_t TTLOutputModule4_getFreqMultiplication(uint32_t &freq);
/*******************************************************************************
* Timecode输出口配置 *
*******************************************************************************/
/**
* @brief TIMECODE输出模块
*
* : SYS_TIMECODE
*/
/**
* @brief BNC输出电平
*
* @param level
* @return xs_error_code_t
*/
xs_error_code_t TimecodeOutputModule_setBncOutputLevel(int level); // 0:line,1:mic
xs_error_code_t TimecodeOutputModule_getBncOutputLevel(int &level);
/**
* @brief
*
* @param level
* @return xs_error_code_t
*/
xs_error_code_t TimecodeOutputModule_setHeadphoneOutputLevel(int level); // 0:line,1:mic
xs_error_code_t TimecodeOutputModule_getHeadphoneOutputLevel(int &level);
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*
*
* : SYS_CLK
* : 沿
* 使 :
*/
/**
* @brief
*
* @param index
* @return xs_error_code_t
*/
xs_error_code_t CameraSyncPacketGeneratorModule_getPacketIndex(uint32_t &index);
private:
};
} // namespace xsync

576
xsync_v2_sdk/xsync_v2.hpp

@ -0,0 +1,576 @@
#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 "i_xsync_udp.hpp"
#include "xsync_errcode.hpp"
#include "xsync_packet.hpp"
#include "xsync_regs.hpp"
#include "xsync_v2_sig_type.hpp"
namespace xsync {
using namespace std;
/**
* @brief
*
* :
* Basic_xxxxx
*
* :
* :
* TimecodeInputModule_XXXXX
*
*
* TTL输入模块:
* TTLInputModule_XXXXX
*
* Genlock输入模块:
* GenlockInputModule_XXXXX
*
* :
*
* InternalTimecode_xxxx
* Genlock信号发生器
* ISG_Genlock_xxxx
*
*/
typedef function<void(XsyncTimecode_t *timecode_msg)> xsync_on_timecode_msg_t;
typedef function<void(uint32_t recordSig)> xsync_on_record_sig_change_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;
xsync_on_record_sig_change_msg_t m_on_record_sig_change_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;
std::recursive_mutex lock_;
Xsync(/* args */);
public:
static Xsync &Ins();
void initialize(I_XSUDPFactory *xsync_udp_factory);
/*******************************************************************************
* *
*******************************************************************************/
bool ping(string xsync_ip);
xs_error_code_t connect(string xsync_ip);
xs_error_code_t disConnect();
xsync_net_state_t getNetState();
/*******************************************************************************
* *
*******************************************************************************/
void Basic_registerOnTimecodeMsgCallback(xsync_on_timecode_msg_t on_timecode_msg_cb);
void Basic_registerOnCameraSyncMsgCallback(xsync_on_camera_sync_msg_t on_camera_sync_msg_cb);
void Basic_registerOnRecordSigChangeMsg(xsync_on_record_sig_change_msg_t on_record_sig_change_msg_cb);
/*******************************************************************************
* *
*******************************************************************************/
xs_error_code_t reg_write(uint32_t regadd, uint32_t regvalue, uint32_t &regbackvalue, int32_t overtime_ms = 100);
xs_error_code_t reg_read(uint32_t regadd, uint32_t &regvalue, int32_t overtime_ms = 100);
xs_error_code_t reg_read_muti(uint32_t regadd, uint32_t nreg, vector<uint32_t> &regvalues, int32_t overtime_ms = 100);
/*******************************************************************************
* *
*******************************************************************************/
xs_error_code_t Basic_generatorNewMac();
xs_error_code_t Basic_factoryReset();
xs_error_code_t Basic_reboot();
xs_error_code_t Basic_changeNetworkConfig(string ip, string mask, string gateway);
xs_error_code_t Basic_clearXsyncCameraSyncIndexCount();
/***********************************************************************************************
* *
***********************************************************************************************/
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*
* @param src
* INPUT_IF_TIMECODE_BNC
* INPUT_IF_TIMECODE_HEADPHONE
*
* @return xs_error_code_t
*/
xs_error_code_t TimecodeInputModule_setSrcSelect(InputInterface_t src);
xs_error_code_t TimecodeInputModule_getSrcSelect(InputInterface_t &timecode_select);
/**
* @brief
*
* @param format
* @return xs_error_code_t
*/
xs_error_code_t TimecodeInputModule_setTimecodeFormat(TimecodeFormat_t format);
xs_error_code_t TimecodeInputModule_getTimecodeFormat(TimecodeFormat_t &format);
/*******************************************************************************
* TTL输入模块 *
*******************************************************************************/
/**
* @brief TTL输入模块的频率
*
* @param index
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t TTLInputModule1_detectFreq(uint32_t &freq);
xs_error_code_t TTLInputModule2_detectFreq(uint32_t &freq);
xs_error_code_t TTLInputModule3_detectFreq(uint32_t &freq);
xs_error_code_t TTLInputModule4_detectFreq(uint32_t &freq);
/*******************************************************************************
* GENLOCK输入配置 *
*******************************************************************************/
/**
* @brief Genlock输入模块的频率
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t GenlockInputModule_detectFreq(uint32_t &freq);
/***********************************************************************************************
* *
***********************************************************************************************/
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief Timecode信号发生器
*
* @param mode
* :
* CONTROLMODE_ALWAYS_START
* @return xs_error_code_t
*/
xs_error_code_t InternalTimecode_setContrlMode(ControlMode_t mode);
xs_error_code_t InternalTimecode_getContrlMode(ControlMode_t &mode);
/**
* @brief Timecode信号发生器Timecode格式
*
* @param format
*
* TIMECODE_FPS2398
* TIMECODE_FPS2400
* TIMECODE_FPS2500
* TIMECODE_FPS2997
* TIMECODE_FPS2997Drop
* TIMECODE_FPS3000
*
* @return xs_error_code_t
*/
xs_error_code_t InternalTimecode_setTimecodeFormat(TimecodeFormat_t format);
xs_error_code_t InternalTimecode_getTimecodeFormat(TimecodeFormat_t &format);
/**
* @brief Timecode信号发生器Timecode值
*
* @param timecode
* @return xs_error_code_t
*/
xs_error_code_t InternalTimecode_setTimecodeValue(XsyncTimecode_t timecode);
xs_error_code_t InternalTimecode_getTimecodeValue(XsyncTimecode_t &timecode);
/*******************************************************************************
* Genlock信号发生器 *
*******************************************************************************/
/**
* @brief Genlock信号发生器
*
* @param mode
* :
* CONTROLMODE_ALWAYS_START
* @return xs_error_code_t
*/
xs_error_code_t InternalGenlock_setContrlMode(ControlMode_t mode);
xs_error_code_t InternalGenlock_getContrlMode(ControlMode_t &mode);
/**
* @brief Genlock信号发生器
*
* @param format
* :
* GENLOCK_FPS2397
* GENLOCK_FPS2398
* GENLOCK_FPS2400
* GENLOCK_FPS2500
* GENLOCK_FPS2997
* GENLOCK_FPS3000
* GENLOCK_FPS5000
* GENLOCK_FPS5994
* GENLOCK_FPS6000
* @return xs_error_code_t
*/
xs_error_code_t InternalGenlock_setFormat(GenlockFormat_t format);
xs_error_code_t InternalGenlock_getFormat(GenlockFormat_t &format);
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*
* @param mode
* :
* CONTROLMODE_ALWAYS_START
* @return xs_error_code_t
*/
xs_error_code_t InternalClockGenerator_setContrlMode(ControlMode_t mode);
xs_error_code_t InternalClockGenerator_getContrlMode(ControlMode_t &mode);
xs_error_code_t InternalClockGenerator_setFreq(uint32_t freq);
xs_error_code_t InternalClockGenerator_getFreq(uint32_t &freq);
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*
* @param mode
* :
* SIGNAL_TTLIN1
* SIGNAL_TTLIN1
* SIGNAL_TTLIN2
* SIGNAL_TTLIN3
* SIGNAL_TTLIN4
* SIGNAL_INTERNAL_FREQ_SIG
* SIGNAL_SYS_GENLOCK_OUTPUT
*
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setSrc(SignalType_t sig);
xs_error_code_t SysClock_getSrc(SignalType_t &sig);
/**
* @brief 沿
*
* @param edge
* TRIGGER_EDGE_RISING
* TRIGGER_EDGE_FALLING
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setTriggerEdge(TriggerEdge_t edge);
xs_error_code_t SysClock_getTriggerEdge(TriggerEdge_t &edge);
/**
* @brief
*
* @param div
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setFreqDivision(uint32_t div);
xs_error_code_t SysClock_geFreqtDivision(uint32_t &div);
/**
* @brief
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setFreqMultiplication(uint32_t freq);
xs_error_code_t SysClock_getFreqMultiplication(uint32_t &freq);
/**
* @brief
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysClock_readFreq(uint32_t &freq);
/**
* @brief
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysClock_readInputFreq(uint32_t &freq);
/*******************************************************************************
* Genlock *
*******************************************************************************/
/**
* @brief Genlock选择时钟源
*
* @param sig
* :
* SIGNAL_EXT_GENLOCK_FREQ
* SIGNAL_INTERNAL_GENLOCK_FREQ
*
* @return xs_error_code_t
*/
xs_error_code_t SysGenlock_setSrc(SignalType_t sig);
xs_error_code_t SysGenlock_getSrc(SignalType_t &sig);
/**
* @brief Genlock频率
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysGenlock_readFreq(uint32_t &freq);
/*******************************************************************************
* Timecode *
*******************************************************************************/
/**
* @brief Timecode选择时钟源
*
* @param internal
* 0: Timecode
* 1: Timecode
* @return xs_error_code_t
*/
xs_error_code_t SysTimecode_setSrc(int32_t sig);
xs_error_code_t SysTimecode_getSrc(int32_t &sig);
/**
* @brief Timecode频率
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysTimecode_readFreq(uint32_t &freq);
/**
* @brief Timecode格式
*
* @param format
* @return xs_error_code_t
*/
xs_error_code_t SysTimecode_readFormat(TimecodeFormat_t &format);
/**
* @brief Timecode值
*
* @param timecode
* @return xs_error_code_t
*/
xs_error_code_t SysTimecode_readTimecode(XsyncTimecode_t &timecode);
/*************************************************************************************************
* *
*************************************************************************************************/
/*******************************************************************************
* *
*******************************************************************************/
/**
*
*
* :使
* timecode控制源:使timecode
* :
* 1.
*
* :
* SIGNAL_BUSINESS_RECORD_SIG
* SIGNAL_BUSINESS_RECORD_EXPOSURE_SIG
*/
/**
* @brief
*
* @param mode
* :
* CONTROLMODE_MANUAL_TRIGGER
* CONTROLMODE_TIMECODE_TRIGGER
* CONTROLMODE_EXTERNALTTL_TRIGGER
* @return xs_error_code_t
*/
xs_error_code_t RecordSigGenerator_setContrlMode(ControlMode_t mode);
xs_error_code_t RecordSigGenerator_getContrlMode(ControlMode_t &mode);
// 手动控制
xs_error_code_t RecordSigGenerator_manualStart();
xs_error_code_t RecordSigGenerator_manualStop();
// timecode控制启停
xs_error_code_t RecordSigGenerator_setAutoStartTimecode(XsyncTimecode_t timecode);
xs_error_code_t RecordSigGenerator_setAutoStopTimecode(XsyncTimecode_t timecode);
xs_error_code_t RecordSigGenerator_getAutoStartTimecode(XsyncTimecode_t &timecode);
xs_error_code_t RecordSigGenerator_getAutoStopTimecode(XsyncTimecode_t &timecode);
// 外部TTL触发控制
/**
* @brief
*
* @param ttlPortNum
* INPUT_IF_TTL1
* INPUT_IF_TTL2
* INPUT_IF_TTL3
* INPUT_IF_TTL4
* @return xs_error_code_t
*/
xs_error_code_t RecordSigGenerator_setExternalTTLTriggerSrc(InputInterface_t ttlPortNum); // 1-4
xs_error_code_t RecordSigGenerator_getExternalTTLTriggerSrc(InputInterface_t &ttlPortNum);
xs_error_code_t RecordSigGenerator_setExternalTTLTriggerPolarity(TriggerPolarity_t polarity);
xs_error_code_t RecordSigGenerator_getExternalTTLTriggerPolarity(TriggerPolarity_t &polarity);
/**
* @brief
*
* @param us
* @return xs_error_code_t
*/
xs_error_code_t RecordSigGenerator_setRecordExposureTime(uint32_t us);
/**
* @brief
*
* @param us
* @return xs_error_code_t
*/
xs_error_code_t RecordSigGenerator_setRecordExposureOffsetTime(uint32_t us);
/*************************************************************************************************
* *
*************************************************************************************************/
/**
* @brief TTLOutputModuleX_setSrcSigType TTL输出口设置信号源
*
* @param source
* :
* 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
*
* @return xs_error_code_t
*/
xs_error_code_t TTLOutputModule1_setSrcSigType(SignalType_t source);
xs_error_code_t TTLOutputModule2_setSrcSigType(SignalType_t source);
xs_error_code_t TTLOutputModule3_setSrcSigType(SignalType_t source);
xs_error_code_t TTLOutputModule4_setSrcSigType(SignalType_t source);
xs_error_code_t TTLOutputModule1_getSrcSigType(SignalType_t &source);
xs_error_code_t TTLOutputModule2_getSrcSigType(SignalType_t &source);
xs_error_code_t TTLOutputModule3_getSrcSigType(SignalType_t &source);
xs_error_code_t TTLOutputModule4_getSrcSigType(SignalType_t &source);
// 分频配置
xs_error_code_t TTLOutputModule1_setFreqDivision(uint32_t div);
xs_error_code_t TTLOutputModule2_setFreqDivision(uint32_t div);
xs_error_code_t TTLOutputModule3_setFreqDivision(uint32_t div);
xs_error_code_t TTLOutputModule4_setFreqDivision(uint32_t div);
xs_error_code_t TTLOutputModule1_getFreqDivision(uint32_t &div);
xs_error_code_t TTLOutputModule2_getFreqDivision(uint32_t &div);
xs_error_code_t TTLOutputModule3_getFreqDivision(uint32_t &div);
xs_error_code_t TTLOutputModule4_getFreqDivision(uint32_t &div);
// 倍频配置
xs_error_code_t TTLOutputModule1_setFreqMultiplication(uint32_t freq);
xs_error_code_t TTLOutputModule2_setFreqMultiplication(uint32_t freq);
xs_error_code_t TTLOutputModule3_setFreqMultiplication(uint32_t freq);
xs_error_code_t TTLOutputModule4_setFreqMultiplication(uint32_t freq);
xs_error_code_t TTLOutputModule1_getFreqMultiplication(uint32_t &freq);
xs_error_code_t TTLOutputModule2_getFreqMultiplication(uint32_t &freq);
xs_error_code_t TTLOutputModule3_getFreqMultiplication(uint32_t &freq);
xs_error_code_t TTLOutputModule4_getFreqMultiplication(uint32_t &freq);
/*******************************************************************************
* Timecode输出口配置 *
*******************************************************************************/
/**
* @brief TIMECODE输出模块
*
* : SYS_TIMECODE
*/
/**
* @brief BNC输出电平
*
* @param level
* @return xs_error_code_t
*/
xs_error_code_t TimecodeOutputModule_setBncOutputLevel(int level); // 0:line,1:mic
xs_error_code_t TimecodeOutputModule_getBncOutputLevel(int &level);
/**
* @brief
*
* @param level
* @return xs_error_code_t
*/
xs_error_code_t TimecodeOutputModule_setHeadphoneOutputLevel(int level); // 0:line,1:mic
xs_error_code_t TimecodeOutputModule_getHeadphoneOutputLevel(int &level);
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*
*
* : SYS_CLK
* : 沿
* 使 :
*/
/**
* @brief
*
* @param index
* @return xs_error_code_t
*/
xs_error_code_t CameraSyncPacketGeneratorModule_getPacketIndex(uint32_t &index);
private:
};
} // namespace xsync

189
xsync_v2_sdk/xsync_v2_sig_type.hpp

@ -0,0 +1,189 @@
#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 "i_xsync_udp.hpp"
#include "xsync_errcode.hpp"
#include "xsync_packet.hpp"
#include "xsync_regs.hpp"
namespace xsync {
using namespace std;
/*******************************************************************************
* XSYNC_STATE *
*******************************************************************************/
typedef enum {
kxsync_net_state_disconnect,
kxsync_net_state_connecting,
kxsync_net_state_connected,
} xsync_net_state_t;
/*******************************************************************************
* TIMECODE *
*******************************************************************************/
typedef struct {
uint32_t tc0;
uint32_t tc1;
} Timecode64_t;
typedef enum {
TIMECODE_FPS2398 = 0,
TIMECODE_FPS2400 = 1,
TIMECODE_FPS2500 = 2,
TIMECODE_FPS2997 = 3,
TIMECODE_FPS2997Drop = 4,
TIMECODE_FPS3000 = 5,
} TimecodeFormat_t;
string TimecodeFormatToStr(TimecodeFormat_t fomrat);
TimecodeFormat_t Str2TimecodeFormat(string format);
list<string> TimecodeFormatStrSet();
typedef struct {
uint8_t hour;
uint8_t minute;
uint8_t second;
uint8_t frame;
} XsyncTimecode_t;
string XsyncTimecodeToStr(XsyncTimecode_t timecode);
XsyncTimecode_t Str2XsyncTimecode(string timecode);
/*******************************************************************************
* GENLOCK *
*******************************************************************************/
typedef enum {
GENLOCK_FPS2397 = 0,
GENLOCK_FPS2398 = 1,
GENLOCK_FPS2400 = 2,
GENLOCK_FPS2500 = 3,
GENLOCK_FPS2997 = 4,
GENLOCK_FPS3000 = 5,
GENLOCK_FPS5000 = 6,
GENLOCK_FPS5994 = 7,
GENLOCK_FPS6000 = 8,
} GenlockFormat_t;
string GenlockFormatToStr(GenlockFormat_t fomrat);
GenlockFormat_t Str2GenlockFormat(string format);
list<string> GenlockFormatStrSet();
/*******************************************************************************
* camera_sync_data *
*******************************************************************************/
typedef struct {
uint32_t frameIndex;
} xysnc_camera_sync_data_t;
/*******************************************************************************
* *
*******************************************************************************/
typedef enum {
/*******************************************************************************
* *
*******************************************************************************/
SIGNAL_TTLIN1, // ttl1输入模块输出信号
SIGNAL_TTLIN2, // ttl2输入模块输出信号
SIGNAL_TTLIN3, // ttl3输入模块输出信号
SIGNAL_TTLIN4, // isolate 输入模块输出输出信号
SIGNAL_EXT_GENLOCK_FREQ, // 外部genlock频率信号
SIGNAL_EXT_TIMECODE_FREQ, // 外部timecode频率信号
/*******************************************************************************
* *
*******************************************************************************/
SIGNAL_INTERNAL_TIMECODE_FREQ, // 内部timecode频率信号
SIGNAL_INTERNAL_GENLOCK_FREQ, // 内部genlock频率信号
SIGNAL_INTERNAL_FREQ_SIG, // 内部信号发生器内部频率信号
/*******************************************************************************
* SYS时钟 *
*******************************************************************************/
SIGNAL_SYS_CLK_OUTPUT, // 系统时钟输出,系统时钟可能来源,内部频率信号发生器,外部genlock,外部timecode,外部ttl
SIGNAL_SYS_GENLOCK_OUTPUT, // 系统genlock输出,系统genlock可能来源,内部genlock 外部genlock
SIGNAL_SYS_TIMECODE_FREQ_OUTPUT, // 系统timecode输出,系统timecode可能来源,内部timecode 外部timecode
/*******************************************************************************
* *
*******************************************************************************/
SIGNAL_BUSINESS_RECORD_SIG, // 录像机触发信号
SIGNAL_BUSINESS_RECORD_EXPOSURE_SIG, // 曝光触发信号
} SignalType_t;
string SignalType2Str(SignalType_t type);
SignalType_t Str2SignalType(string type);
list<string> SignalTypeStrSet();
/*******************************************************************************
* *
*******************************************************************************/
typedef enum {
CONTROLMODE_ALWAYS_START, // 总是启动
CONTROLMODE_MANUAL_TRIGGER, // 手动,启动停止
CONTROLMODE_TIMECODE_TRIGGER, // TIMECODE触发启动,手动控制停止
CONTROLMODE_EXTERNALTTL_TRIGGER, // 外部TTL输入触发,高电平开始,低电平停止
} ControlMode_t;
string ControlMode2Str(ControlMode_t mode);
ControlMode_t Str2ControlMode(string mode);
list<string> ControlModeStrSet();
/*******************************************************************************
* *
*******************************************************************************/
typedef enum {
INPUT_IF_TTL1,
INPUT_IF_TTL2,
INPUT_IF_TTL3,
INPUT_IF_TTL4,
INPUT_IF_GENLOCK,
INPUT_IF_TIMECODE_BNC,
INPUT_IF_TIMECODE_HEADPHONE,
} InputInterface_t;
string InputInterface2Str(InputInterface_t input);
InputInterface_t Str2InputInterface(string input);
list<string> InputInterfaceStrSet();
/*******************************************************************************
* 沿 *
*******************************************************************************/
typedef enum {
TRIGGER_EDGE_RISING, // 上升沿触发
TRIGGER_EDGE_FALLING, // 下降沿触发
TRIGGER_EDGE_BOTH, // 上升沿和下降沿触发
} TriggerEdge_t;
TriggerEdge_t Str2TriggerEdge(string edge);
string TriggerEdge2Str(TriggerEdge_t edge);
list<string> TriggerEdgeStrSet();
// TriggerPolarity_t
typedef enum {
kTriggerPolarityPositive, // 高电平触发
kTriggerPolarityNegative, // 低电平触发
} TriggerPolarity_t;
} // namespace xsync

210
xsync_v2_sig_type.cpp

@ -0,0 +1,210 @@
#include "xsync_v2_sig_type.hpp"
#include <string.h>
using namespace xsync;
/*******************************************************************************
* TIMECODE *
*******************************************************************************/
static map<string, TimecodeFormat_t> TimecodeFormatMap = {
{"TIMECODE_FPS2398", TIMECODE_FPS2398}, //
{"TIMECODE_FPS2400", TIMECODE_FPS2400}, //
{"TIMECODE_FPS2500", TIMECODE_FPS2500}, //
{"TIMECODE_FPS2997", TIMECODE_FPS2997}, //
{"TIMECODE_FPS2997Drop", TIMECODE_FPS2997Drop}, //
{"TIMECODE_FPS3000", TIMECODE_FPS3000}, //
};
string TimecodeFormatToStr(TimecodeFormat_t type) {
for (auto &item : TimecodeFormatMap) {
if (item.second == type) return item.first;
}
return "unkown";
}
TimecodeFormat_t Str2TimecodeFormat(string val) {
if (TimecodeFormatMap.find(val) != TimecodeFormatMap.end()) {
return TimecodeFormatMap[val];
}
return TIMECODE_FPS2997;
}
list<string> TimecodeFormatStrSet() {
list<string> ret;
for (auto &item : TimecodeFormatMap) {
ret.push_back(item.first);
}
return ret;
}
string XsyncTimecodeToStr(XsyncTimecode_t timecode) {
char buf[32] = {0};
sprintf(buf, "%02d:%02d:%02d:%02d", timecode.hour, timecode.minute, timecode.second, timecode.frame);
return string(buf);
}
XsyncTimecode_t Str2XsyncTimecode(string timecode) {
XsyncTimecode_t ret;
char buf[128] = {0};
strncpy(buf, timecode.c_str(), 127);
sscanf(buf, "%02d:%02d:%02d:%02d", &ret.hour, &ret.minute, &ret.second, &ret.frame);
return ret;
}
/*******************************************************************************
* GENLOCK *
*******************************************************************************/
static map<string, GenlockFormat_t> GenlockFormatMap = {
{"GENLOCK_FPS2397", GENLOCK_FPS2397}, //
{"GENLOCK_FPS2398", GENLOCK_FPS2398}, //
{"GENLOCK_FPS2400", GENLOCK_FPS2400}, //
{"GENLOCK_FPS2500", GENLOCK_FPS2500}, //
{"GENLOCK_FPS2997", GENLOCK_FPS2997}, //
{"GENLOCK_FPS3000", GENLOCK_FPS3000}, //
{"GENLOCK_FPS5000", GENLOCK_FPS5000}, //
{"GENLOCK_FPS5994", GENLOCK_FPS5994}, //
{"GENLOCK_FPS6000", GENLOCK_FPS6000}, //
};
string GenlockFormatToStr(GenlockFormat_t fomrat) {
for (auto &item : GenlockFormatMap) {
if (item.second == fomrat) return item.first;
}
return "unkown";
}
GenlockFormat_t Str2GenlockFormat(string format) {
if (GenlockFormatMap.find(format) != GenlockFormatMap.end()) {
return GenlockFormatMap[format];
}
return GENLOCK_FPS2997;
}
list<string> GenlockFormatStrSet() {
list<string> ret;
for (auto &item : GenlockFormatMap) {
ret.push_back(item.first);
}
return ret;
}
/*******************************************************************************
* Signal_Type *
*******************************************************************************/
static map<string, SignalType_t> SignalTypeMap = {
{"SIGNAL_TTLIN1", SIGNAL_TTLIN1},
{"SIGNAL_TTLIN2", SIGNAL_TTLIN2},
{"SIGNAL_TTLIN3", SIGNAL_TTLIN3},
{"SIGNAL_TTLIN4", SIGNAL_TTLIN4},
{"SIGNAL_EXT_GENLOCK_FREQ", SIGNAL_EXT_GENLOCK_FREQ},
{"SIGNAL_EXT_TIMECODE_FREQ", SIGNAL_EXT_TIMECODE_FREQ},
{"SIGNAL_INTERNAL_TIMECODE_FREQ", SIGNAL_INTERNAL_TIMECODE_FREQ},
{"SIGNAL_INTERNAL_GENLOCK_FREQ", SIGNAL_INTERNAL_GENLOCK_FREQ},
{"SIGNAL_INTERNAL_FREQ_SIG", SIGNAL_INTERNAL_FREQ_SIG},
{"SIGNAL_SYS_CLK_OUTPUT", SIGNAL_SYS_CLK_OUTPUT},
{"SIGNAL_SYS_GENLOCK_OUTPUT", SIGNAL_SYS_GENLOCK_OUTPUT},
{"SIGNAL_SYS_TIMECODE_FREQ_OUTPUT", SIGNAL_SYS_TIMECODE_FREQ_OUTPUT},
};
string SignalType2Str(SignalType_t type) {
for (auto &item : SignalTypeMap) {
if (item.second == type) return item.first;
}
return "unkown";
}
SignalType_t Str2SignalType(string type) {
if (SignalTypeMap.find(type) != SignalTypeMap.end()) {
return SignalTypeMap[type];
}
return SIGNAL_TTLIN1;
}
list<string> SignalTypeStrSet() {
list<string> ret;
for (auto &item : SignalTypeMap) {
ret.push_back(item.first);
}
return ret;
}
/*******************************************************************************
* *
*******************************************************************************/
static map<string, ControlMode_t> ControlModeMap = {
{"CONTROLMODE_ALWAYS_START", CONTROLMODE_ALWAYS_START}, //
{"CONTROLMODE_MANUAL_TRIGGER", CONTROLMODE_MANUAL_TRIGGER}, //
{"CONTROLMODE_TIMECODE_TRIGGER", CONTROLMODE_TIMECODE_TRIGGER}, //
{"CONTROLMODE_EXTERNALTTL_TRIGGER", CONTROLMODE_EXTERNALTTL_TRIGGER}, //
};
string ControlMode2Str(ControlMode_t mode) {
for (auto &item : ControlModeMap) {
if (item.second == mode) return item.first;
}
return "unkown";
}
ControlMode_t Str2ControlMode(string mode) {
if (ControlModeMap.find(mode) != ControlModeMap.end()) {
return ControlModeMap[mode];
}
return CONTROLMODE_MANUAL_TRIGGER;
}
list<string> ControlModeStrSet() {
list<string> ret;
for (auto &item : ControlModeMap) {
ret.push_back(item.first);
}
return ret;
}
static map<string, InputInterface_t> InputInterfaceMap = {
{"INPUT_IF_TTL1", INPUT_IF_TTL1}, //
{"INPUT_IF_TTL2", INPUT_IF_TTL2}, //
{"INPUT_IF_TTL3", INPUT_IF_TTL3}, //
{"INPUT_IF_TTL4", INPUT_IF_TTL4}, //
{"INPUT_IF_GENLOCK", INPUT_IF_GENLOCK}, //
{"INPUT_IF_TIMECODE_BNC", INPUT_IF_TIMECODE_BNC}, //
{"INPUT_IF_TIMECODE_HEADPHONE", INPUT_IF_TIMECODE_HEADPHONE}, //
};
string InputInterface2Str(InputInterface_t input) {
for (auto &item : InputInterfaceMap) {
if (item.second == input) return item.first;
}
return "unkown";
}
InputInterface_t Str2InputInterface(string input) {
if (InputInterfaceMap.find(input) != InputInterfaceMap.end()) {
return InputInterfaceMap[input];
}
return INPUT_IF_TTL1;
}
list<string> InputInterfaceStrSet() {
list<string> ret;
for (auto &item : InputInterfaceMap) {
ret.push_back(item.first);
}
return ret;
}
static map<string, TriggerEdge_t> TriggerEdgeMap = {
{"TRIGGER_EDGE_RISING", TRIGGER_EDGE_RISING}, //
{"TRIGGER_EDGE_FALLING", TRIGGER_EDGE_FALLING}, //
{"TRIGGER_EDGE_BOTH", TRIGGER_EDGE_BOTH}, //
};
TriggerEdge_t Str2TriggerEdge(string edge) {
if (TriggerEdgeMap.find(edge) != TriggerEdgeMap.end()) {
return TriggerEdgeMap[edge];
}
return TRIGGER_EDGE_RISING;
}
string TriggerEdge2Str(TriggerEdge_t edge) {
for (auto &item : TriggerEdgeMap) {
if (item.second == edge) return item.first;
}
return "unkown";
}
list<string> TriggerEdgeStrSet() {
list<string> ret;
for (auto &item : TriggerEdgeMap) {
ret.push_back(item.first);
}
return ret;
}

189
xsync_v2_sig_type.hpp

@ -0,0 +1,189 @@
#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 "i_xsync_udp.hpp"
#include "xsync_errcode.hpp"
#include "xsync_packet.hpp"
#include "xsync_regs.hpp"
namespace xsync {
using namespace std;
/*******************************************************************************
* XSYNC_STATE *
*******************************************************************************/
typedef enum {
kxsync_net_state_disconnect,
kxsync_net_state_connecting,
kxsync_net_state_connected,
} xsync_net_state_t;
/*******************************************************************************
* TIMECODE *
*******************************************************************************/
typedef struct {
uint32_t tc0;
uint32_t tc1;
} Timecode64_t;
typedef enum {
TIMECODE_FPS2398 = 0,
TIMECODE_FPS2400 = 1,
TIMECODE_FPS2500 = 2,
TIMECODE_FPS2997 = 3,
TIMECODE_FPS2997Drop = 4,
TIMECODE_FPS3000 = 5,
} TimecodeFormat_t;
string TimecodeFormatToStr(TimecodeFormat_t fomrat);
TimecodeFormat_t Str2TimecodeFormat(string format);
list<string> TimecodeFormatStrSet();
typedef struct {
uint8_t hour;
uint8_t minute;
uint8_t second;
uint8_t frame;
} XsyncTimecode_t;
string XsyncTimecodeToStr(XsyncTimecode_t timecode);
XsyncTimecode_t Str2XsyncTimecode(string timecode);
/*******************************************************************************
* GENLOCK *
*******************************************************************************/
typedef enum {
GENLOCK_FPS2397 = 0,
GENLOCK_FPS2398 = 1,
GENLOCK_FPS2400 = 2,
GENLOCK_FPS2500 = 3,
GENLOCK_FPS2997 = 4,
GENLOCK_FPS3000 = 5,
GENLOCK_FPS5000 = 6,
GENLOCK_FPS5994 = 7,
GENLOCK_FPS6000 = 8,
} GenlockFormat_t;
string GenlockFormatToStr(GenlockFormat_t fomrat);
GenlockFormat_t Str2GenlockFormat(string format);
list<string> GenlockFormatStrSet();
/*******************************************************************************
* camera_sync_data *
*******************************************************************************/
typedef struct {
uint32_t frameIndex;
} xysnc_camera_sync_data_t;
/*******************************************************************************
* *
*******************************************************************************/
typedef enum {
/*******************************************************************************
* *
*******************************************************************************/
SIGNAL_TTLIN1, // ttl1输入模块输出信号
SIGNAL_TTLIN2, // ttl2输入模块输出信号
SIGNAL_TTLIN3, // ttl3输入模块输出信号
SIGNAL_TTLIN4, // isolate 输入模块输出输出信号
SIGNAL_EXT_GENLOCK_FREQ, // 外部genlock频率信号
SIGNAL_EXT_TIMECODE_FREQ, // 外部timecode频率信号
/*******************************************************************************
* *
*******************************************************************************/
SIGNAL_INTERNAL_TIMECODE_FREQ, // 内部timecode频率信号
SIGNAL_INTERNAL_GENLOCK_FREQ, // 内部genlock频率信号
SIGNAL_INTERNAL_FREQ_SIG, // 内部信号发生器内部频率信号
/*******************************************************************************
* SYS时钟 *
*******************************************************************************/
SIGNAL_SYS_CLK_OUTPUT, // 系统时钟输出,系统时钟可能来源,内部频率信号发生器,外部genlock,外部timecode,外部ttl
SIGNAL_SYS_GENLOCK_OUTPUT, // 系统genlock输出,系统genlock可能来源,内部genlock 外部genlock
SIGNAL_SYS_TIMECODE_FREQ_OUTPUT, // 系统timecode输出,系统timecode可能来源,内部timecode 外部timecode
/*******************************************************************************
* *
*******************************************************************************/
SIGNAL_BUSINESS_RECORD_SIG, // 录像机触发信号
SIGNAL_BUSINESS_RECORD_EXPOSURE_SIG, // 曝光触发信号
} SignalType_t;
string SignalType2Str(SignalType_t type);
SignalType_t Str2SignalType(string type);
list<string> SignalTypeStrSet();
/*******************************************************************************
* *
*******************************************************************************/
typedef enum {
CONTROLMODE_ALWAYS_START, // 总是启动
CONTROLMODE_MANUAL_TRIGGER, // 手动,启动停止
CONTROLMODE_TIMECODE_TRIGGER, // TIMECODE触发启动,手动控制停止
CONTROLMODE_EXTERNALTTL_TRIGGER, // 外部TTL输入触发,高电平开始,低电平停止
} ControlMode_t;
string ControlMode2Str(ControlMode_t mode);
ControlMode_t Str2ControlMode(string mode);
list<string> ControlModeStrSet();
/*******************************************************************************
* *
*******************************************************************************/
typedef enum {
INPUT_IF_TTL1,
INPUT_IF_TTL2,
INPUT_IF_TTL3,
INPUT_IF_TTL4,
INPUT_IF_GENLOCK,
INPUT_IF_TIMECODE_BNC,
INPUT_IF_TIMECODE_HEADPHONE,
} InputInterface_t;
string InputInterface2Str(InputInterface_t input);
InputInterface_t Str2InputInterface(string input);
list<string> InputInterfaceStrSet();
/*******************************************************************************
* 沿 *
*******************************************************************************/
typedef enum {
TRIGGER_EDGE_RISING, // 上升沿触发
TRIGGER_EDGE_FALLING, // 下降沿触发
TRIGGER_EDGE_BOTH, // 上升沿和下降沿触发
} TriggerEdge_t;
TriggerEdge_t Str2TriggerEdge(string edge);
string TriggerEdge2Str(TriggerEdge_t edge);
list<string> TriggerEdgeStrSet();
// TriggerPolarity_t
typedef enum {
kTriggerPolarityPositive, // 高电平触发
kTriggerPolarityNegative, // 低电平触发
} TriggerPolarity_t;
} // namespace xsync
Loading…
Cancel
Save