46#ifdef VRPN_USE_USDIGITAL
63 vrpn_uint32 numChannels,
64 vrpn_int32 reportOnChangeOnly) :
66_SEIopened(vrpn_false),
68_reportChange(reportOnChangeOnly!=0),
71#ifdef VRPN_USE_USDIGITAL
73 this->setNumChannels( numChannels );
77 fprintf(stderr,
"vrpn_Analog_USDigital_A2: Can't get connection!\n");
83#ifdef VRPN_USE_USDIGITAL
84 err = InitializeSEI(portNum, AUTOASSIGN) ;
86 fprintf(stderr,
"vrpn_Analog_USDigital_A2::vrpn_Analog_USDigital_A2(): Not yet implemented for this architecture\n");
90 fprintf(stderr,
"vrpn_Analog_USDigital_A2: Can't initialize SEI bus for port %d.\n",
91#ifdef VRPN_USE_USDIGITAL
100 _SEIopened = vrpn_true ;
104#ifdef VRPN_USE_USDIGITAL
105 _numDevices = GetNumberOfDevices() ;
109 "vrpn_Analog_USDigital_A2: Error (%d) returned from GetNumberOfDevices call on SEI bus",
113 if (_numDevices != numChannels)
115 "vrpn_Analog_USDigital_A2: Warning, number of requested devices (%d) is not the same as found (%d)\n",
116 numChannels, _numDevices) ;
123 for (vrpn_uint32 d=0 ; d<_numDevices ; d++) {
124 long deviceInfoErr, model, serialnum, version, addr ;
125#ifdef VRPN_USE_USDIGITAL
126 deviceInfoErr = GetDeviceInfo(d, &model, &serialnum, &version, &addr) ;
134 fprintf(stderr,
"vrpn_Analog_USDigital_A2: could not get information on Device #%d!\n", d) ;
136 fprintf(stderr,
"vrpn_Analog_USDigital_A2: Device #%d: model=%d, serialnum=%d, version=%d, addr=%d\n",
137 d, model, serialnum, version, addr) ;
141 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");
142 portNum = portNum + 1;
143 numChannels = numChannels + 1;
144 _SEIopened = !_SEIopened;
145 _devAddr = _devAddr + 1;
146 _numDevices = _numDevices + 1;
153#ifdef VRPN_USE_USDIGITAL
155 if (_SEIopened==vrpn_true) {
163 fprintf(stderr,
"vrpn_Analog_USDigital_A2::~vrpn_Analog_USDigital_A2(): delete failed\n");
180#ifdef VRPN_USE_USDIGITAL
181 long readErr, readVal ;
184 for (vrpn_uint32 c=0 ; c<(vrpn_uint32)
num_channel ; c++)
187 if (c<_numDevices && _devAddr[c]>=0)
189 readErr = A2GetPosition(_devAddr[c], &readVal) ;
193 "vrpn_Analog_USDigital_A2: Error code %d received while reading channel %d.\n",
195 fprintf(stderr,
"vrpn_Analog_USDigital_A2: Attempting to reinitialize SEI bus...") ;
196 readErr = ResetSEI() ;
198 fprintf(stderr,
"failed.") ;
199 fprintf(stderr,
"failed.") ;
204 channel[c] = (vrpn_float64) readVal ;
219vrpn_int32 vrpn_Analog_USDigital_A2::setNumChannels (vrpn_int32 sizeRequested)
221 if (sizeRequested < 0)
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)
virtual ~vrpn_Analog_USDigital_A2()
static const vrpn_uint32 vrpn_Analog_USDigital_A2_FIND_PORT
virtual void mainloop()
This routine is called each time through the server's main loop.
static const vrpn_uint32 vrpn_Analog_USDigital_A2_CHANNEL_MAX
vrpn_float64 channel[vrpn_CHANNEL_MAX]
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 ...
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...
vrpn_Connection * d_connection
Connection that this object talks to.
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
Generic connection class not specific to the transport mechanism.
void vrpn_SleepMsecs(double dMilliSecs)