owwl.h File Reference

Headers for oww_trx client library. More...

#include <time.h>

Go to the source code of this file.

Classes

struct  owwl_data_temperature
 Structure to hold thermometer data. More...
struct  owwl_data_barometer
 Structure to hold barometer data. More...
struct  owwl_data_humidity
 Structure to hold hygrometer data. More...
struct  owwl_data_solar
 Structure to hold solar sensor data. More...
struct  owwl_data_wind
 Structure to hold wind data. More...
struct  owwl_data_rain
 Structure to hold rain data. More...
struct  owwl_data_gpc
 Structure to hold general-purpose counter data. More...
struct  owwl_data_psb
 Structure to hold PSB device data. More...
struct  owwl_data_diode
 Structure to hold diode thermometer data. More...
struct  owwl_data_grt
 Structure to hold GRT device data. More...
struct  owwl_data_cryo
 Structure to hold calibrated cryogenic thermometer data. More...
struct  owwl_data_heater
 Structure to hold heater voltage data. More...
struct  owwl_data_resistance
 Structure to hold resistance data. More...
struct  owwl_data_floats
 Structure to hold device data - general floats. More...
union  device_data_union
 A union of all possible device data structures. More...
struct  owwl_data_
 Structure used to hold a data item. More...
struct  owwl_client_
 Structure used to hold client connexion data. More...
struct  owwl_server_
 Structure used to hold server data. More...
struct  owwl_conn
 Structure used to hold connexion data. More...
struct  owwl_buffer
 Structure used to build transmit (server) data stream. More...

Defines

#define OWW_PROTO_VERSION   101L
#define OwwlUnit_Metric   0
#define OwwlUnit_Imperial   1
#define OwwlUnit_Alt1   2
#define OwwlUnit_Alt2   3
#define OwwlUnit_Mm   OwwlUnit_Metric
#define OwwlUnit_Inch   OwwlUnit_Imperial
#define OwwlUnit_Kph   OwwlUnit_Metric
#define OwwlUnit_Mph   OwwlUnit_Imperial
#define OwwlUnit_Mps   OwwlUnit_Alt1
#define OwwlUnit_Knot   OwwlUnit_Alt2
#define OwwlUnit_Mbar   OwwlUnit_Metric
#define OwwlUnit_InchHg   OwwlUnit_Imperial
#define OwwlUnit_Kpa   OwwlUnit_Alt1
#define OwwlUnit_Atm   OwwlUnit_Alt2
#define OwwlUnit_Bearing   OwwlUnit_Metric
#define OwwlUnit_Point16   OwwlUnit_Imperial
#define OwwlUnit_Name   OwwlUnit_Alt1
#define OwwlUnit_Radians   OwwlUnit_Alt2
#define OwwlSubtype_Any   -1
#define OwwlSubtype_Default   0
#define OwwlBuffInc   16
#define OWW_TRX_END   0L
#define OWW_TRX_TIME   0x1000000L
#define OWW_TRX_WIND   0x2000000L
#define OWW_TRX_RAIN   0x3000000L
#define OWW_TRX_T   0x4000000L
#define OWW_TRX_RH   0x6000000L
#define OWW_TRX_BP   0x7000000L
#define OWW_TRX_SOLAR   0xb000000L
#define OWW_TRX_PSB   0x10000000L
#define OWW_TRX_DIODE   0x11000000L
#define OWW_TRX_GRT   0x12000000L
#define OWW_TRX_CRYO   0x13000000L
#define OWW_TRX_HEATER   0x14000000L
#define OWW_TRX_RESISTANCE   0x15000000L
#define OWW_TRX_UPDT   0x80000000L
#define OWW_TRX_GPC   0x90000000L
#define OWW_TRX_LOC   0xa0000000L
#define OWW_TRX_HEAD   0xff000000L
#define OWW_TRX_SUB_TRH   0x10000L
#define OWW_TRX_SUB_TB   0x20000L
#define OWW_TRX_SUB_TCD   0x10000L
#define OWW_TRX_SUB_TCG   0x20000L
#define OWW_TRX_SERIAL   0x100L
#define OWW_TRX_SIZE   1L
#define OWW_TRX_MSG_WSDATA   1
#define OWW_TRX_MSG_UPDT   2
#define OWW_TRX_MSG_MORT   3
#define OWW_TRX_MSG_ANNOUN   4

