/*
 * grifo_header.h
 *
 */

#ifndef GRIFO_HEADER_H_
#define GRIFO_HEADER_H_

namespace gpb_header
{

typedef int timetag_t;

struct header_info_t
{
	unsigned int header_marker;
	unsigned int rev_id;
	unsigned int header_dim;
};

struct siminfo_t
{
    enum validity_codes_t { v_valid=0x4F5053/*="OPR"*/, v_gabbiano_dbs=0x716566/*="GAB"*/};

    int validity;
    unsigned int sigremap;   //0=standard map. Filled by simulator if required

    enum batch_type_t {
        batch_operative=0,      //from 0..99, an operative batch
        batch_calibration=100,  //from 100.199: a calibraiton batch
        batch_test=200};        //from 200.299: a tets (BITE) batch

    unsigned int batch_types;
    unsigned int signal_destination; //0=default (DSP), 1=EIF (? never used), 2=DFE, 3=DSP. >0x10 -> SRIO destination ID

    unsigned int data[6];   //custom data, depending on validity and batch type. For DBS Gabbiano vector, carry some data overrides not present in header
};

struct packet_descr_t
{
	unsigned int npri;
	unsigned int nrbin;
	unsigned int num_of_channels;
	unsigned int block_dim;
	unsigned int signal_order;
};
struct signal_descr_t
{
	unsigned int bacth_counter;
	timetag_t ttag;
	struct packet_descr_t packet_descr;
	unsigned int packet_len;
	unsigned int num_of_packets;
};


struct signal_mini_header_t
{
    header_info_t info;
    siminfo_t sim_info;
    signal_descr_t signal;
};

struct hdr0_mini_t
{
	uint32_t preamble[17-(6+3)];

    uint32_t header_type;
    uint32_t header_counter;
    uint32_t ch_mask;

    signal_mini_header_t hdr;
};

struct soft_mini_header_t
{
    signal_mini_header_t hdr;
};

}/*namespace*/




#endif /* GRIFO_HEADER_H_ */
