123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- import QtQuick 2.11
- import QtQuick.Controls 1.4
- import SerialUi 1.0
- //import SerialPort 1.0
- import ReportWord 1.0
- import QtTest 1.14
- import FileIO 1.0
- import "modbus.js" as ModbusJs
- ApplicationWindow {
- id: window
- visible: true
- width: 1010
- height: 700
- title: qsTr("阀门试验")
- property bool lampState:false
- property bool virtualkeyboard:true
- maximumHeight: height
- maximumWidth: width
- minimumHeight: height
- minimumWidth: width
- menuBar: ChooseValve{
- id:choosevalve
- onChoose: {
- if(text === "安全阀"){
- breatheValve.exit()
- vacuoValve.exit()
- peopleCoverHoleValve.exit()
- tankValve.exit()
- calibrationMode.exit()
- sealSelfTest.exit()
- safeValve.show()
- ModbusJs.closeAllValve(controlSerial)
- }
- else if(text === "呼吸阀"){
- safeValve.exit()
- vacuoValve.exit()
- peopleCoverHoleValve.exit()
- tankValve.exit()
- calibrationMode.exit()
- sealSelfTest.exit()
- breatheValve.show()
- ModbusJs.closeAllValve(controlSerial)
- }
- else if(text === "真空阀"){
- safeValve.exit()
- breatheValve.exit()
- peopleCoverHoleValve.exit()
- tankValve.exit()
- calibrationMode.exit()
- vacuoValve.show()
- sealSelfTest.exit()
- ModbusJs.closeAllValve(controlSerial)
- }
- else if(text === "人孔盖"){
- safeValve.exit()
- breatheValve.exit()
- vacuoValve.exit()
- tankValve.exit()
- calibrationMode.exit()
- sealSelfTest.exit()
- peopleCoverHoleValve.show()
- ModbusJs.closeAllValve(controlSerial)
- }
- else if(text === "罐体"){
- safeValve.exit()
- breatheValve.exit()
- vacuoValve.exit()
- peopleCoverHoleValve.exit()
- calibrationMode.exit()
- sealSelfTest.exit()
- tankValve.show()
- ModbusJs.closeAllValve(controlSerial)
- }
- else if(text === "密封自检"){
- safeValve.exit()
- breatheValve.exit()
- vacuoValve.exit()
- peopleCoverHoleValve.exit()
- calibrationMode.exit()
- tankValve.exit()
- sealSelfTest.show()
- ModbusJs.closeAllValve(controlSerial)
- }
- else if(text === "标定模式"){
- safeValve.exit()
- breatheValve.exit()
- vacuoValve.exit()
- peopleCoverHoleValve.exit()
- tankValve.exit()
- calibrationMode.show()
- }
- }
- }
- SafeValve{
- id:safeValve
- anchors.fill: parent
- }
- BreatheValve{
- id:breatheValve
- anchors.fill: parent
- }
- VacuoValve{
- id:vacuoValve
- anchors.fill: parent
- }
- PeopleCoverHoleValve{
- id:peopleCoverHoleValve
- anchors.fill: parent
- }
- TankValve{
- id:tankValve
- anchors.fill: parent
- }
- SealSelfTest{
- id:sealSelfTest
- anchors.fill: parent
- }
- Calibration{
- anchors.fill: parent
- id:calibrationMode
- }
- Component.onCompleted: {
- breatheValve.show()
- }
- GenerateCurve{
- id:generateCurve
- z:100
- }
- SerialUi{
- id:controlSerial
- property bool connected: false
- // onTimeout:{
- // log.show("control modbus通讯接收超时")
- // }
- onCheckError: {
- //log.show("control modbus通讯接收数据校验错误")
- }
- Component.onCompleted: {
- //(QString port, QString baudrate, QString databits, QString parity, QString stopbits)
- connected = controlSerial.serialConnect("COM4","9600","8","0","1")
- if(connected === false){
- log.show("打开控制串口COM4失败")
- }
- else{
- console.log("打开控制串口COM4成功")
- timer.start()
- }
- }
- }
- Timer{
- id:timer
- interval: 1000
- repeat: false
- onTriggered: {
- console.log("关闭所有阀门")
- ModbusJs.closeAllValve(controlSerial)
- }
- }
- SerialUi{
- id:sensorSerial
- property bool connected: false
- // onTimeout:{
- // log.show("sensor modbus通讯接收超时")
- // }
- onCheckError: {
- // log.show("sensor modbus通讯接收数据校验错误")
- }
- Component.onCompleted: {
- //(QString port, QString baudrate, QString databits, QString parity, QString stopbits)
- connected = sensorSerial.serialConnect("COM3","9600","8","2","1")
- if(connected === false){
- log.show("打开传感器串口COM3失败")
- }
- else{
- console.log("打开传感器串口COM3成功")
- }
- }
- }
- FileIO{
- id:fileio
- }
- //wait 超时专用
- SignalSpy {
- id: spy
- target: controlSerial
- signalName: "spy"
- }
- Log{
- id:log
- z:10
- width: 300
- height: 50
- anchors.centerIn: parent
- }
- Log{
- id:reportProgressLog
- z:10
- width: 300
- height: 50
- anchors.centerIn: parent
- }
- ReportPicture{
- id:reportPicture
- }
- ReportPicture{
- id:reportPicture0
- }
- ReportPicture{
- id:reportPicture1
- }
- ReportPicture{
- id:reportPicture2
- }
- ReportPicture{
- id:reportPicture3
- }
- ReportPicture{
- id:reportPicture4
- }
- ReportPicture{
- id:reportPicture5
- }
- ReportPicture{
- id:reportPicture6
- }
- ReportPicture{
- id:reportPicture7
- }
- ReportPicture{
- id:reportPicture8
- }
- ReportPicture{
- id:reportPicture9
- }
- ReportPicture{
- id:reportPicture10
- }
- ReportPicture{
- id:reportPicture11
- }
- ReportPicture{
- id:reportPicture12
- }
- ReportPicture{
- id:reportPicture13
- }
- ReportPicture{
- id:reportPicture14
- }
- ReportWord{
- id:reportWord
- onReportProgress: {
- if(text === "close")
- reportProgressLog.exit()
- else
- reportProgressLog.show(text)
- }
- }
- function pad_with_zeroes(number, length) {
- var my_string = '' + number;
- while (my_string.length < length) {
- my_string = '0' + my_string;
- }
- return my_string;
- }
- function getWordSaveFileName( para){
- var date = new Date;
- var year = date.getFullYear()
- var month = pad_with_zeroes(date.getMonth()+1,2)
- var day = pad_with_zeroes(date.getDate(),2)
- var hour = pad_with_zeroes(date.getHours(),2)
- var minute = pad_with_zeroes(date.getMinutes(),2)
- var second = pad_with_zeroes(date.getSeconds(),2)
- var time = year+month+day+hour+minute+second
- return "file:///"+time+"_"+para
- }
- }
|