📄 chunnel.cpp
字号:
#include "stdafx.h"
#include "GtMpeg.h"
#include "Chunnel.h"
IMPLEMENT_SERIAL(CChunnel, CObject, 1)
/////////////////////////////////////////
//
/////////////////////////////////////////
CChunnel::CChunnel()
{
m_nSort=-1;
}
CChunnel::~CChunnel()
{
POSITION nPos=m_lstZone.GetHeadPosition();
while(nPos!=NULL)
{
CZone *pZone=m_lstZone.GetNext(nPos);
delete pZone;
}
m_lstZone.RemoveAll();
nPos=m_lstSecondary.GetHeadPosition();
while(nPos!=NULL)
{
CSecondary *pSecondary=m_lstSecondary.GetNext(nPos);
delete pSecondary;
}
m_lstSecondary.RemoveAll();
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CChunnel::InitList(int nChunnel)
{
m_nSort=nChunnel;
if(m_lstZone.GetCount()==0)
{
for(int i=0;i<16;i++)
{
CZone *pZone=new CZone;
m_lstZone.AddTail(pZone);
pZone->SetBindChunnel(nChunnel);
pZone->SetSort(i);
}
}
if(m_lstSecondary.GetCount()==0)
{
for(int i=0;i<8;i++)
{
CSecondary *pSecondary=new CSecondary;
pSecondary->SetBindChunnel(nChunnel);
m_lstSecondary.AddTail(pSecondary);
pSecondary->SetSort(i);
}
}
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CChunnel::Serialize(CArchive& ar)
{
CObject::Serialize(ar);
if (ar.IsStoring())
ar << (DWORD)m_nSort;
else
{
DWORD temp;
ar >> temp; m_nSort=temp;
}
m_lstZone.Serialize(ar);
m_lstSecondary.Serialize(ar);
}
/////////////////////////////////////////
//
/////////////////////////////////////////
CZone* CChunnel::GetZone(int nAddress)
{
POSITION nPos=m_lstZone.FindIndex(nAddress);
if(nPos==NULL) return NULL;
return m_lstZone.GetAt(nPos);
}
/////////////////////////////////////////
//
/////////////////////////////////////////
CSecondary* CChunnel::GetSecondary(int nAddress)
{
POSITION nPos=m_lstSecondary.FindIndex(nAddress);
if(nPos==NULL) return NULL;
return m_lstSecondary.GetAt(nPos);
}
/////////////////////////////////////////
//
/////////////////////////////////////////
CSecondary* CChunnel::GetZoneSecondary(int nAddress)
{
POSITION nPos=m_lstZone.FindIndex(nAddress);
if(nPos==NULL) return NULL;
CZone *pZone=m_lstZone.GetAt(nPos);
if(pZone->GetBindSecondary()==-1)
return NULL;
nPos=m_lstSecondary.FindIndex(pZone->GetBindSecondary());
if(nPos==NULL)
return NULL;
return m_lstSecondary.GetAt(nPos);
}
/////////////////////////////////////////
//
/////////////////////////////////////////
int CChunnel::GetZonesStates()
{
int nStates=0;
for(int i=0;i<16;i++)
{
CZone *pZone=GetZone(i);
int nTmp=1;
if(pZone->m_nType==7)
{
if(pZone->GetStates())
{
nTmp<<=i;
nStates+=nTmp;
}
}
else if(pZone->m_nCtrlWay==0)
{
if(pZone->GetStates())
{
nTmp<<=i;
nStates+=nTmp;
}
}
else if(pZone->m_nCtrlWay==1)
{
if(pZone->m_bStates2)
{
nTmp<<=i;
nStates+=nTmp;
}
}
else if(pZone->m_nCtrlWay==2)
{
if(pZone->m_bStates2||pZone->m_bStates3)
{
nTmp<<=i;
nStates+=nTmp;
}
}
}
return nStates;
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CChunnel::SetZonesStates(int nZone,int nStates)
{
CZone *pZone=GetZone(nZone);
if(pZone!=NULL)
pZone->SetStates(nStates);
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CChunnel::SetSecondarysStates(int nSecondary,int nStates)
{
CSecondary *pSecondary=GetSecondary(nSecondary);
if(pSecondary!=NULL)
pSecondary->SetStates(nStates);
}
/////////////////////////////////////////
//
/////////////////////////////////////////
int CChunnel::GetSecondarysStates()
{
int nStates=0;
for(int i=0;i<8;i++)
{
CSecondary *pSecondary=GetSecondary(i);
int nTmp=1;
if(pSecondary->GetStates())
{
nTmp<<=i;
nStates+=nTmp;
}
}
return nStates;
}
/////////////////////////////////////////
//
/////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -