Skip to content

Commit

Permalink
修改部分bug。
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoweihan committed Sep 14, 2017
1 parent 008221f commit cc83a5d
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 89 deletions.
28 changes: 14 additions & 14 deletions Src/Edislab/Bin_x64/SensorConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"SensorConfig": [
{
"SensorID": 1,
"SensorID": 0,
"AddtoSensorlist": true,
"SensorName": "静力",
"TypeName": "1-普通",
Expand Down Expand Up @@ -48,7 +48,7 @@
"Timelength": 15
},
{
"SensorID": 2,
"SensorID": 4,
"AddtoSensorlist": true,
"SensorName": "光电门",
"TypeName": "4-光电门",
Expand Down Expand Up @@ -87,7 +87,7 @@
"Timelength": 20
},
{
"SensorID": 3,
"SensorID": 16,
"AddtoSensorlist": true,
"SensorName": "单体位移",
"TypeName": "2-位移",
Expand Down Expand Up @@ -115,7 +115,7 @@
"Timelength": 20
},
{
"SensorID": 4,
"SensorID": 17,
"AddtoSensorlist": true,
"SensorName": "加速度",
"TypeName": "1-普通",
Expand Down Expand Up @@ -176,7 +176,7 @@
"Timelength": 15
},
{
"SensorID": 5,
"SensorID": 1,
"AddtoSensorlist": true,
"SensorName": "微力",
"TypeName": "1-普通",
Expand Down Expand Up @@ -215,7 +215,7 @@
"Timelength": 15
},
{
"SensorID": 6,
"SensorID": 10,
"AddtoSensorlist": true,
"SensorName": "普通温度",
"TypeName": "1-普通",
Expand Down Expand Up @@ -243,7 +243,7 @@
"Timelength": 180
},
{
"SensorID": 7,
"SensorID": 18,
"AddtoSensorlist": true,
"SensorName": "高温",
"TypeName": "1-普通",
Expand Down Expand Up @@ -271,7 +271,7 @@
"Timelength": 20
},
{
"SensorID": 8,
"SensorID": 12,
"AddtoSensorlist": true,
"SensorName": "压强",
"TypeName": "1-普通",
Expand Down Expand Up @@ -299,7 +299,7 @@
"Timelength": 960
},
{
"SensorID": 9,
"SensorID": 5,
"AddtoSensorlist": true,
"SensorName": "声振动",
"TypeName": "1-普通",
Expand Down Expand Up @@ -338,7 +338,7 @@
"Timelength": 5
},
{
"SensorID": 10,
"SensorID": 15,
"AddtoSensorlist": true,
"SensorName": "光强分布",
"TypeName": "6-专用实验",
Expand Down Expand Up @@ -366,7 +366,7 @@
"Timelength": 10
},
{
"SensorID": 11,
"SensorID": 15,
"AddtoSensorlist": true,
"SensorName": "光照度",
"TypeName": "1-普通",
Expand Down Expand Up @@ -405,7 +405,7 @@
"Timelength": 10
},
{
"SensorID": 12,
"SensorID": 43,
"AddtoSensorlist": true,
"SensorName": "电流",
"TypeName": "1-普通",
Expand Down Expand Up @@ -444,7 +444,7 @@
"Timelength": 20
},
{
"SensorID": 13,
"SensorID": 44,
"AddtoSensorlist": true,
"SensorName": "电压",
"TypeName": "1-普通",
Expand Down Expand Up @@ -483,7 +483,7 @@
"Timelength": 15
},
{
"SensorID": 14,
"SensorID": 11,
"AddtoSensorlist": true,
"SensorName": "磁感应强度",
"TypeName": "1-普通",
Expand Down
12 changes: 6 additions & 6 deletions Src/Edislab/Edislab Pro/CommandEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,24 +672,24 @@ void HandleStart(CEdislabProView* pView)
return;
}

std::vector<std::string> SensorNameArray;
CSensorIDGenerator::CreateInstance().GetAllSensorName(SensorNameArray,false);
std::vector<SENSOR_TYPE_INFO_ELEMENT> SensorArray;
CSensorManager::CreateInstance().GetSensorList(SensorArray);
if (s_bStartCapture)
{
//通知所有需要停止刷新的控件停止刷新
pView->NotifyControlsStopRefresh();
BOOST_FOREACH(auto& V,SensorNameArray)
BOOST_FOREACH(auto& V,SensorArray)
{
CSerialPortService::CreateInstance().StopSensorCollect(V);
CSerialPortService::CreateInstance().StopSensorCollect(V.nSensorID,V.nSensorSerialID);
}
}
else
{
//通知所有需要开始刷新的控件开始刷新
pView->NotifyControlsStartRefresh();
BOOST_FOREACH(auto& V,SensorNameArray)
BOOST_FOREACH(auto& V,SensorArray)
{
CSerialPortService::CreateInstance().StartSensorCollect(V);
CSerialPortService::CreateInstance().StartSensorCollect(V.nSensorID,V.nSensorSerialID);
}
}
s_bStartCapture = !s_bStartCapture;
Expand Down
7 changes: 5 additions & 2 deletions Src/Edislab/Edislab Pro/CustomGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "CustomGrid.h"
#include <algorithm>
#include <boost/foreach.hpp>
#include "SensorIDGenerator.h"
#include "SensorManager.h"
#include "Utility.h"
#include "Msg.h"
//默认增加列的宽度
Expand Down Expand Up @@ -384,7 +384,10 @@ void CCustomGrid::AddColumnInfo(const CString& strHeaderName,const CString& strC
{
CString strAddColumnName = ColumnElement.strColumnName;
std::string strTempColumnName = Utility::WideChar2MultiByte(strAddColumnName.GetBuffer(0));
if (ColumnElement.strColumnName == strColumnName || CSensorIDGenerator::CreateInstance().QuerySensorTypeIDByName(strTempColumnName) < 0)

SENSOR_TYPE_KEY KeyID;
CSensorManager::CreateInstance().QuerySensorIDByName(strTempColumnName,KeyID);
if (ColumnElement.strColumnName == strColumnName || KeyID.nSensorID < 0)
{
return true;
}
Expand Down
46 changes: 27 additions & 19 deletions Src/Edislab/Edislab Pro/DlgSensorChoose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#include "DlgSensorChoose.h"
#include <boost/foreach.hpp>
#include "Global.h"
#include "SensorTypeTable.h"
#include "SensorManager.h"
#include "Msg.h"
#include "SensorConfig.h"
#include "SerialPortService.h"
#include "GridColumnGroupManager.h"
// CDlgSensorChoose 对话框

IMPLEMENT_DYNAMIC(CDlgSensorChoose, CBaseDialog)
Expand Down Expand Up @@ -59,7 +65,6 @@ void CDlgSensorChoose::InitCtrls()
if (g_bAutoSelect)
{
m_CheckAutoChoose.SetCheck(BST_CHECKED);

m_BtnAdd.EnableWindow(FALSE);
m_BtnDel.EnableWindow(FALSE);
m_BtnDelAll.EnableWindow(FALSE);
Expand Down Expand Up @@ -174,7 +179,7 @@ void CDlgSensorChoose::OnBnClickedBtnAdd()
int nIndex = m_ListSensor.GetCurSel();
nIndex = (int)m_ListSensor.GetItemData(nIndex);
std::map<int, SENSOR_CONFIG_ELEMENT>::iterator iter = m_mapCurrentSensor.find(nIndex);
if (m_mapCurrentSensor.cend() != iter)
if (m_mapCurrentSensor.end() != iter)
{

if (iter->second.SensorRangeInfoArray.empty())
Expand All @@ -189,13 +194,12 @@ void CDlgSensorChoose::OnBnClickedBtnAdd()
{
std::string strSensorUnit = iter->second.SensorRangeInfoArray[0].strUnitName;

std::string strSensorName = iter->second.strSensorName + std::string("[") + strSensorUnit + std::string("]");
std::string strTempSensorName = CSensorTypeTable::CreateInstance().QuerySensorNameByID(iter->second.nSensorID);

if (-1 == CSensorIDGenerator::CreateInstance().AddSensor(strSensorName))
{
return;
}
std::string strSensorName = strTempSensorName;//strTempSensorName + std::string("[") + strSensorUnit + std::string("]");

CSensorManager::CreateInstance().RegisterSensor(iter->second.nSensorID,0);

str.Format(_T("数据列:%s(%s)"), CString(iter->second.strSensorSymbol.c_str()), CString(iter->second.strSensorName.c_str()));

// 拼凑添加项描述文字
Expand Down Expand Up @@ -275,7 +279,10 @@ void CDlgSensorChoose::OnBnClickedBtnDelete()
std::string strSensorUnit = element.SensorRangeInfoArray[0].strUnitName;

std::string strSensorName = element.strSensorName + std::string("[") + strSensorUnit + std::string("]");
CSensorIDGenerator::CreateInstance().DelSensor(strSensorName);

//根据ID

CSensorManager::CreateInstance().UnRegisterSensor(element.nSensorID,0);
// 删除表格数据列
CString strColumnName(strSensorName.c_str());
CGridColumnGroupManager::CreateInstance().RemoveColumnInfo(_T("当前"), strColumnName);
Expand Down Expand Up @@ -323,7 +330,7 @@ void CDlgSensorChoose::OnBnClickedBtnDeleteAll()
std::string strSensorUnit = element.SensorRangeInfoArray[0].strUnitName;

std::string strSensorName = element.strSensorName + std::string("[") + strSensorUnit + std::string("]");
CSensorIDGenerator::CreateInstance().DelSensor(strSensorName);
CSensorManager::CreateInstance().UnRegisterSensor(element.nSensorID,0);
// 删除表格数据列
CString strColumnName(strSensorName.c_str());
CGridColumnGroupManager::CreateInstance().RemoveColumnInfo(_T("当前"), strColumnName);
Expand Down Expand Up @@ -417,12 +424,10 @@ void CDlgSensorChoose::RefreshSensorList()
// 已经添加的传感器禁止再次显示
std::string strSensorUnit = sensor.SensorRangeInfoArray[0].strUnitName;

std::string strSensorName = sensor.strSensorName + std::string("[") + strSensorUnit + std::string("]");
if (CSensorIDGenerator::CreateInstance().IsSensorExist(strSensorName))
{
continue;
}
//根据传感器ID获取传感器名称
sensor.strSensorName = CSensorTypeTable::CreateInstance().QuerySensorNameByID(sensor.nSensorID);

//std::string strSensorName = sensor.strSensorName + std::string("[") + strSensorUnit + std::string("]");

CString str(sensor.strSensorName.c_str());
int nIndex = m_ListSensor.AddString(str);
Expand Down Expand Up @@ -523,11 +528,13 @@ void CDlgSensorChoose::OnCbnSelchangeCmbRange()

void CDlgSensorChoose::RefreshChoosedSensorList()
{
std::vector<std::string> vecStrSensorList;
CSensorIDGenerator::CreateInstance().GetAllSensorName(vecStrSensorList);
//获取已经选择的传感器
std::vector<SENSOR_TYPE_INFO_ELEMENT> vecStrSensorList;
CSensorManager::CreateInstance().GetSensorList(vecStrSensorList);

BOOST_FOREACH(auto &strSenorName , vecStrSensorList)
BOOST_FOREACH(auto &V , vecStrSensorList)
{
std::string strSenorName = V.strSensorName;
auto nIndexof = strSenorName.find_first_of('[');
if (-1 == nIndexof)
{
Expand All @@ -548,11 +555,12 @@ void CDlgSensorChoose::RefreshChoosedSensorList()
if (nNum == 0)
{

if (-1 == CSensorIDGenerator::CreateInstance().AddSensor(element.strSensorName))
/*if (-1 == CSensorIDGenerator::CreateInstance().AddSensor(element.strSensorName))
{
return;
}
}*/

CSensorManager::CreateInstance().RegisterSensor(element.nSensorID,0);
str.Format(_T("数据列:%s(%s)"), CString(element.strSensorSymbol.c_str()), CString(element.strSensorName.c_str()));

// 拼凑添加项描述文字
Expand Down
5 changes: 0 additions & 5 deletions Src/Edislab/Edislab Pro/DlgSensorChoose.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#pragma once
#include "BaseDialog.h"
#include "Type.h"
#include "SensorConfig.h"
#include "SensorIDGenerator.h"
#include "GridColumnGroupManager.h"
#include "SerialPortService.h"
#include "Msg.h"
#include <set>

// CDlgSensorChoose 对话框
Expand Down
2 changes: 0 additions & 2 deletions Src/Edislab/Edislab Pro/Edislab Pro.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@
<ClInclude Include="SensorConfig.h" />
<ClInclude Include="SensorData.h" />
<ClInclude Include="SensorDataManager.h" />
<ClInclude Include="SensorIDGenerator.h" />
<ClInclude Include="SensorManager.h" />
<ClInclude Include="SensorTypeTable.h" />
<ClInclude Include="SerialPortService.h" />
Expand Down Expand Up @@ -335,7 +334,6 @@
<ClCompile Include="SensorConfig.cpp" />
<ClCompile Include="SensorData.cpp" />
<ClCompile Include="SensorDataManager.cpp" />
<ClCompile Include="SensorIDGenerator.cpp" />
<ClCompile Include="SensorManager.cpp" />
<ClCompile Include="SensorTypeTable.cpp" />
<ClCompile Include="SerialPortService.cpp" />
Expand Down
6 changes: 0 additions & 6 deletions Src/Edislab/Edislab Pro/Edislab Pro.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,6 @@
<ClInclude Include="SensorConfig.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="SensorIDGenerator.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="ConverEncode.h">
<Filter>头文件</Filter>
</ClInclude>
Expand Down Expand Up @@ -437,9 +434,6 @@
<ClCompile Include="SensorConfig.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="SensorIDGenerator.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="ConverEncode.cpp">
<Filter>源文件</Filter>
</ClCompile>
Expand Down
8 changes: 5 additions & 3 deletions Src/Edislab/Edislab Pro/GridColumnGroupManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <algorithm>
#include <boost/foreach.hpp>
#include "Utility.h"
#include "SensorIDGenerator.h"
#include "SensorManager.h"
CGridColumnGroupManager& CGridColumnGroupManager::CreateInstance()
{
return s_obj;
Expand Down Expand Up @@ -212,9 +212,11 @@ void CGridColumnGroupManager::AddDisplayColumnInfo( const CString& strHeaderName
#else
strConvertColumnName = strTempColumnName.GetBuffer(0);
#endif

SENSOR_TYPE_KEY KeyID;
CSensorManager::CreateInstance().QuerySensorIDByName(strConvertColumnName,KeyID);
//列名称相同
if (ColumnInfo.strColumnName == AddColumnInfo.strColumnName ||
CSensorIDGenerator::CreateInstance().QuerySensorTypeIDByName(strConvertColumnName) < 0)
if (ColumnInfo.strColumnName == AddColumnInfo.strColumnName || KeyID.nSensorID < 0)
{
return true;
}
Expand Down
Loading

0 comments on commit cc83a5d

Please sign in to comment.