add codes
This commit is contained in:
parent
c81f579692
commit
bb9ab6db01
@ -163,7 +163,7 @@ void JsonData::CmtCmd_82(char* MeasurementID,char* send_data,int& channel,int& s
|
||||
char* buffer = NULL;
|
||||
int thisSize = 0;
|
||||
WaveRes wave;
|
||||
char whereCon[32]={0};
|
||||
char whereCon[64]={0};
|
||||
sprintf(whereCon,"MeasurementID = '%s'",MeasurementID);
|
||||
vec_t vecRes = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), "samplingRate,ACCSampleTime",whereCon);
|
||||
std::string strChannel = "";
|
||||
@ -175,33 +175,26 @@ void JsonData::CmtCmd_82(char* MeasurementID,char* send_data,int& channel,int& s
|
||||
}else if (channel == 3){
|
||||
strChannel = "Z";
|
||||
}
|
||||
std::string data_file = "/opt/data/" + std::string(MeasurementID) + "-" + strChannel;
|
||||
std::string data_file = "/opt/data/" + std::string(MeasurementID) + "-" + strChannel + ".dat";
|
||||
zlog_info(zct, "strFileName = %s", data_file.c_str());
|
||||
|
||||
pFile = fopen(data_file.c_str(), "rb");
|
||||
if (pFile != NULL) {
|
||||
while (fgetc(pFile) != EOF) {
|
||||
++thisSize;
|
||||
}
|
||||
rewind(pFile);
|
||||
buffer = (char*)malloc(thisSize);
|
||||
fread(buffer, sizeof(char), thisSize, pFile);
|
||||
fseek(pFile, 32, SEEK_SET);//跳过32个字节的时间戳
|
||||
buffer = (char*)malloc(thisSize - 32);
|
||||
fread(buffer, sizeof(char), thisSize - 32, pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
char test_buf[12800 * 4 + 1]={0};
|
||||
for (int i = 0; i < 12800; i++)
|
||||
{
|
||||
char temp[5]={0};
|
||||
sprintf(temp,"%d",i);
|
||||
memcpy(test_buf + i * 4, temp, 4);
|
||||
}
|
||||
|
||||
//wave.sampling_rate = atoi(vecRes[0].c_str());
|
||||
wave.sampling_rate = 12800;
|
||||
wave.sampling_rate = atoi(vecRes[0].c_str());
|
||||
wave.sampling_time = atoi(vecRes[1].c_str());
|
||||
wave.version = 1;
|
||||
send_length = sizeof(WaveRes) + 51200;
|
||||
send_length = sizeof(WaveRes) + thisSize - 32;
|
||||
memcpy(send_data,(char*)&wave,sizeof(WaveRes));
|
||||
memcpy(send_data + sizeof(WaveRes) ,test_buf,51200);
|
||||
memcpy(send_data + sizeof(WaveRes) ,buffer,thisSize - 32);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
@ -214,7 +207,6 @@ void JsonData::CmtCmd_83(char* MeasurementID,char* send_data,int& send_length)
|
||||
vecRes = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), "*", whereCon);
|
||||
if (vecRes.size() > 0){
|
||||
DownloadConfig download_config;
|
||||
download_config.version = 1;
|
||||
memcpy(download_config.gw_mac,GlobalConfig::MacAddr_G.c_str(),sizeof(download_config.gw_mac));
|
||||
if (vecRes[17] == "01"){
|
||||
memcpy(download_config.product,"DN101",sizeof(download_config.product));
|
||||
@ -251,7 +243,7 @@ void JsonData::CmtCmd_83(char* MeasurementID,char* send_data,int& send_length)
|
||||
|
||||
char localtimestamp[32] = {0};
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
filename = "config_" + std::string(localtimestamp);
|
||||
filename = "/opt/DataNode/config_" + std::string(localtimestamp)+ ".csv";
|
||||
std::ofstream csvFile(filename);
|
||||
if (!csvFile.is_open()) {
|
||||
std::cerr << "Error: Could not open file " << filename << std::endl;
|
||||
@ -273,6 +265,7 @@ void JsonData::CmtCmd_83(char* MeasurementID,char* send_data,int& send_length)
|
||||
}
|
||||
send_length = sizeof(DownloadConfigRes);
|
||||
DownloadConfigRes download_condfig_res;
|
||||
download_condfig_res.version = 1;
|
||||
memcpy(download_condfig_res.filename,filename.c_str(),sizeof(download_condfig_res));
|
||||
memcpy(send_data,(char*)&download_condfig_res,sizeof(DownloadConfigRes));
|
||||
zlog_info(zct, "cmd 83 send_length = %d",send_length);
|
||||
@ -334,6 +327,7 @@ void JsonData::CmtCmd_84(char* filename)
|
||||
if (iRet != 0) {
|
||||
zlog_error(zct, "UpdataDataNodeConfig UpdateTableData fail");
|
||||
}
|
||||
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
memset(updateSql, 0x00, sizeof(updateSql));
|
||||
}
|
||||
@ -343,4 +337,9 @@ void JsonData::CmtCmd_84(char* filename)
|
||||
void JsonData::CmtCmd_85(char* filename)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void JsonData::CmtCmd_86(char* filename)
|
||||
{
|
||||
|
||||
}
|
||||
@ -84,6 +84,7 @@ public:
|
||||
void CmtCmd_83(char* MeasurementID,char* send_data,int& return_length);
|
||||
void CmtCmd_84(char* filename);
|
||||
void CmtCmd_85(char* filename);
|
||||
void CmtCmd_86(char* filename);
|
||||
|
||||
private:
|
||||
Json::FastWriter show_value_;
|
||||
|
||||
@ -50,9 +50,9 @@ void LocalServer::HandleTcp_cmd(const char* recv_data,char* send_data,uint8_t& r
|
||||
zlog_info(zct, "CmtCmd_83 = %d",send_length);
|
||||
}break;
|
||||
case KUploadConfig:{
|
||||
UpgradeSensorReq upgrade_sensor;
|
||||
memcpy(&upgrade_sensor,recv_data + sizeof(PackgeHead),sizeof(UpgradeSensorReq));
|
||||
jd.CmtCmd_84(upgrade_sensor.filename);
|
||||
UploadConfigReq upload_config;
|
||||
memcpy(&upload_config,recv_data + sizeof(PackgeHead),sizeof(UploadConfigReq));
|
||||
jd.CmtCmd_84(upload_config.filename);
|
||||
|
||||
}break;
|
||||
case KUpgadeGateway:{
|
||||
@ -64,9 +64,10 @@ void LocalServer::HandleTcp_cmd(const char* recv_data,char* send_data,uint8_t& r
|
||||
}
|
||||
}break;
|
||||
case KUpgradeSensor:{
|
||||
|
||||
}
|
||||
break;
|
||||
UpgradeSensorReq upgrade_sensor;
|
||||
memcpy(&upgrade_sensor,recv_data + sizeof(PackgeHead),sizeof(UpgradeSensorReq));
|
||||
jd.CmtCmd_86(upgrade_sensor.filename);
|
||||
}break;
|
||||
case KEigenvalue:{
|
||||
|
||||
}
|
||||
|
||||
@ -98,10 +98,10 @@ enum Range{
|
||||
RANGE_50G = 4
|
||||
};
|
||||
struct DownloadConfigRes{
|
||||
char filename[32];
|
||||
int version;
|
||||
char filename[64];
|
||||
};
|
||||
struct DownloadConfig{
|
||||
int version;
|
||||
char gw_mac[20];
|
||||
char product[6]; // DN101;DN102
|
||||
char ip[16];
|
||||
@ -127,7 +127,7 @@ struct DownloadConfig{
|
||||
};
|
||||
|
||||
//上传配置 cmd 84
|
||||
struct UploadConfig{
|
||||
struct UploadConfigReq{
|
||||
char filename[32];
|
||||
};
|
||||
//网关更新 cmd 85
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user