'''
Created on Aug 31, 2012
@author: Dilum Bandara
@email: dilumb@engr.colostate.edu
@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

CACHING_POLICY = 'oldest' #oldest, LRU, LFU 
PIT_TIMEOUT = 120 #PIT timeout in seconds
#Capacity of content store. Set to -1 to prevent data packets without data 
#(i.e., dataSize = 0) from storing in CS
SIZE_CS =  -1 #10 * math.pow(2, 20) 
SIZE_PIT = 0
SIZE_FIB = 0

NUM_DIMENSIONS = 2              #No of dimensions
SIZE_TORUS = [10, 10]             #Size of d-torus
#SIZE_TORUS = [1000000, 1000000] #Size of d-torus
NUM_BITS = 2                    #Number of bits per axis on torus

NUM_W_STATIONS = 20             #Number of weather stations
FRACTION_IN_OVERLAY = 0.5       #Fraction of weather stations in overlay
SENSOR_NAMES = ['X', 'Y', 'ELEV', 'T', 'RH']  #List of sensor names
MIN_VALID_TIME = 1800       #Sensor data should at least expire after this time
#Apply thresholds to prevent advertising of minor changes in sensor readings
USE_THRESHOLDS = True  
#Number of bytes required to represent sensor readings. 1 byte for sensor name
#and 4 bytes for sensor reading
SIZE_SENSOR_READINGS = len(SENSOR_NAMES) * 5
#End user placement. Total users of given type = i * j (if [i, j]) or i if ([i])
USERS = [['NWS', [2, 2]], ['EM', [4, 4]], ['RES', [3]], ['MED', [5]]]

JOIN_DELAY = 0.1 #Delay between 2 nodes that join
SIM_TIME_AFTER_LAST_QUERY = 150 #After what time should simulator be stopped

BANDWIDTH = math.pow(10, 9)

PREFETCH_TIME = 180             #Time to prefetch weather station data & queries
PREFETCH_INTERVAL = 120         #How frequently to prefetch
#Subscriptions expires time. If subset of queries are send for speed up. Else
#Should be greater than the time of last query + SIM_TIME_AFTER_LAST_QUERY 
STAT_COLLECTION_INTERVAL = 120 #When to collect statistics

SPEED_LIGHT = 299792458            #m/sec
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 = 'SCPMap.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 (%)


assert(len(SIZE_TORUS) == NUM_DIMENSIONS), \
    'NUM_DIMENSION & SIZE TORUS don\'t match'
    
assert(PREFETCH_TIME > PREFETCH_INTERVAL), 'PREFETCH_INTERVAL >= PREFETCH_TIME'
