Hal Standalone and a Java gui

More
28 Aug 2019 18:27 #143466 by tommylight
@Reinhard
Thank you, you are right, i do not know it although i can mess with it easily and i am fully aware it can do some things that would need many hoops to be jumped when done with anything else. It just uses to much for litle things, like "onmouseover" and similar, and to much of a security risc. But these days everything has become a security risc.
Python does a lot of things easily, but the version changes and the new additions are causing people agravation.
Same goes for all other programing languages/scripting languages, all have good things and not so good things.
Regards,
Tom.

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

More
28 Aug 2019 20:43 - 28 Aug 2019 20:47 #143477 by dab77
Replied by dab77 on topic Hal Standalone and a Java gui
I've done some software in java, and i've created my own gui library with all the standard widgets and some special one (once you start..), and i.e. one thing I needed was the ability to change the opacity of the widgets, because I had a video stream as a background and the buttons and texts over. Other than this It was very simple to draw over the video stream in 3D, mixing on the same window 3D and 2D widgets..
It turned out a very useful and modern look software, and it took me little time to program.
Of course there are a lot of guis out there which are ready to be used, and wx and qt are ready with Hal widgets, but I cannot do those exotic things..
I'm sure many things i wrote are not optimized and can be slow, but when I try to replicate some of the things i need in python i get stuck with stupid things..
for example: which is the right library to draw a rectangle and then how to generate an event on mouse click inside that? it should be trivial, but it's hard!

In the meantime, while studying python, I'm digging into the kivy gui library, which seems fast, easy and modern too.
Last edit: 28 Aug 2019 20:47 by dab77.

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

More
28 Aug 2019 20:51 #143478 by andypugh
I am not pushing Python on you because I object to Java, or because I am a fan of Python. It is just that LinuxCNC already has a lot of interfaces for Python. You can even re-write G-codes in Python. I don't think it is as easy to do this with Java.

If you create a Python program that includes "import hal" then you can create HAL pins in shared memory and link those to the motor positions. Then setting a new position is just a case of giving the variable a new value, rather than the rather clunky approach of creating "halcmd ..... " strings and passing them to the shell.

linuxcnc.org/docs/2.8/html/hal/halmodule.html

Has some simple examples.

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

More
28 Aug 2019 20:53 #143479 by andypugh
Note that linuxcnc.org/docs/2.8/html/config/python-interface.html
Won't work in a standalone HAL session, as far as I know.

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

More
28 Aug 2019 20:55 #143482 by dab77
Replied by dab77 on topic Hal Standalone and a Java gui


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.

one thing i've looked at is JNI , but then i couldn't find enough info on how to 'speak' to hal, or use NML. ..so i left that road..
if you know how, i'm still interested in this road.

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

More
29 Aug 2019 17:22 #143581 by Reinhard
Take a look at "src/emc/usr_intf/axis/extensions/emcmodule.cc" and there at emcSendCommand and emcWaitCommandComplete ...
Another directory, you should dig into is src/libnml ...

I guess, these both emc-functions is all you need to code in JNI - all other stuff could be coded in pure Java :)

Cheers Reinhard

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

More
30 Aug 2019 10:00 #143644 by dab77
Replied by dab77 on topic Hal Standalone and a Java gui
thanks for addressing me.
i'll look into that in the next days.

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

More
05 Sep 2019 03:10 #144187 by Reinhard
Hi,

i have very little spare time actually, so it took a while.
But I succeeded in creating a java prototype that is able to print position - pretty easy :)

I started an axis linuxcnc and started the demo. Then I paused the execution and started the java app, which just printed the position. Then I compared the shown values. Looks good.
So I guess, I can implement the NML-layer for java apps :)

Cheers Reinhard

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

More
05 Sep 2019 06:38 #144215 by pl7i92
this is a nice project lots of people will love a boost to edingCNC users that are android Java CNC aplicants

any Images so far
Attachments:

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

More
05 Sep 2019 06:49 #144217 by dab77
Replied by dab77 on topic Hal Standalone and a Java gui
That sound encouraging!

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

Time to create page: 0.104 seconds
Powered by Kunena Forum