⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 soeview.cpp

📁 保护装置的mbpc软件
💻 CPP
字号:
// SoeView.cpp : implementation file
//

#include "stdafx.h"
#include "mbpc.h"
#include "SoeView.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSoeView

IMPLEMENT_DYNCREATE(CSoeView, CFormView)

CSoeView::CSoeView()
	: CFormView(CSoeView::IDD)
{
	//{{AFX_DATA_INIT(CSoeView)
	m_nTimerFlag = 0;
	m_szSoeDis = _T("");
	//}}AFX_DATA_INIT
}

CSoeView::~CSoeView()
{
}

void CSoeView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSoeView)
	DDX_Control(pDX, IDC_SOE, m_List);
	DDX_Text(pDX, IDC_SOEDIS, m_szSoeDis);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSoeView, CFormView)
	//{{AFX_MSG_MAP(CSoeView)
	ON_WM_CREATE()
	ON_WM_TIMER()
	ON_WM_DESTROY()
	ON_LBN_SELCHANGE(IDC_SOE, OnSelchangeSoe)
	ON_BN_CLICKED(IDC_CLEAR, OnClear)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSoeView diagnostics

#ifdef _DEBUG
void CSoeView::AssertValid() const
{
	CFormView::AssertValid();
}

void CSoeView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CSoeView message handlers

void CSoeView::Serialize(CArchive& ar) 
{
	if (ar.IsStoring())
	{	// storing code
	}
	else
	{	// loading code
	}
}

int CSoeView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CFormView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	SetTimer(1, 50, NULL);
	return 0;
}

void CSoeView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	if(1 == nIDEvent)
	{
		m_nTimerFlag++;
		
		if(m_nTimerFlag > 1)
		{
			m_nTimerFlag --;
		}
		else
		{
			if(GetDocument()->m_bSoeCome && GetDocument()->m_nObjListPos != -1)
			{
				POSITION pos;
				pos = GetDocument()->m_ObjList.FindIndex(GetDocument()->m_nObjListPos);
				CMyObject *MyObj,*MyObj1;
				MyObj = GetDocument()->m_ObjList.GetAt(pos);
				
				pos = GetDocument()->m_ObjList.FindIndex(1);
				if(pos != NULL)
					MyObj1 = GetDocument()->m_ObjList.GetAt(pos);
				FormatSoeStr(MyObj->m_frame, GetDocument()->m_nObjListPos);
			
				GetDocument()->m_bSoeCome = FALSE;
			}
		}
		m_nTimerFlag--;
	}
	CFormView::OnTimer(nIDEvent);
}

void CSoeView::OnDestroy() 
{
	CFormView::OnDestroy();
	
	// TODO: Add your message handler code here
	KillTimer(1);
}

void CSoeView::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	int i,count;
	count = GetDocument()->m_ObjList.GetCount();
	POSITION pos = GetDocument()->m_ObjList.GetHeadPosition();
	CMyObject *MyObj;
	for(i = 0; i < count; i++)
	{
		MyObj = GetDocument()->m_ObjList.GetNext(pos);
		FormatSoeStr(MyObj->m_frame, i);
	}
}

CMbpcDoc* CSoeView::GetDocument()
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMbpcDoc)));
	return (CMbpcDoc*)m_pDocument;
}

