Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

framegrabber_protocol enhancement #2595

Merged
merged 4 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/devices/RemoteFrameGrabber/RemoteFrameGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ YARP_LOG_COMPONENT(REMOTEFRAMEGRABBER, "yarp.devices.RemoteFrameGrabber")

RemoteFrameGrabber::RemoteFrameGrabber() :
FrameGrabberControls_Forwarder(port),
FrameGrabberControlsDC1394_Forwarder(port),
RgbVisualParams_Forwarder(port)
{
}
1 change: 0 additions & 1 deletion src/devices/RemoteFrameGrabber/RemoteFrameGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class RemoteFrameGrabber :
yarp::os::Network::connect(local,remote);
}
reader.attach(port);
FrameGrabberControlsDC1394_Forwarder::init(&port);
return true;
}

Expand Down
4 changes: 4 additions & 0 deletions src/devices/framegrabber_protocol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ if(YARP_COMPILE_DEVICE_PLUGINS)
yarp/proto/framegrabber/FrameGrabberControls_Responder.h
yarp/proto/framegrabber/FrameGrabberControls_Forwarder.cpp
yarp/proto/framegrabber/FrameGrabberControls_Forwarder.h
yarp/proto/framegrabber/FrameGrabberOf_Forwarder.h
yarp/proto/framegrabber/FrameGrabberOf_Forwarder-inl.h
yarp/proto/framegrabber/FrameGrabberOf_Responder.h
yarp/proto/framegrabber/FrameGrabberOf_Responder-inl.h
yarp/proto/framegrabber/RgbVisualParams_Responder.cpp
yarp/proto/framegrabber/RgbVisualParams_Responder.h
yarp/proto/framegrabber/RgbVisualParams_Forwarder.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,66 +99,4 @@ constexpr yarp::conf::vocab32_t VOCAB_DRSETCAP = yarp::os::createVocab('D','R','
constexpr yarp::conf::vocab32_t VOCAB_DRSETBPP = yarp::os::createVocab('D','R','2','N'); // 39
constexpr yarp::conf::vocab32_t VOCAB_DRGETBPP = yarp::os::createVocab('D','R','2','O'); // 40



#if 0
cameraFeature_id_t featureVOCABEnum(int vocab)
{
switch (vocab) {
case VOCAB_BRIGHTNESS:
return YARP_FEATURE_BRIGHTNESS;
case VOCAB_EXPOSURE:
return YARP_FEATURE_EXPOSURE;
case VOCAB_SHARPNESS:
return YARP_FEATURE_SHARPNESS;
case VOCAB_WHITE:
return YARP_FEATURE_WHITE_BALANCE;
case VOCAB_HUE:
return YARP_FEATURE_HUE;
case VOCAB_SATURATION:
return YARP_FEATURE_SATURATION;
case VOCAB_GAMMA:
return YARP_FEATURE_GAMMA;
case VOCAB_SHUTTER:
return YARP_FEATURE_SHUTTER;
case VOCAB_GAIN:
return YARP_FEATURE_GAIN;
case VOCAB_IRIS:
return YARP_FEATURE_IRIS;
default:
return YARP_FEATURE_INVALID;
}

}

int featureEnum2Vocab(cameraFeature_id_t _enum)
{
switch (_enum) {
case YARP_FEATURE_BRIGHTNESS:
return VOCAB_BRIGHTNESS;
case YARP_FEATURE_EXPOSURE:
return VOCAB_EXPOSURE;
case YARP_FEATURE_SHARPNESS:
return VOCAB_SHARPNESS;
case YARP_FEATURE_WHITE_BALANCE:
return VOCAB_WHITE;
case YARP_FEATURE_HUE:
return VOCAB_HUE;
case YARP_FEATURE_SATURATION:
return VOCAB_SATURATION;
case YARP_FEATURE_GAMMA:
return VOCAB_GAMMA;
case YARP_FEATURE_SHUTTER:
return VOCAB_SHUTTER;
case YARP_FEATURE_GAIN:
return VOCAB_GAIN;
case YARP_FEATURE_IRIS:
return VOCAB_IRIS;
default:
return -1;
}

}
#endif

#endif // YARP_FRAMEGRABBER_PROTOCOL_CAMERAVOCABS_H
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

using yarp::proto::framegrabber::FrameGrabberControlsDC1394_Forwarder;

void FrameGrabberControlsDC1394_Forwarder::init(yarp::os::Port* port)
FrameGrabberControlsDC1394_Forwarder::FrameGrabberControlsDC1394_Forwarder(yarp::os::Port& port) :
m_port(port)
{
m_port = port;
}


Expand All @@ -28,7 +28,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setCommand(int code, double v)
cmd.addVocab(VOCAB_SET);
cmd.addVocab(code);
cmd.addFloat64(v);
m_port->write(cmd, response);
m_port.write(cmd, response);
return true;
}

