# Path: D3HRE/core/get_hash.py
# def hash_value(data):
#     """
#     Get hash of python object
# 
#     :param data: object or data
#     :return: the hash value for the data (full length)
#     """
#     hashId = hashlib.md5()
#     hashId.update(repr(data).encode('utf-8'))
#     return hashId.hexdigest()
# 
# Path: D3HRE/core/dataframe_utility.py
# def full_day_cut(df):
#     '''
#     Crop dataFrame at the end of the day
# 
#     :param df: pandas data frame
#     :return: pandas data frame that end at full day
#     '''
#     df = df[0 : int(floor(len(df) / 24)) * 24]
#     return df


import numpy as np
import pandas as pd
import nvector as nv
from math import radians, cos, sin, asin, sqrt
from datetime import timedelta
from D3HRE.core.get_hash import hash_value
from D3HRE.core.dataframe_utility import full_day_cut


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)

# Path: D3HRE/core/get_hash.py
# def hash_value(data):
#     """
#     Get hash of python object
# 
#     :param data: object or data
#     :return: the hash value for the data (full length)
#     """
#     hashId = hashlib.md5()
#     hashId.update(repr(data).encode('utf-8'))
#     return hashId.hexdigest()
# 
# Path: D3HRE/core/dataframe_utility.py
# def full_day_cut(df):
#     '''
#     Crop dataFrame at the end of the day
# 
#     :param df: pandas data frame
#     :return: pandas data frame that end at full day
#     '''
#     df = df[0 : int(floor(len(df) / 24)) * 24]
#     return df


# Path: D3HRE/core/mission_utility.py
import numpy as np
import pandas as pd
import nvector as nv
from math import radians, cos, sin, asin, sqrt
from datetime import timedelta
from D3HRE.core.get_hash import hash_value
from D3HRE.core.dataframe_utility import full_day_cut



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)