Typedefs

typedef owwl_data_ owwl_data
 Structure used to hold a data item.
typedef owwl_client_ owwl_client
 Structure used to hold client connexion data.
typedef owwl_server_ owwl_server
 Structure used to hold server data.
typedef int(* owwl_func )(owwl_conn *conn, owwl_data *data, void *user_data)

Enumerations

enum  owwl_unit_class_enum {
  owwl_unit_class_unknown = -1, owwl_unit_class_dimensionless = 0, owwl_unit_class_time, owwl_unit_class_count,
  owwl_unit_class_count_rate, owwl_unit_class_length, owwl_unit_class_length_rate, owwl_unit_class_speed,
  owwl_unit_class_temperature, owwl_unit_class_pressure, owwl_unit_class_direction, owwl_unit_class_humidity,
  owwl_unit_class_voltage, owwl_unit_class_muvoltage, owwl_unit_class_nanocurrent, owwl_unit_class_cryo,
  owwl_unit_class_resistance
}
 An enumeration used to specify the class of unit associated with a data stream. More...
enum  owwl_device_type_enum {
  OwwlDev_Any = -1, OwwlDev_Temperature = 0, OwwlDev_Barometer, OwwlDev_Humidity,
  OwwlDev_Wind, OwwlDev_Rain, OwwlDev_Gpc, OwwlDev_Solar,
  OwwlDev_Psb = 64, OwwlDev_Diode, OwwlDev_Grt, OwwlDev_Cryo,
  OwwlDev_Heater, OwwlDev_Resistance
}
 Enumeration for different types of device. More...
enum  owwl_temperature_subtype_enum { OwwlTemp_Any = OwwlSubtype_Any, OwwlTemp_Thermometer = OwwlSubtype_Default, OwwlTemp_Humidity, OwwlTemp_Barometer }
 Enum for thermometer sub-types. More...
enum  owwl_cryo_subtype_enum { OwwlCryo_Any = OwwlSubtype_Any, OwwlCryo_Thermometer = OwwlSubtype_Default, OwwlCryo_Diode, OwwlCryo_Grt }
 Enum for calibrated cryogenic thermometer sub-types. More...
enum  owwl_read_result { Owwl_Read_Disconnect = -2, Owwl_Read_Error = -1, Owwl_Read_Read_And_Decoded = 0, Owwl_Read_Again }
 The values returned by owwl_read(). More...

Functions

owwl_connowwl_new_conn (int socket, void *user_data)
 Create a new owwl connexion context.
int owwl_read (owwl_conn *conn)
 Try to read new data from server.
int owwl_free (owwl_conn *conn)
 Free up finished-with connexion context.
unsigned int owwl_data_arg_to_id (owwl_data *data, int arg)
 Get an integer id uniquely identifying a data stream.
void owwl_id_to_data_arg (owwl_conn *conn, unsigned int id, owwl_data **data, int *arg)
 Get a data stream pointer from a unique id value.
int owwl_foreach (owwl_conn *conn, owwl_func func, void *user_data)
 Call a function for each data entry.
int owwl_foreach_ordered (owwl_conn *conn, owwl_func func, void *user_data)
 Call a function for each data entry, in a set order.
char * owwl_name (owwl_data *data, char *buffer, int bufflen, int *length, int long_not_short)
 Get a name for a data entry.
char * owwl_arg_stem (enum owwl_device_type_enum device_type, int device_subtype, int arg)
 Name for a data argument.
char * owwl_arg_name (owwl_data *data, char *buffer, int bufflen, int *length, int long_not_short, int arg)
 Get a name for a data entry argument.
enum owwl_unit_class_enum owwl_unit_class (owwl_data *data, int arg)
 Get the unit class for an arg.
char * owwl_unit_name (owwl_data *data, int unit_type, int arg)
 Get the unit name string for a data value.
char * owwl_unit_desc (owwl_data *data, int unit_type, int arg)
 Get the unit string for a data value.
int owwl_next_arg (owwl_data *data, int arg)
 Get the next arg number.
