Personal tools
You are here: Home Members srubio PySignalSimulator Device Server
Log in


Forgot your password?
 

PySignalSimulator Device Server

This device server allows to declare dynamic attributes using lines of python code that can be modified at runtime.

PySignalSimulator Device Server

This Python Device Server will allow to declare dynamic attributes which values will depend on a given time-dependent formula:

To specify the code for each attribute we use python that has several advantages:

  • No compilation of code; just write, refresh() and see the result.
  • Easy syntax (users can tune it).
  • We can control what can be executed (we use a restricted python eval that only loads the modules/libraries we are interested in).
Example of DynamicAttributes property declaration

The attributes are created after restarting the device or calling updateDynamicAttributes() ... do not use Init() to do it!

  Square=0.5+square(t) #(t = seconds since the device started)
  NoisySinus=2+1.5*sin(3*t)-0.5*random()
  SomeNumbers=DevVarLongArray([1000.*i for i in range(1,10)])\

  TEMPERATURE = 25+5*sin((1./60)*t)
  PRESSURE = 2.5e-5+1e-6*sin((1./60)*t)
  TEMPERATURES = DevVarDoubleArray([25+v*sin((1./k)*t) for v,k in [(5,60),(10,30),(15,45),(5,5)]])

  MAX_TEMPERATURE = max(TEMPERATURES)
  TEMP_LIMIT = READ and VAR('TEMP_LIMIT') or WRITE and VAR('TEMP_LIMIT',VALUE)

  HOT = DevBoolean(MAX_TEMPERATURE>VAR('TEMP_LIMIT'))
  COLD = DevBoolean(MAX_TEMPERATURE<15)
  TEMPERATE = DevBoolean(not HOT and not COLD)
  EXTREME = DevBoolean(HOT or COLD)

Right part of equality is the attribute name, type is DevDouble? by default but all tango types are available. READ,WRITE,VALUE,t,ATTR(),VAR() are reserved keywords to manage READ/WRITE access, time, external attribute reading and storing variables to be used in other attributes.

Format is specified at  tango-controls.org

Signals that can be easily generated with amplitude between 0.0 and 1.0 are:

rampt(t), sin(t), cos(t), exp(t), triangle(t), square(t,duty), random()

The MaxValue/MinValue property for each Attribute will determine the State of the Device only if the property DynamicStates is not defined.

If defined, DynamicStates will use this format:

  FAULT=2*square(0.9,60)>0.<br>
  ALARM=NoisySinus>3<br>
  ON=1<br>

This device inherits from PyTango_utils.dynamic.DynamicDS Class

Document Actions