[4332] | 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 | |
---|
[1915] | 12 | classdef wl_trigger_eth_udp_broadcast < wl_trigger |
---|
[4332] | 13 | |
---|
[1915] | 14 | properties (SetAccess = protected) |
---|
[4332] | 15 | description = 'UDP over Ethernet Broadcast Trigger'; |
---|
[1915] | 16 | ID; |
---|
| 17 | transport; |
---|
| 18 | end |
---|
[4332] | 19 | |
---|
[1915] | 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{:}); |
---|
[1935] | 34 | |
---|
| 35 | configFile = which('wl_config.ini'); |
---|
[4332] | 36 | |
---|
[1935] | 37 | if(isempty(configFile)) |
---|
[2865] | 38 | error('cannot find wl_config.ini. please run wl_setup.m'); |
---|
[1935] | 39 | end |
---|
[4332] | 40 | |
---|
[1935] | 41 | readKeys = {'network','','transport',''}; |
---|
| 42 | transport = inifile(configFile,'read',readKeys); |
---|
| 43 | transport = transport{1}; |
---|
| 44 | |
---|
[1915] | 45 | for index = 1:N |
---|
[2855] | 46 | obj(1,index) = wl_trigger_eth_udp_broadcast('no_id'); |
---|
| 47 | obj(index).ID = IDvec(index); |
---|
[2084] | 48 | |
---|
[2855] | 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 |
---|
[1935] | 55 | |
---|
[1915] | 56 | obj(index).transport.open(); |
---|
| 57 | end |
---|
| 58 | end |
---|
| 59 | end |
---|
| 60 | end |
---|
[1948] | 61 | |
---|
[1915] | 62 | function out = send(obj) |
---|
| 63 | if(isempty(obj.ID)) |
---|
[2865] | 64 | error('Trigger is missing ID parameter.'); |
---|
[1915] | 65 | end |
---|
[4332] | 66 | |
---|
[1915] | 67 | obj.transport.send('trigger',obj.ID); |
---|
| 68 | end |
---|
| 69 | end |
---|
| 70 | end |
---|
| 71 | |
---|