From 9419203b1578feaa47a28dfcb6d5bf2113c6f127 Mon Sep 17 00:00:00 2001
From: Jonathan Hanks <jonathan.hanks@ligo.org>
Date: Wed, 4 Nov 2020 13:58:25 -0800
Subject: [PATCH] Changed the PV type for the checksum PVs in cps_recv to
 double to match daqd.

Daqd exports all PVs as doubles, changing the channel list checksum and data checksum to be doubles to match.  If this is not done, then a negative value is shown if the high bit is set when viewing the cps_recv version of the checksum, where the daqd shows a large positive number.
---
 src/pub_sub_stream/dc_stats.cc | 24 ++++++++++++------------
 src/pub_sub_stream/dc_stats.hh |  4 ++--
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/pub_sub_stream/dc_stats.cc b/src/pub_sub_stream/dc_stats.cc
index 7458cb44f..e2011bee2 100644
--- a/src/pub_sub_stream/dc_stats.cc
+++ b/src/pub_sub_stream/dc_stats.cc
@@ -202,7 +202,7 @@ DCStats::DCStats( std::vector< SimplePV >& pvs,
     }
     total_chans_ = boost::accumulate( channels_, 0, count_data_channels );
 
-    channel_config_hash_ = static_cast< int >( crc.result( ) );
+    channel_config_hash_ = static_cast< double >( crc.result( ) );
     std::cerr << "Loaded " << channels_.size( ) << " tp + channels"
               << std::endl;
 
@@ -250,7 +250,7 @@ DCStats::DCStats( std::vector< SimplePV >& pvs,
     } );
     pvs.emplace_back( SimplePV{
         "PRDCR_DATA_CRC",
-        SIMPLE_PV_INT,
+        SIMPLE_PV_DOUBLE,
         reinterpret_cast< void* >( &data_crc_ ),
         std::numeric_limits< int >::max( ),
         std::numeric_limits< int >::min( ),
@@ -259,7 +259,7 @@ DCStats::DCStats( std::vector< SimplePV >& pvs,
     } );
     pvs.emplace_back( SimplePV{
         "CHANNEL_LIST_CHECK_SUM",
-        SIMPLE_PV_INT,
+        SIMPLE_PV_DOUBLE,
         reinterpret_cast< void* >( &channel_config_hash_ ),
         std::numeric_limits< int >::max( ),
         std::numeric_limits< int >::min( ),
@@ -297,10 +297,10 @@ DCStats::DCStats( std::vector< SimplePV >& pvs,
         "PRDCR_UNIQUE_DCU_REPORTED_PER_S",
         SIMPLE_PV_INT,
         reinterpret_cast< void* >( &unique_dcus_per_sec_ ),
-        static_cast< int >( dcus.size( ) ) + 1,
-        static_cast< int >( dcus.size( ) ) - 1,
-        static_cast< int >( dcus.size( ) ) + 1,
-        static_cast< int >( dcus.size( ) ) - 1,
+        static_cast< double >( dcus.size( ) ) + 1,
+        static_cast< double >( dcus.size( ) ) - 1,
+        static_cast< double >( dcus.size( ) ) + 1,
+        static_cast< double >( dcus.size( ) ) - 1,
     } );
     pvs.emplace_back( SimplePV{
         "DATA_RATE",
@@ -315,10 +315,10 @@ DCStats::DCStats( std::vector< SimplePV >& pvs,
         "TOTAL_CHANS",
         SIMPLE_PV_INT,
         reinterpret_cast< void* >( &total_chans_ ),
-        total_chans_ + 1,
-        total_chans_ - 1,
-        total_chans_ + 1,
-        total_chans_ - 1,
+        static_cast< double >( total_chans_ + 1 ),
+        static_cast< double >( total_chans_ - 1 ),
+        static_cast< double >( total_chans_ + 1 ),
+        static_cast< double >( total_chans_ - 1 ),
     } );
     pvs.emplace_back( SimplePV{
         "PRDCR_OPEN_TP_COUNT",
@@ -733,7 +733,7 @@ DCStats::run( simple_pv_handle epics_server )
                           total_data_crc.add( &( entry.second ),
                                               sizeof( entry.second ) );
                       } );
-            data_crc_ = static_cast< unsigned int >( total_data_crc.result( ) );
+            data_crc_ = static_cast< double >( total_data_crc.result( ) );
         }
 
         // we can either do this off of our counter or off of the
diff --git a/src/pub_sub_stream/dc_stats.hh b/src/pub_sub_stream/dc_stats.hh
index 449f13916..905f21cbb 100644
--- a/src/pub_sub_stream/dc_stats.hh
+++ b/src/pub_sub_stream/dc_stats.hh
@@ -147,8 +147,8 @@ private:
     int          not_stalled_{ 0 };
     int          uptime_{ 0 };
     unsigned int gpstime_{ 0 };
-    int          data_crc_{ 0 };
-    int          channel_config_hash_{ 0 };
+    double       data_crc_{ 0 };
+    double       channel_config_hash_{ 0 };
     int          unique_dcus_per_sec_{ 0 };
     int          data_rate_{ 0 };
     int          total_chans_{ 0 };
-- 
GitLab