改用内存表

main
BlueMatthew 2 years ago
parent 91b0b7d13a
commit df1725177b

@ -219,6 +219,8 @@ bool LoadIecPoints()
g_iec_points.push_back(pt); g_iec_points.push_back(pt);
} }
printf("IEC Points: %lld\n", (long long)g_iec_points.size());
} }
#endif #endif
@ -249,10 +251,9 @@ int GetAIPntMsg(int j, unsigned int *igno, unsigned int* iItemNo, DAY_TIME* sCur
} }
char buf[16] = { 0 }; char buf[16] = { 0 };
sprintf(buf, "%u", pt.sadr); snprintf(buf, sizeof(buf), "%u", pt.sadr);
std::string sql = "SELECT sadr,state,stype,ival,fval,d_time FROM niec_origin_data WHERE sadr="; std::string sql = "SELECT sadr,state,stype,ival,fval,d_time FROM niec_latest_org_data WHERE sadr=";
sql += buf; sql += buf;
sql += " ORDER BY `id` DESC LIMIT 1";
if (mysql_query(mysql, sql.c_str())) if (mysql_query(mysql, sql.c_str()))
{ {
@ -273,7 +274,17 @@ int GetAIPntMsg(int j, unsigned int *igno, unsigned int* iItemNo, DAY_TIME* sCur
if (igno != NULL) *igno = pt.sensorGroupNo; if (igno != NULL) *igno = pt.sensorGroupNo;
if (iItemNo != NULL) *iItemNo = pt.itemNo; if (iItemNo != NULL) *iItemNo = pt.itemNo;
if (iaddr != NULL) *iaddr = pt.sensorId; if (iaddr != NULL) *iaddr = pt.sensorId;
if (pfValue != NULL) *pfValue = atof(row[4]); if (pfValue != NULL)
{
if (row[4] != NULL && strlen(row[4]) > 0)
{
*pfValue = atof(row[4]);
}
else
{
*pfValue = 0.0f;
}
}
if (sCurTime != NULL && row[5] != NULL) if (sCurTime != NULL && row[5] != NULL)
{ {
sscanf(row[5], "%04d-%02d-%2d %02d:%02d:%02d", &year, &mon, &day, &hour, &min, &sec); sscanf(row[5], "%04d-%02d-%2d %02d:%02d:%02d", &year, &mon, &day, &hour, &min, &sec);

Loading…
Cancel
Save