format Functions

Name

format Functions -- Functions to create ring items.

Synopsis


#include <DataFormat.h>
            

pPhysicsEventItem formatEventitem( size_t nWords, void* pPayload );

pPhysicsEventCountItem formatTriggerCountItem ( uint32_t runTime , time_ttimeStamp , uint64_ttriggerCount );

pScalerItem formatScalerItem ( unsigned scalerCount , time_ttimestamp , uint32_t btime , uint32etime , void* pCounters );

pTextItem formatTextItem ( unsigned nStrings , time_t stamp , uint32_t runTime , const char** pStrings , int type );

pStateChangeItem formatStateChange ( time_t stamp , uint32_t offset , uint32_t runNumber , const char* pTitle , uin32_t type );

pScalerItem formatNonIncrTSScalerItem( unsigned scalerCount , time_t timestamp , uint32_t btime , uint32_t etime , uint64_t eventTimestamp , void* pCounters , uint32_t timebaseDivisor );

pDataFormatformatDataFormat (void);

pGlomParameters formatGlomParameters ( uint64_t coincidenceWindow , intisBuilding , inttimestampPolicy );

pEventBuilderFragment formatEVBFragment ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , uint32_t payloadSize , const void* pPayload );

pEventBuilderFragment formatEVBFragmentUnknown ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , uint32_t payloadSize , const void* pPayload );

pPhysicsEventItem formatTimestampedEventItem ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , uint32_t payloadSize , const void* pPayload );

pPhysicsEventCountItem formatTimestampedTriggerCountItem ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , uint32_t runTime , uint32_t offsetDivisor , time_t stamp , uint64_t triggerCount );

pScalerItem formatTimestampedScalerItem ( uint64_ttimestamp , uint32_t sourceId , uint32_t barrier , int isIncremental , uint32_t timeIntervalDivisor , uint32_t timeofday , uint32_t btime , uint32_t etime , uint32_t nScalers , void* pCounters );

pTextItem formatTimestampedTextItem ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , unsigned nStrings , time_t stamp , uint32_t runTime , const char**pStrings , int type , uint32_t timeIntervalDivisor );

pStateChangeItem formatTimestampedStateChange ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , time_t stamp , uint32_t offset , uint32_t runNumber , uint32_t offsetDivisor , const char* pTitle , int type );

void* bodyPointer ( pRingItem pItem );

pAbnormalEndItem formatAbnormalEndItem (void);

DESCRIPTION

These functions produce dynamically allocated ring items that reflect the parameters that have been passed to them. All functions that create ring items use malloc(3) to allocate storage. When you no longer need an item you must free(3) the item to prevent memory leaks.

pPhysicsEventItem formatEventitem( size_t nWords , void* pPayload );

Creates a PHYSICS_EVENT ring item. nWords is the number of uint16_t objects that are in the event data pointed to by pPayload. When the ring item is created, a uint32_t containing nWords + 2 is inserted prior to the payload to conform to NSCL standards for the payload contents.

pPhysicsEventCountItem formatTriggerCountItem ( uint32_t runTime , time_ttimeStamp , uint64_ttriggerCount );

Creates a PHYSICS_EVENT_COUNT ring item. runTime should be the number of seconds into the run the items is emitted. timeStamp should be the unix time(2) at which the event count is being submittted and triggerCount is the total number of event triggers that have been created by this point in the run.

pScalerItem formatScalerItem ( unsigned scalerCount , time_ttimestamp , uint32_t btime , uint32etime , void* pCounters );

Creates a scaler ring item (INCREMENTAL_SCALERS). scalerCount is the number of scalers read out and pCounters points to an array of uint32_t scalers. btime and etime are respectively the beginning and end run offsets over which the scalers counted.

timestamp is the time at which the scaler data was read.

pTextItem formatTextItem ( unsigned nStrings , time_t stamp , uint32_t runTime , const char** pStrings , int type );

Creates a text ring item. The type of the ring items is provided by the type argument however this should be one of PACKET_TYPES or MONITORED_VARIABLES or a user type that is larger than FIRST_USER_ITEM_CODE.

The number of strings put in the item are nStrings and pStrings is a pointer to an array of pointers to the null terminated strings that are put in the s_strings storage of the ring item.

stamp is the unix time(2) at which the item was created and runTime the number of seconds into the run at which this time was created.

pStateChangeItem formatStateChange ( time_t stamp , uint32_t offset , uint32_t runNumber , const char* pTitle , uin32_t type );

Formats and returns a state change item. State change items reflect a change in the run state. While the type parameter provides the item type, this should normally be one of BEGIN_RUN, END_RUN, PAUSE_RUN or RESUME_RUN.

runNumber should be a unique run number for the run and pTitle should point to a null terminated title string.

offset is the time into the run at which the state change took place in seconds. This will be 0 for BEGIN_RUN and the number of seconds the run was active for END_RUN

Finally stamp is the unix absolute timestamp from time(2) at which the state change occured.

pScalerItem formatNonIncrTSScalerItem( unsigned scalerCount , time_t timestamp , uint32_t btime , uint32_t etime , uint64_t eventTimestamp , void* pCounters , uint32_t timebaseDivisor );

Formats a scaler ring item (ScalerItem) into dynamically allocated data and returns a pointer to the formatted item. The item will be created with the s_incremental flag of the body turned off. This is intended for compatibility with code written for NSCLDAQ 11.1-100. New code should just use formatTimestampedScalerItem

The scalers are defined by scalerCount which provides the number of scalers and pCounters which is a pointer to an array of scaler values. The timestamp, btime and etime values have the same meaning as for formatScalerItem