Expand All @@ -42,7 +42,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setCommand(int code, double b, double
cmd.addVocab(code);
cmd.addFloat64(b);
cmd.addFloat64(r);
m_port->write(cmd, response);
m_port.write(cmd, response);
return true;
}

Expand All @@ -54,7 +54,7 @@ double FrameGrabberControlsDC1394_Forwarder::getCommand(int code) const
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_GET);
cmd.addVocab(code);
m_port->write(cmd, response);
m_port.write(cmd, response);
// response should be [cmd] [name] value
return response.get(2).asFloat64();
}
Expand All @@ -67,7 +67,7 @@ bool FrameGrabberControlsDC1394_Forwarder::getCommand(int code, double& b, doubl
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_GET);
cmd.addVocab(code);
m_port->write(cmd, response);
m_port.write(cmd, response);
// response should be [cmd] [name] value
b = response.get(2).asFloat64();
r = response.get(3).asFloat64();
Expand All @@ -81,7 +81,7 @@ unsigned int FrameGrabberControlsDC1394_Forwarder::getVideoModeMaskDC1394()
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETMSK);
m_port->write(cmd, response);
m_port.write(cmd, response);
return static_cast<unsigned int>(response.get(0).asInt32());
}

Expand All @@ -92,7 +92,7 @@ unsigned int FrameGrabberControlsDC1394_Forwarder::getVideoModeDC1394()
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETVMD);
m_port->write(cmd, response);
m_port.write(cmd, response);
return static_cast<unsigned int>(response.get(0).asInt32());
}

Expand All @@ -104,7 +104,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setVideoModeDC1394(int video_mode)
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETVMD);
cmd.addInt32(video_mode);
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -115,7 +115,7 @@ unsigned int FrameGrabberControlsDC1394_Forwarder::getFPSMaskDC1394()
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETFPM);
m_port->write(cmd, response);
m_port.write(cmd, response);
return static_cast<unsigned int>(response.get(0).asInt32());
}

Expand All @@ -126,7 +126,7 @@ unsigned int FrameGrabberControlsDC1394_Forwarder::getFPSDC1394()
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETFPS);
m_port->write(cmd, response);
m_port.write(cmd, response);
return static_cast<unsigned int>(response.get(0).asInt32());
}

Expand All @@ -138,7 +138,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setFPSDC1394(int fps)
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETFPS);
cmd.addInt32(fps);
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -149,7 +149,7 @@ unsigned int FrameGrabberControlsDC1394_Forwarder::getISOSpeedDC1394()
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETISO);
m_port->write(cmd, response);
m_port.write(cmd, response);
return static_cast<unsigned int>(response.get(0).asInt32());
}

Expand All @@ -161,7 +161,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setISOSpeedDC1394(int speed)
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETISO);
cmd.addInt32(speed);
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -173,7 +173,7 @@ unsigned int FrameGrabberControlsDC1394_Forwarder::getColorCodingMaskDC1394(unsi
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETCCM);
cmd.addInt32(video_mode);
m_port->write(cmd, response);
m_port.write(cmd, response);
return static_cast<unsigned int>(response.get(0).asInt32());
}