owwl_dataowwl_find (owwl_conn *conn, enum owwl_device_type_enum device_type, int device_subtype, int index)
 Find a device by type and index.
owwl_dataowwl_find_first (owwl_conn *conn, enum owwl_device_type_enum device_type, int device_subtype)
 Find the first device of the given type.
int owwl_tx_build (owwl_conn *conn, int msg_type, owwl_buffer *buff)
 Fill a buffer with data for transmission.
int owwl_data_in (owwl_conn *conn, enum owwl_device_type_enum device_type, int device_subtype, int index,...)
 Update or add data values in a data stream.
int owwl_tx_new_server (owwl_conn *conn, SOCKET socket)
 Create a new server from a listening socket.
int owwl_tx (owwl_conn *conn, owwl_buffer *buff)
 Send contents of buffer buff to all clients.
void owwl_tx_add_timestamp (owwl_conn *conn)
 Set the timestamp on conn according to the current time.
int owwl_tx_poll_servers (owwl_conn *conn)
 Poll for incoming data and connexion requests.


Detailed Description

Headers for oww_trx client library.


Typedef Documentation

typedef struct owwl_data_ owwl_data
 

Structure used to hold a data item.

Data are stored in an array of "owwl_data". Each item contains a union of data structures for the various data types. Functions to convert data to strings or doubles are provided.


Function Documentation

char* owwl_arg_name owwl_data data,
char *  buffer,
int  bufflen,
int *  length,
int  long_not_short,
int  arg
 

Get a name for a data entry argument.

Parameters:
data Pointer to a data stream from an owwl_conn
buffer Buffer to hold the returned name - use NULL just to get the length required
bufflen The length of the provided buffer
length Pointer to int that will take the length written to buffer on return
long_not_short Non-zero for a long version, or 0 for short
arg The argument number from the data stream
Returns:
Name for the data stream

char* owwl_arg_stem enum owwl_device_type_enum  device_type,
int  device_subtype,
int  arg
 

Name for a data argument.

Parameters:
device_type The device type
device_subtype The device sub-type
arg The argument number
Returns:
Name for this type of argument

unsigned int owwl_data_arg_to_id owwl_data data,
int  arg
 

Get an integer id uniquely identifying a data stream.

Parameters:
data Pointer to the data stream
arg Argument number
Returns:
Unique identifier

int owwl_data_in owwl_conn conn,
enum owwl_device_type_enum  device_type,
int  device_subtype,
int  index,
  ...
 

Update or add data values in a data stream.

This is a convenience function for updating data streams. You could just as well access the data structs directly, which would remove the overhead of device lookup, if you retain a list of pointers.

Data streams listed under conn are searched for a matching device_type, device_subtype and index. If no match is found, a new data stream is added to the list. If no match is found, a new data stream is added to the list. A variable argument list follows index, according to the device type.

Parameters:
conn owwl_conn context for the connexion
device_type The device type for the devcie
device_subtype The device sub-type for the device
index The index of the device
... Variable argument list depending on device type
Returns:
0 on success, -1 on memory exhaustion, -2 on bad device type

owwl_data* owwl_find owwl_conn conn,
enum owwl_device_type_enum  device_type,
int  device_subtype,
int  index
 

Find a device by type and index.

Parameters:
conn owwl_conn context for the connexion
device_type The device type to find, or -1 (OwwlDev_Any) for any
device_subtype The device sub-type to find, or -1 (OwwlSubtype_Any) for any
index The index number to find
Returns:
Pointer to data stream

owwl_data* owwl_find_first owwl_conn conn,
enum owwl_device_type_enum  device_type,
int  device_subtype
 

Find the first device of the given type.

Parameters:
conn owwl_conn context for the connexion
device_type The device type to find, or -1 (OwwlDev_Any) for any
device_subtype The device sub-type to find, or -1 (OwwlSubtype_Any) for any
Returns:
Pointer to data stream

int owwl_foreach owwl_conn conn,
owwl_func  func,
void *  user_data
 

Call a function for each data entry.

The function should return non-zero to break out of the loop

Parameters:
conn owwl_conn context for the connexion
func Pointer to user function to call
user_data Pointer to arbitrary space to pass to user function
Returns:
  • 0 on completion of full loop
  • -1 if the user function broke out of the loop (by returning non-zero)

