Commit 685e3120 authored by M. Rehan Abbasi's avatar M. Rehan Abbasi
Browse files

initialize scenario before populating traffic load table

parent 229d7e2e
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ func Init(cfg SbiCfg) (err error) {
	// Connect to GIS cache
	sbi.gisCache, err = gc.NewGisCache(sbi.sandboxName, cfg.RedisAddr)
	if err != nil {
		log.Error("Failed to GIS Cache: ", err.Error())
		log.Error("Failed to connect to GIS Cache: ", err.Error())
		return err
	}
	log.Info("Connected to GIS Cache")
@@ -156,7 +156,7 @@ func Init(cfg SbiCfg) (err error) {
	}
	log.Info("Created new VIS DB tables")

	// Populate VIS DB Tables
	// Populate VIS DB Categories Table
	err = sbi.trafficMgr.PopulateCategoryTable()
	if err != nil {
		log.Error("Failed to populate categories table: ", err)
@@ -164,6 +164,10 @@ func Init(cfg SbiCfg) (err error) {
	}
	log.Info("Populated VIS DB categories table")

	// Initialize service
	processActiveScenarioUpdate()

	// Populate VIS DB Traffic Load Table
	err = populatePoaTable()
	if err != nil {
		log.Error("Failed to populate traffic load table: ", err)
@@ -171,9 +175,6 @@ func Init(cfg SbiCfg) (err error) {
	}
	log.Info("Populated VIS DB traffic load table")

	// Initialize service
	processActiveScenarioUpdate()

	return nil
}

@@ -298,7 +299,7 @@ func processActiveScenarioUpdate() {
}

func populatePoaTable() (err error) {
	poaNameList := sbi.activeModel.GetNodeNames(mod.NodeTypePoa4G, mod.NodeTypePoa5G, mod.NodeTypePoaWifi, mod.NodeTypePoa)
	poaNameList := sbi.activeModel.GetNodeNames(mod.NodeTypePoa4G, mod.NodeTypePoa5G)
	err = sbi.trafficMgr.PopulateStaticPoaLoad(poaNameList)
	if err != nil {
		log.Error(err.Error())
+4 −4
Original line number Diff line number Diff line
@@ -418,7 +418,7 @@ func (tm *TrafficMgr) CreateCategoryLoad(category string, data map[string]int32)

	if profiling {
		now := time.Now()
		log.Debug("CreatePoaLoad: ", now.Sub(profilingTimers["CreatePoaLoad"]))
		log.Debug("CreateCategoryLoad: ", now.Sub(profilingTimers["CreateCategoryLoad"]))
	}
	return nil
}
@@ -458,7 +458,7 @@ func (tm *TrafficMgr) CreatePoaLoad(poaName string, category string) (err error)
	// Create Traffic Load entry
	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)`
			VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`
	_, 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())
@@ -620,7 +620,7 @@ func (tm *TrafficMgr) PopulateCategoryTable() (err error) {
}

// PopulateStaticPoaLoad - Populate the Traffic Load table with static data
func (tm *TrafficMgr) PopulateStaticPoaLoad(poaMap []string) (err error) {
func (tm *TrafficMgr) PopulateStaticPoaLoad(poaNameList []string) (err error) {
	var poaCategoryMap = map[string]string{
		"4g-macro-cell-6":  "commercial",
		"4g-macro-cell-7":  "commercial",
@@ -654,7 +654,7 @@ func (tm *TrafficMgr) PopulateStaticPoaLoad(poaMap []string) (err error) {
		"5g-small-cell-20": "beach",
	}

	for _, poaName := range poaMap {
	for _, poaName := range poaNameList {
		for poa, category := range poaCategoryMap {
			if poa == poaName {
				err = tm.CreatePoaLoad(poaName, category)