Commit 7149a0d970c08e7729a5dd74b34346e6f8352f9c
1 parent
88285b24
PositioningService : ajout attr DebianDao, ajout getter macAddr et modif getLoc…
…ation() pour vérifier si nbVal >= 3
Showing
1 changed file
with
29 additions
and
22 deletions
Show diff stats
project/server_core/src/main/java/service/PositioningService.java
1 | package service; | 1 | package service; |
2 | 2 | ||
3 | +import dao.DebianDao; | ||
3 | import dao.HibernateDao; | 4 | import dao.HibernateDao; |
4 | import repository.Location; | 5 | import repository.Location; |
5 | import repository.RssiRecord; | 6 | import repository.RssiRecord; |
@@ -15,33 +16,37 @@ public class PositioningService { | @@ -15,33 +16,37 @@ public class PositioningService { | ||
15 | 16 | ||
16 | private static final double DEFAULT_POSITIONING_PRECISION = 7.5; | 17 | private static final double DEFAULT_POSITIONING_PRECISION = 7.5; |
17 | 18 | ||
18 | - private HibernateDao dao; | 19 | + private HibernateDao hibDao; |
20 | + private DebianDao debDao; | ||
19 | 21 | ||
20 | public PositioningService () { | 22 | public PositioningService () { |
21 | - this.dao = new HibernateDao(); | ||
22 | - } | ||
23 | - public PositioningService (HibernateDao dao) { | ||
24 | - this.dao = dao; | 23 | + this.debDao = new DebianDao(); |
24 | + this.hibDao = new HibernateDao(); | ||
25 | } | 25 | } |
26 | 26 | ||
27 | - public Location getLocation (String clientMacAddr) { | ||
28 | - Location bestLoc = null; | ||
29 | - double bestLocProbability = -1; | ||
30 | - for(Location loc : dao.getLocations()) { | ||
31 | - //Liste des RSSISample pour une position donnée, chaque RSSISample étant | ||
32 | - //assossié à un AccessPoint | ||
33 | - List<RssiRecord> rssis = dao.getRssiRecord(loc.getId()); | ||
34 | - | ||
35 | - //Liste des RSSISample associé à un ap, mesuré pour un client | ||
36 | - List<TempRssi> clientRssi = dao.getTempRssi(clientMacAddr); | ||
37 | - | ||
38 | - double currentLocProbability = probability(clientRssi, rssis, DEFAULT_POSITIONING_PRECISION); | ||
39 | - if(bestLocProbability == -1 || currentLocProbability > bestLocProbability){ | ||
40 | - bestLoc = loc; | ||
41 | - bestLocProbability = currentLocProbability; | 27 | + public Location getLocation (String ipAddr) { |
28 | + | ||
29 | + //Liste des RSSISample associé à un ap, mesuré pour un client | ||
30 | + List<TempRssi> clientRssi = hibDao.getTempRssi(debDao.getMacAddr(ipAddr)); | ||
31 | + | ||
32 | + if(clientRssi.size()>=3) { | ||
33 | + Location bestLoc = null; | ||
34 | + double bestLocProbability = -1; | ||
35 | + for (Location loc : hibDao.getLocations()) { | ||
36 | + //Liste des RSSISample pour une position donnée, chaque RSSISample étant | ||
37 | + //assossié à un AccessPoint | ||
38 | + List<RssiRecord> rssis = hibDao.getRssiRecord(loc.getId()); | ||
39 | + | ||
40 | + | ||
41 | + double currentLocProbability = probability(clientRssi, rssis, DEFAULT_POSITIONING_PRECISION); | ||
42 | + if (bestLocProbability == -1 || currentLocProbability > bestLocProbability) { | ||
43 | + bestLoc = loc; | ||
44 | + bestLocProbability = currentLocProbability; | ||
45 | + } | ||
42 | } | 46 | } |
47 | + return bestLoc; | ||
43 | } | 48 | } |
44 | - return bestLoc; | 49 | + return null; |
45 | } | 50 | } |
46 | 51 | ||
47 | private double probability(List<TempRssi> temps, List<RssiRecord> rssis, double precision){ | 52 | private double probability(List<TempRssi> temps, List<RssiRecord> rssis, double precision){ |
@@ -91,5 +96,7 @@ public class PositioningService { | @@ -91,5 +96,7 @@ public class PositioningService { | ||
91 | } | 96 | } |
92 | } | 97 | } |
93 | 98 | ||
94 | - | 99 | + public String getMacAddr (final String clientIpAddr) { |
100 | + return debDao.getMacAddr(clientIpAddr); | ||
101 | + } | ||
95 | } | 102 | } |