X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fhw_xapp_main.cc;h=1771797997a2b4dc858938cfe798d600e97a8b85;hb=refs%2Fchanges%2F42%2F4042%2F2;hp=624d88fc467aa22e429e7a0a5d2620614eef5d42;hpb=b85024cd183a527cd8d61353637850cb6d30cf36;p=ric-app%2Fhw.git diff --git a/src/hw_xapp_main.cc b/src/hw_xapp_main.cc index 624d88f..1771797 100644 --- a/src/hw_xapp_main.cc +++ b/src/hw_xapp_main.cc @@ -1,6 +1,6 @@ /* ================================================================================== - Copyright (c) 2018-2019 AT&T Intellectual Property. + Copyright (c) 2019-2020 AT&T Intellectual Property. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -51,45 +51,40 @@ int main(int argc, char *argv[]){ signal(SIGTERM, signalHandler); //getting the listening port and xapp name info - std::string port = config[XappSettings::SettingName::HW_PORTS]; + std::string port = config[XappSettings::SettingName::HW_PORT]; std::string name = config[XappSettings::SettingName::XAPP_NAME]; //initialize rmr - std::unique_ptr rmr; - rmr = std::make_unique(port); - rmr->xapp_rmr_init(); + std::unique_ptr rmr = std::make_unique(port); + rmr->xapp_rmr_init(true); - std::unique_ptr hw_xapp = std::make_unique(std::ref(config),std::ref(*rmr)); + //Create Subscription Handler if Xapp deals with Subscription. + std::unique_ptr sub_handler = std::make_unique(); - //register MsgHandler plugin for a received rmr_buffer - std::unique_ptr mp_handler = std::make_unique(); - hw_xapp->register_handler(std::bind(&XappMsgHandler::operator (),mp_handler.get(),std::placeholders::_1,std::placeholders::_2)); + //create HelloWorld Xapp Instance. + std::unique_ptr hw_xapp; + hw_xapp = std::make_unique(std::ref(config),std::ref(*rmr)); - rmr->set_listen(true); - hw_xapp->start_xapp_receiver(std::ref(*mp_handler)); + mdclog_write(MDCLOG_INFO, "Created Hello World Xapp Instance"); - sleep(5); + sleep(1); + //Startup E2 subscription and A1 policy + hw_xapp->startup(std::ref(*sub_handler)); - //Delete all subscriptions if any based on Xapp Mode. - //xapp->shutdown(); - - xapp_rmr_header hdr; - hdr.message_type = RIC_HEALTH_CHECK_REQ; + //start listener threads and register message handlers. + int num_threads = std::stoi(config[XappSettings::SettingName::THREADS]); + mdclog_write(MDCLOG_INFO, "Starting Listener Threads. Number of Workers = %d", num_threads); - char *strMsg = "HelloWorld: RMR Health Check\0"; + std::unique_ptr mp_handler = std::make_unique(config[XappSettings::SettingName::XAPP_ID]); + hw_xapp->start_xapp_receiver(std::ref(*mp_handler)); - clock_gettime(CLOCK_REALTIME, &(hdr.ts)); - hdr.payload_length = strlen(strMsg); + sleep(1); - bool res = rmr->xapp_rmr_send(&hdr,(void*)strMsg); + //xapp->shutdown(); - if (!res){ - std::cout << "Xapp RMR Send Failure"; - } - usleep(10); - while(1){ + while(1){ sleep(1); }