CControlHardware

Name

CControlHardware -- Base class (ABC) of a slow controls driver

Synopsis


           class CControlHardware {
           
  CControlHardware(std::string name);
           
  virtual  = 0 void  onAttach(CControlModule& configuration);
               virtual   void  Initialize(CCCUSB& crate);
  
               virtual   = 0 std::string  Update(CCCUSB& crate);
  
                virtual   = 0 std::string  Set (CCCUSB& crate, std::string  parameter, std::string  value);
              virtual  = 0  std::string  Get(CCCUSB&  crate, std::string parameter);
             virtual   = 0 void  clone(const  CControlHardware& rhs);
  

};
        

DESCRIPTION

CControlHardware is the abstract base class for slow controls drivers. See METHODS below for the set of methods a driver must implement. See CModuleFactory and CModuleCreator for information about how to make the Module create command aware of your driver so that it instantiate it.

METHODS

CControlHardware(std::string name);

The base class constructor is how a module name gets associated with a module driver instance. The name parameter specifies the name of the module. This is normally passed in from the name in the Module create command.

virtual = 0 void onAttach(CControlModule& configuration);

Each driver instance has a configuration associated with it wrapped inside a ControlModule object. This packaging provides the transparent configuration and command dispatching required to decouple the code required by the device driver from the code that makes use of the device driver.

A driver instance and its CControlModule get bound together soon after the driver instance and CControlModule are created. At that time, the framework code invokes the OnAttach method of the driver passing in configuration, a reference to the instance's CControlModule object.

The driver normally needs to save configuration so that it an access its configuration in later operations. The driver also should create configuration parameters when OnAttach is called. In most cases a driver will at least neaed to define a slot configuration parameter that can be configured with the slot in which the hardware has been installed.

This method is pure virtual in the base class and therefore must be implemented in concrete derived classes.

virtual void Initialize(CCCUSB& crate);

This method is called after the control configuration script has completely run. It provides for one-time initialiation to set the device into a known state. The crate parameter is a controller object that allows the method to perform CAMAC operations.

The base class method does nothing but is defined. Therefore concrete classes that do not require device initialization may omit this method.

virtual = 0 std::string Update(CCCUSB& crate);

This method is intended for devices with write only registers. It allows internal shadow state to be written to the device. The crate parameter is the controller object that allows the method to perform CAMAC operations.

On success this method is supposed to return OK while on failure, it should return a string of the form: ERROR - Some human readable error message.

virtual = 0 std::string Set (CCCUSB& crate, std::string parameter, std::string value);

This is called by the framework whena a client has requested a slow control parameter be set. The crate parameter is the controller object that allows the driver to perform CAMAC operations.

Each device defines a set of settable parameters. These are given names by the driver. The client specifies the name of the parameter to be set and its value. These are transmitted to the driver's Set method via the parameter and value parameters respectively.

The driver is supposed to set the named parameter to value. On success, the driver should return the string OK If the driver detects an error it should return a string of the form: ERROR - Some human readable error string

This method is pure virtual in this base class so it must be defined in concrete drivers. Device drivers that manage devices without settable parameters can simple return an error string.

virtual = 0 std::string Get(CCCUSB& crate, std::string parameter);

The Get method is called when a client requests a parameter from a device. The crate parameter is the controller object and can be used to perform CAMAC operations.

As with Set the driver defines a set of named parameters that can be read. The client provides this as the parameter parameter. The driver is supposed to retrive the value of parameter from the hardware, convert it to text and return that text as its value. If the driver detects an error, it returns a string of the form ERRORSome human readable error message

virtual = 0 void clone(const CControlHardware& rhs);

This method is used to support virtual copy construction. The driver should copy the state of the rhs objet into its own state. The copy should be done safely so that destruction of rhs won't implicitly destroy parts of the copied state.

The driver is guaranteed that the actual type of rhs is the same as the class of the driver itself.