yamcs / yamcs-studio

Desktop TM/TC Client for Yamcs
https://docs.yamcs.org/yamcs-studio/
Eclipse Public License 2.0
27 stars 14 forks source link

Execute Python Scrip Example in Documentation #96

Closed lorenzo-gomez-windhover closed 3 years ago

lorenzo-gomez-windhover commented 3 years ago

Hi there,

I've been playing around with YAMCS-STUDIO and it is very intuitive and integrates so well with YAMCS software. We are currently using it for the development of airliner's ground system.

We can make interactive displays with our telemetry very easy, which is awesome, thanks for that!

The only thing I am currently unable to do make something like a plain button and hook it up to a command so that we are able to send telecommands to our vehicles directly from our OPI displays. I was reading the docs and it looks like this is what the "Actions" concept is for? Am I understanding it correctly?

I came across an "example" link in the documentation for Python scripts that send commands, but the link is broken; it gives me a "404" error.

OS:18.04.5 LTS (Bionic Beaver) YAMCS data format:XTCE YAMCS Studio version: 1.5.3 YAMCS version:5.1.3

I hope I explained my issue clearly.

Cheers!

lorenzo-gomez-windhover commented 3 years ago

I may have answered my own issue. Is this what I should look at?

fqqb commented 3 years ago

Hi, thanks for your kind words. I was not aware of the 404s - i will look into that.

The last link you provide is a general Python 3 library which can be used for integrating third-party applications, or standalone Python scripts, but is has no relation to Yamcs Studio.

Yamcs Studio is a Java program. For the scripts in Python-syntax, it uses Jython, a java implementation of a Python 2.7 distribution. There is very limited support to import external modules inside display scripts. Variations on this question come up quite often, so I'm thinking how best to address this core need going forward.

If all you would like to do is send a command, you can just use something like this as an action script attached to your button (python or javascript -- should both work):

Yamcs.issueCommand("/YSS/SIMULATOR/BatteryVoltage", {"voltage_num": 1})

The backend implementation of this method is here: https://github.com/yamcs/yamcs-studio/blob/master/bundles/org.yamcs.studio.css.script/src/main/java/org/yamcs/studio/script/Yamcs.java

As you can see from that link, there's not many other functions in there, so it's an area of improvement.

lorenzo-gomez-windhover commented 3 years ago

This is exactly what I did! And it's working!

Thanks so much for the quick and detailed response! It'd be cool to expand that implementation to do more. Do you guys accept contributions at the moment? I'm curious for the future in case my team and I come up with something and it could be integrated into the main line. We are very interested in the auto-generation of displays for Ground Systems and this API has a lot of potential for that kind of work.

fqqb commented 3 years ago

I would need to confirm with management, but my personal view is that with Yamcs Studio being EPL1.0, contributions can be considered under those license conditions.

For Yamcs Server, and some other products we have to be more careful in order to protect our interests, as well as retain the ability to provide commercial licensing to customers that cannot or do not want to work under the restrictions of AGPL. So there we have a CLA in place, which allows you to make contributions while retaining ownership.

Back on the scripts, my current thinking is that it should be technically possible to autogenerate all of the API methods into java. Then they would be available in both Python and JavaScript display scripts. Our API is fully described in .proto files, so from there, using protoc, it is possible to do some custom code generation.

fqqb commented 3 years ago

Or maybe just continue with manual wrappers on top of YamcsClient/ProcessorClient/... . I've been resisting this a bit in order to avoid yet another maintenance area. But we've been getting better at keeping the API stable compared to a few years ago, so not the worst idea.

m-sc commented 3 years ago

This is exactly what I did! And it's working!

Thanks so much for the quick and detailed response! It'd be cool to expand that implementation to do more. Do you guys accept contributions at the moment? I'm curious for the future in case my team and I come up with something and it could be integrated into the main line. We are very interested in the auto-generation of displays for Ground Systems and this API has a lot of potential for that kind of work.

I see you managed to get it working. For future reference, there is some documentation and an example of this use case in the Yamcs Studio doc: https://docs.yamcs.org/yamcs-studio/authoring/example-action-telecommand/

lorenzo-gomez-windhover commented 3 years ago

Thanks @m-sc. I'll be sure to read that documentation as well :+1: .

fqqb commented 3 years ago

404s fixed and deployed