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

📄 postxtdlg.cpp

📁 一个完整的数字硬盘录像机系统软件
💻 CPP
字号:
// PosTxtDlg.cpp : implementation file
//

#include "stdafx.h"
#include "gtmpeg.h"
#include "PosTxtDlg.h"
#include "MapDlg.h"
#include "PosZoneDlg.h"
#include "GtMpegWnd.h"
#include "Chunnel.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
CPosTxtDlg::CPosTxtDlg(int nIndex,CMapDlg* pParent /*=NULL*/)
	: CDialog(CPosTxtDlg::IDD, (CWnd *)pParent)
{
	//{{AFX_DATA_INIT(CPosTxtDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_nIndex=nIndex;
    m_pParent=pParent;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosTxtDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPosTxtDlg)
	DDX_Control(pDX, IDC_POS_TXT, m_cPosTxtLst);
	//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CPosTxtDlg, CDialog)
	//{{AFX_MSG_MAP(CPosTxtDlg)
	ON_BN_CLICKED(IDC_SET_ZONES, OnSetZones)
	ON_BN_CLICKED(IDC_ZONE_INIT, OnZoneInit)
	ON_BN_CLICKED(IDC_STOP_ALARM,OnStopAlarm)
	ON_BN_CLICKED(IDC_ZONE_OPEN,OnZoneOpen)
    ON_BN_CLICKED(IDC_ZONE_CLOSE,OnZoneClose)
	ON_BN_CLICKED(IDC_RESET, OnReset)
	ON_BN_CLICKED(IDC_FORCE_CLOSE, OnForceClose)
	ON_BN_CLICKED(IDC_FORCE_OPEN, OnForceOpen)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BOOL CPosTxtDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CString sTxt=m_pParent->GetPosCaption(m_nIndex);
	GetDlgItem(IDC_CAPTION)->SetWindowText(sTxt);
	BuildPosTxt();
	return TRUE;
}
//////////////////////////////////
//
//////////////////////////////////
CString CPosTxtDlg::Space(int space)
{
  CString ret=_T("");
  for(int i=0;i<space;i++)
	  ret+=32;
  return ret;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosTxtDlg::BuildPosTxt()
{
	m_cPosTxtLst.ResetContent();
	int nChunnel=m_pParent->GetChunnel(m_nIndex);
	CUIntArray Zones;
	m_pParent->GetPosZones(m_nIndex,Zones);
	CGtMpegWnd *pWnd=(CGtMpegWnd *)theApp.m_pMainWnd;
	CChunnel *pChunnel=pWnd->GetChunnel(nChunnel);
    for(int i=0;i<Zones.GetSize();i++)
	{
	    int nAddress=Zones.GetAt(i)-1;
		CZone *pZone=pChunnel->GetZone(nAddress);
		if(pZone==NULL)
			break;
		CString sTxt="";
		sTxt=g_sZoneType[pZone->m_nType];
		sTxt+=Space(15-sTxt.GetLength());
		sTxt+="\t";
		CString sTxt1="";
		if(pZone->m_nBelong!=-1)
		{
		    CZone *pOpenZone=pChunnel->GetZone(pZone->m_nBelong);
			if(pOpenZone->m_bStates2)
			{
			   sTxt1+="前端布防";
			   if((pOpenZone->m_bStates2!=pZone->m_bStates2)&&pOpenZone->m_nCtrlWay>0)
				   sTxt1+="(紧急处理),";
			   else
                   sTxt1+=","+Space(10);
			}
			else
			{
               sTxt1+="前端撤防,";
			}
			if(pZone->m_nCtrlWay==2)
			{
		        if(pZone->m_bStates3)
				{
			       sTxt1+="中心布防,";
				}
				else
				{
				   sTxt1+="中心撤防,";
				}
			}
		}
		else
		{
		   if(pZone->GetStates())
		   {
		      sTxt1+="布防,";
		   }
		   else
		   {
		      sTxt1+="布防,";
		   }
		}
		sTxt1+=Space(28-sTxt1.GetLength());
		sTxt1+="\t";
		sTxt+=sTxt1;
		if(pZone->GetBindSecondary()!=-1)
		{
			CSecondary *pSecondary=pChunnel->GetSecondary(pZone->GetBindSecondary());
			if(pSecondary->GetStates())
				sTxt+="报警";
			else
				sTxt+="正常";
		}
		else
		{
				sTxt+="无";
		}
		m_cPosTxtLst.AddString(sTxt);
	}
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosTxtDlg::OnOK() 
{
	CEdit *pEdit=(CEdit *)GetDlgItem(IDC_CAPTION);
	CString sTxt;
	pEdit->GetWindowText(sTxt);
    m_pParent->WriteMap(m_nIndex,"Caption",sTxt);
	CDialog::OnOK();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CPosTxtDlg::OnSetZones() 
{
   CPosZoneDlg dlg(m_nIndex,m_pParent);
   if(dlg.DoModal()==IDOK)
	   BuildPosTxt();
}
////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////
void CPosTxtDlg::OnZoneInit()
{
   CGtMpegWnd *pWnd=(CGtMpegWnd *)theApp.m_pMainWnd;
   pWnd->SaveAlarmSet();
   int nChunnel=m_pParent->GetChunnel(m_nIndex);
   CChunnel *pChunnel=pWnd->GetChunnel(nChunnel);
   CUIntArray Zones;
   m_pParent->GetPosZones(m_nIndex,Zones);
   for(int i=0;i<Zones.GetSize();i++)
   {
	    int nAddress=Zones.GetAt(i)-1;
		CZone *pOpenZone=pChunnel->GetZone(nAddress);
	    if(pOpenZone->m_nType==7)
		{
		  NMHDR Msg;
		  Msg.hwndFrom=m_hWnd;
		  UINT uInfoID;
		  Msg.idFrom=IDC_ZONE_STATES_1+nAddress;
		  uInfoID=_ALARM_ZONE_INFO;
		  Msg.code=nChunnel;
		  Msg.code<<=16;
		  Msg.code+=1;
		  pWnd->SendMessage(WM_NOTIFY,uInfoID,(LPARAM)&Msg);
	   }
   }
}
//////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////
void CPosTxtDlg::OnStopAlarm()
{
   CGtMpegWnd *pWnd=(CGtMpegWnd *)theApp.m_pMainWnd;
   int nChunnel=m_pParent->GetChunnel(m_nIndex);
   CChunnel *pChunnel=pWnd->GetChunnel(nChunnel);
   CUIntArray Zones;
   m_pParent->GetPosZones(m_nIndex,Zones);
   NMHDR Msg;
   Msg.hwndFrom=m_hWnd;
   UINT uInfoID;
   Msg.idFrom=GetDlgCtrlID();
   uInfoID=_ALARM_SECONDARY_INFO;
   for(int i=0;i<Zones.GetSize();i++)
   {
        Msg.code=nChunnel;
        Msg.code<<=16;
	    int nAddress=Zones.GetAt(i)-1;
		CZone *pZone=pChunnel->GetZone(nAddress);
		CSecondary *pSecondary=NULL;
		if(pZone->GetBindSecondary()!=-1)
		{
			pSecondary=pChunnel->GetSecondary(pZone->GetBindSecondary());
			if(pSecondary->GetStates())
			{
			   pSecondary->SetStates(!pSecondary->GetStates());
			   Msg.code+=pSecondary->GetStates();
			   theApp.m_pMainWnd->SendMessage(WM_NOTIFY,uInfoID,(LPARAM)&Msg);
			   //Sleep(40);
			}
		}
        Msg.code=nChunnel;
        Msg.code<<=16;
		if(pZone->m_nBindSecondary2!=-1)
		{
			pSecondary=pChunnel->GetSecondary(pZone->m_nBindSecondary2);
			if(pSecondary->GetStates())
			{
			   pSecondary->SetStates(!pSecondary->GetStates());
			   Msg.code+=pSecondary->GetStates();
			   theApp.m_pMainWnd->SendMessage(WM_NOTIFY,uInfoID,(LPARAM)&Msg);
			   //Sleep(40);
			}
		}
   }
   pWnd->SaveAlarmSet();
}
//////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////
void CPosTxtDlg::OnZoneOpen()
{
	int nChunnel=m_pParent->GetChunnel(m_nIndex);
	CUIntArray Zones;
	m_pParent->GetPosZones(m_nIndex,Zones);
	CGtMpegWnd *pWnd=(CGtMpegWnd *)theApp.m_pMainWnd;
	CChunnel *pChunnel=pWnd->GetChunnel(nChunnel);
	//
	BYTE byCommand[5];
	int  nTmp=pWnd->GetZonesStates(nChunnel);
	byCommand[0]=(BYTE)0xcc;
    byCommand[1]=(BYTE)nChunnel;
    byCommand[2]=LOBYTE(nTmp);
    byCommand[3]=HIBYTE(nTmp);
	byCommand[4]=(BYTE)0x10;
    for(int i=0;i<Zones.GetSize();i++)
	{
	    int nAddress=Zones.GetAt(i)-1;
		CZone *pZone=pChunnel->GetZone(nAddress);
	    BYTE byTmp=1;
		if(pZone==NULL)
			break;
		if(pZone->m_nBelong!=-1)//防区类属某个防区
		{
		    if(pZone->m_nCtrlWay==2)
			{
			   if(!pZone->m_bStates3)
			   {
			      //布防操作
		          if(nAddress>=0&&nAddress<=7)
				  {
		             byTmp<<=nAddress;
                     byCommand[2]|=byTmp;
				  }
		          else
				  {
		             byTmp<<=(nAddress-8);
                     byCommand[3]|=byTmp;
				  }
				  pZone->m_bStates3=TRUE;
			   }
			}
		}
		else if(pZone->m_nType!=7)
		{
		   if(!pZone->GetStates())
		   {
			 //布防操作
		     if(nAddress>=0&&nAddress<=7)
			 {
		        byTmp<<=nAddress;
                byCommand[2]|=byTmp;
			  }
		      else
			  {
		         byTmp<<=(nAddress-8);
                 byCommand[3]|=byTmp;
			  }
			  pZone->SetStates(TRUE);
		   }
		}
	}
    pWnd->WriteCommCommand(byCommand,5);
	pWnd->SaveAlarmSet();
	BuildPosTxt();
}
//////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////
void CPosTxtDlg::OnZoneClose()
{
	int nChunnel=m_pParent->GetChunnel(m_nIndex);
	CUIntArray Zones;
	m_pParent->GetPosZones(m_nIndex,Zones);
	CGtMpegWnd *pWnd=(CGtMpegWnd *)theApp.m_pMainWnd;
	CChunnel *pChunnel=pWnd->GetChunnel(nChunnel);
    //
    BYTE byCommand[5];
	int  nTmp=pWnd->GetZonesStates(nChunnel);
	byCommand[0]=(BYTE)0xcc;
    byCommand[1]=(BYTE)nChunnel;
    byCommand[2]=LOBYTE(nTmp);
    byCommand[3]=HIBYTE(nTmp);
	byCommand[4]=(BYTE)0x10;
    for(int i=0;i<Zones.GetSize();i++)
	{
	    int nAddress=Zones.GetAt(i)-1;
		CZone *pZone=pChunnel->GetZone(nAddress);
	    BYTE byTmp=1;
		if(pZone==NULL)
			break;
		if(pZone->m_nBelong!=-1)//防区类属某个防区
		{
		    if(pZone->m_nCtrlWay==2)
			{
			   if(pZone->m_bStates3&&!pZone->m_bStates2)
			   {
		          if(nAddress>=0&&nAddress<=7)
				  {
		             byTmp<<=nAddress;
		             byTmp=~byTmp;
                     byCommand[2]&=byTmp;
				  }
		          else
				  {
		              byTmp<<=(nAddress-8);
		              byTmp=~byTmp;
                      byCommand[3]&=byTmp;
				  }
				  pZone->m_bStates3=FALSE;
			   }
			}
		}
		else if(pZone->m_nType!=7)
		{
		   if(pZone->GetStates())
		   {
			 //撤防操作
		     if(nAddress>=0&&nAddress<=7)
			 {
		          byTmp<<=nAddress;
		          byTmp=~byTmp;
                  byCommand[2]&=byTmp;
			 }
		     else
			 {
		          byTmp<<=(nAddress-8);
		          byTmp=~byTmp;
                  byCommand[3]&=byTmp;
			 }
			 pZone->SetStates(FALSE);
		   }
		}
	}
    pWnd->WriteCommCommand(byCommand,5);
	pWnd->SaveAlarmSet();
	BuildPosTxt();
}
//////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////
void CPosTxtDlg::OnReset() 
{
	BuildPosTxt();	
}
//////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////
void CPosTxtDlg::OnForceClose() 
{
	int nChunnel=m_pParent->GetChunnel(m_nIndex);
	CUIntArray Zones;
	m_pParent->GetPosZones(m_nIndex,Zones);
	CGtMpegWnd *pWnd=(CGtMpegWnd *)theApp.m_pMainWnd;
	CChunnel *pChunnel=pWnd->GetChunnel(nChunnel);
    //
    BYTE byCommand[5];
	int  nTmp=pWnd->GetZonesStates(nChunnel);
	byCommand[0]=(BYTE)0xcc;
    byCommand[1]=(BYTE)nChunnel;
    byCommand[2]=LOBYTE(nTmp);
    byCommand[3]=HIBYTE(nTmp);
	byCommand[4]=(BYTE)0x10;
    for(int i=0;i<Zones.GetSize();i++)
	{
	    int nAddress=Zones.GetAt(i)-1;
		CZone *pZone=pChunnel->GetZone(nAddress);
	    BYTE byTmp=1;
		if(pZone==NULL)
			break;
		if(pZone->m_nBelong!=-1)//防区类属某个防区
		{
		    if(pZone->m_nCtrlWay==2||pZone->m_nCtrlWay==1)
			{
		        if(nAddress>=0&&nAddress<=7)
				{
		           byTmp<<=nAddress;
		           byTmp=~byTmp;
                   byCommand[2]&=byTmp;
				}
		        else
				{
		           byTmp<<=(nAddress-8);
		           byTmp=~byTmp;
                   byCommand[3]&=byTmp;
				}
				pZone->m_bStates2=FALSE;
				pZone->m_bStates3=FALSE;
			}
		}
	}
    pWnd->WriteCommCommand(byCommand,5);
	pWnd->SaveAlarmSet();
	BuildPosTxt();
}
//////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////
void CPosTxtDlg::OnForceOpen() 
{
	int nChunnel=m_pParent->GetChunnel(m_nIndex);
	CUIntArray Zones;
	m_pParent->GetPosZones(m_nIndex,Zones);
	CGtMpegWnd *pWnd=(CGtMpegWnd *)theApp.m_pMainWnd;
	CChunnel *pChunnel=pWnd->GetChunnel(nChunnel);
	//
	BYTE byCommand[5];
	int  nTmp=pWnd->GetZonesStates(nChunnel);
	byCommand[0]=(BYTE)0xcc;
    byCommand[1]=(BYTE)nChunnel;
    byCommand[2]=LOBYTE(nTmp);
    byCommand[3]=HIBYTE(nTmp);
	byCommand[4]=(BYTE)0x10;
    for(int i=0;i<Zones.GetSize();i++)
	{
	    int nAddress=Zones.GetAt(i)-1;
		CZone *pZone=pChunnel->GetZone(nAddress);
	    BYTE byTmp=1;
		if(pZone==NULL)
			break;
		if(pZone->m_nBelong!=-1)//防区类属某个防区
		{
		    CZone *pOpenZone=pWnd->GetChunnel(nChunnel)->GetZone(pZone->m_nBelong);
			if(pZone->m_nCtrlWay==2||pZone->m_nCtrlWay==1)
			{
			  if(pOpenZone->m_bStates2!=pZone->m_bStates2)
			  {
				  //布防操作
				  if(nAddress>=0&&nAddress<=7)
				  {
					 byTmp<<=nAddress;
					 byCommand[2]|=byTmp;
				  }
				  else
				  {
					 byTmp<<=(nAddress-8);
					 byCommand[3]|=byTmp;
				  }
				  pZone->m_bStates2=TRUE;
			  }
			}
		}
	}
    pWnd->WriteCommCommand(byCommand,5);
	pWnd->SaveAlarmSet();
	BuildPosTxt();}
//////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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