| 15 | |
| 16 | |
| 17 | class Observer(): |
| 18 | |
| 19 | def __init__(self, file_path, configuration_file_path, inclination, |
| 20 | satellite_altitude, orbit_number, sat_number, duration, |
| 21 | antenna_number, GS_lat_long, antenna_inclination, |
| 22 | intra_routing, hello_interval, AS): |
| 23 | self.file_path = file_path |
| 24 | self.configuration_file_path = configuration_file_path |
| 25 | self.inclination = inclination |
| 26 | self.satellite_altitude = satellite_altitude |
| 27 | self.orbit_number = orbit_number |
| 28 | self.sat_number = sat_number |
| 29 | self.duration = duration |
| 30 | self.antenna_number = antenna_number |
| 31 | self.GS_lat_long = GS_lat_long |
| 32 | self.antenna_inclination = antenna_inclination |
| 33 | self.intra_routing = intra_routing |
| 34 | self.hello_interval = hello_interval |
| 35 | self.AS = AS |
| 36 | |
| 37 | def access_P_L_shortest(self, sat_cbf, fac_cbf, fac_num, sat_num, |
| 38 | num_orbits, num_sats_per_orbit, duration, fac_ll, |
| 39 | sat_lla, bound_dis, alpha, antenna_num, path): |
| 40 | delay_matrix = np.zeros((fac_num + sat_num, fac_num + sat_num)) |
| 41 | for cur_time in range(duration): |
| 42 | for i in range(0, fac_num): |
| 43 | access_list = {} |
| 44 | fac_lat = float(fac_ll[i][0]) # latitude |
| 45 | up_lat = fac_lat + alpha # bound |
| 46 | down_lat = fac_lat - alpha |
| 47 | x2 = fac_cbf[i][0] |
| 48 | y2 = fac_cbf[i][1] |
| 49 | z2 = fac_cbf[i][2] |
| 50 | for j in range(0, sat_num): |
| 51 | if sat_lla[cur_time][j][0] >= down_lat and sat_lla[ |
| 52 | cur_time][j][0] <= up_lat: |
| 53 | x1 = sat_cbf[cur_time][j][0] # in km |
| 54 | y1 = sat_cbf[cur_time][j][1] |
| 55 | z1 = sat_cbf[cur_time][j][2] |
| 56 | dist = math.sqrt( |
| 57 | np.square(x1 - x2) + np.square(y1 - y2) + |
| 58 | np.square(z1 - z2)) |
| 59 | if dist < bound_dis: |
| 60 | # [satellite index,distance] |
| 61 | access_list.update({j: dist}) |
| 62 | if len(access_list) > antenna_num: |
| 63 | sorted_access_list = dict( |
| 64 | sorted(access_list.items(), key=lambda item: item[1])) |
| 65 | cnt = 0 |
| 66 | for key, value in sorted_access_list.items(): |
| 67 | cnt = cnt + 1 |
| 68 | if cnt > antenna_num: |
| 69 | break |
| 70 | delay_time = value / (17.31 / 29.5 * |
| 71 | 299792.458) * 1000 # ms |
| 72 | delay_matrix[sat_num + i][key] = delay_time |
| 73 | delay_matrix[key][sat_num + i] = delay_time |
| 74 | elif len(access_list) != 0: |