diff --git a/xsync.cpp b/xsync.cpp index 8fcbe2c..265bbb5 100644 --- a/xsync.cpp +++ b/xsync.cpp @@ -128,9 +128,9 @@ xs_error_code_t Xsync::disConnect() { } xsync_net_state_t Xsync::getNetState() { return m_net_state; } -void Xsync::registerOnTimecodeMsgCallback(xsync_on_timecode_msg_t on_timecode_msg_cb) { m_on_timecode_msg_cb = on_timecode_msg_cb; } -void Xsync::registerOnCameraSyncMsgCallback(xsync_on_camera_sync_msg_t on_camera_sync_msg_cb) { m_on_camera_sync_msg_cb = on_camera_sync_msg_cb; } -void Xsync::registerOnWorkstateChangeMsgCallback(xsync_on_workstate_change_msg_t on_workstate_change_msg_cb) { m_on_workstate_change_msg_cb = on_workstate_change_msg_cb; } +void Xsync::registerOnTimecodeMsgCallback(xsync_on_timecode_msg_t cb) { m_on_timecode_msg_cb = cb; } +void Xsync::registerOnCameraSyncMsgCallback(xsync_on_camera_sync_msg_t cb) { m_on_camera_sync_msg_cb = cb; } +void Xsync::registerOnRecordSigChangeMsgCallback(xsync_on_record_sig_change_msg_t cb) { m_on_record_sig_change_msg_cb = cb; } xs_error_code_t Xsync::xsync_send_cmd_block(iflytop_xsync_packet_header_t *cmd, iflytop_xsync_packet_header_t *rx_data, int32_t buffersize, int32_t overtime_ms) { lock_guard lock(lock_); @@ -323,7 +323,12 @@ void Xsync::parseTimecodeMsgAndReport(XsyncNetAdd &from, uint8_t *data, size_t l if (m_on_timecode_msg_cb) m_on_timecode_msg_cb(&timecode); } else if (packet->eventid == kxsync_work_state_report_event) { // 信号发生器状态改变 - if (m_on_workstate_change_msg_cb) m_on_workstate_change_msg_cb(packet->data[0]); + Timecode64_t tc64; + tc64.tc0 = packet->data[1]; + tc64.tc1 = packet->data[2]; + XsyncTimecode_t timecode = timecode64ToXsyncTimeCode(tc64); + + if (m_on_record_sig_change_msg_cb) m_on_record_sig_change_msg_cb(packet->data[0], &timecode); } } void Xsync::parseCameraSyncMsgAndReport(XsyncNetAdd &from, uint8_t *data, size_t length) { @@ -634,7 +639,7 @@ xs_error_code_t Xsync::RecordSigGenerator_getExternalTTLTriggerPolarity(uint32_t return _reg_read(reg::record_sig_gen_ttlin_trigger_level, polarity); } xs_error_code_t Xsync::RecordSigGenerator_setRecordExposureTime(uint32_t us) { // - return reg_write(reg::record_sig_gen_exposure_time, us); + return reg_write(reg::record_sig_gen_exposure_time, us); } xs_error_code_t Xsync::RecordSigGenerator_getRecordExposureTime(uint32_t &us) { auto ret = reg_read(reg::record_sig_gen_exposure_time, us); diff --git a/xsync.hpp b/xsync.hpp index baa105f..535619c 100644 --- a/xsync.hpp +++ b/xsync.hpp @@ -20,9 +20,9 @@ namespace xsync { using namespace std; -typedef function xsync_on_timecode_msg_t; -typedef function xsync_on_workstate_change_msg_t; -typedef function xsync_on_camera_sync_msg_t; +typedef function xsync_on_timecode_msg_t; +typedef function xsync_on_record_sig_change_msg_t; +typedef function xsync_on_camera_sync_msg_t; class Xsync { public: @@ -37,9 +37,9 @@ class Xsync { 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_workstate_change_msg_t m_on_workstate_change_msg_cb = nullptr; + 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; @@ -61,9 +61,9 @@ class Xsync { xsync_net_state_t getNetState(); bool ping(string xsync_ip); - void registerOnTimecodeMsgCallback(xsync_on_timecode_msg_t on_timecode_msg_cb); - void registerOnCameraSyncMsgCallback(xsync_on_camera_sync_msg_t on_camera_sync_msg_cb); - void registerOnWorkstateChangeMsgCallback(xsync_on_workstate_change_msg_t on_workstate_change_msg_cb); + void registerOnTimecodeMsgCallback(xsync_on_timecode_msg_t cb); + void registerOnCameraSyncMsgCallback(xsync_on_camera_sync_msg_t cb); + void registerOnRecordSigChangeMsgCallback(xsync_on_record_sig_change_msg_t cb); xs_error_code_t reg_write(uint32_t regadd, uint32_t regvalue, uint32_t ®backvalue, int32_t overtime_ms = 100); xs_error_code_t reg_write(uint32_t regadd, uint32_t regvalue, int32_t overtime_ms = 100); @@ -445,6 +445,7 @@ class Xsync { */ xs_error_code_t RecordSigGenerator_getRecordState(uint32_t &state); xs_error_code_t RecordSigGenerator_readTimecodeSnapshot(XsyncTimecode_t &timecode); + private: xs_error_code_t doaction(uint32_t action, uint32_t actionval, uint32_t *ackreturn, int32_t overtime_ms = 100); xs_error_code_t storageConfig();