Explorar o código

增加稳态值和摩擦力.

git-svn-id: https://202.107.226.68:8443/svn/Services/ResistanceMonitor@76 a05970a1-87b9-9d4f-9ee5-fa77e2ec115b
shenchunzhong hai 1 ano
pai
achega
bede944a1c
Modificáronse 1 ficheiros con 55 adicións e 4 borrados
  1. 55 4
      4.Data/HttpPrcess.cpp

+ 55 - 4
4.Data/HttpPrcess.cpp

@@ -4674,6 +4674,7 @@ int DealResistMove(const httplib::Request& req, const string token, char** json,
 
 		list<CONVERT_RESIST> maxResist;   //转换力数据
 		list<PASS_RESIST> lstPass;   //过车数据
+		list<FRICTION_RESIST> lstFriction; //摩擦力数据
 		std::map<time_t, int64_t> maxlock0, maxlock1;//锁闭力 前面时间戳, 后面 高4位显示值,  低4位报警值
 		std::map<time_t, int64_t>  retentionforce0, retentionforce1; //保持力 时间戳,  高4位显示值, 低4位报警值
 		std::map<time_t, tagSecondStatInfo> mapSecondStatInfo0, mapSecondStatInfo1, mapSecondStatInfo2;
@@ -4692,6 +4693,40 @@ int DealResistMove(const httplib::Request& req, const string token, char** json,
 				++it;
 			}
 		}
