summaryrefslogtreecommitdiff
path: root/cesar/bsu/aclf/test/utest/estimateBP.sce
blob: 3fe548737dbd3fe31e910c88e510074e53874bf4 (plain)
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
// SPiDCOM Technologies.
// Nélio Laranjeiro
// 16-05-2008
// Cesar project.

//Estimate the beacon period using the synchronisation of the PWL.
//This shall use a function to generate the ACL frequency.

// The function phy_clock_get_zero_cross_captured_date shall be written in
// function of the test which is being done.
// WARN : Import the file containing the function before using this script.

// compute the estimation of the ACL period.
// @param  cp  the CP context.
//            	- date_ntb[2]
//		- bp_ntb
//		- zc_ntb
//		- per_ntb
// @return  the [per, date_ntb']
function [res] = estimate_beacon_period (cp)

date_ntb = [cp(1) ,cp(2)];
bp_ntb = cp(3);
zc_ntb = cp(4);
per_ntb = cp(5);

date_ntb(2) = date_ntb(1);
date_ntb(1) = phy_clock_get_zero_cross (date_ntb(2));
diff_ntb = modulo((date_ntb(1) - date_ntb(2)), bp_ntb + 10000);

if diff_ntb < 3*zc_ntb
  diff_ntb = (4-int((diff_ntb / zc_ntb))) * zc_ntb + diff_ntb;
end

// Using a WP with a K = 4.
per_ntb = int(per_ntb + 0.0625 * (diff_ntb - per_ntb));

res = [date_ntb, bp_ntb, zc_ntb, per_ntb];
return res;

endfunction