123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- import QtQuick 2.11
- import QtQuick.Controls 1.4
- import QtQuick.Layouts 1.14
- import "modbus.js" as ModbusJs
- Item {
- Loader{
- id:loader
- anchors.fill: parent
- anchors.margins: 5
- }
- function show(){
- if(loader.sourceComponent === null){
- loader.sourceComponent = componet
- }
- loader.item.show()
- }
- function exit(){
- if(loader.sourceComponent !== null){
- loader.item.exit()
- }
- }
- Component{
- id:componet
- GroupBox{
- id:groupbox
- x:width
- title: "标定模式"
- //property int readPressure_index: 0;
- Timer{
- id:componetTimer
- repeat: false
- interval: 1000
- onTriggered: {
- var ret = ModbusJs.checkModebusDevice(controlSerial,sensorSerial,log)
- if(ret === false)
- log.show("自检错误")
- else{
- log.show("自检正常")
- ModbusJs.closeAllValve(controlSerial)
- //打开三个传感阀
- ModbusJs.highPressureSensorCtrl(controlSerial,true)
- ModbusJs.lowPressureSensorCtrl(controlSerial,true)
- ModbusJs.negativePumpPowerCtrl(controlSerial,true)
- sensorTimer.start()
- //sensorTimer.running = true
- }
- //1000 会造成启动慢 延迟赋值
- //gauge.maximumValue = 1
- }
- }
- Timer{
- id:sensorTimer
- repeat: true
- triggeredOnStart: false
- interval: 1000
- onTriggered: {
- var obj
- if(comboBox1.currentText === "低压传感器"){
- obj = ModbusJs.lowPressureSensorReadReq(sensorSerial)
- if(obj.ret === false){
- log.show("低压传感器"+"通讯错误")
- }
- else{
- gauge_low.value = obj.pressureNumber //parseInt(obj.pressureNumber)
- //gauge_low.realValue = obj.pressureNumber
- }
- }else if(comboBox1.currentText === "高压传感器"){
- obj = ModbusJs.highPressureSensorReadReq(sensorSerial)
- if(obj.ret === false){
- log.show("高压传感器"+"通讯错误")
- }
- else{
- gauge_high.value = obj.pressureNumber//parseInt(obj.pressureNumber)
- //gauge_high.realValue = obj.pressureNumber
- }
- }else if(comboBox1.currentText === "负压传感器"){
- obj = ModbusJs.negativePressureSensorReadReq(sensorSerial)
- if(obj.ret === false){
- log.show("负压传感器"+"通讯错误")
- }
- else{
- gauge_negative.value = obj.pressureNumber // parseInt(obj.pressureNumber)
- //gauge_negative.realValue = obj.pressureNumber
- }
- }
- }
- }
- function show(){
- animationShow.running = true
- componetTimer.start()
- }
- function exit(){
- sensorTimer.stop()
- animationExit.running = true
- ModbusJs.closeAllValve(controlSerial)
- }
- //加载任务动画效果
- NumberAnimation {
- id: animationShow
- target: groupbox
- property: "x"
- from: groupbox.x
- to: 0
- duration: 500
- }
- NumberAnimation {
- id: animationExit
- target: groupbox
- property: "x"
- from: groupbox.x
- to: 1024
- duration: 500
- }
- Column{
- anchors.left: parent.left
- anchors.leftMargin: 2
- anchors.top: parent.top
- anchors.topMargin: 10
- spacing: 30
- Rectangle{
- width: 980
- height: 75
- color: "white"
- radius: 6
- Row{
- //anchors.fill: parent
- anchors.centerIn: parent.Center
- spacing: 20
- Button{
- id:positive_relif
- text: "打开正压罐泄压阀"
- //anchors.horizontalCenter: parent.horizontalCenter
- onClicked: {
- ModbusJs.positivePressureTankOutputCtrl(controlSerial,true)
- }
- }
- Button{
- id:negitive_relif
- text: "打开负压罐泄压阀"
- //anchors.horizontalCenter: parent.horizontalCenter
- onClicked: {
- ModbusJs.negativePressureTankOutputCtrl(controlSerial,true)
- }
- }
- Row{
- spacing: 5
- Text {
- anchors.verticalCenter: parent.verticalCenter
- text: qsTr("读取压力值:")
- font.bold: true
- font.pixelSize: 13
- }
- UserComboBox{
- id:comboBox1
- anchors.verticalCenter: parent.verticalCenter
- width: 145
- height: 25
- bgColor:"#D2D5D9"
- model: ["不读取","高压传感器","低压传感器", "负压传感器"]
- onActivated: {
- if(currentText === "不读取"){
- low_zero.enabled = false;
- high_zero.enabled = false;
- neg_zero.enabled = false;
- }else if(currentText === "高压传感器"){
- low_zero.enabled = false;
- high_zero.enabled = true;
- neg_zero.enabled = false;
- }else if(currentText === "低压传感器"){
- low_zero.enabled = true;
- high_zero.enabled = false;
- neg_zero.enabled = false;
- }else if(currentText === "负压传感器"){
- low_zero.enabled = false;
- high_zero.enabled = false;
- neg_zero.enabled = true;
- }
- }
- }
- }
- }
- }
- Row{
- x:-10
- spacing: 50
- anchors.horizontalCenter: parent.horizontalCenter
- Rectangle{
- width: 300*0.75
- height: 300
- color: "white"
- radius: 6
- anchors.verticalCenter: parent.verticalCenter
- Column{
- anchors.fill: parent
- spacing: 20
- Button{
- id:high_zero
- text: "高压传感器标零"
- enabled: false
- anchors.horizontalCenter: parent.horizontalCenter
- onClicked: {
- if(ModbusJs.highPressureSetZeroReq(sensorSerial)){
- }else{
- log.show("高压传感器:"+"标零失败!")
- }
- }
- }
- Gauge {
- id:gauge_high
- width: parent.width
- height: parent.width
- //anchors.centerIn: parent
- value: 0.0
- //realValue:0.0
- maximumValue: 1000
- minimumValue: {
- return 0
- }
- Behavior on value { NumberAnimation { duration: 1000 }}
- }
- }
- }
- Rectangle{
- width: 300*0.75
- height: 300
- color: "white"
- radius: 6
- anchors.verticalCenter: parent.verticalCenter
- Column{
- anchors.fill: parent
- spacing: 20
- Button{
- id:low_zero
- text: "低压传感器标零"
- enabled: false
- anchors.horizontalCenter: parent.horizontalCenter
- onClicked: {
- if(ModbusJs.lowPressureSetZeroReq(sensorSerial)){
- }else{
- log.show("低压传感器:"+"标零失败!")
- }
- }
- }
- Gauge {
- id:gauge_low
- width: parent.width
- height: parent.width
- anchors.centerIn: parent
- value: 0.0
- //realValue:0.0
- maximumValue: 1000
- minimumValue: {
- return 0
- }
- Behavior on value { NumberAnimation { duration: 1000 }}
- }
- }
- }
- Rectangle{
- width: 300*0.75
- height: 300
- color: "white"
- radius: 6
- anchors.verticalCenter: parent.verticalCenter
- Column{
- anchors.fill: parent
- spacing: 20
- Button{
- id:neg_zero
- text: "负压传感器标零"
- enabled: false
- anchors.horizontalCenter: parent.horizontalCenter
- onClicked: {
- if(ModbusJs.negativePressureSetZeroReq(sensorSerial)){
- }else{
- log.show("负压传感器:"+"标零失败!")
- }
- }
- }
- Gauge {
- id:gauge_negative
- width: parent.width
- height: parent.width
- anchors.centerIn: parent
- value: 0.0
- //realValue:0.0
- maximumValue: 900
- minimumValue: {
- return -100
- }
- Behavior on value { NumberAnimation { duration: 1000 }}
- }
- }
- }
- }
- }
- }
- }
- }
|