YKData.cpp
上传用户:asikq0571
上传日期:2014-07-12
资源大小:528k
文件大小:3k
- // YKData.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Peugeot.h"
- #include "YKData.h"
- #include "MainFrm.h"
- #include "PeugeotDoc.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CYKData dialog
- IMPLEMENT_DYNCREATE(CYKData, CDialog)
- CYKData::CYKData(CWnd* pParent /*=NULL*/)
- : CDialog(CYKData::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CYKData)
- m_YKSelect = -1;
- m_YKExecute = -1;
- //}}AFX_DATA_INIT
- // m_pYKGridCtrl = NULL;
- }
- void CYKData::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CYKData)
- DDX_Radio(pDX, IDC_YK_S_ACK, m_YKSelect);
- DDX_Radio(pDX, IDC_YK_E_ACK, m_YKExecute);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CYKData, CDialog)
- //{{AFX_MSG_MAP(CYKData)
- ON_BN_CLICKED(IDC_YK_E_ACK, OnYKEAck)
- ON_BN_CLICKED(IDC_YK_E_NAK, OnYKENak)
- ON_BN_CLICKED(IDC_YK_S_ACK, OnYKSAck)
- ON_BN_CLICKED(IDC_YK_S_NAK, OnYKSNak)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CYKData message handlers
- BOOL CYKData::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- /*
- if (m_pYKGridCtrl == NULL)
- {
- //创建m_pDoc->m_pYXGridCtrl对象
- m_pYKGridCtrl = new CGridCtrl;
- // m_pYXGridCtrl->m_hGridOwner=m_hGridOwner;
- if (!m_pYKGridCtrl)
- {
- AfxMessageBox("创建遥信表格失败");
- return false;
- }
- // 创建m_pDoc->m_pYXGridCtrl对象窗体
- CRect rect,TempRect;
- GetClientRect(TempRect);
- rect=TempRect;
- rect.left=TempRect.left+20;
- rect.top=TempRect.top+30;
- rect.bottom=TempRect.bottom-71;
- rect.right=TempRect.right-20;
- m_pYKGridCtrl->Create(rect, this, 100);
- // 初始化m_pDoc->m_pYXGridCtrl对象设置
- // m_pYXGridCtrl->m_wParam=1; //标志是遥信表格
- // m_pYXGridCtrl->m_bIsOpen=TRUE;
- m_pYKGridCtrl->SetEditable(TRUE);
- m_pYKGridCtrl->EnableDragAndDrop(TRUE);
- // TODO: Add extra initialization here
-
- }
- */
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CYKData::OnYKEAck()
- {
- UpdateYKChara(TRUE);
- }
- void CYKData::OnYKENak()
- {
- UpdateYKChara(TRUE);
- }
- void CYKData::OnYKSAck()
- {
- UpdateYKChara(TRUE);
- }
- void CYKData::OnYKSNak()
- {
- UpdateYKChara(TRUE);
- }
- void CYKData::UpdateYKChara(BOOL bSave)
- {
- CMainFrame* pMainFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd; //框架窗口指针;
- CPeugeotDoc* pDoc = (CPeugeotDoc*) pMainFrame->GetActiveDocument(); //文档指针
- ASSERT_VALID(pDoc);
-
- if (bSave)
- {
- UpdateData(TRUE);
- if (m_YKSelect == 0)
- pDoc->m_PrtIEC101.m_YKChara = pDoc->m_PrtIEC101.m_YKChara & 0xfd; //确认应答
- else
- pDoc->m_PrtIEC101.m_YKChara = pDoc->m_PrtIEC101.m_YKChara | 0x02; //否定应答
- if (m_YKExecute == 0)
- pDoc->m_PrtIEC101.m_YKChara = pDoc->m_PrtIEC101.m_YKChara & 0xfb; //确认应答
- else
- pDoc->m_PrtIEC101.m_YKChara = pDoc->m_PrtIEC101.m_YKChara | 0x04; //否定应答
- }
- else
- {
- m_YKSelect = (pDoc->m_PrtIEC101.m_YKChara & 0x02) >> 1;
- m_YKExecute = (pDoc->m_PrtIEC101.m_YKChara & 0x04) >> 2;
- UpdateData(FALSE);
- }
- }