From sth at info-igor.org Wed Sep 5 08:12:39 2018
From: sth at info-igor.org (Scott Hannahs)
Date: Wed, 5 Sep 2018 11:12:39 -0400


Subject: Writing Igor experiment from Python?
In-Reply-To: <373879b1-4da5-97be-74da-48ad0a63f640@virtuell-zuhause.de>
References: <D7B2C354.72DF%francis.dalaudier@wanadoo.fr>
<b8013b5d-449f-7099-a285-2cf2568f60c2@freenet.de>
<21E1D892-35BD-427E-8D0C-34D6788D7FF5@anl.gov>
<B0943AF2-A92A-4472-87C4-0F58E6B0577A@info-igor.org>
<14fe8e0b-936b-06a5-0011-0ab8fc026f5c@virtuell-zuhause.de>
<F6901180-183D-4723-A679-AF3851F8E6C8@magnet.fsu.edu>
<373879b1-4da5-97be-74da-48ad0a63f640@virtuell-zuhause.de>
Message-ID: <84E1D1FB-5856-46CF-A710-FE9719AEFF74@info-igor.org>

Thomas,

This looks great. Now I have to think about the other third party software and zeromq which may be easy (or not). And then start designing my protocol (and decide who is server and who is client!). This does simplify things a lot.

-Scott


> On Sep 3, 2018, at 7:01 PM, Thomas Braun <thomas.braun at virtuell-zuhause.de> wrote:
>
> Am 03.09.2018 um 23:17 schrieb Scott Hannahs:
>> I was not going to dive into the C++ but use the already existing Sockit XOP.
>> https://www.wavemetrics.com/project/SOCKIT
>>
>> But ZeroMQ could also work as a messaging platform. I was also looking for data to go the other way and to push collected data into Igor as a binary transfer. That was why I was thinking of a two channel system of one for command and one for data streams.
>
> You can also just skip the bells & whistles of the ZeroMQ XOP and just
> push data around.
>
> Using two Igor Pro instances
>
> Side A (Dealer):
>
> The string msg is pushed, we wait for a reply and then finish.
>
> Function ClientLoop()
>
> zeromq_stop()
> // zeromq_set(ZeroMQ_SET_FLAGS_DEBUG)
> zeromq_client_connect("tcp://127.0.0.1:5555")
>
> string msg = "someData"
>
> for(;;)
> zeromq_client_send(msg)
> string reply = zeromq_client_recv()
>
> if(numtype(strlen(reply)) != 0 || strlen(reply) == 0)
> break
> endif
>
> printf "Received reply: \"%s\"\r", reply
> break
> endfor
> End
>
> Side B (Router):
>
> We wait for incoming messages and acknowledge them.
>
> Function ServerLoop()
>
> string reply, identity
>
> zeromq_stop()
> // zeromq_set(ZeroMQ_SET_FLAGS_DEBUG)
> zeromq_server_bind("tcp://127.0.0.1:5555")
>
> for(;;)
> string msg = zeromq_server_recv(identity)
>
> if(numtype(strlen(msg)) != 0 || strlen(msg) == 0)
> break
> endif
>
> printf "got data: %s\r", msg
> printf "identity: %s\r", identity
>
> reply = "Got it!"
>
> printf "Sending reply: %s\r", reply
> zeromq_server_send(identity, reply)
> endfor
> End
>
> You are limited to pushing at most 2GB at a time as this (IIRC) is the
> maximum string length in IP. By default all recv functions wait
> indefinitly for a message, this can be changed with
> zeromq_set(ZeroMQ_SET_FLAGS_NOBUSYWAITRECV). The implemented ZeroMQ
> pattern is explained here https://rfc.zeromq.org/spec:28/REQREP/.
>
> On the github page are XOPs for Windows and Mac available.
>
> Hope that helps,
> Thomas
>
>>> On Sep 3, 2018, at 2:47 PM, Thomas Braun <thomas.braun at virtuell-zuhause.de> wrote:
>>>
>>> Am 03.09.2018 um 18:34 schrieb Scott Hannahs:
>>>> The other method that I haven?t coded up, but keep thinking about is to use the TCP/IP xop to run in a background task. It listens for command strings and executes them. To transfer data, that special command would open an additional TCP channel and just dump data of a given type and length into a wave.
>>>>
>>>> This then means that the Igor plot/analysis server can exist on any machine and not just the local system.
>>>
>>>
>>> I don't want to take away the fun of doing some C++ coding and having
>>> fun with the OS TCP/IP stack, but I might have something usable already.
>>>
>>> We are using an Igor Pro application and a python application together.
>>> And the python application can execute Igor Pro user functions via [1]
>>> and return their results. It uses ZeroMQ as messaging layer and can be
>>> used either locally or over the network.
>>>
>>> The following parameter/return types for Igor Pro functions are
>>> currently supported:
>>>
>>> ###
>>> Supported parameter types:
>>>
>>> string (including pass-by-reference)
>>> variable (including pass-by-reference)
>>> datafolder reference
>>>
>>> Supported return types:
>>>
>>> string
>>> variable
>>> wave (without wave reference waves or datafolder reference waves)
>>> datafolder reference
>>> ###
>>>
>>> This is used like everyday and a lot and works pretty well.
>>>
>>> Thomas
>>>
>>> [1]: https://github.com/AllenInstitute/ZeroMQ-XOP/
>>> _______________________________________________
>>> Info-igor mailing list
>>> Info-igor at lists.info-igor.org
>>> http://lists.info-igor.org/listinfo.cgi/info-igor-info-igor.org
>>
>> _______________________________________________
>> Info-igor mailing list
>> Info-igor at lists.info-igor.org
>> http://lists.info-igor.org/listinfo.cgi/info-igor-info-igor.org
>>
>
> _______________________________________________
> Info-igor mailing list
> Info-igor at lists.info-igor.org
> http://lists.info-igor.org/listinfo.cgi/info-igor-info-igor.org