SeaBreeze
Device.h
Go to the documentation of this file.
1 /***************************************************/
39 #ifndef DEVICE_H
40 #define DEVICE_H
41 
42 #include <vector>
43 #include <string>
44 #include "common/buses/Bus.h"
45 #include "common/buses/BusFamily.h"
50 
51 
52 // usb endpoints are associated with a particular device.
53 typedef enum usbEndpointType
54 {
55  kEndpointTypePrimaryOut, // slow speed
56  kEndpointTypePrimaryIn, // slow speed
57  kEndpointTypeSecondaryOut, // could be high speed
58  kEndpointTypeSecondaryIn, // could be high speed
59  kEndpointTypeSecondaryIn2 // generally high speed
60 } usbEndpointType;
61 
62 namespace seabreeze {
63 
64  class Device {
65  public:
66  Device();
67  virtual ~Device();
68  std::vector<Bus *> &getBuses();
69  std::vector<Feature *> &getFeatures();
70  std::vector<Protocol *> &getProtocols();
71  std::string &getName();
72 
73  // get the usb endpoints, according to the endpointType enumerator,
74  // if the endpoint type is not used, a 0 is returned
75  // TODO: this should be delegated down into a Bus instance
76  // (e.g. found by getBusesByFamily()) for USB. It is inappropriate here.
77  unsigned char getEndpoint(int *errorCode, usbEndpointType endpointType);
78 
79  /* This will allow the driver to probe the device and initialize itself
80  * based on what it finds there. This should be called shortly after
81  * open(). The Device instance should use the indicated Bus instance to
82  * communicate with the hardware and get everything set up. It can
83  * use any appropriate protocol or protocols that are valid for the Bus.
84  */
85  virtual bool initialize(const Bus &bus);
86 
87  /* Each instance of a device is assumed to be associated with a unique
88  * location on a bus. If the device is connected via multiple buses, then
89  * a special DeviceLocator and TransferHelper will have to hide those
90  * details. Otherwise, each connection to the device will be considered
91  * independent of all others.
92  */
93  virtual DeviceLocatorInterface *getLocation();
94  virtual void setLocation(const DeviceLocatorInterface &loc);
95 
96  virtual int open();
97 
98  virtual void close();
99 
100  virtual std::vector<Bus *> getBusesByFamily(BusFamily &family);
101 
102  virtual seabreeze::ProtocolFamily getSupportedProtocol(
103  seabreeze::FeatureFamily family, BusFamily bus) = 0;
104 
105  virtual std::vector<Protocol *> getProtocolsByFamily(
106  seabreeze::ProtocolFamily &family);
107 
108  virtual Bus *getOpenedBus();
109 
110  protected:
111  std::vector<Bus *> buses;
112  std::vector<Feature *> features;
113  std::vector<Protocol *> protocols;
114 
115  std::string name;
116  unsigned char usbEndpoint_primary_out;
117  unsigned char usbEndpoint_primary_in;
118  unsigned char usbEndpoint_secondary_out;
119  unsigned char usbEndpoint_secondary_in;
120  unsigned char usbEndpoint_secondary_in2;
121 
122 
123  DeviceLocatorInterface *location;
124  Bus *openedBus;
125  };
126 
127 }
128 
129 #endif /* DEVICE_H */
Definition: DeviceLocatorInterface.h:47
Definition: ProtocolFamily.h:39
Definition: BusFamily.h:38
Definition: FeatureFamily.h:39
Definition: Bus.h:48
Definition: Device.h:64
Encapsulates all SeaBreeze classes.
Definition: DeviceFactory.h:42