The Application of Multi-threaded Socket and Picture Field Technology of DataGridView in the Development of Alarm Receiver Software

Similar documents
Construction of Wireless Fire Alarm System Based on ZigBee Technology

Avigilon Control Center 5 System Integration Guide

Design of Humidity Monitoring System Based on Virtual Instrument

Ion Gateway Cellular Gateway and Wireless Sensors

[ [ ADMIN PANEL USER GUIDE

Added password for IP setup page : Password must be in IP format!

Avigilon Control Center System Integration Guide

Avigilon Control Center 5 System Integration Guide

Avigilon Control Center System Integration Guide

Avigilon Control Center 5 System Integration Guide. with STENTOFON AlphaCom. INT-STENTOFON-C-Rev1

Millennium Xtra. Millennium ATMA setup and configuration guide. May Millennium Group, Inc.

C&K Software What s New. Commander II Version 3.0 Monitor II Version 3.0 Satellite II Version 1.0

Procedia - Social and Behavioral Sciences 195 ( 2015 ) World Conference on Technology, Innovation and Entrepreneurship

Avigilon Control Center 5 System Integration Guide

Yokogawa DX Ethernet Driver Help Kepware Technologies

Please use authentic SATA hard drive, USB device and battery.

Monitoring Operator Guide. Access Control Manager Software Version

Preface. Thank you for purchasing our GSM Security Alarm System ( The System )! The System will keep your home and property safe around the clock.

Patriot Systems Limited

Operation Manual Fighter ProVision Software. Version: 0.0 Revision: 1

Oracle Communications Performance Intelligence Center

BlackBerry AtHoc Networked Crisis Communication Siemens Indoor Fire Panel Installation and Configuration Guide Release Version 7.

ION Meter Alerts TECHNICAL NOTE NOVEMBER In This Document

Available online at ScienceDirect. Physics Procedia 67 (2015 )

Laptop / PC Programming Manual

IndigoVision Alarm Panel. User Guide

DEVELOPMENT OF THE TANGO ALARM SYSTEM

WiFi Hints & Tips. Contents. WiFi Hints and Tips 1. Page No. Section No. Title

Ademco Vista Alarm Panel

FCD-wire Contents. List of Figures

PWM. Solar Charge controller with Ethernet. Solar Smart PWM 20Amp. Hardware Description : Release : 19 June 2014

Avigilon Control Center System Integration Guide

Patriot Systems Limited

Avigilon Control Center System Integration Guide

Grandstream Networks, Inc. GDS3710 Input/output Connection Guide

KNX module for smoke alarm devices Dual/VdS and Q-Label (Order no )

LineGuard 2300 Program User Manual (FloBoss 107)

Simplex Panel Interface Guide

Simulation of Full-scale Smoke Control in Atrium

Design of the Fiber-optic Fence Warning System with Distributed Video Real-Time Display Function Qiang-yi YI and Zheng-hong YU *

Chapter 6. Alarm History Screen. Otasuke GP-EX! Chapter 6 Alarm History Screen 6-0. Alarm History Screen 6-1. Display Alarm History in List 6-2

Multi-sensor System For Indoor Environment Monitoring Zheng-yu Wanga, and Xiao-ru Zhangb

IndigoVision. GAI-Tronics Integration Module. Administrator's Guide

Lighting Xpert Insight User Manual

Moxa Proactive Monitoring User s Manual

MR688 Project Sample Test Report

A study of Transient Performance of A Cascade Heat Pump System

[ [ ADMIN PANEL USER GUIDE

Avigilon System Integration Guide. for the Avigilon Control Center and Access Control Manager

SPECTRUM Web Operator

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

JOVY SYSTEMS RE User Manual Rev. 1.00

Research on the Monitor and Control System of Granary Temperature and Humidity Based on ARM

Halton SAFE / 7.14 user guide and installation instructions

Avigilon System Integration Guide. Avigilon Control Center with AMAG Symmetry Security Management System 7.0

The Design of Temperature Control System for Vegetable Greenhouse

Bosch TCU Integration Module Administrator's Guide

WHAT HAPPENS NEXT FOR ADT SMART BUSINESS CUSTOMERS

Application Notes for Configuring NovaLink NovaAlert SIP with Avaya IP Office Issue 1.0

MultiSite Manager. Setup Guide

Avigilon System Integration Guide. for the Avigilon Control Center and Access Control Manager

MicroTech Series 200 Centrifugal Chiller

HikCentral Web Client. User Manual

APP Function Introduction

GSM WIRELESS ALARM SYSTEM Model: GSM-0308W

Available online at ScienceDirect. Procedia Engineering 135 (2016 )

Refrigerated Incubator Model and Operating Instructions

Chapter. Configuring OnSSI NetDVMS. OnSSI NetDVMS versions 5.x through 6.5g. OnSSI NetDVMS Ocularis. Configuring Third-Party Programs

ViewMatrix. Software for Online Monitoring & Control of Matrix2000 Conventional Fire Alarm Panels. Version: 2.0 Revision: 0.1

Centroid Snet 2. Battery Management Software. User Manual V1.1. Eagle Eye Power Solutions, LLC Keeping an Eye on Your Critical Power!

Advanced Features Guide of Visual MIBrowser Pro

USER MANUAL FOR OPERATING SYSTEM

Manage Alarms. Before You Begin CHAPTER

WiFi + PSTN. Smart Home Alarm System

User manual. KNXgal. version

Chapter. Configuring Genetec Omnicast. Version 4.7 SR1. Configuring Third-Party Programs. SightLogix, Inc

Milestone SMI Intrepid II Perimeter Module 1.1 User s Manual

Alarm Client. Installation and User Guide. NEC NEC Corporation. May 2009 NDA-30364, Revision 9

Proliphix. Remote Management. User Guide

Modbus TCP/IP Option Instruction Manual

CRIME. Manufacturing And Minor Inventions CRIME. Control Room Integrated Monitoring Environment

Installation Manual GalaXy G2 / G3 / GD. o Settings GalaXy o Linking with iprotect o Keymap

HikCentral Web Client. User Manual

the Comprehensive Control Solution

Manage Alarms. Before You Begin. NTP-E57 Document Existing Provisioning CHAPTER

Manage Alarms. Before You Begin CHAPTER

Memcom Emergency Telephone

ModSync Sequencing System Installation & Operation Manual. For use with Fulton Steam Boilers.

rvm4c Installation Guide Remote Video Module

Fire Operator Workstation (Fire OWS) User s Guide

HEGA Ethernet Gateway Browser Interface Guide

ScienceDirect. Development progress of critical equipment in the CSNS cryogenic hydrogen system

QUICK CONSUMER REFERENCE GUIDE

QUICK CONSUMER REFERENCE GUIDE

Yoosee fast operating guide V1.6

Fridge-tag 2 OPERATION MANUAL ENGLISH PAGE 1-36 GEBRAUCHSANWEISUNG DEUTSCH SEITE with internal sensor

Q-tag CLm doc family Type: doc / doc L / doc LR / doc D

User manual. Epi-Care mobile. Danish Care Technology ApS Energivej 3, DK-4180 Sorø version 1.15 Phone: Page 1 of 17

AK-CS On Board Guide

CompleteView SightLogix Sensor Setup Manual. CompleteView Version 4.7.1

Transcription:

Available online at www.sciencedirect.com Physics Procedia 25 (2012 ) 1397 1404 2012 International Conference on Solid State Devices and Materials Science The Application of Multi-threaded Socket and Picture Field Technology of DataGridView in the Development of Alarm Receiver Software Guo hao The Computer Science and Technology College,Taiyuan University of Technology,Shanxi, China 030024 Abstract In this paper, we achieve the alarm receiving software and discuss programming ideas of the multi-threaded asynchronous receiver about SOCKET and picture field technology of DataGridView in the process of development. 2012 2011 Published by Elsevier Ltd. B.V. Selection and/or peer-review under responsibility of of [name Garry organizer] Lee Open access under CC BY-NC-ND license. Keywords-VS 2005, C#, SOCKET, multi-thread, asynchronous reception, DataGridView, picture field 1. Introduction Alarm receiving software is a kind of common functional block and used in many systems. Its main function typically includes receiving the alarm information, displaying alarm information, sounding the alarm tone, prohibiting alarm tone, processing alarm status, poping up window, generating log, reminding email/sms, inquiring police record and so on. In this paper, we focuse on the implement of receiving and displaying alarm information, playing and stopping sound, and several other features. 2. Main Functions 2.1 Receiving the alarm information The alarm information usually has a number of alarm generated sources, these sources randomly generate alarm information, send to the receiver. Sending process is as follows: alarm generated source sends SOCKET connection requests with IP and specified port to the receiver; After a successful connection, it sends a data packet; After the success of packet transmission, the connection is disconnect. 1875-3892 2012 Published by Elsevier B.V. Selection and/or peer-review under responsibility of Garry Lee Open access under CC BY-NC-ND license. doi:10.1016/j.phpro.2012.03.252

1398 Guo hao / Physics Procedia 25 ( 2012 ) 1397 1404 Because generation sources may send alarm information at the same time, the receiver must take multithreaded asynchronous receiver to treat information. Multi-threaded asynchronous receiver refers to that the receiver listens port in the loop, when it receives a connection request, it starts a new thread to receive the data, analyze data packet, display alarm information, write the log records, etc., the main thread continues to monitor port. In the realization of more complex data receiver, data receiving and processing need to be separated into two threads, that is to say, it will start another asynchronous process. In this paper, the length of data package is short, the structure is relatively simple, so we eliminate confirming IP, establishing SESSION, verifying the checksum of data packets, parsing the data packet, merging related data packet and other steps, don't to start new thread. 2.2 Displaying the alarm information Successfully received alarm information will be displayed in the DataGridView, including processing status, alarm sound status, receiving time, alarm content and so on. Processing status and alarm sound status are image field, the initial state are (pending alarm), (alarm sound). 2.3 Playing and stopping the alarm tone The field of alarm sound state is a picture field, default is to send alarm tone, this is to stop the alarm tone, The field of alarm sound status is changed to stop the alarm tone, the field's Tag property is set to False. When all the records of alarm sound status in DataGridView are banned status, it will stop the alarm sound, or play alarm sound. The control of sound uses System.Media class in the SoundPlayer. This class is a new class in the. NET Framework 2.0 version. It is easy to include sound in the application software by using the SoundPlayer class. SoundPlayer class provides simple interface to load and play.wav files. SoundPlayer class supports Stream to contain.wav file from the file path, URL, or load.wav file from embedded resource which includes.wav files. 2.4 Status of alarm processing The field of alarm processing status is image field, default is raw alarm information which is need to be displayed. Clicking on the icon means that the operator has dealt with this alarm, the system will log the processing time and remove this record from the DataGridView. 3. Implementation 3.1 Boot screen The boot screen includes two Textbox of user name and password, the login button, DataGridView (control name dg, four fields: processing, sound, time, alarm content)which display the alarm information. Figure 1 is a form of startup screen.

Guo hao / Physics Procedia 25 (2012 ) 1397 1404 1399 Figure 1. A form of startup screen 3.2 The main thread You enter the user name, password and click login, if the information is right, the button at the top changes. It initiates the Socket instance of receive, and starts two threads, one thread of ththreadsound detects whether to play the alarm sound, another thread of ththreadlisten monitors a specified port. receive = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //start a Socket instance IPe = new IPEndPoint(IPAddr, port); //initate IPEndPoint instance receive.bind(ipe);//connect Socket with IPEndPoint receive.listen(15);//listen ththreadsound = new Thread(new ThreadStart(SoundPlay)); ththreadsound.start(); //start the thread of playing alarm sound ththreadlisten = new Thread(new ThreadStart(Listen)); ththreadlisten.start();//start listening thread 3.3 The thread of playing alarm sound SoundPlay () which is the thread of playing alarm sound looply detects every Tag property of sound field in DataGridView to determine to play or stop alarm sound. It calculates number that which Tag property is True in per cycle, if the number is greater than 0, sound file is played, if the number is equal to 0, sound file is stopped. Each test was suspended 5 seconds. public static SoundPlayer sound = new SoundPlayer();//initiate playing sound instance private void SoundPlay() Thread.CurrentThread.IsBackground = true;

1400 Guo hao / Physics Procedia 25 ( 2012 ) 1397 1404 // Specify the current thread as background thread DataGridViewRowCollection ls; int acount = 0; sound.soundlocation = "Alarm.wav"; //specify sound file while (runtype) ls = dg.rows; acount = 0; foreach (DataGridViewRow dgr in ls) //check each row in DataGridView if (dgr.cells[1].tag == null) //if this is a new row dgr.cells[1].tag = true;//assign True to Tag if ((bool)dgr.cells[1].tag) acount++; //calculate records number which should play sound if (acount > 0) sound.play();//play sound else sound.stop();//stop sound Thread.Sleep(5 * 1000);//sleep 5s 3.4 Monitor thread Monitor thread looply detects the new connection of Socket instance, it will start ReceiveTh which is the processing thread after receiving the connection request. private void Listen() Thread.CurrentThread.IsBackground = true; // Specify the current thread as background thread // while (true) Socket accept = receive.accept(); //start Socket for the new connection Thread receiveth = new Thread(new ParameterizedThreadStart(ReceiveTh)); receiveth.start(accept); //start receiving and processing thread 3.5 Receiving and processing thread Receiving and processing thread detects data receive buffer of Socket connection, receive the data transfers received data to adddg which is displaying and processing program in DataGridView and then closes the connection. Here we should note the received data 's encoding, we can force the specified

Guo hao / Physics Procedia 25 (2012 ) 1397 1404 1401 string to be encoded as GB2312 by GetEncoding ("GB2312"), if you do not specify the source code information, some warning alarms message may be displayed as garbled. private void ReceiveTh(object asocket) Thread.CurrentThread.IsBackground = true; // Specify the current thread as background thread Socket receive = (Socket)asocket; byte[] buffer = new byte[1024]; // Establish a data receive buffer string rstr; int scount = 0; while (true) try scount = receive.receive(buffer); // Get length of receive data catch if (scount > 0) rstr = Encoding.GetEncoding("GB2312").GetString(buffer, 0, scount);// Access to //alarm information data adddg(rstr);//process data else receive.close();//close Socket connection break; 3.6 Display processing of DataGridView Display processing program of DataGridView runs in ReceiveTh which is a receiving and processing thread, while DataGridView runs in the main thread. The program after NET2.0 enhances security mechanisms, does not allow WINFORM to access control properties across threads. So when you need to update DataGridView, you should use delegate. Figure 2 is the screen that DataGridView is updated after receiving alarm information,the system starts to play the alarm sound at the moment. delegate void SetDgvCallback(string text); private void adddg(string disp) if (this.dg.invokerequired) // Check whether the control is idle //The control is busy SetDgvCallback d = new SetDgvCallback(adddg); //Wait for rerunning this.invoke(d, new object[] disp ); //Pass parameters

1402 Guo hao / Physics Procedia 25 ( 2012 ) 1397 1404 else //The control is idle try dg.rows.insert(0, new object[] dispalarm.properties.resources.alarm, dispalarm.properties.resources.sound, DateTime.Now, disp );//Add a new record in DataGridView dg.refresh(); //Refresh the display of DataGridView control catch (Exception e) MessageBox.Show(e.ToString()); //Display error message Figure 2. display screen 3.7 Stopping the alarm tone The CellContentClick events in DataGridView can trigger to stop the alarm tone. The operator clicks the sound field in a row and sets the picture in the sound field as, and tag to false. Figure 3 is the display screen after the operator clicks, then the sound is stopped. if (e.columnindex == 1) // Determine whether the alarm status field is clicked dg.rows[e.rowindex].cells[e.columnindex].value = dispalarm.properties.resources.nosound; // update the display image in the field dg.rows[e.rowindex].cells[e.columnindex].tag = false;//update Tag property

Guo hao / Physics Procedia 25 (2012 ) 1397 1404 1403 Figure 3. display screen after the sound field is clicked 3.8 Changing the alarm process status When the operator clicks the status bar of a row, the system writes the processing time of the alarm record to the log and deletes this record from the DataGridView. Figure 4 is the display screen after the operator clicks. if (e.columnindex == 0) // Determine whether the treatment status field was clicked writelog(dg.rows[e.rowindex].cells[3]); // write the processing time of the alarm to log dg.rows.remove(dg.rows[e.rowindex]); // Delete the record in the DataGridView Figure 4. display screen after the status bar is clicked 4. Conclusion

1404 Guo hao / Physics Procedia 25 ( 2012 ) 1397 1404 The alarm receiving software has been tested and no packet loss, functions could meet demands. I believe that through this practice, multi-threaded asynchronous receiver technology of SOCKET can deal with complex receive requirements. Of course, there are some details that need to pay attention to the reader in practical applications, such as: data in DataGridView written to the database, the mode of written logs, due to space limitations, we can not discuss here. References [1] Zhou Cunjie, C# network programming tutorial examples, Beijing Hope Electronic Press, 2002.7 [2] Su Guiyang, ASP.NET network programming from basic to practice, Electronic Industry Press, 2005.10 [3] Ye Shuhua, Gao Zhihong, practical tutorials of network programming, Posts & Telecom Press, 2006.10