eventTimestamp associates an event timestamp value with the scaler item, forcing the creation of a body header. The source id and barrier type of that header are both set to zero.

timebaseDivisor supports btime and etime parameters that have resolutions less than one second. The run time in seconds is gotten by doing a floating point division of either of the time parameters by timebaseDivisor For example, if btime is 10 and timebaseDivisor is 4, the run time is 2.5 seconds>

Note that as with all of these functions, the resulting pointer is to dynamically allocated memor that must be released via a call to free(3),

pDataFormatformatDataFormat (void);

Formats a DataFormat ring item into dynamically allocated memory. A pointer to the resulting ring item is returned as the function value. The caller must free(3)

The function takes the values to put in this data item from the FORMAT_MAJOR and FORMAT_MINOR constant values defined in DataFormat.h at the time it was compiled.

pGlomParameters formatGlomParameters ( uint64_t coincidenceWindow , intisBuilding , int timestampPolicy );

Dynamically creates a GlomParameters ring item and returns a pointer to it. The coincidenceWindow parameter determines the value of the s_coincidenceTicks field and the isBuilding parameter determiens the value of the s_isBuilding field. timestampPolicy is used to fill in the s_timestampPolicy field.

The item must be released by the caller via a call to free(3).

pEventBuilderFragment formatEVBFragment ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , uint32_t payloadSize , const void* pPayload );

Formats an event builder frragment item with type EVB_FRAGMENT. The item is dynamically allocated and must be passed to free(3) to be released.

The contents of the ring item are as follows: The ring item body header is filled in from timestamp, sourceId and barrier. The event fragment payload size in bytes is payloadSize and the payload itself is copied in from pPayload.

pEventBuilderFragment formatEVBFragmentUnknown ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , uint32_t payloadSize , const void* pPayload );

This performs the same operation as formatEVBFragment however the ring item is given the type EVB_UNKNOWN_PAYLOAD

pPhysicsEventItem formatTimestampedEventItem ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , uint32_t payloadSize , const void* pPayload );

Creates an event ring item that has a full body header. The body header contents are determined by the timestamp, sourceId and barrier parameters. The contents of the event are payloadSize words (16 bit words) long and are pointed to by pPayload

pPhysicsEventCountItem formatTimestampedTriggerCountItem ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , uint32_t runTime , uint32_t offsetDivisor , time_t stamp , uint64_t triggerCount );

Creates a trigger count ring item that has a full body header. The body header allows trigger counts to be accumulated from several event sources. The body header is filled in from timestamp, sourceId and barrier

The runTime and offsetDivisor provide for sub-second timing information. The offset into the run in floating point seconds is given by the expression runTime/offsetDivisor

stamp is the unix time_t that describes the absolute time at which this item was created. The triggerCount item is the total number of triggers the sourceId has responded to since the beginnin of the run

pScalerItem formatTimestampedScalerItem ( uint64_ttimestamp , uint32_t sourceId , uint32_t barrier , int isIncremental , uint32_t timeIntervalDivisor , uint32_t timeofday , uint32_t btime , uint32_t etime , uint32_t nScalers , void* pCounters );

Creates a scaler ring item with a full body header. Scaler readout can be incremental or not and the time offsets for the start and end times (btime> and etime) of the counting interval use timeIntervalDivisor to supply sub-second time resolution.

The body header values are determined by timestamp, sourceId and barrier.

If isIncremental is true (nonzero), the scaler values are incremental. Incremental scaler values represent the number of counts during the btime etime interval only.

If isIncremental is false (zero), the scaler values are cumulative and represent the total number of counts since the start of the run.

The scalers themselves are pointed to by pCounters and nScalers tells you how many there are.

pTextItem formatTimestampedTextItem ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , unsigned nStrings , time_t stamp , uint32_t runTime , const char**pStrings , int type , uint32_t timeIntervalDivisor );

Creates a text list item with a full body header. The type of the ring item is determined by type. It should be one of PACKET_TYPES, MONITORED_VARIABLES or a user defined type.

The body header contents are determined by timestamp, sourceId and barrier

The time into the run at which this item was emitted in in floating point seconds is runTime/timeIntervalDivisor. The absolute time at which the item was created is stamp which is a Unix time_t value.

The number of strings is nStrings. pStrings is an array of pointers to each string, which must be null terminated like all Unix strings.

pStateChangeItem formatTimestampedStateChange ( uint64_t timestamp , uint32_t sourceId , uint32_t barrier , time_t stamp , uint32_t offset , uint32_t runNumber , uint32_t offsetDivisor , const char* pTitle , int type );

Creates a state change item that has a complete body header. The type parameter is the ring item type and should be any of BEGIN_RUN, END_RUN, PAUSE_RUN or RESUME_RUN or a user defined ring item type if appropriate.

The body header is determine by timestamp, sourceId and barrier

The Offset into the run at which this item was emitted in seconds is: offset/offsetDivisor. The stamp parameter is the Unix time_t that specifies the absolute time at which the item was emitted.

Information about the run is also provided. runNumber is the number of the run and pTitle points to the null terminated title string.

pAbnormalEndItem formatAbnormalEndItem (void);

Formats an abnormal end item and returns a pointer to the dynamically allocated item. You must at some point call free(3) to release the storage allocated to this ring item.

void* bodyPointer ( pRingItem pItem );

The pointer to the actual body of an item depends on whether or not a body header is present in the item. This function will return a pointer to the body of a ring item pItem taking this into account.

RETURNS

Pointers to dynamically allocated storage which has been filled in with the requested ring item. When the caller is done with the item it should pass it to free(3) to release the storage.

If storage could not be allocated for the ring item NULL is returned instead.