'''
Created on Jan 3, 2011
Modified on July 19, 2012
@author: Dilum Bandara
@version: 0.22
@license: Apache License v2.0

   Copyright 2012 H. M. N. Dilum Bandara and Anura P. Jayasumana, Colorado State
   University

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
'''

import math

NUM_WSTATIONS = 1081 #No of weather stations
NUM_IN_OVERLAY = 109 #No of nodes in overlay
NUM_USERS = 500 #No of end users

NUM_ATTRIBS = 8
ATT_LIST = ['ELEV', 'DD', 'FF', 'P', 'RH', 'T', 'X', 'Y']

THRES_MAX_QUE_LOAD = 300 #Threshold query load = queries per sec x interval 
THRES_MIN_QUE_LOAD = 0.1 * THRES_MAX_QUE_LOAD #Minimum query contribution
THRES_IDX_SIZE = 500 #Threshold index size

#Next hop selection policy for load balancing  
NEXT_HOP_SELECTION = 'RoundRobin' #'RoundRobin' or 'Random'

#Resource & packet size
IP_PORT_SIZE = 6 #IP address & poer no - In bytes
ATT_VALUE_SIZE = 4 #Size of an attribute value
MAX_PACKET_SIZE = 150000 #Largest packet size (bytes) -Set 0 if size not important
PREFETCH_TIME = 120
PREFETCH_INTERVAL = 90
SIM_TIME_AFTER_LAST_QUERY = 150
FIX_FINGER_INTERVAL = 180
TRACK_ATT_COST = False #Track which attribute contribute to cost
STAT_COLLECTION_INTERVAL = 300
MIN_VALID_TIME = 1800

#Simulation type 'Chord', 'Chord+Split', 'Chord+Split+Add', 'Chord+RDSim'
SIMULATION_TYPE = 'Chord'

if SIMULATION_TYPE not in ['Chord', 'Chord+Split', 'Chord+RDSim']:
    assert(False), 'Unknown simulation type'

assert(NUM_ATTRIBS == len(ATT_LIST)), 'NUM_ATTRIBS & ATT_LIST don\'t match'

KEY_LENGTH = 32 #Default key length is 160-bits
MAX_KEY = long(math.pow(2, KEY_LENGTH) - 1)


QUERY_FILE = 'Queries.txt'         #Query file
W_STATION_FILE = 'WStations.txt'   #Sensor readings from weather stations file
S_READING_FILE = 'SReadings.txt'   #Sensor readings from weather stations file
SFC_MAP_FILE = 'SFCMap.txt'        #File with mapping between coordinates to SFP 
RESULTS_FILE = 'results.txt'       #File to store results

#Thresholds
T_DD = 5.0          #Wind direction (deg)
T_FF = 1.5          #Wind speed (m/s)
T_FFGUST = 1        #Wind gust (m/s)
T_ELEV = 0.0001     #Elevation. Threshold is used as ELEV is a float value
T_P = 1000.0        #Station pressure (Pa)
T_PCP1H = 0.02      #Accumulated precipitation 1 Hour (m)
T_PCP5M = 0.02      #Accumulated precipitation 5 min (m)
T_PCP15M = 0.02     #Accumulated precipitation 15 min (m)
T_PCPRATE = 0.1     #Precipitation rate kg/m^2/s
T_PCPINT = 1        #Precipitation intensity (category)
T_PCPTYPE = 1       #Precipitation type (category)
T_T = 1.0           #Air temperature (K)
T_RH = 5.0          #Relative humidity (%)
T_X = 0.0001        #X positions. Threshold is used as X is a float value
T_Y = 0.0001        #Y positions. Threshold is used as Y is a float value

MIN_DD = 0.0        #Wind direction (deg)
MAX_DD = 360.0      #Wind direction (deg)
MIN_ELEV = 0.0      #Minimum elevation (m)
MAX_ELEV = 2000.0  #Maximum elevation (m)
MIN_FF = 0.0        #Min wind speed (m/s)
MAX_FF = 25.0       #Max wind speed (m/s)
MIN_FFGUST = 0      #Min Wind gust (m/s)
MAX_FFGUST = 90     #Max Wind gust (m/s)
MIN_P = 25000.0     #Min Station pressure (Pa)
MAX_P = 110000.0    #Max Station pressure (Pa)
MIN_PCP1H = 0       #Accumulated precipitation 1 Hour (m)
MAX_PCP1H = 0.5     #Accumulated precipitation 1 Hour (m)
MIN_PCP5M = 0       #Accumulated precipitation 5 min (m)
MAX_PCP5M = 0.5     #Accumulated precipitation 5 min (m)
MIN_PCP15M = 0      #Accumulated precipitation 15 min (m)
MAX_PCP15M = 0.5    #Accumulated precipitation 15 min (m)
MIN_PCPRATE = 0     #Precipitation rate kg/m^2/s
MAX_PCPRATE = 0.5   #Precipitation rate kg/m^2/s
MIN_PCPINT = 0      #Precipitation intensity (category)
MAX_PCPINT = 6      #Precipitation intensity (category)
MIN_PCPTYPE = 0     #Precipitation type (category)
MAX_PCPTYPE = 15    #Precipitation type (category)
MIN_T = 243.0       #Air temperature (K)
MAX_T = 320.0       #Air temperature (K)
MIN_RH = 0.0        #Min relative humidity (%)
MAX_RH = 100.00     #Max relative humidity (%)
MIN_X = 0.0
MAX_X= 1000000
MIN_Y = 0.0
MAX_Y= 1000000