sending messages to an already-running instance of octave

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

sending messages to an already-running instance of octave

Dan Hitt-2
Suppose that i start octave from the command line or otherwise, and am
interacting with it.

And suppose that i then run some other program.

Is there any way that the other program can send commands and data to
my running octave, through dbus or any other ipc method?

The only requirements are that the user should not have to do anything
to octave to make it respond (e.g., the user should not have to tell
octave to open a particular file), and the other program and octave
should be unrelated processes (although owned by the same user).

(The kinds of commands would be things that a user could presumably
directly do, like make plots, or inquire about the internal state of
octave, and the data would be numerical.)

TIA for any info or suggestions.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sending messages to an already-running instance of octave

Olaf Till-2
On Sat, Jun 17, 2017 at 10:21:46PM -0700, Dan Hitt wrote:

> Suppose that i start octave from the command line or otherwise, and am
> interacting with it.
>
> And suppose that i then run some other program.
>
> Is there any way that the other program can send commands and data to
> my running octave, through dbus or any other ipc method?
>
> The only requirements are that the user should not have to do anything
> to octave to make it respond (e.g., the user should not have to tell
> octave to open a particular file), and the other program and octave
> should be unrelated processes (although owned by the same user).
>
> (The kinds of commands would be things that a user could presumably
> directly do, like make plots, or inquire about the internal state of
> octave, and the data would be numerical.)
>
> TIA for any info or suggestions.
I think this would require a thread for remote execution in Octave, or
a mode of Octave in which every command is executed by an Octave
server. This is both not implemented.

Maybe there are ideas for alternative solutions if you detail your
needs.

Olaf

--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sending messages to an already-running instance of octave

Dan Hitt-2
Thanks Olaf!

My situation is that i'm writing software that produces data i would
like to plot and probably interact with, and i want it to be as smooth
and easy as possible.

It would be possible for me to create plots in gtk, with all the
advantages of interactivity and control and so on that this implies,
but also all the disadvantages of a great deal more code, most of it
devoted to supporting other code.

