Ứng dụng công nghệ GSMGPRS trong điều khiển và giám sát các hệ thống chiếu sáng

111 292 0
Ứng dụng công nghệ GSMGPRS trong điều khiển và giám sát các hệ thống chiếu sáng

Đ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

TRANG BèA PH B GIO DC V O TO TRNG I HC BCH KHOA H NI Lấ THI HIP NG DNG CễNG NGH GSM/GPRS TRONG IU KHIN V GIM ST CC H THNG CHIU SNG Chuyờn ngnh: Thit b in in t LUN VN THC S KHOA HC K THUT IN HNG DN KHOA HC: PGS.TS Lấ VN DOANH H Ni - 2010 LI CAM OAN Tụi xin cam oan õy l cụng trỡnh nghiờn cu ca riờng tụi Cỏc s liu, kt qu nờu lun l trung thc v cha tng c cụng b bt k cụng trỡnh no khỏc Tỏc gi lun Lờ Thỏi Hip MC LC Trang TRANG BèA PH LI CAM OAN MC LC DANH MC CC Kí HIU V CH VIT TT DANH MC CC BNG 11 DANH MC CC HèNH V V TH 12 M U 14 Tớnh cp thit ca ti 14 í ngha khoa hc v thc tin ca ti 15 Mc ớch, i tng, phm vi v phng phỏp nghiờn cu ca ti 15 3.1 Mc ớch 15 3.2 i tng nghiờn cu 15 3.3 Phm vi nghiờn cu 15 3.4 Phng phỏp nghiờn cu 15 Kt cu ca lun 16 Chng I 18 CC VN CHUNG V IU KIN V GIM ST H THNG CHIU SNG CễNG CNG 18 1.1 Hin trng h thng chiu sỏng cụng cng ca thnh ph Quy Nhn 18 1.1.1 n v qun lý hnh h thng chiu sỏng cụng cng thnh ph Quy Nhn 18 1.1.2 Chiu sỏng ti mt s khu vc chớnh thnh ph Quy Nhn 19 1.1.3 Cụng tỏc iu khin v hnh h thng chiu sỏng cụng cng ti thnh ph Quy Nhn 24 1.2 Cỏc phng phỏp iu khin v hnh h thng chiu sỏng cụng cng 25 1.2.1 Phng phỏp tt xen k gim cụng sut h thng chiu sỏng 25 1.2.2 Phng phỏp iu chnh bng chn lu nhiu mc cụng sut cú h thng ốn nhiu cp cụng sut 27 1.2.3 Phng phỏp iu chnh in ỏp ti t iu khin chiu sỏng tit gim cụng sut ca h thng chiu sỏng 30 1.3 Nhng hn ch ca cỏc h thng chiu sỏng m cỏc t iu khin chiu sỏng lm vic c lp 33 1.4 Vn hnh v iu khin h thng chiu sỏng cụng cng thụng qua ng dõy mng in thoi v mng in cung cp ti H Ni 34 1.4.1 Truyn thụng gia Trung tõm iu khin v t iu khin khu vc 35 1.4.2 Truyn thụng gia t iu khin khu vc v t chiu sỏng 35 1.4.3 Cỏc cp iu khin ca h thng iu khin giỏm sỏt trung tõm 35 1.4.4 u v nhc im 37 1.5 Vn hnh v iu khin h thng chiu sỏng cụng cng thụng qua mng Internet v mng in cung cp ti thnh ph H Chớ Minh 38 1.5.1 Truyn thụng gia Trung tõm iu khin v t iu khin khu vc 39 1.5.2 u v nhc im 39 Kt lun chng 39 Chng II 41 GII PHP CễNG NGH CHO IU KHIN V GIM ST H THNG CHIU SNG CễNG CNG 41 2.1 Mt s gii phỏp iu khin v giỏm sỏt h thng chiu sỏng theo cụng ngh hin i 41 2.1.1 iu khin v giỏm sỏt h thng chiu sỏng thụng qua ng dõy in thoi kt hp vi mng in cung cp 41 2.1.2 iu khin v giỏm sỏt h thng chiu sỏng thụng qua mng Internet kt hp vi mng in cung cp .42 2.1.3 iu khin v giỏm sỏt h thng chiu sỏng thụng qua mng GSM/GPRS 43 2.1.4 So sỏnh cỏc cụng ngh hin cú nc 44 2.2 Tng quan v cụng ngh GSM/GPRS 46 2.2.1 Tng quan v GSM: .47 2.2.2 Tng quan v GPRS .53 2.2.3 Tng quan ca cụng ngh GSM/GPRS mng vin thụng 58 2.3 Cỏc thit b k thut h tr truyn thụng theo cụng ngh GSM/GPRS .59 2.4 Cỏc gii phỏp ng dng cụng ngh GSM/GPRS giỏm sỏt v iu khin chiu sỏng cụng cng 61 2.4.1 iu khin v giỏm sỏt theo khu vc .61 2.4.2 iu khin v giỏm sỏt theo im sỏng 62 2.5 Mụ hỡnh chung v h thng chiu sỏng cụng cng ng dng cụng ngh GSM/GPRS 63 Kt lun chng 64 Chng III 65 XY DNG NG DNG DA VO CễNG NGH GSM/GPRS IU KHIN V GIM ST H THNG CHIU SNG CễNG CNG TRấN A BN THNH PH QUY NHN 65 3.1 Cu trỳc h thng 65 3.1.1 Cu trỳc chi tit h thng 65 3.1.2 Cu trỳc t iu khin chiu sỏng 66 3.1.3 Cu trỳc b ốn .67 3.2 Xõy dng phn mm 68 3.2.1 Cỏc bc xõy dng phn mm .68 3.2.2 S ca phn mm 72 3.2.3 Lu thut toỏn ca phn mm 73 3.2.4 Cỏc giao din chớnh ca phn mm 76 3.3 Phõn tớch tớnh hiu qu 77 3.3.1 Hiu qu k thut 77 3.3.2 Hiu qu qun lý 78 3.3.3 Hiu qu kinh t 79 3.3.4 Tỏc ng mụi trng 79 Kt lun chng 79 KT QU V BN LUN 80 Kt qu thc hin 80 Cỏc nhn xột 81 KT LUN V KIN NGH 82 Kt lun 82 úng gúp mi v kin ngh v s dng kt qu ca lun 82 2.1 Cỏc úng gúp mi 82 2.2 Kin ngh v s dng kt qu lun .82 Hn ch, hng phỏt trin .83 TI LIU THAM KHO 84 PH LC 88 DANH MC CC Kí HIU V CH VIT TT Ký hiu Ký hiu I Iốn U Uốn Ulv P Wh Tờn gi Cng dũng in Cng dũng in qua mt b ốn in ỏp in ỏp cp cho mt b ốn in ỏp lm vic Cụng sut tỏc dng Ch s cụng t in Ch vit tt Ch vit tt A AC ADSL AP ATM AUC English Ting Vit Alternating Current Asymmetric Digital Subscriber Line Attacked Processor Asynchronous Transfer Mode Authentication Center Dũng in xoay chiu ng thuờ bao s khụng i xng B x lý gn thờm Ch truyn khụng ng b Trung tõm nhn thc Border Gateway Base Station Controler Base Station Subsystem Base Tranceiver Station Cng ng biờn B iu khin trm gc Phõn h trm gc Trm thu phỏt gc Common Communication Services Code Division Multiple Access Charging Data Records Committee of European Post and Telecommunication Circuit Switch Public Data Cỏc dch v truyn thụng chung B BG BSC BSS BTS C CCS CDMA CDR CEPT CSPDN a truy nhp phõn chia theo mó Bn ghi d liu cc y ban bu chớnh v vin thụng chõu u Mng d liu chuyn mch cụng CtyTNHH D DC K KCS E EDGE EIR ETSI F FDMA FTP G G (2G;3G ) GGSN GMSC GPRS GSM GSN Network cng Cụng ty trỏch nhim hu hn Direct Curent Dũng in mt chiu iu khin iu khin chiu sỏng Enhanced Data rate for GSM Evolution Equipment Identity Register European Telecommunications Standard Institute Mng thụng tin di ng ton cu cú tc truyn dn cao Thanh ghi nhn dng thit b Vin tiờu chun vin thụng Chõu u Frequence Division Multiple a truy cp phõn chia theo tn Access s File Transfer Protocol Giao thc truyn tin Generation Gateway GPRS Support Node Gateway Mobile Service Switching Centre General Packet Radio Services Global System for Mobile communication GPRS Support Node Th h Nỳt h tr cng GPRS Cng chuyn mch dch v di ng trung tõm Dch v vụ tuyn gúi chung Thụng tin di ng ton cu Home Location Register Human Machine Interface High Pressure Sodium Hypertext Transfer Protocol Thanh ghi nh v thng trỳ Giao din ngi mỏy ốn Sodium cao ỏp H thng chiu sỏng cụng cng Giao thc Truyn Siờu bn Internet Protocol Industrial PC Integrated Servive Network InterWorking Function Chc nng tng tỏc mng Nỳt h tr GPRS H HLR HMI HPS HTCSCC HTTP I IP IPC ISDN IWF K KT KTYC M ME Giao thc mng Internet Mỏy tớnh cụng nghip Digital Mng s a dch v Kim tra Kim tra yờu cu Mobile Equipment Thit b di ng MS MSC Mobile Station Mobile Switching Center Trm di ng Trung tõm chuyn mch di ng N NSS Network Subsystem and Switching Mng phõn h chuyn mch O OMC Operations and Maintenance Center Application Programming Interface Open System Interconnection Operation and Support Subsystem OPC OSI OSS Trung tõm khai thỏc v bo dng Giao din kh trỡnh ng dng Liờn thụng cỏc h thng m Phõn h khai thỏc v h tr P PAC Programmable Automation Controller Personal Computer Packet Control Unit Public Data Network Packet Data Protocol Programable Logic Controller Power Line Communication PC PCU PDN PDP PLC PLC PLC-RTU PLMN PS PSPDN PSTN B iu khin t ng húa kh trỡnh Mỏy tớnh cỏ nhõn n v iu khin gúi Mng d liu cụng cng Giao thc d liu gúi Thit b iu khin kh trỡnh Cụng ngh truyn thụng qua ng dõy cung cp in Power Line Communication Thit b u cui iu khin t Remote Terminal Unit xa theo cụng ngh truyn thụng qua ng cung cp in Public Land Mobile Network Mng di ng mt t cụng cng Packet Switch B chuyn mch gúi Public Switched Packet Data Mng chuyn mch gúi d liu Network cụng cng Public Switched Telephone Mng chuyn mch thoi cụng Network cng Q QoS Quality of Service Cht lng dch v Session Control Serving GPRS Support Node Subscriber Identity Module iu khin tỏc v giao tip Nỳt h tr dch v GPRS Module nhn dng thuờ bao S SC SGSN SIM SMS SMTP Short Message Services Simple mail Transfer Protocol SS Switching Subsytem T TCP/IP TDMA TI TP TRAU TT TU Dch v thụng bỏo ngn Giao thc chuyn th tớn n gin Phõn h chuyn mch Transmission Control Protocol/ Giao thc iu khin truyn d Internet Protocol liu/Giao thc mng Internet Time Division Multiple Access a truy cp phõn chia theo thi gian Current Transformers Mỏy bin dũng in Thnh ph Transcoder/Rate Adaption Unit Khi mó hoỏ v gii mó thớch nghi tc S th t Voltage Transformers Mỏy bin in ỏp V VLR VAS W WCDMA Visitor Location Register Value Added Service Wideband Code Multiplex Access Thanh ghi nh v tm trỳ Dch v giỏ tr b sung Division a truy cp phõn chia theo mó bng rng 10 Ph lc Mụ hỡnh thng iu khin v giỏm sỏt s dng PAC ca Opto 22 Ngun [31] 98 Ph lc 6: Mụ hỡnh h thng iu khin v giỏm sỏt t xa ca Schneider Electric Ngun [32] 99 Ph lc 7: Mụ hỡnh h thng iu khin v qun lý ca Schweitzer Engineering Laboratories (SEL) Ngun [35] 100 Ph lc 8: Mụ hỡnh h thng iu khin v giỏm sỏt t xa ca Teldat Ngun [36],[37] 101 Ph lc 9: Mó lnh phn mm Control Lighting 9.1 Mó lnh chng trỡnh Control Lighting for Server Ph lc ch trỡnh by cỏc mó lnh chớnh ca chng trỡnh 9.1.1 Form Main Giao din thit k Form Private Sub MDIForm_Unload(Cancel As Integer) End End Sub Mó lnh: Option Explicit Dim StateBut11 As Boolean, StateBut12 As Boolean, StateBut13 As Boolean Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer) Dim traloi As String traloi = MsgBox("Do you want to exit?", vbQuestion + vbYesNo, "Attention! ") If Val(traloi) = Then Cancel = True ' MsgBox traloi End Sub Private Sub mnuBackup_Click() ' fsaoluu End Sub Private Sub mnuPrintRecord_Click() Select Case KindControl Case PrintRecord "temptsaveroad" Case ' PrintRecord "viewpark" Case ' PrintRecord "viewart" End Select End Sub Private Sub mnuPrintReport_Click() Select Case KindControl Case PrintReport "viewroad" Case PrintReport "viewpark" Case PrintReport "viewart" End Select End Sub Private Sub Timer1_Timer() SetChedo End Sub Private Sub MDIForm_Activate() ' ChooseF123 End Sub Private Sub MDIForm_Initialize() F0dsTramdk.Show mnuWorkStations.Checked = True ChooseF123 dinhviForm 'MsgBox Toolbar.Buttons(1).Caption QuyenAdmin ChooseF123 F11StateofConnection.Show End Sub Private Sub MDIForm_Resize() dinhviForm End Sub Private Sub dinhviForm() Dim x As Integer, a As Integer, b As Integer x = 1500 'F11StateofConnection.Height = x a = 180 'Bo theo huong ngang b = 800 'Bo theo huong dung F0dsTramdk.Top = F0dsTramdk.Left = F0dsTramdk.Width = 3400 If (MDIf1.Height - Toolbar.Height) > (b + x) Then F0dsTramdk.Height = MDIf1.Height - Toolbar.Height - b - x Else F0dsTramdk.Height = MDIf1.Height End If ' ' Bao loi ' -F11StateofConnection.Left = F11StateofConnection.Width = F0dsTramdk.Width F11StateofConnection.Height = x F11StateofConnection.Top = F0dsTramdk.Height ' ' Road ' -F1road.Top = F1road.Left = F0dsTramdk.Width If (MDIf1.Width - F0dsTramdk.Width) > a Then F1road.Width = MDIf1.Width - F0dsTramdk.Width - a Else F1road.Width = a End If F1road.Height = F0dsTramdk.Height + x ' F2road.Top = F2road.Left = F0dsTramdk.Width If (MDIf1.Width - F0dsTramdk.Width) > a Then F2road.Width = MDIf1.Width - F0dsTramdk.Width - a Else F2road.Width = a End If F2road.Height = F0dsTramdk.Height + x ' F3road.Top = F3road.Left = F0dsTramdk.Width If (MDIf1.Width - F0dsTramdk.Width) > a Then F3road.Width = MDIf1.Width - F0dsTramdk.Width - a Else F3road.Width = a End If F3road.Height = F0dsTramdk.Height + x ' F4road.Top = F4road.Left = F0dsTramdk.Width If (MDIf1.Width - F0dsTramdk.Width) > a Then F4road.Width = MDIf1.Width - F0dsTramdk.Width - a Else F4road.Width = a End If F4road.Height = F0dsTramdk.Height + x ' ' Park ' F1park.Top = F1park.Left = F0dsTramdk.Width If (MDIf1.Width - F0dsTramdk.Width) > a Then F1park.Width = MDIf1.Width - F0dsTramdk.Width - a Else F1park.Width = a End If F1park.Height = F0dsTramdk.Height + x ' F2park.Top = F2park.Left = F0dsTramdk.Width If (MDIf1.Width - F0dsTramdk.Width) > a Then F2park.Width = MDIf1.Width - F0dsTramdk.Width - a Else 102 F2park.Width = a End If F2park.Height = F0dsTramdk.Height + x ' F3park.Top = F3park.Left = F0dsTramdk.Width If (MDIf1.Width - F0dsTramdk.Width) > a Then F3park.Width = MDIf1.Width - F0dsTramdk.Width - a Else F3park.Width = a End If F3park.Height = F0dsTramdk.Height + x ' ' Art ' F1art.Top = F1art.Left = F0dsTramdk.Width If (MDIf1.Width - F0dsTramdk.Width) > a Then F1art.Width = MDIf1.Width - F0dsTramdk.Width - a Else F1art.Width = a End If F1art.Height = F0dsTramdk.Height + x ' F2art.Top = F2art.Left = F0dsTramdk.Width If (MDIf1.Width - F0dsTramdk.Width) > a Then F2art.Width = MDIf1.Width - F0dsTramdk.Width - a Else F2art.Width = a End If F2art.Height = F0dsTramdk.Height + x ' F3art.Top = F3art.Left = F0dsTramdk.Width If (MDIf1.Width - F0dsTramdk.Width) > a Then F3art.Width = MDIf1.Width - F0dsTramdk.Width - a Else F3art.Width = a End If F3art.Height = F0dsTramdk.Height + x ' End Sub Private Sub TimerAutosave_Timer() ' SetServerToClient SetAutoSave End Sub Private Sub Toolbar_ButtonClick(ByVal Button As ComctlLib.Button) If Button.Index = 11 Then IndexBut = ChooseF123 IndexBut End If If Button.Index = 12 Then IndexBut = ChooseF123 IndexBut End If If Button.Index = 13 Then IndexBut = ChooseF123 IndexBut End If If Button.Index = 14 Then IndexBut = ChooseF123 IndexBut End If Private Sub StateButs(ByVal IndexBut As Integer, ValButTrue As Boolean) Select Case IndexBut Case 11 StateBut11 = ValButTrue StateBut12 = Not ValButTrue StateBut13 = Not ValButTrue Case 12 StateBut11 = Not ValButTrue StateBut12 = ValButTrue StateBut13 = Not ValButTrue Case 13 StateBut11 = Not ValButTrue StateBut12 = ValButTrue StateBut13 = Not ValButTrue End Select End Sub Public Sub ChooseF123(ByVal IndexBut As Integer) ' On Error GoTo ErrorState Select Case IndexBut Case 'Supervise Select Case KindControl Case F1road.Visible = True F2road.Visible = False F3road.Visible = False F4road.Visible = False F1park.Visible = False F2park.Visible = False F3park.Visible = False F1art.Visible = False F2art.Visible = False F3art.Visible = False Case F1road.Visible = False F2road.Visible = False F3road.Visible = False F4road.Visible = False F1park.Visible = True F2park.Visible = False F3park.Visible = False F1art.Visible = False F2art.Visible = False F3art.Visible = False Case F1road.Visible = False F2road.Visible = False F3road.Visible = False F4road.Visible = False F1park.Visible = False F2park.Visible = False F3park.Visible = False F1art.Visible = True F2art.Visible = False F3art.Visible = False End Select If (Button.Index = 11) Or (Button.Index = 12) Or (Button.Index = 13) Or (Button.Index = 14) Then dinhviForm End If ' If Button.Index = Then Select Case IndexBut Case Select Case KindControl Case PrintReport "viewroad" Case PrintReport "viewpark" Case PrintReport "viewart" End Select Case Select Case KindControl Case PrintRecord "temptsaveroad" Case PrintRecord "temptsavepark" Case PrintRecord "temptsaveart" End Select End Select End If End Sub Case 'Control Select Case KindControl Case F1road.Visible = False F2road.Visible = True F3road.Visible = False F4road.Visible = False F1park.Visible = False F2park.Visible = False F3park.Visible = False F1art.Visible = False F2art.Visible = False F3art.Visible = False F2road.LoadValueDK Case F1road.Visible = False F2road.Visible = False F3road.Visible = False F4road.Visible = False F1park.Visible = False F2park.Visible = True F3park.Visible = False F1art.Visible = False F2art.Visible = False F3art.Visible = False Case F1road.Visible = False F2road.Visible = False F3road.Visible = False F4road.Visible = False F1park.Visible = False F2park.Visible = False F3park.Visible = False F1art.Visible = False F2art.Visible = True F3art.Visible = False End Select 103 Case 'Report Select Case KindControl Case F1road.Visible = False F2road.Visible = False F3road.Visible = True F4road.Visible = False F1park.Visible = False F2park.Visible = False F3park.Visible = False F1art.Visible = False F2art.Visible = False F3art.Visible = False Case F1road.Visible = False F2road.Visible = False F3road.Visible = False F4road.Visible = False F1park.Visible = False F2park.Visible = False F3park.Visible = True F1art.Visible = False F2art.Visible = False F3art.Visible = False Case F1road.Visible = False F2road.Visible = False F3road.Visible = False F4road.Visible = False F1park.Visible = False F2park.Visible = False F3park.Visible = False F1art.Visible = False F2art.Visible = False F3art.Visible = True End Select Case 'Report Select Case KindControl Case F1road.Visible = False F2road.Visible = False F3road.Visible = False F4road.Visible = True F1park.Visible = False F2park.Visible = False F3park.Visible = False F1art.Visible = False F2art.Visible = False F3art.Visible = False Case F1road.Visible = False F2road.Visible = False F3road.Visible = False F4road.Visible = False F1park.Visible = False F2park.Visible = False F3park.Visible = True F1art.Visible = False F2art.Visible = False F3art.Visible = False Case F1road.Visible = False F2road.Visible = False F3road.Visible = False F4road.Visible = False F1park.Visible = False F2park.Visible = False F3park.Visible = False F1art.Visible = False F2art.Visible = False F3art.Visible = True End Select End Select Exit Sub ErrorState: End Sub Private Sub mnuMDIexit_Click() End End Sub Private Sub mnusetting_Click() F8setting.Show End Sub Private Sub mnuWorkStations_Click() If mnuWorkStations.Checked = False Then F0dsTramdk.Show dinhviForm mnuWorkStations.Checked = True Else F0dsTramdk.Hide mnuWorkStations.Checked = False End If End Sub Private Sub mnuAdmin_Click() f7admin.Show End Sub Private Sub mnuUser_Click() f6user.Show End Sub Private Sub mnuInfor_Click() f4infor.Show End Sub Private Sub QuyenAdmin() If Adminlogon = Then mnuAdmin.Enabled = True mnuUser.Enabled = False mnusetting.Enabled = True Else mnuAdmin.Enabled = False mnuUser.Enabled = True mnusetting.Enabled = False End If End Sub '##################################################################### 9.1.2 Form Start Giao din thit k Form: Mó lnh: Option Explicit End Sub '###################################################################### Public Sub mnuWorkStationCheck0() mnuWorkStations.Checked = False End Sub Public Sub mnuWorkStationCheck1() mnuWorkStations.Checked = True End Sub Private Sub mnuMDImain_Click() F0dsTramdk.Show dinhviForm End Sub Private Sub mnuMDIclose_Click() MDIf1.Hide ' dkmenuMDI = False Private Sub Cmdclose_Click() End End Sub Private Sub Cmdinfor_Click() f4infor.Show End Sub Private Sub Cmdlogon_Click() f5logon.Show End Sub Private Sub Command1_Click() FSetParameters.Show Form_Initialize End Sub Private Sub Form_Initialize() '%%%%%%%%%%%%%%%%%%%%%%%%%%%% 104 Khoitaogiatridau '%%%%%%%%%%%%%%%%%%%%%%%%%%%% localname = "(local)" Frame1f0.Left = (F0.Width - Frame1f0.Width) / 'auto set Frame1,2f0 at center Frame2f0.Left = (F0.Width - Frame2f0.Width) / FrameReset.Left = (F0.Width - FrameReset.Width) / 9.1.4 Form Workstations list Giao din thit k Form: ' SQLServerName = localname LoadthongsoServer F3progress0.Show FrameReset.Visible = False If StateConnect = False Then Cmdlogon.Enabled = False FrameReset.Visible = True FrameReset.Left = (F0.Width - FrameReset.Width) / End If If StateConnect Then Cmdlogon.Enabled = True ReadTimeSaoluu ReadTimeConnectServerClient SetThoidiemAutoSave SetThoidiemConnectServerClient End If End Sub ' Private Sub Form_Resize() Frame1f0.Left = (F0.Width - Frame1f0.Width) / Frame2f0.Left = (F0.Width - Frame2f0.Width) / FrameReset.Left = (F0.Width - FrameReset.Width) / End Sub 9.1.3 Form Logon Giao din thit k Form: Mó lnh: Option Explicit Private Sub Form_Activate() ReLoaddstramdk End Sub Private Sub Form_Initialize() ReLoaddstramdk MSHfgroad_Click End Sub Private Sub Form_Load() DinhdangluoiArt DinhdangluoiPark DinhdangluoiRoad MDIf1.mnuWorkStationCheck1 End Sub Private Sub Form_Unload(Cancel As Integer) MDIf1.mnuWorkStationCheck0 End Sub Private Sub Form_Resize() VitriSStab0 VitriluoiArt VitriluoiPark VitriluoiRoad End Sub Mó lnh: Option Explicit Private Sub Form_Load() Text2pass.Locked = True End Sub Private Sub Image1_Click() If XacnhanAccont(Trim(Text1user.Text), Trim(Text2pass.Text)) = True Then WriteUserLogon f5logon.Hide ' f10Location.Show F0.Hide MDIf1.Show Else Labwarning.Caption = "User name or Password is wrong Try again!" End If End Sub Private Sub Image2_Click() f5logon.Hide End Sub Private Sub Text1user_GotFocus() Labwarning.Caption = "" End Sub Private Sub Text1user_LostFocus() Text2pass.Locked = False End Sub Private Sub Text2pass_GotFocus() Labwarning.Caption = "" End Sub Private Sub Text2pass_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Image1_Click End If End Sub Public Sub VitriSStab0() SSTab0.Left = SSTab0.Width = F0dsTramdk.Width SSTab0.Top = SSTab0.Height = F0dsTramdk.Height End Sub Private Sub SSTab0_Click(PreviousTab As Integer) KindControl = SSTab0.Tab MDIf1.ChooseF123 Select Case KindControl Case Firsroad Case Firspark Case Firsart End Select MDIf1.ChooseF123 IndexBut End Sub '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' Road '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Private Sub VitriluoiRoad() MSHfgroad.Left = 100 MSHfgroad.Top = 400 MSHfgroad.Width = SSTab0.Width - 300 If SSTab0.Height > 800 Then MSHfgroad.Height = SSTab0.Height - 800 Else MSHfgroad.Height = End If End Sub Private Sub DinhdangluoiRoad() MSHfgroad.Clear MSHfgroad.Rows = MSHfgroad.Cols = MSHfgroad.TextMatrix(0, 0) = "" MSHfgroad.TextMatrix(0, 1) = "Maừ tuỷ ẹK" MSHfgroad.TextMatrix(0, 2) = "Teõn tuỷ ẹK" MSHfgroad.ColWidth(0) = 300 MSHfgroad.ColWidth(1) = 900 105 MSHfgroad.ColWidth(2) = 4000 End Sub Public Sub DanhsachTramdkRoad() ' On Error GoTo StateError Dim i As Integer, j As Integer Dim str As String i=1 str = "select * from vtramdk order by matramdk" Set rs1 = New ADODB.Recordset MSHfgroad.Rows = rs1.Open str, db, adOpenDynamic, adLockReadOnly If rs1.RecordCount Then With rs1 If Not (.BOF And EOF) Then Do Until rs1.EOF MSHfgroad.AddItem "" MSHfgroad.TextMatrix(i, 0) = "" & Fields(2).Value MSHfgroad.TextMatrix(i, 1) = "" & Fields(0).Value MSHfgroad.TextMatrix(i, 2) = "" & Fields(1).Value i=i+1 MoveNext Loop MoveFirst Else Exit Sub End If End With End If rs1.Close Exit Sub StateError: Baoloi = "Disconnect to data on Server!" & Chr(13) & Chr(10) & Baoloi 'Chr(13)la Enter, Chr(10) la ve dau dong F11StateofConnection.TextBaoloi = Baoloi End Sub Private Sub MSHfgroad_Click() ' On Error GoTo StateError If MSHfgroad.Row > Then ChontramdkRoad = MSHfgroad.Row End If 'MsgBox MSHfgroad.Row Matramdk0 = MSHfgroad.TextMatrix(ChontramdkRoad, 1) Matramdk0 = Trim(Matramdk0) F2road.Form_Activate0 Exit Sub StateError: End Sub Private Sub Firsroad() ChontramdkRoad = DanhsachTramdkRoad Matramdk0 = MSHfgroad.TextMatrix(ChontramdkRoad, 1) Matramdk0 = Trim(Matramdk0) F2road.Form_Activate0 End Sub '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%' Park '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Private Sub VitriluoiPark() MSHfgpark.Left = 100 MSHfgpark.Top = 400 MSHfgpark.Width = SSTab0.Width - 300 If SSTab0.Height > 800 Then MSHfgpark.Height = SSTab0.Height - 800 Else MSHfgpark.Height = End If End Sub Private Sub DinhdangluoiPark() MSHfgpark.Clear MSHfgpark.Rows = MSHfgpark.Cols = MSHfgpark.TextMatrix(0, 0) = "" MSHfgpark.TextMatrix(0, 1) = "Maừ tuỷ ẹK" MSHfgpark.TextMatrix(0, 2) = "Teõn tuỷ ẹK" MSHfgpark.ColWidth(0) = 300 MSHfgpark.ColWidth(1) = 900 MSHfgpark.ColWidth(2) = 4000 End Sub Private Sub DanhsachTramdkPark() ' On Error GoTo StateError Dim i As Integer, j As Integer Dim str As String i=1 str = "select * from vcvtramdk order by matramdk" Set rs1 = New ADODB.Recordset MSHfgpark.Rows = rs1.Open str, db, adOpenDynamic, adLockReadOnly If rs1.RecordCount Then With rs1 If Not (.BOF And EOF) Then Do Until rs1.EOF MSHfgpark.AddItem "" MSHfgpark.TextMatrix(i, 0) = "" & Fields(2).Value MSHfgpark.TextMatrix(i, 1) = "" & Fields(0).Value MSHfgpark.TextMatrix(i, 2) = "" & Fields(1).Value i=i+1 MoveNext Loop MoveFirst Else Exit Sub End If End With End If rs1.Close Exit Sub StateError: Baoloi = "Disconnect to data on Server!" & Chr(13) & Chr(10) & Baoloi 'Chr(13)la Enter, Chr(10) la ve dau dong F11StateofConnection.TextBaoloi = Baoloi End Sub Private Sub MSHfgPark_Click() On Error GoTo StateError If MSHfgpark.Row > Then ChontramdkPark = MSHfgpark.Row End If 'MsgBox MSHfgPark.Row Matramdk0 = MSHfgpark.TextMatrix(ChontramdkPark, 1) Matramdk0 = Trim(Matramdk0) F2park.Form_Activate0 Exit Sub StateError: End Sub Private Sub Firspark() ChontramdkPark = DanhsachTramdkPark Matramdk0 = MSHfgpark.TextMatrix(ChontramdkPark, 1) Matramdk0 = Trim(Matramdk0) F2park.Form_Activate0 End Sub '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ' Art '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Private Sub VitriluoiArt() MSHfgart.Left = 100 MSHfgart.Top = 400 MSHfgart.Width = SSTab0.Width - 300 If SSTab0.Height > 800 Then MSHfgart.Height = SSTab0.Height - 800 Else MSHfgart.Height = End If End Sub Private Sub DinhdangluoiArt() MSHfgart.Clear MSHfgart.Rows = MSHfgart.Cols = MSHfgart.TextMatrix(0, 0) = "" MSHfgart.TextMatrix(0, 1) = "Maừ tuỷ ẹK" MSHfgart.TextMatrix(0, 2) = "Teõn tuỷ ẹK" MSHfgart.ColWidth(0) = 300 MSHfgart.ColWidth(1) = 900 MSHfgart.ColWidth(2) = 4000 End Sub Private Sub DanhsachTramdkArt() ' On Error GoTo StateError Dim i As Integer, j As Integer Dim str As String i=1 str = "select * from varttramdk order by matramdk" Set rs1 = New ADODB.Recordset MSHfgart.Rows = rs1.Open str, db, adOpenDynamic, adLockReadOnly If rs1.RecordCount Then With rs1 If Not (.BOF And EOF) Then Do Until rs1.EOF MSHfgart.AddItem "" MSHfgart.TextMatrix(i, 0) = "" & Fields(2).Value MSHfgart.TextMatrix(i, 1) = "" & Fields(0).Value MSHfgart.TextMatrix(i, 2) = "" & Fields(1).Value i=i+1 MoveNext Loop MoveFirst Else 106 Exit Sub End If End With End If rs1.Close Exit Sub StateError: Baoloi = "Disconnect to data on Server!" & Chr(13) & Chr(10) & Baoloi 'Chr(13)la Enter, Chr(10) la ve dau dong F11StateofConnection.TextBaoloi = Baoloi End Sub Private Sub MSHfgArt_Click() On Error GoTo StateError If MSHfgart.Row > Then ChontramdkArt = MSHfgart.Row End If 'MsgBox MSHfgArt.Row Matramdk0 = "" & MSHfgart.TextMatrix(ChontramdkArt, 1) Matramdk0 = Trim(Matramdk0) F2art.Form_Activate0 Exit Sub StateError: End Sub Private Sub Firsart() ChontramdkArt = DanhsachTramdkArt Matramdk0 = MSHfgart.TextMatrix(ChontramdkArt, 1) Matramdk0 = Trim(Matramdk0) F2art.Form_Activate0 End Sub Private Sub ReLoaddstramdk() Select Case KindControl Case DanhsachTramdkRoad Case DanhsachTramdkPark Case DanhsachTramdkArt End Select End Sub VitriFrameS a End Sub Private Sub Timer1_Timer() ClickButRoad End Sub Private Sub CmdDown1_Click() DemClickDown ClickButRoad HideShowBut End Sub Private Sub CmdDown2_Click() DemClickDown ClickButRoad HideShowBut End Sub Private Sub CmdUp1_Click() DemClickUp ClickButRoad HideShowBut End Sub Private Sub CmdUp2_Click() DemClickUp ClickButRoad HideShowBut End Sub Private Sub Form_Activate() ClickButRoad HideShowBut End Sub Private Sub Form_Initialize() DemClickcu = DemClick = ClickButRoad End Sub Private Sub Form_Resize() VitriFrameSview VitriBut VitriFrameS ActiveHScroll End Sub 9.1.5 Form Supervise Cỏc form Supervise u tng t Cú ba form Supervise v ba i Private Sub VitriFrameSview() If F1road.Width > LabSWindow.Width Then tng: h thng ốn ng (ký hiu l LabSWindow.Left = (F1road.Width - LabSWindow.Width) / Else = 255 Road); h thng ốn cụng viờn (ký hiu EndLabSWindow.Left If FrameSview.Left = l Park); h thng ốn m thut (ký hiu FrameSview.Top = LabSWindow.Height FrameSview.Width = F1road.Width l Art) If F1road.Height > 1000 Then FrameSview.Height = F1road.Height - 1000 Form Supervise Lighting for Road Else FrameSview.Height = 1000 Giao din thit k Form: End If End Sub Mó lnh: Option Explicit Dim DemClick As Integer, DemClickcu As Integer Private Sub HScroll_Change() Dim a As Double ' MsgBox HScroll.Value a = (3 * FrameS11.Width) - FrameSview.Width a = a / HScroll.Max a = a * HScroll.Value ' MsgBox a Private Sub VitriFrameS(ByVal LeftFrame11 As Integer) Dim a As Integer a = FrameSview.Width - (3 * FrameS11.Width) a=a\3 If a < Then a = If FrameSview.Width >= (3 * FrameS11.Width) Then FrameS11.Left = a \ Else FrameS11.Left = -LeftFrame11 End If FrameS21.Left = FrameS11.Left FrameS31.Left = FrameS11.Left FrameS12.Left = FrameS11.Left + FrameS11.Width + a FrameS13.Left = FrameS12.Left + FrameS12.Width + a FrameS22.Left = FrameS12.Left FrameS23.Left = FrameS13.Left FrameS32.Left = FrameS12.Left FrameS33.Left = FrameS13.Left ' End If a = FrameSview.Height - (3 * FrameS11.Height) a=a\3 If a < Then a = FrameS11.Top = a \ FrameS12.Top = FrameS11.Top FrameS13.Top = FrameS11.Top FrameS21.Top = FrameS11.Top + FrameS11.Height + a FrameS31.Top = FrameS21.Top + FrameS21.Height + a 107 FrameS22.Top = FrameS21.Top FrameS32.Top = FrameS31.Top FrameS23.Top = FrameS21.Top FrameS33.Top = FrameS31.Top ' End If End Sub Exit Sub End If End With rs1.Close rs2.Close End Sub Private Sub VitriBut() Dim Wbut, Hbut As Integer Hbut = 255 Wbut = 615 ' CmdUp1.Left = CmdUp1.Width = Wbut CmdUp1.Top = FrameSview.Top - Hbut CmdUp1.Height = Hbut CmdUp2.Left = FrameSview.Width - Wbut CmdUp2.Width = Wbut CmdUp2.Top = FrameSview.Top - Hbut CmdUp2.Height = Hbut CmdDown1.Left = CmdDown1.Width = Wbut CmdDown1.Top = FrameSview.Height + LabSWindow.Height CmdDown1.Height = Hbut CmdDown2.Left = FrameSview.Width - Wbut CmdDown2.Width = Wbut CmdDown2.Top = FrameSview.Height + LabSWindow.Height CmdDown2.Height = Hbut ' -HScroll.Left = Wbut If FrameSview.Width > * Wbut Then HScroll.Width = FrameSview.Width - * Wbut Else HScroll.Width = Wbut End If HScroll.Top = CmdDown1.Top HScroll.Height = Hbut End Sub Public Sub LoadValueS12(ByVal Smatramdk As String) Dim a As String Dim str As String, str1 As String str1 = "select * from chedo where matramdk = '" + Smatramdk + "'" Set rs1 = New ADODB.Recordset rs1.Open str1, db, adOpenDynamic, adLockReadOnly str = "select * from viewroad where matramdk = '" + Smatramdk + "'" Set rs2 = New ADODB.Recordset rs2.Open str, db, adOpenDynamic, adLockReadOnly With rs2 If Not (.BOF And EOF) Then Lbs12matramdk.Caption = "" & Fields("matramdk").Value LbS12tentramdk.Caption = "" & Fields("tentramdk").Value a = Trim(.Fields("onoff").Value) If a = "on" Then ImageS12on.Visible = True ImageS12off.Visible = False Else ImageS12on.Visible = False ImageS12off.Visible = True End If If (Trim(.Fields("onoff").Value)) = (Trim(rs1.Fields("setonoff").Value)) Then Lb12Warning.Visible = False Else Lb12Warning.Visible = True End If If (Trim(.Fields("chedo").Value)) = (Trim(rs1.Fields("setchedo").Value)) Then Lb12Warning.Visible = False Else Lb12Warning.Visible = True End If LbS12chedo.Caption = "" & Trim(.Fields("chedo").Value) LbS12Uab.Caption = "" & Fields("Uab").Value & " V" LbS12Ubc.Caption = "" & Fields("Ubc").Value & " V" LbS12Uac.Caption = "" & Fields("Uac").Value & " V" LbS12Ua.Caption = "" & Fields("Ua").Value & " V" LbS12Ub.Caption = "" & Fields("Ub").Value & " V" LbS12Uc.Caption = "" & Fields("Uc").Value & " V" LbS12.Caption = "" & Fields("Ulv").Value & " V" LbS12Ia.Caption = "" & Fields("Ia").Value & " A" LbS12Ib.Caption = "" & Fields("Ib").Value & " A" LbS12Ic.Caption = "" & Fields("Ic").Value & " A" LbS12P.Caption = "" & Fields("P").Value & " W" LbS12Wh.Caption = "" & Fields("Wh").Value & " kWh" LbS12Cosphi.Caption = "" & Fields("cosphi").Value Else Exit Sub End If End With rs1.Close rs2.Close End Sub Private Sub ActiveHScroll() If FrameS13.Left + FrameS13.Width > FrameSview.Width Then HScroll.Visible = True Else HScroll.Visible = False End If End Sub '################################################################## Public Sub LoadValueS11(ByVal Smatramdk As String) Dim a As String Dim str As String, str1 As String str1 = "select * from chedo where matramdk = '" + Smatramdk + "'" Set rs1 = New ADODB.Recordset rs1.Open str1, db, adOpenDynamic, adLockReadOnly str = "select * from viewroad where matramdk = '" + Smatramdk + "'" Set rs2 = New ADODB.Recordset rs2.Open str, db, adOpenDynamic, adLockReadOnly With rs2 If Not (.BOF And EOF) Then Lbs11matramdk.Caption = "" & Fields("matramdk").Value LbS11tentramdk.Caption = "" & Fields("tentramdk").Value a = Trim(.Fields("onoff").Value) If a = "on" Then ImageS11on.Visible = True ImageS11off.Visible = False Else ImageS11on.Visible = False ImageS11off.Visible = True End If If (Trim(.Fields("onoff").Value)) = (Trim(rs1.Fields("setonoff").Value)) Then Lb11Warning.Visible = False Else Lb11Warning.Visible = True End If If (Trim(.Fields("chedo").Value)) = (Trim(rs1.Fields("setchedo").Value)) Then Lb11Warning.Visible = False Else Lb11Warning.Visible = True End If LbS11chedo.Caption = "" & Trim(.Fields("chedo").Value) LbS11Uab.Caption = "" & Fields("Uab").Value & " V" LbS11Ubc.Caption = "" & Fields("Ubc").Value & " V" LbS11Uac.Caption = "" & Fields("Uac").Value & " V" LbS11Ua.Caption = "" & Fields("Ua").Value & " V" LbS11Ub.Caption = "" & Fields("Ub").Value & " V" LbS11Uc.Caption = "" & Fields("Uc").Value & " V" LbS11.Caption = "" & Fields("Ulv").Value & " V" LbS11Ia.Caption = "" & Fields("Ia").Value & " A" LbS11Ib.Caption = "" & Fields("Ib").Value & " A" LbS11Ic.Caption = "" & Fields("Ic").Value & " A" LbS11P.Caption = "" & Fields("P").Value & " W" LbS11Wh.Caption = "" & Fields("Wh").Value & " kWh" LbS11Cosphi.Caption = "" & Fields("cosphi").Value Else Public Sub LoadValueS13(ByVal Smatramdk As String) Dim a As String Dim str As String, str1 As String str1 = "select * from chedo where matramdk = '" + Smatramdk + "'" Set rs1 = New ADODB.Recordset rs1.Open str1, db, adOpenDynamic, adLockReadOnly str = "select * from viewroad where matramdk = '" + Smatramdk + "'" Set rs2 = New ADODB.Recordset rs2.Open str, db, adOpenDynamic, adLockReadOnly With rs2 If Not (.BOF And EOF) Then Lbs13matramdk.Caption = "" & Fields("matramdk").Value LbS13tentramdk.Caption = "" & Fields("tentramdk").Value a = Trim(.Fields("onoff").Value) If a = "on" Then ImageS13on.Visible = True ImageS13off.Visible = False Else ImageS13on.Visible = False ImageS13off.Visible = True End If If (Trim(.Fields("onoff").Value)) = (Trim(rs1.Fields("setonoff").Value)) Then Lb13Warning.Visible = False Else Lb13Warning.Visible = True End If If (Trim(.Fields("chedo").Value)) = (Trim(rs1.Fields("setchedo").Value)) Then Lb13Warning.Visible = False Else Lb13Warning.Visible = True End If LbS13chedo.Caption = "" & Trim(.Fields("chedo").Value) LbS13Uab.Caption = "" & Fields("Uab").Value & " V" LbS13Ubc.Caption = "" & Fields("Ubc").Value & " V" 108 ImageS22off.Visible = True End If If (Trim(.Fields("onoff").Value)) = (Trim(rs1.Fields("setonoff").Value)) Then Lb22Warning.Visible = False Else Lb22Warning.Visible = True End If If (Trim(.Fields("chedo").Value)) = (Trim(rs1.Fields("setchedo").Value)) Then Lb22Warning.Visible = False Else Lb22Warning.Visible = True End If LbS22chedo.Caption = "" & Trim(.Fields("chedo").Value) LbS22Uab.Caption = "" & Fields("Uab").Value & " V" LbS22Ubc.Caption = "" & Fields("Ubc").Value & " V" LbS22Uac.Caption = "" & Fields("Uac").Value & " V" LbS22Ua.Caption = "" & Fields("Ua").Value & " V" LbS22Ub.Caption = "" & Fields("Ub").Value & " V" LbS22Uc.Caption = "" & Fields("Uc").Value & " V" LbS22.Caption = "" & Fields("Ulv").Value & " V" LbS22Ia.Caption = "" & Fields("Ia").Value & " A" LbS22Ib.Caption = "" & Fields("Ib").Value & " A" LbS22Ic.Caption = "" & Fields("Ic").Value & " A" LbS22P.Caption = "" & Fields("P").Value & " W" LbS22Wh.Caption = "" & Fields("Wh").Value & " kWh" LbS22Cosphi.Caption = "" & Fields("cosphi").Value LbS13Uac.Caption = "" & Fields("Uac").Value & " V" LbS13Ua.Caption = "" & Fields("Ua").Value & " V" LbS13Ub.Caption = "" & Fields("Ub").Value & " V" LbS13Uc.Caption = "" & Fields("Uc").Value & " V" LbS13.Caption = "" & Fields("Ulv").Value & " V" LbS13Ia.Caption = "" & Fields("Ia").Value & " A" LbS13Ib.Caption = "" & Fields("Ib").Value & " A" LbS13Ic.Caption = "" & Fields("Ic").Value & " A" LbS13P.Caption = "" & Fields("P").Value & " W" LbS13Wh.Caption = "" & Fields("Wh").Value & " kWh" LbS13Cosphi.Caption = "" & Fields("cosphi").Value Else Exit Sub End If End With rs1.Close rs2.Close End Sub Public Sub LoadValueS21(ByVal Smatramdk As String) Dim a As String Dim str As String, str1 As String str1 = "select * from chedo where matramdk = '" + Smatramdk + "'" Set rs1 = New ADODB.Recordset rs1.Open str1, db, adOpenDynamic, adLockReadOnly str = "select * from viewroad where matramdk = '" + Smatramdk + "'" Set rs2 = New ADODB.Recordset rs2.Open str, db, adOpenDynamic, adLockReadOnly With rs2 If Not (.BOF And EOF) Then Lbs21matramdk.Caption = "" & Fields("matramdk").Value LbS21tentramdk.Caption = "" & Fields("tentramdk").Value a = Trim(.Fields("onoff").Value) If a = "on" Then ImageS21on.Visible = True ImageS21off.Visible = False Else ImageS21on.Visible = False ImageS21off.Visible = True End If If (Trim(.Fields("onoff").Value)) = (Trim(rs1.Fields("setonoff").Value)) Then Lb21Warning.Visible = False Else Lb21Warning.Visible = True End If If (Trim(.Fields("chedo").Value)) = (Trim(rs1.Fields("setchedo").Value)) Then Lb21Warning.Visible = False Else Lb21Warning.Visible = True End If LbS21chedo.Caption = "" & Trim(.Fields("chedo").Value) LbS21Uab.Caption = "" & Fields("Uab").Value & " V" LbS21Ubc.Caption = "" & Fields("Ubc").Value & " V" LbS21Uac.Caption = "" & Fields("Uac").Value & " V" LbS21Ua.Caption = "" & Fields("Ua").Value & " V" LbS21Ub.Caption = "" & Fields("Ub").Value & " V" LbS21Uc.Caption = "" & Fields("Uc").Value & " V" LbS21.Caption = "" & Fields("Ulv").Value & " V" LbS21Ia.Caption = "" & Fields("Ia").Value & " A" LbS21Ib.Caption = "" & Fields("Ib").Value & " A" LbS21Ic.Caption = "" & Fields("Ic").Value & " A" LbS21P.Caption = "" & Fields("P").Value & " W" LbS21Wh.Caption = "" & Fields("Wh").Value & " kWh" LbS21Cosphi.Caption = "" & Fields("cosphi").Value Else Exit Sub End If End With rs1.Close rs2.Close End Sub Public Sub LoadValueS22(ByVal Smatramdk As String) Dim a As String Dim str As String, str1 As String str1 = "select * from chedo where matramdk = '" + Smatramdk + "'" Set rs1 = New ADODB.Recordset rs1.Open str1, db, adOpenDynamic, adLockReadOnly str = "select * from viewroad where matramdk = '" + Smatramdk + "'" Set rs2 = New ADODB.Recordset rs2.Open str, db, adOpenDynamic, adLockReadOnly With rs2 If Not (.BOF And EOF) Then Lbs22matramdk.Caption = "" & Fields("matramdk").Value LbS22tentramdk.Caption = "" & Fields("tentramdk").Value a = Trim(.Fields("onoff").Value) If a = "on" Then ImageS22on.Visible = True ImageS22off.Visible = False Else ImageS22on.Visible = False Else Exit Sub End If End With rs1.Close rs2.Close End Sub Public Sub LoadValueS23(ByVal Smatramdk As String) Dim a As String Dim str As String, str1 As String str1 = "select * from chedo where matramdk = '" + Smatramdk + "'" Set rs1 = New ADODB.Recordset rs1.Open str1, db, adOpenDynamic, adLockReadOnly str = "select * from viewroad where matramdk = '" + Smatramdk + "'" Set rs2 = New ADODB.Recordset rs2.Open str, db, adOpenDynamic, adLockReadOnly With rs2 If Not (.BOF And EOF) Then Lbs23matramdk.Caption = "" & Fields("matramdk").Value LbS23tentramdk.Caption = "" & Fields("tentramdk").Value a = Trim(.Fields("onoff").Value) If a = "on" Then ImageS23on.Visible = True ImageS23off.Visible = False Else ImageS23on.Visible = False ImageS23off.Visible = True End If If (Trim(.Fields("onoff").Value)) = (Trim(rs1.Fields("setonoff").Value)) Then Lb23Warning.Visible = False Else Lb23Warning.Visible = True End If If (Trim(.Fields("chedo").Value)) = (Trim(rs1.Fields("setchedo").Value)) Then Lb23Warning.Visible = False Else Lb23Warning.Visible = True End If LbS23chedo.Caption = "" & Trim(.Fields("chedo").Value) LbS23Uab.Caption = "" & Fields("Uab").Value & " V" LbS23Ubc.Caption = "" & Fields("Ubc").Value & " V" LbS23Uac.Caption = "" & Fields("Uac").Value & " V" LbS23Ua.Caption = "" & Fields("Ua").Value & " V" LbS23Ub.Caption = "" & Fields("Ub").Value & " V" LbS23Uc.Caption = "" & Fields("Uc").Value & " V" LbS23.Caption = "" & Fields("Ulv").Value & " V" LbS23Ia.Caption = "" & Fields("Ia").Value & " A" LbS23Ib.Caption = "" & Fields("Ib").Value & " A" LbS23Ic.Caption = "" & Fields("Ic").Value & " A" LbS23P.Caption = "" & Fields("P").Value & " W" LbS23Wh.Caption = "" & Fields("Wh").Value & " kWh" LbS23Cosphi.Caption = "" & Fields("cosphi").Value Else Exit Sub End If End With rs1.Close rs2.Close End Sub Public Sub LoadValueS31(ByVal Smatramdk As String) Dim a As String Dim str As String, str1 As String str1 = "select * from chedo where matramdk = '" + Smatramdk + "'" Set rs1 = New ADODB.Recordset rs1.Open str1, db, adOpenDynamic, adLockReadOnly str = "select * from viewroad where matramdk = '" + Smatramdk + "'" 109 Set rs2 = New ADODB.Recordset rs2.Open str, db, adOpenDynamic, adLockReadOnly With rs2 If Not (.BOF And EOF) Then Lbs31matramdk.Caption = "" & Fields("matramdk").Value LbS31tentramdk.Caption = "" & Fields("tentramdk").Value a = Trim(.Fields("onoff").Value) If a = "on" Then ImageS31on.Visible = True ImageS31off.Visible = False Else ImageS31on.Visible = False ImageS31off.Visible = True End If If (Trim(.Fields("onoff").Value)) = (Trim(rs1.Fields("setonoff").Value)) Then Lb31Warning.Visible = False Else Lb31Warning.Visible = True End If If (Trim(.Fields("chedo").Value)) = (Trim(rs1.Fields("setchedo").Value)) Then Lb31Warning.Visible = False Else Lb31Warning.Visible = True End If LbS31chedo.Caption = "" & Trim(.Fields("chedo").Value) LbS31Uab.Caption = "" & Fields("Uab").Value & " V" LbS31Ubc.Caption = "" & Fields("Ubc").Value & " V" LbS31Uac.Caption = "" & Fields("Uac").Value & " V" LbS31Ua.Caption = "" & Fields("Ua").Value & " V" LbS31Ub.Caption = "" & Fields("Ub").Value & " V" LbS31Uc.Caption = "" & Fields("Uc").Value & " V" LbS31.Caption = "" & Fields("Ulv").Value & " V" LbS31Ia.Caption = "" & Fields("Ia").Value & " A" LbS31Ib.Caption = "" & Fields("Ib").Value & " A" LbS31Ic.Caption = "" & Fields("Ic").Value & " A" LbS31P.Caption = "" & Fields("P").Value & " W" LbS31Wh.Caption = "" & Fields("Wh").Value & " kWh" LbS31Cosphi.Caption = "" & Fields("cosphi").Value Else Exit Sub End If End With rs1.Close rs2.Close End Sub Public Sub LoadValueS32(ByVal Smatramdk As String) Dim a As String Dim str As String, str1 As String str1 = "select * from chedo where matramdk = '" + Smatramdk + "'" Set rs1 = New ADODB.Recordset rs1.Open str1, db, adOpenDynamic, adLockReadOnly str = "select * from viewroad where matramdk = '" + Smatramdk + "'" Set rs2 = New ADODB.Recordset rs2.Open str, db, adOpenDynamic, adLockReadOnly With rs2 If Not (.BOF And EOF) Then Lbs32matramdk.Caption = "" & Fields("matramdk").Value LbS32tentramdk.Caption = "" & Fields("tentramdk").Value a = Trim(.Fields("onoff").Value) If a = "on" Then ImageS32on.Visible = True ImageS32off.Visible = False Else ImageS32on.Visible = False ImageS32off.Visible = True End If If (Trim(.Fields("onoff").Value)) = (Trim(rs1.Fields("setonoff").Value)) Then Lb32Warning.Visible = False Else Lb32Warning.Visible = True End If If (Trim(.Fields("chedo").Value)) = (Trim(rs1.Fields("setchedo").Value)) Then Lb32Warning.Visible = False Else Lb32Warning.Visible = True End If LbS32chedo.Caption = "" & Trim(.Fields("chedo").Value) LbS32Uab.Caption = "" & Fields("Uab").Value & " V" LbS32Ubc.Caption = "" & Fields("Ubc").Value & " V" LbS32Uac.Caption = "" & Fields("Uac").Value & " V" LbS32Ua.Caption = "" & Fields("Ua").Value & " V" LbS32Ub.Caption = "" & Fields("Ub").Value & " V" LbS32Uc.Caption = "" & Fields("Uc").Value & " V" LbS32.Caption = "" & Fields("Ulv").Value & " V" LbS32Ia.Caption = "" & Fields("Ia").Value & " A" LbS32Ib.Caption = "" & Fields("Ib").Value & " A" LbS32Ic.Caption = "" & Fields("Ic").Value & " A" LbS32P.Caption = "" & Fields("P").Value & " W" LbS32Wh.Caption = "" & Fields("Wh").Value & " kWh" LbS32Cosphi.Caption = "" & Fields("cosphi").Value Else Exit Sub End If End With rs1.Close rs2.Close End Sub Public Sub LoadValueS33(ByVal Smatramdk As String) Dim a As String Dim str As String, str1 As String str1 = "select * from chedo where matramdk = '" + Smatramdk + "'" Set rs1 = New ADODB.Recordset rs1.Open str1, db, adOpenDynamic, adLockReadOnly str = "select * from viewroad where matramdk = '" + Smatramdk + "'" Set rs2 = New ADODB.Recordset rs2.Open str, db, adOpenDynamic, adLockReadOnly With rs2 If Not (.BOF And EOF) Then Lbs33matramdk.Caption = "" & Fields("matramdk").Value LbS33tentramdk.Caption = "" & Fields("tentramdk").Value a = Trim(.Fields("onoff").Value) If a = "on" Then ImageS33on.Visible = True ImageS33off.Visible = False Else ImageS33on.Visible = False ImageS33off.Visible = True End If If (Trim(.Fields("onoff").Value)) = (Trim(rs1.Fields("setonoff").Value)) Then Lb33Warning.Visible = False Else Lb33Warning.Visible = True End If If (Trim(.Fields("chedo").Value)) = (Trim(rs1.Fields("setchedo").Value)) Then Lb33Warning.Visible = False Else Lb33Warning.Visible = True End If LbS33chedo.Caption = "" & Trim(.Fields("chedo").Value) LbS33Uab.Caption = "" & Fields("Uab").Value & " V" LbS33Ubc.Caption = "" & Fields("Ubc").Value & " V" LbS33Uac.Caption = "" & Fields("Uac").Value & " V" LbS33Ua.Caption = "" & Fields("Ua").Value & " V" LbS33Ub.Caption = "" & Fields("Ub").Value & " V" LbS33Uc.Caption = "" & Fields("Uc").Value & " V" LbS33.Caption = "" & Fields("Ulv").Value & " V" LbS33Ia.Caption = "" & Fields("Ia").Value & " A" LbS33Ib.Caption = "" & Fields("Ib").Value & " A" LbS33Ic.Caption = "" & Fields("Ic").Value & " A" LbS33P.Caption = "" & Fields("P").Value & " W" LbS33Wh.Caption = "" & Fields("Wh").Value & " kWh" LbS33Cosphi.Caption = "" & Fields("cosphi").Value Else Exit Sub End If End With rs1.Close rs2.Close End Sub '############################################################## Private Sub DemClickDown() Dim a As Double a = DemRecord("viewroad") 'MsgBox "DemRecord = " & a a=a/9 DemClickcu = DemClick If DemClick < a Then DemClick = DemClick + End If 'MsgBox DemClick End Sub Private Sub DemClickUp() DemClickcu = DemClick If DemClick > Then DemClick = DemClick - End If ' MsgBox DemClick End Sub Private Sub HideShowBut() Dim a As Double a = DemRecord("viewroad") a=a/9 If DemClick < a Then CmdDown1.Visible = True CmdDown2.Visible = True Else CmdDown1.Visible = False CmdDown2.Visible = False End If If DemClick > Then CmdUp1.Visible = True CmdUp2.Visible = True Else CmdUp1.Visible = False 110 CmdUp2.Visible = False End If End Sub LbTentramdk.Caption = "" & rs.Fields(1).Value 9.1.6 Form Control Cỏc form Control u tng t Cú ba form Control v ba i tng: h thng ốn ng (ký hiu l Road); h thng ốn cụng viờn (ký hiu l Park); h thng ốn m thut (ký hiu l Art) Form Control Lighting for Road Giao din thit k Form: Mó lnh: Option Explicit Private Sub Command1_Click() SaveValueDK SaveValueTextDK SaveValueUlv LoadValueDK End Sub Private Sub Form_Resize() Vitritext End Sub Public Sub Form_Activate0() LoadValueDK LoadValuechoCheckmoi LoadValueTextmoi End Sub Private Sub Vitritext() If F2road.Width > LbControlwindow.Width Then LbControlwindow.Left = (F1road.Width - LbControlwindow.Width) / Else LbControlwindow.Left = End If If F2road.Width > (Frame1.Width + * Command1.Width) Then Frame1.Left = (F1road.Width - Frame1.Width) / ElseIf F2road.Width > (Frame1.Width + 1.5 * Command1.Width) Then Frame1.Left = (F1road.Width - Frame1.Width + 1.5 * Command1.Width) / Else Frame1.Left = 1.5 * Command1.Width End If Frame2.Left = Frame1.Left Command1.Left = Frame1.Left - 1.5 * Command1.Width Label17.Left = Command1.Left LbMatramdk.Top = Frame1.Top - LbMatramdk.Height LbMatramdk.Left = Frame1.Left LbTentramdk.Top = LbMatramdk.Top LbTentramdk.Left = LbMatramdk.Left + LbMatramdk.Width If LbMatramdk.Top > LbControlwindow.Height Then LbControlwindow.Visible = True Else LbControlwindow.Visible = False End If End Sub Public Sub LoadValueDK() ' On Error GoTo StateError Dim i As Integer Dim str As String, a As String i=1 str = "select * from vchedo where matramdk = '" + Matramdk0 + "'" Set rs = New ADODB.Recordset rs.Open str, db, adOpenDynamic, adLockReadOnly If Not rs.EOF Then LbMatramdk.Caption = "" & rs.Fields(0).Value i = rs.Fields(2).Value Checkcu0.Value = Abs(i) i = rs.Fields(4).Value Checkcu30.Value = Abs(i) i = rs.Fields(6).Value Checkcu50.Value = Abs(i) i = rs.Fields(8).Value Checkcu70.Value = Abs(i) i = rs.Fields(10).Value Checkcu100.Value = Abs(i) a = Format(Trim(rs.Fields(3).Value), "dd/mm/yyyy hh:mm:ss") Lb0.Caption = "" & Mid(a, 12, 5) a = Format(Trim(rs.Fields(5).Value), "dd/mm/yyyy hh:mm:ss") Lb30.Caption = "" & Mid(a, 12, 5) a = Format(Trim(rs.Fields(7).Value), "dd/mm/yyyy hh:mm:ss") Lb50.Caption = "" & Mid(a, 12, 5) a = Format(Trim(rs.Fields(9).Value), "dd/mm/yyyy hh:mm:ss") Lb70.Caption = "" & Mid(a, 12, 5) a = Format(Trim(rs.Fields(11).Value), "dd/mm/yyyy hh:mm:ss") Lb100.Caption = "" & Mid(a, 12, 5) Else MsgBox "No data!", vbExclamation, "Warning!" End If rs.Close ' str = "select * from datUlv where matramdk = '" + Matramdk0 + "'" Set rs = New ADODB.Recordset rs.Open str, db, adOpenDynamic, adLockReadOnly If Not rs.EOF Then LbUlvcu.Caption = "" & rs.Fields("Ulv").Value TextUlv = "" & rs.Fields("Ulv").Value Else MsgBox "No data!", vbExclamation, "Warning!" End If rs.Close Exit Sub StateError: Baoloi = "Disconnect to data on Server!" & Chr(13) & Chr(10) & Baoloi 'Chr(13)la Enter, Chr(10) la ve dau dong F11StateofConnection.TextBaoloi = Baoloi End Sub Private Sub SaveValueDK() ' On Error GoTo StateError Dim i As Integer Dim str As String i = Checkmoi0.Value str = "update chedo Set on0 =" & i & " where matramdk = '" + Trim(Matramdk0) + "'" db.Execute str i = Checkmoi30.Value str = "update chedo Set on30 =" & i & " where matramdk = '" + Trim(Matramdk0) + "'" db.Execute str i = Checkmoi50.Value str = "update chedo Set on50 =" & i & " where matramdk = '" + Trim(Matramdk0) + "'" db.Execute str i = Checkmoi70.Value str = "update chedo Set on70 =" & i & " where matramdk = '" + Trim(Matramdk0) + "'" db.Execute str i = Checkmoi100.Value str = "update chedo Set on100 =" & i & " where matramdk = '" + Trim(Matramdk0) + "'" db.Execute str Exit Sub StateError: Baoloi = "Disconnect to data on Server!" & Chr(13) & Chr(10) & Baoloi 'Chr(13)la Enter, Chr(10) la ve dau dong F11StateofConnection.TextBaoloi = Baoloi End Sub Private Sub SaveValueTextDK() ' On Error GoTo StateError Dim str As String, a As String, b As String a = Now() a = Mid(a, 1, 11) b = a & Lenght2(Text0h) & ":" & Lenght2(Text0ph) & ":00" str = "update chedo Set giobat0 ='" & Format$(b, "mm/dd/yyyy hh:mm:ss") & "' where matramdk = '" + Matramdk0 + "'" db.Execute str b = a & Lenght2(Text30h) & ":" & Lenght2(Text30ph) & ":00" str = "update chedo Set giobat30 ='" & Format$(b, "mm/dd/yyyy hh:mm:ss") & "' where matramdk = '" + Matramdk0 + "'" db.Execute str b = a & Lenght2(Text50h) & ":" & Lenght2(Text50ph) & ":00" str = "update chedo Set giobat50 ='" & Format$(b, "mm/dd/yyyy hh:mm:ss") & "' where matramdk = '" + Matramdk0 + "'" db.Execute str b = a & Lenght2(Text70h) & ":" & Lenght2(Text70ph) & ":00" str = "update chedo Set giobat70 ='" & Format$(b, "mm/dd/yyyy hh:mm:ss") & "' where matramdk = '" + Matramdk0 + "'" db.Execute str b = a & Lenght2(Text100h) & ":" & Lenght2(Text100ph) & ":00" 111 str = "update chedo Set giobat100 ='" & Format$(b, "mm/dd/yyyy hh:mm:ss") & "' where matramdk = '" + Matramdk0 + "'" db.Execute str Exit Sub StateError: Baoloi = "Disconnect to data on Server!" & Chr(13) & Chr(10) & Baoloi 'Chr(13)la Enter, Chr(10) la ve dau dong F11StateofConnection.TextBaoloi = Baoloi End Sub LoadValueTextmoi Exit Sub End If If i < Then MsgBox "Please, try again!", vbExclamation, "Warning!" LoadValueTextmoi Exit Sub End If Exit Sub ErrorState: MsgBox "Please, try again!", vbExclamation, "Warning!" LoadValueTextmoi End Sub Private Sub SaveValueUlv() ' On Error GoTo StateError Dim str As String, a As Integer a = CInt(TextUlv) str = "update datUlv Set Ulv ='" & a & "' where matramdk = '" + Matramdk0 + "'" db.Execute str a = 160 str = "update datUlv Set Umin ='" & a & "' where matramdk = '" + Matramdk0 + "'" db.Execute str a = 225 str = "update datUlv Set Umax ='" & a & "' where matramdk = '" + Matramdk0 + "'" db.Execute str Exit Sub StateError: Baoloi = "Disconnect to data on Server!" & Chr(13) & Chr(10) & Baoloi 'Chr(13)la Enter, Chr(10) la ve dau dong F11StateofConnection.TextBaoloi = Baoloi End Sub Private Sub KtraText30h() ' On Error GoTo ErrorState Dim a As String, i As Integer a = Trim(Text30h) i = CInt(a) If i > 23 Then MsgBox "Please, try again!", vbExclamation, "Warning!" LoadValueTextmoi Exit Sub End If If i < Then MsgBox "Please, try again!", vbExclamation, "Warning!" LoadValueTextmoi Exit Sub End If Exit Sub ErrorState: MsgBox "Please, try again!", vbExclamation, "Warning!" LoadValueTextmoi End Sub Private Function Lenght2(ByVal abc As String) As String If Len(abc) < Then Lenght2 = "0" & abc Else Lenght2 = abc End If End Function Private Sub LoadValuechoCheckmoi() Checkmoi0.Value = Checkcu0.Value Checkmoi30.Value = Checkcu30.Value Checkmoi50.Value = Checkcu50.Value Checkmoi70.Value = Checkcu70.Value Checkmoi100.Value = Checkcu100.Value End Sub Private Sub LoadValueTextmoi() ' On Error GoTo StateError Dim str As String, a As String str = "select * from vchedo where matramdk = '" + Matramdk0 + "'" Set rs = New ADODB.Recordset rs.Open str, db, adOpenDynamic, adLockReadOnly If Not rs.EOF Then LbMatramdk.Caption = "" & rs.Fields(0).Value LbTentramdk.Caption = "" & rs.Fields(1).Value a = Format(Trim(rs.Fields(3).Value), "dd/mm/yyyy hh:mm:ss") Text0h = "" & Mid(a, 12, 2) a = Format(Trim(rs.Fields(5).Value), "dd/mm/yyyy hh:mm:ss") Text30h = "" & Mid(a, 12, 2) a = Format(Trim(rs.Fields(7).Value), "dd/mm/yyyy hh:mm:ss") Text50h = "" & Mid(a, 12, 2) a = Format(Trim(rs.Fields(9).Value), "dd/mm/yyyy hh:mm:ss") Text70h = "" & Mid(a, 12, 2) a = Format(Trim(rs.Fields(11).Value), "dd/mm/yyyy hh:mm:ss") Text100h = "" & Mid(a, 12, 2) '========================================================== a = Format(Trim(rs.Fields(3).Value), "dd/mm/yyyy hh:mm:ss") Text0ph = "" & Mid(a, 15, 2) a = Format(Trim(rs.Fields(5).Value), "dd/mm/yyyy hh:mm:ss") Text30ph = "" & Mid(a, 15, 2) a = Format(Trim(rs.Fields(7).Value), "dd/mm/yyyy hh:mm:ss") Text50ph = "" & Mid(a, 15, 2) a = Format(Trim(rs.Fields(9).Value), "dd/mm/yyyy hh:mm:ss") Text70ph = "" & Mid(a, 15, 2) a = Format(Trim(rs.Fields(11).Value), "dd/mm/yyyy hh:mm:ss") Text100ph = "" & Mid(a, 15, 2) Else MsgBox "No data!", vbExclamation, "Warning!" End If rs.Close Exit Sub StateError: Baoloi = "Disconnect to data on Server!" & Chr(13) & Chr(10) & Baoloi 'Chr(13)la Enter, Chr(10) la ve dau dong F11StateofConnection.TextBaoloi = Baoloi End Sub '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Private Sub KtraText0h() ' On Error GoTo ErrorState Dim a As String, i As Integer a = Trim(Text0h) i = CInt(a) If i > 23 Then MsgBox "Please, try again!", vbExclamation, "Warning!" Private Sub KtraText50h() ' On Error GoTo ErrorState Dim a As String, i As Integer a = Trim(Text50h) i = CInt(a) If i > 23 Then MsgBox "Please, try again!", vbExclamation, "Warning!" LoadValueTextmoi Exit Sub End If If i < Then MsgBox "Please, try again!", vbExclamation, "Warning!" LoadValueTextmoi Exit Sub End If Exit Sub ErrorState: MsgBox "Please, try again!", vbExclamation, "Warning!" LoadValueTextmoi End Sub Private Sub KtraText70h() ' On Error GoTo ErrorState Dim a As String, i As Integer a = Trim(Text70h) i = CInt(a) If i > 23 Then MsgBox "Please, try again!", vbExclamation, "Warning!" LoadValueTextmoi Exit Sub End If If i < Then MsgBox "Please, try again!", vbExclamation, "Warning!" LoadValueTextmoi Exit Sub End If Exit Sub ErrorState: MsgBox "Please, try again!", vbExclamation, "Warning!" LoadValueTextmoi End Sub 112 ... PHÁP CÔNG NGHỆ CHO ĐIỀU KHIỂN VÀ GIÁM SÁT HỆ THỐNG CHIẾU SÁNG CÔNG CỘNG 41 2.1 Một số giải pháp điều khiển giám sát hệ thống chiếu sáng theo công nghệ đại 41 2.1.1 Điều khiển giám sát. .. hình điều khiển giám sát hệ thống chiếu sáng theo khu vực ứng dụng công nghệ GSM/GPRS 61 Hình - 12: Mô hình điều khiển giám sát hệ thống chiếu sáng theo điểm sáng ứng dụng công nghệ GSM/GPRS... tiến có để ứng dụng vào điều khiển giám sát hệ thống chiếu sáng công cộng Từ sở trên, tác giả xây dựng giải pháp công nghệ cho việc điều khiển giám sát hệ thống chiếu sáng công cộng Căn vào tình

Ngày đăng: 19/07/2017, 22:53

Từ khóa liên quan

Mục lục

  • TRANG BÌA

  • LỜI CAM ĐOAN

  • MỤC LỤC

  • DANH MỤC CÁC KÝ HIỆU VÀ CHỮ VIẾT TẮT

  • DANH MỤC CÁC BẢNG

  • DANH MỤC CÁC HÌNH VẼ VÀ ĐỒ THỊ

  • MỞ ĐẦU

  • Chương I

  • Chương II

  • Chương III

  • KẾT QUẢ VÀ BÀN LUẬN

  • KẾT LUẬN VÀ KIẾN NGHỊ

  • TÀI LIỆU THAM KHẢO

  • DANH MỤC CÁC PHỤ LỤC

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

Tài liệu liên quan