Skip to content
Snippets Groups Projects
Commit d895b6b0 authored by Jonathan Hanks's avatar Jonathan Hanks
Browse files

Adding {prefix}TOTAL_CRC_SUM to cps_recv.

parent 87ed6f6d
No related branches found
No related tags found
1 merge request!170Cps recv to get dc diags
...@@ -356,6 +356,15 @@ DCStats::DCStats( std::vector< SimplePV >& pvs, ...@@ -356,6 +356,15 @@ DCStats::DCStats( std::vector< SimplePV >& pvs,
std::numeric_limits< int >::max( ), std::numeric_limits< int >::max( ),
-1, -1,
} ); } );
pvs.emplace_back( SimplePV{
"TOTAL_CRC_SUM",
SIMPLE_PV_INT,
reinterpret_cast< void* >( &total_crc_count_ ),
1,
1,
-1,
-1,
} );
valid_ = true; valid_ = true;
} }
...@@ -574,6 +583,12 @@ entry_was_processed( DCUStats& cur ) ...@@ -574,6 +583,12 @@ entry_was_processed( DCUStats& cur )
return cur.processed; return cur.processed;
} }
static std::int64_t
total_crc_sum( std::int64_t val, const DCUStats& cur )
{
return val + static_cast< std::int64_t >( cur.crc_sum );
}
dc_queue::value_type dc_queue::value_type
DCStats::get_message( simple_pv_handle epics_server ) DCStats::get_message( simple_pv_handle epics_server )
{ {
...@@ -602,6 +617,7 @@ DCStats::run( simple_pv_handle epics_server ) ...@@ -602,6 +617,7 @@ DCStats::run( simple_pv_handle epics_server )
std::vector< dcuid_crc_pair > data_block_crcs; std::vector< dcuid_crc_pair > data_block_crcs;
data_block_crcs.reserve( DCU_COUNT ); data_block_crcs.reserve( DCU_COUNT );
int prev_total_crc_count{ 0 };
std::uint64_t tp_data{ 0 }; std::uint64_t tp_data{ 0 };
std::uint64_t model_data{ 0 }; std::uint64_t model_data{ 0 };
std::uint64_t total_data{ 0 }; std::uint64_t total_data{ 0 };
...@@ -694,6 +710,13 @@ DCStats::run( simple_pv_handle epics_server ) ...@@ -694,6 +710,13 @@ DCStats::run( simple_pv_handle epics_server )
for_each( dcu_status_, mark_dcu_if_skipped_this_cycle ); for_each( dcu_status_, mark_dcu_if_skipped_this_cycle );
for_each( dcu_status_, clear_seen_last_cycle_if_skipped ); for_each( dcu_status_, clear_seen_last_cycle_if_skipped );
uint64_t crc_sum = boost::accumulate( dcu_status_, 0, total_crc_sum );
if ( crc_sum > prev_total_crc_count )
{
total_crc_count_ += crc_sum - prev_total_crc_count;
}
prev_total_crc_count = crc_sum;
bool alternating_cycle = cycles % 2 == 0; bool alternating_cycle = cycles % 2 == 0;
bool one_sec_update = cycles % 16 == 0; bool one_sec_update = cycles % 16 == 0;
...@@ -739,6 +762,7 @@ DCStats::run( simple_pv_handle epics_server ) ...@@ -739,6 +762,7 @@ DCStats::run( simple_pv_handle epics_server )
{ {
for_each( dcu_status_, clear_crc ); for_each( dcu_status_, clear_crc );
request_clear_crc_ = false; request_clear_crc_ = false;
prev_total_crc_count = 0;
} }
} }
else if ( alternating_cycle ) else if ( alternating_cycle )
......
...@@ -108,6 +108,17 @@ public: ...@@ -108,6 +108,17 @@ public:
return dcu_status_[ dcuid ]; return dcu_status_[ dcuid ];
} }
/*!
* @brief Return the total crc count for the system, a debugging/testing
* aid.
* @return the sum of the crc count for the lifetime of this object.
*/
int
get_total_crcs( ) const
{
return total_crc_count_;
}
/*! /*!
* @brief get a readonly reference to the channel list * @brief get a readonly reference to the channel list
* @return the channel list * @return the channel list
...@@ -145,6 +156,7 @@ private: ...@@ -145,6 +156,7 @@ private:
unsigned int tp_data_kb_per_s_{ 0 }; unsigned int tp_data_kb_per_s_{ 0 };
unsigned int model_data_kb_per_s_{ 0 }; unsigned int model_data_kb_per_s_{ 0 };
unsigned int total_data_kb_per_s_{ 0 }; unsigned int total_data_kb_per_s_{ 0 };
int total_crc_count_{ 0 };
std::atomic< bool > request_clear_crc_{ false }; std::atomic< bool > request_clear_crc_{ false };
std::atomic< bool > request_stop_{ false }; std::atomic< bool > request_stop_{ false };
......
...@@ -142,6 +142,7 @@ TEST_CASE( ...@@ -142,6 +142,7 @@ TEST_CASE(
REQUIRE( dc_stats.peek_stats( 2 ).processed ); REQUIRE( dc_stats.peek_stats( 2 ).processed );
REQUIRE( dc_stats.peek_stats( 2 ).crc_sum == 0 ); REQUIRE( dc_stats.peek_stats( 2 ).crc_sum == 0 );
REQUIRE( dc_stats.peek_stats( 2 ).status == 0 ); REQUIRE( dc_stats.peek_stats( 2 ).status == 0 );
REQUIRE( dc_stats.get_total_crcs( ) == 0 );
{ {
auto data = make_unique_ptr< daq_dc_data_t >( ); auto data = make_unique_ptr< daq_dc_data_t >( );
memset( memset(
...@@ -158,6 +159,7 @@ TEST_CASE( ...@@ -158,6 +159,7 @@ TEST_CASE(
REQUIRE( dc_stats.peek_stats( 2 ).processed ); REQUIRE( dc_stats.peek_stats( 2 ).processed );
REQUIRE( dc_stats.peek_stats( 2 ).crc_sum == 0 ); REQUIRE( dc_stats.peek_stats( 2 ).crc_sum == 0 );
REQUIRE( dc_stats.peek_stats( 2 ).status == 0 ); REQUIRE( dc_stats.peek_stats( 2 ).status == 0 );
REQUIRE( dc_stats.get_total_crcs( ) == 1 );
{ {
auto data = make_unique_ptr< daq_dc_data_t >( ); auto data = make_unique_ptr< daq_dc_data_t >( );
memset( memset(
...@@ -174,6 +176,7 @@ TEST_CASE( ...@@ -174,6 +176,7 @@ TEST_CASE(
REQUIRE( dc_stats.peek_stats( 2 ).processed ); REQUIRE( dc_stats.peek_stats( 2 ).processed );
REQUIRE( dc_stats.peek_stats( 2 ).crc_sum == 0 ); REQUIRE( dc_stats.peek_stats( 2 ).crc_sum == 0 );
REQUIRE( dc_stats.peek_stats( 2 ).status == 0 ); REQUIRE( dc_stats.peek_stats( 2 ).status == 0 );
REQUIRE( dc_stats.get_total_crcs( ) == 1 );
dc_stats.stop( ); dc_stats.stop( );
th.join( ); th.join( );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment