1. Trang chủ
  2. » Luận Văn - Báo Cáo

Xây dựng phần mềm điều khiển hệ thống thuỷ nông tiếp cận hiện đại hoá

179 0 0

Đ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

Mục lục Mục lục ........................................................................................................................ 3 Chương 1. Tổng quan ...................................................................................................4 I. Thông tin chung.....................................................................................................4 II. Nội dung khoa học và công nghệ của đề tài .......................................................... 4 Chương 2. Thu thập tài liệu .......................................................................................... 7 Chương 3. Tài liệu về các công nghệ sử dụng ............................................................... 8 Chương 4. Phân tích yêu cầu và thiết kế cơ sở dữ liệu...................................................9 I. Phân tích yêu cầu người sử dụng............................................................................9 II. Thiết kế Cơ sở dữ liệu ........................................................................................ 10 Chương 5. Xây dựng phần mềm quản lý và điều khiển ............................................... 11 I. Module phần mềm quản lý thông tin trên bản đồ số và điều khiển qua kết nối Internet.................................................................................................................... 11 II. Module truyền hình ảnh từ camera qua mạng Internet......................................... 11 III. Module kết nối với thiết bị ngoại vi và điều khiển qua Internet......................... 11 IV. Module giám sát, điều khiển thiết bị qua mạng điện thoại dựa trên giao tiếp giọng nói........................................................................................................................... 12 V. Module giám sát, điều khiển thiết bị qua mạng điện thoại dựa trên giao tiếp tin nhắn SMS................................................................................................................ 12 Chương 6. Cài đặt, chạy thử nghiệm và hiệu chỉnh phần mềm .................................... 13 I. Tăng cường tính bảo mật của module quản lý, giám sát, điều khiển qua Internet .. 13 II. Quản lý nhiều camera......................................................................................... 13 III. Quản lý các file hồ sơ........................................................................................ 13 IV. Thêm nội dung thời gian trong tin nhắn phản hồi về.......................................... 14 Chương 7. Tài liệu hướng dẫn sử dụng ....................................................................... 15 I. Hướng dẫn cài đặt và thiết lập hệ thống ............................................................... 15 II. Hướng dẫn sử dụng chức năng quản lý, giám sát, điều khiển qua Internet........... 15 III. Hướng dẫn sử dụng chức năng giám sát, điều khiển qua mạng điện thoại .......... 15 Kết luận...................................................................................................................... 16