Expand All @@ -184,7 +184,7 @@ unsigned int FrameGrabberControlsDC1394_Forwarder::getColorCodingDC1394()
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETCOD);
m_port->write(cmd, response);
m_port.write(cmd, response);
return static_cast<unsigned int>(response.get(0).asInt32());
}

Expand All @@ -196,7 +196,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setColorCodingDC1394(int coding)
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETCOD);
cmd.addInt32(coding);
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -212,7 +212,7 @@ bool FrameGrabberControlsDC1394_Forwarder::getFormat7MaxWindowDC1394(unsigned in
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETF7M);
m_port->write(cmd, response);
m_port.write(cmd, response);

xdim = response.get(0).asInt32();
ydim = response.get(1).asInt32();
Expand All @@ -230,7 +230,7 @@ bool FrameGrabberControlsDC1394_Forwarder::getFormat7WindowDC1394(unsigned int&
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETWF7);
m_port->write(cmd, response);
m_port.write(cmd, response);
xdim = response.get(0).asInt32();
ydim = response.get(1).asInt32();
x0 = response.get(2).asInt32();
Expand All @@ -249,7 +249,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setFormat7WindowDC1394(unsigned int x
cmd.addInt32(ydim);
cmd.addInt32(x0);
cmd.addInt32(y0);
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -261,7 +261,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setOperationModeDC1394(bool b1394b)
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETOPM);
cmd.addInt32(int(b1394b));
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -272,7 +272,7 @@ bool FrameGrabberControlsDC1394_Forwarder::getOperationModeDC1394()
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETOPM);
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -284,7 +284,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setTransmissionDC1394(bool bTxON)
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETTXM);
cmd.addInt32(int(bTxON));
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -295,7 +295,7 @@ bool FrameGrabberControlsDC1394_Forwarder::getTransmissionDC1394()
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETTXM);
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -307,7 +307,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setBroadcastDC1394(bool onoff)
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETBCS);
cmd.addInt32(static_cast<int>(onoff));
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -318,7 +318,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setDefaultsDC1394()
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETDEF);
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -329,7 +329,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setResetDC1394()
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETRST);
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -341,7 +341,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setPowerDC1394(bool onoff)
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETPWR);
cmd.addInt32(static_cast<int>(onoff));
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -353,7 +353,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setCaptureDC1394(bool bON)
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETCAP);
cmd.addInt32(int(bON));
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -365,7 +365,7 @@ bool FrameGrabberControlsDC1394_Forwarder::setBytesPerPacketDC1394(unsigned int
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRSETBPP);
cmd.addInt32(int(bpp));
m_port->write(cmd, response);
m_port.write(cmd, response);
return response.get(0).asBool();
}

Expand All @@ -376,6 +376,6 @@ unsigned int FrameGrabberControlsDC1394_Forwarder::getBytesPerPacketDC1394()
yarp::os::Bottle response;
cmd.addVocab(VOCAB_FRAMEGRABBER_CONTROL_DC1394);
cmd.addVocab(VOCAB_DRGETBPP);
m_port->write(cmd, response);
m_port.write(cmd, response);
return static_cast<unsigned int>(response.get(0).asInt32());
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class FrameGrabberControlsDC1394_Forwarder :
public yarp::dev::IFrameGrabberControlsDC1394
{
public:
void init(yarp::os::Port* port);
FrameGrabberControlsDC1394_Forwarder(yarp::os::Port& port);
~FrameGrabberControlsDC1394_Forwarder() override = default;

unsigned int getVideoModeMaskDC1394() override;
unsigned int getVideoModeDC1394() override;
Expand Down Expand Up @@ -61,7 +62,7 @@ class FrameGrabberControlsDC1394_Forwarder :
unsigned int getBytesPerPacketDC1394() override;

private:
yarp::os::Port* m_port {nullptr};
yarp::os::Port& m_port;

bool setCommand(int code, double v);
bool setCommand(int code, double b, double r);
Expand Down
Loading