Commit 86bf5a5a authored by Simon Pastor's avatar Simon Pastor
Browse files

merge

parent 0edf8654
Loading
Loading
Loading
Loading
+31 −16
Original line number Diff line number Diff line
@@ -222,7 +222,11 @@ func processActiveScenarioUpdate() {
	}

	// Update POA Cellular and Wifi info
	poaNameList := sbi.activeModel.GetNodeNames(mod.NodeTypePoa4G, mod.NodeTypePoa5G, mod.NodeTypePoaWifi)
	poaTypeList := [3]string{mod.NodeTypePoa4G, mod.NodeTypePoa5G, mod.NodeTypePoaWifi}
	conType := ""
	for _, poaType := range poaTypeList {

		poaNameList := sbi.activeModel.GetNodeNames(poaType)
		for _, name := range poaNameList {
			zone, netLoc, err := getNetworkLocation(name)
			if err != nil {
@@ -236,9 +240,20 @@ func processActiveScenarioUpdate() {
				longitude, latitude = parsePosition(poa.Position)
			}

		sbi.updateAccessPointInfoCB(zone, netLoc, "UNKNOWN", "SERVICEABLE", uePerNetLocMap[netLoc], longitude, latitude)
			switch poaType {
			case mod.NodeTypePoa4G:
				conType = "Macro"
			case mod.NodeTypePoa5G:
				conType = "Smallcell"
			case mod.NodeTypePoaWifi:
				conType = "Wifi"
			default:
				conType = "Unknown"
			}
			sbi.updateAccessPointInfoCB(zone, netLoc, conType, "Serviceable", uePerNetLocMap[netLoc], longitude, latitude)
			poaPerZoneMap[zone]++
		}
	}

	// Update Zone info
	zoneNameList := sbi.activeModel.GetNodeNames("ZONE")
@@ -364,7 +379,7 @@ func updateAccessPointPosition(name string) {
	}

	// Update info
	sbi.updateAccessPointInfoCB(zone, netLoc, "UNKNOWN", "", -1, longitude, latitude)
	sbi.updateAccessPointInfoCB(zone, netLoc, "", "", -1, longitude, latitude)
}

func updateAllAccessPointPosition() {
@@ -388,7 +403,7 @@ func updateAllAccessPointPosition() {
			longitude, latitude = parsePosition(poa.Position)
		}

		sbi.updateAccessPointInfoCB(zone, netLoc, "UNKNOWN", "", -1, longitude, latitude)
		sbi.updateAccessPointInfoCB(zone, netLoc, "", "", -1, longitude, latitude)
	}
}

