fandango.interface.inheritance module

@if gnuheader

## ## file : interface.py ## ## description : see below ## ## project : Tango Control System ## ## $Author: Sergi Rubio Manrique, srubio@cells.es $ ## ## $Revision: 2008 $ ## ## copyleft : ALBA Synchrotron Controls Section, CELLS ## Bellaterra ## Spain ## ############################################################################# ## ## This file is part of Tango Control System ## ## Tango Control System is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as published ## by the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## Tango Control System is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, see <http://www.gnu.org/licenses/>. ########################################################################### # Adding TRUE DeviceServer Inheritance # Searchs all dicts in the ChildClass and updates its values using the Parent dicts @endif

@package interface @author srubio@cells.es

<h2 id=”Proposals”>Proposals of implementation</h2> <h3 id=”CommsDev”>CommsDev</h3> <p> Hypothetical Abstract Class for Devices using Serial Line, Tcp Socket, Modbus, ... </p> <h4 id=”Properties”>Properties</h4> <dl><dt><tt>str[] CommsDev__Properties</tt></dt><dd> Allows to setup the properties of the device<br /> <tt>[‘key:value’,’key:value’,’key:[values]’,...]</tt> </dd></dl> <h4 id=”Attributes”>Attributes</h4> <dl><dt><tt>int LastComm</tt></dt><dd> The last time that a communication was successful. </dd></dl>

<dl><dt><tt>state ChannelState</tt></dt><dd> State of the hardware device on charge of communications <tt>[ON/OFF/FAULT/UNKNOWN/RUNNING]</tt> </dd></dl> <h4 id=”Commands”>Commands</h4> <dl><dt><tt>str Talk(str)</tt></dt><dd> A direct raw writing/reading to the communication port </dd></dl>

<h3>Example of making a Controller device with embedded Serial communications</h3>
<pre>
# Adding TRUE DeviceServer Inheritance from interface import FullTangoInheritance VacuumController,VacuumControllerClass = FullTangoInheritance(‘VacuumController’, VacuumController,VacuumControllerClass, SerialDS,SerialDSClass,ForceDevImpl=True) py.add_TgClass(VacuumController,VacuumControllerClass,’VacuumController’)

</pre>

fandango.interface.inheritance.DeviceClassInheritance(ChildClass)[source]

class decorator

fandango.interface.inheritance.FullTangoInheritance(name, child, childClass, parent, parentClass, Exclude=[], ForceDevImpl=False)[source]

arguments are: NewDeviceName, Device, DeviceClass, newParentDevice, newParentDeviceClass, parent members to exclude @remark The code must be added always before each add_TgClass call (it could be outside the class definition file!)

example: <pre>

# Adding TRUE DeviceServer Inheritance from interface import FullTangoInheritance PySignalSimulator,PySignalSimulatorClass = FullTangoInheritance(‘PySignalSimulator’, PySignalSimulator,PySignalSimulatorClass, DynamicDS,DynamicDSClass,ForceDevImpl=True) py.add_TgClass(PySignalSimulatorClass,PySignalSimulator,’PySignalSimulator’)

</pre>

fandango.interface.inheritance.NewTypeInheritance(name, klass, parent, dikt={})[source]

Based on NewClass = type(‘nameOfClass’,(bases,),dikt={})

fandango.interface.inheritance.addAllClasses(obj, servername='', db=None, classes=None)[source]

This method will add all classes listed in the database to the server object (if those classes are available in the pythonpath)

obj argument must be a PyTango.Util([‘exec_name’,’instance_name’]) object If servername or db are not specified will be taken from obj.instance()

Dependences can be added to pythonpath using sys.path.insert(0,’path/to/your/device’)

fandango.interface.inheritance.addCommandToTgClass(dev, dev_class, cmd_name, cmd_def, cmd_fun)[source]

@param cmd_def should be like [[argintype,”desc”],[argouttype,”desc”],{‘property’:value}] e.g: [[PyTango.DevString, “formula to evaluate”],[PyTango.DevString, “formula to evaluate”],{‘Display level’:PyTango.DispLevel.EXPERT,}]

fandango.interface.inheritance.addTangoInterfaces(device, interfaces)[source]

It adds properties and implementation to the parent class from a list of tuples (Device,DeviceClass) @param device A tuple (Device,DeviceClass) to be extended with interfaces @param interfaces A list of tuples (Device,DeviceClass) to the first server @return Returns a tuple (Device,DeviceClass) containing the new interfaces

from interface import FullTangoInheritance PySignalSimulator,PySignalSimulatorClass = FullTangoInheritance(‘PySignalSimulator’,PySignalSimulator,PySignalSimulatorClass,DynamicDS,DynamicDSClass,ForceDevImpl=True) py.add_TgClass(PySignalSimulatorClass,PySignalSimulator,’PySignalSimulator’)
fandango.interface.inheritance.getDeviceClassObjects(classname, path='')[source]

This method locates a Tango Device Class in the python Path and returns its (Device,DeviceClass) objects

fandango.interface.inheritance.updateChildClassDicts(Child, Parent, Exclude=[])[source]