NDS3  1.0.0
API reference manual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nds::Factory Class Reference

Detailed Description

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.

Examples:
oscilloscope/oscilloscope.cpp, oscilloscopeMultiChannel/oscilloscopeMultiChannel.cpp, rpcSquare/rpcSquare.cpp, and thermometer/thermometer.cpp.

#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 &parameters)
 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...
 

Constructor & Destructor Documentation

nds::Factory::Factory ( const std::string &  controlSystemName)

Allocate a factory object that communicates with the control system.

Parameters
controlSystemNamethe type of control system to communicate with (empty = default)

Member Function Documentation

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.

Parameters
driverNamethe name of the driver that implements the device
deviceNamea parameter passed to the device usually used to set the name of the root node
parametersmap of named parameters passed to the device
void nds::Factory::destroyDevice ( const std::string &  deviceName)

Destroy a device created with createDevice().

Parameters
deviceNamethe name given to the device in createDevice()
static void nds::Factory::registerControlSystem ( Factory factory)
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.

Parameters
factorythe control system to be registered
static void nds::Factory::registerDriver ( const std::string &  driverName,
allocateDriver_t  allocateFunction,
deallocateDriver_t  deallocateFunction 
)
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.

Parameters
driverNamethe device driver name
allocateFunctionthe allocation function
deallocateFunctionthe 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.

Parameters
replicateSourcethe full name of the input PV from which the data is replicated
replicateDestinationthe 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.

Parameters
argcthe argc parameter received by the main() function
argvthe 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.

Parameters
namethe thread name
functionthe function to execute in the new thread
Returns
a Thread object that references the new thread
void nds::Factory::stopReplicationTo ( const std::string &  destination)

Stop the replication to the specified PV.

Parameters
destinationthe 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.

Parameters
pushFromthe full name of the input PV from which the data must be pushed
pushTothe 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.

Parameters
pushTothe name of the receiving PV that must be unsubscribed

The documentation for this class was generated from the following file: