# Path: D3HRE/core/mission_utility.py
# class Mission:
#     def __init__(self, start_time=None, route=None, speed=None):
#         if start_time is None or route is None or speed is None:
#             print('Please use custom mission setting.')
#         else:
#             self.start_time = start_time
#             self.route = route
#             self.speed = speed
#             self.df = get_mission(self.start_time, self.route, self.speed)
#             self.get_ID()
# 
#     def __str__(self):
#         return "This mission {ID} is start from {a} at {b} UTC.".format(
#             a=self.route[0], b=self.start_time, ID=self.ID
#         )
# 
#     def custom_set(self, mission_df, ID):
#         self.df = mission_df
#         self.ID = ID
# 
#     def get_ID(self):
#         route_tuple = tuple(self.route.flatten().tolist())
#         if isinstance(self.speed, list):
#             speed_tuple = tuple(self.speed)
#         else:
#             speed_tuple = self.speed
# 
#         ID_tuple = (self.start_time, route_tuple, speed_tuple)
#         self.ID = hash_value(ID_tuple)
#         return self.ID
# 
# Path: D3HRE/simulation.py
# class Task:
#     """
#     Task is a high level object that contains the mission and the robot object.
#     """
#     def __init__(self, mission, robot, power_consumption_list={}):
#         """
# 
#         :param mission: Object mission object
#         :param robot: Object robot object
#         :param power_consumption_list: optional the list of demand load, only use in legacy mode
#         """
#         self.mission = mission
#         self.robot = robot
#         if power_consumption_list != {}:
#             self.power_consumption_list = power_consumption_list
#             self.estimate_demand_load_compatible()
#         else:
#             self.estimate_demand_load()
# 
#     def estimate_demand_load_compatible(self):
#         new_robot = MaritimeRobot(self.power_consumption_list)
#         new_robot.set_from_PyResis(self.robot)
#         self.robot = new_robot
#         self.estimate_demand_load()
# 
#     def estimate_demand_load(self):
#         self.robot.estimate_demand_load(self.mission)
#         self.hotel_load = self.robot.hotel_load
#         self.prop_load = self.robot.prop_load
#         self.critical_hotel_load = self.robot.critical_hotel_load
#         self.critical_prop_load = self.robot.critical_prop_load
#         self.load_demand = self.hotel_load + self.prop_load


import pytest
import numpy as np
from D3HRE.core.mission_utility import Mission
from D3HRE.simulation import Task
from PyResis import propulsion_power


test_route =  np.array([[  10.69358 ,  -178.94713892], [  11.06430687, +176.90022735]])


test_ship = propulsion_power.Ship()
test_ship.dimension(5.72, 0.248, 0.76, 1.2, 5.72/(0.549)**(1/3),0.613)

power_consumption_list = {'single_board_computer': {'power': [2, 10], 'duty_cycle': 0.5},
                              'webcam': {'power': [0.6], 'duty_cycle': 1},
                              'gps': {'power': [0.04, 0.4], 'duty_cycle': 0.9},
                              'imu': {'power': [0.67, 1.1], 'duty_cycle': 0.9},
                              'sonar': {'power': [0.5, 50], 'duty_cycle': 0.5},
                              'ph_sensor': {'power': [0.08, 0.1], 'duty_cycle': 0.95},
                              'temp_sensor': {'power': [0.04], 'duty_cycle': 1},
                              'wind_sensor': {'power': [0.67, 1.1], 'duty_cycle': 0.5},
                              'servo_motors': {'power': [0.4, 1.35], 'duty_cycle': 0.5},
                              'radio_transmitter': {'power': [0.5, 20], 'duty_cycle': 0.2}}

test_mission = Mission('2014-01-01', test_route, 2)

# Path: D3HRE/core/mission_utility.py
# class Mission:
#     def __init__(self, start_time=None, route=None, speed=None):
#         if start_time is None or route is None or speed is None:
#             print('Please use custom mission setting.')
#         else:
#             self.start_time = start_time
#             self.route = route
#             self.speed = speed
#             self.df = get_mission(self.start_time, self.route, self.speed)
#             self.get_ID()
# 
#     def __str__(self):
#         return "This mission {ID} is start from {a} at {b} UTC.".format(
#             a=self.route[0], b=self.start_time, ID=self.ID
#         )
# 
#     def custom_set(self, mission_df, ID):
#         self.df = mission_df
#         self.ID = ID
# 
#     def get_ID(self):
#         route_tuple = tuple(self.route.flatten().tolist())
#         if isinstance(self.speed, list):
#             speed_tuple = tuple(self.speed)
#         else:
#             speed_tuple = self.speed
# 
#         ID_tuple = (self.start_time, route_tuple, speed_tuple)
#         self.ID = hash_value(ID_tuple)
#         return self.ID
# 
# Path: D3HRE/simulation.py
# class Task:
#     """
#     Task is a high level object that contains the mission and the robot object.
#     """
#     def __init__(self, mission, robot, power_consumption_list={}):
#         """
# 
#         :param mission: Object mission object
#         :param robot: Object robot object
#         :param power_consumption_list: optional the list of demand load, only use in legacy mode
#         """
#         self.mission = mission
#         self.robot = robot
#         if power_consumption_list != {}:
#             self.power_consumption_list = power_consumption_list
#             self.estimate_demand_load_compatible()
#         else:
#             self.estimate_demand_load()
# 
#     def estimate_demand_load_compatible(self):
#         new_robot = MaritimeRobot(self.power_consumption_list)
#         new_robot.set_from_PyResis(self.robot)
#         self.robot = new_robot
#         self.estimate_demand_load()
# 
#     def estimate_demand_load(self):
#         self.robot.estimate_demand_load(self.mission)
#         self.hotel_load = self.robot.hotel_load
#         self.prop_load = self.robot.prop_load
#         self.critical_hotel_load = self.robot.critical_hotel_load
#         self.critical_prop_load = self.robot.critical_prop_load
#         self.load_demand = self.hotel_load + self.prop_load


# Path: tests/test_demand_load.py
import pytest
import numpy as np
from D3HRE.core.mission_utility import Mission
from D3HRE.simulation import Task
from PyResis import propulsion_power



test_route =  np.array([[  10.69358 ,  -178.94713892], [  11.06430687, +176.90022735]])


test_ship = propulsion_power.Ship()
test_ship.dimension(5.72, 0.248, 0.76, 1.2, 5.72/(0.549)**(1/3),0.613)

power_consumption_list = {'single_board_computer': {'power': [2, 10], 'duty_cycle': 0.5},
                              'webcam': {'power': [0.6], 'duty_cycle': 1},
                              'gps': {'power': [0.04, 0.4], 'duty_cycle': 0.9},
                              'imu': {'power': [0.67, 1.1], 'duty_cycle': 0.9},
                              'sonar': {'power': [0.5, 50], 'duty_cycle': 0.5},
                              'ph_sensor': {'power': [0.08, 0.1], 'duty_cycle': 0.95},
                              'temp_sensor': {'power': [0.04], 'duty_cycle': 1},
                              'wind_sensor': {'power': [0.67, 1.1], 'duty_cycle': 0.5},
                              'servo_motors': {'power': [0.4, 1.35], 'duty_cycle': 0.5},
                              'radio_transmitter': {'power': [0.5, 20], 'duty_cycle': 0.2}}

test_mission = Mission('2014-01-01', test_route, 2)

test_task = Task(test_mission, test_ship, power_consumption_list)