Commit 57f53fd8 authored by M. Rehan Abbasi's avatar M. Rehan Abbasi
Browse files

add VIS implementation with prediction for time

parent f31c01b8
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -307,3 +307,11 @@ func populatePoaTable() (err error) {
	}
	return nil
}

func GetPredictedPowerValues(hour int32, inRsrp int32, inRsrq int32, poaName string) (outRsrp int32, outRsrq int32, err error) {
	outRsrp, outRsrq, err = sbi.trafficMgr.PredictQosPerTrafficLoad(hour, inRsrp, inRsrq, poaName)
	if err != nil {
		log.Error(err.Error())
	}
	return outRsrp, outRsrq, err
}
+25 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ const serviceCategory = "V2XI"
const defaultMepName = "global"
const defaultScopeOfLocality = "MEC_SYSTEM"
const defaultConsumedLocalOnly = true
const defaultPredictionModelSupported = false
const appTerminationPath = "notifications/mec011/appTermination"

var redisAddr string = "meep-redis-master.default.svc.cluster.local:6379"
@@ -68,6 +69,7 @@ var sandboxName string
var mepName string = defaultMepName
var scopeOfLocality string = defaultScopeOfLocality
var consumedLocalOnly bool = defaultConsumedLocalOnly
var predictionModelSupported bool = defaultPredictionModelSupported
var locality []string
var basePath string
var baseKey string
@@ -334,6 +336,16 @@ func Init() (err error) {
	}
	log.Info("MEEP_LOCALITY: ", locality)

	// Get prediction model support
	predictionModelSupportedEnv := strings.TrimSpace(os.Getenv("PREDICTION_MODEL_SUPPORTED"))
	if predictionModelSupportedEnv != "" {
		value, err := strconv.ParseBool(predictionModelSupportedEnv)
		if err == nil {
			predictionModelSupported = value
		}
	}
	log.Info("PREDICTION_MODEL_SUPPORTED: ", predictionModelSupported)

	// Set base path
	if mepName == defaultMepName {
		basePath = "/" + sandboxName + "/" + visBasePath
@@ -611,6 +623,12 @@ func predictedQosPost(w http.ResponseWriter, r *http.Request) {
				return
			}

			if routeInfo.Time != nil && !predictionModelSupported {
				log.Error("routes.routeInfo.time is not supported for this scenario")
				errHandlerProblemDetails(w, "routes.routeInfo.time is not supported for this scenario", http.StatusBadRequest)
				return
			}

			geocoordinates = append(geocoordinates, gisClient.GeoCoordinate{
				Latitude:  routeInfo.Location.GeoArea.Latitude,
				Longitude: routeInfo.Location.GeoArea.Longitude,
@@ -627,6 +645,13 @@ func predictedQosPost(w http.ResponseWriter, r *http.Request) {
		routeInfoList := responseData.Routes[i].RouteInfo
		for j, routeInfo := range routeInfoList {
			currGeoCoordinate := powerResp.CoordinatesPower[j]
			if predictionModelSupported && routeInfo.Time != nil {
				rsrp := currGeoCoordinate.Rsrp
				rsrq := currGeoCoordinate.Rsrq
				poaName := currGeoCoordinate.PoaName
				estTimeHour := int32(time.Unix(int64(routeInfo.Time.Seconds), int64(routeInfo.Time.Seconds)).Hour())
				currGeoCoordinate.Rsrq, currGeoCoordinate.Rsrp, _ = sbi.GetPredictedPowerValues(estTimeHour, rsrp, rsrq, poaName)
			}
			latCheck := routeInfo.Location.GeoArea.Latitude == currGeoCoordinate.Latitude
			longCheck := routeInfo.Location.GeoArea.Longitude == currGeoCoordinate.Longitude
			if latCheck && longCheck {
+1 −5
Original line number Diff line number Diff line
@@ -814,11 +814,7 @@ func (tm *TrafficMgr) PopulateStaticPoaLoad(poaNameList []string) (err error) {
}

// Returns Predicted QoS in terms of RSRQ and RSRP values based on Traffic Load patterns
func (tm *TrafficMgr) PredictQosPerTrafficLoad(estimatedTime TimeStamp, inRsrp int32, inRsrq int32, poaName string) (outRsrp int32, outRsrq int32, err error) {

	// Convert unix time to UTC time
	utcTime := time.Unix(int64(estimatedTime.Seconds), int64(estimatedTime.NanoSeconds))
	hour := int32(utcTime.Hour())
func (tm *TrafficMgr) PredictQosPerTrafficLoad(hour int32, inRsrp int32, inRsrq int32, poaName string) (outRsrp int32, outRsrq int32, err error) {

	// Get time range for DB query
	timeRange := inTimeRange(hour)