Live listener - connection address

Hello

I have created a live listener that generates sin data. I am plotting data quite happily and now would like to listen to an external data source. The connection address in ILiveListener::connect() is always 0.0.0.0:0. How can I get a connection address?

Regards

Derek Sandiford

Hi Derek,

I assume you are going through the StartLiveData algorithm to start the listening?

Do you have an entry in the Facilities.xml file? This is required so that the address can be passed to the live listener on connection.

Hi Martyn

I have created a listener called MYTEST.

I can use the StartLiveData in a script or manually load live data

my script:

StartLiveData( Instrument='MYTEST', OutputWorkspace='cos', UpdateEvery=2,AccumulationMethod='Replace', PreserveEvents=0)

I have added a facility in Facilities.xml.

  <instrument name="ABCDEF">
    <technique>Tech 1</technique>
    <livedata address="BOO:1234" />
  </instrument>

  <instrument name="MYTEST">
    <technique>Tech 2</technique>
    <livedata address="BOO:1234" />
  </instrument>

</facility>

When I print the address in connect() I always see “0.0.0.0:0”

Regards

Derek

I think you are be missing the listener= attribute on your livedata tag to tell it which listener class to create.

Can you try adding that?

Got it. Thanks.

So if I want the same listener class to read several signals on different ports I just need an instrument for each signal defined in the facilities.xml?

Thanks

Derek

Great!

Currently, yes you’ll need a separate instrument per address.

Martyn

Thanks

Slightly off topic but is it possible to define additional parameters for an instrument that can be accessed in the listener?

I may want my listeners to read data via a REST API so will need to pass a URL to the listener.

Derek

I’m afraid the parameters definable at that level are fixed so you would’t be able to pass anything extra that way.

The only way I can think of at present to be able to define that information & access it in the listener would be to save it has a config option in the script and access it in the listener.

In Python:

config['myinst.apiurl'] = 'http://ww.foo.bar/api'
StartLiveData(....)

In the C++ LiveListener class:

// this returns an empty string if that key doesn't exist
auto apiIURL = ConfigService::Instance().getString("myinst.url");

It’s not pretty and separates the information but it would work.

That will be fine.

Thanks