# author Aaron Moser

from enum import Enum

# Comstants

# 96 kWh maximale Arbeit, die von einer Instanz verrichtet werden kann
# 4kW volle Leistungslast, welche in einer Stunde moeglich ist
# 4kW / 100 = 0.04kW = 1 Prozent
MAX_WORKLOAD_IN_KW:int = 4
MAX_WORKLOAD_IN_KW_ONE_PERCENT:float = MAX_WORKLOAD_IN_KW / 100

# 24h/d * 60min/h * 60s/min = 86400s/d = Anzahl Sekunden am Tag
# Ein Tag um Faktor 1000 gekuerzt = 86400s/d / 1000 = 86.4s/d
# 86,4s/d / 1440min/d = 0.06s/min
# Ratio how many seconds simulate one minute of a day
DAILY_MODE_MILLISECONDS_MINUTE_RATIO:int = 60

MINIMUM_NUMBER_CLIENTS = 1
MAXIMUM_NUMBER_CLIENTS = 20

# Error code enums
class ConnectErrorCode(Enum):
    CONNECTED = 1
    ALREADY_CONNECTED = 2
    UNVERIFIED_KEY = 3
    AUTHENTICATION_FAILED = 4
    SOCKET_ERROR = 5
    ALL_CONNECTION_ATTEMPTS_FAILED = 6
    SSH_EXCEPTION = 7

class State(Enum):
    Stopped = 1
    Running = 2

# Commands
START_SIMULATION_COMMAND = "startsimulation"
STOP_SIMULATION_COMMAND = "stopsimulation"
SET_SIMULATION_MODE_COMMAND = "setsimulationmode"
ADD_INSTANCE_COMMAND = "addinstance"
REMOVE_INSTANCE_COMMAND = "removeinstance"
SHOW_INSTANCES_COMMAND = "showinstances"
DISPLAY_OUTCOME_COMMAND = "displayoutcome"
HELP_COMMAND = "help"
EXIT_COMMAND = "exit"

SET_SIMULATION_MODE_COMMAND_REALTIME = "realtime"
SET_SIMULATION_MODE_COMMAND_DAILY = "daily"

COMMANDS_HELP = [
    "StartSimulation [daily, realtime] [start date] [end date]         // Starts simulation with default mode or optionally with given mode, start and end date.",
    "StopSimulation                                                    // Stops running simulation by stopping threads of instances.",
    "SetSimulationMode                                                 // 'daily' or 'realtime', sets simulation mode depending on second argument.",
    "AddInstance <hostname> <username> <ssh_key_filename> <passphrase> // Adds new instance to load balancer.",
    "RemoveInstance <hostname> <username>                              // Removes existing instance.",
    "ShowInstances                                                     // Lists all existsing instances and their state.",
    "DisplayOutcome                                                    // Shows global outcome which consists of: count, tries and PI",
    "Help                                                              // Shows commands and descriptions.",
    "Exit                                                              // Stops load balancer and exits application."]

# Messages
START_MESSAGE = "-------------------------------\nLoad Balancer has been started."