+		//摩擦力过滤
+		for (auto it = maxResist.begin(); it != maxResist.end();)
+		{
+			int first_value = 0, last_value = 0;
+			auto ii = mapSecondStatInfo2.find(it->tmStart);
+			ASSERT(ii != mapSecondStatInfo2.end());
+			first_value = ii->second.first_val;
+			ii = mapSecondStatInfo2.find(it->tmEnd);
+			if (ii == mapSecondStatInfo2.end())
+				ii = mapSecondStatInfo2.find(it->tmEnd - 1);
+            ASSERT(ii != mapSecondStatInfo2.end());
+			last_value = ii->second.end_val;
+			auto dif = abs(last_value - first_value);
+			if (dif > 1000)
+			{
+				auto strLog = fmt::format("{}  first:{}  last:{} dif:{}", 
+					CTime(it->time/1000).Format("%Y-%m-%d %H:%M:%S"), first_value, last_value, dif);
+				SPDLOG_INFO(strLog);
+				FRICTION_RESIST info;
+				info.peak_time = it->time;
+				info.peak_val = it->val;
+				info.show_time = it->time; //暂时赋值峰值
+				info.show_val = last_value;
+				info.tmStart = it->tmStart;
+				info.tmEnd = it->tmEnd;
+				info.t = strLog;
+				lstFriction.emplace_back(info);
+				it = maxResist.erase(it);
+				++it;
+			}
+			else
+				++it;
+		}
+
 		if (maxResist.size())
 		{
 			mg_per_session_data::GetMaxLockNew(data0, maxResist, maxlock0, retentionforce0);
@@ -4810,6 +4845,22 @@ int DealResistMove(const httplib::Request& req, const string token, char** json,
 			//JudgeAlarm(pService, pInvertSuobiOverInfo, it.first, show_val, eSuoBiPosi::SB_INVERT, mo, mp, zzjno);
 		}
 
+		for (auto& it : lstFriction)
+		{
+			time_t show_time = it.peak_time;
+			int curr_val = it.peak_val;
+			int show_val = it.show_val;
+			auto obj = yyjson_mut_obj(doc);
+			yyjson_mut_arr_add_val(convert_points, obj);
+			auto coord = yyjson_mut_arr(doc);
+			yyjson_mut_obj_add_val(doc, obj, "coord", coord);
+			yyjson_mut_arr_add_int(doc, coord, show_time);
+			yyjson_mut_arr_add_int(doc, coord, curr_val);
+			yyjson_mut_obj_add_strcpy(doc, obj, "time", fmt::format("{}.{:0>3}", CTime(show_time / 1000).Format("%Y-%m-%d %H:%M:%S"), show_time % 1000).c_str());
+			yyjson_mut_obj_add_int(doc, obj, "val", show_val);
+			yyjson_mut_obj_add_strcpy(doc, obj, "label", ANSItoUTF8(fmt::format("稳态值:{}", show_val)).c_str());
+		}
+
 		for (auto& it : maxResist)
 		{
 			auto obj = yyjson_mut_obj(doc);
@@ -4847,7 +4898,7 @@ int DealResistMove(const httplib::Request& req, const string token, char** json,
 					}
 					if (curr_val < 0)
 						yyjson_mut_obj_add_str(doc, obj, "position", "bottom");
-					yyjson_mut_obj_add_strcpy(doc, obj, "label", ANSItoUTF8(fmt::format("定扳反:{}", ++show_val)).c_str());
+					yyjson_mut_obj_add_strcpy(doc, obj, "label", ANSItoUTF8(fmt::format("定扳反:{}", show_val)).c_str());
 
 					//CResistAlarmMng::InsertToDBByMove(mo, mp, it.time, it.tmStart, it.tmEnd, it.val, it.fluctuation_val, i,
 					//	(uint8_t)eDaoChaPosi::DCP_FIX2INVERT, fmt::format("{}:{}", in_name, it.fluctuation_val));
@@ -4885,7 +4936,7 @@ int DealResistMove(const httplib::Request& req, const string token, char** json,
 					}
 					if (curr_val < 0)
 						yyjson_mut_obj_add_str(doc, obj, "position", "bottom");
-					yyjson_mut_obj_add_strcpy(doc, obj, "label", ANSItoUTF8(fmt::format("反扳定:{}", ++show_val)).c_str());
+					yyjson_mut_obj_add_strcpy(doc, obj, "label", ANSItoUTF8(fmt::format("反扳定:{}", show_val)).c_str());
 
 					//CResistAlarmMng::InsertToDBByMove(mo, mp, it.time, it.tmStart, it.tmEnd, it.val, it.fluctuation_val, i,
 					//	(uint8_t)eDaoChaPosi::DCP_INVERT2FIX, fmt::format("{}:{}", in_name, it.fluctuation_val));
@@ -4926,7 +4977,7 @@ int DealResistMove(const httplib::Request& req, const string token, char** json,
 					}
 					if (curr_val < 0)
 						yyjson_mut_obj_add_str(doc, obj, "position", "bottom");
-					yyjson_mut_obj_add_strcpy(doc, obj, "label", ANSItoUTF8(fmt::format("定扳反:{}", ++show_val)).c_str());
+					yyjson_mut_obj_add_strcpy(doc, obj, "label", ANSItoUTF8(fmt::format("定扳反:{}", show_val)).c_str());
 
 					//CResistAlarmMng::InsertToDBByMove(mo, mp, it.time, it.tmStart, it.tmEnd, it.val, it.fluctuation_val, i,
 					//	(uint8_t)eDaoChaPosi::DCP_FIX2INVERT, fmt::format("{}:{}", out_name, it.fluctuation_val));
@@ -4964,7 +5015,7 @@ int DealResistMove(const httplib::Request& req, const string token, char** json,
 					}
 					if (curr_val < 0)
 						yyjson_mut_obj_add_str(doc, obj, "position", "bottom");
-					yyjson_mut_obj_add_strcpy(doc, obj, "label", ANSItoUTF8(fmt::format("反扳定:{}", ++show_val)).c_str());
+					yyjson_mut_obj_add_strcpy(doc, obj, "label", ANSItoUTF8(fmt::format("反扳定:{}", show_val)).c_str());
 
 					//CResistAlarmMng::InsertToDBByMove(mo, mp, it.time, it.tmStart, it.tmEnd, it.val, it.fluctuation_val, i,
 					//	(uint8_t)eDaoChaPosi::DCP_INVERT2FIX, fmt::format("{}:{}", out_name, it.fluctuation_val));