📄 dlg_comstt.cpp
字号:
// (Version 1.00 :: 10-Mar-1999 :: Harutoshi Yoshida)
// Dlg_ComStt.cpp : 僀儞僾儕儊儞僥乕僔儑儞 僼傽僀儖
//
#include "stdafx.h"
#include "KSG.h"
#include "Dlg_ComStt.h"
#include "C_Proc.h"
#include "C_Work.h"
#if !C_FILE_INC
#include "C_File.h"
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlg_ComStt 僟僀傾儘僌
CDlg_ComStt::CDlg_ComStt(CWnd* pParent /*=NULL*/)
: CDialog(CDlg_ComStt::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlg_ComStt)
// 儊儌 - ClassWizard 偼偙偺埵抲偵儅僢僺儞僌梡偺儅僋儘傪捛壛傑偨偼嶍彍偟傑偡丅
//}}AFX_DATA_INIT
}
void CDlg_ComStt::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlg_ComStt)
// 儊儌 - ClassWizard 偼偙偺埵抲偵儅僢僺儞僌梡偺儅僋儘傪捛壛傑偨偼嶍彍偟傑偡丅
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlg_ComStt, CDialog)
//{{AFX_MSG_MAP(CDlg_ComStt)
ON_CBN_SELCHANGE(IDC_CMB_SEL_CH, OnSelchangeCmbSelCh)
ON_CBN_SELCHANGE(IDC_CMB_SEL_BUF, OnSelchangeCmbSelBuf)
ON_BN_CLICKED(IDC_BTN_SAVE, OnBtnSave)
ON_BN_CLICKED(IDC_BTN_LOAD, OnBtnLoad)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlg_ComStt 儊僢僙乕僕 僴儞僪儔
/*=====================================
m:04-Dec-1999
@p << initalize >>
=====================================*/
BOOL CDlg_ComStt::OnInitDialog()
{
CDialog::OnInitDialog();
CComboBox *pCmbBx;
// 慖戰 channel 曄峏
pCmbBx = (CComboBox*)GetDlgItem(IDC_CMB_SEL_CH);
pCmbBx->SetCurSel(DbgSelCh);
// 慖戰 Buffer 曄峏
pCmbBx = (CComboBox*)GetDlgItem(IDC_CMB_SEL_BUF);
pCmbBx->SetCurSel(DbgSelBf);
AllReDisp();
return (TRUE);
}
/*=====================================
m:04-Dec-1999
@p << 慡嵞昞帵 >>
=====================================*/
void CDlg_ComStt::AllReDisp()
{
CComboBox* pCmbBx;
CListBox* pLstBx;
char buf[80];
uchar c, *cp;
int a, ch, lc, x, cnt, wp;
// 慖戰 channel 曄峏
pCmbBx = (CComboBox*)GetDlgItem(IDC_CMB_SEL_CH);
DbgSelCh = pCmbBx->GetCurSel();
if (DbgSelCh < 0 || DbgSelCh >= MAX_CH){
DbgSelCh = 0;
pCmbBx->SetCurSel(DbgSelCh);
}
ch = DbgSelCh;
// 娤應揰昞帵
SetDlgItemText(IDC_STC_NAME, AdrEntDat[ch].AdrName);
// 偦偺懠偺僗僥乕僞僗昞帵
sprintf(buf, "%04d", Rcw[ch].RcvCnt); SetDlgItemText(IDC_STC_01, buf);
sprintf(buf, "%04d", Rcw[ch].RcvLen); SetDlgItemText(IDC_STC_02, buf);
sprintf(buf, "%04d", Rcw[ch].WrtPoi); SetDlgItemText(IDC_STC_03, buf);
sprintf(buf, "%04d", Rcw[ch].RedPoi); SetDlgItemText(IDC_STC_04, buf);
sprintf(buf, "%04d", Rcw[ch].ComPhs); SetDlgItemText(IDC_STC_05, buf);
sprintf(buf, "%04d", Rcw[ch].CalBcc & 0xff); SetDlgItemText(IDC_STC_06, buf);
sprintf(buf, "%04d", Scw[ch].WrtPoi); SetDlgItemText(IDC_STC_07, buf);
sprintf(buf, "%04d", Scw[ch].RedPoi); SetDlgItemText(IDC_STC_08, buf);
sprintf(buf, "%04d", Scw[ch].ComPhs); SetDlgItemText(IDC_STC_09, buf);
sprintf(buf, "%04d", Scw[ch].CalBcc & 0xff); SetDlgItemText(IDC_STC_10, buf);
// 慖戰 Buffer 曄峏
pCmbBx = (CComboBox*)GetDlgItem(IDC_CMB_SEL_BUF);
DbgSelBf = pCmbBx->GetCurSel();
pLstBx = (CListBox*) GetDlgItem(IDC_LST_01);
pLstBx->ResetContent(); // list box reset
if (DbgSelBf){ // 憲怣
wp = Scw[ch].WrtPoi;
cp = (uchar*)&Scw[ch].Buffer[0];
}
else{ // 庴怣
wp = Rcw[ch].WrtPoi;
cp = (uchar*)&Rcw[ch].Buffer[0];
}
cnt = (RSB_MAX + 1) / 16;
for (a=0;a<73;a++){ //
buf[a] = ' ';
}
buf[73] = 0;
//xxxx: 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 00 01234567 89ABCDEF
for (lc=0;lc<cnt;lc++){ // line loop
// address
sprintf(buf, "%04d", wp); buf[4] = ':';
for (a=0;a<16;a++){
x = 3 * a + 6 + (a / 8);
c = cp[wp];
wp &= RSB_MAX;
if (c < 0x20 || c > 0x7f){
c = '.';
}
sprintf(&buf[x], "%02x", (uint)cp[wp]); buf[x+2] = ' ';
x = a + 56 + (a / 8);
buf[x] = c;
wp ++;
}
pLstBx->InsertString(-1, buf);
}
pLstBx->SetCurSel(cnt-1);
}
/*=====================================
m:04-Dec-1999
@p << CH change >>
=====================================*/
void CDlg_ComStt::OnSelchangeCmbSelCh()
{
AllReDisp();
}
void CDlg_ComStt::OnSelchangeCmbSelBuf()
{
AllReDisp();
}
/*=====================================
m:04-Dec-1999
@p << Data Save >>
=====================================*/
void CDlg_ComStt::OnBtnSave()
{
int hdl;
char *name;
CC_File pFile;
name = "COM_DAT.DAT";
pFile.C_FileDelete(name);
hdl = pFile.Creat(name);
pFile.Close(hdl);
hdl = pFile.Open(name, _O_BINARY | O_RDWR);
if (hdl != -1){
pFile.Write(hdl, (char*) Rcw, sizeof(Rcw));
pFile.Write(hdl, (char*) Scw, sizeof(Scw));
}
pFile.Close(hdl);
}
void CDlg_ComStt::OnBtnLoad()
{
int hdl;
char *name;
CC_File pFile;
name = "COM_DAT.DAT";
hdl = pFile.Open(name, _O_BINARY | O_RDWR);
if (hdl != -1){
pFile.Read(hdl, (char*) Rcw, sizeof(Rcw));
pFile.Read(hdl, (char*) Scw, sizeof(Scw));
}
pFile.Close(hdl);
}
void CDlg_ComStt::OnOK()
{
int a, p;
uint bcc, c;
bcc = 0;
p = 4;
for (a=0;a<BF_256-1;a++){
c = (uint) Rcw[0].Buffer[p ++];
bcc += c;
}
c = (uint) Rcw[0].Buffer[p ++];
bcc = 0;
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -