From cd7289bfe3a988ea8629cbe2603c72ddf78d33aa Mon Sep 17 00:00:00 2001 From: Chris Pinkenburg Date: Thu, 29 Aug 2024 15:27:54 -0400 Subject: [PATCH] decode gtm data separately --- newbasic/oncsSub_idtpcfeev4.cc | 56 ++++++++++++++++++++++++++++++++-- newbasic/oncsSub_idtpcfeev4.h | 6 ++-- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/newbasic/oncsSub_idtpcfeev4.cc b/newbasic/oncsSub_idtpcfeev4.cc index 7c98a30..699dfca 100644 --- a/newbasic/oncsSub_idtpcfeev4.cc +++ b/newbasic/oncsSub_idtpcfeev4.cc @@ -11,8 +11,6 @@ using namespace std; oncsSub_idtpcfeev4::oncsSub_idtpcfeev4(subevtdata_ptr data) :oncsSubevent_w2 (data) { - - _is_decoded = 0; _last_requested_element = -1; // impossible value to mark "unnused" _last_requested_waveform = 0; } @@ -106,6 +104,58 @@ int oncsSub_idtpcfeev4::decode_gtm_data(unsigned short dat[16]) return 0; } +int oncsSub_idtpcfeev4::tpc_gtm_decode () +{ + + if (_is_gtm_decoded ) return 0; + _is_gtm_decoded = 1; + + unsigned int payload_length = 2 * (getLength() - SEVTHEADERLENGTH - getPadding() ); + + unsigned int index = 0; + + unsigned short *buffer = ( unsigned short *) &SubeventHdr->data; + + // demultiplexer + while (index < payload_length) + { + // Length for the 256-bit wide Round Robin Multiplexer for the data stream + const unsigned int datalength = 0xf; + + if ((buffer[index] & 0xFF00) == FEE_MAGIC_KEY) + { + + unsigned int fee_id = buffer[index] & 0xff; + // coutfl << " index = " << index << " fee_id = " << fee_id << " len = " << datalength << endl; + ++index; + if (fee_id < MAX_FEECOUNT) + { + index += datalength; + } + if (index >= payload_length) break; + } + else if ((buffer[index] & 0xFF00) == GTM_MAGIC_KEY) + { + unsigned short buf[16]; + + // memcpy? + for (unsigned int i = 0; i < 16; i++) + { + buf[i] = buffer[index++]; + } + + decode_gtm_data(buf); + } + else + { + // not FEE data, e.g. GTM data or other stream, to be decoded + index += datalength + 1; + } + + } + return 0; +} + int oncsSub_idtpcfeev4::tpc_decode () { @@ -290,7 +340,7 @@ int oncsSub_idtpcfeev4::tpc_decode () long long oncsSub_idtpcfeev4::lValue(const int n, const char *what) { - tpc_decode(); + tpc_gtm_decode(); // this only decodes the gtm const size_t i = n; diff --git a/newbasic/oncsSub_idtpcfeev4.h b/newbasic/oncsSub_idtpcfeev4.h index 5b6a0aa..c238890 100644 --- a/newbasic/oncsSub_idtpcfeev4.h +++ b/newbasic/oncsSub_idtpcfeev4.h @@ -29,7 +29,8 @@ class oncsSub_idtpcfeev4 : public oncsSubevent_w2 { protected: - int tpc_decode (); + int tpc_decode(); + int tpc_gtm_decode(); static const unsigned short MAGIC_KEY_0 = 0xfe; // static const unsigned short MAGIC_KEY_1 = 0x00; @@ -56,7 +57,8 @@ class oncsSub_idtpcfeev4 : public oncsSubevent_w2 { int _broken; - int _is_decoded; + int _is_decoded{0}; + int _is_gtm_decoded{0}; struct sampa_waveform { unsigned short fee = std::numeric_limits::max();