import parameters.Constants as Constants
import parameters.Results as Results


def initialize(
    END_DEVICE_NUMBER
    ,MIN_SF
    ,MAX_SF
    ,SUPER_GROUP_LENGTH_IN_SECONDS
    ,DEVICE_ADDRESS_LENGTH_IN_BIT
    ,SUBSCRIPTION_ID_LENGTH_IN_BIT
    ,BANDWIDTH_IN_HERTZ
    ,NUMBER_OF_PREAMBLE
    ,SYNCHRONIZATION_WORD
    ,SF_TO_MAC_PAYLOAD_IN_BYTE
    ,SF_TO_RECEIVE_FRAME_MAC_PAYLOAD_IN_BYTE
    ,SF_TO_MAX_MAC_PAYLOAD_IN_BYTE
    ,SF_TO_SUPER_GROUP_PERIOD_IN_SEC
    ,CRC
    ,IH
    ,DE
    ,CODING_RATE
    ,DUTY_CYCLE_IN_PERCENTAGE
    ,SIMULATION_LIFE_TIME_IN_SECONDS
    ,SF_TO_ACTIVATION_PROB
):
    Constants.END_DEVICE_NUMBER = END_DEVICE_NUMBER
    Constants.MIN_SF = MIN_SF
    Constants.MAX_SF = MAX_SF
    Constants.SFs = [sf for sf in range(Constants.MIN_SF, Constants.MAX_SF + 1)]
    Constants.EXPONENTIAL_DIST_SIZE = Constants.MAX_SF - Constants.MIN_SF + 1
    Constants.EXPONENTIAL_DIST_SCALE = 1

    Constants.SUPER_GROUP_LENGTH_IN_SECONDS = SUPER_GROUP_LENGTH_IN_SECONDS
    Constants.DEVICE_ADDRESS_LENGTH_IN_BIT = DEVICE_ADDRESS_LENGTH_IN_BIT
    Constants.SUBSCRIPTION_ID_LENGTH_IN_BIT = SUBSCRIPTION_ID_LENGTH_IN_BIT

    # they are for calculation of the time on air
    Constants.BANDWIDTH_IN_HERTZ = BANDWIDTH_IN_HERTZ
    Constants.NUMBER_OF_PREAMBLE = NUMBER_OF_PREAMBLE
    Constants.SYNCHRONIZATION_WORD = SYNCHRONIZATION_WORD
    Constants.SF_TO_MAC_PAYLOAD_IN_BYTE = SF_TO_MAC_PAYLOAD_IN_BYTE
    Constants.SF_TO_RECEIVE_FRAME_MAC_PAYLOAD_IN_BYTE = SF_TO_RECEIVE_FRAME_MAC_PAYLOAD_IN_BYTE
    Constants.SF_TO_MAX_MAC_PAYLOAD_IN_BYTE = SF_TO_MAX_MAC_PAYLOAD_IN_BYTE
    Constants.SF_TO_SUPER_GROUP_PERIOD_IN_SEC = SF_TO_SUPER_GROUP_PERIOD_IN_SEC
    Constants.CRC = CRC
    Constants.IH = IH
    Constants.DE = DE
    Constants.CODING_RATE = CODING_RATE

    Constants.DUTY_CYCLE_IN_PERCENTAGE = DUTY_CYCLE_IN_PERCENTAGE
    Constants.SIMULATION_LIFE_TIME_IN_SECONDS = SIMULATION_LIFE_TIME_IN_SECONDS
    Constants.SF_TO_ACTIVATION_PROB = SF_TO_ACTIVATION_PROB

    Results.BOOLEAN_EXP_FOR_SAME_ACK = ''
    Results.DEVICE_ID_LENGTH_IN_BIT_SAME_ACK = 0
    Results.MAC_PAYLOAD_IN_BIT_SAME_ACK = 0
    Results.BOOLEAN_EXP_FOR_DIFFERENT_ACK = {}
    Results.DEVICE_ID_LENGTH_IN_BIT_DIFFERENT_ACK = {}
    Results.MAC_PAYLOAD_IN_BIT_DIFFERENT_ACK = {}
    Results.SPREADING_FACTOR_BASED_NUMBER_OF_END_DEVICES = {}
    Results.NUMBER_OF_TRANSMITTERS = 0
    Results.NUMBER_OF_SUSPENDED_DEVICES = 0
    Results.NUMBER_OF_FAILED_DEVICES = 0

