Nghiên cứu và xây dựng hệ thống giám sát môi trường tại các trung tâm tích hợp dữ liệu

102 303 0
Nghiên cứu và xây dựng hệ thống giám sát môi trường tại các trung tâm tích hợp dữ liệu

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

ĐẠI HỌC THÁI NGUYÊN TRƯỜNG ĐẠI HỌC CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG ––––––––––––––––––––––––– PHẠM NGỌC PHƯƠNG NGHIÊN CỨU VÀ XÂY DỰNG HỆ THỐNG GIÁM SÁT MÔI TRƯỜNG TẠI CÁC TRUNG TÂM TÍCH HỢP DỮ LIỆU Chuyên ngành: Khoa học máy tính Mã số: 60 48 01 LUẬN VĂN THẠC SĨ KHOA HỌC MÁY TÍNH Người hướng dẫn khoa học: PGS TS Nguyễn Văn Tam THÁI NGUYÊN - 2013 LỜI CAM ĐOAN Tôi xin cam đoan luận văn thực hoàn thành sở tìm kiếm, thu thập, nghiên cứu, tổng hợp phần lý thuyết phương pháp kĩ thuật trình bày văn nước giới Mọi tài liệu tham khảo nêu phần cuối luận văn Luận văn hoàn toàn không chép nguyên từ nguồn tài liệu khác Nếu có sai sót, xin chịu trách nhiệm./ HỌC VIÊN Phạm Ngọc Phương i MỤC LỤC PHỤ LỤC 61 ii BẢNG CÁC THUẬT NGỮ TIẾNG VIỆT VÀ TỪ VIẾT TẮT STT Định nghĩa/Từ viết tắt CNTT CSDL ĐHTN HTĐ TTTHDL Giải thích Công nghệ thông tin Cơ sở liệu Đại học Thái Nguyên Hệ thống thông tin đo lường Trung tâm tích hợp liệu BẢNG CÁC THUẬT NGỮ TIẾNG ANH VÀ TỪ VIẾT TẮT Thuật ngữ viết tắt ADC ALU ASCII ATS CPU CMOS DC DAC EEPROM HVAC HTTP ISP Internet LAN LCD LAN PWM ROM RAM SRAM TTL UART Tiếng Anh Analog to Digital Converter Arithmetic and Logic Unit American Standard Code for Information Interchange Automatic Transfer Switches Central processing unit Complementary Metal-OxideSemiconductor Data Center Digital to Analog Converter Electrically Erasable Programmable Read-Only Memory Heating, Ventilation and Air Conditioning HyperText Transfer Protocol Internet Service Provider Internet Local Area Network Liquid Crystal Display Local Area Network Pulse Width Modulation Read-Only Memory Random Access Memory Static Random Access Memory Transistor - Transistor Logic Universal Asinchonus Receiver Transmitter Tiếng Việt Bộ chuyển đổi tương tự sang số Đơn vị số học logic Chuẩn mã trao đổi thông tin Hoa Kì Hệ thống tự động chuyển đổi nguồn điện Khối điều khiển trung tâm Chuẩn logic CMOS dựa vi mạch tích hợp Trung tâm tích hợp liệu Bộ chuyển đổi số sang tương tự Chíp nhớ khả trình không bị xóa điện Nhiệt, thông gió điều hòa không khí Giao thức chuyển tải siêu văn Nhà cung cấp địch vụ Internet Hệ thống thông tin toàn cầu Mạng cục Màn tinh thể lỏng Mạng cục Bộ điều chế độ rộng xung Bộ nhớ đọc Bộ nhớ truy xuất ngẫu nhiên RAM tĩnh Bộ logic xây dựng từ transistor Thiết bị thu / phát không đồng iii Thuật ngữ viết tắt UPS µC (MCU) µP Tiếng Anh Tiếng Việt Uninterruptible Power Supplier Microcontroller Unit MicroProcessor Hệ thống nguồn cung cấp liên tục Bộ vi điều khiển Bộ vi xử lý iv DANH MỤC CÁC BẢNG BIỂU Bảng biểu Nội dung Bảng 3.1 Tham số cài đặt giám sát thử nghiệm Bảng A.1 Yêu cầu phân cấp điện Bảng A.2 Các yêu cầu Hệ thống học Trang 51 60 66 v DANH MỤC CÁC HÌNH VẼ Hình vẽ Hình A Hình 1.1 Hình 1.2 Hình 1.3 Hình 1.4 Hình 1.5 Hình 1.6 Hình 1.7 Hình 1.8 Hình 1.9 Hình 1.10 Hình 1.11 Hình 1.12 Hình 1.13 Hình 2.1 Hình 2.2 Hình 2.3 Hình 2.4 Hình 2.5 Hình 2.6 Hình 2.7 Hình 2.8 Hình 2.9 Hình 2.10 Hình 2.11 Hình 2.12 Hình 2.13 Hình 2.14 Hình 2.15 Hình 2.16 Nội dung Một môi trường trung tâm tích hợp liệu với nhiều tham số phải giám sát Bản vẽ kiến trúc mạng xương sống TTTHDL tỉnh Quảng Ninh Bản vẽ mặt bố trí thiết bị tài TTTHDL tỉnh Quảng Ninh Bản vẽ kiến trúc mạng xương sống TTTHDL Đại học Thái Nguyên Bản vẽ mặt bố trí thiết bị tài TTTHDL Đại học Thái Nguyên Sơ đồ cấu trúc hệ thống thông tin đo lường Hệ thống đo sử dụng vi xử lý trao đổi vi xử lý giao diện Xây dựng sơ đồ hệ thống giám sát môi trường Thiết kế dạng cho hệ thống giám sát nhiệt độ Thiết kế dạng cho hệ thống giám sát nhiệt độ Thiết kế sơ đồ khối cho hệ thống giám sát độ ẩm Thiết kế hệ thống giám sát báo cháy cho TTTHDL tủ báo cháy Thiết kế hệ thống giám sát báo cháy cho TTTHDL có tủ báo cháy Nguyên lý giám sát điện lưới Sơ đồ khối hệ thống giám sát Mạch nguyên lý khối vi điều khiển trung tâm Cấu trúc vi điều khiển AVR ATmega16 Sơ đồ cấu trúc CPU AVR ATmega16 Sơ đồ nhớ tổng quát AVR ATmega16 Sơ đồ khối cấu tạo cảm biến nhiệt DS18B20 Sơ đồ kết nối dây dọc liệu nhiệt độ từ cảm biến DS18B20 Sơ đồ kết nối LM35 đọc liệu cảm biến nhiệt độ qua ADC Sơ đồ kết nối dây dọc liệu nhiệt độ từ cảm biến DHT11 Mạch nguyên lý khối giám sát báo cháy Mạch nguyên lý khối giám sát nguồn điện Tín hiệu tương đương UART RS232 Truyền bit theo phương pháp song song nối tiếp Bản vẽ kết nối máy chủ vi điều khiển qua giao tiếp RS232 Thiết kế khối cảnh báo sử dụng modem GSM Sơ đồ khối bên GSM modem Trang 11 13 16 17 18 21 21 22 25 26 27 28 29 30 31 32 33 34 35 36 37 39 39 40 vi Hình 2.17 Hình 2.18 Hình 2.19 Hình 2.20 Hình 2.21 Hình 2.22 Hình 2.23 Hình 2.24 Hình 2.25 Hình 3.1 Hình 3.2 Hình 3.3 Hình 3.4 Hình 3.5 Hình 3.4 Hình 3.7 Hình 3.8 Hình 3.9 Mạch nguyên lý khối cảnh báo qua GSM Mạch nguyên lý nguồn tuyến tính Lưu đồ thuật toán xử lý vi khối xử lý trung tâm Lưu đồ thuật toán truyền thông Lưu đồ thuật toán giám sát nhiệt độ Lưu đồ thuật toán giám sát độ ẩm Lưu đồ thuật toán giám sát báo cháy lỗi cấp nguồn Lưu đồ thuật toán giám sát máy tính Lưu đồ thuật toán cảnh báo từ xa qua modem GSM Mô hình kết nối hệ thống thử nghiệm giám sát môi trường TTTHDL ĐHTN Thử nghiệm lắp đặt mạch xử lý trung tâm Thử nghiệm cài đặt phần mềm giám sát máy chủ Các giao diện thiết lập thông số cảnh báo giám sát Giao diện theo dõi lịch sử giám sát Kết thử nghiệm giám sát nhiệt độ Kết thử nghiệm giám sát độ ẩm Kết thử nghiệm giám sát báo cháy Kết thử nghiệm giám sát nguồn điện 41 43 44 45 46 47 48 49 50 52 53 53 54 54 55 56 56 57 MỞ ĐẦU Khi nhắc đến tảng hệ thống thông tin không nhắc đến Trung tâm tích hợp liệu (Data Center), trái tim toàn hệ thống Việc xây dựng Trung tâm tích hợp liệu (viết tắt TTTHDL) xu tất yếu nhu cầu bắt buộc, thiếu doanh nghiệp hay tổ chức Việc xây dựng TTTHDL tiêu chuẩn đảm bảo mục tiêu tối ưu cho hoạt động, đảm bảo tính sẵn sàng, tính thuận tiện vận hành phát triển hệ thống sau Thực tế thiết kế chuẩn hạ tầng kỹ thuật, TTTHDL gồm thành phần chính: − Hạ tầng mạng: máy chủ, hệ thống lưu trữ, thiết bị mạng… − Hạ tầng vật lý quan trọng: hệ thống làm mát HVAC, hệ thống phòng cháy chữa cháy, hệ thống nguồn cấp UPS, hệ thống an ninh vật lý v.v Hình A: Một môi trường trung tâm tích hợp liệu với nhiều tham số phải giám sát Như vậy, môi trường vận hành TTTHDL tồn hệ thống riêng biệt điều khiển tham số khác (điện áp, nhiệt độ, độ ẩm, nguồn điện, v.v.) với chung mục đích trì TTTHDL hoạt động an toàn, hiệu ổn định Tuy nhiên, thực tế hệ thống thường hoạt động độc lập giám sát xử lý cố tập trung dẫn đến tình trạng liệu nhiều, khó giám sát, tổng hợp so sánh Với lý đó, lựa chọn đề tài “Nghiên cứu xây dựng hệ thống giám sát môi trường Trung tâm tích hợp liệu” cho luận văn, tập trung nghiên cứu xây dựng hệ thống giám sát môi trường Trung tâm THDL thực giám sát thử nghiệm số thông số chọn lọc quan trọng nhiệt độ, báo cháy, độ ẩm, điện lưới (gọi tắt thông số chọn lọc) Để giải vấn đề, luận văn bố cục thành chương chính: Chương 1: Khảo sát tổng quan môi trường vận hành TTTHDL nghiên cứu lý thuyết đo lường giám sát sở xây dựng toán giám sát môi trường vận hành với số thông số chọn lọc Chương 2: Nghiên cứu xây dựng mô hình hệ thống giám sát số số thông số chọn lọc môi trường vận hành TTTHDL, từ thiết kế chi tiết thành phần phần cứng phần mềm tích hợp lại thành hệ thống giám sát hoàn chỉnh Chương 3: Tiến hành cài đặt thử nghiệm với số kịch giám sát thông số môi trường khác nhiệt độ, độ ẩm, báo cháy, điện lưới Trên cở sở đó, đánh giá độ xác phép đo khả triển khai hệ thống thực tế 78 UCSRC=0x86; UBRRH=0x00; UBRRL=0x19; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00; // ADC initialization // ADC Clock frequency: 187.500 kHz // ADC Voltage Reference: Int., cap on AREF // ADC Auto Trigger Source: Free Running // Only the most significant bits of // the AD conversion result are used ADMUX=ADC_VREF_TYPE & 0xff; ADCSRA=0x85;//bo chia tan so f/32 // SPI initialization // SPI disabled SPCR=0x00; // TWI initialization // TWI disabled TWCR=0x00; init_ds18b20(); //Init Ds18B20 // Alphanumeric LCD initialization // Connections specified in the // Project|Configure|C Compiler|Libraries|Alphanumeric LCD menu: // RS - PORTB Bit // RD - PORTB Bit // EN - PORTB Bit // D4 - PORTB Bit // D5 - PORTB Bit // D6 - PORTB Bit // D7 - PORTB Bit // Characters/line: 16 PORTC=0x00; y=7; lcd_init(16); lcd_gotoxy(0,0); //Di den cot1 dong lcd_putsf("ADC: RH: "); //Hien thi sau ky tu "" lcd_gotoxy(6,0); //Di den cot1 dong lcd_putchar(0b11011111); // ki tu lcd_putsf("C"); lcd_gotoxy(15,0); //Di den cot1 dong lcd_putsf("%"); lcd_gotoxy(0,1); //Di den cot1 dong lcd_putsf("DS18B: "); //Hien thi sau ky tu "" lcd_putsf("C"); lcd_gotoxy(0,2); //Di den cot1 dong lcd_putsf("PW: -Fire "); //Hien thi sau ky tu "" delay_ms(2000); lcd_gotoxy(0,3); //Di den cot1 dong lcd_putsf("RX:"); 79 alert=0; normal=1; while (1) { Read_Alert();//ktra canh bao nhietdovadoam();//Doc nhiet va dam read_ds18b20();//Doc nhiet DS18B20 read_temp(4);//Doc nhiet ADC lcd_putnum(temp,4,0);//Hien thi LCD tai vi tri 4x0 if(alert==1){lcd_gotoxy(8,3); lcd_putsf("Alert!");} else if(alert==0) {lcd_gotoxy(8,3); lcd_putsf("Normal");} Truyennhan(); delay_ms(50); // Place your code here } } Phụ lục C: Mã nguồn phần mềm giám sát viết cho máy chủ quản lý unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, jpeg, ComCtrls, CPort, Mask, DB, ADODB; type TForm1 = class(TForm) Button1: TButton; Button3: TButton; Label5: TLabel; Label6: TLabel; Panel1: TPanel; Timer1: TTimer; TabControl1: TTabControl; Label1: TLabel; Label3: TLabel; Label4: TLabel; Shape1: TShape; Shape2: TShape; Shape3: TShape; Shape4: TShape; Image4: TImage; Image5: TImage; 80 Image6: TImage; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Shape5: TShape; Shape6: TShape; Image3: TImage; Timer2: TTimer; Label7: TLabel; Label8: TLabel; Label9: TLabel; Shape7: TShape; Shape8: TShape; Image7: TImage; Shape9: TShape; Shape10: TShape; StaticText6: TStaticText; StaticText7: TStaticText; Shape11: TShape; StaticText8: TStaticText; Shape12: TShape; Image8: TImage; Edit5: TEdit; ComPort1: TComPort; ComPort2: TComPort; StaticText10: TStaticText; Button6: TButton; Panel2: TPanel; Timer3: TTimer; Button8: TButton; Image9: TImage; CheckBox1: TCheckBox; CheckBox2: TCheckBox; CheckBox3: TCheckBox; CheckBox4: TCheckBox; Label2: TLabel; Label10: TLabel; Edit6: TEdit; Label11: TLabel; Label12: TLabel; Label13: TLabel; Shape13: TShape; Shape14: TShape; Shape15: TShape; Shape16: TShape; Label14: TLabel; Label15: TLabel; Label16: TLabel; Label17: TLabel; Shape18: TShape; Shape17: TShape; Image10: TImage; Button5: TButton; Timer4: TTimer; Shape19: TShape; 81 Shape20: TShape; ADOConnection1: TADOConnection; ADOTable1: TADOTable; DataSource1: TDataSource; Shape21: TShape; Shape22: TShape; Shape23: TShape; Label21: TLabel; Label22: TLabel; Label23: TLabel; Label24: TLabel; Label25: TLabel; Edit7: TEdit; Panel3: TPanel; Memo1: TMemo; Image2: TImage; Label19: TLabel; Image1: TImage; Memo2: TMemo; Button2: TButton; Timer5: TTimer; Memo3: TMemo; Memo4: TMemo; DataSource2: TDataSource; ADOConnection2: TADOConnection; ADOTable2: TADOTable; ADOQuery1: TADOQuery; Button4: TButton; procedure Creat(Sender: TObject); procedure Time(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Timer3Timer(Sender: TObject); procedure Button1Click(Sender: TObject); procedure TabControl1Change(Sender: TObject); procedure Button8Click(Sender: TObject); procedure Timer2Timer(Sender: TObject); procedure Timer4Timer(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Timer5Timer(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button7Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Count: Integer; fire1,fire2,fire3,fire4,pw1,pw2,ups1,ups2,tempx: Integer; temp1,temp2,temp3,humi,temp9:Integer; 82 temp5,temp6,temp7,temp10:String; temp_x1,temp_y1,temp_x2,temp_y2,startGSM,retry: Integer; jj,ii,kk,qq,alert,normal,nortifi:integer; temp8 : Array[1 12] of Integer; // temp10 : Array[1 5] of String; implementation uses Unit2, Unit3, Unit4, Unit5, Unit6, Unit7, Unit8,Unit9; {$R *.dfm} procedure TForm1.Creat(Sender: TObject); var i:integer; begin timer1.Enabled:=false; timer2.Enabled:=false; timer3.Enabled:=false; timer4.Enabled:=false; timer5.Enabled:=false; tempx:=1; startGSM:=0; retry:=0; //Khoi tao cac bien trang thai alert:=0; normal:=1; nortifi:=0; temp1:=20; temp2:=21; temp3:=22; humi:=43; fire1:=1;fire2:=1;fire3:=1;fire4:=1; pw1:=1; pw1:=1;ups1:=1; ups2:=1; // khoi tao bien de ve thi jj:=16; ii:=16; kk:=16; qq:=16; temp_x1:=16; temp_y1:=image1.Height-15; temp_x2:=16; temp_y2:=image1.Height-15; Image1.Canvas.Pen.Width:=1; Image1.Canvas.Pen.Color:=clBlack; Image1.Canvas.brush.Color:=clBlack; image1.canvas.Rectangle(0,0,image1.Width,image1.Height); //Ve duong ngang Image1.Canvas.Pen.Color:=clGray; Image1.Canvas.brush.Color:=clGray; for i:=1 to 10 begin Image1.Canvas.moveTo(15,image1.Height-25*I-15); Image1.Canvas.lineTo(Image1.width-0, image1.Height-25*i-15); end; //Bieu dien thang nhiet Image1.Canvas.Pen.Color:=clRed; 83 Image1.Canvas.brush.Color:=clBlack; Image1.Canvas.Font.Color:=clRed; for i:=1 to 10 begin image1.Canvas.TextOut(0,image1.Height-25*i-20, InttoStr(10*i)); end; //Bieu dien thang thoi gian Image1.Canvas.Pen.Color:=clBlue; Image1.Canvas.brush.Color:=clBlack; Image1.Canvas.Font.Color:=clWhite; ; for i:=2 to 25 begin image1.Canvas.TextOut(25*i-20,image1.Height-15, InttoStr(10*i-10)); end; //Ve duong doc Image1.Canvas.Pen.Color:=clGray; Image1.Canvas.brush.Color:=clGray; for i:=2 to 25 begin Image1.Canvas.moveTo(25*i-10, 10); Image1.Canvas.lineTo(25*i-10, Image1.height-15); end; //Ve cot x va y cua thi Image1.Canvas.Pen.Color:=clRed; Image1.Canvas.brush.Color:=clRed; image1.canvas.MoveTo(15,0); image1.canvas.LineTo(15,image1.Height-15); image1.canvas.MoveTo(15,image1.Height-15); image1.canvas.LineTo(image1.width,image1.height-15); // bat dau ve thi Image1.Canvas.Pen.Width:=2; Datasource1.DataSet.Active:=true; ADOTable1.Active:=true; Datasource2.DataSet.Active:=true; ADOTable2.Active:=true; { Comport1.Port:=ADOTable1.FieldByName('com_gsm_port').Value; Comport1.BaudRate:=br9600; Comport1.DataBits := dbEight; Comport1.Parity.Bits:=prNone; Comport1.StopBits:=sbOneStopBit; Comport1.FlowControl.FlowControl:=fcNone; Comport2.Port:=ADOTable1.FieldByName('com_dcems_port').Value; Comport2.BaudRate:=br9600; Comport2.DataBits := dbEight; Comport2.Parity.Bits:=prNone; Comport2.StopBits:=sbOneStopBit; Comport2.FlowControl.FlowControl:=fcNone; } Comport2.ShowSetupDialog; Comport2.Open; Form1.WindowState:=wsMaximized; Shape9.Brush.color:=clgray; 84 Shape10.Brush.color:=clgray; Timer1.enabled:=true; Timer2.enabled:=true; Timer3.enabled:=true; Timer4.enabled:=true; Timer5.enabled:=true; end; procedure TForm1.Time(Sender: TObject); var pp:integer; begin Panel1.Caption:=FormatDateTime('hh:nn:ss',Now); // Hien thi gio Panel2.caption:= FormatDateTime('dd/mm/yyyy',Now); //Hien thi ADOTable1.TableName:='config'; Timer3.Interval:= ADOTable1.FieldByName('interval').Value; Timer4.Interval:= ADOTable1.FieldByName('interval').Value; if (((ADOTable1.FieldByName('pw1_en').Value='1')and (pw1=0)) or ((ADOTable1.FieldByName('pw2_en').Value='1') and (pw2=0)) or ((ADOTable1.FieldByName('ups1_en').Value='1') and (ups1=0)) or ((ADOTable1.FieldByName('ups2_en').Value='1') and (ups2=0)) or ((ADOTable1.FieldByName('fire1_en').Value='1') and (fire1=0)) or ((ADOTable1.FieldByName('fire2_en').Value='1') and (fire2=0))or ((ADOTable1.FieldByName('fire3_en').Value='1') and (fire3=0)) or ((ADOTable1.FieldByName('fire4_en').Value='1') and (fire4=0))or ((temp1 ADOTable1.FieldByName('temp_alert_b').Value) and (ADOTable1.FieldByName('temp1_en').Value='1'))or ((temp2 ADOTable1.FieldByName('temp_alert_b').Value) and (ADOTable1.FieldByName('temp2_en').Value='1'))or ((temp3 ADOTable1.FieldByName('temp_alert_b').Value) and (ADOTable1.FieldByName('temp3_en').Value='1'))or ((humi ADOTable1.FieldByName('humi_alert_b').Value) and (ADOTable1.FieldByName('humi_en').Value='1'))) then begin alert:=1; //thiet lap gia tri canh bao normal:=0; ADOTable1.Edit;//Luu vao CSDL ADOTable1.TableName:='config'; ADOTable1.FieldByName('alert').AsVariant:='1'; ADOTable1.FieldByName('normal').AsVariant:='0'; ADOTable1.UpdateStatus; ADOTable1.Post; Shape21.Brush.color:=clGray; Shape23.Brush.color:=clRed; end; if (((temp1>ADOTable1.FieldByName('temp_norti1_a').Value) and (ADOTable1.FieldByName('temp1_en').Value='1')) or 85 ((temp1< ADOTable1.FieldByName('temp_norti1_b').Value) and (ADOTable1.FieldByName('temp1_en').Value='1'))or ((temp1>ADOTable1.FieldByName('temp_norti2_a').Value) and (ADOTable1.FieldByName('temp1_en').Value='1')) or ((temp1< ADOTable1.FieldByName('temp_norti2_b').Value) and (ADOTable1.FieldByName('temp1_en').Value='1'))or ((humi>ADOTable1.FieldByName('humi_norti1_a').Value) and (ADOTable1.FieldByName('humi_en').Value='1')) or ((humi< ADOTable1.FieldByName('humi_norti1_b').Value) and (ADOTable1.FieldByName('humi_en').Value='1'))or ((humi>ADOTable1.FieldByName('humi_norti2_a').Value) and (ADOTable1.FieldByName('humi_en').Value='1')) or ((humi< ADOTable1.FieldByName('humi_norti2_b').Value) and (ADOTable1.FieldByName('humi_en').Value='1'))) then begin nortifi:=1; //thiet lap gia tri canh bao normal:=0; ADOTable1.Edit;//Luu vao CSDL ADOTable1.TableName:='config'; ADOTable1.FieldByName('nortification').AsVariant:='1'; ADOTable1.FieldByName('normal').AsVariant:='0'; ; ADOTable1.UpdateStatus; ADOTable1.Post; Shape22.Brush.color:=clYellow; Shape21.Brush.color:=clGray; //Tin hieu canh bao end; end; procedure TForm1.Button4Click(Sender: TObject); var num1:String; begin Comport1.Port:= ADOTable1.FieldByName('com_gsm_port').Value; ComPort1.Open; if comport1.connected true then Comport1.ClearBuffer(True, True); //Test so if ((ADOTable1.FieldByName('gsm_enable').Value='1') and (ADOTable1.FieldByName('sdt1_enable').Value='1')) then begin num1:=ADOTable1.FieldByName('sdt1').Value; ComPort1.WriteStr('AT+CMGF=1'+ #13#10); Sleep(100); ComPort1.WriteStr('AT+CMGS="'); ComPort1.WriteStr(num1); ComPort1.WriteStr('"'+#13#10); Sleep(100); ComPort1.WriteStr('Test SMS from DCEMS successfull!' + #26+ #13#10); Sleep(1000); end; end; procedure TForm1.Button5Click(Sender: TObject); var num1:String; begin Comport1.Port:= ADOTable1.FieldByName('com_gsm_port').Value; 86 ComPort1.Open; if comport1.connected true then Comport1.ClearBuffer(True, True); //Test so if ((ADOTable1.FieldByName('gsm_enable').Value='1') and (ADOTable1.FieldByName('sdt1_enable').Value='1') and (startGSM=1)) then begin num1:=ADOTable1.FieldByName('sdt1').Value; { ComPort1.WriteStr('AT+CMGF=1'+ #13#10); Sleep(100); ComPort1.WriteStr('AT+CMGS="'); ComPort1.WriteStr(num1); ComPort1.WriteStr('"'+#13#10); Sleep(100); ComPort1.WriteStr('Test SMS from DCEMS successfull!' + #26+ #13#10); Sleep(1000); } //Goi dien ComPort1.WriteStr('ATD'); ComPort1.WriteStr(num1); ComPort1.WriteStr(';'); ComPort1.WriteStr(#13#10); Sleep(100); end; end; procedure TForm1.Button6Click(Sender: TObject); begin Application.CreateForm(TForm9, Form9); Form9.Show; end; procedure TForm1.Timer3Timer(Sender: TObject); begin //Doc so dien thoai canh bao man hinh Edit5.Text:=ADOTable1.FieldByName('sdt1').Value; Edit6.Text:=ADOTable1.FieldByName('sdt2').Value; Edit7.Text:=ADOTable1.FieldByName('sdt3').Value; //Doc trang thai Power if (ADOTable1.FieldByName('pw1_en').Value='1') then shape5.Brush.color:=clLime else shape5.Brush.color:=clgray; if (ADOTable1.FieldByName('pw2_en').Value='1') then shape19.Brush.color:=clLime else shape19.Brush.color:=clgray; if (ADOTable1.FieldByName('ups1_en').Value='1') then shape6.Brush.color:=clLime else shape6.Brush.color:=clgray; if (ADOTable1.FieldByName('ups2_en').Value='1') then shape20.Brush.color:=clLime else shape20.Brush.color:=clgray; //Doc trang thai Bao chay if (ADOTable1.FieldByName('fire1_en').Value='1') then Shape13.Brush.color:=clLime else 87 Shape13.Brush.color:=clgray; if (ADOTable1.FieldByName('fire2_en').Value='1') then shape14.Brush.color:=clLime else shape14.Brush.color:=clgray; if (ADOTable1.FieldByName('fire3_en').Value='1') then shape15.Brush.color:=clLime else shape15.Brush.color:=clgray; if (ADOTable1.FieldByName('fire4_en').Value='1') then shape16.Brush.color:=clLime else shape16.Brush.color:=clgray; //3 Trang thai canh bao if (ADOTable1.FieldByName('normal').Value='1') then Shape21.Brush.color:=clLime else shape21.Brush.color:=clgray; if (ADOTable1.FieldByName('nortification').Value='1') then Shape22.Brush.color:=clYellow else shape22.Brush.color:=clgray; if (ADOTable1.FieldByName('alert').Value='1') then begin Shape23.Brush.color:=clRed; if ((ADOTable1.FieldByName('gsm_enable').Value='1')and (ADOTable1.FieldByName('call_enable').Value='1')) then begin if (Button5.Enabled=true)then Button5.Click; Button5.Enabled:=false; end; if ((ADOTable1.FieldByName('gsm_enable').Value='1')and (ADOTable1.FieldByName('sms_enable').Value='1')) then begin if (Button4.Enabled=true)then Button4.Click; Button4.Enabled:=false; end; end else shape23.Brush.color:=clgray; end; procedure TForm1.Button1Click(Sender: TObject); begin Application.CreateForm(TForm7, Form7); Form7.Show; end; procedure TForm1.TabControl1Change(Sender: TObject); begin if TabControl1.TabIndex = then begin Form1.Show; Form1.TabControl1.TabIndex := 0; end; if TabControl1.TabIndex = then begin Application.CreateForm(TForm2, Form2); Form2.Show; Form1.TabControl1.TabIndex := 1; end; if TabControl1.TabIndex = then 88 begin Application.CreateForm(TForm3, Form3); Form3.Show; Form1.TabControl1.TabIndex := 2; end; if TabControl1.TabIndex = then begin Application.CreateForm(TForm8, Form8); //delay(1000); Form8.Show; Form1.TabControl1.TabIndex := 3; end; if TabControl1.TabIndex = then begin Application.CreateForm(TForm6, Form6); Form6.Show; Form1.TabControl1.TabIndex := 4; end; end; procedure TForm1.Button8Click(Sender: TObject); begin Application.CreateForm(TForm5, Form5); Form5.Show; Form5.WindowState:= wsMaximized; end; procedure TForm1.Timer2Timer(Sender: TObject); var tt: Integer; begin if(Comport2.Connected=true) then begin if(ADOTable1.FieldByName('temp1_en').Value='1')then begin Comport2.WriteStr('T'); if (Comport2.TriggersOnRxChar) then begin for tt:=1 to 12 begin Comport2.WriteStr('T'); Comport2.Read(temp8[tt],1); end; end; end; Memo1.Text:= inttostr(temp8[1]); Panel3.Caption:=inttostr(temp8[1])+ ' oC'; Memo2.Text:= inttostr(temp8[2]); Memo3.Text:= inttostr(temp8[3]); Memo4.Text:= inttostr(temp8[4]); //Nhiet va am if(ADOTable1.FieldByName('temp1_en').Value='1')then if (ABS(temp8[1]-temp1)

Ngày đăng: 16/04/2017, 17:33

Từ khóa liên quan

Mục lục

  • PHỤ LỤC

Tài liệu cùng người dùng

Tài liệu liên quan