Skip to content

Commit 566af66

Browse files
committed
Merge branch 'jonaskn-zmqrr'
2 parents 628c355 + e17c2f4 commit 566af66

21 files changed

Lines changed: 809 additions & 12 deletions
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
% compile 0MQ matlab request->response (zeroMQrr)
2+
3+
% 1. find the correct locations of zermoMQ librearies and heaers
4+
if strfind(computer,'PCWIN')
5+
Codefolder=mfilename('fullpath');
6+
Codefolder=Codefolder(1:(end-length(mfilename()-1)-length('Matlab')-1-1));
7+
libraryName = 'libzmq-v120-mt-4_0_4';
8+
if strcmp(computer,'PCWIN64')
9+
libFolder = [Codefolder, '\windows-libs\ZeroMQ\lib_x64'];
10+
else
11+
libFolder = [Codefolder, '\windows-libs\ZeroMQ\lib_x86'];
12+
end
13+
headerFolder = [Codefolder, '\windows-libs\ZeroMQ\include'];
14+
elseif strcmp(computer,'GLNX86') || strcmp(computer,'GLNXA64')
15+
libraryName = 'zmq';
16+
if ~isempty(dir(['/usr/local/lib/lib' libraryName '*']))
17+
libFolder = '/usr/local/lib';
18+
headerFolder = '??';
19+
else
20+
error('compile:matlab_zeroMQrr','please add the paths to your zeroMQ libraries and headers');
21+
end
22+
elseif strcmp(computer,'MACI64')
23+
libraryName = 'zmq';
24+
%iterate trough some options
25+
if ~isempty(dir(['/usr/local/Cellar/zeromq/4.1.4/lib/lib' libraryName '*'])) %should prob. iterate to find the newest version
26+
libFolder = '/usr/local/Cellar/zeromq/4.1.4/lib';
27+
headerFolder = '/usr/local/Cellar/zeromq/4.1.4/include';
28+
% elseif ~isempty(dir(['/usr/local/lib/lib' libraryName '*']))
29+
% libFolder = '/usr/local/lib';
30+
% headerFolder = '??';
31+
else
32+
error('compile:matlab_zeroMQrr','please add the paths to your zeroMQ libraries and headers');
33+
end
34+
35+
end
36+
37+
cppFile = 'zeroMQrr/zeroMQrr.cpp';
38+
% 2. compile
39+
eval(['mex ' cppFile ' -I',headerFolder,' -L',libFolder,' -l',libraryName] )
File renamed without changes.

Resources/Matlab/libzmq-v110-mt-3_2_2.dll

100755100644
File mode changed.
530 KB
Binary file not shown.

Resources/Matlab/zeroMQrr.m

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
% zeroMQrr provides a simple wrapper around the zeromq library with a
2+
% request->response scenario in mind
3+
%
4+
% Usage:
5+
%
6+
% zeroMQrr('Command',...);
7+
%
8+
% zeroMQrr('Send',url, request, [blocking=0]);
9+
% When blocking is true, zeroMQrr waits for and returns the response
10+
% [response, dialogue]=zeroMQrr('Send',url, request, 1);
11+
% When blocking is 0 (default) zeroMQrr adds the request to a queue and returns the time the request was added to that queue. See 'GetResponses'
12+
% [timeRequestAdded]=zeroMQrr('Send',url, request, 0);
13+
%
14+
% dialogue = zeroMQrr('GetResponses' [, url] [,wairForEmptyQueue=1])
15+
% Retirieves responses collected for requests send in non blocking mode. If an url is provided
16+
% only responses for that url will be returend. If wairForEmptyQueue>0, the function waits for
17+
% the last queued request to get a response.
18+
% Dialogue is a struct with the fields: request, response, timeRequestAdded, timeRequestSent, timeResponeRecieved
19+
% At the moment this cannot get filtered by the url of the request yet.
20+
%
21+
% zeroMQrr('CloseAll')
22+
% closes all open sockets and the queue thread if open.
23+
%
24+
%
25+
% zeroMQrr('CloseThread')
26+
% closes the queue thread if open
27+
%
28+
% url = zeroMQrr('StartConnectThread', url)
29+
% This function is not neccessary and for backward compatability only. It simply returns the url of the input as previous versions required a handle instead of the url if the 'Send' command
30+
%
31+
% currently only tested on OSX. To compile you need the zeromq library
32+
% installed (e.g. using brew on OSX) and the libraries set correctly in
33+
% compile_matlab_wrapper
34+
%
35+
% Copyright (c) 2008 Shay Ohayon, California Institute of Technology.
36+
% This file is a part of a free software. you can redistribute it and/or modify
37+
% it under the terms of the GNU General Public License as published by
38+
% the Free Software Foundation (see GPL.txt)
39+
%
40+
% Changes to allow receiving responses by Jonas Knoell, 2016
31.5 KB
Binary file not shown.

Resources/Matlab/zeroMQrr.mexw64

31 KB
Binary file not shown.

0 commit comments

Comments
 (0)