Skip to content

Commit

Permalink
decode gtm data separately
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkenburg committed Aug 29, 2024
1 parent 57e40ad commit cd7289b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
56 changes: 53 additions & 3 deletions newbasic/oncsSub_idtpcfeev4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 ()
{

Expand Down Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions newbasic/oncsSub_idtpcfeev4.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<unsigned short>::max();
Expand Down

0 comments on commit cd7289b

Please sign in to comment.