📄 fert2000dlg.cpp
字号:
Index += 6;
if (Index >= Rtus[m_CurRtuNo].RecLen) break;
j--;
continue;
}
}
if (DispartRow)
{
str2 += " ";
j++;
if (j>=(RecSize.cx)) continue;
}
}
str.Format ("%02X ",Rtus[m_CurRtuNo].RecBuf[Index++]);
str2 += str;
if(Index >= Rtus[m_CurRtuNo].RecLen) break;
}
RecColor[CurRecRow] = SendRecColor[RecColorPtr];
RecShowStr[CurRecRow++] = str2;
str2 = "";
if (CurRecRow >= RecSize.cy) CurRecRow = 0;
if (Index >= Rtus[m_CurRtuNo].RecLen) break;
}
Rtus[m_CurRtuNo].bReceiveCanDisp = FALSE;
RecShowStr[CurRecRow] = "";
ShowType |= 0x2;
RecColorPtr = ++RecColorPtr % 5;
}
}else
{
CString str;
int ChNo = m_CurChNo;//Rtus[m_CurRtuNo].RtuChNo;
int DataLen = (Channels[ChNo].MoxaEnd - Channels[ChNo].MoxaShowStart + REC_BUF_LEN)%REC_BUF_LEN;
BYTE *MoxaBuf = &Channels[ChNo].MoxaReadBuffer[0];
int MoxaShowStart = Channels[ChNo].MoxaShowStart;
for (int j=0;j<DataLen;j++)
{
str.Format("%02X ",Channels[ChNo].MoxaReadBuffer[MoxaShowStart++]);
RecShowStr[CurRecRow] += str;
if (MoxaShowStart >= REC_BUF_LEN) MoxaShowStart = 0;
if (++CurRecCol >= RecSize.cx)
{
CurRecCol = 0;
if (++CurRecRow >= RecSize.cy)
{
if (++RecColorPtr >= 5) RecColorPtr = 0;
CurRecRow =0;
}
RecShowStr[CurRecRow] = "";
RecColor[CurRecRow] = SendRecColor[RecColorPtr];
}
}
ShowType |= 2;
Channels[ChNo].MoxaShowStart = MoxaShowStart;
}
}
else
{
CString str;
int ChNo = m_CurChNo;//Rtus[m_CurRtuNo].RtuChNo;
if (Channels[ChNo].WorkType == 3)//Gps
{
if (GpsSendBuf[0])
{
CString str;
for (int j = 0;j < GpsSendBuf[1];j++)
{
str.Format("%02X ",GpsSendBuf[2 + j]);
SendShowStr[CurSendRow] += str;
}
if (++CurSendRow >= SendSize.cy) CurSendRow = 0;
if (++SendColorPtr >= 5) SendColorPtr = 0;
GpsSendBuf[0] = 0;
SendShowStr[CurSendRow] = "";
SendColor[CurSendRow] = SendRecColor[SendColorPtr];
ShowType |= 0x1;
}
if (GpsRecBuf[0])//Gps处理接收数据可显示
{
for (int j=0;j<GpsRecBuf[1];j++)
{
str.Format("%02X ",GpsRecBuf[2 + j]);
RecShowStr[CurRecRow] += str;
}
if (++CurRecRow >= RecSize.cy) CurRecRow = 0;
if (++RecColorPtr >= 5) RecColorPtr = 0;
RecShowStr[CurRecRow] = "";
RecColor[CurRecRow] = SendRecColor[RecColorPtr];
GpsRecBuf[0] = 0;
ShowType |= 2;
}
}
else if (Channels[ChNo].WorkType == 4 || Channels[ChNo].WorkType == 6)//Channel Switch
{
if (SwitchSendBuf[0])
{
CString str;
for (int j = 0;j < SwitchSendBuf[1];j++)
{
str.Format("%02X ",SwitchSendBuf[2 + j]);
SendShowStr[CurSendRow] += str;
}
if (++CurSendRow >= SendSize.cy) CurSendRow = 0;
if (++SendColorPtr >= 5) SendColorPtr = 0;
SwitchSendBuf[0] = 0;
SendShowStr[CurSendRow] = "";
SendColor[CurSendRow] = SendRecColor[SendColorPtr];
ShowType |= 0x1;
}
if (SwitchRecBuf[0])
{
for (int j=0;j<SwitchRecBuf[1];j++)
{
str.Format("%02X ",SwitchRecBuf[2 + j]);
RecShowStr[CurRecRow] += str;
}
if (++CurRecRow >= RecSize.cy) CurRecRow = 0;
if (++RecColorPtr >= 5) RecColorPtr = 0;
RecShowStr[CurRecRow] = "";
RecColor[CurRecRow] = SendRecColor[RecColorPtr];
SwitchRecBuf[0] = 0;
ShowType |= 2;
}
}
}
if (ShowType) ShowBuffer(ShowType,true,OldSendRow,OldRecRow);
}
void CFert2000Dlg::OnButtonPause()
{
// TODO: Add your control notification handler code here
if (bShowPause)
{
GetDlgItem(IDC_BUTTON_PAUSE)->SetWindowText("暂停");
bShowPause = false;
}else
{
GetDlgItem(IDC_BUTTON_PAUSE)->SetWindowText("刷新");
bShowPause = true;
}
}
void CFert2000Dlg::OnRecwindow()
{
if (ShowType == 1) return;
ShowType = 1;
GetMenu()->CheckMenuItem(IDM_RECWINDOW,MF_BYCOMMAND|MF_CHECKED);
GetMenu()->CheckMenuItem(IDM_SENDWINDOW,MF_BYCOMMAND|MF_UNCHECKED);
GetMenu()->CheckMenuItem(IDM_ALLWINDOW,MF_BYCOMMAND|MF_UNCHECKED);
CRect ClientRect;
long RecCy =0,Cx = 0;
GetClientRect(&ClientRect);
ClientRect.top += 60;
ClientRect.bottom -= 14;
ClientRect.left += 14;
ClientRect.right -= 14;
RecCy = ClientRect.bottom - ClientRect.top;
Cx = ClientRect.right - ClientRect.left;
RecBufferRect.left = ClientRect.left;
RecBufferRect.top = ClientRect.top;
RecBufferRect.right = ClientRect.right;
RecSize.cx = (int)(Cx / FontWidth / 3);
RecSize.cy = (int)(RecCy / (FontHeight + 5));
RecBufferRect.bottom = RecBufferRect.top + RecSize.cy*(FontHeight + 5);
RecShowStr.SetSize(RecSize.cy);
RecColor.SetSize(RecSize.cy);
CClientDC dc(this);
dc.FillSolidRect(ClientRect,RGB(0XC0,0XC0,0XC0));
ShowBuffer(3);
}
void CFert2000Dlg::OnSendwindow()
{
if (ShowType == 2) return;
ShowType = 2;
GetMenu()->CheckMenuItem(IDM_RECWINDOW,MF_BYCOMMAND|MF_UNCHECKED);
GetMenu()->CheckMenuItem(IDM_SENDWINDOW,MF_BYCOMMAND|MF_CHECKED);
GetMenu()->CheckMenuItem(IDM_ALLWINDOW,MF_BYCOMMAND|MF_UNCHECKED);
CRect ClientRect;
long SendCy =0,Cx = 0;
GetClientRect(&ClientRect);
ClientRect.top += 60;
ClientRect.bottom -= 14;
ClientRect.left += 14;
ClientRect.right -= 14;
SendCy = ClientRect.bottom - ClientRect.top;
Cx = ClientRect.right - ClientRect.left;
SendBufferRect.left = ClientRect.left;
SendBufferRect.top = ClientRect.top;
SendBufferRect.right = ClientRect.right;
SendSize.cx = (int)(Cx / FontWidth / 3);
SendSize.cy = (int)(SendCy / (FontHeight + 5));
SendBufferRect.bottom = SendBufferRect.top + SendSize.cy*(FontHeight + 5);
SendShowStr.SetSize(SendSize.cy);
SendColor.SetSize(SendSize.cy);
CClientDC dc(this);
dc.FillSolidRect(ClientRect,RGB(0XC0,0XC0,0XC0));
ShowBuffer(3);
}
void CFert2000Dlg::OnAllwindow()
{
if (ShowType == 0) return;
ShowType = 0;
GetMenu()->CheckMenuItem(IDM_RECWINDOW,MF_BYCOMMAND|MF_UNCHECKED);
GetMenu()->CheckMenuItem(IDM_SENDWINDOW,MF_BYCOMMAND|MF_UNCHECKED);
GetMenu()->CheckMenuItem(IDM_ALLWINDOW,MF_BYCOMMAND|MF_CHECKED);
CRect ClientRect;
CFont Font,*OldFont;
long SendCy=0,RecCy=0,Cx = 0;
CClientDC ClientDC(this);
TEXTMETRIC TextOption;
Font.CreatePointFont(120,"Fixedsys");
OldFont = ClientDC.SelectObject(&Font);
ClientDC.GetTextMetrics(&TextOption);
FontHeight = TextOption.tmHeight;
FontWidth = TextOption.tmHeight / 2;
GetClientRect(&ClientRect);
ClientRect.top += 60;
ClientRect.bottom -= 14;
ClientRect.left += 14;
ClientRect.right -= 14;
RecCy = (ClientRect.bottom - ClientRect.top) * 3/5;
SendCy = (ClientRect.bottom - ClientRect.top) * 2/5 - 20;
Cx = ClientRect.right - ClientRect.left;
RecBufferRect.left = ClientRect.left;
RecBufferRect.top = ClientRect.top;
RecBufferRect.right = ClientRect.right;
SendBufferRect.left = ClientRect.left;
SendBufferRect.top = ClientRect.top + RecCy + 20;
SendBufferRect.right = ClientRect.right;
RecSize.cx = (int)(Cx / FontWidth / 3);
RecSize.cy = (int)(RecCy / (FontHeight+5));
//RecShowStr.SetSize(RecSize.cy);
RecBufferRect.bottom = RecBufferRect.top + RecSize.cy * (FontHeight+5);
SendSize.cx = RecSize.cx;
SendSize.cy = (int)(SendCy / (FontHeight + 5));
//SendShowStr.SetSize(SendSize.cy);
SendBufferRect.bottom = SendBufferRect.top + SendSize.cy*(FontHeight + 5);
ClientDC.SelectObject (OldFont);
Font.DeleteObject ();
CClientDC dc(this);
dc.FillSolidRect(ClientRect.left-2,ClientRect.top+2,ClientRect.right+2,ClientRect.bottom+2,RGB(0XC0,0XC0,0XC0));
ShowBuffer(3);
}
void CFert2000Dlg::OnKybit()
{
// TODO: Add your control notification handler code here
CAboutDlg Dlg;
Dlg.DoModal();
}
void CFert2000Dlg::OnAllShow()
{
if (!CheckOkShow) return;
CheckOkShow = 0;
GetMenu()->CheckMenuItem(IDM_ALL_SHOW,MF_BYCOMMAND|MF_CHECKED);
GetMenu()->CheckMenuItem(IDM_CHECK_SHOW,MF_BYCOMMAND|MF_UNCHECKED);
}
void CFert2000Dlg::OnCheckShow()
{
if (CheckOkShow) return;
CheckOkShow = 1;
GetMenu()->CheckMenuItem(IDM_ALL_SHOW,MF_BYCOMMAND|MF_UNCHECKED);
GetMenu()->CheckMenuItem(IDM_CHECK_SHOW,MF_BYCOMMAND|MF_CHECKED);
}
void CFert2000Dlg::OnNorowshow()
{
if (!DispartRow) return;
DispartRow = 0;
GetMenu()->CheckMenuItem(IDM_ROWSHOW,MF_BYCOMMAND|MF_UNCHECKED);
GetMenu()->CheckMenuItem(IDM_NOROWSHOW,MF_BYCOMMAND|MF_CHECKED);
}
void CFert2000Dlg::OnRowshow()
{
if (DispartRow) return;
DispartRow = 1;
GetMenu()->CheckMenuItem(IDM_ROWSHOW,MF_BYCOMMAND|MF_CHECKED);
GetMenu()->CheckMenuItem(IDM_NOROWSHOW,MF_BYCOMMAND|MF_UNCHECKED);
}
void CFert2000Dlg::InitBufferRect()
{
CRect ClientRect;
CFont Font,*OldFont;
long SendCy=0,RecCy=0,Cx = 0;
CClientDC ClientDC(this);
TEXTMETRIC TextOption;
Font.CreatePointFont(120,"Fixedsys");
OldFont = ClientDC.SelectObject(&Font);
ClientDC.GetTextMetrics(&TextOption);
FontHeight = TextOption.tmHeight;
FontWidth = TextOption.tmHeight / 2;
GetClientRect(&ClientRect);
ClientRect.top += 60;
ClientRect.bottom -= 14;
ClientRect.left += 14;
ClientRect.right -= 14;
RecCy = (ClientRect.bottom - ClientRect.top) * 3/5;
SendCy = (ClientRect.bottom - ClientRect.top) * 2/5 - 20;
Cx = ClientRect.right - ClientRect.left;
RecBufferRect.left = ClientRect.left;
RecBufferRect.top = ClientRect.top;
RecBufferRect.right = ClientRect.right;
SendBufferRect.left = ClientRect.left;
SendBufferRect.top = ClientRect.top + RecCy + 20;
SendBufferRect.right = ClientRect.right;
RecSize.cx = (int)(Cx / FontWidth / 3);
RecSize.cy = (int)(RecCy / (FontHeight+5));
RecShowStr.SetSize(RecSize.cy);
RecColor.SetSize(RecSize.cy);
RecBufferRect.bottom = RecBufferRect.top + RecSize.cy * (FontHeight+5);
SendSize.cx = RecSize.cx;
SendSize.cy = (int)(SendCy / (FontHeight + 5));
SendShowStr.SetSize(SendSize.cy);
SendColor.SetSize(SendSize.cy);
SendBufferRect.bottom = SendBufferRect.top + SendSize.cy*(FontHeight + 5);
ClientDC.SelectObject (OldFont);
Font.DeleteObject ();
}
void CFert2000Dlg::OnRtuCanshu()
{
// TODO: Add your command handler code here
if (!theApp.m_bPermit)
{
AfxMessageBox("你没有登录!",MB_OK + MB_ICONSTOP);
return;
}
if (!SystemCount.RtuNum)
{
MessageBox("RTU数为零!\n请先设置系统参数!","错误",MB_OK|MB_ICONSTOP);
return;
}
CRtuPara Dlg;
Dlg.bChanCall = false;
Dlg.DoModal();
m_ChNo.ResetContent();
CString str1;
// m_ChNo.AddString("计算机COM1");
// m_ChNo.AddString("计算机COM2");
for(int i=0;i<SystemCount.ChNum;i++)
{
str1.Format("COM%d",i+1);
m_ChNo.AddString(str1);
}
m_ChNo.SetCurSel (m_ChSelNo);
FillRtuNo(m_ChSelNo);
}
void CFert2000Dlg::OnSortShow()
{
CSortShow Dlg;
Dlg.EndCode = ShowEndCode;
Dlg.StartCode = ShowStartCode;
Dlg.CurRtuNo = m_CurRtuNo;
Dlg.DoModal();
if (Dlg.Confirm)
{
ShowEndCode = Dlg.EndCode;
ShowStartCode = Dlg.StartCode;
}
}
void CFert2000Dlg::OnButtonDebug()
{
if (!theApp.m_bPermit)
{
AfxMessageBox("你没有登录!",MB_OK + MB_ICONSTOP);
return;
}
UpdateData();
if (DebugRtuNo == -1)
{
CDebugDialog DebugDlg;
DebugDlg.m_RtuNo = m_CurRtuNo;
DebugDlg.DoModal();
if (DebugDlg.DebugFlag)
{
GetDlgItem(IDC_BUTTON_DEBUG)->SetWindowText("恢复正常");
}
}
else
{
DebugRtuNo = -1;
GetDlgItem(IDC_BUTTON_DEBUG)->SetWindowText("进行调试");
}
}
void CFert2000Dlg::FillRtuNo(int iChNo)
{
m_RtuNo.ResetContent ();
if (Channels[iChNo].Flag )
{
if (Channels[iChNo].WorkType < 3 || Channels[iChNo].WorkType == 5)
{
if (Channels[iChNo].ChRtuNum > 0)
{
m_RtuNo.EnableWindow ();
for (int i = 0;i < Channels[iChNo].ChRtuNum ;i++)
{
CString str1;
str1.Format ("%d-%s",Channels[iChNo].ChRtuNo[i],Rtus[Channels[iChNo].ChRtuNo[i]].Name );
m_RtuNo.AddString (str1);
}
if (m_RtuSelNo < m_RtuNo.GetCount ())
m_RtuNo.SetCurSel (m_RtuSelNo);
else
m_RtuNo.SetCurSel (0);
m_CurRtuNo = Channels[iChNo].ChRtuNo[0];
}
else
m_RtuNo.EnableWindow (false);
}
else//Gps or ChannelSwitch
m_RtuNo.EnableWindow (false);
}
else
m_RtuNo.EnableWindow (false);
}
void CFert2000Dlg::OnSelchangeComboChan()
{
UpdateData();
m_CurChNo = m_ChNo.GetCurSel ();
m_ChSelNo = m_CurChNo;
FillRtuNo(m_CurChNo);
if (Channels[m_CurChNo].Protocol == 0 || Channels[m_CurChNo].Protocol == 2 || Channels[m_CurChNo].Protocol == 3)
ConfirmShow = true;
else
ConfirmShow = false;
GetDlgItem(IDC_BUTTON_DEBUG)->SetWindowText("进行调试");
if (Channels[m_CurChNo].Protocol == 1 && Channels[m_CurChNo].WorkType == 0)
GetDlgItem(IDC_BUTTON_DEBUG)->EnableWindow(TRUE);
else
GetDlgItem(IDC_BUTTON_DEBUG)->EnableWindow(FALSE);
}
void CFert2000Dlg::OnSelchangeComboRtuno()
{
UpdateData(TRUE);
if (m_RtuNo.GetCount() <= 0) return;
m_RtuSelNo = m_RtuNo.GetCurSel ();
m_CurRtuNo = Channels[m_CurChNo].ChRtuNo [m_RtuSelNo];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -