pythonredhawksdr

Unable to set equation in redhawk's fcalc component


In REDHAWK IDE (v2.12), I am trying to use fcalc component for some math calculations. I tried to follow an example in the doc by putting math.sin(a+b)+random.random() in the equation field, but I got the following error:

CF.PropertySetPackage.InvalidConfiguration: Failure: . Properties: equation
IDL:CF/PropertySet/InvalidConfiguration:1.0

I also tried other math functions, such as sqrt. However, none of them worked. It is very hard to add any modules in the import field as well.

Did I do anything wrong while using this fcalc component?


Solution

  • It appears that the property change listener is not being triggered for the initial property configuration when launched in the IDE sandbox. There are several workarounds:

    1. Manually configure the import property after launching the component, which will trigger the property change listener. Adding time to the list of imports, for example, will then import math and random as well.
    2. Use the Python sandbox instead of the IDE sandbox

      >>> from ossie.utils import sb
      >>> fcalc = sb.launch('rh.fcalc')
      2019-01-04 11:55:44 WARNING rh_fcalc:176 - NOT overriding global namespace with random from random
      >>> fcalc.equation = 'sin(a+b)+random.random()'
      

      The warning is expected and just indicates that you can't use random() in the equation without the full namespace random.random() because it would conflict with the random library.

    3. Launch rh.fcalc in a waveform in a domain