libdas2
das2 core C utilities
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 libdas2, the Core Das2 C Library.
5  *
6  * Libdas2 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  * Libdas2 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 libdas2; 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 PktDesc* new_PktDesc(void);
171 
183 PktDesc* new_PktDesc_xml(DasBuf* pBuf, DasDesc* pParent, int nPktId);
184 
190 void del_PktDesc(PktDesc* pThis);
191 
203 bool PktDesc_equalFormat(const PktDesc* pPd1, const PktDesc* pPd2);
204 
213 int PktDesc_getId(const PktDesc* pThis);
214 
225 const char* PktDesc_getGroup(const PktDesc* pThis);
226 
233 void PktDesc_setGroup(PktDesc* pThis, const char* sGroup);
234 
235 
242 size_t PktDesc_recBytes(const PktDesc* pThis);
243 
244 
250 size_t PktDesc_getNPlanes(const PktDesc* pThis);
251 
259 size_t PktDesc_getNPlanesOfType(const PktDesc* pThis, plane_type_t pt);
260 
292 int PktDesc_addPlane(PktDesc* pThis, PlaneDesc* pPlane);
293 
294 
307 DasErrCode PktDesc_copyPlanes(PktDesc* pThis, const PktDesc* pOther);
308 
321 bool PktDesc_validate(PktDesc* pThis );
322 
340 plane_type_t PktDesc_getPlaneType(const PktDesc* pThis, int iPlane);
341 
342 
353 PlaneDesc* PktDesc_getPlane(PktDesc* pThis, int iplane);
354 
355 
362 int PktDesc_getPlaneIdx(PktDesc* pThis, PlaneDesc* pPlane);
363 
369 PlaneDesc* PktDesc_getPlaneByName(PktDesc* pThis, const char* name);
370 
381  PktDesc* pThis, plane_type_t ptype, int iRelIndex);
382 
401  const PktDesc* pThis, plane_type_t ptype, int iRelIndex
402 );
403 
412  PktDesc* pThis, const char* name, plane_type_t planeType
413 );
414 
419 
428 DasErrCode PktDesc_encode(const PktDesc* pThis, DasBuf* pBuf);
429 
441 DasErrCode PktDesc_encodeData(const PktDesc* pThis, DasBuf* pBuf);
442 
451 
465 DasErrCode PktDesc_setValue(PktDesc* pThis, size_t uPlane, size_t uItem, double val);
466 
480 DasErrCode PktDesc_setValues(PktDesc* pThis, size_t uPlane, const double* pVals);
481 
482 #ifdef __cplusplus
483 }
484 #endif
485 
486 #endif /* _das_packet_h_ */
DasErrCode PktDesc_decodeData(PktDesc *pThis, DasBuf *pBuf)
Decode 1 packet&#39;s worth of data from a buffer.
Describes a data plane within a packet type.
Definition: plane.h:119
int DasErrCode
return code type 0 indicates success, negative integer indicates failure
Definition: util.h:117
PlaneDesc * PktDesc_getPlaneByType(PktDesc *pThis, plane_type_t ptype, int iRelIndex)
Get the Ith plane of a given type.
DasErrCode PktDesc_encode(const PktDesc *pThis, DasBuf *pBuf)
Serialize a packet descriptor as XML data.
plane_type_t PktDesc_getPlaneType(const PktDesc *pThis, int iPlane)
Determine the type of plane by index.
DasErrCode PktDesc_encodeData(const PktDesc *pThis, DasBuf *pBuf)
Serialize a packet&#39;s current data In addition to holding the format information for Das2 Stream packe...
Holds information for a single packet type in a Das2 stream.
Definition: packet.h:138
Header for Plane Descriptor Objects.
PktDesc * new_PktDesc(void)
Creates a packet descriptor with the default settings.
DasErrCode PktDesc_copyPlanes(PktDesc *pThis, const PktDesc *pOther)
Copy in all planes from another a packet descriptor.
size_t PktDesc_recBytes(const PktDesc *pThis)
Get the size of data records defined by a packet descriptor.
Little buffer class to handle accumulating string data.
Definition: buffer.h:49
size_t PktDesc_getNPlanes(const PktDesc *pThis)
Get the number of planes in this type of packet.
int PktDesc_getPlaneIdx(PktDesc *pThis, PlaneDesc *pPlane)
Get the plane number within this packet description.
bool PktDesc_equalFormat(const PktDesc *pPd1, const PktDesc *pPd2)
Check for packet descriptor format equality.
PktDesc * new_PktDesc_xml(DasBuf *pBuf, DasDesc *pParent, int nPktId)
Create a PktDesc from XML data.
Base structure for Stream Header Items.
Definition: descriptor.h:80
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: ...
int PktDesc_addPlane(PktDesc *pThis, PlaneDesc *pPlane)
Add a plane to a packet.
PlaneDesc * PktDesc_getXPlane(PktDesc *pThis)
returns the PlaneDescriptor for the 1st X Tag plane.
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: ...
int PktDesc_getPlaneIdxByName(PktDesc *pThis, const char *name, plane_type_t planeType)
returns the plane number for the named plane.
void PktDesc_setGroup(PktDesc *pThis, const char *sGroup)
Set the data group for this packet.
int PktDesc_getPlaneIdxByType(const PktDesc *pThis, plane_type_t ptype, int iRelIndex)
Gets the Nth plane of a given type.
size_t PktDesc_getNPlanesOfType(const PktDesc *pThis, plane_type_t pt)
Get the number of planes of a particular type in a packet.
bool PktDesc_validate(PktDesc *pThis)
Check to see if a legal plane layout is present.
PlaneDesc * PktDesc_getPlane(PktDesc *pThis, int iplane)
returns the PlaneDescriptor for plane number iplane This can be used to query properties of the plane...
plane_type_t
An enumeration of packet data plane types.
Definition: plane.h:58
void del_PktDesc(PktDesc *pThis)
Free a packet descriptor and all it&#39;s contained objects.
int PktDesc_getId(const PktDesc *pThis)
Get the packet ID for this packet.
#define MAXPLANES
maximum planes allowed in a packet
Definition: packet.h:32
PlaneDesc * PktDesc_getPlaneByName(PktDesc *pThis, const char *name)
Get a Plane Descriptor for the plane with the name name.
void * pUser
User data pointer.
Definition: packet.h:161
const char * PktDesc_getGroup(const PktDesc *pThis)
Get the data group for this packet.