3 #include <e2sm/wrapper.h>
\r
4 #cgo LDFLAGS: -lm -le2smwrapper
\r
5 #cgo CFLAGS: -I/usr/local/include/e2sm
\r
18 // "encoding/binary"
\r
25 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/clientmodel"
\r
26 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
\r
27 influxdb2 "github.com/influxdata/influxdb-client-go"
\r
30 type Control struct {
\r
31 RMR chan *xapp.RMRParams //channel for receiving rmr message
\r
32 client influxdb2.Client //client for influxdb
\r
36 timeToWait = "w10ms"
\r
37 subsequentActionType = "continue"
\r
38 actionType = "report"
\r
44 clientEndpoint = clientmodel.SubscriptionParamsClientEndpoint{Host: "service-ricxapp-kpimon-go-http.ricxapp", HTTPPort: &hPort, RMRPort: &rPort}
\r
46 var Glob_cell = make(map[string]bool)
\r
47 var Glob_Ran_cell = make(map[string][]string)
\r
48 var Glob_cell_Plmn = make(map[string]string)
\r
49 var ranUeKpi = make(map[string][]string)
\r
50 var ranCellKpi = make(map[string][]string)
\r
51 func (c Control) Consume(msg *xapp.RMRParams) error {
\r
52 id := xapp.Rmr.GetRicMessageName(msg.Mtype)
\r
54 "Message received: name=%s meid=%s subId=%d txid=%s len=%d",
\r
65 func NewControl() Control {
\r
66 xapp.Logger.Info("In new control\n")
\r
68 xapp.Logger.Info("returning control\n")
\r
70 make(chan *xapp.RMRParams),
\r
71 influxdb2.NewClient("http://ricplt-influxdb.ricplt:8086", "client"),
\r
75 //Create a database named kpimon in influxDB
\r
76 xapp.Logger.Info("In create_db\n")
\r
77 _, err := http.Post("http://ricplt-influxdb.ricplt:8086/query?q=create%20database%20kpimon", "", nil)
\r
79 xapp.Logger.Error("Create database failed!")
\r
81 xapp.Logger.Info("exiting create_db\n")
\r
84 func (c Control) getEnbList() ([]*xapp.RNIBNbIdentity, error) {
\r
85 enbs, err := xapp.Rnib.GetListEnbIds()
\r
87 xapp.Logger.Error("err: %s", err)
\r
91 xapp.Logger.Info("List for connected eNBs :")
\r
92 for index, enb := range enbs {
\r
93 xapp.Logger.Info("%d. enbid: %s", index+1, enb.InventoryName)
\r
98 func (c *Control) getGnbList() ([]*xapp.RNIBNbIdentity, error) {
\r
99 gnbs, err := xapp.Rnib.GetListGnbIds()
\r
102 xapp.Logger.Error("err: %s", err)
\r
105 xapp.Logger.Info("List of connected gNBs :")
\r
106 for index, gnb := range gnbs {
\r
107 xapp.Logger.Info("%d. gnbid : %s", index+1, gnb.InventoryName)
\r
112 func (c *Control) getnbList() []*xapp.RNIBNbIdentity {
\r
113 //Get all GnodeB and EnodeB connected to RIC
\r
114 var nbs []*xapp.RNIBNbIdentity
\r
116 if enbs, err := c.getEnbList(); err == nil {
\r
117 nbs = append(nbs, enbs...)
\r
120 if gnbs, err := c.getGnbList(); err == nil {
\r
121 nbs = append(nbs, gnbs...)
\r
126 func cellid_to_list_of_int(str string) []int64 {
\r
129 for i := 0; i < l; i += 2 {
\r
130 output, err := strconv.ParseInt(str[i:i+2], 16, 64)
\r
135 ans = append(ans, output)
\r
139 func plmnid_to_list_of_int(str string) []int64 {
\r
142 for i := 0; i < l; i += 2 {
\r
143 output, err := strconv.ParseInt(str[i:i+2], 16, 64)
\r
148 ans = append(ans, output)
\r
152 func encode_action_format1(plmn string, cellid string, meid string) clientmodel.ActionDefinition {
\r
153 lol1 := plmnid_to_list_of_int(plmn)
\r
154 lol2 := cellid_to_list_of_int(cellid)
\r
155 var format1 []int64
\r
156 //format1=[]int64{0,1,1,8,0,19,32,0,3,1,32,0,0,32,0,4,1,32,0,0,32,0,78,1,32,0,0,32,0,79,1,32,0,0,32,0,8,1,32,0,0,32,0,7,1,32,0,0,32,0,11,1,32,0,0,32,0,12,1,32,0,0,32,0,80,1,32,0,0,32,0,81,1,32,0,0,32,0,13,1,32,0,0,32,0,14,1,32,0,0,32,0,40,1,32,0,0,32,0,41,1,32,0,0,32,0,42,1,32,0,0,32,0,82,1,32,0,0,32,0,83,1,32,0,0,32,0,84,1,32,0,0,32,0,85,1,32,0,0,32,0,86,1,32,0,0,64,39,15,0,0,31,1,18,52,92,0,16}
\r
157 //0(nr) 1(eutra) 0,31,1(plmn)18,52,92,0,16(cellid)
\r
158 link:="http://service-ricplt-e2mgr-http.ricplt.svc.cluster.local:3800/v1/nodeb/"
\r
161 tmpr,err := http.Get(link)
\r
167 defer tmpr.Body.Close()
\r
168 var resp E2mgrResponse
\r
170 err=json.NewDecoder(tmpr.Body).Decode(&resp)
\r
178 //RanFunctionId=2 for kpm in viavi
\r
179 for i := 0; i < len(resp.Gnb.RanFunctions); i++ {
\r
180 if resp.Gnb.RanFunctions[i].RanFunctionId == 2 {
\r
185 cString := C.CString(resp.Gnb.RanFunctions[counter].RanFunctionDefinition)
\r
186 defer C.free(unsafe.Pointer(cString)) // Free the allocated C string when done
\r
187 // Call the C function
\r
188 determine := 2 //2 for format1 by name
\r
189 result:=C.encode_action_Definition(cString, C.int(determine))
\r
191 for i := 0; i < int(result.length); i++ {
\r
192 value := int64(*(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(result.array)) + uintptr(i*4))))
\r
193 format1 = append(format1, value)
\r
195 format1 = append(format1, lol1...) //appending plmn
\r
196 format1 = append(format1, lol2...) //appending cellid
\r
200 func encode_action_format2() clientmodel.ActionDefinition{
\r
201 var format2 []int64
\r
202 format2 = []int64{0, 1, 0, 0, 0, 20, 0, 160, 68, 82, 66, 46, 85, 69, 84, 104, 112, 68, 108, 1, 0, 0, 0, 1, 64, 68, 82, 66, 46, 85, 69, 84, 104, 112, 85, 108, 1, 0, 0, 0, 1, 0, 71, 78, 66, 45, 68, 85, 45, 73, 68, 1, 0, 0, 0, 0, 160, 78, 82, 45, 67, 71, 73, 1, 0, 0, 0, 0, 160, 78, 82, 45, 80, 67, 73, 1, 0, 0, 0, 2, 192, 81, 111, 115, 70, 108, 111, 119, 46, 80, 100, 99, 112, 80, 100, 117, 86, 111, 108, 117, 109, 101, 68, 108, 1, 0, 0, 0, 2, 192, 81, 111, 115, 70, 108, 111, 119, 46, 80, 100, 99, 112, 80, 100, 117, 86, 111, 108, 117, 109, 101, 85, 108, 1, 0, 0, 0, 1, 64, 82, 82, 67, 46, 67, 111, 110, 110, 77, 97, 120, 1, 0, 0, 0, 1, 96, 82, 82, 67, 46, 67, 111, 110, 110, 77, 101, 97, 110, 1, 0, 0, 0, 1, 160, 82, 82, 85, 46, 80, 114, 98, 65, 118, 97, 105, 108, 68, 108, 1, 0, 0, 0, 1, 160, 82, 82, 85, 46, 80, 114, 98, 65, 118, 97, 105, 108, 85, 108, 1, 0, 0, 0, 1, 32, 82, 82, 85, 46, 80, 114, 98, 84, 111, 116, 1, 0, 0, 0, 1, 96, 82, 82, 85, 46, 80, 114, 98, 84, 111, 116, 68, 108, 1, 0, 0, 0, 1, 96, 82, 82, 85, 46, 80, 114, 98, 84, 111, 116, 85, 108, 1, 0, 0, 0, 1, 128, 82, 82, 85, 46, 80, 114, 98, 85, 115, 101, 100, 68, 108, 1, 0, 0, 0, 1, 128, 82, 82, 85, 46, 80, 114, 98, 85, 115, 101, 100, 85, 108, 1, 0, 0, 0, 1, 64, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 120, 1, 0, 0, 0, 1, 64, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 121, 1, 0, 0, 0, 1, 64, 86, 105, 97, 118, 105, 46, 71, 101, 111, 46, 122, 1, 0, 0, 0, 2, 0, 86, 105, 97, 118, 105, 46, 82, 97, 100, 105, 111, 46, 112, 111, 119, 101, 114, 1, 0, 0, 0, 2, 64, 86, 105, 97, 118, 105, 46, 82, 97, 100, 105, 111, 46, 115, 101, 99, 116, 111, 114, 115, 1, 0, 0, 0, 0, 0}
\r
203 //encode the variable part and append it to our array.
\r
204 format2 = append(format2, 89) //appending variable part if necessory
\r
208 func encode_action_format3(meid string) clientmodel.ActionDefinition {
\r
209 var format3 []int64
\r
211 //for simulation-by measId(not supported in Viavi 1.4)
\r
212 //format3=[]int64{0,1,3,64,0,29,32,0,90,0,0,16,0,0,16,0,91,0,0,16,0,0,16,0,3,0,0,16,0,0,16,0,4,0,0,16,0,0,16,0,80,0,0,16,0,0,16,0,13,0,0,16,0,0,16,0,14,0,0,16,0,0,16,0,92,0,0,16,0,0,16,0,93,0,0,16,0,0,16,0,44,0,0,16,0,0,16,0,40,0,0,16,0,0,16,0,41,0,0,16,0,0,16,0,42,0,0,16,0,0,16,0,94,0,0,16,0,0,16,0,95,0,0,16,0,0,16,0,96,0,0,16,0,0,16,0,97,0,0,16,0,0,16,0,45,0,0,16,0,0,16,0,98,0,0,16,0,0,16,0,99,0,0,16,0,0,16,0,100,0,0,16,0,0,16,0,101,0,0,16,0,0,16,0,102,0,0,16,0,0,16,0,103,0,0,16,0,0,16,0,104,0,0,16,0,0,16,0,43,0,0,16,0,0,16,0,105,0,0,16,0,0,16,0,106,0,0,16,0,0,16,0,107,0,0,16,0,0,16,0,108,0,0,16,0,0,32,39,15}
\r
213 //variable part is not presetnt in action def format 3
\r
215 link:="http://service-ricplt-e2mgr-http.ricplt.svc.cluster.local:3800/v1/nodeb/"
\r
217 tmpr,err := http.Get(link)
\r
224 defer tmpr.Body.Close()
\r
225 var resp E2mgrResponse
\r
227 err=json.NewDecoder(tmpr.Body).Decode(&resp)
\r
235 //RanFunctionId=2 for kpm in viavi
\r
236 for i := 0; i < len(resp.Gnb.RanFunctions); i++ {
\r
237 if resp.Gnb.RanFunctions[i].RanFunctionId == 2 {
\r
242 cString := C.CString(resp.Gnb.RanFunctions[counter].RanFunctionDefinition)
\r
243 defer C.free(unsafe.Pointer(cString)) // Free the allocated C string when done
\r
244 // Call the C function
\r
245 determine := 4 //2 for format1 by name
\r
247 result:=C.encode_action_Definition(cString, C.int(determine))
\r
248 for i := 0; i < int(result.length); i++ {
\r
249 value := int64(*(*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(result.array)) + uintptr(i*4))))
\r
250 format3 = append(format3, value)
\r
255 //variable part is not presetnt in action def format 3
\r
258 func encode_actionsToBeSetup(meid string) clientmodel.ActionsToBeSetup {
\r
259 var l clientmodel.ActionsToBeSetup
\r
261 link:="http://service-ricplt-e2mgr-http.ricplt.svc.cluster.local:3800/v1/nodeb/"
\r
263 tmpr,err := http.Get(link)
\r
268 defer tmpr.Body.Close()
\r
269 var resp E2mgrResponse
\r
271 err=json.NewDecoder(tmpr.Body).Decode(&resp)
\r
279 for i := 0; i < len(resp.Gnb.NodeConfigs); i++ {
\r
280 if resp.Gnb.NodeConfigs[i].E2nodeComponentInterfaceType == "f1" {
\r
285 tm := resp.Gnb.NodeConfigs[counter].E2nodeComponentRequestPart
\r
286 base64Text := make([]byte, base64.StdEncoding.DecodedLen(len(tm)))
\r
287 nl, _ := base64.StdEncoding.Decode(base64Text, []byte(tm))
\r
288 message := string(base64Text[:nl])
\r
291 for i := 0; i < len(meid); i++ {
\r
292 if meid[i] == '_' {
\r
301 ans := strings.ToUpper(meid[counter:len(meid)])
\r
302 l1 := int64(len(message))
\r
303 l2 := int64(len(ans))
\r
305 for i := int64(0); i <= l1-l2; i++ {
\r
306 if strings.Contains(message[i:i+l2], ans) {
\r
307 Glob_cell[message[i:i+10]]=true
\r
308 cells = append(cells, message[i:i+10])
\r
309 fmt.Println(message[i : i+10])
\r
315 cells:=Glob_Ran_cell[meid]
\r
316 //fmt.Println("len of Tonga cells= ",len(cells))
\r
317 //fmt.Println("Tonga cells = ", cells)
\r
318 //fmt.Println("Tonga = ", Glob_Ran_cell)
\r
320 var tempCells []string
\r
321 for _, ele:=range cells{
\r
323 tempCells =append(tempCells,ele)
\r
326 //fmt.Println("len of Tonga tmep cells= ",len(tempCells))
\r
327 //fmt.Println("Tonga temp cells = ", tempCells)
\r
329 //var ue int64 = 1 //get no of ue connected to du(if required)
\r
332 for n <= int64(len(tempCells)) {
\r
333 //fix double length issue/empty cell sting in Glob_Ran_cell map
\r
335 var lol *int64 = &tmp
\r
336 s := clientmodel.ActionToBeSetup{
\r
338 ActionType: &actionType,
\r
339 ActionDefinition: encode_action_format1(Glob_cell_Plmn[tempCells[n-1]], tempCells[n-1],meid),
\r
340 SubsequentAction: &clientmodel.SubsequentAction{
\r
341 SubsequentActionType: &subsequentActionType,
\r
342 TimeToWait: &timeToWait,
\r
349 var tmp_act_id int64 = n
\r
352 // for action def 2
\r
354 var tmp int64 = tmp_act_id
\r
355 var lol *int64 = &tmp
\r
356 s := clientmodel.ActionToBeSetup{
\r
358 ActionType: &actionType,
\r
359 ActionDefinition: encode_action_format2(),
\r
360 SubsequentAction: &clientmodel.SubsequentAction{
\r
361 SubsequentActionType: &subsequentActionType,
\r
362 TimeToWait: &timeToWait,
\r
366 tmp_act_id = tmp_act_id + 1
\r
372 var tmp int64 = tmp_act_id
\r
373 var lol *int64 = &tmp
\r
374 s := clientmodel.ActionToBeSetup{
\r
376 ActionType: &actionType,
\r
377 ActionDefinition: encode_action_format3(meid),
\r
378 SubsequentAction: &clientmodel.SubsequentAction{
\r
379 SubsequentActionType: &subsequentActionType,
\r
380 TimeToWait: &timeToWait,
\r
388 func (c Control) sendSubscription(meid string) {
\r
389 //Create Subscription message and send it to RIC platform
\r
390 xapp.Logger.Info("Sending subscription request for MEID: %v", meid)
\r
392 subscritionParams := clientmodel.SubscriptionParams{
\r
393 ClientEndpoint: &clientEndpoint,
\r
395 RANFunctionID: &funcId,
\r
396 SubscriptionDetails: clientmodel.SubscriptionDetailsList{
\r
397 &clientmodel.SubscriptionDetail{
\r
398 EventTriggers: clientmodel.EventTriggerDefinition{
\r
401 XappEventInstanceID: &seqId,
\r
402 ActionToBeSetupList: clientmodel.ActionsToBeSetup{
\r
403 &clientmodel.ActionToBeSetup{
\r
404 ActionID: &actionId,
\r
405 ActionType: &actionType,
\r
406 ActionDefinition: clientmodel.ActionDefinition{
\r
409 SubsequentAction: &clientmodel.SubsequentAction{
\r
410 SubsequentActionType: &subsequentActionType,
\r
411 TimeToWait: &timeToWait,
\r
420 //8,39,15, for 10000 ms reporting period
\r
421 subscritionParams := clientmodel.SubscriptionParams{
\r
422 ClientEndpoint: &clientEndpoint,
\r
424 RANFunctionID: &funcId,
\r
425 SubscriptionDetails: clientmodel.SubscriptionDetailsList{
\r
426 &clientmodel.SubscriptionDetail{
\r
427 EventTriggers: clientmodel.EventTriggerDefinition{
\r
430 XappEventInstanceID: &seqId,
\r
431 ActionToBeSetupList: encode_actionsToBeSetup(meid),
\r
436 b, err := json.MarshalIndent(subscritionParams, "", " ")
\r
438 xapp.Logger.Error("Json marshaling failed: %v", err)
\r
440 xapp.Logger.Info("*****body: %s", string(b))
\r
442 resp, err := xapp.Subscription.Subscribe(&subscritionParams)
\r
444 xapp.Logger.Error("Subscription (%s) failed with error: %s", meid, err)
\r
447 xapp.Logger.Info("Successfully subscription done (%s), subscriptrion id: %s", meid, *resp.SubscriptionID)
\r
450 func Test() (err error) {
\r
454 //indicationMsg, err := e2ap.GetIndicationMessage(params.Payload)
\r
455 indicationMsg, err := e2ap.GetIndicationM()
\r
458 xapp.Logger.Error("Failed to decode RIC Indication message: %v", err)
\r
462 //log.Printf("RIC Indication message from {%s} received", params.Meid.RanName)
\r
464 indicationHdr, err := e2sm.GetIndicationHeader(indicationMsg.IndHeader)
\r
466 xapp.Logger.Error("Failed to decode RIC Indication Header: %v", err)
\r
471 //Decoding message and put information into log
\r
472 log.Printf("-----------RIC Indication Header-----------")
\r
473 log.Printf("indicationMsg.IndHeader= %x", indicationMsg.IndHeader)
\r
475 buf := new(bytes.Buffer) //create my buffer
\r
476 binary.Write(buf, binary.LittleEndian, indicationMsg.IndHeader)
\r
477 log.Printf("binary Write buf= %x",buf )
\r
479 //str := buf.String()
\r
480 //log.Printf(" buf Strin()= %s",str )
\r
481 //cptr1:= unsafe.Pointer(C.CString(str))
\r
482 cptr1:= unsafe.Pointer(&b[0])
\r
483 defer C.free(cptr1)
\r
485 cptr1 := unsafe.Pointer(&indicationMsg.IndHeader[0])
\r
486 decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(len(indicationMsg.IndHeader)))
\r
487 //decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(len(str)))
\r
488 //decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(buf.Len()))
\r
489 if decodedHdr == nil {
\r
490 return errors.New("e2sm wrapper is unable to get IndicationHeader due to wrong or invalid input")
\r
492 defer C.e2sm_free_ric_indication_header(decodedHdr)
\r
493 IndHdrType := int32(decodedHdr.indicationHeader_formats.present)
\r
495 log.Printf("No Indication Header present")
\r
498 log.Printf("Indication Header format = %d",IndHdrType)
\r
499 indHdrFormat1_C := *(**C.E2SM_KPM_IndicationHeader_Format1_t)(unsafe.Pointer(&decodedHdr.indicationHeader_formats.choice[0]))
\r
500 //senderName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderName))
\r
501 senderName_C:=indHdrFormat1_C.senderName
\r
502 var senderName []byte
\r
503 senderName = C.GoBytes(unsafe.Pointer(senderName_C.buf), C.int(senderName_C.size))
\r
504 log.Printf("Sender Name = %x",senderName)
\r
506 //senderType_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderType))
\r
507 senderType_C :=indHdrFormat1_C.senderType
\r
508 //senderType []byte
\r
509 senderType := C.GoBytes(unsafe.Pointer(senderType_C.buf), C.int(senderType_C.size))
\r
510 log.Printf("Sender Type = %x",senderType)
\r
512 //vendorName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.vendorName))
\r
513 vendorName_C :=indHdrFormat1_C.vendorName
\r
514 //vendorName []byte
\r
515 vendorName := C.GoBytes(unsafe.Pointer(vendorName_C.buf), C.int(vendorName_C.size))
\r
516 log.Printf("Vendor Name = %x",vendorName)
\r
522 indMsg, err := e2sm.GetIndicationMessage(indicationMsg.IndMessage)
\r
524 xapp.Logger.Error("Failed to decode RIC Indication Message: %v", err)
\r
528 log.Printf("-----------RIC Indication Message-----------")
\r
529 log.Printf("indicationMsg.IndMessage= %x",indicationMsg.IndMessage)
\r
530 cptr2 := unsafe.Pointer(&indicationMsg.IndMessage[0])
\r
531 indicationmessage := C.e2sm_decode_ric_indication_message(cptr2, C.size_t(len(indicationMsg.IndMessage)))
\r
532 if indicationmessage == nil {
\r
533 return errors.New("e2sm wrapper is unable to get IndicationMessage due to wrong or invalid input")
\r
535 defer C.e2sm_free_ric_indication_message(indicationmessage)
\r
536 IndMsgType := int32(indicationmessage.indicationMessage_formats.present)
\r
537 if IndMsgType==1 {//parsing cell metrics
\r
538 fmt.Printf(" parsing for cell metrics\n" )
\r
539 indMsgFormat1_C := *(**C.E2SM_KPM_IndicationMessage_Format1_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))
\r
540 no_of_cell:=int32(indMsgFormat1_C .measData.list.count)
\r
541 fmt.Printf(" \n No of cell = %d\n",no_of_cell )
\r
542 //fmt.Println(no_of_cell)
\r
543 for n := int32(0); n < no_of_cell; n++ {
\r
544 var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t
\r
545 MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat1_C.measData.list.array)) + (uintptr)(int(n))*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))
\r
546 no_of_cell_metrics:=int32(MeasurementDataItem_C.measRecord.list.count)
\r
547 var CellM CellMetricsEntry
\r
548 v := reflect.ValueOf(CellM)
\r
549 fmt.Printf(" \n No of cell metrics = %d\n",no_of_cell_metrics)
\r
550 values := make(map[string]interface{}, v.NumField())
\r
551 //assert no_of_cell_metrics == v.NumField() they both should be equal.
\r
552 for i := int32(0); i < no_of_cell_metrics; i++ {
\r
554 if v.Field(int(i)).CanInterface() {
\r
555 var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t
\r
556 MeasurementRecordItem_C:=*(**C. MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(int(i))*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))
\r
557 type_var:=int(MeasurementRecordItem_C.present)
\r
559 var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))
\r
560 values[v.Type().Field(int(i)).Name]=int32(*cast_integer)
\r
561 }else if type_var==2{
\r
562 var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))
\r
563 values[v.Type().Field(int(i)).Name]=float64(*cast_float)
\r
565 fmt.Printf("Wrong Data Type")
\r
569 fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)
\r
571 }//end of inner for loop
\r
574 fmt.Println(values)
\r
575 fmt.Printf("Parsing Cell Metric Done")
\r
576 //c.writeCellMetrics_db(&values)//push cellmetrics map entry to database.
\r
577 }//end of outer for loop
\r
578 //end of if IndMsgType==1 , parsing cell metrics done
\r
580 } else if IndMsgType==2 { //parsing ue metrics
\r
582 fmt.Printf(" parsing for UE metrics" )
\r
583 indMsgFormat2_C := *(**C.E2SM_KPM_IndicationMessage_Format2_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))
\r
584 no_of_ue_metrics:=int32(indMsgFormat2_C .measData.list.count)
\r
585 fmt.Printf(" \n No of ue metrics = %d\n",no_of_ue_metrics)
\r
587 var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t
\r
588 MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(0)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))
\r
590 no_of_ue:=int32(MeasurementDataItem_C.measRecord.list.count)
\r
591 fmt.Printf(" \n No of ue= %d\n",no_of_ue)
\r
592 for n := int32(0); n < no_of_ue; n++ {
\r
593 var UeM UeMetricsEntry
\r
594 v := reflect.ValueOf(UeM)
\r
595 values := make(map[string]interface{}, v.NumField())
\r
596 //assert no_of_ue_metrics == v.NumField() they both should be equal.
\r
597 for i := int32(0); i < no_of_ue_metrics; i++ {
\r
599 if v.Field(int(i)).CanInterface() {
\r
601 var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t
\r
602 MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(i)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))
\r
603 var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t
\r
604 MeasurementRecordItem_C:=*(**C.MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(n)*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))
\r
606 type_var:=int(MeasurementRecordItem_C.present)
\r
608 var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))
\r
609 values[v.Type().Field(int(i)).Name]=int32(*cast_integer)
\r
610 }else if type_var==2{
\r
611 var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))
\r
612 values[v.Type().Field(int(i)).Name]=float64(*cast_float)
\r
615 fmt.Printf("Wrong Data Type")
\r
619 fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)
\r
623 } //end of inner for loop
\r
624 fmt.Println(values)
\r
625 fmt.Printf("Parsing UE Metric Done")
\r
626 //c.writeUeMetrics_db(&values)//push UEmetrics map entry to database.
\r
628 }// end of outer for loop
\r
629 //parsing ue metrics done
\r
631 fmt.Printf(" Invalid Indication message format" )
\r
639 func (c *Control) controlLoop() {
\r
640 //Handle receiving message based on message type
\r
643 xapp.Logger.Debug("Received message type: %d", msg.Mtype)
\r
645 case xapp.RIC_INDICATION:
\r
646 go c.handleIndication(msg)
\r
648 xapp.Logger.Error("Unknown Message Type '%d', discarding", msg.Mtype)
\r
652 func (c *Control) handleIndication(params *xapp.RMRParams) (err error) {
\r
656 indicationMsg, err := e2ap.GetIndicationMessage(params.Payload)
\r
658 xapp.Logger.Error("Failed to decode RIC Indication message: %v", err)
\r
662 log.Printf("RIC Indication message from {%s} received", params.Meid.RanName)
\r
664 indicationHdr, err := e2sm.GetIndicationHeader(indicationMsg.IndHeader)
\r
666 xapp.Logger.Error("Failed to decode RIC Indication Header: %v", err)
\r
671 //Decoding message and put information into log
\r
672 //log.Printf("-----------RIC Indication Header-----------")
\r
673 //log.Printf("indicationMsg.IndHeader= %x", indicationMsg.IndHeader)
\r
675 buf := new(bytes.Buffer) //create my buffer
\r
676 binary.Write(buf, binary.LittleEndian, indicationMsg.IndHeader)
\r
677 log.Printf("binary Write buf= %x",buf )
\r
679 //str := buf.String()
\r
680 //log.Printf(" buf Strin()= %s",str )
\r
681 //cptr1:= unsafe.Pointer(C.CString(str))
\r
682 cptr1:= unsafe.Pointer(&b[0])
\r
683 defer C.free(cptr1)
\r
685 cptr1 := unsafe.Pointer(&indicationMsg.IndHeader[0])
\r
686 decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(len(indicationMsg.IndHeader)))
\r
687 //decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(len(str)))
\r
688 //decodedHdr := C.e2sm_decode_ric_indication_header(cptr1, C.size_t(buf.Len()))
\r
689 if decodedHdr == nil {
\r
690 return errors.New("e2sm wrapper is unable to get IndicationHeader due to wrong or invalid input")
\r
692 defer C.e2sm_free_ric_indication_header(decodedHdr)
\r
693 IndHdrType := int32(decodedHdr.indicationHeader_formats.present)
\r
695 log.Printf("No Indication Header present")
\r
698 log.Printf("Indication Header format = %d",IndHdrType)
\r
700 indHdrFormat1_C := *(**C.E2SM_KPM_IndicationHeader_Format1_t)(unsafe.Pointer(&decodedHdr.indicationHeader_formats.choice[0]))
\r
701 //senderName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderName))
\r
702 senderName_C:=indHdrFormat1_C.senderName
\r
703 var senderName []byte
\r
704 senderName = C.GoBytes(unsafe.Pointer(senderName_C.buf), C.int(senderName_C.size))
\r
705 //log.Printf("Sender Name = %x",senderName)
\r
707 //senderType_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.senderType))
\r
708 senderType_C :=indHdrFormat1_C.senderType
\r
709 //senderType []byte
\r
710 senderType := C.GoBytes(unsafe.Pointer(senderType_C.buf), C.int(senderType_C.size))
\r
711 //log.Printf("Sender Type = %x",senderType)
\r
713 //vendorName_C := (*C.PrintableString_t)(unsafe.Pointer(indHdrFormat1_C.vendorName))
\r
714 vendorName_C :=indHdrFormat1_C.vendorName
\r
715 //vendorName []byte
\r
716 vendorName := C.GoBytes(unsafe.Pointer(vendorName_C.buf), C.int(vendorName_C.size))
\r
717 //log.Printf("Vendor Name = %x",vendorName)
\r
723 indMsg, err := e2sm.GetIndicationMessage(indicationMsg.IndMessage)
\r
725 xapp.Logger.Error("Failed to decode RIC Indication Message: %v", err)
\r
729 //log.Printf("-----------RIC Indication Message-----------")
\r
730 //log.Printf("indicationMsg.IndMessage= %x",indicationMsg.IndMessage)
\r
731 cptr2 := unsafe.Pointer(&indicationMsg.IndMessage[0])
\r
732 indicationmessage := C.e2sm_decode_ric_indication_message(cptr2, C.size_t(len(indicationMsg.IndMessage)))
\r
733 if indicationmessage == nil {
\r
734 return errors.New("e2sm wrapper is unable to get IndicationMessage due to wrong or invalid input")
\r
736 defer C.e2sm_free_ric_indication_message(indicationmessage)
\r
737 IndMsgType := int32(indicationmessage.indicationMessage_formats.present)
\r
738 if IndMsgType==1 {//parsing cell metrics
\r
739 fmt.Printf(" parsing for cell metrics\n" )
\r
740 indMsgFormat1_C := *(**C.E2SM_KPM_IndicationMessage_Format1_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))
\r
741 no_of_cell:=int32(indMsgFormat1_C .measData.list.count)
\r
742 fmt.Printf(" \n No of cell = %d\n",no_of_cell )
\r
743 //fmt.Println(no_of_cell)
\r
744 for n := int32(0); n < no_of_cell; n++ {
\r
745 var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t
\r
746 MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat1_C.measData.list.array)) + (uintptr)(int(n))*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))
\r
747 no_of_cell_metrics:=int32(MeasurementDataItem_C.measRecord.list.count)
\r
748 //var CellM CellMetricsEntry
\r
749 //v := reflect.ValueOf(CellM)
\r
750 fmt.Printf(" \n No of cell metrics = %d\n",no_of_cell_metrics)
\r
751 //values := make(map[string]interface{}, v.NumField())
\r
752 values := make(map[string]interface{})
\r
753 CellKpi:=ranCellKpi[params.Meid.RanName]
\r
754 var tmpCellKpi []string
\r
755 for _, ele:=range CellKpi{
\r
757 tmpCellKpi =append(tmpCellKpi,ele)
\r
761 //assert no_of_cell_metrics == v.NumField() they both should be equal.
\r
762 if (int(no_of_cell_metrics) != len(tmpCellKpi)){
\r
763 log.Printf("no_of_cell_metrics != len(tmpCellKpi)")
\r
764 return errors.New("no_of_cell_metrics !=len(tmpCellKpi)")
\r
766 for i := int32(0); i < no_of_cell_metrics; i++ {
\r
768 //if v.Field(int(i)).CanInterface() {
\r
769 var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t
\r
770 MeasurementRecordItem_C:=*(**C. MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(int(i))*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))
\r
771 type_var:=int(MeasurementRecordItem_C.present)
\r
773 var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))
\r
774 //values[v.Type().Field(int(i)).Name]=int32(*cast_integer)
\r
775 values[tmpCellKpi[int(i)]]=int32(*cast_integer)
\r
776 }else if type_var==2{
\r
777 var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))
\r
778 //values[v.Type().Field(int(i)).Name]=float64(*cast_float)
\r
779 values[tmpCellKpi[int(i)]]=float64(*cast_float)
\r
781 fmt.Printf("Wrong Data Type")
\r
785 //fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)
\r
787 }//end of inner for loop
\r
790 fmt.Println(values)
\r
791 fmt.Printf("Parsing Cell Metric Done")
\r
792 c.writeCellMetrics_db(&values)//push cellmetrics map entry to database.
\r
793 }//end of outer for loop
\r
794 //end of if IndMsgType==1 , parsing cell metrics done
\r
796 } else if IndMsgType==2 { //parsing ue metrics
\r
798 fmt.Printf(" parsing for UE metrics" )
\r
799 indMsgFormat2_C := *(**C.E2SM_KPM_IndicationMessage_Format2_t)(unsafe.Pointer(&indicationmessage.indicationMessage_formats.choice[0]))
\r
800 //no_of_ue_metrics:=int32(indMsgFormat2_C .measData.list.count)
\r
801 //fmt.Printf(" \n No of ue metrics = %d\n",no_of_ue_metrics)
\r
803 var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t
\r
804 MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(0)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))
\r
805 UeKpi:=ranUeKpi[params.Meid.RanName]
\r
806 var tmpUeKpi []string
\r
807 for _, ele:=range UeKpi{
\r
809 tmpUeKpi =append(tmpUeKpi,ele)
\r
814 no_of_ue:=int32(MeasurementDataItem_C.measRecord.list.count)/int32(len(tmpUeKpi))
\r
815 no_of_ue_metrics:=int32(len(tmpUeKpi))
\r
816 fmt.Printf(" \n No of ue= %d\n",no_of_ue)
\r
818 for n := int32(0); n < no_of_ue; n++ {
\r
819 //var UeM UeMetricsEntry
\r
820 //v := reflect.ValueOf(UeM)
\r
821 //values := make(map[string]interface{}, v.NumField())
\r
822 values := make(map[string]interface{})
\r
823 //assert no_of_ue_metrics == v.NumField() they both should be equal.
\r
824 //if (int(no_of_ue_metrics) != v.NumField()){
\r
825 //log.Printf("no_of_ue_metrics != v.NumField()")
\r
826 //return errors.New("no_of_ue_metrics != v.NumField()")
\r
828 for i := int32(0); i < no_of_ue_metrics; i++ {
\r
830 //if v.Field(int(i)).CanInterface() {
\r
832 //var sizeof_MeasurementDataItem_t *C.MeasurementDataItem_t
\r
833 //MeasurementDataItem_C:=*(**C.MeasurementDataItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(indMsgFormat2_C.measData.list.array)) + (uintptr)(i)*unsafe.Sizeof(sizeof_MeasurementDataItem_t)))
\r
835 var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t
\r
836 MeasurementRecordItem_C:=*(**C.MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(n+(i*no_of_ue))*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))
\r
837 //var sizeof_MeasurementRecordItem_t *C.MeasurementRecordItem_t
\r
838 //MeasurementRecordItem_C:=*(**C.MeasurementRecordItem_t)(unsafe.Pointer(uintptr(unsafe.Pointer(MeasurementDataItem_C.measRecord.list.array)) + (uintptr)(n)*unsafe.Sizeof(sizeof_MeasurementRecordItem_t)))
\r
840 type_var:=int(MeasurementRecordItem_C.present)
\r
842 var cast_integer *C.long = (*C.long)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))
\r
843 values[tmpUeKpi[int(i)]]=int32(*cast_integer)
\r
844 }else if type_var==2{
\r
845 var cast_float *C.double = (*C.double)(unsafe.Pointer(&MeasurementRecordItem_C.choice[0]))
\r
846 values[tmpUeKpi[int(i)]]=float64(*cast_float)
\r
849 fmt.Printf("Wrong Data Type")
\r
853 // fmt.Printf("sorry you have a unexported field (lower case) value you are trying to sneak past. Can not allow it: %v\n", v.Type().Field(int(i)).Name)
\r
857 } //end of inner for loop
\r
858 fmt.Println(values)
\r
859 fmt.Printf("Parsing UE Metric Done")
\r
860 c.writeUeMetrics_db(&values)//push UEmetrics map entry to database.
\r
862 }// end of outer for loop
\r
863 //parsing ue metrics done
\r
865 fmt.Printf(" Invalid Indication message format" )
\r
875 // func (c *Control) writeUeMetrics_db(ueMetrics UeMetricsEntry) {
\r
876 // //Write metric to InfluxDB using API
\r
877 // writeAPI := c.client.WriteAPIBlocking("my-org", "kpimon")
\r
878 // ueMetricsJSON, err := json.Marshal(ueMetrics)
\r
880 // xapp.Logger.Error("Marshal UE Metrics failed!")
\r
882 // p := influxdb2.NewPointWithMeasurement("ricIndication_UeMetrics").
\r
883 // AddField("UE Metrics", ueMetricsJSON).
\r
884 // SetTime(time.Now())
\r
885 // writeAPI.WritePoint(context.Background(), p)
\r
886 // xapp.Logger.Info("Wrote UE Metrics to InfluxDB")
\r
889 // func (c *Control) writeCellMetrics_db(cellMetrics CellMetricsEntry) {
\r
890 // writeAPI := c.client.WriteAPIBlocking("my-org", "kpimon")
\r
891 // cellMetricsJSON, er := json.Marshal(cellMetrics)
\r
893 // xapp.Logger.Error("Marshal Cell Metrics failed!")
\r
895 // p := influxdb2.NewPointWithMeasurement("ricIndication_cellMetrics").
\r
896 // AddField("Cell Metrics", cellMetricsJSON).
\r
897 // SetTime(time.Now())
\r
898 // writeAPI.WritePoint(context.Background(), p)
\r
899 // xapp.Logger.Info("Wrote Cell Metrics to InfluxDB")
\r
903 func (c *Control) queryUEReports() {
\r
904 log.Printf("query UE")
\r
905 resp, err := http.Get("http://10.244.0.68/sba/influx/query?db=RIC-Test-static&q=select+*+from+UEReports")
\r
909 body, err := ioutil.ReadAll(resp.Body)
\r
913 var results ViaviMessages
\r
914 er := json.Unmarshal(body, &results)
\r
918 // sb := string(body)
\r
920 c.writeUeMetrics_db(results.results.series)
\r
923 func (c *Control) queryCellReports() {
\r
924 log.Printf("query cell")
\r
925 resp, err := http.Get("http://10.244.0.68/sba/influx/query?db=RIC-Test-static&q=select+*+from+CellReports")
\r
929 body, err := ioutil.ReadAll(resp.Body)
\r
933 var results ViaviMessages
\r
934 er := json.Unmarshal(body, &results)
\r
938 c.writeCellMetrics_db(results.results.series)
\r
941 func (c *Control) writeUeMetrics_db(ueMetrics *map[string]interface{}) {
\r
942 writeAPI := c.client.WriteAPIBlocking("my-org", "kpimon")
\r
944 ueMetricsJSON, err := json.Marshal(ueMetrics)
\r
946 xapp.Logger.Error("Marshal UE Metrics failed!")
\r
949 p := influxdb2.NewPointWithMeasurement("UeMetrics").
\r
950 AddField("UE Metrics", ueMetricsJSON).
\r
951 SetTime(time.Now())
\r
953 p := influxdb2.NewPointWithMeasurement("UeMetrics").SetTime(time.Now())
\r
954 for key, value := range *ueMetrics {
\r
955 p = p.AddField(key, value)
\r
958 writeAPI.WritePoint(context.Background(), p)
\r
959 xapp.Logger.Info("Wrote UE Metrics to InfluxDB")
\r
962 func (c *Control) writeCellMetrics_db(cellMetrics *map[string]interface{}) {
\r
963 writeAPI := c.client.WriteAPIBlocking("my-org", "kpimon")
\r
965 cellMetricsJSON, er := json.Marshal(cellMetrics)
\r
967 xapp.Logger.Error("Marshal Cell Metrics failed!")
\r
970 p := influxdb2.NewPointWithMeasurement("cellMetrics").
\r
971 AddField("Cell Metrics", cellMetricsJSON).
\r
972 SetTime(time.Now())
\r
974 p := influxdb2.NewPointWithMeasurement("cellMetrics").SetTime(time.Now())
\r
975 for key, value := range *cellMetrics {
\r
976 p = p.AddField(key, value)
\r
978 writeAPI.WritePoint(context.Background(), p)
\r
979 xapp.Logger.Info("Wrote Cell Metrics to InfluxDB")
\r
982 func (c Control) xAppStartCB(d interface{}) {
\r
983 xapp.Logger.Info("In callback KPI monitor xApp ...")
\r
985 //ranUeKpi ranCellKpi
\r
987 nbList := c.getnbList()
\r
989 for _, nb := range nbList {
\r
990 if nb.ConnectionStatus == 1 {
\r
991 xapp.Logger.Info("Building ranCellKp for %v", nb.InventoryName)
\r
992 link:="http://service-ricplt-e2mgr-http.ricplt.svc.cluster.local:3800/v1/nodeb/"
\r
993 link=link+nb.InventoryName
\r
994 tmpr,err := http.Get(link)
\r
997 panic("Unable to build ranCellKpi")
\r
999 defer tmpr.Body.Close()
\r
1000 var resp E2mgrResponse
\r
1002 err=json.NewDecoder(tmpr.Body).Decode(&resp)
\r
1005 panic("Unable to build ranCellKpi")
\r
1009 //RanFunctionId=2 for kpm in viavi
\r
1010 for i := 0; i < len(resp.Gnb.RanFunctions); i++ {
\r
1011 if resp.Gnb.RanFunctions[i].RanFunctionId == 2 {
\r
1016 cString := C.CString(resp.Gnb.RanFunctions[counter].RanFunctionDefinition)
\r
1017 defer C.free(unsafe.Pointer(cString)) // Free the allocated C string when done
\r
1018 result:=C.buildRanCellUeKpi(cString)
\r
1020 ueSlice := make([]string, result.ueKpiSize)
\r
1022 for _, v := range unsafe.Slice(result.ueKpi, result.ueKpiSize) {
\r
1023 ueSlice = append(ueSlice, C.GoString(v))
\r
1025 ranUeKpi[nb.InventoryName]=ueSlice
\r
1026 //fmt.Println("len of ranUeKpi= ",len(ranUeKpi))
\r
1027 //fmt.Println("ranUeKpi map = ", ranUeKpi)
\r
1030 cellSlice := make([]string, result.cellKpiSize)
\r
1032 for _, v := range unsafe.Slice(result.cellKpi, result.cellKpiSize) {
\r
1033 cellSlice = append(cellSlice, C.GoString(v))
\r
1035 ranCellKpi[nb.InventoryName]=cellSlice
\r
1036 //fmt.Println("len of ranCellKpi= ",len(ranCellKpi))
\r
1037 //fmt.Println("ranCellKpi map = ", ranCellKpi)
\r
1040 for i := 0; i < len(resp.Gnb.NodeConfigs); i++ {
\r
1041 if resp.Gnb.NodeConfigs[i].E2nodeComponentInterfaceType == "f1" {
\r
1048 tm := resp.Gnb.NodeConfigs[counter].E2nodeComponentRequestPart
\r
1049 base64Text := make([]byte, base64.StdEncoding.DecodedLen(len(tm)))
\r
1050 nl, _ := base64.StdEncoding.Decode(base64Text, []byte(tm))
\r
1051 message := string(base64Text[:nl])
\r
1054 cString2 := C.CString(message)
\r
1055 fmt.Println("Ponga = ",tm)
\r
1056 fmt.Println("Ponga = ",message)
\r
1057 defer C.free(unsafe.Pointer(cString2)) // Free the allocated C string when done
\r
1058 result2:=C.decodeF1apGetCellIds(cString2)
\r
1059 cellList:=make([]string, result2.size)
\r
1060 for _, v := range unsafe.Slice(result2.cellids, result2.size) {
\r
1061 cellList = append(cellList, C.GoString(v))
\r
1063 plmnList:=make([]string, result2.size)
\r
1064 for _, v := range unsafe.Slice(result2.plmn, result2.size) {
\r
1065 plmnList = append(plmnList, C.GoString(v))
\r
1071 fmt.Println("Ponga = ",tm)
\r
1072 cellList,plmnList:=f1ap.F1apGetCellIds(message)
\r
1073 Glob_Ran_cell[nb.InventoryName]=cellList
\r
1074 for i := 0; i < len(cellList); i++ {
\r
1075 Glob_cell_Plmn[cellList[i]]=plmnList[i]
\r
1078 response, err4 := http.Get("http://localhost:8090/getdata?gnbid="+nb.InventoryName)
\r
1080 fmt.Println("Error:", err4)
\r
1083 defer response.Body.Close()
\r
1085 var response2 APIResponse
\r
1086 if err5 := json.NewDecoder(response.Body).Decode(&response2); err5 != nil {
\r
1087 fmt.Println("Error decoding response:", err5)
\r
1091 fmt.Printf("f1apSever Response: %+v\n", response2)
\r
1093 Glob_Ran_cell[nb.InventoryName]=response2.Cellids
\r
1094 for i := 0; i < len(response2.Cellids); i++ {
\r
1095 Glob_cell_Plmn[response2.Cellids[i]]=response2.PlmnIds[i]
\r
1099 //C.freeMemorydRanCellUeKpi(result)
\r
1107 time.Sleep(5 * time.Second)
\r
1108 if xapp.IsRegistered() {
\r
1109 xapp.Logger.Info("App registration is done, ready to send subscription request.")
\r
1112 xapp.Logger.Debug("App registration is not done yet, sleep 5s and check again")
\r
1114 // Send subscription request to connected NodeB
\r
1115 for _, nb := range nbList {
\r
1116 if nb.ConnectionStatus == 1 {
\r
1117 xapp.Logger.Info("Before send subscription request to %v", nb.InventoryName)
\r
1118 c.sendSubscription(nb.InventoryName)
\r
1119 xapp.Logger.Info("After send subscription request to %v", nb.InventoryName)
\r
1124 fmt.Println("len of ranUeKpi= ",len(ranUeKpi))
\r
1125 fmt.Println("ranUeKpi map = ", ranUeKpi)
\r
1127 fmt.Println("len of ranCellKpi= ",len(ranCellKpi))
\r
1128 fmt.Println("ranCellKpi map = ", ranCellKpi)
\r
1130 fmt.Println("len of Glob_cell_Plmn= ",len(Glob_cell_Plmn))
\r
1131 fmt.Println("Glob_cell_Plmn map = ", Glob_cell_Plmn)
\r
1134 go c.controlLoop()
\r
1135 //go c.queryUEReports()
\r
1136 //go c.queryCellReports()
\r
1137 xapp.Logger.Info("End callback KPI monitor xApp ...")
\r
1140 func (c Control) Run() {
\r
1142 xapp.Logger.SetLevel(xapp.Config.GetInt("logger.level"))
\r
1143 // Register callback
\r
1144 xapp.Logger.Info("In Run() ...")
\r
1145 xapp.SetReadyCB(c.xAppStartCB, true)
\r