46 #ifdef VRPN_USE_USDIGITAL 63 vrpn_uint32 numChannels,
64 vrpn_int32 reportOnChangeOnly) :
66 _SEIopened(vrpn_false),
69 _reportChange(reportOnChangeOnly!=0)
71 #ifdef VRPN_USE_USDIGITAL 73 if (this->_devAddr == NULL) {
74 fprintf(stderr,
"vrpn_Analog_USDigital_A2: Out of memory!\n");
78 this->setNumChannels( numChannels );
82 fprintf(stderr,
"vrpn_Analog_USDigital_A2: Can't get connection!\n");
88 #ifdef VRPN_USE_USDIGITAL 89 err = InitializeSEI(portNum, AUTOASSIGN) ;
91 fprintf(stderr,
"vrpn_Analog_USDigital_A2::vrpn_Analog_USDigital_A2(): Not yet implemented for this architecture\n");
95 fprintf(stderr,
"vrpn_Analog_USDigital_A2: Can't initialize SEI bus for port %d.\n",
96 #ifdef VRPN_USE_USDIGITAL
105 _SEIopened = vrpn_true ;
109 #ifdef VRPN_USE_USDIGITAL 110 _numDevices = GetNumberOfDevices() ;
114 "vrpn_Analog_USDigital_A2: Error (%d) returned from GetNumberOfDevices call on SEI bus",
118 if (_numDevices != numChannels)
120 "vrpn_Analog_USDigital_A2: Warning, number of requested devices (%d) is not the same as found (%d)\n",
121 numChannels, _numDevices) ;
128 for (vrpn_uint32 d=0 ; d<_numDevices ; d++) {
129 long deviceInfoErr, model, serialnum, version, addr ;
130 #ifdef VRPN_USE_USDIGITAL 131 deviceInfoErr = GetDeviceInfo(d, &model, &serialnum, &version, &addr) ;
139 fprintf(stderr,
"vrpn_Analog_USDigital_A2: could not get information on Device #%d!\n", d) ;
141 fprintf(stderr,
"vrpn_Analog_USDigital_A2: Device #%d: model=%d, serialnum=%d, version=%d, addr=%d\n",
142 d, model, serialnum, version, addr) ;
146 fprintf(stderr,
"vrpn_Analog_USDigital_A2::vrpn_Analog_USDigital_A2(): Not compiled in; define VRPN_USE_USDIGITAL in vrpn_Configure.h and recompile VRPN\n");
153 #ifdef VRPN_USE_USDIGITAL 155 if (_SEIopened==vrpn_true) {
175 #ifdef VRPN_USE_USDIGITAL 176 long readErr, readVal ;
179 for (vrpn_uint32 c=0 ; c<(vrpn_uint32)
num_channel ; c++)
182 if (c<_numDevices && _devAddr[c]>=0)
184 readErr = A2GetPosition(_devAddr[c], &readVal) ;
188 "vrpn_Analog_USDigital_A2: Error code %d received while reading channel %d.\n",
190 fprintf(stderr,
"vrpn_Analog_USDigital_A2: Attempting to reinitialize SEI bus...") ;
191 readErr = ResetSEI() ;
193 fprintf(stderr,
"failed.") ;
194 fprintf(stderr,
"failed.") ;
199 channel[c] = (vrpn_float64) readVal ;
214 vrpn_int32 vrpn_Analog_USDigital_A2::setNumChannels (vrpn_int32 sizeRequested)
216 if (sizeRequested < 0)
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
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...
static const vrpn_uint32 vrpn_Analog_USDigital_A2_FIND_PORT
void vrpn_SleepMsecs(double dMsecs)
virtual ~vrpn_Analog_USDigital_A2()
vrpn_Analog_USDigital_A2(const char *name, vrpn_Connection *c, vrpn_uint32 portNum=vrpn_Analog_USDigital_A2_FIND_PORT, vrpn_uint32 numChannels=vrpn_Analog_USDigital_A2_CHANNEL_MAX, vrpn_int32 reportOnChangeOnly=0)
vrpn_float64 channel[vrpn_CHANNEL_MAX]
static const vrpn_uint32 vrpn_Analog_USDigital_A2_CHANNEL_MAX
Generic connection class not specific to the transport mechanism.
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 ...
vrpn_Connection * d_connection
Connection that this object talks to.
virtual void mainloop()
This routine is called each time through the server's main loop.