RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_LUDL.h
1// Device drivers for the LUDL family of translation stage controllers.
2// The only device currently implemented is the USBMAC6000 controller in its
3// two-axis configuration controlling the stage for the Panoptes system
4// at UNC Chapel Hill.
5
6#ifndef VRPN_LUDL_H
7#define VRPN_LUDL_H
8
9#include "vrpn_Analog.h" // for vrpn_Analog
10#include "vrpn_Analog_Output.h" // for vrpn_Analog_Output
11#include "vrpn_Configure.h" // for VRPN_CALLBACK, etc
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_uint8, etc
15
16#if defined(VRPN_USE_LIBUSB_1_0)
17
18// This driver uses the VRPN-preferred LibUSB-1.0 to control the device.
19// It exposes the vrpn_Analog and the
20// vrpn_Analog_Output interfaces, to report and set the stage position.
21// The first two entries below enable the client to set the desired
22// position (in ticks) and to read back when the device has finished
23// the move to the requested position. They do not actually look at
24// the position sensors on the device.
25//
26// Analog/Analog_Output channel 0 is X (0 to maximum #ticks, in ticks).
27// Analog/Analog_Output channel 1 is Y (0 to maximum #ticks, in ticks).
28//
29// The next two report the actual sensor positions in X and Y. These
30// may differ by quite a lot (a micron or more) from the requested
31// position, so code that is watching to see if a requested move has
32// completed should use the ones above, but those that want to know
33// the actual postion, even as it shifts, should use the ones below.
34//
35// Analog channel 2 is X (0 to maximum #ticks, in ticks).
36// Analog channel 3 is Y (0 to maximum #ticks, in ticks).
37
38class vrpn_LUDL_USBMAC6000 :
39 public vrpn_Analog,
41{
42public:
43 vrpn_LUDL_USBMAC6000(const char *name, vrpn_Connection *c = 0, bool do_recenter = false);
44 virtual ~vrpn_LUDL_USBMAC6000();
45
46 virtual void mainloop();
47
48protected:
49 struct libusb_context *_context; // LibUSB context used for this device
50 struct libusb_device_handle *_device_handle; // Handle for the USB device
51 struct timeval _timestamp;
52 unsigned _endpoint; // Which endpoint to use to communicate with the device
53
54 // Buffer to store incoming data from the device and count of how many characters
55 // we got. Function to check and read any incoming data (and set _incount).
56 // Function to parse accumulated data.
57 static const unsigned _INBUFFER_SIZE = 1024;
58 vrpn_uint8 _inbuffer[_INBUFFER_SIZE]; // MUST CHANGE the sizeof() code if this becomes not an array.
59 unsigned _incount;
60 bool check_for_data(); // False if error. True even if no data.
61 bool interpret_usbmac_ascii_response(const vrpn_uint8 *buffer,
62 int *device_return,
63 int *command_return,
64 int *index_return,
65 int *value_return);
66
67 // vrpn_Analog overridden methods.
68 // Send report iff changed
69 void report_changes (vrpn_uint32 class_of_service = vrpn_CONNECTION_RELIABLE);
70 // Send report whether or not changed
71 void report (vrpn_uint32 class_of_service = vrpn_CONNECTION_RELIABLE);
72
73 // No actual types to register, derived classes will be analogs and analog_outputs
74 int register_types(void) { return 0; }
75
76 // Handlers for the Analog_Output messages.
79 static int VRPN_CALLBACK handle_request_message(void *userdata, vrpn_HANDLERPARAM p);
80
82 static int VRPN_CALLBACK handle_request_channels_message(void *userdata, vrpn_HANDLERPARAM p);
83
85 static int VRPN_CALLBACK handle_connect_message(void *userdata, vrpn_HANDLERPARAM p);
86
87private:
88 // Helper functions for communication with the stage
89 void flush_input_from_ludl(void);
90 bool send_usbmac_command(unsigned device, unsigned command, unsigned index, int value);
91 bool recenter(void);
92 bool ludl_axis_moving(unsigned axis); // Returns true if the axis is still moving
93 bool move_axis_to_position(int axis, int position);
94 // Returns true on success, fills in the position of the axis.
95 bool ludl_axis_position(unsigned axis, vrpn_int32 *position_return);
96
97 // Stores whether we think each axis is moving and where we think each axis is
98 // going if it is moving. These are set in the move_axis_to_position() routine
99 // and used in the mainloop() routine to decide if it is time to report that we
100 // have gotten where we want to be.
101 bool *_axis_moving;
102 vrpn_float64 *_axis_destination;
103};
104
105// end of OS selection
106#endif
107
108// end of VRPN_LUDL_H
109#endif
定义 vrpn_Analog_Output.h:26
定义 vrpn_Analog.h:28
virtual void report(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
virtual void report_changes(vrpn_uint32 class_of_service=vrpn_CONNECTION_LOW_LATENCY, const struct timeval time=vrpn_ANALOG_NOW)
virtual int register_types(void)
virtual void mainloop()=0
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
This structure is what is passed to a vrpn_Connection message callback.
定义 vrpn_Connection.h:41