BỘ NÔNG NGHIỆP VÀ PHÁT TRIỂN NÔNG THÔN TRƯỜNG ĐẠI HỌC THUỶ LỢI BÁO CÁO ĐỀ TÀI NGHIÊN CỨU KHOA HỌC VÀ PHÁT TRIỂN CÔNG NGHỆ Xây dựng phần mềm điều khiển hệ thống thuỷ nông tiếp cận đại hoá Chủ nhiệm đề tài: ThS Đỗ Văn Hải HÀ NỘI - 2009 Mục lục Mục lục Chương Tổng quan I Thông tin chung II Nội dung khoa học công nghệ đề tài Chương Thu thập tài liệu Chương Tài liệu công nghệ sử dụng Chương Phân tích yêu cầu thiết kế sở liệu I Phân tích yêu cầu người sử dụng II Thiết kế Cơ sở liệu 10 Chương Xây dựng phần mềm quản lý điều khiển 11 I Module phần mềm quản lý thông tin đồ số điều khiển qua kết nối Internet 11 II Module truyền hình ảnh từ camera qua mạng Internet 11 III Module kết nối với thiết bị ngoại vi điều khiển qua Internet 11 IV Module giám sát, điều khiển thiết bị qua mạng điện thoại dựa giao tiếp giọng nói 12 V Module giám sát, điều khiển thiết bị qua mạng điện thoại dựa giao tiếp tin nhắn SMS 12 Chương Cài đặt, chạy thử nghiệm hiệu chỉnh phần mềm 13 I Tăng cường tính bảo mật module quản lý, giám sát, điều khiển qua Internet 13 II Quản lý nhiều camera 13 III Quản lý file hồ sơ 13 IV Thêm nội dung thời gian tin nhắn phản hồi 14 Chương Tài liệu hướng dẫn sử dụng 15 I Hướng dẫn cài đặt thiết lập hệ thống 15 II Hướng dẫn sử dụng chức quản lý, giám sát, điều khiển qua Internet 15 III Hướng dẫn sử dụng chức giám sát, điều khiển qua mạng điện thoại 15 Kết luận 16 Chương Tổng quan I Thông tin chung Tên đề tài: Xây dựng phần mềm điều khiển hệ thống thuỷ nông tiếp cận đại hoá Chủ nhiệm đề tài: ThS Đỗ Văn Hải Đơn vị cơng tác: Bộ mơn Kỹ thuật máy tính - Trường Đại học Thuỷ Lợi Kinh phí đề tài: 60 triệu đồng từ Ngân sách nghiệp khoa học Thời gian thực hiện: từ 06-2008 đến 12-2008 II Nội dung khoa học công nghệ đề tài Mục tiêu đề tài Đề xuất xây dựng phần mềm quản lý, giám sát, điều khiển hệ thống thuỷ nông từ xa qua mạng Internet, mạng điện thoại cố định, di động để nắm bắt, thu thập thông tin hệ thống đề xuất giải pháp quản lý hiệu tiếp cận đại hoá Tình hình nghiên cứu ngồi nước a Ngồi nước Việc tự động hố cơng tác vận hành cơng trình thuỷ nơng nước ngồi thực phổ biến đem lại nhiều lợi ích thiết thực cho xã hội Giải pháp mà hãng nước đưa giải pháp tổng thể phần cứng, phần mềm cho toàn hệ thống Do đó, chi phí đầu tư ban đầu lớn Điều không phù hợp với điều kiện thực tế nước ta đặc biệt cơng trình có quy mơ vừa nhỏ Mặt khác, giải pháp nước thường giải pháp đóng, khó mở rộng, thay khơng có hỗ trợ phía nhà cung cấp hệ thống b Trong nước Hiện Việt Nam có hàng nghìn hệ thống thuỷ nông lớn nhỏ làm nhiệm vụ cấp nước cho tưới cho nhu cầu dân sinh, nông nghiệp, công nghiệp góp phần quan trọng việc nâng cao hiệu kinh tế xã hội Tuy nhiên hầu hết hệ thống chủ yếu quản lý chỗ theo phương thức thủ công phần tự động hoá Đây nguyên nhân làm hạn chế hiệu cấp nước hệ thống thuỷ nông Người quản lý trực tiếp quan quản lý cấp khó thu thập thông tin trực tiếp từ hệ thống từ xa thời điểm Điều dẫn đến người quản lý nắm bắt thông tin điều khiển tức thời hệ thống cần thiết (không phụ thuộc thời gian khơng gian) Vì vậy, việc nghiên cứu xây dựng phần mềm giám sát, điều khiển từ xa giúp cho nhà quản lý cập nhật thông tin hệ thống thuỷ nông thời gian địa điểm thông qua hệ thống Internet mạng điện thoại công cộng cách an tồn hiệu Từ đó, có giải pháp thích hợp việc điều khiển hệ thống đáp ứng yêu cầu cấp nước hiệu sở thông tin hệ thống thu nhận từ xa Hiện Việt Nam hệ thống điều khiển chủ yếu chỗ Có số hệ thống thủy nơng vấn đề thu thập, điều khiển thực phòng điều khiển trung tâm như: hệ thống thuỷ lợi Dầu Tiếng Tây Ninh, hệ thống thuỷ nơng Đan Hồi Hà Tây Tuy nhiên để làm điều cần kinh phí đầu tư lớn, khó áp dụng cho hệ thống thuỷ nơng vừa nhỏ Có thể liệt kê số đề tài thực liên quan đến lĩnh vực đề tài cấp Bộ “Từng bước đại hố cơng tác quản lý hệ thống thuỷ lợi Ấp Bắc, Nam hồng, Đông Anh, Hà nội” Trung tâm Công nghệ phần mềm Thuỷ lợi, Viện Khoa học Thuỷ lợi thực từ năm 2001 đến năm 2003 Đề tài xây dựng phần mềm điều hành, quản lý hệ thống thuỷ nông, chế tạo thành công vi xử lý RTU thay cho PLC, 70% giá nhập ngoại Việc kết nối đến thiết bị từ xa thực cách dùng máy tính quay số qua modem Đề tài “Nghiên cứu giải pháp công nghệ, thiết bị hệ thống thủy lợi nhằm phân phối số lượng nước hiệu cao” Viện Khoa học Thuỷ lợi miền Nam thực từ năm 2006 đến năm 2008 Đề tài nghiên cứu ứng dụng cơng nghệ SCADA cơng trình đo nước vào cơng trình tiêu biểu hệ thống thủy nơng Củ Chi, hồ Dầu Tiếng Việc kết nối từ xa đến hệ thống thực theo cách quay số qua modem hữu tuyến modem vô tuyến Đánh giá so sánh Các hệ thống nêu cịn có số hạn chế sau: - Giá thành đầu tư thiết bị lớn, chủ yếu nhập ngoại - Chưa giám sát camera từ xa - Việc thu nhận liệu từ xa chủ yếu dùng máy tính quay số điện thoại qua modem, tốc độ chậm khơng thuận tiện Giải pháp mà đưa nhằm loại bỏ phần nhược điểm trên: - Tích hợp cơng nghệ GIS cho phép người quản lý giám sát cơng trình phạm vi rộng cách dễ dàng thông qua đồ số - Hệ thống cho phép giám sát hình ảnh từ xa sử dụng mạng Internet thông qua camera - Cho phép nhiều phương thức kết nối đến hệ thống, người sử dụng dùng thiết bị đầu cuối sau tương tác với hệ thống từ xa: - Máy tính nối mạng Internet: Với phương pháp kết nối người dùng quan sát trực quan vị trí cơng trình đồ số xem thơng tin chi tiết tức thời cơng trình thời điểm Ngồi người dùng cịn xem hình ảnh trực tiếp cơng trình thơng qua camera phân quyền, người dùng điều khiển thiết bị từ xa thông qua vài cú nhấp chuột đơn giản - Điện thoại (cố định, di động) thơng qua giao tiếp giọng nói: Với điện thoại người dùng gọi điện đến hệ thống làm theo hướng dẫn, hệ thống trả lời tự động trả lời thơng tin mà người dùng u cầu tình hình thiết bị cơng trình, ngồi người dùng điều khiển thiết bị từ xa thơng qua bàn phím điện thoại - Điện thoại di động sử dụng tin nhắn – SMS: Với phương pháp người sử dụng cần điện thoại có chức gửi, nhận tin nhắn tương tác với hệ thống Người sử dụng gửi tin nhắn theo cú pháp định, hệ thống trả lời cách chi tiết tình hình thiết bị cơng trình có quyền, người sử dụng điều khiển thiết bị thơng qua tin nhắn SMS Tóm lại: giải pháp mà đề xuất không tập trung vào phần cứng mà tập trung chủ yếu vào giải pháp phần mềm giúp cho người sử dụng tương tác với hệ thống từ xa nhiều phương thức khác điều làm cho việc tiếp cận, giám sát hệ thống cách thuận tiện đơn giản Chương Thu thập tài liệu Chúng tiến hành thu thập tài liệu thông số kỹ thuật số cơng trình đầu mối cống trạm bơm tiêu biểu địa phận Hà Nội gồm: trạm bơm Đan Hồi, trạm bơm Vân Đình, trạm bơm n Sở, cống Liên Mạc - Trạm bơm Đan Hoài xây dựng từ năm 1961 năm 1962 cơng trình đưa vào phục vụ sản xuất Trạm bơm đầu mồi có nhiệm vụ lấy nước từ sơng Hồng cấp nước tưới cho hệ thống - Trạm bơm Vân Đình có nhiệm vụ nhiệm vụ tưới tiêu o Tiêu: Tổng diện tích 13466ha thuộc ba huyện: Thanh Oai, Ứng Hồ, Phú Xuyên - TP Hà Nội o Tưới: Cho 2500ha - 3000ha vùng ven đáy huyện Ứng Hoà o Ngồi trạm bơm Vân Đình có nhiệm vụ bơm cắt lũ cho sơng Nhuệ bơm tiêu nước cho TP Hà Nội - Trạm bơm Yên Sở thiết kế để hút nước từ sông Lừ , Sét , Tô Lịch, Kim Ngưu sông Hồng gồm 11 tổ máy bơm Công suất tổng cộng 45m3/s - Cống Liên Mạc 1: Được xây dựng từ năm 1938 đến năm 1941 có nhiệm vụ tưới vận tải phục vụ cho địa phương: Hà Nội, Hà Nam Sau thực tế số cơng trình thuỷ nông, nhận thấy việc giám sát điều hành hệ thống thuỷ nơng từ xa cịn gặp nhiều khó khăn Các quan quản lý cơng trình thuỷ thơng mong muốn tiếp cận, nắm bắt tình hình hệ thống cách trực quan lúc nơi để có đưa định điều hành kịp thời, xác nâng cao hiệu sử dụng công trình Giải pháp chúng tơi đưa là: - Tích hợp cơng nghệ GIS cho phép người quản lý giám sát cơng trình phạm vi rộng cách dễ dàng thông qua đồ số - Hệ thống cho phép giám sát hình ảnh từ xa sử dụng mạng Internet thơng qua camera đặt cơng trình - Cho phép nhiều phương thức kết nối đến hệ thống, người sử dụng dùng thiết bị đầu cuối sau tương tác với hệ thống từ xa: qua máy tính nối mạng Internet, qua điện thoại cố định qua điện thoại di động Chúng tin việc thực thành công đề tài giúp đơn vị quản lý công trình thuỷ nơng có thêm cơng cụ hữu hiệu để điều hành hệ thống cách thuận tiện Chương Tài liệu công nghệ sử dụng Trong chương giới thiệu cơng nghệ sử dụng để xây dựng phần mềm gồm: - Hệ thống thông tin địa lý (GIS): GIS - Geographic Information System hình thành từ ba khái niệm địa lý, thông tin hệ thống Khái niệm “địa lý” liên quan đến đặc trưng khơng gian, vị trí Các đặc trưng ánh xạ trực tiếp đến đối tượng khơng gian Chúng vật lý, văn hố, kinh tế,… tự nhiên Mục đích phần nghiên cứu ứng dụng GIS vào việc quản lý, giám sát cơng trình thuỷ nơng - Kỹ thuật lập trình giao tiếp với điện thoại cố định, điện thoại di động: o Mục đích phần nghiên cứu cách thức nối ghép điện thoại di động máy tính để nhận gửi tin nhắn SMS o Mục đích phần tìm hiểu cách thức xây dựng tổng đài trả lời tự động thơng số hệ thống (tình trạng máy bơm) giọng nói thơng qua đường dây điện thoại - Kỹ thuật lập trình giao tiếp với thiết bị ngoại vi: mục đích nghiên cứu tìm hiểu cách thức điều khiển thiết bị máy tính Chương Phân tích yêu cầu thiết kế sở liệu I Phân tích yêu cầu người sử dụng Việc quản lý thông tin cơng trình đồ số chúng tơi tiến hành với cơng trình cống trạm bơm bảy tuyến đê Hà Nội (cũ) Mỗi cơng trình cống trạm bơm phải thuộc tuyến đê bảy tuyến: Hữu Hồng, Tả Hồng, Hữu Đuống, Tả Đuống, Hữu Cà Lồ, Tả Cà Lồ, Hữu Cầu Và thuộc đội quản lý: Đơng Anh, Gia Lâm, Long Biên, Nội Thành, Sóc Sơn, Thanh Trì Từ Liêm Ngồi việc quản lý thơng tin số, chương trình phải quản lý thơng tin cơng trình đồ số như: vị trí, biểu tượng Cống qua đê Việc quản lý cống qua đê cần lưu trữ số liệu sau: - Thông tin chung: Tuyến đê, Đội quản lý đê, Tên cống, Vị trí (km+m), Quận-huyện, Phường-xã, Chức (tưới, tiêu, tưới+tiêu), Có kết hợp nhiệm vụ khác khơng, Lưu lượng, Diện tích phục vụ, Đơn vị xây dựng, Đơn vị quản lý, Năm xây dựng, Ngày nhập số liệu, Người nhập số liệu - Thông tin kỹ thuật: Cao trình (đỉnh, đáy, đỉnh tường ngực), Phai (số lượng khe phai, loại phai, số lượng phai), Kích thước (rộng, dài, cao, chiều dài qua đê), Kết cấu, Khẩu độ, Số khoang, Hình thức, Hình thức đóng mở, Mực nước thiết kế ngồi sơng đồng, Chênh lệch đầu nước thiết kế, Mực nước lũ lớn vào năm nào, Mực nước báo động cấp 1, 2, 3, Mực nước cho phép đóng mở mùa lũ - Mỗi cống cần phải lưu trữ hồ sơ gồm thông tin: năm khảo sát, số hồ sơ, tên tài liệu, ghi - Các ghi thêm Ngồi có u cầu quản lý khác như: - Quản lý file hồ sơ liên quan đến cơng trình file word, excel, vẽ CAD, - Quản lý, lưu trữ ảnh, đoạn video có liên quan đến cơng trình Trạm bơm Việc quản lý trạm bơm cần lưu trữ số liệu sau: - Thông tin chung: Tuyến đê, Đội quản lý đê, Tên trạm bơm, Vị trí (km+m), quậnhuyện, Phường-xã, Chức (tưới, tiêu, tưới+tiêu), Đơn vị xây dựng, Đơn vị quản lý, Năm xây dựng, Ngày nhập số liệu, Người nhập số liệu - Thông kỹ thuật: Hình thức, Số tổ máy, Cơng suất tổ, Cơng suất tổng, Van đóng mở, Mức nước cao vận hành phía sơng phía đồng, Diện tích tưới tiêu (thiết kế thực tế), Đơn vị hưởng lợi - Các ghi thêm Ngồi có yêu cầu quản lý khác như: - Quản lý file hồ sơ liên quan đến cơng trình file word, excel, vẽ CAD, - Quản lý, lưu trữ ảnh, đoạn video có liên quan đến công trạm bơm II Thiết kế Cơ sở liệu Cơ sở liệu thiết kế dựa mơ hình quan hệ, bao gồm bảng có liên kết với hình 10 Chương Xây dựng phần mềm quản lý điều khiển Trong chương chúng tơi trình bày bước xây dựng module phần mềm quản lý điều khiển Các module xây dựng nên phần mềm gồm có: I Module phần mềm quản lý thông tin đồ số điều khiển qua kết nối Internet Mục đích module quản lý thông tin công trình đồ số điều khiển thiết bị cơng trình trực tiếp qua mạng Internet Module viết ngôn ngữ Visual Basic 6.0 II Module truyền hình ảnh từ camera qua mạng Internet Để truyền hình ảnh qua mạng Internet chúng tơi sử dụng camera có giá thành thấp (webcam) kết nối với máy chủ Giải pháp có ưu điểm chi phí thấp có kết nối nhiều camera Để truyền hình ảnh trực tiếp từ cơng trình đến người sử dụng thơng qua mạng Internet sử dụng phần mềm Umediaserver UliveServer Unreal Streaming Technologies, phần mềm giúp broadcast video tốt III Module kết nối với thiết bị ngoại vi điều khiển qua Internet Để kết nối máy tính từ xa đến máy chủ đặt cơng trình thuỷ nơng qua mạng Internet, chúng tơi sử dụng giải pháp lập trình socket Windows Phía server mở socket để client kết nối vào Sau kết nối thành cơng Phía server gửi thơng tin trạng thái đến client: trạng thái tổ máy thời, số lượng camera có hệ thống Module viết ngôn ngữ Visual Basic 6.0 11 OptionSPOnHook.Value = etPhone1.SpeakerphoneOnHook OptionSPOffHook.Value = etPhone1.SpeakerphoneMicrophoneAndSpeaker If etPhone1.SpeakerphoneVolumeAvailable Then TextSPVolume.Text = Str(etPhone1.SpeakerphoneVolume) LabelSPVolume.Enabled = True TextSPVolume.Enabled = True CommandSPVolumeApply.Enabled = True Else LabelSPVolume.Enabled = False TextSPVolume.Enabled = False CommandSPVolumeApply.Enabled = False End If If etPhone1.SpeakerphoneGainAvailable Then TextSPGain.Text = Str(etPhone1.SpeakerphoneGain) LabelSPGain.Enabled = True TextSPGain.Enabled = True CommandSPGainApply.Enabled = True Else LabelSPGain.Enabled = False TextSPGain.Enabled = False CommandSPGainApply.Enabled = False End If End If End If End Sub Private Sub CheckActive_Click() If CheckActive.Value = Then If etLine1.DeviceActive Then If etPhone1.DeviceActive Then 'Deactivate the phone device before the line device TextStatus.Text = TextStatus.Text & "etPhone1.DeviceActive = False" & vbCrLf etPhone1.DeviceActive = False If etPhone1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etPhone1.ErrorText & vbCrLf End If End If TextStatus.Text = TextStatus.Text & "etLine1.DeviceActive = False" & vbCrLf etLine1.DeviceActive = False If Not etLine1.DeviceActive Then CommandDial.Enabled = False CommandDialtone.Enabled = False Else TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etLine1.ErrorText & vbCrLf CheckActive.Value = End If End If Else If Not etLine1.DeviceActive Then CommandAnswer.Enabled = True CommandHangup.Enabled = False CommandDialtone.Enabled = True CheckPlayOnConnect.Enabled = True TextWaveFile.Enabled = True CheckLoop.Enabled = True CheckPhone.Enabled = True PictureHandsetOnHook.Enabled = True PictureHandsetOffHook.Enabled = True FrameSpeakerphone.Enabled = True OptionSPOffHook.Enabled = True OptionSPOnHook.Enabled = True LabelSPVolume.Enabled = True LabelSPGain.Enabled = True TextSPVolume.Enabled = True TextSPGain.Enabled = True CommandSPVolumeApply.Enabled = True CommandSPGainApply.Enabled = True LabelRecord.Enabled = True CommandRecord.Enabled = True TextStatus.Text = TextStatus.Text & "etLine1.DeviceActive = True" & vbCrLf etLine1.DeviceActive = True If etLine1.ErrorNumber = INVALID_SERIAL_NUMBER Then 152 MsgBox ("Error opening line device: " & etLine1.ErrorText & vbCrLf & vbCrLf & _ "See the help topic:" & vbCrLf & vbCrLf & _ vbTab & "Why Serial Numbers Are Important") End If If (Not etLine1.DeviceActive) And (etLine1.ErrorNumber = LINEERR_INVALMEDIAMODE) And _ (InStr(1, etLine1.TAPITSP, "Modem", 1) > 0) Then CommandAnswer.Enabled = False CommandDialtone.Enabled = False CheckPlayOnConnect.Enabled = False TextWaveFile.Enabled = False CheckLoop.Enabled = False CheckPhone.Enabled = False PictureHandsetOnHook.Enabled = False PictureHandsetOffHook.Enabled = False FrameSpeakerphone.Enabled = False OptionSPOffHook.Enabled = False OptionSPOnHook.Enabled = False LabelSPVolume.Enabled = False LabelSPGain.Enabled = False TextSPVolume.Enabled = False TextSPGain.Enabled = False CommandSPVolumeApply.Enabled = False CommandSPGainApply.Enabled = False LabelRecord.Enabled = False CommandRecord.Enabled = False etLine1.PrivilegeNone = True etLine1.DeviceActive = True MsgBox ("TeleTools has detected that your device is a (" + etLine1.DeviceName & _ ") DATA modem and therefore has no voice capabilities." & vbCrLf & vbCrLf & _ "TeleTools will now force a compatibility mode in order to allow you to " & _ " continue while greying out options your modem may not support." & vbCrLf & vbCrLf & _ "This device will be able to:" & vbCrLf & vbCrLf & vbTab & "DIAL" & vbCrLf & vbCrLf & _ "If you think you have a voice modem, expected more functionality, " & _ "or other programs provide more functionality with this modem, see the " & _ "topic 'Working with Modems' in the Appendix of the TeleTools help file.") End If If etLine1.DeviceActive Then CommandDial.Enabled = True If CheckPhone.Value = Then 'Activate the phone device after the line device etPhone1.DeviceActive = True If Not etPhone1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etPhone1.ErrorText & vbCrLf End If End If ' Not all telephony devices are capable of controling the volume ' of the wave play device This includes modems that use the ' Microsoft UnimodemV telephony service provider The following ' code checks to see if the Unimodem TSP is being used and ' disables etPlay from working with the volume properties If InStr(1, etLine1.TAPITSP, "Modem", 1) > Then etPlay1.VolumeEnabled = False Else etPlay1.VolumeEnabled = True End If Else TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etLine1.ErrorText & vbCrLf CheckActive.Value = End If End If End If If etLine1.WavePlayAvailable Then CheckPlayOnConnect.Enabled = True 153 TextWaveFile.Enabled = True CheckLoop.Enabled = True Else CheckPlayOnConnect.Enabled = False TextWaveFile.Enabled = False CheckLoop.Enabled = False End If UpdatePhoneDisplay If (etPhone1.AboutLevel = "Professional") Or (etPhone1.AboutLevel = "Enterprise") Then If etLine1.PhoneAvailable Then CheckPhone.Value = Else CheckPhone.Value = End If End If End Sub Private Sub CheckLoop_Click() If CheckLoop = Then etPlay1.DeviceLoop = True Else etPlay1.DeviceLoop = False End If End Sub Private Sub CheckPhone_Click() If CheckPhone.Value = Then If etPhone1.DeviceActive Then 'Deactivate the phone device before the line device TextStatus.Text = TextStatus.Text & "etPhone1.DeviceActive etPhone1.DeviceActive = False If etPhone1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " vbCrLf CheckPhone.Value = End If End If Else If (etLine1.DeviceActive) And (Not etPhone1.DeviceActive) Then TextStatus.Text = TextStatus.Text & "etPhone1.DeviceActive etPhone1.DeviceActive = True If Not etPhone1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " vbCrLf CheckPhone.Value = End If End If End If UpdatePhoneDisplay End Sub = False" & vbCrLf & etPhone1.ErrorText & = True" & vbCrLf & etPhone1.ErrorText & Private Sub cmdResetMessCount_Click() MessageCount = lstMess.Clear End Sub Private Sub ComboDevice_Click() If etLine1.DeviceActive Then CheckActive.Value = End If TextStatus.Text = TextStatus.Text & "etLine1.DeviceID = " & Str(ComboDevice.ListIndex) & vbCrLf etLine1.DeviceID = ComboDevice.ListIndex If etLine1.ErrorNumber Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etLine1.ErrorText & vbCrLf Else etLine1.PrivilegeMonitor = True etLine1.PrivilegeOwner = True End If End Sub Private Sub Command1_Click() etPlay1.DeviceID = etLine1.WavePlayID etPlay1.SourceFileName = "c:\temp.wav" End Sub 154 Private Sub CommandAnswer_Click() TextStatus.Text = TextStatus.Text & "Answering" & vbCrLf If Not etLine1.CallAnswer Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etLine1.ErrorText & vbCrLf End If End Sub Private Sub CommandClear_Click() TextStatus.Text = "" End Sub Private Sub CommandDial_Click() State = "Dial" etLine1.CallPhoneNumber = TextPhoneNumber.Text TextStatus.Text = TextStatus.Text & "Dialing [" & TextPhoneNumber.Text & "]" & vbCrLf If etLine1.CallDial Then CommandDial.Enabled = False CommandDialtone.Enabled = False CommandHangup.Enabled = True Else TimerAutomatedAnsweringDevice.Enabled = False etLine1.CallMonitorSilenceActive = False TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etLine1.ErrorText & vbCrLf etLine1.CallHangup 'Just in case the device didn't drop the call End If End Sub Private Sub CommandDialtone_Click() State = "Dialtone test" etLine1.CallPhoneNumber = "W;" TextStatus.Text = TextStatus.Text & "Testing for dialtone" & vbCrLf If (etLine1.PrivilegeNone = True) And _ (etLine1.DeviceMediaModesActive = LINEMEDIAMODE_DATAMODEM) Then TextStatus.Text = TextStatus.Text & vbTab & "This will not work because this device is not be 100% TAPI compliant" & vbCrLf Else If Not etLine1.CallDial Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etLine1.ErrorText & vbCrLf End If End If End Sub Private Sub CommandHangup_Click() TextStatus.Text = TextStatus.Text & "Hangup" & vbCrLf ' We need to make sure that the wave play device is deactivated This code can be found in location ' CommandHangup_Click, etLine1_OnDisconnected, etLine1_OnIdle and Form_Unload If etPlay1.DeviceActive Then etPlay1.DeviceActive = False If etPlay1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etPlay1.ErrorText & vbCrLf End If End If If etRecord1.DeviceActive Then etRecord1.DeviceActive = False If etRecord1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etRecord1.ErrorText & vbCrLf End If End If CommandRecord.Enabled = False TimerAutomatedAnsweringDevice.Enabled = False If etLine1.CallMonitorSilenceActive Then etLine1.CallMonitorSilenceActive = False End If If Not etLine1.CallHangup Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etLine1.ErrorText & vbCrLf End If End Sub Private Sub CommandRecord_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) 'Not all telephony devices are capable of recording with the format 155 'PCM 8,000 hz, 16 bit, Mono For example if you are using a Dialogic 'card you will need to use the following line of code to select a 'different format If InStr(1, etLine1.TAPITSP, "Dialogic", 1) > Then etRecord1.SourceFormatID = wfuLaw08000M08 Else etRecord1.SourceFormatID = wfPCM08000M16 End If etRecord1.SourceFileName = App.Path & "\record\temp.wav" TextStatus.Text = TextStatus.Text & "Recording wave file [" & etRecord1.SourceFileName & "]" & vbCrLf etRecord1.DeviceID = etLine1.WaveRecordID etRecord1.DeviceActive = True If Not etRecord1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etRecord1.ErrorText & vbCrLf End If End Sub Private Sub CommandRecord_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) If etRecord1.DeviceActive Then TextStatus.Text = TextStatus.Text & "Stop recording wave file [" & etRecord1.SourceFileName & "]" & vbCrLf etRecord1.DeviceActive = False If etRecord1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etRecord1.ErrorText & vbCrLf Else If etPlay1.DeviceActive Then etPlay1.DeviceActive = False End If TextStatus.Text = TextStatus.Text & "Playing wave file [" & etRecord1.SourceFileName & "]" & vbCrLf etPlay1.SourceFileName = etRecord1.SourceFileName etPlay1.DeviceID = etLine1.WavePlayID etPlay1.DeviceActive = True If etRecord1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etPlay1.ErrorText & vbCrLf End If End If End If End Sub Private Sub CommandSPGainApply_Click() etPhone1.SpeakerphoneGain = Val(TextSPGain.Text) DoEvents TextSPGain.Text = Str(etPhone1.SpeakerphoneGain) End Sub Private Sub CommandSPVolumeApply_Click() etPhone1.SpeakerphoneVolume = Val(TextSPVolume.Text) DoEvents TextSPVolume.Text = Str(etPhone1.SpeakerphoneVolume) End Sub Private Sub etLine1_OnAddressState(ByVal Address As Long, ByVal State As Long) 'a = a End Sub Private Sub etLine1_OnBusy(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnBusy" & vbCrLf CommandHangup_Click End Sub Private Sub etLine1_OnCallBegin(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnCallBegin" & vbCrLf End Sub Private Sub etLine1_OnCalledID(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnCalledID" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "CalledIDName = " & etLine1.CallCalledIDName & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "CalledIDNumber = " & etLine1.CallCalledIDNumber & vbCrLf End Sub 156 Private Sub etLine1_OnCallEnd(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnCallEnd" & vbCrLf End Sub Private Sub etLine1_OnCallerID(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnCallerID" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "CallerIDName = " & etLine1.CallCallerIDName & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "CallerIDNumber = " & etLine1.CallCallerIDNumber & vbCrLf End Sub Private Sub etLine1_OnCallState(ByVal CallHandle As Long, ByVal State As Long, ByVal StateMode As Long, ByVal Privilege As Long) 'Me.Caption = Me.Caption & "+" & State End Sub Private Sub etLine1_OnConnected(ByVal CallHandle As Long) Timer1.Enabled = True waitingTime = TextStatus.Text = TextStatus.Text & "etLine1.OnConnected" & vbCrLf If (etLine1.AboutLevel = "Standard") Or _ (etLine1.AboutLevel = "Professional") Or _ (etLine1.AboutLevel = "Enterprise") Then If (etLine1.CallOrigin = LINECALLORIGIN_OUTBOUND) Then 'Modems not support monitor silence If (InStr(1, etLine1.TAPITSP, "Modem", 1) = 0) And _ ((etLine1.AddressCapabilitiesCallFeatures And LINECALLFEATURE_MONITORTONES) 0) Then 'Modems not report LINECALLFEATURE_MONITORTONES correctly! TextStatus.Text = TextStatus.Text & vbTab & "Check for automated device" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & vbTab & "etLine1.CallMonitorSilenceActive = True" & vbCrLf TimerAutomatedAnsweringDevice.Enabled = True gdtConnected = Now etLine1.CallMonitorSilenceDuration = 1500 etLine1.CallMonitorSilenceActive = True If (Not etLine1.CallMonitorSilenceActive) Then TextStatus.Text = TextStatus.Text & vbTab & vbTab & "Error = " & etLine1.ErrorText & vbCrLf End If 'See the events etLine.OnSilence and TimerAutomatedAnsweringDevice.Timer End If End If End If CommandAnswer.Enabled = False CommandHangup.Enabled = True If CheckPlayOnConnect.Value = Then If Not etLine1.WavePlayAvailable Then TextStatus.Text = TextStatus.Text & vbTab & "etLine1.WavePlayAvailable = False" & vbCrLf Else TextStatus.Text = TextStatus.Text & vbTab & "Playing wave file [" & TextWaveFile.Text & "]" & vbCrLf etPlay1.DeviceID = etLine1.WavePlayID etPlay1.SourceFileName = TextWaveFile.Text CheckLoop_Click etPlay1.DeviceActive = True If Not etPlay1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & vbTab & "Error = " & etPlay1.ErrorText & vbCrLf End If End If End If ' Modems not report LINECALLFEATURE_MONITORDIGITS correctly! ' Use this method to check for modems If (InStr(1, etLine1.TAPITSP, "Modem", 1) > 0) Then If (Not etLine1.PrivilegeNone) Then ' Using a voice modem etLine1.CallMonitorDigitsActive = True End If Else 157 If (etLine1.AddressCapabilitiesCallFeatures And LINECALLFEATURE_MONITORDIGITS) Then etLine1.CallMonitorDigitsActive = True End If End If If etLine1.WaveRecordAvailable Then CommandRecord.Enabled = True Else CommandRecord.Enabled = False End If 'haidv================================== 'If AnswerFunc = False Then Exit Sub SystemStatusPosition = If PlayWaveFile(FolderWAVE & "chao.wav", False) = False Then Exit Sub 'If PlayWaveFile(FolderWAVE & "3wellcome.wav", False) = False Then Exit Sub End Sub Private Sub etLine1_OnConnectedID(ByVal TextStatus.Text = TextStatus.Text & TextStatus.Text = TextStatus.Text & etLine1.CallConnectedIDName & vbCrLf TextStatus.Text = TextStatus.Text & etLine1.CallConnectedIDNumber & vbCrLf End Sub CallHandle As Long) "etLine1.OnConnectedID" & vbCrLf vbTab & "ConnectedIDName = " & vbTab & "ConnectedIDNumber = " & Private Sub etLine1_OnDialing(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnDialing" & vbCrLf End Sub Private Sub etLine1_OnDialtone(ByVal CallHandle As Long) If State = "Dialtone test" Then TextStatus.Text = TextStatus.Text & vbTab & State & " Successful" & vbCrLf etLine1.CallHangup Else TextStatus.Text = TextStatus.Text & "etLine1.OnDialtone" & vbCrLf End If End Sub Private Sub etLine1_OnDigitReceived(ByVal CallHandle As Long, ByVal Digit As Integer, ByVal Tag As Long) waitingTime = Dim b As Byte TextStatus.Text = TextStatus.Text & "etLine1.OnDigitReceived [" & Chr(Digit) & "]" & vbCrLf If etPlay1.DeviceActive Then ' Stop playing wave file when a digit is received etPlay1.DeviceActive = False End If '================== Kiem tra pass================== If SystemStatusPosition = Then If Chr(Digit) = "#" Then ' danh xong pass If PasswordRECEIVE = Password Then PlayWaveFile FolderWAVE & "chao2.wav", False SystemStatusPosition = 30 Exit Sub Else PlayWaveFile FolderWAVE & "matkhausai.wav" PasswordRECEIVE = "" ' danh lai pass di 'CommandHangup_Click End If Exit Sub End If ' PasswordRECEIVE = PasswordRECEIVE & Chr(Digit) ' Debug.Print PasswordRECEIVE & Chr(13) List1.AddItem PasswordRECEIVE End If '================== Kiem tra pass================== If SystemStatusPosition = 30 Then PasswordRECEIVE = "" Select Case Chr(Digit) 158 Case "1": 'tat tra loi tu dong b = PortIn(LPT) If b = Then PlayWaveFile FolderWAVE & "bom11.wav", If b = Then PlayWaveFile FolderWAVE & "bom01.wav", If b = Then PlayWaveFile FolderWAVE & "bom10.wav", If b = Then PlayWaveFile FolderWAVE & "bom00.wav", Case "2": PlayWaveFile FolderWAVE & "chao3.wav", False SystemStatusPosition = 302 Exit Sub Case "*": SystemStatusPosition = 30 PlayWaveFile FolderWAVE & "chao2.wav" False False False False End Select Exit Sub End If ' dieu khien may bom========================== If SystemStatusPosition = 302 Then Select Case Chr(Digit) Case "1": 'dk may b = PortIn(LPT) SystemStatusPosition = 3021 If b = Or b = Then 'bom dang tat PlayWaveFile FolderWAVE & "chao3_bom1tat.wav" SystemStatusPosition = 30210 End If If b = Or b = Then 'bom dang mo PlayWaveFile FolderWAVE & "chao3_bom1mo.wav" SystemStatusPosition = 30211 End If Case "2": b = PortIn(LPT) SystemStatusPosition = 3022 If b = Or b = Then 'bom dang tat PlayWaveFile FolderWAVE & "chao3_bom2tat.wav" SystemStatusPosition = 30220 End If If b = Or b = Then 'bom dang mo PlayWaveFile FolderWAVE & "chao3_bom2mo.wav" SystemStatusPosition = 30221 End If Case "*": SystemStatusPosition = 30 PlayWaveFile FolderWAVE & "chao2.wav" End Select Exit Sub End If ' dieu khien may bom 1========================== If SystemStatusPosition = 30210 Then If Chr(Digit) = "1" Then 'dk may b = PortIn(LPT) PortOut LPT, b - SystemStatusPosition = 302 PlayWaveFile FolderWAVE & "bom1mo.wav" 'PlayWaveFile FolderWAVE & "chao3.wav" End If Exit Sub End If ' -If SystemStatusPosition = 30211 Then If Chr(Digit) = "0" Then 'dk may b = PortIn(LPT) PortOut LPT, b + SystemStatusPosition = 302 PlayWaveFile FolderWAVE & "bom1tat.wav" 'PlayWaveFile FolderWAVE & "chao3.wav" 159 End If Exit Sub End If ' dieu khien may bom 2========================== If SystemStatusPosition = 30220 Then If Chr(Digit) = "1" Then 'dk may b = PortIn(LPT) PortOut LPT, b - SystemStatusPosition = 302 PlayWaveFile FolderWAVE & "bom2mo.wav" 'PlayWaveFile FolderWAVE & "chao3.wav" End If Exit Sub End If ' -If SystemStatusPosition = 30221 Then If Chr(Digit) = "0" Then 'dk may b = PortIn(LPT) PortOut LPT, b + SystemStatusPosition = 302 PlayWaveFile FolderWAVE & "bom2tat.wav" 'PlayWaveFile FolderWAVE & "chao3.wav" End If Exit Sub End If End Sub Private Sub etLine1_OnDisconnected(ByVal CallHandle As Long) Timer1.Enabled = False If State = "Dialtone test" Then If (etLine1.CallDisconnectMode = LINEDISCONNECTMODE_NODIALTONE) Or _ (etLine1.CallDisconnectMode = LINEDISCONNECTMODE_OUTOFORDER) Then TextStatus.Text = TextStatus.Text & vbTab & "Failure" & vbCrLf End If End If TextStatus.Text = TextStatus.Text & "etLine1.OnDisconnected" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "etLine1.CallDisconnectMode = " & _ etLine1.StringLINEDISCONNECTMODE(etLine1.CallDisconnectMode) & vbCrLf TimerAutomatedAnsweringDevice.Enabled = False If etLine1.CallMonitorSilenceActive Then etLine1.CallMonitorSilenceActive = False End If ' We need to make sure that the wave play device is deactivated This code can be found in location ' CommandHangup_Click, etLine1_OnDisconnected, etLine1_OnIdle and Form_Unload If etPlay1.DeviceActive Then etPlay1.DeviceActive = False If etPlay1.DeviceActive Then ' TextStatus.Text = TextStatus.Text & vbTab & "Error = " & ePlay1.ErrorText & vbCrLf End If End If If etRecord1.DeviceActive Then etRecord1.DeviceActive = False If etRecord1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etRecord1.ErrorText & vbCrLf End If End If CommandRecord.Enabled = False If etLine1.CallState LINECALLSTATE_IDLE Then etLine1.CallHangup End If CommandHangup_Click End Sub Private Sub etLine1_OnError() TextStatus.Text = TextStatus.Text & "etLine1.OnError" & vbCrLf 160 TextStatus.Text = TextStatus.Text & vbTab & "etLine1.ErrorText = " & etLine1.ErrorText & vbCrLf End Sub Private Sub etLine1_OnHold(ByVal CallHandle As Long) End End Sub Private Sub etLine1_OnIdle(ByVal CallHandle As Long) State = "" TextStatus.Text = TextStatus.Text & "etLine1.OnIdle" & vbCrLf CommandAnswer.Enabled = False If Not etLine1.PrivilegeNone Then CommandDialtone.Enabled = True End If CommandHangup.Enabled = False CommandDial.Enabled = True TimerAutomatedAnsweringDevice.Enabled = False 'If this is not a data modem then enabled the "Check For Dialtone" button If Not etLine1.PrivilegeNone Then CommandDialtone.Enabled = True End If If etLine1.CallMonitorDigitsActive Then etLine1.CallMonitorDigitsActive = False End If If etLine1.CallMonitorSilenceActive Then etLine1.CallMonitorSilenceActive = False End If ' We need to make sure that the wave play device is deactivated This code can be found in location ' CommandHangup_Click, etLine1_OnDisconnected, etLine1_OnIdle and Form_Unload If etPlay1.DeviceActive Then etPlay1.DeviceActive = False If etPlay1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etPlay1.ErrorText & vbCrLf End If End If If etRecord1.DeviceActive Then etRecord1.DeviceActive = False If etRecord1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etRecord1.ErrorText & vbCrLf End If End If CommandRecord.Enabled = False End Sub Private Sub etLine1_OnLineState(ByVal State As Long, ByVal Param2 As Long, ByVal Param3 As Long) 'Me.Caption = Me.Caption & "-" & State End Sub Private Sub etLine1_OnOffering(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnOffering" & vbCrLf CommandAnswer.Enabled = True CommandDialtone.Enabled = False End Sub Private Sub etLine1_OnProceeding(ByVal CallHandle As Long) a = a End Sub Private Sub etLine1_OnRedirectingID(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnRedirectingID" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "RedirectingIDName = " & etLine1.CallRedirectingIDName & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "RedirectingIDNumber = " & etLine1.CallRedirectingIDNumber & vbCrLf End Sub Private Sub etLine1_OnRedirectionID(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnRedirectionID" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "RedirectionIDName = " & etLine1.CallRedirectionIDName & vbCrLf 161 TextStatus.Text = TextStatus.Text & vbTab & "RedirectionIDNumber = " & etLine1.CallRedirectionIDNumber & vbCrLf End Sub Private Sub etLine1_OnRing(ByVal Count As Long, ByVal RingMode As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnRing [" & Str(Count) & ", " & Str(RingMode) & "]" & vbCrLf If Count >= Val(txtRingCount.Text) And Val(txtRingCount.Text) Then 'tr¶ lêi tù ®éng If AnswerFunc = False Then Exit Sub SystemStatusPosition = If PlayWaveFile(FolderWAVE & "chao.wav", False) = False Then Exit Sub End If End Sub Private Sub etLine1_OnRingBack(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnRingBack" & vbCrLf End Sub Private Sub etLine1_OnSilence(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnSilence" & vbCrLf If etLine1.CallOrigin = LINECALLORIGIN_OUTBOUND Then TimerAutomatedAnsweringDevice.Enabled = False etLine1.CallMonitorSilenceActive = False If ((Now - gdtConnected) < (ONE_SECOND * 3)) Then TextStatus.Text = TextStatus.Text & vbTab & "Silence detected in less than seconds" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & vbTab & "Likely a human" & vbCrLf Else TextStatus.Text = TextStatus.Text & vbTab & "Silence detected in greater than seconds" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & vbTab & "Likely an automated device" & vbCrLf End If End If End Sub Private Sub etLine1_OnSpecialInfo(ByVal CallHandle As Long) TextStatus.Text = TextStatus.Text & "etLine1.OnSpecialInfo" & vbCrLf End Sub Private Sub etLine1_Validate(Cancel As Boolean) a = a End Sub Private Sub etPhone1_OnDigitDown(ByVal wDetail As Integer) TextStatus.Text = TextStatus.Text & "etPhone1.OnDigitDown [" & Chr(wDetail) & "]" & vbCrLf End Sub Private Sub etPhone1_OnDigitUp(ByVal wDetail As Integer) TextStatus.Text = TextStatus.Text & "etPhone1.OnDigitUp [" & Chr(wDetail) & "]" & vbCrLf End Sub Private Sub etPhone1_OnError() TextStatus.Text = TextStatus.Text & "etPhone1.OnError" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.ErrorText = " & etPhone1.ErrorText & vbCrLf End Sub Private Sub etPhone1_OnHandsetHookSwitch() TextStatus.Text = TextStatus.Text & "etPhone1.OnHandsetHookSwitch" & vbCrLf If etPhone1.HandsetMicrophoneAndSpeaker Then TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.HandsetMicrophoneAndSpeaker = True" & vbCrLf Else TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.HandsetMicrophoneAndSpeaker = False" & vbCrLf End If If etPhone1.HandsetMicrophoneOnly Then TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.HandsetMicrophoneOnly = True" & vbCrLf Else TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.HandsetMicrophoneOnly = False" & vbCrLf End If 162 If etPhone1.HandsetOnHook Then TextStatus.Text = TextStatus.Text Else TextStatus.Text = TextStatus.Text End If If etPhone1.HandsetSpeakerOnly Then TextStatus.Text = TextStatus.Text vbCrLf Else TextStatus.Text = TextStatus.Text vbCrLf End If UpdatePhoneDisplay End Sub & vbTab & "etPhone1.HandsetOnHook = True" & vbCrLf & vbTab & "etPhone1.HandsetOnHook = False" & vbCrLf & vbTab & "etPhone1.HandsetSpeakerOnly = True" & & vbTab & "etPhone1.HandsetSpeakerOnly = False" & Private Sub etPhone1_OnPhoneState() TextStatus.Text = TextStatus.Text & "etPhone1.OnPhoneState [" & Hex(etPhone1.DeviceState) & "] [" & Hex(etPhone1.DeviceStateDetails) & "]" & vbCrLf End Sub Private Sub etPhone1_OnSpeakerphoneGain() TextStatus.Text = TextStatus.Text & "etPhone1.OnSpeakerphoneGain" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.SpeakerphoneGain = " & Str(etPhone1.SpeakerphoneGain) & vbCrLf TextSPGain.Text = Str(etPhone1.SpeakerphoneGain) End Sub Private Sub etPhone1_OnSpeakerphoneHookSwitch() TextStatus.Text = TextStatus.Text & "etPhone1.OnSpeakerphoneHookSwitch" & vbCrLf If etPhone1.SpeakerphoneMicrophoneAndSpeaker Then TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.SpeakerphoneMicrophoneAndSpeaker = True" & vbCrLf OptionSPOffHook.Value = True Else TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.SpeakerphoneMicrophoneAndSpeaker = False" & vbCrLf End If If etPhone1.SpeakerphoneMicrophoneOnly Then TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.SpeakerphoneMicrophoneOnly = True" & vbCrLf OptionSPOffHook.Value = True Else TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.SpeakerphoneMicrophoneOnly = False" & vbCrLf End If If etPhone1.SpeakerphoneOnHook Then TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.SpeakerphoneOnHook = True" & vbCrLf OptionSPOnHook.Value = True Else TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.SpeakerphoneOnHook = False" & vbCrLf End If If etPhone1.SpeakerphoneSpeakerOnly Then TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.SpeakerphoneSpeakerOnly = True" & vbCrLf OptionSPOffHook.Value = True Else TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.SpeakerphoneSpeakerOnly = False" & vbCrLf End If End Sub Private Sub etPhone1_OnSpeakerphoneVolume() TextStatus.Text = TextStatus.Text & "etPhone1.OnSpeakerphoneVolume" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.SpeakerphoneVolume = " & Str(etPhone1.SpeakerphoneVolume) & vbCrLf TextSPVolume.Text = Str(etPhone1.SpeakerphoneVolume) End Sub Private Sub etPlay1_OnDone() TextStatus.Text = TextStatus.Text & "etPlay1.OnDone" & vbCrLf End Sub Private Sub etPlay1_OnError() TextStatus.Text = TextStatus.Text & "etPlay1.OnError" & vbCrLf 163 TextStatus.Text = TextStatus.Text & vbTab & "etPlay1.ErrorText = " & etPlay1.ErrorText & vbCrLf End Sub Private Sub etPlay1_OnLoaded() TextStatus.Text = TextStatus.Text & "etPlay1.OnLoaded" & vbCrLf End Sub Private Sub etPlay1_OnLoop() TextStatus.Text = TextStatus.Text & "etPlay1.OnLoop" & vbCrLf End Sub Private Sub etPlay1_OnWarning(bContinue As Boolean) TextStatus.Text = TextStatus.Text & "etPlay1.OnWarning" & vbCrLf If MsgBox("Error playing: " & etPlay1.ErrorText, vbOKCancel) = vbCancel Then bContinue = False Else bContinue = True End If End Sub Private Sub etRecord1_OnError() TextStatus.Text = TextStatus.Text & "etRecord1.OnError" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "etRecord1.ErrorText = " & etRecord1.ErrorText & vbCrLf End Sub Private Sub etRecord1_OnWarning(bContinue As Boolean) TextStatus.Text = TextStatus.Text & "etRecord1.OnError" & vbCrLf If MsgBox("Error recording: " & etRecord1.ErrorText, vbOKCancel) = vbCancel Then bContinue = False Else bContinue = True End If End Sub Private Sub Form_Load() 'Enabled all ExceleTel TeleTools controls before using them etLine1.Enabled = True etPhone1.Enabled = True etPlay1.Enabled = True etRecord1.Enabled = True 'TextWaveFile.Text = App.Path & "\ \ \ \wav\et" 'TextWaveFile.Text = App.Path & "\wav\IVRGreet.wav" ComboDevice.Clear etLine1.DeviceID = For L = To etLine1.DeviceCount - ComboDevice.AddItem etLine1.DeviceList(L) Next L If ComboDevice.ListCount > Then ComboDevice.Text = ComboDevice.List(0) End If ComboDevice.ListIndex = ' ' ' etLine1.AboutLoadSerialNumber = True MsgBox "etLine1.AboutLoadSerialNumber=" & etLine1.AboutLoadSerialNumber MsgBox etPhone1.AboutSerialNumber MsgBox etRecord1.AboutSerialNumber 'etLine1.AboutLoadSerialNumber = 0# - 1933 - 3999 'etLine1.AboutLoadSerialNumber = True SetFolder cmdResetMessCount_Click End Sub Private Sub Form_Resize() ' If Form1.Width < 6810 Then ' TextStatus.Width = 6495 ' Else 164 ' TextStatus.Width = Form1.Width - 315 ' End If ' If Form1.Height < 5970 Then ' TextStatus.Height = 5495 ' Else ' TextStatus.Height = Form1.Height - TextStatus.Top - 475 ' End If End Sub Private Sub Form_Unload(Cancel As Integer) ' We need to make sure that the wave play device is deactivated This code can be found in location ' CommandHangup_Click, etLine1_OnDisconnected, etLine1_OnIdle and Form_Unload If etPlay1.DeviceActive Then etPlay1.DeviceActive = False If etPlay1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etPlay1.ErrorText & vbCrLf End If End If 'Close the etLine control when closing the form If etRecord1.DeviceActive Then etRecord1.DeviceActive = False If etRecord1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etRecord1.ErrorText & vbCrLf End If End If CommandRecord.Enabled = False etLine1.DeviceActive = False End Sub Private Sub OptionSPOffHook_Click() etPhone1.SpeakerphoneMicrophoneAndSpeaker = OptionSPOffHook.Value End Sub Private Sub OptionSPOnHook_Click() etPhone1.SpeakerphoneOnHook = OptionSPOnHook.Value End Sub Private Sub TextSPGain_LostFocus() TextSPGain.Text = Str(Val(TextSPGain.Text)) If (Val(TextSPGain.Text) < 0) Or (Val(TextSPGain.Text) > 100) Then TextSPGain.Text = Str(etPhone1.SpeakerphoneGain) End If End Sub Private Sub TextSPVolume_LostFocus() TextSPVolume.Text = Str(Val(TextSPVolume.Text)) If (Val(TextSPVolume.Text) < 0) Or (Val(TextSPVolume.Text) > 100) Then TextSPVolume.Text = Str(etPhone1.SpeakerphoneVolume) End If End Sub Private Sub Timer1_Timer() waitingTime = waitingTime + If waitingTime = 25 Then CommandHangup_Click Me.Caption = waitingTime End Sub Private Sub TimerAutomatedAnsweringDevice_Timer() TimerAutomatedAnsweringDevice.Enabled = False etLine1.CallMonitorSilenceActive = False TextStatus.Text = TextStatus.Text & "Silence not detected in " & _ Str(TimerAutomatedAnsweringDevice.Interval) & " milliseconds" & vbCrLf TextStatus.Text = TextStatus.Text & vbTab & "Likely an automated device" & vbCrLf End Sub '==============haidv============================ Public Function AnswerFunc() As Boolean TextStatus.Text = TextStatus.Text & "Answering" & vbCrLf AnswerFunc = True If Not etLine1.CallAnswer Then AnswerFunc = False TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etLine1.ErrorText & vbCrLf End If 165 End Function Public Function PlayWaveFile(fileName As String, Optional isLoop As Boolean = False) As Boolean If etPlay1.DeviceActive Then etPlay1.DeviceActive = False If Not etLine1.WavePlayAvailable Then TextStatus.Text = TextStatus.Text & vbTab & "etLine1.WavePlayAvailable = False" & vbCrLf PlayWaveFile = False Else PlayWaveFile = True TextStatus.Text = TextStatus.Text & vbTab & "Playing wave file [" & fileName & "]" & vbCrLf etPlay1.DeviceID = etLine1.WavePlayID etPlay1.SourceFileName = fileName 'etPlay1.DeviceLoop = True etPlay1.DeviceActive = True etPlay1.DeviceLoop = isLoop 'TextStatus.Text = TextStatus.Text & vbTab & vbTab & "Error = " & etPlay1.ErrorText & vbCrLf End If End Function Public Function Record2File(fileName As String) As Boolean If InStr(1, etLine1.TAPITSP, "Dialogic", 1) > Then etRecord1.SourceFormatID = wfuLaw08000M08 Else etRecord1.SourceFormatID = wfPCM08000M16 End If etRecord1.SourceFileName = fileName TextStatus.Text = TextStatus.Text & "Recording wave file [" & etRecord1.SourceFileName & "]" & vbCrLf etRecord1.DeviceID = etLine1.WaveRecordID etRecord1.DeviceActive = True If Not etRecord1.DeviceActive Then TextStatus.Text = TextStatus.Text & vbTab & "Error = " & etRecord1.ErrorText & vbCrLf End If End Function -************** 166

Ngày đăng: 07/09/2023, 14:44

Xem thêm:

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w