-
Notifications
You must be signed in to change notification settings - Fork 0
/
userStation.m
66 lines (60 loc) · 2.12 KB
/
userStation.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
classdef userStation < handle
properties
ID
location
reqRate
CHn
freq
tx_pwr
APs
selected_AP
servedRate
trig
blocked = 0;
end
methods
function obj = userStation(u_, cc, parameters, varargin)
obj.ID = u_;
locate_STA(obj, cc, parameters);
obj.reqRate=parameters.rates(randi(length(parameters.rates)));
obj.CHn = randi(11);
obj.freq = parameters.freq(obj.CHn);
obj.tx_pwr = parameters.STAsInitTxPwr;
end
function locate_STA(obj, cc, parameters)
x_temp=randi(parameters.area_X);
y_temp=randi(parameters.area_Y);
x_STAs=[];
y_STAs=[];
if isfield(cc.entities,'APs')
for ap=1:length(cc.entities.APs)
x_APs(ap)=cc.entities.APs(ap).location(1,1);
y_APs(ap)=cc.entities.APs(ap).location(1,2);
end
if isfield(cc.entities,'STAs')
for sta=1:length(cc.entities.STAs)
x_STAs(sta)=cc.entities.STAs(sta).location(1,1);
y_STAs(sta)=cc.entities.STAs(sta).location(1,2);
end
end
x_APs_STAs=[x_APs, x_STAs];
y_APs_STAs=[y_APs, y_STAs];
ii=0;
while(min(sqrt((x_APs_STAs-x_temp).^2 ...
+ (y_APs_STAs-y_temp).^2)) < parameters.STAs_minDist)
x_temp=randi(parameters.area_X);
y_temp=randi(parameters.area_Y);
if ii+1 > 200
error('the ''parameters.area'' may need to be increased')
end
end
end
obj.location=[x_temp, y_temp];
end
function update_APs(obj, APs)
for ap=1:length(APs)
obj.APs(ap)=APs(ap);
end
end
end
end