Skip to content

Commit

Permalink
修改手动模式下添加传感器只能显示一列的Bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoweihan committed Jul 1, 2017
1 parent 87c7296 commit 67530ec
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 22 deletions.
3 changes: 3 additions & 0 deletions Src/Edislab/Edislab Pro/DlgGridContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,15 @@ void CDlgGridContainer::OnMenuGridLastRow()
void CDlgGridContainer::OnMenuGridAddColumn()
{
// TODO: 在此添加命令处理程序代码

#if 0
CDlgAddColumn Dlg;

if (IDOK == Dlg.DoModal())
{

}
#endif
}

LRESULT CDlgGridContainer::NotifyGridOption( WPARAM wp,LPARAM lp )
Expand Down
79 changes: 57 additions & 22 deletions Src/Edislab/Edislab Pro/DlgSensorChoose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,20 @@ void CDlgSensorChoose::InitCtrls()
{
if (g_bAutoSelect)
{
m_BtnChooseCon.SetCheck(BST_CHECKED);
m_CheckAutoChoose.SetCheck(BST_CHECKED);

m_BtnAdd.EnableWindow(FALSE);
m_BtnDel.EnableWindow(FALSE);
m_BtnDelAll.EnableWindow(FALSE);
m_BtnChooseCon.EnableWindow(FALSE);
}
else
{
m_BtnChooseCon.SetCheck(BST_CHECKED);
m_CheckAutoChoose.SetCheck(BST_UNCHECKED);
m_BtnAdd.EnableWindow(TRUE);
m_BtnDel.EnableWindow(TRUE);
m_BtnDelAll.EnableWindow(TRUE);
m_BtnChooseCon.EnableWindow(TRUE);
}

}
Expand Down Expand Up @@ -91,11 +100,13 @@ void CDlgSensorChoose::InitCtrls()
m_ListChoosedSensor.SetImageList(IDB_SENSOR_ICON_LIST, 48);
}

#if 0
if (m_CheckAutoChoose.GetSafeHwnd())
{
m_CheckAutoChoose.SetCheck(TRUE);
OnBnClickedCheckAutoRecognize();
}
#endif

if (m_ListSensor.GetSafeHwnd())
{
Expand All @@ -106,26 +117,34 @@ void CDlgSensorChoose::InitCtrls()

void CDlgSensorChoose::OnBnClickedCheckAutoRecognize()
{
if (NULL == m_CheckAutoChoose.GetSafeHwnd())
{
return;
}
// TODO: 在此添加控件通知处理程序代码
if(BST_CHECKED == m_CheckAutoChoose.GetCheck())
{
m_BtnAdd.EnableWindow(false);
m_BtnDel.EnableWindow(false);
m_BtnDelAll.EnableWindow(false);
m_BtnChooseCon.EnableWindow(false);
m_BtnAdd.EnableWindow(FALSE);
m_BtnDel.EnableWindow(FALSE);
m_BtnDelAll.EnableWindow(FALSE);
m_BtnChooseCon.EnableWindow(FALSE);
//begin add by xiaowei.han
g_bAutoSelect = true;
//end add by xiaowei.han
}
else
{
m_BtnAdd.EnableWindow(true);
m_BtnDel.EnableWindow(true);
m_BtnDelAll.EnableWindow(true);
m_BtnChooseCon.EnableWindow(true);
m_BtnAdd.EnableWindow(TRUE);
m_BtnDel.EnableWindow(TRUE);
m_BtnDelAll.EnableWindow(TRUE);
m_BtnChooseCon.EnableWindow(TRUE);
CSerialPortService::CreateInstance().StopSerialPortService();
//begin add by xiaowei.han
g_bAutoSelect = false;
//end add by xiaowei.han
}

// 添加传感器识别部分代码


}


Expand All @@ -145,19 +164,32 @@ BOOL CDlgSensorChoose::OnInitDialog()
void CDlgSensorChoose::OnBnClickedBtnAdd()
{
// TODO: 在此添加控件通知处理程序代码
if (NULL == m_ListSensor.GetSafeHwnd())
{
return;
}

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 (iter->second.SensorRangeInfoArray.empty())
{
return;
}
CString str;
// 拼凑添加项的头
// 传感器只能添加一个 2017.06.28
int nNum = (int)m_setChooseSensorID.count(iter->second.nSensorID);
if (nNum == 0)
{
std::string strSensorUnit = iter->second.SensorRangeInfoArray[0].strUnitName;

if (-1 == CSensorIDGenerator::CreateInstance().AddSensor(iter->second.strSensorName))
std::string strSensorName = iter->second.strSensorName + std::string("[") + strSensorUnit + std::string("]");

if (-1 == CSensorIDGenerator::CreateInstance().AddSensor(strSensorName))
{
return;
}
Expand All @@ -183,15 +215,23 @@ void CDlgSensorChoose::OnBnClickedBtnAdd()

// 添加列表显示列
COLUMN_INFO AddColumnInfo;
AddColumnInfo.strColumnName.Format(_T("%s(%s)"), CString(iter->second.strSensorSymbol.c_str()), CString(iter->second.strSensorName.c_str()));
//如果尚未添加时间列
AddColumnInfo.strColumnName = _T("t(s)时间");
CGridColumnGroupManager::CreateInstance().AddDisplayColumnInfo(_T("当前"),AddColumnInfo);
//begin modify by xiaowei.han 2017-7-1
//AddColumnInfo.strColumnName.Format(_T("%s[%s]"), CString(iter->second.strSensorSymbol.c_str()), CString(iter->second.strSensorName.c_str()));

AddColumnInfo.Reset();
AddColumnInfo.strColumnName.Format(_T("%s"), CString(strSensorName.c_str()));

CGridColumnGroupManager::CreateInstance().AddDisplayColumnInfo(_T("当前"), AddColumnInfo);
//通知Grid刷新
CWnd* pWnd = AfxGetMainWnd();
if (nullptr != pWnd)
{
pWnd->PostMessage(WM_NOTIFY_GRID_GROUP_INFO_CHANGE,0,0);
}

//end modify by xiaowei.han 2017-7-1
// 删除已有的传感器,防止重新添加
nIndex = m_ListSensor.GetCurSel();
m_ListSensor.DeleteString(nIndex);
Expand All @@ -201,12 +241,6 @@ void CDlgSensorChoose::OnBnClickedBtnAdd()
m_mapCurrentSensor.erase(iter);
}
}
// else
// {
// str.Format(_T("数据列:%s_%d(%s)"), CString(iter->second.strSensorSymbol.c_str()), nNum, CString(iter->second.strSensorName.c_str()));
// }


}
}

Expand Down Expand Up @@ -257,8 +291,9 @@ void CDlgSensorChoose::OnBnClickedBtnChooseConnected()
void CDlgSensorChoose::OnBnClickedBtnOk()
{
// TODO: 在此添加控件通知处理程序代码

CSerialPortService::CreateInstance().StartSerialPortService();

OnOK();
}

void CDlgSensorChoose::OnCbnSelchangeCmbSensorType()
Expand Down
Binary file modified Src/Edislab/Edislab Pro/resource.h
Binary file not shown.

0 comments on commit 67530ec

Please sign in to comment.