0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 function ltpdv_server_set_duration(mainfig, start, stop)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % Get handle
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 dh = findobj(mainfig, 'Tag', 'LTPDVserverDurationDisplay');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % Get duration
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 dur = stop - start + 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 if dur < 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 error('### The duration is negative. Change the start or stop time.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 hours = fix(dur/3600);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 mins = fix((dur-hours*3600)/60);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 secs = dur-hours*3600-mins*60;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 sign = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 if hours < 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 sign = '-';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 hours = abs(hours);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 if mins < 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 sign = '-';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 mins = abs(mins);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 if secs < 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 sign = '-';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 secs = abs(secs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 set(dh, 'String', sprintf('%s%02d:%02d:%02d', sign, hours, mins, secs));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33
|