vrpn 07.35
Virtual Reality Peripheral Network
 
Loading...
Searching...
No Matches
vrpn_BiosciencesTools.h
Go to the documentation of this file.
1#ifndef VRPN_BIOSCIENCES_H
2#define VRPN_BIOSCIENCES_H
3
4// XXX Need to have a VRPN boolean output device. Then we can set the
5// temperature control to be on or off based on its value. For now, we're
6// doing a horrible thing and packing it into an analog output channel.
7
8#include "vrpn_Analog.h" // for vrpn_Serial_Analog
9#include "vrpn_Analog_Output.h" // for vrpn_Analog_Output
10#include "vrpn_Button.h" // for vrpn_Button_Filter
11#include "vrpn_Configure.h" // for VRPN_CALLBACK, VRPN_API
12#include "vrpn_Connection.h" // for vrpn_CONNECTION_RELIABLE, etc
13#include "vrpn_Shared.h" // for timeval
14#include "vrpn_Types.h" // for vrpn_uint32, vrpn_float64
15
16/*
17# Analog channels: (read by client)
18# 0 Reading from stage 1 in degrees Celcius
19# 1 Reading from bath 1 in degrees Celcius
20# 2 External 1 in degrees Celcius (or setpoint if ext not used)
21# 3 Reading from stage 2 in degrees Celcius
22# 4 Reading from bath 2 in degrees Celcius
23# 5 External 1 in degrees Celcius (or setpoint if ext not used)
24# Button channels: (read by client)
25# 0 Temperature control is on or off
26# Analog_Output channels: (set by client)
27# 0 Reference temperature for channel 1
28# 1 Reference temperature for channel 2
29# 2 Turn temperature control on/off (0 = off, otherwise on)
30*/
31
34{
35public:
36 // Tell it the temperature to use to set channels 1 and 2 to
37 // in Celcius and also whether to turn the temperature control on.
38 vrpn_BiosciencesTools (const char * name, vrpn_Connection * c,
39 const char * port, float temp1, float temp2,
40 bool control_on);
42
44 virtual void mainloop ();
45
46 protected:
47 char d_buffer[128]; //< Buffer of characters in report
48 unsigned d_bufcount; //< How many characters we have so far
49
50 struct timeval timestamp; //< Time of the last report from the device
51
52 virtual int reset(void); //< Set device back to starting config
53 virtual int get_report(void); //< Try to read a report from the device
54
55 // Channels are zero-referenced. Use 0 for channel 1.
56 bool set_reference_temperature(unsigned channel, float value);
57 bool set_control_status(bool on);
58 bool request_temperature(unsigned channel);
59
60 // Sets a specified channel based on a new value from the Analog_Output.
61 // Channels 0 and 1 are temperature settings, and channel 2 is our
62 // hack to turn on and off temperatur control.
63 bool set_specified_channel(unsigned channel, vrpn_float64 value);
64
65 // This lets us know which channel we're waiting for a reading on.
66 // It cycles; each time we hear from one, we ask for the next.
68
69 float convert_bytes_to_reading(const char *buf);
70
72 virtual void report_changes
73 (vrpn_uint32 class_of_service = vrpn_CONNECTION_RELIABLE);
75 virtual void report
76 (vrpn_uint32 class_of_service = vrpn_CONNECTION_RELIABLE);
77
81
84
87};
88
89#endif
vrpn_Analog_Output(const char *name, vrpn_Connection *c=NULL)
vrpn_float64 channel[vrpn_CHANNEL_MAX]
Definition vrpn_Analog.h:38
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report whether something has changed or not (for servers) Optionally, tell what time to stamp ...
Definition vrpn_Analog.C:94
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
Send a report only if something has changed (for servers) Optionally, tell what time to stamp the val...
Definition vrpn_Analog.C:71
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
static int VRPN_CALLBACK handle_connect_message(void *userdata, vrpn_HANDLERPARAM p)
Responds to a connection request with a report of the values.
vrpn_BiosciencesTools(const char *name, vrpn_Connection *c, const char *port, float temp1, float temp2, bool control_on)
static int VRPN_CALLBACK handle_request_channels_message(void *userdata, vrpn_HANDLERPARAM p)
Responds to a request to change multiple channels at once.
bool request_temperature(unsigned channel)
bool set_reference_temperature(unsigned channel, float value)
float convert_bytes_to_reading(const char *buf)
bool set_specified_channel(unsigned channel, vrpn_float64 value)
static int VRPN_CALLBACK handle_request_message(void *userdata, vrpn_HANDLERPARAM p)
Responds to a request to change one of the values by setting the channel to that value.
vrpn_Button_Filter(const char *, vrpn_Connection *c=NULL)
Generic connection class not specific to the transport mechanism.
vrpn_Serial_Analog(const char *name, vrpn_Connection *connection, const char *port, int baud=9600, int bits=8, vrpn_SER_PARITY parity=vrpn_SER_PARITY_NONE, bool rts_flow=false)
This structure is what is passed to a vrpn_Connection message callback.
#define VRPN_API
#define VRPN_CALLBACK
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...