int owwl_foreach_ordered owwl_conn conn,
owwl_func  func,
void *  user_data
 

Call a function for each data entry, in a set order.

The function should return non-zero to break out of the loop

Parameters:
conn owwl_conn context for the connexion
func Pointer to user function to call
user_data Pointer to arbitrary space to pass to user function
Returns:
  • 0 on completion of full loop
  • -1 if the user function broke out of the loop (by returning non-zero)

void owwl_id_to_data_arg owwl_conn conn,
unsigned int  id,
owwl_data **  data,
int *  arg
 

Get a data stream pointer from a unique id value.

Parameters:
conn owwl_conn context for the connexion
id Unique id value
data Pointer to value to receive data stream pointer
arg Pointer to integer that will receive argument number

char* owwl_name owwl_data data,
char *  buffer,
int  bufflen,
int *  length,
int  long_not_short
 

Get a name for a data entry.

Parameters:
data Pointer to a data stream from an owwl_conn
buffer Buffer to hold the returned name - use NULL just to get the length required
bufflen The length of the provided buffer
length Pointer to int that will take the length written to buffer on return
long_not_short Non-zero for a long version, or 0 for short
Returns:
Name for the data stream
Length of name string written to length

owwl_conn* owwl_new_conn int  socket,
void *  user_data
 

Create a new owwl connexion context.

Parameters:
socket fd of established socket to receive data from server
user_data Pointer to user data to associate with the conn
Returns:
A new owwl_conn context

int owwl_next_arg owwl_data data,
int  arg
 

Get the next arg number.

Parameters:
data Pointer to a data stream from an owwl_conn
arg The previous argument number
Returns:
The next argument number, or -1 if the last one was already reached

int owwl_read owwl_conn conn  ) 
 

Try to read new data from server.

Parameters:
conn owwl_conn context for the connexion we want to read
Returns:

int owwl_tx owwl_conn conn,
owwl_buffer buff
 

Send contents of buffer buff to all clients.

Parameters:
conn owwl_conn context for the connexion
buff The dynamic buffer in which the message was built
Returns:
0 on success

void owwl_tx_add_timestamp owwl_conn conn  ) 
 

Set the timestamp on conn according to the current time.

Parameters:
conn owwl_conn context for the connexion

int owwl_tx_build owwl_conn conn,
int  msg_type,
owwl_buffer buff
 

Fill a buffer with data for transmission.

Parameters:
conn owwl_conn context for the connexion
msg_type The type of message to build
buff The dynamic buffer in which the message will be built
Returns:
0 on success

int owwl_tx_new_server owwl_conn conn,
SOCKET  socket
 

Create a new server from a listening socket.

Parameters:
conn owwl_conn context for the connexion
socket The socket that is listening for connexion requests
Returns:
0 on success

int owwl_tx_poll_servers owwl_conn conn  ) 
 

Poll for incoming data and connexion requests.

Parameters:
conn owwl_conn context for the connexion
Returns:
0 on success, -1 on error

enum owwl_unit_class_enum owwl_unit_class owwl_data data,
int  arg
 

Get the unit class for an arg.

Parameters:
data Pointer to a data stream from an owwl_conn
arg The argument number from the data stream
Returns:
The class of unit for this data stream argument

char* owwl_unit_desc owwl_data data,
int  unit_type,
int  arg
 

Get the unit string for a data value.

Parameters:
data Pointer to a data stream from an owwl_conn
unit_type The type of unit:
  • 0 Metric
  • 1 Imperial
  • 2 Alt Metric
  • 3 Alt Imperial
arg The argument number from the given unit class
Returns:
The unit string

char* owwl_unit_name owwl_data data,
int  unit_type,
int  arg
 

Get the unit name string for a data value.

Parameters:
data Pointer to a data stream from an owwl_conn
unit_type The type of unit:
  • 0 Metric
  • 1 Imperial
  • 2 Alt Metric
  • 3 Alt Imperial
arg The argument number from the given unit class
Returns:
The unit name string


Generated on Fri Aug 11 19:46:55 2006 for owwl by  doxygen 1.4.6