Hal Standalone and a Java gui

More
22 Aug 2019 16:43 - 22 Aug 2019 16:47 #142855 by dab77
Hi, two months ago I have been suggested in the users-mailing-list to use Hal without Linuxcnc to do some motor control, which doesn't need Gcode. As an example think about a couple of indipendent motors, and to control them separately following prewritten positions, speeds and ramps. I really like the Hal standalone idea, I tried, and of course it does work.

I know I could draw a simple gui using pyvcp or gladevcp or (never tried) qtvcp, but I need a more complex and custom Gui, and I'm good in doing this in Java, while as far as I try I cannot in python.

So, do you think there is a way to do all the Hal stuff as usual in python, and then control Hal pins in Java?

Thanks, Davide.
Last edit: 22 Aug 2019 16:47 by dab77.

Please Log in or Create an account to join the conversation.

More
22 Aug 2019 17:58 #142866 by cmorley
i know nothing of Java.
HAL is written in C and the python module hooks into the HAL C library to do the dirty work.
Can Java hook into C libraries?

Chris M

Please Log in or Create an account to join the conversation.

More
22 Aug 2019 18:46 #142874 by tommylight
I would not use Java for ...... well anything ever, but since it is being forced down our throat i am having trouble avoiding it totaly.
I do not like the overhead on the recourses.
Just my opinion.

Please Log in or Create an account to join the conversation.

More
25 Aug 2019 14:52 #143147 by dab77
Replied by dab77 on topic Hal Standalone and a Java gui
I know Java weights a lot, but it is also waay simpler and faster to write. But that's only my opinion since I can't write python as I would like to.

Anyway, thanks for answering.

Please Log in or Create an account to join the conversation.

More
25 Aug 2019 15:57 #143149 by dab77
Replied by dab77 on topic Hal Standalone and a Java gui
I have found a way to interact in a very simple way inside java, with HAL.
I'm using Processing here to make it simple..
I have created a siggen module and added to a thread.
then inside Processing just launched a system command like this (just the hint):
String[] cmd = {"halcmd", "setp", "siggen.0.frequency", "50"};
 Runtime.getRuntime().exec(cmd, new String[0], new File("/"));
it works, changing the frequency as expected.

Do you think it can be enough to work with Hal standalone?

thanks, Davide

Please Log in or Create an account to join the conversation.

More
27 Aug 2019 23:45 #143377 by andypugh
It looks like it could work, bit it seems rather "hacky".

I think you should learn Python, and output the required motor parameters on HAL pins.

Please Log in or Create an account to join the conversation.

More
28 Aug 2019 07:42 #143410 by dab77
Replied by dab77 on topic Hal Standalone and a Java gui
Thanks Andy, i'm going on in studying python, because i would like to master that, but the most of the time it makes me angry.
in the meanwhile i know i can have something working..
anyway thanks for the suggestion.

davide

Please Log in or Create an account to join the conversation.

More
28 Aug 2019 09:14 #143424 by rodw
Replied by rodw on topic Hal Standalone and a Java gui

Thanks Andy, i'm going on in studying python, because i would like to master that, but the most of the time it makes me angry.
in the meanwhile i know i can have something working..
anyway thanks for the suggestion.

davide


Find the Google tutorial for Python and you will be an expert in 2-3 days.
developers.google.com/edu/python/

The videos are awesome!
The following user(s) said Thank You: dab77

Please Log in or Create an account to join the conversation.

More
28 Aug 2019 10:45 #143437 by dab77
Replied by dab77 on topic Hal Standalone and a Java gui
Thank you, I missed these tutorials.

going to read them.
The following user(s) said Thank You: rodw

Please Log in or Create an account to join the conversation.

More
28 Aug 2019 18:04 #143460 by Reinhard

I would not use Java for ...... well anything ever ...
I do not like the overhead on the recourses.

Those who don't know have an oppinion and they fight for it :(
Oh man ...
Seen that habbit uncounted times ...

I remember one project, where the customer wanted to replace a central system service, which became slow with the time being. Original service was coded in smalltalk ...
We built two replacement prototypes - one coded in C and one in java - and the result was, that the java service had the same client processing times as the C service (within microsecond resolution). Only drawback of the jave program was the initial startup time - but who cares on a system service running 24/7?
We had to code some tweaks to get the garbade collection work as fast as the client connections, but when that was done, the resources consumed stayed stable.
We let the services run several days and nights - with the result, that java was more stable than the C service. Reproducable.
With our prototypes we could beat every lie, like java is too slow, jave needs to many resources, java is not stable ...
At the end, the IT-commissary stated: we're not able to support java and its release cycles ... :(

I very like the idea of java working together with hal services. Java offers the most freedom on UI and has a very clean event system.

But using Runtime.exec is the worst possibility for IPC.
Don't know enuf about NML, but I guess its based on shared memory. To use that, java needs a little help of C - just like Python does too. JNI is the right javatask for that.

But if you're going to code java for linuxcnc - keep in mind, that there is really a lot of UI-stuff already worked out with python. Its pretty big job to code all that from scratch. Don't know, if you want to spend so much time on that item.
.

i'm going on in studying python, ... but the most of the time it makes me angry.

Same happens to me ;)
Every time I look at python sources

Cheers Reinhard
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

Time to create page: 0.087 seconds
Powered by Kunena Forum