This example shows an PVAction node used for RPC-like functionality.
class RPCSquare
{
public:
void square(const timespec& timestamp, const std::int32_t& value);
void init(timespec* timestamp, std::int32_t* value);
private:
};
RPCSquare::RPCSquare(
nds::Factory& factory,
const std::string& device,
{
"Square", std::bind(&RPCSquare::square, this,
std::placeholders::_1, std::placeholders::_2),
std::bind(&RPCSquare::init, this, std::placeholders::_1,
std::placeholders::_2));
squarePV.setDescription("Square any integer");
rootNode.addChild(squarePV);
rootNode.initialize(this, factory);
}
void
RPCSquare::square(const timespec& timestamp, const std::int32_t& value)
{
squarePV.setValueBack(timestamp, value*value);
}
void
RPCSquare::init(timespec* timestamp, std::int32_t* value)
{
*value = 0;
}