123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #include "upsimpl.h"
- #include "log4vendor.h"
- UpsClassImpl* g_pUpsDevice = NULL;
- void __attribute__((destructor)) uninit()
- {
- if (g_pUpsDevice)
- {
- delete g_pUpsDevice;
- g_pUpsDevice = NULL;
- }
- }
- void __attribute__((constructor)) init()
- {
- }
- DEVICEBASE_API ErrorCodeEnum CreateDevComponent(DeviceBaseClass *&baseObj)
- {
- ErrorCodeEnum eRt = Error_Succeed;
- if(NULL == g_pUpsDevice)
- {
- g_pUpsDevice = new UpsClassImpl();
- baseObj = (DeviceBaseClass *)g_pUpsDevice;
- cmb::log_init_config config;
- config.log_level=CMB_LOG_LEVEL_ALL;
- config.dev_name = "UPS";
- #if defined(_MSC_VER)
- config.log_dir = ("C:\\rvc\\dbg\\");
- #else
- config.log_dir = ("/opt/rvc/dbg/");
- #endif //_MSC_VER
- std::string str;
- cmb::log4vendor::init(config, str);
- printf("init after: %s\n", str.c_str());
- }
- else
- {
- eRt = Error_AlreadyExist;
- }
- return eRt;
- }
- DEVICEBASE_API ErrorCodeEnum ReleaseDevComponent(DeviceBaseClass *&pBaseObj)
- {
- ErrorCodeEnum eRt = Error_Succeed;
- if(pBaseObj == (DeviceBaseClass*)g_pUpsDevice)
- {
- delete g_pUpsDevice;
- g_pUpsDevice = NULL;
- return Error_Succeed;
- }
- return Error_Param;
- }
|