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.

381 lines
20 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #pragma once
  2. #include <fstream>
  3. #include <functional>
  4. #include <iostream>
  5. #include <list>
  6. #include <map>
  7. #include <memory>
  8. #include <mutex>
  9. #include <set>
  10. #include <sstream>
  11. #include <string>
  12. #include <vector>
  13. #include "xsync_errcode.hpp"
  14. #include "xsync_v2_sig_type.hpp"
  15. namespace xsync {
  16. using namespace std;
  17. typedef function<void(XsyncTimecode_t *timecode_msg)> xsync_on_timecode_msg_t;
  18. typedef function<void(uint32_t recordSig, XsyncTimecode_t *timecode_msg)> xsync_on_record_sig_change_msg_t;
  19. typedef function<void(bool state, string targetIp)> xsync_on_connect_state_change_t;
  20. typedef function<void(xysnc_camera_sync_data_t *timecode_msg)> xsync_on_camera_sync_msg_t;
  21. typedef struct {
  22. bool placeholder;
  23. } xsync_config_t;
  24. typedef struct {
  25. uint32_t main;
  26. uint32_t sub;
  27. uint32_t fix;
  28. } version_t;
  29. class IXsync {
  30. public:
  31. virtual ~IXsync() {}
  32. public:
  33. virtual xs_error_code_t initialize(xsync_config_t *config) = 0;
  34. virtual bool ping() = 0;
  35. virtual bool getConnectState() = 0;
  36. virtual string getDeviceIp() = 0;
  37. /*******************************************************************************
  38. * *
  39. *******************************************************************************/
  40. /**
  41. * @brief
  42. * :
  43. * 1. storageConfig才会持久化
  44. * 2. reboot方法
  45. */
  46. virtual xs_error_code_t NetworkConfig_setMode(NetworkMode_t mode) = 0;
  47. virtual xs_error_code_t NetworkConfig_getMode(NetworkMode_t &mode) = 0;
  48. virtual xs_error_code_t NetworkConfigStaticIpMode_setIp(string ip) = 0;
  49. virtual xs_error_code_t NetworkConfigStaticIpMode_setMask(string mask) = 0;
  50. virtual xs_error_code_t NetworkConfigStaticIpMode_setGateway(string gateway) = 0;
  51. virtual xs_error_code_t NetworkConfigStaticIpMode_getIp(string &ip) = 0;
  52. virtual xs_error_code_t NetworkConfigStaticIpMode_getMask(string &mask) = 0;
  53. virtual xs_error_code_t NetworkConfigStaticIpMode_getGateway(string &gateway) = 0;
  54. /*******************************************************************************
  55. * *
  56. *******************************************************************************/
  57. virtual void registerOnTimecodeMsgCallback(xsync_on_timecode_msg_t cb) = 0; // timecode 回调
  58. virtual void registerOnCameraSyncMsgCallback(xsync_on_camera_sync_msg_t cb) = 0; // 相机同步包 回调
  59. virtual void registerOnRecordSigChangeMsgCallback(xsync_on_record_sig_change_msg_t cb) = 0; // 录制信号变化 回调
  60. virtual void registerOnConnectStateChangeCallback(xsync_on_connect_state_change_t cb) = 0; // 连接状态变化 回调
  61. /*******************************************************************************
  62. * *
  63. *******************************************************************************/
  64. virtual xs_error_code_t generatorNewMac() = 0;
  65. virtual xs_error_code_t factoryReset() = 0;
  66. virtual xs_error_code_t reboot() = 0;
  67. virtual xs_error_code_t readSn(string &sn) = 0;
  68. virtual xs_error_code_t readMac(string &mac) = 0;
  69. virtual xs_error_code_t storageConfig() = 0;
  70. virtual xs_error_code_t readSDKVersion(version_t &version) = 0;
  71. virtual xs_error_code_t readARMSoftwareVersion(version_t &version) = 0;
  72. virtual xs_error_code_t readFPGASoftwareVersion(version_t &version) = 0;
  73. // virtual xs_error_code_t changeNetworkConfig(string ip, string mask, string gateway) = 0;
  74. public:
  75. virtual xs_error_code_t reg_write(uint32_t regadd, uint32_t regvalue, uint32_t &regbackvalue, int32_t overtime_ms = 100) = 0;
  76. virtual xs_error_code_t reg_read(uint32_t regadd, uint32_t &regvalue, int32_t overtime_ms = 100) = 0;
  77. public:
  78. /***********************************************************************************************
  79. * *
  80. ***********************************************************************************************/
  81. /**
  82. * @brief
  83. *
  84. * : 33
  85. * TTLInputModule1_XXXXX: TTL1_IN
  86. * TTLInputModule2_XXXXX: TTL2_IN
  87. * TTLInputModule3_XXXXX: TTL3_IN
  88. * TTLInputModule4_XXXXX:
  89. *
  90. * ExternalTimecode_XXXXX : BNC时码输入口
  91. *
  92. * ExternalGenlock_XXXXX : GENLOCK输入口
  93. *
  94. *
  95. *
  96. *
  97. * 使:
  98. * 使使
  99. *
  100. * ExternalTimecode_setSource
  101. * :
  102. * :
  103. * INPUT_IF_TIMECODE_BNC
  104. * INPUT_IF_TIMECODE_HEADPHONE
  105. *
  106. *
  107. * ExternalTimecode_setFormat
  108. * :
  109. * :
  110. * TIMECODE_FPS2398
  111. * TIMECODE_FPS2400
  112. * TIMECODE_FPS2500
  113. * TIMECODE_FPS2997
  114. * TIMECODE_FPS2997Drop
  115. * TIMECODE_FPS3000
  116. *
  117. *
  118. * TTLInputModuleX_detectFreq
  119. * :TTL输入频率
  120. *
  121. * ExternalGenlock_detectFreq
  122. * :GENLOCK信号频率
  123. *
  124. */
  125. virtual xs_error_code_t ExternalTimecode_readSrc(InputInterface_t &timecode) = 0;
  126. virtual xs_error_code_t ExternalTimecode_readCode(XsyncTimecode_t &timecode) = 0;
  127. virtual xs_error_code_t ExternalTimecode_readFreq(float &freq) = 0;
  128. virtual xs_error_code_t ExternalTimecode_readFormat(TimecodeFormat_t &timecode) = 0;
  129. virtual xs_error_code_t TTLInputModule1_detectFreq(float &freq) = 0;
  130. virtual xs_error_code_t TTLInputModule2_detectFreq(float &freq) = 0;
  131. virtual xs_error_code_t TTLInputModule3_detectFreq(float &freq) = 0;
  132. virtual xs_error_code_t TTLInputModule4_detectFreq(float &freq) = 0;
  133. virtual xs_error_code_t ExternalGenlock_detectFreq(float &freq) = 0;
  134. /***********************************************************************************************
  135. * *
  136. ***********************************************************************************************/
  137. /**
  138. * @brief
  139. *
  140. * : 7
  141. * InternalTimecode_XXXXX :
  142. * InternalGenlock_XXXXX :
  143. * InternalClock_XXXXX :
  144. *
  145. * SysTimecode_XXXXX :
  146. * SysGenlock_XXXXX :
  147. * SysClock_XXXXX :
  148. *
  149. *
  150. *
  151. * :
  152. * Xsync系统中一共有三个比较重要概念GenlockGenlock
  153. * GenlockGenlockGenlock
  154. * Genlock
  155. *
  156. *
  157. * ---|1
  158. * ---|0 ---->
  159. *
  160. *
  161. * Genlock ---|1
  162. * Genlock ---|0 ----> Genlock
  163. *
  164. *
  165. * ---|
  166. * Genlock ---|
  167. * ---| ---->
  168. * TTL输入信号 ---|
  169. * ---|
  170. *
  171. *
  172. * :
  173. * 1. GenlockAPI进行修改
  174. * 2. GenlockGenlock
  175. * 3. 沿
  176. *
  177. *
  178. */
  179. virtual xs_error_code_t InternalSigSrouce_start() = 0;
  180. virtual xs_error_code_t InternalSigSrouce_stop() = 0;
  181. virtual xs_error_code_t InternalSigSrouce_readState(bool &en) = 0;
  182. virtual xs_error_code_t InternalTimecode_setFormat(TimecodeFormat_t format) = 0;
  183. virtual xs_error_code_t InternalTimecode_getFormat(TimecodeFormat_t &format) = 0;
  184. virtual xs_error_code_t InternalTimecode_setCode(XsyncTimecode_t timecode) = 0;
  185. virtual xs_error_code_t InternalTimecode_getCode(XsyncTimecode_t &timecode) = 0;
  186. virtual xs_error_code_t InternalTimecode_readFreq(float &freq) = 0;
  187. virtual xs_error_code_t InternalGenlock_setFormat(GenlockFormat_t format) = 0;
  188. virtual xs_error_code_t InternalGenlock_getFormat(GenlockFormat_t &format) = 0;
  189. virtual xs_error_code_t InternalClock_setFreq(float freq) = 0;
  190. virtual xs_error_code_t InternalClock_getFreq(float &freq) = 0;
  191. /*******************************************************************************
  192. * *
  193. *******************************************************************************/
  194. virtual xs_error_code_t SysTimecode_setSource(uint32_t sig) = 0;
  195. virtual xs_error_code_t SysTimecode_getSource(uint32_t &sig) = 0;
  196. virtual xs_error_code_t SysTimecode_readFormat(TimecodeFormat_t &format) = 0;
  197. virtual xs_error_code_t SysTimecode_readCode(XsyncTimecode_t &timecode) = 0;
  198. virtual xs_error_code_t SysTimecode_readFreq(float &freq) = 0;
  199. virtual xs_error_code_t SysGenlock_setSrc(uint32_t source) = 0;
  200. virtual xs_error_code_t SysGenlock_getSrc(uint32_t &source) = 0;
  201. virtual xs_error_code_t SysGenlock_readFreq(float &freq) = 0;
  202. virtual xs_error_code_t SysClock_setSrc(SignalType_t sig) = 0;
  203. virtual xs_error_code_t SysClock_getSrc(SignalType_t &sig) = 0;
  204. virtual xs_error_code_t SysClock_setTriggerEdge(TriggerEdge_t edge) = 0;
  205. virtual xs_error_code_t SysClock_getTriggerEdge(TriggerEdge_t &edge) = 0;
  206. virtual xs_error_code_t SysClock_setFreqDivision(uint32_t div) = 0;
  207. virtual xs_error_code_t SysClock_geFreqtDivision(uint32_t &div) = 0;
  208. virtual xs_error_code_t SysClock_setFreqMultiplication(uint32_t muti) = 0;
  209. virtual xs_error_code_t SysClock_getFreqMultiplication(uint32_t &muti) = 0;
  210. virtual xs_error_code_t SysClock_readOutSigFreq(float &freq) = 0;
  211. virtual xs_error_code_t SysClock_readInSigFreq(float &freq) = 0;
  212. /***********************************************************************************************
  213. * *
  214. ***********************************************************************************************/
  215. /**
  216. * @brief
  217. *
  218. * :
  219. * 使
  220. * TimeCode启动TTL触发启动三种方式RecordSigGenerator_setContrlMode可以设置
  221. *
  222. * :
  223. *
  224. * RecordSigGenerator_setContrlMode将模式配置成CONTROLMODE_MANUAL_TRIGGER
  225. *
  226. * RecordSigGenerator_manualStart
  227. * RecordSigGenerator_manualStop
  228. *
  229. *
  230. * Timecode控制:
  231. *
  232. * Timecode控制启动RecordSigGenerator_setContrlMode将模式配置成CONTROLMODE_TIMECODE_TRIGGER
  233. * RecordSigGenerator_setTimecodeCtrlFlag方法使Timecode自动控制
  234. * 使Timecode自动控制停止
  235. * RecordSigGenerator_setAutoStartTimecode :
  236. * RecordSigGenerator_setAutoStopTimecode :
  237. * RecordSigGenerator_setTimecodeCtrlFlag :使使
  238. *
  239. * TTL控制:
  240. *
  241. * TTL触发启动RecordSigGenerator_setContrlMode将模式配置成CONTROLMODE_EXTERNALTTL_TRIGGER
  242. *
  243. * RecordSigGenerator_setExternalTTLTriggerSrc : TTL触发源INPUT_IF_TTL1->INPUT_IF_TTL4
  244. * RecordSigGenerator_setExternalTTLTriggerPolarity : (0:1:)
  245. *
  246. *
  247. *
  248. * RecordSigGenerator_setRecordExposureTime
  249. * RecordSigGenerator_setRecordExposureOffsetTime
  250. *
  251. *
  252. */
  253. virtual xs_error_code_t RecordSigGenerator_setContrlMode(ControlMode_t mode) = 0;
  254. virtual xs_error_code_t RecordSigGenerator_getContrlMode(ControlMode_t &mode) = 0;
  255. virtual xs_error_code_t RecordSigGenerator_manualStart() = 0;
  256. virtual xs_error_code_t RecordSigGenerator_manualStop() = 0;
  257. virtual xs_error_code_t RecordSigGenerator_setAutoStartTimecode(XsyncTimecode_t timecode) = 0;
  258. virtual xs_error_code_t RecordSigGenerator_setAutoStopTimecode(XsyncTimecode_t timecode) = 0;
  259. virtual xs_error_code_t RecordSigGenerator_getAutoStartTimecode(XsyncTimecode_t &timecode) = 0;
  260. virtual xs_error_code_t RecordSigGenerator_getAutoStopTimecode(XsyncTimecode_t &timecode) = 0;
  261. virtual xs_error_code_t RecordSigGenerator_setTimecodeCtrlFlag(uint32_t autoStart, uint32_t autoStop) = 0;
  262. virtual xs_error_code_t RecordSigGenerator_getTimecodeCtrlFlag(uint32_t &autoStart, uint32_t &autoStop) = 0;
  263. virtual xs_error_code_t RecordSigGenerator_setExternalTTLTriggerSrc(InputInterface_t ttlPortNum) = 0;
  264. virtual xs_error_code_t RecordSigGenerator_getExternalTTLTriggerSrc(InputInterface_t &ttlPortNum) = 0;
  265. virtual xs_error_code_t RecordSigGenerator_setExternalTTLTriggerPolarity(uint32_t polarity) = 0;
  266. virtual xs_error_code_t RecordSigGenerator_getExternalTTLTriggerPolarity(uint32_t &polarity) = 0;
  267. virtual xs_error_code_t RecordSigGenerator_setRecordExposureTime(uint32_t us) = 0;
  268. virtual xs_error_code_t RecordSigGenerator_getRecordExposureTime(uint32_t &us) = 0;
  269. virtual xs_error_code_t RecordSigGenerator_setRecordExposureOffsetTime(uint32_t us) = 0;
  270. virtual xs_error_code_t RecordSigGenerator_getRecordExposureOffsetTime(uint32_t &us) = 0;
  271. virtual xs_error_code_t RecordSigGenerator_getRecordState(uint32_t &state) = 0;
  272. virtual xs_error_code_t RecordSigGenerator_readTimecodeSnapshot(XsyncTimecode_t &timecode) = 0;
  273. /***********************************************************************************************
  274. * *
  275. ***********************************************************************************************/
  276. /**
  277. * @brief 4TTLTimecodeGenlockTTL输出()
  278. *
  279. *
  280. * TTL输出组件
  281. * :
  282. * SIGNAL_LOGIC0
  283. * SIGNAL_LOGIC1
  284. * SIGNAL_TTLIN1
  285. * SIGNAL_TTLIN2
  286. * SIGNAL_TTLIN3
  287. * SIGNAL_TTLIN4
  288. * SIGNAL_SYS_CLK_OUTPUT
  289. * SIGNAL_SYS_GENLOCK_OUTPUT
  290. * SIGNAL_SYS_TIMECODE_FREQ_OUTPUT
  291. * SIGNAL_BUSINESS_RECORD_SIG
  292. * SIGNAL_BUSINESS_RECORD_EXPOSURE_SIG
  293. *
  294. * :
  295. * SIGNAL_BUSINESS_RECORD_SIG SIGNAL_BUSINESS_RECORD_EXPOSURE_SIG
  296. * 012
  297. * 012
  298. *
  299. *
  300. */
  301. virtual xs_error_code_t TTLOutputModule1_setSrcSigType(SignalType_t source) = 0;
  302. virtual xs_error_code_t TTLOutputModule1_getSrcSigType(SignalType_t &source) = 0;
  303. virtual xs_error_code_t TTLOutputModule1_setFreqDivision(uint32_t div) = 0;
  304. virtual xs_error_code_t TTLOutputModule1_getFreqDivision(uint32_t &div) = 0;
  305. virtual xs_error_code_t TTLOutputModule1_setFreqMultiplication(uint32_t multi) = 0;
  306. virtual xs_error_code_t TTLOutputModule1_getFreqMultiplication(uint32_t &multi) = 0;
  307. virtual xs_error_code_t TTLOutputModule1_readInFreq(float &freq) = 0;
  308. virtual xs_error_code_t TTLOutputModule1_readOutFreq(float &freq) = 0;
  309. virtual xs_error_code_t TTLOutputModule2_setSrcSigType(SignalType_t source) = 0;
  310. virtual xs_error_code_t TTLOutputModule2_getSrcSigType(SignalType_t &source) = 0;
  311. virtual xs_error_code_t TTLOutputModule2_setFreqDivision(uint32_t div) = 0;
  312. virtual xs_error_code_t TTLOutputModule2_getFreqDivision(uint32_t &div) = 0;
  313. virtual xs_error_code_t TTLOutputModule2_setFreqMultiplication(uint32_t multi) = 0;
  314. virtual xs_error_code_t TTLOutputModule2_getFreqMultiplication(uint32_t &multi) = 0;
  315. virtual xs_error_code_t TTLOutputModule2_readInFreq(float &freq) = 0;
  316. virtual xs_error_code_t TTLOutputModule2_readOutFreq(float &freq) = 0;
  317. virtual xs_error_code_t TTLOutputModule3_setSrcSigType(SignalType_t source) = 0;
  318. virtual xs_error_code_t TTLOutputModule3_getSrcSigType(SignalType_t &source) = 0;
  319. virtual xs_error_code_t TTLOutputModule3_setFreqDivision(uint32_t div) = 0;
  320. virtual xs_error_code_t TTLOutputModule3_getFreqDivision(uint32_t &div) = 0;
  321. virtual xs_error_code_t TTLOutputModule3_setFreqMultiplication(uint32_t multi) = 0;
  322. virtual xs_error_code_t TTLOutputModule3_getFreqMultiplication(uint32_t &multi) = 0;
  323. virtual xs_error_code_t TTLOutputModule3_readInFreq(float &freq) = 0;
  324. virtual xs_error_code_t TTLOutputModule3_readOutFreq(float &freq) = 0;
  325. virtual xs_error_code_t TTLOutputModule4_setSrcSigType(SignalType_t source) = 0;
  326. virtual xs_error_code_t TTLOutputModule4_getSrcSigType(SignalType_t &source) = 0;
  327. virtual xs_error_code_t TTLOutputModule4_setFreqDivision(uint32_t div) = 0;
  328. virtual xs_error_code_t TTLOutputModule4_getFreqDivision(uint32_t &div) = 0;
  329. virtual xs_error_code_t TTLOutputModule4_setFreqMultiplication(uint32_t multi) = 0;
  330. virtual xs_error_code_t TTLOutputModule4_getFreqMultiplication(uint32_t &multi) = 0;
  331. virtual xs_error_code_t TTLOutputModule4_readInFreq(float &freq) = 0;
  332. virtual xs_error_code_t TTLOutputModule4_readOutFreq(float &freq) = 0;
  333. /*******************************************************************************
  334. * *
  335. *******************************************************************************/
  336. virtual xs_error_code_t Utils_readSigFreq(SignalType_t sig, float &freq) = 0;
  337. };
  338. } // namespace xsync