void CSoeView::FormatSoeStr(BYTE *frame, int pos)
{
	CString str;
	int i,j;
	BYTE a[2];
	memset(a,0,2);
	WORD ms;
	int cntr = 0;
	POSITION pos1 = GetDocument()->m_ObjList.GetHeadPosition();
	CMyObject *MyObj;
	
	for(i = 0; i < pos; i++)
	{
		MyObj = GetDocument()->m_ObjList.GetNext(pos1);
		cntr += MyObj->m_nChgCntr;
	}
	
	pos = cntr;

	pos1 = GetDocument()->m_ObjList.FindIndex(pos);
	MyObj = GetDocument()->m_ObjList.GetAt(pos1);


	switch(frame[8])
	{
	default:
		{
			str.Empty();
			break;
		}
	case SEND_DI_CHANGE:
		{
			for(i = 0; i < 8; i++)
			{
				for(j = 0; j < 8; j++)
				{
					if(frame[17+i] & (int)pow(2,j))
					{
						a[1] = frame[31]; a[0] = frame[32];
						memcpy(&ms, a, sizeof(WORD));
						if(MyObj->m_bStatus[i*8+j] == 0)
							str.Format("%d年%d月%d日 %d:%d:%d:%d 开入%d %s %s",
							frame[25],frame[26],frame[27],frame[28],frame[29],frame[30],ms,
							i*8+j+1, 
							GetDocument()->m_DiInfo[i*8+j].digital_name,
							GetDocument()->m_DiInfo[i*8+j].off_name);
						else
							str.Format("%d年%d月%d日 %d:%d:%d:%d 开入%d %s %s",
							frame[25],frame[26],frame[27],frame[28],frame[29],frame[30],ms,
							i*8+j+1, 
							GetDocument()->m_DiInfo[i*8+j].digital_name,
							GetDocument()->m_DiInfo[i*8+j].on_name);
						m_List.InsertString(pos,str);
						pos++;
					}
				}
			}
			break;
		}
	case SEND_DO_CHANGE:
		{
			for(i = 0; i < 4; i++)
			{
				for(j = 0; j < 8; j++)
				{
					if(frame[13+i] & (int)pow(2,j))
					{
						a[1] = frame[23]; a[0] = frame[24];
						memcpy(&ms, a, sizeof(WORD));
						if(MyObj->m_bStatus[i*8+j] == 0)
							str.Format("%d年%d月%d日 %d:%d:%d:%d 开出%d %s %s",
							frame[17],frame[18],frame[19],frame[20],frame[21],frame[22],ms,
							i*8+j+1, 
							GetDocument()->m_DoInfo[i*8+j].digital_name,
							GetDocument()->m_DoInfo[i*8+j].off_name);
						else
							str.Format("%d年%d月%d日 %d:%d:%d:%d 开出%d %s %s",
							frame[17],frame[18],frame[19],frame[20],frame[21],frame[22],ms,
							i*8+j+1, 
							GetDocument()->m_DoInfo[i*8+j].digital_name,
							GetDocument()->m_DoInfo[i*8+j].on_name);
						m_List.InsertString(pos,str);
						pos++;
					}
				}
			}
			break;
		}
	case SEND_ENABLE_CHANGE:
		{
			for(i = 0; i < 4; i++)
			{
				for(j = 0; j < 8; j++)
				{
					if(frame[13+i] & (int)pow(2,j))
					{
						a[1] = frame[23]; a[0] = frame[24];
						memcpy(&ms, a, sizeof(WORD));
						if(MyObj->m_bStatus[i*8+j] == 0)
							str.Format("%d年%d月%d日 %d:%d:%d:%d 开出%d %s %s",
							frame[17],frame[18],frame[19],frame[20],frame[21],frame[22],ms,
							i*8+j+1, 
							GetDocument()->m_EnableInfo[i*8+j].digital_name,
							GetDocument()->m_EnableInfo[i*8+j].off_name);
						else
							str.Format("%d年%d月%d日 %d:%d:%d:%d 开出%d %s %s",
							frame[17],frame[18],frame[19],frame[20],frame[21],frame[22],ms,
							i*8+j+1, 
							GetDocument()->m_EnableInfo[i*8+j].digital_name,
							GetDocument()->m_EnableInfo[i*8+j].on_name);
						m_List.InsertString(pos,str);
						pos++;
					}
				}
			}
			break;
		}
	case SEND_ALARM:
		{
			for(i = 0; i < 4; i++)
			{
				for(j = 0; j < 8; j++)
				{
					if(frame[13+i] & (int)pow(2,j))
					{
						a[1] = frame[23]; a[0] = frame[24];
						memcpy(&ms, a, sizeof(WORD));
						if(MyObj->m_bStatus[i*8+j] == 0)
							str.Format("%d年%d月%d日 %d:%d:%d:%d 开出%d %s %s",
							frame[17],frame[18],frame[19],frame[20],frame[21],frame[22],ms,
							i*8+j+1, 
							GetDocument()->m_AlarmInfo[i*8+j].digital_name,
							GetDocument()->m_AlarmInfo[i*8+j].off_name);
						else
							str.Format("%d年%d月%d日 %d:%d:%d:%d 开出%d %s %s",
							frame[17],frame[18],frame[19],frame[20],frame[21],frame[22],ms,
							i*8+j+1, 
							GetDocument()->m_AlarmInfo[i*8+j].digital_name,
							GetDocument()->m_AlarmInfo[i*8+j].on_name);
						m_List.InsertString(pos,str);
						pos++;
					}
				}
			}
			break;
		}
	case SEND_RECORD_CHANGE:
		{
			for(i = 0; i < 4; i++)
			{
				for(j = 0; j < 8; j++)
				{
					if(frame[13+i] & (int)pow(2,j))
					{
						a[1] = frame[23]; a[0] = frame[24];
						memcpy(&ms, a, sizeof(WORD));
						if(MyObj->m_bStatus[i*8+j] == 0)
							str.Format("%d年%d月%d日 %d:%d:%d:%d 开出%d %s %s",
							frame[17],frame[18],frame[19],frame[20],frame[21],frame[22],ms,
							i*8+j+1, 
							GetDocument()->m_RecordInfo[i*8+j].digital_name,
							GetDocument()->m_RecordInfo[i*8+j].off_name);
						else
							str.Format("%d年%d月%d日 %d:%d:%d:%d 开出%d %s %s",
							frame[17],frame[18],frame[19],frame[20],frame[21],frame[22],ms,
							i*8+j+1, 
							GetDocument()->m_RecordInfo[i*8+j].digital_name,
							GetDocument()->m_RecordInfo[i*8+j].on_name);
						m_List.InsertString(pos,str);
						pos++;
					}
				}
			}
			break;
		}
	}
}

void CSoeView::OnSelchangeSoe() 
{
	// TODO: Add your control notification handler code here
	m_List.GetText(m_List.GetCurSel(), m_szSoeDis);
	UpdateData(FALSE);
}

void CSoeView::OnClear() 
{
	// TODO: Add your control notification handler code here
	GetDocument()->m_ObjList.RemoveAll();
	this->m_List.ResetContent();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -