YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FrameGrabberControls_Forwarder.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
7#include "CameraVocabs.h"
8
9#include <yarp/os/Bottle.h>
10#include <yarp/os/LogStream.h>
11
13
18
19
21{
23 yarp::os::Bottle response;
27 yInfo() << m_port.isOpen();
28 bool ret = m_port.write(cmd, response);
29
30 // response should be [fgc2] [camd] [is] [busType] [description]
31 camera->busType = static_cast<BusType>(response.get(3).asInt32());
32 camera->deviceDescription = response.get(4).asString();
33 return ret;
34}
35
36bool FrameGrabberControls_Forwarder::hasFeature(int feature, bool* hasFeature)
37{
39 yarp::os::Bottle response;
43 cmd.addInt32(feature);
44 bool ret = m_port.write(cmd, response);
45
46 *hasFeature = response.get(4).asInt32() != 0 ? true : false;
47 return ret;
48}
49
50bool FrameGrabberControls_Forwarder::setFeature(int feature, double value)
51{
53 yarp::os::Bottle response;
57 cmd.addInt32(feature);
58 cmd.addFloat64(value);
59 return m_port.write(cmd, response);
60}
61
62bool FrameGrabberControls_Forwarder::setFeature(int feature, double value1, double value2)
63{
65 yarp::os::Bottle response;
69 cmd.addInt32(feature);
70 cmd.addFloat64(value1);
71 cmd.addFloat64(value2);
72 return m_port.write(cmd, response);
73}
74
75bool FrameGrabberControls_Forwarder::getFeature(int feature, double* value)
76{
78 yarp::os::Bottle response;
82 cmd.addInt32(feature);
83 bool ret = m_port.write(cmd, response);
84
85 *value = response.get(3).asFloat64();
86 return ret;
87}
88
89bool FrameGrabberControls_Forwarder::getFeature(int feature, double* value1, double* value2)
90{
92 yarp::os::Bottle response;
96 cmd.addInt32(feature);
97 bool ret = m_port.write(cmd, response);
98
99 *value1 = response.get(3).asFloat64();
100 *value2 = response.get(4).asFloat64();
101 return ret;
102}
103
104bool FrameGrabberControls_Forwarder::hasOnOff(int feature, bool* hasOnOff)
105{
107 yarp::os::Bottle response;
111 cmd.addInt32(feature);
112 bool ret = m_port.write(cmd, response);
113
114 *hasOnOff = response.get(4).asInt32() != 0 ? true : false;
115 return ret;
116}
117
118bool FrameGrabberControls_Forwarder::setActive(int feature, bool onoff)
119{
121 yarp::os::Bottle response;
125 cmd.addInt32(feature);
126 cmd.addInt32(onoff);
127 return m_port.write(cmd, response);
128}
129
130bool FrameGrabberControls_Forwarder::getActive(int feature, bool* isActive)
131{
133 yarp::os::Bottle response;
137 cmd.addInt32(feature);
138 bool ret = m_port.write(cmd, response);
139
140 *isActive = response.get(3).asInt32() != 0 ? true : false;
141 return ret;
142}
143
144bool FrameGrabberControls_Forwarder::hasAuto(int feature, bool* hasAuto)
145{
147 yarp::os::Bottle response;
151 cmd.addInt32(feature);
152 bool ret = m_port.write(cmd, response);
153
154 *hasAuto = response.get(4).asInt32() != 0 ? true : false;
155 return ret;
156}
157
158bool FrameGrabberControls_Forwarder::hasManual(int feature, bool* hasManual)
159{
161 yarp::os::Bottle response;
165 cmd.addInt32(feature);
166 bool ret = m_port.write(cmd, response);
167
168 *hasManual = response.get(4).asInt32() != 0 ? true : false;
169 return ret;
170}
171
172bool FrameGrabberControls_Forwarder::hasOnePush(int feature, bool* hasOnePush)
173{
175 yarp::os::Bottle response;
179 cmd.addInt32(feature);
180 bool ret = m_port.write(cmd, response);
181
182 *hasOnePush = response.get(4).asInt32() != 0 ? true : false;
183 return ret;
184}
185
187{
189 yarp::os::Bottle response;
193 cmd.addInt32(feature);
194 cmd.addInt32(mode);
195 return m_port.write(cmd, response);
196}
197
199{
201 yarp::os::Bottle response;
205 cmd.addInt32(feature);
206 bool ret = m_port.write(cmd, response);
207
208 *mode = static_cast<FeatureMode>(response.get(3).asInt32());
209 return ret;
210}
211
213{
215 yarp::os::Bottle response;
219 cmd.addInt32(feature);
220 return m_port.write(cmd, response);
221}
constexpr yarp::conf::vocab32_t VOCAB_ACTIVE
constexpr yarp::conf::vocab32_t VOCAB_FEATURE2
constexpr yarp::conf::vocab32_t VOCAB_FEATURE
constexpr yarp::conf::vocab32_t VOCAB_MANUAL
constexpr yarp::conf::vocab32_t VOCAB_ONEPUSH
constexpr yarp::conf::vocab32_t VOCAB_MODE
constexpr yarp::conf::vocab32_t VOCAB_ONOFF
constexpr yarp::conf::vocab32_t VOCAB_CAMERA_DESCRIPTION
constexpr yarp::conf::vocab32_t VOCAB_HAS
constexpr yarp::conf::vocab32_t VOCAB_AUTO
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_CONTROL
constexpr yarp::conf::vocab32_t VOCAB_GET
constexpr yarp::conf::vocab32_t VOCAB_SET
bool ret
#define yInfo(...)
Definition Log.h:319
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
Definition Bottle.cpp:164
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
Definition Bottle.cpp:158
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
A mini-server for network communication.
Definition Port.h:46
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
Definition Port.cpp:436
bool isOpen() const
Check if the port has been opened.
Definition Port.cpp:677
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition Value.cpp:222
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition Value.cpp:204
virtual std::string asString() const
Get string value.
Definition Value.cpp:234
This classes implement a sender / parser for IFrameGrabberControls interface messages.
bool hasAuto(int feature, bool *hasAuto) override
Check if the requested feature has the 'auto' mode.
bool setActive(int feature, bool onoff) override
Set the requested feature on or off.
bool hasFeature(int feature, bool *hasFeature) override
Check if camera has the requested feature (saturation, brightness ... )
bool getActive(int feature, bool *isActive) override
Get the current status of the feature, on or off.
bool setOnePush(int feature) override
Set the requested feature to a value (saturation, brightness ... )
bool hasOnePush(int feature, bool *hasOnePush) override
Check if the requested feature has the 'onePush' mode.
bool setFeature(int feature, double value) override
Set the requested feature to a value (saturation, brightness ... )
bool getFeature(int feature, double *value) override
Get the current value for the requested feature.
bool hasManual(int feature, bool *hasManual) override
Check if the requested feature has the 'manual' mode.
bool getMode(int feature, FeatureMode *mode) override
Get the current mode for the feature.
bool hasOnOff(int feature, bool *HasOnOff) override
Check if the camera has the ability to turn on/off the requested feature.
bool getCameraDescription(CameraDescriptor *camera) override
Get a basic description of the camera hw.
bool setMode(int feature, FeatureMode mode) override
Set the requested mode for the feature.