1 | %------------------------------------------------------------------------- |
---|
2 | % WARPLab Framework |
---|
3 | % |
---|
4 | % Copyright 2013, Mango Communications. All rights reserved. |
---|
5 | % Distributed under the WARP license (http://warpproject.org/license) |
---|
6 | % |
---|
7 | % Chris Hunter (chunter [at] mangocomm.com) |
---|
8 | % Patrick Murphy (murphpo [at] mangocomm.com) |
---|
9 | % Erik Welsh (welsh [at] mangocomm.com) |
---|
10 | %------------------------------------------------------------------------- |
---|
11 | |
---|
12 | classdef wl_trigger_eth_udp_broadcast < wl_trigger |
---|
13 | |
---|
14 | properties (SetAccess = protected) |
---|
15 | description = 'UDP over Ethernet Broadcast Trigger'; |
---|
16 | ID; |
---|
17 | transport; |
---|
18 | end |
---|
19 | |
---|
20 | methods |
---|
21 | function obj = wl_trigger_eth_udp_broadcast(varargin) |
---|
22 | if(nargin == 0) |
---|
23 | obj(1) = wl_trigger_eth_udp_broadcast(1); |
---|
24 | else |
---|
25 | if(ischar(varargin{1})) |
---|
26 | if(strcmpi(varargin{1},'no_id')) |
---|
27 | return; |
---|
28 | else |
---|
29 | obj(1) = wl_trigger_eth_udp_broadcast(1,varargin{:}); |
---|
30 | end |
---|
31 | else |
---|
32 | N = varargin{1}; |
---|
33 | IDvec = wl_trigger_IDs.getID(varargin{:}); |
---|
34 | |
---|
35 | configFile = which('wl_config.ini'); |
---|
36 | |
---|
37 | if(isempty(configFile)) |
---|
38 | error('cannot find wl_config.ini. please run wl_setup.m'); |
---|
39 | end |
---|
40 | |
---|
41 | readKeys = {'network','','transport',''}; |
---|
42 | transport = inifile(configFile,'read',readKeys); |
---|
43 | transport = transport{1}; |
---|
44 | |
---|
45 | for index = 1:N |
---|
46 | obj(1,index) = wl_trigger_eth_udp_broadcast('no_id'); |
---|
47 | obj(index).ID = IDvec(index); |
---|
48 | |
---|
49 | switch(transport) |
---|
50 | case 'java' |
---|
51 | obj(index).transport = wl_transport_eth_udp_java_bcast; |
---|
52 | case 'wl_mex_udp' |
---|
53 | obj(index).transport = wl_transport_eth_udp_mex_bcast; |
---|
54 | end |
---|
55 | |
---|
56 | obj(index).transport.open(); |
---|
57 | end |
---|
58 | end |
---|
59 | end |
---|
60 | end |
---|
61 | |
---|
62 | function out = send(obj) |
---|
63 | if(isempty(obj.ID)) |
---|
64 | error('Trigger is missing ID parameter.'); |
---|
65 | end |
---|
66 | |
---|
67 | obj.transport.send('trigger',obj.ID); |
---|
68 | end |
---|
69 | end |
---|
70 | end |
---|
71 | |
---|