增加了配电和ccu数据的数据库存储功能
This commit is contained in:
@@ -49,6 +49,7 @@ PowerManger::PowerManger()
|
||||
m_db = new SQLiteDB(dbPath);
|
||||
m_db->createPowerDataTables();
|
||||
m_db->createStateTables();
|
||||
m_db->createDisCcuSysTables();
|
||||
|
||||
//注册状态机
|
||||
m_fsm.RegisterState("Init", 1, m_Inite_s1);
|
||||
@@ -288,33 +289,35 @@ bool PowerManger::updatePmState()
|
||||
double time;
|
||||
m_udpComm.popMsgFormQueue(time,m_CcuCurrentState);
|
||||
m_pmCurrentState.ccustate = m_CcuCurrentState.data;
|
||||
double df;
|
||||
IsSkewed(time, &df);
|
||||
cout << "CcuState Skew:" << df << endl;
|
||||
m_db->insertCcuData(m_CcuCurrentState.data); //写入数据库
|
||||
}
|
||||
if(!m_udpComm.m_qReceiveDisHighVolBusBuffer.empty())
|
||||
{
|
||||
double time;
|
||||
m_udpComm.popMsgFormQueue(time,m_disHighVolBusCurrentState);
|
||||
m_pmCurrentState.bus1State = m_disHighVolBusCurrentState.data;
|
||||
m_db->insertDisHighVolBusData(m_disHighVolBusCurrentState.data); //写入数据库
|
||||
}
|
||||
if(!m_udpComm.m_qReceiveDisHighAVolBusBuffer.empty())
|
||||
{
|
||||
double time;
|
||||
m_udpComm.popMsgFormQueue(time,m_disHighAVolBusCurrentState);
|
||||
m_pmCurrentState.bus2State = m_disHighAVolBusCurrentState.data;
|
||||
m_db->insertDisHighAVolBusData(m_disHighAVolBusCurrentState.data); //写入数据库
|
||||
}
|
||||
if(!m_udpComm.m_qReceiveDisHighBVolBusBuffer.empty())
|
||||
{
|
||||
double time;
|
||||
m_udpComm.popMsgFormQueue(time,m_disHighBVolBusCurrentState);
|
||||
m_pmCurrentState.bus3State = m_disHighBVolBusCurrentState.data;
|
||||
m_db->insertDisHighBVolBusData(m_disHighBVolBusCurrentState.data); //写入数据库
|
||||
}
|
||||
if(!m_udpComm.m_qReceiveDisLowBusBuffer.empty())
|
||||
{
|
||||
double time;
|
||||
m_udpComm.popMsgFormQueue(time,m_disLowBusState);
|
||||
m_pmCurrentState.bus4State = m_disLowBusState.data;
|
||||
m_db->insertDisLowBusData(m_disLowBusState.data); //写入数据库
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -459,7 +462,9 @@ bool PowerManger::writeDataToDB()
|
||||
m_stateData.note = "No fault";
|
||||
if(!m_db->insertStateData(m_stateData))
|
||||
return false;
|
||||
|
||||
// //写入配电系统状态
|
||||
// if(!m_db->insertDisCcuData(m_pmCurrentState))
|
||||
// return false;
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -479,7 +484,6 @@ void PowerManger::printState(FSM_State st, string desp){
|
||||
|
||||
int PowerManger::handleInite_s1(FSM_State &fsm, void* pData)
|
||||
{
|
||||
cout << fsm.name << endl;
|
||||
PowerManger* pm = (PowerManger*)pData;
|
||||
//1. 检查复合管控器连接 如果10S则进入故障状态
|
||||
double StartTime = pm->GetAppStartTime();
|
||||
@@ -522,6 +526,7 @@ int PowerManger::handleInite_s1(FSM_State &fsm, void* pData)
|
||||
int PowerManger::handleStandby_s2(FSM_State &fsm, void* pData)
|
||||
{
|
||||
PowerManger* pm = (PowerManger*)pData;
|
||||
pm->m_stateData.note = "待机状态";
|
||||
while (true)
|
||||
{
|
||||
string desp = "待机状态";
|
||||
@@ -551,31 +556,6 @@ int PowerManger::handleFault_s99(FSM_State &fsm, void* pData)
|
||||
}
|
||||
|
||||
|
||||
// int PowerManger::handleState1(FSM_State &fsm,void* pData)
|
||||
// {
|
||||
// cout << fsm.name << endl;
|
||||
// PowerManger* pm = (PowerManger*)pData;
|
||||
// fsm = pm->m_fsm.getState("PM_STATE2");
|
||||
// // pm->m_pmEvent = "a";
|
||||
// return 0;
|
||||
// }
|
||||
// int PowerManger::handleState2(FSM_State &fsm,void* pData)
|
||||
// {
|
||||
// cout << fsm.name << endl;
|
||||
// PowerManger* pm = (PowerManger*)pData;
|
||||
// fsm = pm->m_fsm.getState("PM_STATE3");
|
||||
// // pm->m_pmEvent = "b";
|
||||
// return 0;
|
||||
// }
|
||||
// int PowerManger::handleState3(FSM_State &fsm,void* pData)
|
||||
// {
|
||||
// cout << fsm.name << endl;
|
||||
// PowerManger* pm = (PowerManger*)pData;
|
||||
// fsm = pm->m_fsm.getState("PM_STATE");
|
||||
// // pm->m_pmEvent = "c";
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
void PowerManger::initTargetDisBreakerState()
|
||||
{
|
||||
m_targetDisBreakerState.bus1Breaker.fuelCellCircuitBreaker = 0;
|
||||
|
||||
Reference in New Issue
Block a user