NDS3
1.0.0
API reference manual
|
Communicates with a static instance of the control system.
It is used to register new devices and to launch the loop that communicates with the actual control system and runs until the application is terminated.
#include <factory.h>
Public Member Functions | |
Factory (const std::string &controlSystemName) | |
Allocate a factory object that communicates with the control system. More... | |
void | run (int argc, char *argv[]) |
Launches a loop that communicate with the control system. More... | |
void | createDevice (const std::string &driverName, const std::string &deviceName, const namedParameters_t ¶meters) |
Create a device registered with registerDriver or loaded during the startup sequence. More... | |
void | destroyDevice (const std::string &deviceName) |
Destroy a device created with createDevice(). More... | |
void | subscribe (const std::string &pushFrom, const std::string &pushTo) |
Subscribe an output PV (derived from PVBaseOut) to an input PV (derived from PVBaseIn). More... | |
void | unsubscribe (const std::string &pushTo) |
Unsubscribe an output PV from the input PV. More... | |
void | replicate (const std::string &replicateSource, const std::string &replicateDestination) |
Replicate an input PV (derived from PVBaseIn) to another input PV. More... | |
void | stopReplicationTo (const std::string &destination) |
Stop the replication to the specified PV. More... | |
Thread | runInThread (const std::string &name, threadFunction_t function) |
Creates a new thread and executes the specified function in it. More... | |
Static Public Member Functions | |
static void | registerDriver (const std::string &driverName, allocateDriver_t allocateFunction, deallocateDriver_t deallocateFunction) |
Register a device in the control system. More... | |
static void | registerControlSystem (Factory &factory) |
Register a new control system. More... | |
nds::Factory::Factory | ( | const std::string & | controlSystemName | ) |
Allocate a factory object that communicates with the control system.
controlSystemName | the type of control system to communicate with (empty = default) |
void nds::Factory::createDevice | ( | const std::string & | driverName, |
const std::string & | deviceName, | ||
const namedParameters_t & | parameters | ||
) |
Create a device registered with registerDriver or loaded during the startup sequence.
driverName | the name of the driver that implements the device |
deviceName | a parameter passed to the device usually used to set the name of the root node |
parameters | map of named parameters passed to the device |
void nds::Factory::destroyDevice | ( | const std::string & | deviceName | ) |
Destroy a device created with createDevice().
deviceName | the name given to the device in createDevice() |
|
static |
Register a new control system.
Control system interfaces are loaded from dynamic modules during startup, but in some cases they may also be registered separately via this method.
The test units use this method to register test control systems that have access to the NDS internals.
factory | the control system to be registered |
|
static |
Register a device in the control system.
The devices are loaded automatically from the folders declared in the enviroment variables NDS_DEVICES and LD_LIBRARY_PATH. However you can use this method to declare additional devices that have been statically linked to your application (e.g.: the NDS test units do this).
Your device lifecycle will be managed by NDS: an allocation function will be called when the device is needed and a deallocation function will be called when the device can be deleted.
The allocation function should take care of creating the device structure using the Node, Port and PVBase derived classes and call initialize() on the root node. It should also allocate the classes that contain the delegate functions used by the nodes and PVs.
The deallocation function should take care of removing the classes that contain the delegate functions.
driverName | the device driver name |
allocateFunction | the allocation function |
deallocateFunction | the deallocation function |
void nds::Factory::replicate | ( | const std::string & | replicateSource, |
const std::string & | replicateDestination | ||
) |
Replicate an input PV (derived from PVBaseIn) to another input PV.
Each time data is pushed to the source input PV then the same data is also pushed to the destination PV immediately and in the same thread used by the original push/write operation.
This method works also across control systems running in the same NDS process.
replicateSource | the full name of the input PV from which the data is replicated |
replicateDestination | the full name of the input PV to which the data must be copied |
void nds::Factory::run | ( | int | argc, |
char * | argv[] | ||
) |
Launches a loop that communicate with the control system.
The loop terminates only when the application must exit.
argc | the argc parameter received by the main() function |
argv | the argv parameter received by the main() function |
Thread nds::Factory::runInThread | ( | const std::string & | name, |
threadFunction_t | function | ||
) |
Creates a new thread and executes the specified function in it.
name | the thread name |
function | the function to execute in the new thread |
void nds::Factory::stopReplicationTo | ( | const std::string & | destination | ) |
Stop the replication to the specified PV.
destination | the full name of the input PV that should stop receiving copies of the data pushed to the source PV |
void nds::Factory::subscribe | ( | const std::string & | pushFrom, |
const std::string & | pushTo | ||
) |
Subscribe an output PV (derived from PVBaseOut) to an input PV (derived from PVBaseIn).
Each time the specified input PV pushes new values or is written by the device support that owns it then the output PV receives the pushed or written value immediately and in the same thread used to push/write the input PV.
This method works also across control systems running in the same NDS process.
pushFrom | the full name of the input PV from which the data must be pushed |
pushTo | the full name of the output PV to which the data must be pushed |
void nds::Factory::unsubscribe | ( | const std::string & | pushTo | ) |
Unsubscribe an output PV from the input PV.
pushTo | the name of the receiving PV that must be unsubscribed |