+15 −11
Original line number Diff line number Diff line
@@ -403,15 +403,7 @@ func checkNotificationRegisteredUsers(oldZoneId string, newZoneId string, oldApI
			zonal.CallbackData = subscription.ClientCorrelator

			if newZoneId != oldZoneId {
				if userSubscriptionEnteringMap[subsId] != "" && newZoneId != "" {
					zonal.ZoneId = newZoneId
					zonal.CurrentAccessPointId = newApId
					event := new(clientNotifOMA.UserEventType)
					*event = clientNotifOMA.ENTERING_UserEventType
					zonal.UserEventType = event
					sendNotification(subscription.CallbackReference.NotifyURL, context.TODO(), subsIdStr, zonal)
					log.Info("User Notification" + "(" + subsIdStr + "): " + "Entering event in zone " + newZoneId + " for user " + userId)
				}
				//process LEAVING events prior to entering ones
				if oldZoneId != "" {
					if userSubscriptionLeavingMap[subsId] != "" {
						zonal.ZoneId = oldZoneId
@@ -423,6 +415,16 @@ func checkNotificationRegisteredUsers(oldZoneId string, newZoneId string, oldApI
						log.Info("User Notification" + "(" + subsIdStr + "): " + "Leaving event in zone " + oldZoneId + " for user " + userId)
					}
				}
				if userSubscriptionEnteringMap[subsId] != "" && newZoneId != "" {
					zonal.ZoneId = newZoneId
					zonal.CurrentAccessPointId = newApId
					event := new(clientNotifOMA.UserEventType)
					*event = clientNotifOMA.ENTERING_UserEventType
					zonal.UserEventType = event
					sendNotification(subscription.CallbackReference.NotifyURL, context.TODO(), subsIdStr, zonal)
					log.Info("User Notification" + "(" + subsIdStr + "): " + "Entering event in zone " + newZoneId + " for user " + userId)
				}

			} else {
				if newApId != oldApId {
					if userSubscriptionTransferringMap[subsId] != "" {
@@ -1424,8 +1426,6 @@ func updateAccessPointInfo(zoneId string, apId string, conTypeStr string, opStat
		apInfo = new(AccessPointInfo)
		apInfo.AccessPointId = apId
		apInfo.ResourceURL = hostUrl.String() + basePath + "zones/" + zoneId + "/accessPoints/" + apId
		conType := convertStringToConnectionType(conTypeStr)
		apInfo.ConnectionType = &conType
	}

	// Update info
@@ -1433,6 +1433,10 @@ func updateAccessPointInfo(zoneId string, apId string, conTypeStr string, opStat
		opStatus := convertStringToOperationStatus(opStatusStr)
		apInfo.OperationStatus = &opStatus
	}
	if conTypeStr != "" {
		conType := convertStringToConnectionType(conTypeStr)
		apInfo.ConnectionType = &conType
	}
	if nbUsers != -1 {
		apInfo.NumberOfUsers = int32(nbUsers)
	}
+2 −0
Original line number Diff line number Diff line
@@ -1565,6 +1565,8 @@ func plmnInfoGET(w http.ResponseWriter, r *http.Request) {
	var timeStamp TimeStamp
	timeStamp.Seconds = int32(seconds)

	//forcing to ignore the appInsId parameter, while keeping the comparison code if turned on again
	appInsId = ""
	//if AppId is set, we return info as per AppIds, otherwise, we return the domain info only
	if appInsId != "" {

+45 −6
Original line number Diff line number Diff line
@@ -206,12 +206,37 @@ func updateUeData(name string, ownMacId string, apMacId string) {
	}
}

func convertFloatToGeolocationFormat(value *float32) int32 {

	str := fmt.Sprintf("%f", *value)
	strArray := strings.Split(str, ".")
	integerPart, err := strconv.Atoi(strArray[0])
	if err != nil {
		log.Error("Can't convert float to int")
		return 0
	}
	fractionPart, err := strconv.Atoi(strArray[1])
	if err != nil {
		log.Error("Can't convert float to int")
		return 0
	}

	//9 first bits are the integer part, last 23 bits are fraction part
	valueToReturn := (integerPart << 23) + fractionPart
	log.Info("SIMON ", integerPart, "---", fractionPart, "---", valueToReturn)
	return int32(valueToReturn)
}

func updateApInfo(name string, apMacId string, longitude *float32, latitude *float32, staMacIds []string) {

	//get from DB
	jsonApInfoComplete, _ := rc.JSONGetEntry(baseKey+"AP:"+name, ".")

	var oldStaMacIds []string
	var oldLat int32 = 0
	var oldLong int32 = 0
	var newLat int32 = 0
	var newLong int32 = 0

	needUpdate := false

@@ -220,6 +245,14 @@ func updateApInfo(name string, apMacId string, longitude *float32, latitude *flo
		apInfoComplete := convertJsonToApInfoComplete(jsonApInfoComplete)

		oldStaMacIds = apInfoComplete.StaMacIds

		if apInfoComplete.ApLocation.GeoLocation != nil {
			oldLat = apInfoComplete.ApLocation.GeoLocation.Lat
			oldLong = apInfoComplete.ApLocation.GeoLocation.Long
		}

		newLat = convertFloatToGeolocationFormat(latitude)
		newLong = convertFloatToGeolocationFormat(longitude)
	} else {
		needUpdate = true
	}
@@ -232,24 +265,30 @@ func updateApInfo(name string, apMacId string, longitude *float32, latitude *flo
		}
	}

	if !needUpdate {
		//check if AP moved
		if oldLat != newLat || oldLong != newLong {
			needUpdate = true
		}
	}

	if needUpdate {
		//updateDB
		var apInfoComplete ApInfoComplete
		var apLocation ApLocation
		var geoLocation GeoLocation
		var apId ApIdentity
		if latitude != nil {
			geoLocation.Lat = int32(*latitude)
		}
		if longitude != nil {
			geoLocation.Long = int32(*longitude)
		}
		geoLocation.Lat = newLat
		geoLocation.Long = newLong

		apLocation.GeoLocation = &geoLocation
		apInfoComplete.ApLocation = apLocation

		apInfoComplete.StaMacIds = staMacIds
		apId.MacId = apMacId
		apInfoComplete.ApId = apId
		_ = rc.JSONSetEntry(baseKey+"AP:"+name, ".", convertApInfoCompleteToJson(&apInfoComplete))
		log.Info("SIMON SIMON ", name, "---", geoLocation.Lat, "---", geoLocation.Long, "---", apMacId)
		checkAssocStaNotificationRegisteredSubscriptions(staMacIds, apMacId)
	}
}