加入了分任务保存日志
This commit is contained in:
@@ -76,7 +76,7 @@ bool DataManagement::OnNewMail(MOOSMSG_LIST &NewMail)
|
||||
if (sval == "true")
|
||||
{
|
||||
logEnable = true;
|
||||
OpenOutputStream();
|
||||
OpenOutputStream("");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -84,6 +84,39 @@ bool DataManagement::OnNewMail(MOOSMSG_LIST &NewMail)
|
||||
CloseOutputStream();
|
||||
}
|
||||
}
|
||||
if(key == "uMission_action_cmd")
|
||||
{
|
||||
if (logEnable)
|
||||
{
|
||||
std::string err;
|
||||
Json::Value recvCommand;
|
||||
std::istringstream iss(sval);
|
||||
Json::CharReaderBuilder builder;
|
||||
try
|
||||
{
|
||||
bool parsingResult = Json::parseFromStream(builder, iss, &recvCommand, &err);
|
||||
if (!parsingResult)
|
||||
{
|
||||
throw ("uMission_action_cmd parse error");
|
||||
}
|
||||
|
||||
if (recvCommand["action"].asString() == "start")
|
||||
{
|
||||
CloseOutputStream();
|
||||
OpenOutputStream(recvCommand["taskName"].asString());
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseOutputStream();
|
||||
OpenOutputStream("");
|
||||
}
|
||||
}
|
||||
catch (std::string s)
|
||||
{
|
||||
std::cout << s << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(key == "uDevice_monitor_fb")
|
||||
{
|
||||
@@ -264,7 +297,9 @@ bool DataManagement::OnNewMail(MOOSMSG_LIST &NewMail)
|
||||
<< motionControlInfo.desiredSpeed << ","
|
||||
<< motionControlInfo.desiredDepth;
|
||||
Notify("uMotion_desired_log", ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return(true);
|
||||
@@ -415,44 +450,7 @@ bool DataManagement::OnStartUp()
|
||||
|
||||
if (logEnable)
|
||||
{
|
||||
// std::string subDir;
|
||||
// std::string localTime;
|
||||
// GenerateFileName(subDir, localTime);
|
||||
// saveLogDir += "/" + subDir;
|
||||
// if (access(saveLogDir.c_str(), F_OK) == -1 )
|
||||
// {
|
||||
// mode_t mode = 0775;
|
||||
// mkdir(saveLogDir.c_str(), mode);
|
||||
// }
|
||||
// saveLogDir += "/" + localTime;
|
||||
// if (access(saveLogDir.c_str(), F_OK) == -1 )
|
||||
// {
|
||||
// mode_t mode = 0775;
|
||||
// mkdir(saveLogDir.c_str(), mode);
|
||||
// }
|
||||
// std::string auvDataSavePath = saveLogDir + "/" + auvDataFile;
|
||||
// std::string missionHistorySavePath = saveLogDir + "/" + missionHistoryFile;
|
||||
// std::string clientCommandSavePath = saveLogDir + "/" + clientCommandFile;
|
||||
// std::string faultLogSavePath = saveLogDir + "/" + faultLogFile;
|
||||
// std::string motionControlSavePath = saveLogDir + "/" + motionControlFile;
|
||||
|
||||
// if(!OpenFile(auvDataStream, auvDataSavePath))
|
||||
// return MOOSFail("Failed to Open auvData file");
|
||||
// if(!OpenFile(missionHistoryStream, missionHistorySavePath))
|
||||
// return MOOSFail("Failed to Open missionHistory file");
|
||||
// if(!OpenFile(clientCommandStream, clientCommandSavePath))
|
||||
// return MOOSFail("Failed to Open clientCommand file");
|
||||
// if(!OpenFile(faultLogStream, faultLogSavePath))
|
||||
// return MOOSFail("Failed to Open faultLog file");
|
||||
// if(!OpenFile(motionControlStream, motionControlSavePath))
|
||||
// return MOOSFail("Failed to Open faultLog file");
|
||||
|
||||
// DoAuvDataLogBanner(auvDataStream);
|
||||
// DoMissionHistoryBanner(missionHistoryStream);
|
||||
// DoFaultHandleBanner(faultLogStream);
|
||||
// DoMotionControlBanner(motionControlStream);
|
||||
|
||||
OpenOutputStream();
|
||||
OpenOutputStream("");
|
||||
}
|
||||
|
||||
RegisterVariables();
|
||||
@@ -485,6 +483,7 @@ void DataManagement::RegisterVariables()
|
||||
Register("DESIRED_DEPTH", 0);
|
||||
Register("uMotion_desired_log", 0);
|
||||
Register("uClient_logEnable_cmd", 0);
|
||||
Register("uMission_action_cmd", 0);
|
||||
}
|
||||
|
||||
bool DataManagement::buildReport()
|
||||
@@ -635,7 +634,7 @@ void DataManagement::GenerateFileName(std::string &fileDir, std::string &fileNam
|
||||
fileName = ss.str();
|
||||
}
|
||||
|
||||
bool DataManagement::OpenOutputStream()
|
||||
bool DataManagement::OpenOutputStream(std::string extraName)
|
||||
{
|
||||
std::string subDir;
|
||||
std::string localTime;
|
||||
@@ -646,7 +645,14 @@ bool DataManagement::OpenOutputStream()
|
||||
mode_t mode = 0775;
|
||||
mkdir(saveSubLogDir.c_str(), mode);
|
||||
}
|
||||
saveSubLogDir += "/" + localTime;
|
||||
if (extraName.size() == 0)
|
||||
{
|
||||
saveSubLogDir += "/" + localTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveSubLogDir += "/" + localTime + "_" + extraName;
|
||||
}
|
||||
if (access(saveSubLogDir.c_str(), F_OK) == -1 )
|
||||
{
|
||||
mode_t mode = 0775;
|
||||
@@ -712,4 +718,4 @@ void DataManagement::CloseOutputStream()
|
||||
{
|
||||
motionControlStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user