Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging UDPs when Timeline is running on expServer #301

Open
k1o0 opened this issue May 5, 2020 · 0 comments
Open

Logging UDPs when Timeline is running on expServer #301

k1o0 opened this issue May 5, 2020 · 0 comments
Assignees
Labels

Comments

@k1o0
Copy link
Contributor

k1o0 commented May 5, 2020

UDPs sent events may be logged in Timeline by your services:

In prepareExp, if your srv.Service object has a Timeline property, it is assigned a handle to srv.expServer's hw.Timeline instance.

Rigbox/+srv/prepareExp.m

Lines 17 to 31 in cd888f0

%configure actions to start and stop services
if isfield(params, 'services') && ~isempty(params.services)
services = srv.findService(params.services); % Uses basicServices
% services = srv.loadService(params.services); % Loads BasicUDPService objects
for i = 1:length(services)
if isprop(services{i},'Timeline')
services{i}.Timeline = rig.timeline;
end
end
startServices = exp.StartServices(services);
stopServices = exp.StopServices(services);
experiment.addEventHandler(...
exp.EventHandler('experimentInit', startServices),...
exp.EventHandler('experimentCleanup', stopServices));
end

When the services are started (a callback of the experimentInit event) or stopped (a callback of the experimentCleanup event), the start and stop methods of your service object may log the event with using Timeline's record method.

What service subclasses are people using (e.g. srv.PrimitiveUDPService)? It's here that you need to add the logic for recording the UDP events. See the code for srv.RemoteMPEPService:

function receiveUDP(obj, src, evt)
obj.LastReceivedMessage = strtrim(fscanf(obj.Socket));
% Let everyone know a message was recieved
notify(obj, 'MessageReceived')
hosts = arrayfun(@(s)s.Tag, obj.Sockets);
if ~isempty(obj.Timeline)&&obj.Timeline.IsRunning
t = obj.Timeline.time; % Note the time
% record the UDP event in Timeline
obj.Timeline.record([hosts 'UDP'], msg, t);
end
% Pass message to callback function for precessing
feval(obj.Callbacks{strcmp(hosts, src.Tag)}, src, evt);
end

Note that the block file contains the timestamps for the experiment events, which will be in Timeline time if it's running for that experiment. These timestamps will tell you when the tart and stop methods were called, which should be just before the UDPs are sent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants