Commit 229d7e2e authored by M. Rehan Abbasi's avatar M. Rehan Abbasi
Browse files

add code for populating traffic load table of traffic manager

parent 24fe68e5
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -162,7 +162,14 @@ func Init(cfg SbiCfg) (err error) {
		log.Error("Failed to populate categories table: ", err)
		return err
	}
	log.Info("Created new VIS DB categories table")
	log.Info("Populated VIS DB categories table")

	err = populatePoaTable()
	if err != nil {
		log.Error("Failed to populate traffic load table: ", err)
		return err
	}
	log.Info("Populated VIS DB traffic load table")

	// Initialize service
	processActiveScenarioUpdate()
@@ -289,3 +296,13 @@ func processActiveScenarioUpdate() {
		}
	}
}

func populatePoaTable() (err error) {
	poaNameList := sbi.activeModel.GetNodeNames(mod.NodeTypePoa4G, mod.NodeTypePoa5G, mod.NodeTypePoaWifi, mod.NodeTypePoa)
	err = sbi.trafficMgr.PopulateStaticPoaLoad(poaNameList)
	if err != nil {
		log.Error(err.Error())
		return err
	}
	return nil
}
+51 −1
Original line number Diff line number Diff line
@@ -459,7 +459,7 @@ func (tm *TrafficMgr) CreatePoaLoad(poaName string, category string) (err error)
	query := `INSERT INTO ` + TrafficTable +
		` (poa_name, category, "0000-0300", "0300-0600", "0600-0900", "0900-1200", "1200-1500", "1500-1800", "1800-2100", "2100-2400")
			VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)`
	_, err = tm.db.Exec(query, poaName, category, loadTime[0:8])
	_, err = tm.db.Exec(query, poaName, category, loadTime[0], loadTime[1], loadTime[2], loadTime[3], loadTime[4], loadTime[5], loadTime[6], loadTime[7])
	if err != nil {
		log.Error(err.Error())
		return err
@@ -618,3 +618,53 @@ func (tm *TrafficMgr) PopulateCategoryTable() (err error) {
	}
	return nil
}

// PopulateStaticPoaLoad - Populate the Traffic Load table with static data
func (tm *TrafficMgr) PopulateStaticPoaLoad(poaMap []string) (err error) {
	var poaCategoryMap = map[string]string{
		"4g-macro-cell-6":  "commercial",
		"4g-macro-cell-7":  "commercial",
		"5g-small-cell-4":  "commercial",
		"5g-small-cell-5":  "commercial",
		"5g-small-cell-6":  "commercial",
		"5g-small-cell-7":  "commercial",
		"5g-small-cell-10": "commercial",
		"5g-small-cell-11": "commercial",
		"5g-small-cell-12": "commercial",
		"4g-macro-cell-1":  "residential",
		"4g-macro-cell-2":  "residential",
		"4g-macro-cell-3":  "residential",
		"4g-macro-cell-4":  "residential",
		"4g-macro-cell-5":  "residential",
		"4g-macro-cell-8":  "residential",
		"4g-macro-cell-9":  "residential",
		"5g-small-cell-1":  "residential",
		"5g-small-cell-2":  "residential",
		"5g-small-cell-3":  "residential",
		"5g-small-cell-8":  "residential",
		"5g-small-cell-9":  "residential",
		"5g-small-cell-13": "residential",
		"5g-small-cell-14": "residential",
		"5g-small-cell-15": "residential",
		"4g-macro-cell-10": "beach",
		"5g-small-cell-16": "beach",
		"5g-small-cell-17": "beach",
		"5g-small-cell-18": "beach",
		"5g-small-cell-19": "beach",
		"5g-small-cell-20": "beach",
	}

	for _, poaName := range poaMap {
		for poa, category := range poaCategoryMap {
			if poa == poaName {
				err = tm.CreatePoaLoad(poaName, category)
				if err != nil {
					log.Error(err.Error())
					return err
				}
			}
		}
	}

	return nil
}