⭐ 新增:校验时间窗口是否满足传输需求
(self, req, estimated_rate)
| 1375 | return req.to_dict() |
| 1376 | |
| 1377 | def _validate_time_window(self, req, estimated_rate): |
| 1378 | """⭐ 新增:校验时间窗口是否满足传输需求""" |
| 1379 | if req.start_time is not None and req.end_time is not None: |
| 1380 | available_duration = req.end_time - req.start_time # 可用时间(秒) |
| 1381 | if available_duration <= 0: |
| 1382 | return False, "TIME_WINDOW_INVALID" |
| 1383 | |
| 1384 | # 计算所需传输时间 (data_size单位可能是KB/MB/GB) - 统一归一到 MB |
| 1385 | data_size_mb = self._data_size_to_mb(req) |
| 1386 | |
| 1387 | # 计算所需时间 (秒) = 数据量(MB) / 速率(Mbps) * 8 |
| 1388 | if estimated_rate > 0: |
| 1389 | required_duration = (data_size_mb * 8) / estimated_rate |
| 1390 | if required_duration > available_duration: |
| 1391 | return False, "TIME_WINDOW_INVALID" |
| 1392 | |
| 1393 | return True, None |
| 1394 | |
| 1395 | def _check_time_window_resources(self, req, satellite): |
| 1396 | """ |
nothing calls this directly
no test coverage detected