ZEO 모듈을 사용하시는 분은 http://whiteat.com/57501 를 참조하여 드라이버를 설치하시고, 프로그래밍 가이드를 따라해 보시기 바랍니다.

 

 

 

C#으로 HumanDetectApp 라는 응용프로그램을 만들어 보겠습니다.

여기서는 Visual Studio 2008 의 C#을 사용하게 됩니다.

 

먼저 Windows Forms Application Template 으로 HumanDetectApp 라는 프로젝트를 생성합니다.

C#을 처음 접하시는 분은 http://whiteat.com/31559 를 한번만 해보셔도 금방 따라 하실 수 있습니다.

 

 

 

 

기본 폼이 완성 되면 LABEL 2개를 추가합니다.

각각의 이름을 lblModel, lblAlarm로 하겠습니다.

lblModel에는 현재 사용중인 ZEO 의 모델명과 버전을 표시할 것이고,

lblAlarm 에는 "침입자 발견" 메시지를 보여줄 것입니다.

 

 

그리고 일정시간마다 센서 값을 읽어 올 수 있게 Timer 를 추가하고 타이머의 이름을 tmrMain 이라고 하겠습니다.

 

 

 

이제 각 기능을 구현하면 됩니다.

 

 

 

센서가 감지되었을 경우 경고 표시

 

 

 

 

평상시 화면

 

 

 

 

 

 

아래는 인체감지 센서를 읽어 알람을 화면에 표시하는 전체 코드입니다.

 

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using ZeoDotNetLib;

 

 

namespace HumanDetectApp

{

public partial class Form1 : Form

{

ZeoLib ZEO = new ZeoLib();

 

public Form1()

{

InitializeComponent();

}

 

private void Form1_Load(object sender, EventArgs e)

{

// ZEO 모듈 열기

this.ZEO.Open();

 

// ZEO 모듈 초기화

this.ZEO.InitZeo(0);

 

// 모델명 버전 표시

this.lblModel.Text = "MODEL: ZEO-" + this.ZEO.GetZeroType().ToString();

this.lblModel.Text += " VERSION: " + this.ZEO.GetBoardVersion();

 

// PA16을 입력으로 설정 (센서 값 읽기)

this.ZEO.PORT_DirInput(PIN_NAME.PA16);

 

}

 

private void tmrMain_Tick(object sender, EventArgs e)

{

// 만약 ZEO와 연결되지 않았다면 아무것도 안하겠다.

if (!this.ZEO.IsOpened) return;

 

// 모든 포트의 값을 읽어

UInt32[] uiData = this.ZEO.ReadPortAll();

 

// PA16의 값이 HIGH 이면

if ((uiData[0] & 0x10000) == 0x10000)

{

// 알람 표시

lblAlarm.Visible = true;

}

else

{

lblAlarm.Visible = false;

}

}

 

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

{

// 프로그램 종료시에는 반드시 Close 를 해줘야 한다.

this.ZEO.Close();

}

}

}

 

 

 

 

Posted by WhiteAT
,