-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlatencyToTS.m
45 lines (31 loc) · 1.34 KB
/
latencyToTS.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function latencyToTS(opID, theTree,samplingTime)
nodeParent = getparent(theTree,opID);
operatorSubTree = theTree.subtree(nodeParent);
theNodes = nnodes(operatorSubTree);
s = '';
totalLStr = '';
disp(operatorSubTree.tostring);
for i=1:theNodes
% disp(i)
% disp(operatorSubTree.get(i));
end
lStr = operatorSubTree.get(12);
l = str2double( lStr );
toleranceString = operatorSubTree.get(11);
toleranceValue = str2double( toleranceString );
if (operatorSubTree.get(1) == '<')
totalL = ((l - toleranceValue)/samplingTime) + 1;
totalLStr = string(totalL);
end
%
if (operatorSubTree.get(1) == '>')
totalL = ((l + toleranceValue)/samplingTime) - 1;
totalLStr = string(totalL);
end
s = strcat('T','(',operatorSubTree.get(9),operatorSubTree.get(8),operatorSubTree.get(10),')','-'...
,'T','(',operatorSubTree.get(5),operatorSubTree.get(4),operatorSubTree.get(6),')',operatorSubTree.get(1),totalLStr);
fileID = fopen('convertedConstraints.txt','a');
fprintf(fileID,s);
fprintf(fileID,newline);
fclose(fileID);
end