das2C
das core C utilities (v3)
packet.h
Go to the documentation of this file.
1 /* Copyright (C) 2004-2017 Jeremy Faden <jeremy-faden@uiowa.edu>
2  * Chris Piker <chris-piker@uiowa.edu>
3  *
4  * This file is part of das2C, the Core Das C Library.
5  *
6  * Das2C is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * Das2C is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 2.1 along with Das2C; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 
22 #ifndef _das_packet_h_
23 #define _das_packet_h_
24 
25 #include <das2/plane.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
32 #define MAXPLANES 100
33 
138 typedef struct packet_descriptor {
139  DasDesc base;
140 
141  int id;
142 
143  size_t uPlanes;
144  PlaneDesc* planes[MAXPLANES];
145 
146  /* Set to true when encode is called, make sure data doesn't go
147  * out the door unless the descriptor is sent first */
148  bool bSentHdr;
149 
150  /* Packets with the same group identifier can be plotted together on
151  * the same graph */
152  char* sGroup;
153 
161  void* pUser;
162 } PktDesc;
163 
164 
170 DAS_API PktDesc* new_PktDesc(void);
171 
176 DAS_API PktDesc* copy_PktDesc(const PktDesc* pOther);
177 
189 DAS_API PktDesc* new_PktDesc_xml(DasBuf* pBuf, DasDesc* pParent, int nPktId);
190 
196 DAS_API void del_PktDesc(PktDesc* pThis);
197 
209 DAS_API bool PktDesc_equalFormat(const PktDesc* pPd1, const PktDesc* pPd2);
210 
219 DAS_API int PktDesc_getId(const PktDesc* pThis);
220 
231 DAS_API const char* PktDesc_getGroup(const PktDesc* pThis);
232 
239 DAS_API void PktDesc_setGroup(PktDesc* pThis, const char* sGroup);
240 
241 
248 DAS_API size_t PktDesc_recBytes(const PktDesc* pThis);
249 
250 
256 DAS_API size_t PktDesc_getNPlanes(const PktDesc* pThis);
257 
265 DAS_API size_t PktDesc_getNPlanesOfType(const PktDesc* pThis, plane_type_t pt);
266 
298 DAS_API int PktDesc_addPlane(PktDesc* pThis, PlaneDesc* pPlane);
299 
300 
313 DAS_API DasErrCode PktDesc_copyPlanes(PktDesc* pThis, const PktDesc* pOther);
314 
327 DAS_API bool PktDesc_validate(PktDesc* pThis );
328 
346 DAS_API plane_type_t PktDesc_getPlaneType(const PktDesc* pThis, int iPlane);
347 
348 
359 DAS_API PlaneDesc* PktDesc_getPlane(PktDesc* pThis, int iplane);
360 
361 
368 DAS_API int PktDesc_getPlaneIdx(PktDesc* pThis, PlaneDesc* pPlane);
369 
375 DAS_API PlaneDesc* PktDesc_getPlaneByName(PktDesc* pThis, const char* name);
376 
387  PktDesc* pThis, plane_type_t ptype, int iRelIndex);
388 
407  const PktDesc* pThis, plane_type_t ptype, int iRelIndex
408 );
409 
418  PktDesc* pThis, const char* name, plane_type_t planeType
419 );
420 
425 
434 DAS_API DasErrCode PktDesc_encode(const PktDesc* pThis, DasBuf* pBuf);
435 
447 DAS_API DasErrCode PktDesc_encodeData(const PktDesc* pThis, DasBuf* pBuf);
448 
457 
472  PktDesc* pThis, size_t uPlane, size_t uItem, double val
473 );
474 
489  PktDesc* pThis, size_t uPlane, const double* pVals
490 );
491 
492 #ifdef __cplusplus
493 }
494 #endif
495 
496 #endif /* _das_packet_h_ */
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition: defs.h:164
DAS_API void del_PktDesc(PktDesc *pThis)
Free a packet descriptor and all it's contained objects.
DAS_API PlaneDesc * PktDesc_getPlaneByType(PktDesc *pThis, plane_type_t ptype, int iRelIndex)
Get the Ith plane of a given type.
DAS_API bool PktDesc_equalFormat(const PktDesc *pPd1, const PktDesc *pPd2)
Check for packet descriptor format equality.
DAS_API PlaneDesc * PktDesc_getPlaneByName(PktDesc *pThis, const char *name)
Get a Plane Descriptor for the plane with the name name.
#define MAXPLANES
maximum planes allowed in a packet
Definition: packet.h:32
DAS_API int PktDesc_getPlaneIdx(PktDesc *pThis, PlaneDesc *pPlane)
Get the plane number within this packet description.
Header for Plane Descriptor Objects.
plane_type_t
An enumeration of packet data plane types.
Definition: plane.h:59
Buffer class to handle accumulating byte streams.
Definition: buffer.h:47
Base structure for Stream Header Items.
Definition: descriptor.h:74
Holds information for a single packet type in a Das2 stream.
Definition: packet.h:138
DAS_API bool PktDesc_validate(PktDesc *pThis)
Check to see if a legal plane layout is present.
DAS_API size_t PktDesc_getNPlanes(const PktDesc *pThis)
Get the number of planes in this type of packet.
DAS_API DasErrCode PktDesc_encodeData(const PktDesc *pThis, DasBuf *pBuf)
Serialize a packet's current data In addition to holding the format information for Das2 Stream packe...
DAS_API int PktDesc_addPlane(PktDesc *pThis, PlaneDesc *pPlane)
Add a plane to a packet.
DAS_API const char * PktDesc_getGroup(const PktDesc *pThis)
Get the data group for this packet.
DAS_API int PktDesc_getPlaneIdxByName(PktDesc *pThis, const char *name, plane_type_t planeType)
returns the plane number for the named plane.
DAS_API void PktDesc_setGroup(PktDesc *pThis, const char *sGroup)
Set the data group for this packet.
DAS_API PktDesc * copy_PktDesc(const PktDesc *pOther)
Make a deep copy of a packet descriptor This is basically the copy constructor.
DAS_API plane_type_t PktDesc_getPlaneType(const PktDesc *pThis, int iPlane)
Determine the type of plane by index.
DAS_API int PktDesc_getPlaneIdxByType(const PktDesc *pThis, plane_type_t ptype, int iRelIndex)
Gets the Nth plane of a given type.
DAS_API PktDesc * new_PktDesc_xml(DasBuf *pBuf, DasDesc *pParent, int nPktId)
Create a PktDesc from XML data.
DAS_API DasErrCode PktDesc_setValue(PktDesc *pThis, size_t uPlane, size_t uItem, double val)
Convenience function for setting a single value in a plane This is just a shortcut for:
DAS_API PlaneDesc * PktDesc_getXPlane(PktDesc *pThis)
returns the PlaneDescriptor for the 1st X Tag plane.
DAS_API size_t PktDesc_recBytes(const PktDesc *pThis)
Get the size of data records defined by a packet descriptor.
DAS_API DasErrCode PktDesc_encode(const PktDesc *pThis, DasBuf *pBuf)
Serialize a packet descriptor as XML data.
DAS_API PktDesc * new_PktDesc(void)
Creates a packet descriptor with the default settings.
DAS_API DasErrCode PktDesc_decodeData(PktDesc *pThis, DasBuf *pBuf)
Decode 1 packet's worth of data from a buffer.
DAS_API size_t PktDesc_getNPlanesOfType(const PktDesc *pThis, plane_type_t pt)
Get the number of planes of a particular type in a packet.
DAS_API DasErrCode PktDesc_setValues(PktDesc *pThis, size_t uPlane, const double *pVals)
Convenience function for setting an array of values in a plane This is just a shortcut for:
DAS_API PlaneDesc * PktDesc_getPlane(PktDesc *pThis, int iplane)
returns the PlaneDescriptor for plane number iplane This can be used to query properties of the plane...
DAS_API int PktDesc_getId(const PktDesc *pThis)
Get the packet ID for this packet.
DAS_API DasErrCode PktDesc_copyPlanes(PktDesc *pThis, const PktDesc *pOther)
Copy in all planes from another a packet descriptor.
void * pUser
User data pointer.
Definition: packet.h:161
Describes a data plane within a packet type.
Definition: plane.h:120