add codes
This commit is contained in:
parent
7f00e1ce52
commit
07c30f4a60
8
Makefile
8
Makefile
@ -20,7 +20,7 @@ LIBS = -L../Tools/renesas_thirdparty/lib \
|
|||||||
-L../Tools/renesas_thirdparty/lib \
|
-L../Tools/renesas_thirdparty/lib \
|
||||||
-lsqlite3 -lboost_system -lpthread -lboost_thread -lboost_date_time -lboost_filesystem -lfftw3 -ljsoncpp -lmosquitto -lcurl -lzlog
|
-lsqlite3 -lboost_system -lpthread -lboost_thread -lboost_date_time -lboost_filesystem -lfftw3 -ljsoncpp -lmosquitto -lcurl -lzlog
|
||||||
|
|
||||||
CFLAGS = -O0 -fpermissive -fstack-protector-all #-Wall -Werror
|
CFLAGS = -O0 -g -std=c++14 -fpermissive -fstack-protector-all #-Wall -Werror
|
||||||
LINKFLAGS =
|
LINKFLAGS =
|
||||||
|
|
||||||
AllDirs :=$(shell ls -R | grep '^\./.*:' | awk '{if( \
|
AllDirs :=$(shell ls -R | grep '^\./.*:' | awk '{if( \
|
||||||
@ -67,8 +67,8 @@ install: $(TARGET)
|
|||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -f $(PREFIX_BIN)/$(TARGET)
|
rm -f $(PREFIX_BIN)/$(TARGET)
|
||||||
strip:
|
#strip:
|
||||||
$(STRIP) $(TARGET)
|
# $(STRIP) $(TARGET)
|
||||||
cp $(TARGET) ~/tftpboot
|
# cp $(TARGET) ~/tftpboot
|
||||||
|
|
||||||
rebuild: clean compile
|
rebuild: clean compile
|
||||||
|
|||||||
@ -226,7 +226,7 @@ void JsonData::CmtCmd_82(char* MeasurementID,char* send_data,int& channel,int& s
|
|||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonData::CmtCmd_83(char* recv_body,int& count,char* send_data,int& send_length)
|
void JsonData:: CmtCmd_83(char* recv_body,int& count,char* send_data,int& send_length)
|
||||||
{
|
{
|
||||||
vec_t vecRes;
|
vec_t vecRes;
|
||||||
std::string filename = "";
|
std::string filename = "";
|
||||||
|
|||||||
@ -106,6 +106,11 @@ std::string JsonData::JsonCmd_Cgi_50() {
|
|||||||
std::vector<std::string> value;
|
std::vector<std::string> value;
|
||||||
std::vector<DataNodeUpdate> vecDataNodeUpdate;
|
std::vector<DataNodeUpdate> vecDataNodeUpdate;
|
||||||
DataNodeUpdate datanodeUpdate;
|
DataNodeUpdate datanodeUpdate;
|
||||||
|
std::fstream is;
|
||||||
|
is.open("/opt/DataNode/config.json", std::ios::in);
|
||||||
|
if (reader.parse(is, root)) {
|
||||||
|
jsBody["sensor"] = root;
|
||||||
|
}
|
||||||
jsBody["GateWayVersion"] = GlobalConfig::Version;
|
jsBody["GateWayVersion"] = GlobalConfig::Version;
|
||||||
jsBody["SystemVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "SystemVersion");
|
jsBody["SystemVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "SystemVersion");
|
||||||
jsBody["WebVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "WebVersion");
|
jsBody["WebVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "WebVersion");
|
||||||
@ -614,14 +619,6 @@ std::string JsonData::JsonCmd_Cgi_59(Param_59 ¶m) {
|
|||||||
Json::Value iTem;
|
Json::Value iTem;
|
||||||
iTem.append(arrResult[i][1]);
|
iTem.append(arrResult[i][1]);
|
||||||
iTem.append(arrResult[i][0]);
|
iTem.append(arrResult[i][0]);
|
||||||
int time = 0;
|
|
||||||
int lost_data_time = atol(arrResult[i][1].c_str()) - atol(arrResult[i][1].c_str());
|
|
||||||
if (param.mMode == 1){
|
|
||||||
time = abs(lost_data_time/featureInterVal);
|
|
||||||
}else if(param.mMode == 2){
|
|
||||||
time = abs(lost_data_time/waveInterVal);
|
|
||||||
}
|
|
||||||
iTem.append(time);
|
|
||||||
valData.append(iTem);
|
valData.append(iTem);
|
||||||
}
|
}
|
||||||
jsonVal["content"] = valData;
|
jsonVal["content"] = valData;
|
||||||
@ -644,7 +641,7 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
|||||||
jsonVal["success"] = true;
|
jsonVal["success"] = true;
|
||||||
jsonVal["message"] = "";
|
jsonVal["message"] = "";
|
||||||
char file_path[64]={0};
|
char file_path[64]={0};
|
||||||
char cmd[128]={0};
|
char cmd[64]={0};
|
||||||
sprintf(cmd, "mv /opt/%s /opt/DataNode/",param.fileName.c_str());
|
sprintf(cmd, "mv /opt/%s /opt/DataNode/",param.fileName.c_str());
|
||||||
system(cmd);
|
system(cmd);
|
||||||
sprintf(file_path, "/opt/DataNode/%s",param.fileName.c_str());
|
sprintf(file_path, "/opt/DataNode/%s",param.fileName.c_str());
|
||||||
@ -751,17 +748,16 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){
|
|||||||
char *end_ptr = NULL;
|
char *end_ptr = NULL;
|
||||||
short_addr = strtol(vecResult[3].c_str(), &end_ptr, 16);
|
short_addr = strtol(vecResult[3].c_str(), &end_ptr, 16);
|
||||||
int res = scheduler::instance().UpgradeSensor(short_addr,std::string(sensor_type),atoi(vecResult[0].c_str()),vecResult[1],std::string(sf_version));
|
int res = scheduler::instance().UpgradeSensor(short_addr,std::string(sensor_type),atoi(vecResult[0].c_str()),vecResult[1],std::string(sf_version));
|
||||||
if (res != 0){
|
if (res != 0)
|
||||||
|
{
|
||||||
jsonVal["success"] = false;
|
jsonVal["success"] = false;
|
||||||
jsonVal["message"] = "UpgradeSensor error";
|
jsonVal["message"] = "UpgradeSensor error";
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return show_value_.write(jsonVal);
|
return show_value_.write(jsonVal);
|
||||||
}
|
}
|
||||||
zlog_info(zct,"000000000000");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
free(buffer);
|
free(buffer);
|
||||||
zlog_info(zct,"11111111111");
|
|
||||||
return show_value_.write(jsonVal);
|
return show_value_.write(jsonVal);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -319,7 +319,7 @@ SensorScheduler::SensorScheduler() {
|
|||||||
ShortAddrCfg::ReadCfg(short_addr_map_);
|
ShortAddrCfg::ReadCfg(short_addr_map_);
|
||||||
|
|
||||||
// read upgrade config file: UPGRADE_CONFIG
|
// read upgrade config file: UPGRADE_CONFIG
|
||||||
UpgradeCfg::ReadCfg(upgrade_);
|
//UpgradeCfg::ReadCfg(upgrade_);
|
||||||
|
|
||||||
// read config update file: CONFIG_UPDATE
|
// read config update file: CONFIG_UPDATE
|
||||||
UpdateCfg::ReadCfg(update_);
|
UpdateCfg::ReadCfg(update_);
|
||||||
|
|||||||
@ -47,49 +47,47 @@ int UpgradeCfg::ReadCfg(std::map<int, UpgradeInfo> &upgrade) {
|
|||||||
info.current_sw_version = item["current_sw_version"].asString();
|
info.current_sw_version = item["current_sw_version"].asString();
|
||||||
info.upgrade_sw_version = item["upgrade_sw_version"].asString();
|
info.upgrade_sw_version = item["upgrade_sw_version"].asString();
|
||||||
info.submit_time = item["submit_time"].asString();
|
info.submit_time = item["submit_time"].asString();
|
||||||
for (const auto &time_item : item["try_world_time"]) {
|
if (info.try_times > 0) {
|
||||||
info.try_world_time1.push_back(time_item.asString());
|
for (const auto &time_item : item["try_world_time"]) {
|
||||||
|
info.try_world_time1.push_back(time_item.asString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
upgrade[item["id"].asInt()] = info;
|
upgrade[item["id"].asInt()] = info;
|
||||||
zlog_info(zbt, "[UpgradeCfg] id:%d need to upgrade from:%s to %s", item["id"].asInt(),
|
zlog_info(zbt, "[UpgradeCfg] id:%d need to upgrade from:%s to %s", item["id"].asInt(),
|
||||||
info.current_sw_version.c_str(), info.upgrade_sw_version.c_str());
|
info.current_sw_version.c_str(), info.upgrade_sw_version.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UpgradeCfg::WriteCfg(std::map<int, UpgradeInfo> &upgrade) {
|
int UpgradeCfg::WriteCfg(std::map<int, UpgradeInfo> &upgrade) {
|
||||||
// if (upgrade.size() == 0) {
|
if (upgrade.size() == 0) {
|
||||||
// ClearCfg();
|
ClearCfg();
|
||||||
// return 0;
|
return 0;
|
||||||
// }
|
}
|
||||||
zlog_info(zct,"123 = %d",upgrade.size());
|
|
||||||
// Json::Value root;
|
Json::Value root;
|
||||||
// for (auto item : upgrade) {
|
for (auto item : upgrade) {
|
||||||
// zlog_info(zct,"1111");
|
Json::Value upgrade_item;
|
||||||
// Json::Value upgrade_item;
|
upgrade_item["id"] = item.first;
|
||||||
// upgrade_item["id"] = item.first;
|
upgrade_item["try_times"] = item.second.try_times;
|
||||||
// upgrade_item["try_times"] = item.second.try_times;
|
upgrade_item["type"] = item.second.sensor_type;
|
||||||
// upgrade_item["type"] = item.second.sensor_type;
|
upgrade_item["hw_version"] = item.second.hw_version;
|
||||||
// upgrade_item["hw_version"] = item.second.hw_version;
|
upgrade_item["current_sw_version"] = item.second.current_sw_version;
|
||||||
// upgrade_item["current_sw_version"] = item.second.current_sw_version;
|
upgrade_item["upgrade_sw_version"] = item.second.upgrade_sw_version;
|
||||||
// upgrade_item["upgrade_sw_version"] = item.second.upgrade_sw_version;
|
upgrade_item["submit_time"] = item.second.submit_time;
|
||||||
// upgrade_item["submit_time"] = item.second.submit_time;
|
Json::Value try_world_time;
|
||||||
// Json::Value try_world_time;
|
for (auto entry : item.second.try_world_time1) {
|
||||||
// zlog_info(zct,"2222");
|
try_world_time.append(entry);
|
||||||
// for (auto entry : item.second.try_world_time1) {
|
}
|
||||||
// try_world_time.append(entry);
|
upgrade_item["try_world_time"] = try_world_time;
|
||||||
// }
|
root.append(upgrade_item);
|
||||||
// zlog_info(zct,"333");
|
}
|
||||||
// upgrade_item["try_world_time"] = try_world_time;
|
Json::StyledStreamWriter streamWriter;
|
||||||
// root.append(upgrade_item);
|
std::ofstream out_file(UPGRADE_CONFIG);
|
||||||
// zlog_info(zct,"444");
|
streamWriter.write(out_file, root);
|
||||||
// }
|
out_file.close();
|
||||||
// zlog_info(zct,"456");
|
|
||||||
// Json::StyledStreamWriter streamWriter;
|
|
||||||
// std::ofstream out_file(UPGRADE_CONFIG);
|
|
||||||
// streamWriter.write(out_file, root);
|
|
||||||
// out_file.close();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user