Lifecycle of Waveform

488 Views Asked by At

I am wanting to start Redhawk Domain Mgr, Device Mgrs, and Waveform on cpu at startup, without any user intervention. I then should be able to connect to it with the IDE.

I have created a python script that does the following:

#! /usr/local/bin/python
from ossie.utils import redhawk
#Start a new domain and device managers
domain = redhawk.kickDomain()
wave = domain.createApplication("/waveforms/msgWaveform/msgWaveform.sad.xml")
wave.start()

This starts Domain mgr, Device mgr, and Msg waveform.

After this perl script completes, I then bring up the IDE. I connect to the Domain. I see the devices, but the waveform is not present. It appears that waveform ends when the perl script finishes. I was hoping that the waveform would not disappear but I would be able to retrieve it at later time.

Do I need to start a service which is used to help keep the waveform alive?

2

There are 2 best solutions below

0
On BEST ANSWER

The "createApplication" intentionally cleans up when the script exits, but there are two ways to get around it.

The easiest would be to add a while loop to the end of the script. This would keep the Waveform running as long as the script is running, and you would stop it by Ctrl-C in the terminal running the script. Based on your original script it would look like:

#! /usr/local/bin/python
import time
from ossie.utils import redhawk
#Start a new domain and device managers
domain = redhawk.kickDomain()
time.sleep(1)

wave = domain.createApplication("/waveforms/Test/Test.sad.xml")
wave.start()

while True:
  time.sleep(1)

This is not recommended for anything other than testing. In addition to closing the Waveform when the script ends, the above code also stops the domain and the device manager.For systems that launch waveforms on boot, commonly the domain and device managers are launched via /etc/init.d scripts like so:

nodeBooter -D --daemon
nodeBooter -d /nodes/DevMgr_[hostname]/DeviceManager.dcd.xml --daemon

And then in your script you would do something like:

from ossie.utils import redhawk
from ossie.cf import CF

domain = redhawk.Domain('REDHAWK_DEV')

try:
  domain.installApplication("/waveforms/Test/Test.sad.xml")
except CF.DomainManager.ApplicationAlreadyInstalled:
  print "Already Installed, skipping."

factories = domain._get_applicationFactories()
#if multiple applications are installed you can look for the correct factory
#  using factories[i]._get_name() == 'Test'
myFactory = factories[0]

myFactory.create('Test_[UNIQUEID]', [], [])
0
On

Try the following script instead:

from ossie.utils import redhawk
#Start a new domain and device managers
domain = redhawk.kickDomain()
domain.installApplication("/waveforms/msgWaveform/msgWaveform.sad.xml")
appFactory = domain._get_applicationFactories()[0]
wave = appFactory.create(appFactory._get_name(), [], [])
wave.start()
# Uninstall the Application Factory
domain.uninstallApplication(appFactory._get_identifier())

The reason your wave is being release is because the createApplication() function is specific to the redhawk python module that you imported. It essentially wraps the above calls into one clean user call. Additionally it keeps track of what applications have been launched so that they can be cleaned up upon the exit of the script, which is what you are seeing.

By doing the above, you are directly accessing the CORBA interface methods which avoids the bookkeeping of the application from the python code and thus will not be cleaned up on the exit of the script.