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

Set iq (output) parameters #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class HttpCommandInterface
//! @returns True on success, false otherwise
bool setParameter(const std::string name, const std::string value);

//! Set iq (io) parameter
//! @param name Name
//! @param value Value
//! @returns True on success, false otherwise
bool setIQParameter(const std::string name, const std::string value);

//! Get sensor parameter
//! @param name Parameter name
//! @returns Optional string value with value of given parameter name
Expand Down
35 changes: 35 additions & 0 deletions pepperl_fuchs_r2000/include/pepperl_fuchs_r2000/r2000_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,41 @@ class R2000Driver
//! @returns True on success, False otherwise
bool setSamplesPerScan( unsigned int samples );

//! Enable I/Q operations on device
//! @param enabled I/Q global enable switch for all channels. true = on. false = off
//! @returns True on success, False otherwise
bool setIQGlobalEnable(bool enabled);

//! Set the IQ mode of the given port
//! @param port 1 or 2
//! @param mode I/Q channel operation mode. Options are: disabled, input_high_z, output_push_pull, output_n_switching, output_p_switching
//! @returns True on success, False otherwise
bool setIQMode(uint8_t iq_port, std::string mode);

//! Set the IQ polarity of the given port
//! @param port 1 or 2
//! @param polarity I/Q channel polarity. Options are: active_high, active_low
//! @returns True on success, False otherwise
bool setIQPolarity(uint8_t iq_port, std::string polarity);

//! Set the IQ off delay param of the given port
//! @param port 1 or 2
//! @param off_delay I/Q channel pulse extension (ms)
//! @returns True on success, False otherwise
bool setIQOffDelay(uint8_t iq_port, unsigned int off_delay);

//! Set the IQ source of the given port
//! @param port 1 or 2 (timesync is only on port 2)
//! @param source Options are: iq_output, timesync
//! @returns True on success, False otherwise
bool setIQSource(uint8_t iq_port, std::string source);

//! Set the IQ timesync interval
//! @param port 1 or 2 (timesync is only on port 2)
//! @param interval Interval for generating a timesync pulse (ms). Intervals MUST be defined in increments of 1000ms. Default = 4000
//! @returns True on success, False otherwise
bool setIQTimesyncInterval(unsigned int interval);

//! Reboot Laserscanner (Takes ~60s)
//! @returns True if command was successfully received, False otherwise
bool rebootDevice();
Expand Down
6 changes: 6 additions & 0 deletions pepperl_fuchs_r2000/src/driver/http_command_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ bool HttpCommandInterface::setParameter(const std::string name, const std::strin
return sendHttpCommand("set_parameter",name,value) && checkErrorCode();
}

//-----------------------------------------------------------------------------
bool HttpCommandInterface::setIQParameter(const std::string name, const std::string value)
{
return sendHttpCommand("set_iq_parameter",name,value) && checkErrorCode();
}

//-----------------------------------------------------------------------------
boost::optional< std::string > HttpCommandInterface::getParameter(const std::string name)
{
Expand Down
47 changes: 47 additions & 0 deletions pepperl_fuchs_r2000/src/driver/r2000_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,53 @@ const std::map< std::string, std::string >& R2000Driver::getParameters()
return parameters_;
}

//-----------------------------------------------------------------------------
bool R2000Driver::setIQGlobalEnable(bool enabled)
{
return command_interface_->setIQParameter("iq_global_enable", enabled ? "on" : "off");
}

//-----------------------------------------------------------------------------
bool R2000Driver::setIQMode(uint8_t iq_port, std::string mode)
{
std::stringstream ss;
ss << "iq"<<(int16_t)iq_port<<"_mode";
return command_interface_->setIQParameter(ss.str(), mode);
}

//-----------------------------------------------------------------------------
bool R2000Driver::setIQPolarity(uint8_t iq_port, std::string polarity)
{
std::stringstream ss;
ss << "iq"<<(int16_t)iq_port<<"_polarity";
return command_interface_->setIQParameter(ss.str(), polarity);
}

//-----------------------------------------------------------------------------
bool R2000Driver::setIQOffDelay(uint8_t iq_port, unsigned int off_delay)
{
std::stringstream ss;
ss << "iq"<<(int16_t)iq_port<<"_off_delay";
return command_interface_->setIQParameter(ss.str(), std::to_string(off_delay));
}

//-----------------------------------------------------------------------------
bool R2000Driver::setIQSource(uint8_t iq_port, std::string source)
{
std::stringstream ss;
ss << "iq"<<(int16_t)iq_port<<"_source";
return command_interface_->setIQParameter(ss.str(), source);
}

//-----------------------------------------------------------------------------
bool R2000Driver::setIQTimesyncInterval(unsigned int interval)
{
if (interval % 1000 != 0){
std::cerr << "WARNING: Cannot set iq_timesync_interval to " << interval << "(ms). value must be a multiple of 1000 (ms)" << std::endl;
}
return command_interface_->setIQParameter("iq_timesync_interval", std::to_string(interval));
}

//-----------------------------------------------------------------------------
bool R2000Driver::setScanFrequency(unsigned int frequency)
{
Expand Down