Loading...
Searching...
No Matches
phydat.h File Reference

Generic data container for physical data interface. More...

Detailed Description

Generic data container for physical data interface.

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de

Definition in file phydat.h.

#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include "modules.h"
+ Include dependency graph for phydat.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  phydat_t
 Generic data structure for expressing physical values. More...
 

Macros

#define PHYDAT_DIM   (3U)
 The fixed number of dimensions we work with.
 
#define PHYDAT_SCALE_STR_MAXLEN   (sizeof("*E-128\0"))
 The maximum length of a scaling string.
 
#define PHYDAT_MIN   (INT16_MIN)
 Minimum value for phydat_t::val.
 
#define PHYDAT_MAX   (INT16_MAX)
 Maximum value for phydat_t::val.
 

Enumerations

enum  {
  UNIT_UNDEF , UNIT_NONE , UNIT_TEMP_C , UNIT_TEMP_F ,
  UNIT_TEMP_K , UNIT_LUX , UNIT_M , UNIT_M2 ,
  UNIT_M3 , UNIT_G_FORCE , UNIT_G = UNIT_G_FORCE , UNIT_DPS ,
  UNIT_GRAM , UNIT_GR = UNIT_GRAM , UNIT_A , UNIT_V ,
  UNIT_W , UNIT_GAUSS , UNIT_GS = UNIT_GAUSS , UNIT_T ,
  UNIT_DBM , UNIT_COULOMB , UNIT_F , UNIT_OHM ,
  UNIT_PH , UNIT_BAR , UNIT_PA , UNIT_CD ,
  UNIT_BOOL , UNIT_CTS , UNIT_PERCENT , UNIT_PERMILL ,
  UNIT_PPM , UNIT_PPB , UNIT_TIME , UNIT_DATE ,
  UNIT_GPM3 , UNIT_CPM3
}
 Definition of physical units and comparable data types. More...
 

Functions

void phydat_dump (phydat_t *data, uint8_t dim)
 Dump the given data container to STDIO.
 
void phydat_unit_print (uint8_t unit)
 Print a unit.
 
ssize_t phydat_unit_write (char *dest, size_t max_size, uint8_t unit)
 Write the string representation of the given unit into the given buffer.
 
char phydat_prefix_from_scale (int8_t scale)
 Convert the given scale factor to an SI prefix.
 
void phydat_fit (phydat_t *dat, const int32_t *values, unsigned int dim)
 Scale integer value(s) to fit into a phydat_t.
 
size_t phydat_to_json (const phydat_t *data, size_t dim, char *buf)
 Convert the given phydat_t structure into a JSON string.
 
int64_t phydat_date_time_to_unix (phydat_t *date, phydat_t *time, int32_t offset_seconds)
 Convert a date and time contained in phydat structs to a Unix timestamp.
 
int64_t phydat_unix (int16_t year, int16_t month, int16_t day, int16_t hour, int16_t minute, int16_t second, int32_t offset)
 Convert a date and time (per ISO8601) to a Unix timestamp (seconds since 1970).