YARP
Yet Another Robot Platform
FrameGrabberControlsDC1394_Responder.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
8 #include "CameraVocabs.h"
9 
10 #include <yarp/os/LogStream.h>
11 
13 
14 bool FrameGrabberControlsDC1394_Responder::configure(yarp::dev::IFrameGrabberControlsDC1394* interface)
15 {
16  fgCtrl_DC1394 = interface;
17  return true;
18 }
19 
21 {
22  if (!fgCtrl_DC1394) {
23  yWarning() << "FrameGrabberControlsDC1394_Responder: firewire interface not implemented in subdevice, some features could not be available";
24  return yarp::dev::DeviceResponder::respond(cmd, response);
25  }
26 
27  int code = cmd.get(1).asVocab32();
28  switch (code) {
29  case VOCAB_DRGETMSK:
30  response.addInt32(int(fgCtrl_DC1394->getVideoModeMaskDC1394()));
31  return true;
32 
33  case VOCAB_DRGETVMD:
34  response.addInt32(int(fgCtrl_DC1394->getVideoModeDC1394()));
35  return true;
36 
37  case VOCAB_DRSETVMD:
38  response.addInt32(int(fgCtrl_DC1394->setVideoModeDC1394(cmd.get(1).asInt32())));
39  return true;
40 
41  case VOCAB_DRGETFPM:
42  response.addInt32(int(fgCtrl_DC1394->getFPSMaskDC1394()));
43  return true;
44 
45  case VOCAB_DRGETFPS:
46  response.addInt32(int(fgCtrl_DC1394->getFPSDC1394()));
47  return true;
48 
49  case VOCAB_DRSETFPS:
50  response.addInt32(int(fgCtrl_DC1394->setFPSDC1394(cmd.get(1).asInt32())));
51  return true;
52 
53  case VOCAB_DRGETISO:
54  response.addInt32(int(fgCtrl_DC1394->getISOSpeedDC1394()));
55  return true;
56 
57  case VOCAB_DRSETISO:
58  response.addInt32(int(fgCtrl_DC1394->setISOSpeedDC1394(cmd.get(1).asInt32())));
59  return true;
60 
61  case VOCAB_DRGETCCM:
62  response.addInt32(int(fgCtrl_DC1394->getColorCodingMaskDC1394(cmd.get(1).asInt32())));
63  return true;
64 
65  case VOCAB_DRGETCOD:
66  response.addInt32(int(fgCtrl_DC1394->getColorCodingDC1394()));
67  return true;
68 
69  case VOCAB_DRSETCOD:
70  response.addInt32(int(fgCtrl_DC1394->setColorCodingDC1394(cmd.get(1).asInt32())));
71  return true;
72 
73  case VOCAB_DRGETF7M:
74  {
75  unsigned int xstep;
76  unsigned int ystep;
77  unsigned int xdim;
78  unsigned int ydim;
79  unsigned int xoffstep;
80  unsigned int yoffstep;
81  fgCtrl_DC1394->getFormat7MaxWindowDC1394(xdim, ydim, xstep, ystep, xoffstep, yoffstep);
82  response.addInt32(xdim);
83  response.addInt32(ydim);
84  response.addInt32(xstep);
85  response.addInt32(ystep);
86  response.addInt32(xoffstep);
87  response.addInt32(yoffstep);
88  }
89  return true;
90 
91  case VOCAB_DRGETWF7:
92  {
93  unsigned int xdim;
94  unsigned int ydim;
95  int x0;
96  int y0;
97  fgCtrl_DC1394->getFormat7WindowDC1394(xdim, ydim, x0, y0);
98  response.addInt32(xdim);
99  response.addInt32(ydim);
100  response.addInt32(x0);
101  response.addInt32(y0);
102  }
103  return true;
104 
105  case VOCAB_DRSETWF7:
106  response.addInt32(int(fgCtrl_DC1394->setFormat7WindowDC1394(cmd.get(1).asInt32(), cmd.get(2).asInt32(), cmd.get(3).asInt32(), cmd.get(4).asInt32())));
107  return true;
108 
109  case VOCAB_DRSETOPM:
110  response.addInt32(int(fgCtrl_DC1394->setOperationModeDC1394(cmd.get(1).asInt32() != 0)));
111  return true;
112 
113  case VOCAB_DRGETOPM:
114  response.addInt32(fgCtrl_DC1394->getOperationModeDC1394());
115  return true;
116 
117  case VOCAB_DRSETTXM:
118  response.addInt32(int(fgCtrl_DC1394->setTransmissionDC1394(cmd.get(1).asInt32() != 0)));
119  return true;
120 
121  case VOCAB_DRGETTXM:
122  response.addInt32(fgCtrl_DC1394->getTransmissionDC1394());
123  return true;
124 
125  case VOCAB_DRSETBCS:
126  response.addInt32(int(fgCtrl_DC1394->setBroadcastDC1394(cmd.get(1).asInt32() != 0)));
127  return true;
128 
129  case VOCAB_DRSETDEF:
130  response.addInt32(int(fgCtrl_DC1394->setDefaultsDC1394()));
131  return true;
132 
133  case VOCAB_DRSETRST:
134  response.addInt32(int(fgCtrl_DC1394->setResetDC1394()));
135  return true;
136 
137  case VOCAB_DRSETPWR:
138  response.addInt32(int(fgCtrl_DC1394->setPowerDC1394(cmd.get(1).asInt32() != 0)));
139  return true;
140 
141  case VOCAB_DRSETCAP:
142  response.addInt32(int(fgCtrl_DC1394->setCaptureDC1394(cmd.get(1).asInt32() != 0)));
143  return true;
144 
145  case VOCAB_DRSETBPP:
146  response.addInt32(int(fgCtrl_DC1394->setBytesPerPacketDC1394(cmd.get(1).asInt32())));
147  return true;
148 
149  case VOCAB_DRGETBPP:
150  response.addInt32(fgCtrl_DC1394->getBytesPerPacketDC1394());
151  return true;
152  }
153 
154  return true;
155 }
constexpr yarp::conf::vocab32_t VOCAB_DRGETISO
Definition: CameraVocabs.h:73
constexpr yarp::conf::vocab32_t VOCAB_DRSETFPS
Definition: CameraVocabs.h:72
constexpr yarp::conf::vocab32_t VOCAB_DRSETDEF
Definition: CameraVocabs.h:90
constexpr yarp::conf::vocab32_t VOCAB_DRSETVMD
Definition: CameraVocabs.h:69
constexpr yarp::conf::vocab32_t VOCAB_DRSETWF7
Definition: CameraVocabs.h:82
constexpr yarp::conf::vocab32_t VOCAB_DRGETF7M
Definition: CameraVocabs.h:80
constexpr yarp::conf::vocab32_t VOCAB_DRSETBCS
Definition: CameraVocabs.h:89
constexpr yarp::conf::vocab32_t VOCAB_DRSETCAP
Definition: CameraVocabs.h:93
constexpr yarp::conf::vocab32_t VOCAB_DRSETCOD
Definition: CameraVocabs.h:77
constexpr yarp::conf::vocab32_t VOCAB_DRGETMSK
Definition: CameraVocabs.h:67
constexpr yarp::conf::vocab32_t VOCAB_DRGETFPS
Definition: CameraVocabs.h:71
constexpr yarp::conf::vocab32_t VOCAB_DRSETOPM
Definition: CameraVocabs.h:83
constexpr yarp::conf::vocab32_t VOCAB_DRGETBPP
Definition: CameraVocabs.h:95
constexpr yarp::conf::vocab32_t VOCAB_DRSETPWR
Definition: CameraVocabs.h:92
constexpr yarp::conf::vocab32_t VOCAB_DRGETCCM
Definition: CameraVocabs.h:75
constexpr yarp::conf::vocab32_t VOCAB_DRGETTXM
Definition: CameraVocabs.h:86
constexpr yarp::conf::vocab32_t VOCAB_DRSETRST
Definition: CameraVocabs.h:91
constexpr yarp::conf::vocab32_t VOCAB_DRSETBPP
Definition: CameraVocabs.h:94
constexpr yarp::conf::vocab32_t VOCAB_DRGETWF7
Definition: CameraVocabs.h:81
constexpr yarp::conf::vocab32_t VOCAB_DRGETVMD
Definition: CameraVocabs.h:68
constexpr yarp::conf::vocab32_t VOCAB_DRGETFPM
Definition: CameraVocabs.h:70
constexpr yarp::conf::vocab32_t VOCAB_DRSETTXM
Definition: CameraVocabs.h:85
constexpr yarp::conf::vocab32_t VOCAB_DRGETCOD
Definition: CameraVocabs.h:76
constexpr yarp::conf::vocab32_t VOCAB_DRSETISO
Definition: CameraVocabs.h:74
constexpr yarp::conf::vocab32_t VOCAB_DRGETOPM
Definition: CameraVocabs.h:84
#define yWarning(...)
Definition: Log.h:268
virtual bool respond(const yarp::os::Bottle &command, yarp::os::Bottle &reply)
Respond to a message.
virtual unsigned int getISOSpeedDC1394()=0
virtual bool setISOSpeedDC1394(int speed)=0
virtual unsigned int getBytesPerPacketDC1394()=0
virtual bool setPowerDC1394(bool onoff)=0
virtual unsigned int getFPSMaskDC1394()=0
virtual bool getFormat7WindowDC1394(unsigned int &xdim, unsigned int &ydim, int &x0, int &y0)=0
virtual unsigned int getFPSDC1394()=0
virtual bool setFormat7WindowDC1394(unsigned int xdim, unsigned int ydim, int x0, int y0)=0
virtual unsigned int getVideoModeDC1394()=0
virtual bool setBroadcastDC1394(bool onoff)=0
virtual bool setBytesPerPacketDC1394(unsigned int bpp)=0
virtual bool setColorCodingDC1394(int coding)=0
virtual bool getFormat7MaxWindowDC1394(unsigned int &xdim, unsigned int &ydim, unsigned int &xstep, unsigned int &ystep, unsigned int &xoffstep, unsigned int &yoffstep)=0
virtual bool setFPSDC1394(int fps)=0
virtual bool setVideoModeDC1394(int video_mode)=0
virtual unsigned int getColorCodingMaskDC1394(unsigned int video_mode)=0
virtual unsigned int getVideoModeMaskDC1394()=0
virtual unsigned int getColorCodingDC1394()=0
virtual bool setCaptureDC1394(bool bON)=0
virtual bool setOperationModeDC1394(bool b1394b)=0
virtual bool setTransmissionDC1394(bool bTxON)=0
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:246
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
Definition: Bottle.cpp:140
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
Definition: Value.cpp:228
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition: Value.cpp:204
bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &response) override
Respond to a message.