diff --git a/src/HTBusiDatabase.cpp b/src/HTBusiDatabase.cpp index b9e33a8..419018b 100644 --- a/src/HTBusiDatabase.cpp +++ b/src/HTBusiDatabase.cpp @@ -15,7 +15,7 @@ static const char *_FILE_ = "HTBusiDatabase.cpp"; /******************************************************************************* ** Function Name : vLoadCommunicationConf -** Description : 加载通信参数 +** Description : 锟斤拷锟斤拷通锟脚诧拷锟斤拷 ** Parameter In : None ** param name : ** Parameter Out : None @@ -46,8 +46,8 @@ void vLoadCommunicationConf() while (row = pdbHandle->GetRecord(res)) { if (row[0] && strlen(row[0]) > 0) { - if (atoi(row[0]) == 1) g_TConfig.setCommProtocol(1); // 通信模式 1:modbus - if (atoi(row[0]) == 2) g_TConfig.setCommProtocol(2); // 通信模式 2:61850 + if (atoi(row[0]) == 1) g_TConfig.setCommProtocol(1); // 通锟斤拷模式 1:modbus + if (atoi(row[0]) == 2) g_TConfig.setCommProtocol(2); // 通锟斤拷模式 2:61850 } if (row[1] && strlen(row[1]) > 0) { g_TConfig.setModbusRtuPort(row[1]); // COMx @@ -56,7 +56,7 @@ void vLoadCommunicationConf() g_TConfig.setModbusBaud(atoi(row[2])); // baud } if (row[3] && strlen(row[3]) > 0) { - g_TConfig.setModbusParity(row[3][0]); // parity bit N=无 O=奇 E=偶 + g_TConfig.setModbusParity(row[3][0]); // parity bit N=锟斤拷 O=锟斤拷 E=偶 } if (row[4] && strlen(row[4]) > 0) { g_TConfig.setModbusDataBit(atoi(row[4])); // data bit 6,7,8 @@ -84,7 +84,7 @@ void vLoadCommunicationConf() return; } -// 加载传感器基本信息 +// 锟斤拷锟截达拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷息 void vLoadBaseDeviceInfo() { char szSql[DEF_BUFFER_1K] = { 0 }; @@ -143,10 +143,10 @@ void vLoadBaseDeviceInfo() m_pIter = g_map_device.find((char*)strKey.c_str()); if (m_pIter == g_map_device.end()) { - // 新配置数据 + // 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 g_map_device.insert(map::value_type(strKey, stThres)); } - else { // 更新配置 + else { // 锟斤拷锟斤拷锟斤拷锟斤拷 memcpy(&m_pIter->second, &stThres, sizeof(ST_DEVICE_INFO)); } mutex_unlock(g_map_device_mutex); @@ -156,7 +156,7 @@ void vLoadBaseDeviceInfo() } /******************************************************************************* ** Function Name : vLoadAmpliDeviceThreshold -** Description : 加载振动装置阈值配置信息 +** Description : 锟斤拷锟斤拷锟斤拷装锟斤拷锟斤拷值锟斤拷锟斤拷锟斤拷息 ** Parameter In : None ** param name : ** Parameter Out : None @@ -238,10 +238,10 @@ void vLoadAmpliDeviceThreshold() m_pIter = g_thres_conf.find((char*)strKey.c_str()); if (m_pIter == g_thres_conf.end()) { - // 新配置数据 + // 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 g_thres_conf.insert(map::value_type(strKey, stThres)); } - else { // 更新配置 + else { // 锟斤拷锟斤拷锟斤拷锟斤拷 memcpy(&m_pIter->second, &stThres, sizeof(ST_THRES_CONF)); } mutex_unlock(g_thres_conf_mutex); @@ -252,7 +252,7 @@ void vLoadAmpliDeviceThreshold() /******************************************************************************* ** Function Name : vLoadNoiseDeviceThreshold -** Description : 加载噪声装置阈值配置信息 +** Description : 锟斤拷锟斤拷锟斤拷锟斤拷装锟斤拷锟斤拷值锟斤拷锟斤拷锟斤拷息 ** Parameter In : None ** param name : ** Parameter Out : None @@ -318,10 +318,10 @@ void vLoadNoiseDeviceThreshold() m_pIter = g_thres_conf.find((char*)stThres.szSensorID); if (m_pIter == g_thres_conf.end()) { - // 新配置数据 + // 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 g_thres_conf.insert(map::value_type(strKey, stThres)); } - else { // 更新配置 + else { // 锟斤拷锟斤拷锟斤拷锟斤拷 memcpy(&m_pIter->second, &stThres, sizeof(ST_THRES_CONF)); } mutex_unlock(g_thres_conf_mutex); @@ -332,7 +332,7 @@ void vLoadNoiseDeviceThreshold() /******************************************************************************* ** Function Name : vLoadCenterDeviceThreshold -** Description : 加载中心点装置阈值配置信息 +** Description : 锟斤拷锟斤拷锟斤拷锟侥碉拷装锟斤拷锟斤拷值锟斤拷锟斤拷锟斤拷息 ** Parameter In : None ** param name : ** Parameter Out : None @@ -397,10 +397,10 @@ void vLoadCenterDeviceThreshold() m_pIter = g_thres_conf.find((char*)stThres.szSensorID); if (m_pIter == g_thres_conf.end()) { - // 新配置数据 + // 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 g_thres_conf.insert(map::value_type(strKey, stThres)); } - else { // 更新配置 + else { // 锟斤拷锟斤拷锟斤拷锟斤拷 memcpy(&m_pIter->second, &stThres, sizeof(ST_THRES_CONF)); } mutex_unlock(g_thres_conf_mutex); @@ -409,7 +409,7 @@ void vLoadCenterDeviceThreshold() return; } -// 加载控制参数 +// 锟斤拷锟截匡拷锟狡诧拷锟斤拷 void vLoadDeviceCtrlParam() { char szSql[DEF_BUFFER_1K] = { 0 }; @@ -467,10 +467,10 @@ void vLoadDeviceCtrlParam() m_pIter = g_ctrl_conf.find((char*)stCtrl.szSensorID); if (m_pIter == g_ctrl_conf.end()) { - // 新配置数据 + // 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 g_ctrl_conf.insert(map::value_type(strKey, stCtrl)); } - else { // 更新配置 + else { // 锟斤拷锟斤拷锟斤拷锟斤拷 memcpy(&m_pIter->second, &stCtrl, sizeof(ST_CONTROL_CONF)); } mutex_unlock(g_ctrl_conf_mutex); @@ -479,16 +479,16 @@ void vLoadDeviceCtrlParam() return; } -// 加载ICD配置节点与传感器绑定关系 +// 锟斤拷锟斤拷ICD锟斤拷锟矫节碉拷锟诫传锟斤拷锟斤拷锟襟定癸拷系 void vLoadICDParameterBind() { char szSql[DEF_BUFFER_1K] = { 0 }; map::iterator m_pIter; CDBMySQL *pdbHandle = CDBMySQL::Instance(); if (!pdbHandle) return; - // 监测类型: 1=振动监测值 2=振动告警 3=噪声监测值 4=噪声告警 5=中心点监测 6=中心点告警 - sprintf(szSql, "select b.sensor_code, b.nodeid,b.frequency,b.nodename,b.monitype,p.nodetype from busi_iedparam p,busi_param_bind b " - "where p.nodename=b.nodename"); + // 锟斤拷锟斤拷锟斤拷锟: 1=锟今动硷拷锟街 2=锟今动告警 3=锟斤拷锟斤拷锟斤拷锟街 4=锟斤拷锟斤拷锟芥警 5=锟斤拷锟侥碉拷锟斤拷 6=锟斤拷锟侥碉拷婢 + sprintf(szSql, "select b.sensor_code, b.node_id,b.frequency,b.node_name,b.monitype,p.node_type from busi_iedparam p,busi_param_bind b " + "where p.node_name=b.node_name"); MYSQL_RES *res = pdbHandle->SelectRecord(szSql); if (!res) return; @@ -513,19 +513,19 @@ void vLoadICDParameterBind() strKey = stBind.nodename; } if (row[4] && strlen(row[4]) > 0) { - stBind.monitype = row[4][0]; // 监测类型: 1=振动监测值 2=振动告警 3=噪声监测值 4=噪声告警 5=中心点监测 6=中心点告警 + stBind.monitype = row[4][0]; // 锟斤拷锟斤拷锟斤拷锟: 1=锟今动硷拷锟街 2=锟今动告警 3=锟斤拷锟斤拷锟斤拷锟街 4=锟斤拷锟斤拷锟芥警 5=锟斤拷锟侥碉拷锟斤拷 6=锟斤拷锟侥碉拷婢 } if (row[5] && strlen(row[5]) > 0) { - strcpy(stBind.nodetype, row[5]); // 节点类型 MX,ST,SE + strcpy(stBind.nodetype, row[5]); // 锟节碉拷锟斤拷锟斤拷 MX,ST,SE } mutex_lock(g_map_parambind_mutex); m_pIter = g_map_parambind.find((char*)stBind.nodename); if (m_pIter == g_map_parambind.end()) { - // 新配置数据 + // 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 g_map_parambind.insert(map::value_type(strKey, stBind)); } - else { // 更新配置 + else { // 锟斤拷锟斤拷锟斤拷锟斤拷 memcpy(&m_pIter->second, &stBind, sizeof(ST_PARAM_BIND)); } mutex_unlock(g_map_parambind_mutex); @@ -535,7 +535,7 @@ void vLoadICDParameterBind() } -// 添加Ied不能连接的告警消息 +// 锟斤拷锟斤拷Ied锟斤拷锟斤拷锟斤拷锟接的告警锟斤拷息 void vSetIedDevicesWarnMesg(char *Ied_ip, int port, time_t altime) { char szTime[32] = { 0 }; @@ -546,14 +546,14 @@ void vSetIedDevicesWarnMesg(char *Ied_ip, int port, time_t altime) } vTranHostTimeFmt(altime, szTime); snprintf(szSql, sizeof(szSql), "INSERT INTO busi_warning(id,sub_id,warn_time,warn_type,load_type,warn_desc,warn_level,state) " - "VALUES(guuid(), '%s', '%s','1', '1','%s:%d,Ied链接异常断开,请检查!', '0','1')", + "VALUES(guuid(), '%s', '%s','1', '1','%s:%d,Ied锟斤拷锟斤拷锟届常锟较匡拷,锟斤拷锟斤拷!', '0','1')", "", szTime, Ied_ip, port); vPrtLogMsg(LOG_DEBUG, RET_OK, "insert Warning: %s", szSql); if (!pdbHandle->InsertRecord((const char *)szSql)) { vPrtLogMsg(LOG_ERROR, RET_FAIL, "INSERT INTO warning message failed,SQL:%s", szSql); } } -// 删除Ied服务不能连接的告警消息 +// 删锟斤拷Ied锟斤拷锟斤拷锟斤拷锟斤拷锟接的告警锟斤拷息 void vDelIedDevicesWarnMesg(char *Ied_ip, int port, time_t altime) { int i = 0; @@ -565,7 +565,7 @@ void vDelIedDevicesWarnMesg(char *Ied_ip, int port, time_t altime) vTranHostTimeFmt(altime, szTime); snprintf(szSql, sizeof(szSql), "update busi_warning set process='network check', process_time=sysdate()," "process_user='system' where warn_type='1' and warn_level='0' and state = '1' and warn_time='%s' " - "warn_desc = '%s:%d,Ied链接异常断开,请检查!' ", szTime, Ied_ip, port); + "warn_desc = '%s:%d,Ied锟斤拷锟斤拷锟届常锟较匡拷,锟斤拷锟斤拷!' ", szTime, Ied_ip, port); vPrtLogMsg(LOG_DEBUG, RET_OK, "update Warning: %s", szSql); if (!pdbHandle->InsertRecord((const char *)szSql)) { vPrtLogMsg(LOG_ERROR, RET_FAIL, "update warning message failed,SQL:%s", szSql); @@ -573,7 +573,7 @@ void vDelIedDevicesWarnMesg(char *Ied_ip, int port, time_t altime) } -// 插入数据 +// 锟斤拷锟斤拷锟斤拷锟斤拷 void vSetRealDevicesMoniMesg(ST_DB_BODY *pData) { int i = 0; @@ -583,8 +583,11 @@ void vSetRealDevicesMoniMesg(ST_DB_BODY *pData) return; } vTranHostTimeFmt(pData->dtime, szTime); - // 1:振动装置 2 : 噪声装置 3 : 中心点装置 - if (pData->szDevType == 1) { + // 1:锟斤拷装锟斤拷 2 : 锟斤拷锟斤拷装锟斤拷 3 : 锟斤拷锟侥碉拷装锟斤拷 + + vPrtLogMsg(LOG_DEBUG, RET_OK, "rensichao insert type: %d", pData->szDevType); + + if (pData->szDevType == '1') { snprintf(szSql, sizeof(szSql), "insert into busi_ampli_real(id, file_id,main_id,sub_id,side,phase,in_out," "frequency,max_amplitude,ins_time) " "values(guuid(), '%s', '%s', '%s', '%c', '%c', '%c', '%s', '%.4f', '%s') ", @@ -592,12 +595,12 @@ void vSetRealDevicesMoniMesg(ST_DB_BODY *pData) pData->szFrequency, pData->value, szTime); vPrtLogMsg(LOG_DEBUG, RET_OK, "insert busi_ampli_real: %s", szSql); } - else if (pData->szDevType == 2) { + else if (pData->szDevType == '2') { snprintf(szSql, sizeof(szSql), "insert into busi_noise_real(id, main_id,max_amplitude,ins_time) " "values(guuid(), '%s','%.4f', '%s') ", pData->m_id, pData->value, szTime); } - else if (pData->szDevType == 3) { + else if (pData->szDevType == '3') { snprintf(szSql, sizeof(szSql), "insert into busi_center_real(id, main_id,max_amplitude,ins_time) " "values(guuid(), '%s','%.4f', '%s') ", pData->m_id, pData->value, szTime); @@ -607,7 +610,7 @@ void vSetRealDevicesMoniMesg(ST_DB_BODY *pData) } } -// 传感器上传的告警消息入库 +// 锟斤拷锟斤拷锟斤拷锟较达拷锟侥告警锟斤拷息锟斤拷锟 void vSetRealDevicesWarnMesg(ST_DB_WARN &stWarn) { char szTime[32] = { 0 }; @@ -634,7 +637,7 @@ void vSetRealDevicesWarnMesg(ST_DB_WARN &stWarn) -// 显示阈值配置信息 +// 锟斤拷示锟斤拷值锟斤拷锟斤拷锟斤拷息 void vPrtDeviceThresholdConf() { int i = 0; @@ -655,14 +658,14 @@ void vPrtDeviceThresholdConf() (m_pIter->second).dThreshold, ((m_pIter->second).szFrequency), (m_pIter->second).bPhase == 0 ? '-' : (m_pIter->second).bPhase, - ((m_pIter->second).bSide == 'P' ? "原边" : ((m_pIter->second).bSide == 'S' ? "副边":"-")), - ((m_pIter->second).bInOut == 'U' ? "上侧" : ((m_pIter->second).bInOut == 'D' ? "下侧" : "-"))); + ((m_pIter->second).bSide == 'P' ? "原锟斤拷" : ((m_pIter->second).bSide == 'S' ? "锟斤拷锟斤拷":"-")), + ((m_pIter->second).bInOut == 'U' ? "锟较诧拷" : ((m_pIter->second).bInOut == 'D' ? "锟铰诧拷" : "-"))); m_pIter++; i++; } vPrtLogMsg(LOG_DEBUG, RET_OK, "--------------- Print device threshold_size:%d-----------", g_thres_conf.size()); mutex_unlock(g_thres_conf_mutex); } -// 显示传感器控制参数 +// 锟斤拷示锟斤拷锟斤拷锟斤拷锟斤拷锟狡诧拷锟斤拷 void vPrtDeviceCtrlParam() { int i = 0; @@ -684,14 +687,14 @@ void vPrtDeviceCtrlParam() (m_pIter->second).SmpProd, (m_pIter->second).SmpInt, (m_pIter->second).StartTime, - ((m_pIter->second).alone == true ? "TRUE" : "FLAS")); //0:分 1 : 合 + ((m_pIter->second).alone == true ? "TRUE" : "FLAS")); //0:锟斤拷 1 : 锟斤拷 m_pIter++; i++; } vPrtLogMsg(LOG_DEBUG, RET_OK, "--------------- Print device control parameter_size:%d-----------", g_ctrl_conf.size()); mutex_unlock(g_ctrl_conf_mutex); } -// 显示传感器控制参数 +// 锟斤拷示锟斤拷锟斤拷锟斤拷锟斤拷锟狡诧拷锟斤拷 void vPrtICDParameterBind() { int i = 0; @@ -713,7 +716,7 @@ void vPrtICDParameterBind() (m_pIter->second).SmpProd, (m_pIter->second).SmpInt, (m_pIter->second).StartTime, - ((m_pIter->second).alone == true ? "TRUE" : "FLAS")); //0:分 1 : 合 + ((m_pIter->second).alone == true ? "TRUE" : "FLAS")); //0:锟斤拷 1 : 锟斤拷 m_pIter++; i++; } vPrtLogMsg(LOG_DEBUG, RET_OK, "--------------- Print device control parameter_size:%d-----------", g_ctrl_conf.size()); diff --git a/src/HTDatabase.cpp b/src/HTDatabase.cpp index f9a8098..c96aa3b 100644 --- a/src/HTDatabase.cpp +++ b/src/HTDatabase.cpp @@ -80,7 +80,7 @@ bool CDBMySQL::dbConnectPool() char value = 1; MYSQL *pMySql = mysql_init((MYSQL*)NULL); //mysql_options(pMySql, MYSQL_SET_CHARSET_NAME, "gbk"); - mysql_options(pMySql, MYSQL_OPT_RECONNECT, (char *)&value); //设置自动连接 + mysql_options(pMySql, MYSQL_OPT_RECONNECT, (char *)&value); //锟斤拷锟斤拷锟皆讹拷锟斤拷锟斤拷 if (pMySql != NULL) { if (!mysql_real_connect(pMySql,m_host,m_user,m_password,m_db,m_port,NULL,0)) @@ -115,7 +115,7 @@ MYSQL* CDBMySQL::GetIdleMySql() if (pMySql ) { m_lsIdleList.pop_front(); m_lsBusyList.push_back(pMySql); - mysql_ping(pMySql); // 检查连接是否正常 + mysql_ping(pMySql); // 锟斤拷锟斤拷锟斤拷锟斤拷欠锟斤拷锟斤拷锟 } } else @@ -138,7 +138,7 @@ void CDBMySQL::SetIdleMysql(MYSQL* pMySql) } //bStart = false : close auto commit // = true : open auto commit -bool CDBMySQL::dbAutoCommit(MYSQL *pMysql, bool bStart) // 开始事务处理 +bool CDBMySQL::dbAutoCommit(MYSQL *pMysql, bool bStart) // 锟斤拷始锟斤拷锟斤拷锟斤拷 { return mysql_autocommit(pMysql, bStart) ? false : true; } @@ -181,8 +181,8 @@ bool CDBMySQL::InsertRecordBitch(const char pszSql[][256], int count) { return false; } - dbAutoCommit(pMySql, false); // 开始批量提交事务 - //mysql_query(pMySql, "START TRANSACTION"); // 开启事务, 如果没有开启事务,那么效率会变得非常低下! + dbAutoCommit(pMySql, false); // 锟斤拷始锟斤拷锟斤拷锟结交锟斤拷锟斤拷 + //mysql_query(pMySql, "START TRANSACTION"); // 锟斤拷锟斤拷锟斤拷锟斤拷 锟斤拷锟矫伙拷锌锟斤拷锟斤拷锟斤拷锟斤拷锟矫葱э拷驶锟斤拷梅浅锟斤拷锟斤拷拢锟 // return 0: successed !0: failed for (int n = 0; n < count; n++) { @@ -195,7 +195,7 @@ bool CDBMySQL::InsertRecordBitch(const char pszSql[][256], int count) } } dbCommit(pMySql); - dbAutoCommit(pMySql, true); // 结束批量提交事务 + dbAutoCommit(pMySql, true); // 锟斤拷锟斤拷锟斤拷锟斤拷锟结交锟斤拷锟斤拷 SetIdleMysql(pMySql); return bRet; diff --git a/src/HTIEC61850.cpp b/src/HTIEC61850.cpp index d3a219c..3cb0ef1 100644 --- a/src/HTIEC61850.cpp +++ b/src/HTIEC61850.cpp @@ -461,7 +461,7 @@ void vDownLoadComtradeFiles(ST_IED_CONN_HANDLE &stIedCon) showComtradeFile(stIedCon.hConnHandle, g_TConfig.getIEDComtradePath()); // 鏌ョ湅寰呬笅杞界殑鏂囦欢鍒楄〃 getComtradeFile(stIedCon.hConnHandle); // 涓嬭浇鏂囦欢 - setComtradeFile(stIedCon.hConnHandle, "etc/setting.ini"); + setComtradeFile(stIedCon.hConnHandle, "../etc/setting.ini"); // 瑙f瀽褰曟挱鏂囦欢骞跺叆搴 memset(&stFiles, 0x00, sizeof(ST_FILES_ATTRIB)); while (!g_list_comtrad_files.empty() || g_list_comtrad_files.size() > 0) @@ -658,30 +658,37 @@ void vIedFreeIedEvent(ST_IED_CONN_HANDLE &stIedHandle) // 鏍规嵁icd鑺傜偣鍚嶇О锛岃幏鍙栦紶鎰熷櫒缁戝畾鍏崇郴 bool bGetDeviceBindRelationship(char *pNodeName, ST_DB_BODY &pDb, ST_DEVICE_INFO &stBaseInfo) { + vPrtLogMsg(LOG_WARNG, 0, "rensichao add list 1."); map::iterator m_pIter; - mutex_lock(g_map_parambind_mutex); + //mutex_lock(g_map_parambind_mutex); m_pIter = g_map_parambind.find((char*)pNodeName); + vPrtLogMsg(LOG_WARNG, 0, "rensichao add list 2."); if (m_pIter == g_map_parambind.end()) { vPrtLogMsg(LOG_WARNG, RET_FAIL, "can not found:[%s] bind device information.", pNodeName); return false; } - strcpy(pDb.szSensorID, (*m_pIter).second.sensorid); - strcpy(pDb.szFrequency , (*m_pIter).second.szFrequency); - mutex_unlock(g_map_parambind_mutex); + strcpy(pDb.szSensorID, m_pIter->second.sensorid); + strcpy(pDb.szFrequency , m_pIter->second.szFrequency); + //mutex_unlock(g_map_parambind_mutex); + vPrtLogMsg(LOG_WARNG, 0, "rensichao add list 3 [%s] [%s].",m_pIter->second.sensorid,m_pIter->second.szFrequency); string strKey = pDb.szSensorID; - if (strlen(pDb.szFrequency) > 0) { // 鏃犻鐜囨椂涓哄櫔澹板拰涓績鐐逛紶鎰熷櫒 - strKey.append("-").append(pDb.szFrequency); - } + //vPrtLogMsg(LOG_WARNG, 0, "rensichao add list 3 [%c][%c][%s][%s].",strKey[0],pDb.szSensorID[0],strKey,pDb.szSensorID); + //if (strlen(pDb.szFrequency) > 0) { // 鏃犻鐜囨椂涓哄櫔澹板拰涓績鐐逛紶鎰熷櫒 + // strKey.append("-").append(pDb.szFrequency); + //} map::iterator m_pTIter; - mutex_lock(g_map_device_mutex); + //mutex_lock(g_map_device_mutex); + vPrtLogMsg(LOG_WARNG, 0, "rensichao add list 4 [%s].",(char*)strKey.c_str()); m_pTIter = g_map_device.find((char*)strKey.c_str()); if (m_pTIter == g_map_device.end()) { vPrtLogMsg(LOG_WARNG, RET_FAIL, "can not found:[%s],objname:[%s] threshold setting.", pDb.szSensorID, pNodeName); return false; } + vPrtLogMsg(LOG_WARNG, 0, "rensichao add list 5."); memcpy(&stBaseInfo, &(*m_pTIter).second, sizeof(ST_DEVICE_INFO)); - mutex_unlock(g_map_device_mutex); + //mutex_unlock(g_map_device_mutex); + vPrtLogMsg(LOG_WARNG, 0, "rensichao add list 6."); return true ; } // 鑾峰彇鎸姩,鍣0,涓績鐐圭洃娴嬪 @@ -704,17 +711,21 @@ bool getIEDMoniValue(IedConnection conn, ST_PARAM_BIND &stBind, ST_IED_VALUES &s IedClientError error; char szTime[32] = { 0 }; bool ret = false; + vPrtLogMsg(LOG_WARNG, 0, "rensichao read [%s] \n", stBind.nodetype); - if (stringncasecmp((const char*)stBind.monitype, "MX", 2)) - fc = IEC61850_FC_MX; - else if(stringncasecmp((const char*)stBind.monitype, "ST", 2)) + if (!stringncasecmp((const char*)stBind.nodetype, "MX", 2)) + {fc = IEC61850_FC_MX; + vPrtLogMsg(LOG_WARNG, 0, "rensichao read fc [%d] \n", fc);} + else if(!stringncasecmp((const char*)stBind.nodetype, "ST", 2)) fc = IEC61850_FC_ST; - else if(stringncasecmp((const char*)stBind.monitype, "SE", 2)) + else if(!stringncasecmp((const char*)stBind.nodetype, "SE", 2)) fc = IEC61850_FC_SE; else { vPrtLogMsg(LOG_WARNG, 0, "read [%s],nodetype[MX|ST|SE] unkown!", stBind.nodename); return false; } + //vPrtLogMsg(LOG_WARNG, 0, "read [%s],[%d]\n", stBind.nodename,fc); + MmsValue* value = IedConnection_readObject(conn, &error, stBind.nodename, fc); if (value != NULL && error == 0) { int n = MmsValue_getArraySize(value); @@ -754,6 +765,7 @@ bool getIEDMoniValue(IedConnection conn, ST_PARAM_BIND &stBind, ST_IED_VALUES &s break; default: vPrtLogMsg(LOG_WARNG, error, "read [%s], value type unkown!", stBind.nodename); + vPrtLogMsg(LOG_WARNG, error, "rensichao read [%s], read [%d]", stBind.nodename, MmsValue_getType(value)); } MmsValue_delete(value); } @@ -789,6 +801,7 @@ bool getAlarmValue(IedConnection conn, char *pobjname,FunctionalConstraint fc) void Add_SetList(ST_DB_BODY *pData, ST_DEVICE_INFO *pstBase) { ST_DB_BODY stSetData; + vPrtLogMsg(LOG_DEBUG, 0, "rensichao confirm add_setlist"); memset(&stSetData, 0x00, sizeof(ST_DB_BODY)); memcpy(&stSetData, pData, sizeof(ST_DB_BODY)); @@ -798,6 +811,7 @@ void Add_SetList(ST_DB_BODY *pData, ST_DEVICE_INFO *pstBase) stSetData.phase = pstBase->cPhase; stSetData.side = pstBase->cSide; stSetData.szDevType = pstBase->cDevType; + vPrtLogMsg(LOG_DEBUG, 0, "rensichao confirm database %s,%c,%c,%c,%d",stSetData.m_id,stSetData.in_out,stSetData.phase,stSetData.side,stSetData.szDevType); mutex_lock(g_list_db_body_mutex); g_list_db_body.push_front(stSetData); @@ -874,12 +888,21 @@ void vGetFCMXData_YC(IedConnection conn) memset(&stBody, 0x00, sizeof(ST_DB_BODY)); memset(&stBase, 0x00, sizeof(ST_DEVICE_INFO)); - memcpy(&m_pIter->second, &stBind, sizeof(ST_PARAM_BIND)); + - if(false == getIEDMoniValue(conn, stBind, stIedVal)) continue; // 鍙栨尟骞呭 + memcpy(&stBind, &m_pIter->second, sizeof(ST_PARAM_BIND)); + vPrtLogMsg(LOG_WARNG, 0, "rensichao read pIter [%s] \n", stBind.nodetype); + + if(false == getIEDMoniValue(conn, stBind, stIedVal)) + { + continue; // 鍙栨尟骞呭 + } stBody.value = stIedVal.MX_f; - bGetDeviceBindRelationship(stBind.nodename, stBody, stBase); + vPrtLogMsg(LOG_WARNG, 0, "rensichao read add list [%d] \n", stBody.value); + if(false==bGetDeviceBindRelationship(stBind.nodename, stBody, stBase)) continue; + vPrtLogMsg(LOG_WARNG, 0, "rensichao read add list midddle[%d] \n", stBody.value); Add_SetList(&stBody,&stBase); + vPrtLogMsg(LOG_WARNG, 0, "rensichao read add list end[%s] \n", stBind.nodetype); // 棰勮鍒ゆ柇 ST_DB_WARN stWarn; diff --git a/src/HTIEC61850Thread.cpp b/src/HTIEC61850Thread.cpp index d378dec..560de95 100644 --- a/src/HTIEC61850Thread.cpp +++ b/src/HTIEC61850Thread.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** File name : HTIEC61850Thread.cpp -** Description : IEC 61850 库API -** : 第三方库 +** Description : IEC 61850 锟斤拷API +** 锟斤拷 锟斤拷锟斤拷锟斤拷锟斤拷 ** Create date : 2019.09.01 ** Auther by : Liuyx ** Version info : V1.0.01 @@ -21,12 +21,13 @@ static const char *_FILE_ = "HTIEC61850Thread.cpp"; ** parameter : none ** return code : NULL ***************************************************************************/ -void *thread_cache_proc(void *arg) // 同步内存数据线程 +void *thread_cache_proc(void *arg) // 同锟斤拷锟节达拷锟斤拷锟斤拷锟竭筹拷 { vPrtLogMsg(LOG_DEBUG, 0, "thread_cache_proc = %d startup...", GETTID()); while (g_Running) { vLoadDeviceCtrlParam(); + vLoadBaseDeviceInfo();// by rensihcao vLoadAmpliDeviceThreshold(); vLoadNoiseDeviceThreshold(); vLoadCenterDeviceThreshold(); @@ -68,14 +69,14 @@ void *thread_iec61850_client_proc(void *arg) while (g_Running && (IED_STATE_CONNECTED == IedConnection_getState(stIedConn.hConnHandle))) { - //vGetRemoteIEDModelConfig(stIedConn.hConnHandle); // 从IED获取icd模型 - //vSetFCSEData_CTRL(stIedConn.hConnHandle); // 下设控制参数 + //vGetRemoteIEDModelConfig(stIedConn.hConnHandle); // 锟斤拷IED锟斤拷取icd模锟斤拷 + //vSetFCSEData_CTRL(stIedConn.hConnHandle); // 锟斤拷锟斤拷锟斤拷撇锟斤拷锟 /* read an analog measurement value from server */ - vGetFCMXData_YC(stIedConn.hConnHandle); // 读取遥测数据-监测值 - //vGetFCMXData_YX(stIedConn.hConnHandle); // 读取遥信数据-告警位 + vGetFCMXData_YC(stIedConn.hConnHandle); // 锟斤拷取遥锟斤拷锟斤拷锟斤拷-锟斤拷锟街 + //vGetFCMXData_YX(stIedConn.hConnHandle); // 锟斤拷取遥锟斤拷锟斤拷锟斤拷-锟芥警位 - //vDownLoadComtradeFiles(stIedConn); // 下载录播文件 + //vDownLoadComtradeFiles(stIedConn); // 锟斤拷锟斤拷录锟斤拷锟侥硷拷 _SLEEP(1000 * 60); vPrtLogMsg(LOG_DEBUG, 0, "Get once monitor data complate..."); } @@ -143,7 +144,7 @@ void *thread_iec61850_manager_proc(void *arg) (*m_pIter).second.hConnHandle = IedConnection_create(); } - // 建立通信链路 + // 锟斤拷锟斤拷通锟斤拷锟斤拷路 IedConnection_connect((*m_pIter).second.hConnHandle, &error, (*m_pIter).second.ied_addr, (*m_pIter).second.ied_port); if (error != IED_ERROR_OK) { vPrtLogMsg(LOG_ERROR, error, "Failed to connect to %s:%i, try again later...", @@ -169,14 +170,14 @@ void *thread_iec61850_manager_proc(void *arg) // 校时 - // 上传配置 - setComtradeFile((*m_pIter).second.hConnHandle, "etc/setting.ini"); + // 锟较达拷锟斤拷锟斤拷 + setComtradeFile((*m_pIter).second.hConnHandle, "../etc/setting.ini"); pthread_t thread_handle_minor_recv = -1; #ifndef _WIN32 pthread_attr_t attr; pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); // 创建一个分离子线程,接收数据线程 + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); // 锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟竭筹拷,锟斤拷锟斤拷锟斤拷锟斤拷锟竭筹拷 #endif ht_pthread_create_background(&thread_handle_minor_recv, thread_iec61850_client_proc, (void*)&(*m_pIter).second); #ifndef _WIN32 @@ -216,8 +217,8 @@ void* thread_database_proc(void * arg) _SLEEP(MAX_SLEEP_EMPTY * 10); continue; } - memcpy(&stData, &(g_list_db_body.back()), sizeof(ST_DB_BODY)); // 由尾取出 - g_list_db_body.pop_back(); // 由尾删除 + memcpy(&stData, &(g_list_db_body.back()), sizeof(ST_DB_BODY)); // 锟斤拷尾取锟斤拷 + g_list_db_body.pop_back(); // 锟斤拷尾删锟斤拷 mutex_unlock(g_list_db_body_mutex); vSetRealDevicesMoniMesg(&stData); @@ -249,8 +250,8 @@ void* thread_dbalarm_proc(void * arg) _SLEEP(MAX_SLEEP_EMPTY * 10); continue; } - memcpy(&stAlarm, &(g_list_db_warn.back()), sizeof(ST_DB_WARN)); // 由尾取出 - g_list_db_warn.pop_back(); // 由尾删除 + memcpy(&stAlarm, &(g_list_db_warn.back()), sizeof(ST_DB_WARN)); // 锟斤拷尾取锟斤拷 + g_list_db_warn.pop_back(); // 锟斤拷尾删锟斤拷 mutex_unlock(g_list_db_warn_mutex); vSetRealDevicesWarnMesg(stAlarm); diff --git a/src/HTPublic.cpp b/src/HTPublic.cpp index 1743a8f..c8a9964 100644 --- a/src/HTPublic.cpp +++ b/src/HTPublic.cpp @@ -37,8 +37,8 @@ int iGetPid() } /**************************************************************** -** Description : 检查文件/目录是否存在 -** param in : pszName -- 要检查的文件/目录,FileName / PathName +** Description : 锟斤拷锟斤拷募锟/目录锟角凤拷锟斤拷锟 +** param in : pszName -- 要锟斤拷锟斤拷锟侥硷拷/目录,FileName / PathName ** : ** param out : None ** return code : 0 -- exist @@ -98,8 +98,8 @@ char* getDirName(char* path, char *dirname) return dirname; } /**************************************************************** -** Description : 创建目录 -** param in : pNmae -- 要创建的目录名称 +** Description : 锟斤拷锟斤拷目录 +** param in : pNmae -- 要锟斤拷锟斤拷锟斤拷目录锟斤拷锟斤拷 ** : ** param out : None ** return code : <0 -- failed @@ -122,12 +122,12 @@ int iBuildDirent(const char *pName) return iRet; } -// 移动文件到指定目录(备份文件) +// 锟狡讹拷锟侥硷拷锟斤拷指锟斤拷目录锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷 bool bMoveFile(char *filename, char *pBakPath) { char *p = NULL, *s = NULL, *t = NULL; char szCmd[1024] = { 0 }; - // 文件名格式:sersorID_time.jpg 或 ../img/sersorid_time.jpg + // 锟侥硷拷锟斤拷锟斤拷式锟斤拷sersorID_time.jpg 锟斤拷 ../img/sersorid_time.jpg if (filename && pBakPath) { if (iDirOrFileExist(pBakPath)) @@ -145,8 +145,8 @@ bool bMoveFile(char *filename, char *pBakPath) return false; } /**************************************************************** -** Description : 获取文件大小 -** param in : pNmae -- 文件名称 +** Description : 锟斤拷取锟侥硷拷锟斤拷小 +** param in : pNmae -- 锟侥硷拷锟斤拷锟斤拷 ** : ** param out : None ** return code : <0 -- failed @@ -163,8 +163,8 @@ int get_file_size(const char *path) return filesize; } /**************************************************************** -** Description : 获取文件创建时间 -** param in : pNmae -- 文件名称 +** Description : 锟斤拷取锟侥硷拷锟斤拷锟斤拷时锟斤拷 +** param in : pNmae -- 锟侥硷拷锟斤拷锟斤拷 ** : ** param out : pCreateTime -- YYYY-MM-DD HH24:MI:SS ** return code : <=0 -- failed @@ -188,22 +188,22 @@ int getFileCreateTime(const char *path, char *pCreateTime) return (int)statbuff.st_size ; } /**************************************************************** -** Description : 从文件全路径中截取文件父目录、文件名及文件扩展名称 -** param in : pFullPath -- 路径名称 +** Description : 锟斤拷锟侥硷拷全路锟斤拷锟叫斤拷取锟侥硷拷锟斤拷目录锟斤拷锟侥硷拷锟斤拷锟斤拷锟侥硷拷锟斤拷展锟斤拷锟斤拷 +** param in : pFullPath -- 路锟斤拷锟斤拷锟斤拷 ** : -** param out : pFilename -- 文件名 -** :pExt -- 扩展名 +** param out : pFilename -- 锟侥硷拷锟斤拷 +** 锟斤拷pExt -- 锟斤拷展锟斤拷 ** return code : <0 -- failed ****************************************************************/ bool bSplitFilenameByFullPath(char *pFullPath, char *pPrantPath, char *pFilename, char *pExt) { char *p, *s; - // 文件名格式:sersorID_time.jpg 或 ../img/sersorid_time.jpg + // 锟侥硷拷锟斤拷锟斤拷式锟斤拷sersorID_time.jpg 锟斤拷 ../img/sersorid_time.jpg if (pFullPath && strlen(pFullPath) > 1) { p = pFullPath + strlen((const char*)pFullPath); while (*p != '\\' && *p != '/' && p != pFullPath) p--; - strncpy(pPrantPath, pFullPath, p - pFullPath + 1); // 父目录名称 + strncpy(pPrantPath, pFullPath, p - pFullPath + 1); // 锟斤拷目录锟斤拷锟斤拷 s = p + 1; while (*s != '.') s++; if (*s != '.') strcpy(pFilename, p + 1); @@ -217,22 +217,22 @@ bool bSplitFilenameByFullPath(char *pFullPath, char *pPrantPath, char *pFilename } /**************************************************************** -** Description : 从文件全路径中截取文件父目录、文件名 -** param in : pFullPath -- 路径名称 +** Description : 锟斤拷锟侥硷拷全路锟斤拷锟叫斤拷取锟侥硷拷锟斤拷目录锟斤拷锟侥硷拷锟斤拷 +** param in : pFullPath -- 路锟斤拷锟斤拷锟斤拷 ** : -** param out : pFilename -- 文件名 -** :pExt -- 扩展名 +** param out : pFilename -- 锟侥硷拷锟斤拷 +** 锟斤拷pExt -- 锟斤拷展锟斤拷 ** return code : <0 -- failed ****************************************************************/ bool bSplitFilenameByPath(char *pFullPath, char *pPrantPath, char *pFilename) { char *p, *s; - // 文件名格式:sersorID_time.jpg 或 ../img/sersorid_time.jpg + // 锟侥硷拷锟斤拷锟斤拷式锟斤拷sersorID_time.jpg 锟斤拷 ../img/sersorid_time.jpg if (pFullPath && strlen(pFullPath) > 1) { p = pFullPath + strlen((const char*)pFullPath); while (*p != '\\' && *p != '/' && p != pFullPath) p--; - strncpy(pPrantPath, pFullPath, p - pFullPath + 1); // 父目录名称 + strncpy(pPrantPath, pFullPath, p - pFullPath + 1); // 锟斤拷目录锟斤拷锟斤拷 pPrantPath[p - pFullPath + 1] = 0x00; s = p + 1; @@ -243,7 +243,7 @@ bool bSplitFilenameByPath(char *pFullPath, char *pPrantPath, char *pFilename) return false; } /*********************************************************************** -** Description : 前导字符串 +** Description : 前锟斤拷锟街凤拷锟斤拷 ** param in : pstr -- source string end=0x00 ** : node -- split char ** : no -- index filed @@ -255,18 +255,18 @@ int iGetFileBeforString(char *pinstr, int pstrlen, char *poutstr) { //0312B12000042A383000022_001_01_20190906123640.dat char *p = NULL, *s = pinstr; - // 文件名称的时间之前最小长度0312B12000042A383000022_001_01_ + // 锟侥硷拷锟斤拷锟狡碉拷时锟斤拷之前锟斤拷小锟斤拷锟斤拷0312B12000042A383000022_001_01_ if (pinstr && pstrlen > 1) { p = pinstr + strlen((const char*)pinstr); while (*p != '_' && p != pinstr) p--; - strncpy(poutstr, pinstr, p - pinstr + 1); // 父目录名称 + strncpy(poutstr, pinstr, p - pinstr + 1); // 锟斤拷目录锟斤拷锟斤拷 poutstr[p - pinstr + 1] = 0x00; } return (p - pinstr + 1); } /*********************************************************************** -** Description : 获取主机时间 +** Description : 锟斤拷取锟斤拷锟斤拷时锟斤拷 ** param in : None ** param out : pszTime -- string time(yyyymmddhhmmss) ** return code : None @@ -293,7 +293,7 @@ void vGetHostTimeOnMillsecond(char *pszTime) return; } /*********************************************************************** -** Description : 获取主机时间 +** Description : 锟斤拷取锟斤拷锟斤拷时锟斤拷 ** param in : None ** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss+xxxx) ** return code : None @@ -321,7 +321,7 @@ time_t vGetHostTimeFmtOnMillsecond(char *pszTime) } /*********************************************************************** -** Description : 获取主机时间 +** Description : 锟斤拷取锟斤拷锟斤拷时锟斤拷 ** param in : None ** param out : pszTime -- string time(yyyymmddhhmmss) ** return code : None @@ -339,8 +339,8 @@ void vGetHostTime (char *pszTime) return ; } /*********************************************************************** -** Description : 将int时间转为已经消失的时间格式串 -** param in : c -- 时间差(s) +** Description : 锟斤拷int时锟斤拷转为锟窖撅拷锟斤拷失锟斤拷时锟斤拷锟绞斤拷锟 +** param in : c -- 时锟斤拷锟(s) ** param out : pszTime -- string time(DD(day) hh:mm:ss) ** return code : None ***********************************************************************/ @@ -354,10 +354,10 @@ void diffTimes(unsigned int c, char *pszTime) sprintf(pszTime, "%02d(day) %02d:%02d:%02d",day, hour, min, sec); } /*********************************************************************** -** Description : 计算与当前时间之差 -** param in : bcd_t -- BCD编码(YYMMDDHHMISS) +** Description : 锟斤拷锟斤拷锟诫当前时锟斤拷之锟斤拷 +** param in : bcd_t -- BCD锟斤拷锟斤拷(YYMMDDHHMISS) ** param out : none -** return code : 差值 +** return code : 锟斤拷值 ***********************************************************************/ int getCurrTimeDiff(unsigned char *bcd_t) { @@ -368,7 +368,7 @@ int getCurrTimeDiff(unsigned char *bcd_t) return int(time(NULL)- strTime2int((char*)szTime)); } /*********************************************************************** -** Description : 获取主机时间 +** Description : 锟斤拷取锟斤拷锟斤拷时锟斤拷 ** param in : None ** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss) ** return code : None @@ -386,7 +386,7 @@ time_t vGetHostTimeFmt (char *pszTime) return t; } /*********************************************************************** -** Description : 获取主机时间 +** Description : 锟斤拷取锟斤拷锟斤拷时锟斤拷 ** param in : None ** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss) ** return code : None @@ -405,7 +405,7 @@ time_t vGetHostTimeFmtBeforBay(char *pszTime, int beforbay) } /*********************************************************************** -** Description : 获取当天的起始和结束时间 +** Description : 锟斤拷取锟斤拷锟斤拷锟斤拷锟绞硷拷徒锟斤拷锟绞憋拷锟 ** param in : None ** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss) ** return code : None @@ -425,7 +425,7 @@ time_t vGeOneDayTimeFmt(char *pSTime, char *pETime) } /*********************************************************************** -** Description : 获取主机时间 +** Description : 锟斤拷取锟斤拷锟斤拷时锟斤拷 ** param in : None ** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss) ** return code : None @@ -438,7 +438,7 @@ unsigned int uiTime (void) } /*********************************************************************** -** Description : 转换time_t的时间 +** Description : 转锟斤拷time_t锟斤拷时锟斤拷 ** param in : t ** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss) ** return code : None @@ -452,8 +452,8 @@ void vTranHostTimeFmt (time_t t, char *pszTime) tms.tm_hour, tms.tm_min, tms.tm_sec); } /***************************************************************** -** Description: 时间串转整数 -** param in : pszTime -- 时间串(yyyy-mm-dd 24hh:mm:ss) +** Description: 时锟戒串转锟斤拷锟斤拷 +** param in : pszTime -- 时锟戒串(yyyy-mm-dd 24hh:mm:ss) ** param out : None ** return code: uintTime *****************************************************************/ @@ -481,7 +481,7 @@ time_t strTimeFmt2int(char *pszTime) return t1; } /*********************************************************************** -** Description : 获取当前时间点到之前360小时的时间段 +** Description : 锟斤拷取锟斤拷前时锟斤拷愕街360小时锟斤拷时锟斤拷锟 ** param in : t ** param out : pSTime -- string time(yyyymmddhh24mmss) ** param out : pETime -- string time(yyyymmddhh24mmss) @@ -499,15 +499,15 @@ void getCurrentBefor360Hour(char *pstime, char *petime) tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); - curTime = curTime - (360 * 60 * 60); // 360小时之前的时间 + curTime = curTime - (360 * 60 * 60); // 360小时之前锟斤拷时锟斤拷 memcpy(&tm, localtime((const time_t *)&curTime), sizeof(struct tm)); sprintf(pstime, "%04d%02d%02d%02d%02d%02d", tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); } /***************************************************************** -** Description: 时间串转整数 -** param in : pszTime -- 时间串(yyyymmddhhmmss) +** Description: 时锟戒串转锟斤拷锟斤拷 +** param in : pszTime -- 时锟戒串(yyyymmddhhmmss) ** param out : None ** return code: uintTime *****************************************************************/ @@ -535,20 +535,20 @@ time_t strTime2int(char *pszTime) return t1 ; } #if 0 -// 日月年(dmyy), 年的表示是先将年转换为2位十六进制数 +// 锟斤拷锟斤拷锟斤拷(dmyy), 锟斤拷谋锟绞撅拷锟斤拷冉锟斤拷锟阶拷锟轿2位十锟斤拷锟斤拷锟斤拷锟斤拷 void setPostionDate(unsigned char *pDate, unsigned char *pTime) { unsigned char szDate[5]={0}; unsigned short usNo = 0; // 20130109 - memcpy(szDate, pDate+6, 2); // 日 - memcpy(szDate+2, pDate+4, 2); // 月 + memcpy(szDate, pDate+6, 2); // 锟斤拷 + memcpy(szDate+2, pDate+4, 2); // 锟斤拷 asc_to_bcd(szDate, 4, pTime); memcpy(szDate, pDate, 4); usNo = htons(atoi((char*)szDate)); - memcpy(pTime+2, &usNo, sizeof(short)); // 年 + memcpy(pTime+2, &usNo, sizeof(short)); // 锟斤拷 } // pDate = HH24MMSS void setPostionTime(unsigned char *pDate, unsigned char *pTime) @@ -558,22 +558,22 @@ void setPostionTime(unsigned char *pDate, unsigned char *pTime) memcpy(pTime, szTmp, 3); } #else -// 日月年(dmyy), 年的表示是先将年转换为2位十六进制数 +// 锟斤拷锟斤拷锟斤拷(dmyy), 锟斤拷谋锟绞撅拷锟斤拷冉锟斤拷锟阶拷锟轿2位十锟斤拷锟斤拷锟斤拷锟斤拷 void setPostionDate(unsigned char *pDate, unsigned char *pTime) { char szDate[5]={0}; unsigned short usNo = 0; // 20130109 - memcpy(szDate, pDate+6, 2); // 日 + memcpy(szDate, pDate+6, 2); // 锟斤拷 pTime[0] = (char)atoi(szDate); - memcpy(szDate, pDate+4, 2); // 月 + memcpy(szDate, pDate+4, 2); // 锟斤拷 pTime[1] = (char)atoi(szDate); memcpy(szDate, pDate, 4); usNo = htons(atoi((char*)szDate)); - memcpy(pTime+2, &usNo, sizeof(short)); // 年 + memcpy(pTime+2, &usNo, sizeof(short)); // 锟斤拷 } // pDate = HH24MMSS @@ -584,10 +584,10 @@ void setPostionTime(unsigned char *pDate, unsigned char *pTime) memcpy(szTmp, pDate, 2); // 时 pTime[0] = (char)atoi(szTmp); - memcpy(szTmp, pDate+2, 2); // 分 + memcpy(szTmp, pDate+2, 2); // 锟斤拷 pTime[1] = (char)atoi(szTmp); - memcpy(szTmp, pDate+4, 2); // 秒 + memcpy(szTmp, pDate+4, 2); // 锟斤拷 pTime[2] = (char)atoi(szTmp); } #endif @@ -633,7 +633,7 @@ void getGnssTime(unsigned char *p_time) } /*********************************************************************** -** Description : 获取主机UTC时间 +** Description : 锟斤拷取锟斤拷锟斤拷UTC时锟斤拷 ** param in : None ** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss) ** return code : None @@ -651,7 +651,7 @@ void getUTCFmtTime (char *pszTime) return ; } /*********************************************************************** -** Description : 获取主机UTC时间 +** Description : 锟斤拷取锟斤拷锟斤拷UTC时锟斤拷 ** param in : None ** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss) ** return code : None @@ -667,7 +667,7 @@ time_t getUTCLongTime (void) return t1 ; } /*********************************************************************** -** Description : 将UTC时间转为格式串 +** Description : 锟斤拷UTC时锟斤拷转为锟斤拷式锟斤拷 ** param in : None ** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss) ** return code : None @@ -684,7 +684,7 @@ void UTC2FmtTime (time_t utc, char *pszTime) return ; } /*********************************************************************** -** Description : UTC时间转为本地时间 +** Description : UTC时锟斤拷转为锟斤拷锟斤拷时锟斤拷 ** param in : None ** param out : pszTime -- string time(yyyy-mm-dd hh:mm:ss) ** return code : None @@ -699,7 +699,7 @@ void UTC2LocalTime (time_t utc, char *pszTime) tm.tm_hour, tm.tm_min, tm.tm_sec); return ; } -// 本地时间转UTC时间, pTime: YYMMDDHH24MISS +// 锟斤拷锟斤拷时锟斤拷转UTC时锟斤拷, pTime: YYMMDDHH24MISS time_t local2Utc(unsigned char *pTime, int iLen) { unsigned char szTime[20] = {0}; @@ -715,7 +715,7 @@ time_t local2Utc(unsigned char *pTime, int iLen) return t1 ; } -// 本地时间转UTC整型时间 +// 锟斤拷锟斤拷时锟斤拷转UTC锟斤拷锟斤拷时锟斤拷 time_t local2UtcTime(time_t localTime) { struct tm tm = {0}; @@ -725,7 +725,7 @@ time_t local2UtcTime(time_t localTime) return t; } -// 根据BCD编码时间转报警ID +// 锟斤拷锟斤拷BCD锟斤拷锟斤拷时锟斤拷转锟斤拷锟斤拷ID // param_in: pTime -- YYMMDDHHMISS, \x13\x10\12\x09\x14\x11 unsigned int getWarnID(unsigned char *pTime, int iLen, unsigned int id) { @@ -741,7 +741,7 @@ unsigned int getWarnID(unsigned char *pTime, int iLen, unsigned int id) return (utc & 0xFFFFFFFF); } /*********************************************************************** -** Description : 获取源串中的第no个域,数字串,eg: 1923.122.3.4 +** Description : 锟斤拷取源锟斤拷锟叫的碉拷no锟斤拷锟斤拷,锟斤拷锟街达拷,eg: 1923.122.3.4 ** param in : pstr -- source string end=0x00 ** : node -- split char ** : no -- index filed @@ -771,7 +771,7 @@ int iSplitNumberFiled(char *pstr, char node, int no) } return 0; } -// 去除版本号首部字符,保留数字版本号 +// 去锟斤拷锟芥本锟斤拷锟阶诧拷锟街凤拷,锟斤拷锟斤拷锟斤拷锟街版本锟斤拷 // eg: Ver1.2.34 ==> 1.2.34 int iTrimVersionHeadChar(char *strver) { @@ -788,7 +788,7 @@ int iTrimVersionHeadChar(char *strver) return strlen(strver); } /*********************************************************************** -** Description : 获取源串中的第no个域, 字符串 +** Description : 锟斤拷取源锟斤拷锟叫的碉拷no锟斤拷锟斤拷, 锟街凤拷锟斤拷 ** param in : pstr -- source string end=0x00 ** : node -- split char ** : no -- index filed @@ -819,8 +819,8 @@ int iSplitStringFiled(char *pstr, char node, char no, char *pFiled) } /*********************************************************************** -** Description : getDateFromTime 从时间字符串获取Date信息 -** param in : p_time -- 时间字符串 +** Description : getDateFromTime 锟斤拷时锟斤拷锟街凤拷锟斤拷锟斤拷取Date锟斤拷息 +** param in : p_time -- 时锟斤拷锟街凤拷锟斤拷 ***********************************************************************/ void getDateFromTime(char* p_time,char* p_date) { @@ -893,7 +893,7 @@ void LRTrim(unsigned char *str) RigthTrim(str) ; } /************************************************************** -** Description: trim char string middle space,仅保留一个空格 +** Description: trim char string middle space,锟斤拷锟斤拷锟斤拷一锟斤拷锟秸革拷 ** param in : ** : *str -- sources string ** param out : @@ -920,7 +920,7 @@ void MiddleTrim(unsigned char *str) *last = '\0'; } /************************************************************** -** Description: trim char string middle space,仅保留一个空格 +** Description: trim char string middle space,锟斤拷锟斤拷锟斤拷一锟斤拷锟秸革拷 ** param in : ** : *str -- sources string ** param out : @@ -948,7 +948,7 @@ void strMiddleTrim(unsigned char *str) } /************************************************************** ** Description: check string all char is digit(number '0'--'9') -** param in : 是否为纯数字的字符串 +** param in : 锟角凤拷为锟斤拷锟斤拷锟街碉拷锟街凤拷锟斤拷 ** : *str -- sources string ** param out : ** : *str -- trim string @@ -1130,7 +1130,7 @@ Param in : Param out : pusTo : object strings. Return Code : none -Note : 本函数入参为网络字节序列 +Note : 锟斤拷锟斤拷锟斤拷锟斤拷锟轿拷锟斤拷锟斤拷纸锟斤拷锟斤拷锟 *************************************************************************/ unsigned int int64To32(utint64 u64) { @@ -1158,7 +1158,7 @@ void LocalTime2Bcd(char *pLocalTime, char *pBcd) } /************************************************************************* -Function : 检查字符串结束符 +Function : 锟斤拷锟斤拷址锟斤拷锟斤拷锟斤拷锟斤拷锟 Param in : psz : source string length : input string length, max 128(Byte) @@ -1202,7 +1202,7 @@ int getHexString(unsigned char *str, int length, unsigned char *pstr) return (length * 2); } /************************************************************************* -Function : 32位整数转二进制字符串 +Function : 32位锟斤拷锟斤拷转锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷 Param in : num : source uint Param out : @@ -1217,12 +1217,12 @@ void uint32_binstr(unsigned int num, char* pBin) { pBin[(sizeof(int)*8-1)-i] = (char)(((num >> i) & 1) + '0'); } - pBin[(sizeof(int)*8)] = 0x00; // 结束符 + pBin[(sizeof(int)*8)] = 0x00; // 锟斤拷锟斤拷锟斤拷 return; } /************************************************************************* -Function : 64位整数转二进制字符串 +Function : 64位锟斤拷锟斤拷转锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷 Param in : num : source uint Param out : @@ -1237,11 +1237,11 @@ void uint64_binstr(utint64 num, char* pBin) { pBin[(sizeof(utint64)*8-1)-i] = (char)(((num >> i) & 1) + '0'); } - pBin[(sizeof(utint64)*8)] = 0x00; // 结束符 + pBin[(sizeof(utint64)*8)] = 0x00; // 锟斤拷锟斤拷锟斤拷 return; } /************************************************************************* -Function : 二进制字符串转32位整数 +Function : 锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷转32位锟斤拷锟斤拷 Param in : pBin : source bin string(eg. 1010101001111), need '\0' end. Param out : @@ -1263,32 +1263,32 @@ unsigned int binstr_uint32(char *pBin) return n; } -//从低位到高位,取n的第m位,m=1...32 +//锟接碉拷位锟斤拷锟斤拷位,取n锟侥碉拷m位,m=1...32 int getBit(int n, int m) { if (m == 0) return (n >> (1 - 1)) & 1; return (n >> (m - 1)) & 1; } -//从低位到高位.将n的第m位置1, m=1...32 +//锟接碉拷位锟斤拷锟斤拷位.锟斤拷n锟侥碉拷m位锟斤拷1, m=1...32 int setBitToOne(int n, int m) { if (m == 0) return n | (1 << (1 - 1)); return n | (1 << (m - 1)); - /*将1左移m-1位找到第m位,得到000...1...000 - n在和这个数做或运算*/ + /*锟斤拷1锟斤拷锟斤拷m-1位锟揭碉拷锟斤拷m位锟斤拷锟矫碉拷000...1...000 + n锟节猴拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟*/ } -//从低位到高位, 将n的第m位置0,m=1...32 +//锟接碉拷位锟斤拷锟斤拷位, 锟斤拷n锟侥碉拷m位锟斤拷0,m=1...32 int setBitToZero(int n, int m) { if (m == 0) return n & ~(1 << (1 - 1)); return n & ~(1 << (m - 1)); - /* 将1左移m-1位找到第m位,取反后变成111...0...1111 - n再和这个数做与运算*/ + /* 锟斤拷1锟斤拷锟斤拷m-1位锟揭碉拷锟斤拷m位锟斤拷取锟斤拷锟斤拷锟斤拷111...0...1111 + n锟劫猴拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟*/ } /************************************************************************* -Function : 字符串反转 +Function : 锟街凤拷锟斤拷锟斤拷转 Param in : str : source string(eg. 1010101001111), need '\0' end. len : source length @@ -1305,7 +1305,7 @@ char* strSwap(char* str,int len) return (strSwap( str+1, len-2)-1); } /************************************************************************* -Function : 二进制字符串转64位整数 +Function : 锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷转64位锟斤拷锟斤拷 Param in : pBin : source bin string(eg. 1010101001111), need '\0' end. Param out : @@ -1328,7 +1328,7 @@ utint64 binstr_uint64(char *pBin) } /************************************************************************* -Function : 将Linux文件路径转为Windows的路径格式, 仅测试用 +Function : 锟斤拷Linux锟侥硷拷路锟斤拷转为Windows锟斤拷路锟斤拷锟斤拷式, 锟斤拷锟斤拷锟斤拷锟斤拷 Param in : pszPath: source path Param out : @@ -1350,7 +1350,7 @@ void Unix2WindowPath(char *pszPath) p[i] = 0x00; } /************************************************************************* -Function : 将Windows文件路径转为Linux的路径格式, 仅测试用 +Function : 锟斤拷Windows锟侥硷拷路锟斤拷转为Linux锟斤拷路锟斤拷锟斤拷式, 锟斤拷锟斤拷锟斤拷锟斤拷 Param in : pszPath -- source path Param out : : pszPath @@ -1390,7 +1390,7 @@ int stringncasecmp(const char *ps1, const char *ps2, int length) } /************************************************************************* -Function : 获取uuid +Function : 锟斤拷取uuid Param in : Param out : : pszPath @@ -1426,7 +1426,7 @@ int getuuid(char *str, int inlen ) /************************************************************************* -Function : 获取1-100内的随机数 +Function : 锟斤拷取1-100锟节碉拷锟斤拷锟斤拷锟 Param in : Param out : Return Code : none @@ -1438,7 +1438,7 @@ double getRandByTime() } /************************************************************************* -Function : 字符串转小写 +Function : 锟街凤拷锟斤拷转小写 Param in : Param out : : pszPath @@ -1452,14 +1452,14 @@ char *str2lower(char *s) for (int i = 0; i < len; i++) { if (s[i] >= 'A' && s[i] <= 'Z'){ - s[i] += 32;//+32转换为小写 + s[i] += 32;//+32转锟斤拷为小写 //s[i]=s[i]-'A'+'a'; } } return p; } /************************************************************************* -Function : 获取1-100内的随机数 +Function : 锟斤拷取1-100锟节碉拷锟斤拷锟斤拷锟 Param in : Param out : : pszPath @@ -1473,7 +1473,7 @@ char *str2upper(char *s) for (int i = 0; i < len; i++) { if (s[i] >= 'a' && s[i] <= 'z'){ - s[i] -= 32;//+32转换为小写 + s[i] -= 32;//+32转锟斤拷为小写 //s[i]=s[i]-'a'+'A'; } }