What i would like to do instead is marshal the data and write it (to a
file or a socket or whatever) and send a command off that says "plot".
(Possibly down the road, it would be nice to get a descriptor back and
be able to produce more data, and send a command that says "add to
plot".)

So i'd like to separate the data preparation from the graphing, what
people sometimes call separating the "business logic" from the
presentation.

(This of course is not new with me nor with this century, so it may
just be my total ineptness at googling that i can't jump right to an
api.)

I'm using debian 9 ("stretch") and would like to do all of this with
free software.  Software in debian packages would be best, but i don't
mind compiling things.

And i wouldn't have to use octave, but it would have to be something
along those lines, something that plots as well as letting the user
interact with the data.

And the communication really has to be at arm's length, the choice of
my programming language is dictated by other concerns.

TIA for any more hints!

dan

On Sun, Jun 18, 2017 at 8:39 AM, Olaf Till <[hidden email]> wrote:

> On Sat, Jun 17, 2017 at 10:21:46PM -0700, Dan Hitt wrote:
>> Suppose that i start octave from the command line or otherwise, and am
>> interacting with it.
>>
>> And suppose that i then run some other program.
>>
>> Is there any way that the other program can send commands and data to
>> my running octave, through dbus or any other ipc method?
>>
>> The only requirements are that the user should not have to do anything
>> to octave to make it respond (e.g., the user should not have to tell
>> octave to open a particular file), and the other program and octave
>> should be unrelated processes (although owned by the same user).
>>
>> (The kinds of commands would be things that a user could presumably
>> directly do, like make plots, or inquire about the internal state of
>> octave, and the data would be numerical.)
>>
>> TIA for any info or suggestions.
>
> I think this would require a thread for remote execution in Octave, or
> a mode of Octave in which every command is executed by an Octave
> server. This is both not implemented.
>
> Maybe there are ideas for alternative solutions if you detail your
> needs.
>
> Olaf
>
> --
> public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sending messages to an already-running instance of octave

Doug Stewart-4


On Sun, Jun 18, 2017 at 12:58 PM, Dan Hitt <[hidden email]> wrote:
Thanks Olaf!

My situation is that i'm writing software that produces data i would
like to plot and probably interact with, and i want it to be as smooth
and easy as possible.

It would be possible for me to create plots in gtk, with all the
advantages of interactivity and control and so on that this implies,
but also all the disadvantages of a great deal more code, most of it
devoted to supporting other code.

What i would like to do instead is marshal the data and write it (to a
file or a socket or whatever) and send a command off that says "plot".
(Possibly down the road, it would be nice to get a descriptor back and
be able to produce more data, and send a command that says "add to
plot".)

So i'd like to separate the data preparation from the graphing, what
people sometimes call separating the "business logic" from the
presentation.

(This of course is not new with me nor with this century, so it may
just be my total ineptness at googling that i can't jump right to an
api.)

I'm using debian 9 ("stretch") and would like to do all of this with
free software.  Software in debian packages would be best, but i don't
mind compiling things.

And i wouldn't have to use octave, but it would have to be something
along those lines, something that plots as well as letting the user
interact with the data.

And the communication really has to be at arm's length, the choice of
my programming language is dictated by other concerns.

TIA for any more hints!

dan

On Sun, Jun 18, 2017 at 8:39 AM, Olaf Till <[hidden email]> wrote:
> On Sat, Jun 17, 2017 at 10:21:46PM -0700, Dan Hitt wrote:
>> Suppose that i start octave from the command line or otherwise, and am
>> interacting with it.
>>
>> And suppose that i then run some other program.
>>
>> Is there any way that the other program can send commands and data to
>> my running octave, through dbus or any other ipc method?
>>
>> The only requirements are that the user should not have to do anything
>> to octave to make it respond (e.g., the user should not have to tell
>> octave to open a particular file), and the other program and octave
>> should be unrelated processes (although owned by the same user).
>>
>> (The kinds of commands would be things that a user could presumably
>> directly do, like make plots, or inquire about the internal state of
>> octave, and the data would be numerical.)
>>
>> TIA for any info or suggestions.
>
> I think this would require a thread for remote execution in Octave, or
> a mode of Octave in which every command is executed by an Octave
> server. This is both not implemented.
>
> Maybe there are ideas for alternative solutions if you detail your
> needs.
>
> Olaf
>
> --
> public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave




Take a look at this:

https://www.gnu.org/software/octave/doc/interpreter/Executable-Octave-Programs.html


this part

Note that when Octave is started from an executable script, the built-in function argv returns a cell array containing the command line arguments passed to the executable Octave script, not the arguments passed to the Octave interpreter on the ‘#!’ line of the script. For example, the following program will reproduce the command line that was used to execute the script, not ‘-qf’.

#! /bin/octave -qf
printf ("%s", program_name ());
arg_list = argv ();
for i = 1:nargin
  printf (" %s", arg_list{i});
endfor
printf ("\n");



you should write your data to a file, then run a script like above that does what you want..

Is this what you wanted?


--
DASCertificate for 206392


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sending messages to an already-running instance of octave

Dan Hitt-2
Thanks Doug, i could and i might, at least as a first step.  (So that my code would write the octave script then exec it.)

The disadvantage is that it would seem to start a new octave process for each run.

Thus if i generated 10 plots, i'd have 10 instances of octave.

Ideally, it would contact an already running octave, and tell it to plot, and also be able to check back in with octave to see if the plot is still being displayed, and if so, maybe add to it.  (Or, if the user modified the data through octave, it might ask to peek at the workspace, recover the changed data, process it, and ask it to re-plot.)

(I don't think i want to run octave as a slave process though, because that would presumably inhibit it from being controlled in other ways?)

Thanks again!

dan


On Sun, Jun 18, 2017 at 10:09 AM, Doug Stewart <[hidden email]> wrote:


On Sun, Jun 18, 2017 at 12:58 PM, Dan Hitt <[hidden email]> wrote:
Thanks Olaf!

My situation is that i'm writing software that produces data i would
like to plot and probably interact with, and i want it to be as smooth
and easy as possible.

It would be possible for me to create plots in gtk, with all the
advantages of interactivity and control and so on that this implies,
but also all the disadvantages of a great deal more code, most of it
devoted to supporting other code.

What i would like to do instead is marshal the data and write it (to a
file or a socket or whatever) and send a command off that says "plot".
(Possibly down the road, it would be nice to get a descriptor back and
be able to produce more data, and send a command that says "add to
plot".)

So i'd like to separate the data preparation from the graphing, what
people sometimes call separating the "business logic" from the
presentation.

(This of course is not new with me nor with this century, so it may
just be my total ineptness at googling that i can't jump right to an
api.)

I'm using debian 9 ("stretch") and would like to do all of this with
free software.  Software in debian packages would be best, but i don't
mind compiling things.

And i wouldn't have to use octave, but it would have to be something
along those lines, something that plots as well as letting the user
interact with the data.

And the communication really has to be at arm's length, the choice of
my programming language is dictated by other concerns.

TIA for any more hints!

dan

On Sun, Jun 18, 2017 at 8:39 AM, Olaf Till <[hidden email]> wrote:
> On Sat, Jun 17, 2017 at 10:21:46PM -0700, Dan Hitt wrote:
>> Suppose that i start octave from the command line or otherwise, and am
>> interacting with it.
>>
>> And suppose that i then run some other program.
>>
>> Is there any way that the other program can send commands and data to
>> my running octave, through dbus or any other ipc method?
>>
>> The only requirements are that the user should not have to do anything
>> to octave to make it respond (e.g., the user should not have to tell
>> octave to open a particular file), and the other program and octave
>> should be unrelated processes (although owned by the same user).
>>
>> (The kinds of commands would be things that a user could presumably
>> directly do, like make plots, or inquire about the internal state of
>> octave, and the data would be numerical.)
>>
>> TIA for any info or suggestions.
>
> I think this would require a thread for remote execution in Octave, or
> a mode of Octave in which every command is executed by an Octave
> server. This is both not implemented.
>
> Maybe there are ideas for alternative solutions if you detail your
> needs.
>
> Olaf
>
> --
> public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave




Take a look at this:

https://www.gnu.org/software/octave/doc/interpreter/Executable-Octave-Programs.html


this part

Note that when Octave is started from an executable script, the built-in function argv returns a cell array containing the command line arguments passed to the executable Octave script, not the arguments passed to the Octave interpreter on the ‘#!’ line of the script. For example, the following program will reproduce the command line that was used to execute the script, not ‘-qf’.

#! /bin/octave -qf
printf ("%s", program_name ());
arg_list = argv ();
for i = 1:nargin
  printf (" %s", arg_list{i});
endfor
printf ("\n");



you should write your data to a file, then run a script like above that does what you want..

Is this what you wanted?


--
DASCertificate for 206392



_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sending messages to an already-running instance of octave

Pantxo
Dan Hitt-2 wrote
Thanks Doug, i could and i might, at least as a first step.  (So that my
code would write the octave script then exec it.)

The disadvantage is that it would seem to start a new octave process for
each run.

Thus if i generated 10 plots, i'd have 10 instances of octave.

Ideally, it would contact an already running octave, and tell it to plot,
and also be able to check back in with octave to see if the plot is still
being displayed, and if so, maybe add to it.  (Or, if the user modified the
data through octave, it might ask to peek at the workspace, recover the
changed data, process it, and ask it to re-plot.)

(I don't think i want to run octave as a slave process though, because that
would presumably inhibit it from being controlled in other ways?)

Thanks again!

dan


On Sun, Jun 18, 2017 at 10:09 AM, Doug Stewart <[hidden email]>
wrote:

>
>
> On Sun, Jun 18, 2017 at 12:58 PM, Dan Hitt <[hidden email]> wrote:
>
>> Thanks Olaf!
>>
>> My situation is that i'm writing software that produces data i would
>> like to plot and probably interact with, and i want it to be as smooth
>> and easy as possible.
>>
>> It would be possible for me to create plots in gtk, with all the
>> advantages of interactivity and control and so on that this implies,
>> but also all the disadvantages of a great deal more code, most of it
>> devoted to supporting other code.
>>
>> What i would like to do instead is marshal the data and write it (to a
>> file or a socket or whatever) and send a command off that says "plot".
>> (Possibly down the road, it would be nice to get a descriptor back and
>> be able to produce more data, and send a command that says "add to
>> plot".)
>>
>> So i'd like to separate the data preparation from the graphing, what
>> people sometimes call separating the "business logic" from the
>> presentation.
>>
>> (This of course is not new with me nor with this century, so it may
>> just be my total ineptness at googling that i can't jump right to an
>> api.)
>>
>> I'm using debian 9 ("stretch") and would like to do all of this with
>> free software.  Software in debian packages would be best, but i don't
>> mind compiling things.
>>
>> And i wouldn't have to use octave, but it would have to be something
>> along those lines, something that plots as well as letting the user
>> interact with the data.
>>
>> And the communication really has to be at arm's length, the choice of
>> my programming language is dictated by other concerns.
>>
>> TIA for any more hints!
>>
>> dan
>>
>> On Sun, Jun 18, 2017 at 8:39 AM, Olaf Till <[hidden email]> wrote:
>> > On Sat, Jun 17, 2017 at 10:21:46PM -0700, Dan Hitt wrote:
>> >> Suppose that i start octave from the command line or otherwise, and am
>> >> interacting with it.
>> >>
>> >> And suppose that i then run some other program.
>> >>
>> >> Is there any way that the other program can send commands and data to
>> >> my running octave, through dbus or any other ipc method?
>> >>
>> >> The only requirements are that the user should not have to do anything
>> >> to octave to make it respond (e.g., the user should not have to tell
>> >> octave to open a particular file), and the other program and octave
>> >> should be unrelated processes (although owned by the same user).
>> >>
>> >> (The kinds of commands would be things that a user could presumably
>> >> directly do, like make plots, or inquire about the internal state of
>> >> octave, and the data would be numerical.)
>> >>
>> >> TIA for any info or suggestions.
>> >
>> > I think this would require a thread for remote execution in Octave, or
>> > a mode of Octave in which every command is executed by an Octave
>> > server. This is both not implemented.
>> >
>> > Maybe there are ideas for alternative solutions if you detail your
>> > needs.
>> >
>> > Olaf
>> >
>> > --
>> > public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net
>>
>> _______________________________________________
>> Help-octave mailing list
>> [hidden email]
>> https://lists.gnu.org/mailman/listinfo/help-octave
>>
>
>
>
>
> Take a look at this:
>
> https://www.gnu.org/software/octave/doc/interpreter/
> Executable-Octave-Programs.html
>
>
> this part
>
> Note that when Octave is started from an executable script, the built-in
> function argv returns a cell array containing the command line arguments
> passed to the executable Octave script, not the arguments passed to the
> Octave interpreter on the ‘#!’ line of the script. For example, the
> following program will reproduce the command line that was used to execute
> the script, not ‘-qf’.
>
> #! /bin/octave -qf
> printf ("%s", program_name ());
> arg_list = argv ();
> for i = 1:nargin
>   printf (" %s", arg_list{i});
> endfor
> printf ("\n");
>
>
>
>
> you should write your data to a file, then run a script like above that
> does what you want..
>
> Is this what you wanted?
>
>
> --
> DAS[image: Certificate for 206392]
>
> <https://linuxcounter.net/user/206392.html>
>

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Hi,

Please write your answers at the bottom of quoted messages (bottom posting), it is the custom on this list.

Octave can be made to execute a function periodically: see "add_input_event_hook". With this function you can probably fake a server client communication from a single instance of Octave.

Pantxo
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sending messages to an already-running instance of octave

Dan Hitt-2
On Sun, Jun 18, 2017 at 10:26 AM, Pantxo <[hidden email]> wrote:

> Hi,
>
> Please write your answers at the bottom of quoted messages (bottom posting),
> it is the custom on this list.
>
> Octave can be made to execute a function periodically: see
> "add_input_event_hook". With this function you can probably fake a server
> client communication from a single instance of Octave.
>
> Pantxo
>

Thanks Pantxo.

I'll try to bottom post any future communication.

And will investigate add_input_event_hook.

So i guess the idea would be to write first write function which
checks a well-known location in the file system, reads and deletes
what's there, and responds accordingly.  Then i would schedule that
function with add_input_event_hook.  Maybe could even put the code to
do all this in my init file, and have a lock in it somewhere so that
only the first octave i run will actually do the checking.

We'll see!

Thanks again everybody for all your help!!! :)

dan

(Pantxo -- sorry for sending this twice to you!! Very poor gmail
skills on my part.)

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sending messages to an already-running instance of octave

Andreas Weber-6
In reply to this post by Pantxo
Am 18.06.2017 um 19:26 schrieb Pantxo:
> Octave can be made to execute a function periodically: see
> "add_input_event_hook". With this function you can probably fake a server
> client communication from a single instance of Octave.

The add_input_event_hook is executed if readline waits for input (I'm
sure you (Pantxo) already know that but I want to add this for Dan)

The other software product has a "Timer Object"
(https://de.mathworks.com/help/matlab/matlab_prog/use-a-matlab-timer-object.html)

I regularly wish Octave also would have a timer hook when using the
instrument-control package or sockets in Octave but haven't had time yet
to start implementing it.

-- Andy

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sending messages to an already-running instance of octave

Dan Hitt-2
> The add_input_event_hook is executed if readline waits for input (I'm
> sure you (Pantxo) already know that but I want to add this for Dan)
>
> The other software product has a "Timer Object"
> (https://de.mathworks.com/help/matlab/matlab_prog/use-a-matlab-timer-object.html)
>
> I regularly wish Octave also would have a timer hook when using the
> instrument-control package or sockets in Octave but haven't had time yet
> to start implementing it.
>
> -- Andy

Ah thanks Andy, that's even better, if i understand you right, as that
would be the right time to call, when it is blocked otherwise.

will investigate.

i certainly appreciate all this info.

dan

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sending messages to an already-running instance of octave

Pantxo
In reply to this post by Dan Hitt-2


2017-06-18 20:27 GMT+02:00 Dan Hitt <[hidden email]>:
On Sun, Jun 18, 2017 at 10:26 AM, Pantxo <[hidden email]> wrote:

> Hi,
>
> Please write your answers at the bottom of quoted messages (bottom posting),
> it is the custom on this list.
>
> Octave can be made to execute a function periodically: see
> "add_input_event_hook". With this function you can probably fake a server
> client communication from a single instance of Octave.
>
> Pantxo
>

Thanks Pantxo.

I'll try to bottom post any future communication.

And will investigate add_input_event_hook.

So i guess the idea would be to write first write function which
checks a well-known location in the file system, reads and deletes
what's there, and responds accordingly.  Then i would schedule that
function with add_input_event_hook.  Maybe could even put the code to
do all this in my init file, and have a lock in it somewhere so that
only the first octave i run will actually do the checking.


Yes, that is basically what I would do. For a more sophisticated (and network based) server/client logic I would look at "socket" or "zeromq" packages in octave-forge:

https://octave.sourceforge.io/sockets/index.html
https://octave.sourceforge.io/zeromq/index.html

Pantxo

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: sending messages to an already-running instance of octave

Mike Miller-4
In reply to this post by Dan Hitt-2
On Sat, Jun 17, 2017 at 22:21:46 -0700, Dan Hitt wrote:

> Suppose that i start octave from the command line or otherwise, and am
> interacting with it.
>
> And suppose that i then run some other program.
>
> Is there any way that the other program can send commands and data to
> my running octave, through dbus or any other ipc method?
>
> The only requirements are that the user should not have to do anything
> to octave to make it respond (e.g., the user should not have to tell
> octave to open a particular file), and the other program and octave
> should be unrelated processes (although owned by the same user).
>
> (The kinds of commands would be things that a user could presumably
> directly do, like make plots, or inquire about the internal state of
> octave, and the data would be numerical.)
>
> TIA for any info or suggestions.

Others have been very helpful. I just wanted to mention that I have been
interested in working on a dbus interface for Octave, but nothing exists
yet that I know of. Let me know if you are interested in helping,
brainstorming, designing, funding, or otherwise.

Octave's Python interface is in development but is fairly functional at
the moment. Using it you might be able to launch some kind of dbus event
loop from within Octave. However there are no facilities to call back
into Octave from Python yet.

--
mike

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Loading...