| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- #include "StdAfx.h"
- #include "SystemLauncher.h"
- #include "DeviceMgr.h"
- #include "NetworkVs.h"
- #include "Config.h"
- #include "../Public/DaemonClient/DaemonClient.h"
- CSystemLauncher::CSystemLauncher(void)
- {
- }
- /*****************************************************************
- **【函数名称】 __openTts
- **【函数功能】 打开TTS
- **【参数】
- **【返回值】
- ****************************************************************/
- void CSystemLauncher::__openTts( void )
- {
- TTS_TYPE TtsType = CConfig::ttsType();
- if(TtsType != TTS_NONE)
- {
- CHAR szErrCode[BUFFER_LENGTH];
- if(ITtsInterface::getInstance().init(TtsType, CConfig::ttsPath(), szErrCode))
- ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("{Core}: TTS打开成功"));
- else
- ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_WARNING, _T("{Core}: TTS打开失败, Reason = %s"), szErrCode);
- }
- }
- /*****************************************************************
- **【函数名称】 __closeTts
- **【函数功能】 关闭TTS
- **【参数】
- **【返回值】
- ****************************************************************/
- void CSystemLauncher::__closeTts( void )
- {
- if(CConfig::ttsType() != TTS_NONE)
- ITtsInterface::getInstance().close();
- }
- /*****************************************************************
- **【函数名称】 stage1Start
- **【函数功能】 第一阶段启动
- **【参数】
- **【返回值】
- ****************************************************************/
- bool CSystemLauncher::stage1Start( void )
- {
- // 连接配置数据库
- if(!IOtlConnection::getInstance()->Connect())
- {
- AfxMessageBox(STR_ERR_INIT_DB_CONN);
- return false;
- }
- // 加载配置
- if(!CConfig::load())
- {
- // 断开数据库连接
- IOtlConnection::getInstance()->Disconnect();
- AfxMessageBox(STR_ERR_INIT_CFG_LOAD);
- return false;
- }
- return true;
- }
- /*****************************************************************
- **【函数名称】 stage2Start
- **【函数功能】 第二阶段启动
- **【参数】
- **【返回值】
- ****************************************************************/
- bool CSystemLauncher::stage2Start( void )
- {
- __openTts();
- if(!CDeviceMgr::GetInstance().initDev())
- {
- // 断开数据库连接
- IOtlConnection::getInstance()->Disconnect();
- ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_ERROR, _T("%s"), STR_ERR_INIT_DEV_OPEN);
- return false;
- }
- if(!CNetworkVs::GetInstance().init())
- {
- CDeviceMgr::GetInstance().closeDev();
- // 断开数据库连接
- IOtlConnection::getInstance()->Disconnect();
- ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_ERROR, _T("%s"), STR_ERR_INIT_NET_SETUP);
- return false;
- }
- CDaemonClient::GetInstance().doWork();
- return true;
- }
- /*****************************************************************
- **【函数名称】 stop
- **【函数功能】 停止
- **【参数】
- **【返回值】
- ****************************************************************/
- void CSystemLauncher::stop( void )
- {
- CNetworkVs::GetInstance().release();
- CDeviceMgr::GetInstance().closeDev();
- __closeTts();
- IOtlConnection::getInstance()->Disconnect();
- ILogger::getInstance().close();
- }
|