123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503 |
- import QtQuick 2.15
- import QtQuick.Layouts 1.3
- import QtQuick.Controls 2.14
- import QtQuick.Controls.Styles 1.2
- import TService 1.0
- Item{
- id: root
- //anchors.fill: parent
- //width:1024
- //height: 768
- //anchors.centerIn: parent
- property var pagetype:rootitem.Page_Type_Testing
- property string title_str:"手动测试"
- property double pressvalue: 1.22
- property bool bSelfTest_Started: false
- property string selfTest_State_str:""
- property string selfTest_Result_str:""
- function show_pressure(pressure_str){
- lcd_pressure.text = pressure_str;
- }
- function show_selftestState(str){
- selfTest_State_str = str
- }
- function show_selftestResult(str){
- selfTest_Result_str = str
- }
- function selftestStop(){
- var ret1 = testService.tstop(0);
- if(ret1){
- bSelfTest_Started = false;
- //selftest_result.text = ""
- selftest_button.text = "开始"
- readbutton.enabled = true;
- adjustbutton.enabled = true;
- //timer.stop()
- }
- }
- // Component{
- // id:componet
- DynamicGroupBox{
- id:groupbox
- //x:width
- //x:0
- anchors.centerIn: parent
- anchors.fill: parent
- title: title_str
- Column{
- spacing: 10
- anchors.centerIn: parent
- DynamicGroupBox{
- id:relays_control
- title: "继电器控制"
- width: 800
- height: 300
- GridLayout{
- anchors.centerIn: parent
- columns: 4
- rows:3
- columnSpacing: 80
- rowSpacing: 30
- UserSwitch{
- id:switch1
- text: "粗调阀1关"
- onCheckedChanged: {
- //console.log("switch 1 onCheckedChanged")
- switch1.text = switch1.checked ? "粗调阀1开":"粗调阀1关"
- }
- onClicked: {
- //console.log("switch 1 clicked")
- if(switch1.checked){
- testService.valve_open(TestService.Valve_ID_ROUGH_0)
- }else{
- testService.valve_close(TestService.Valve_ID_ROUGH_0)
- }
- }
- }
- UserSwitch{
- id:switch2
- text: "粗调阀2关"
- onCheckedChanged: {
- switch2.text = switch2.checked ? "粗调阀2开":"粗调阀2关"
- }
- onClicked: {
- if(switch2.checked){
- testService.valve_open(TestService.Valve_ID_ROUGH_1)
- }else{
- testService.valve_close(TestService.Valve_ID_ROUGH_1)
- }
- }
- }
- UserSwitch{
- id:switch3
- text: "粗调阀3关"
- onCheckedChanged: {
- switch3.text = switch3.checked ? "粗调阀3开":"粗调阀3关"
- }
- onClicked: {
- if(switch3.checked){
- testService.valve_open(TestService.Valve_ID_ROUGH_2)
- }else{
- testService.valve_close(TestService.Valve_ID_ROUGH_2)
- }
- }
- }
- UserSwitch{
- id:switch4
- text: "校准阀 关"
- onCheckedChanged: {
- switch4.text = switch4.checked ? "校准阀 开":"校准阀 关"
- }
- onClicked: {
- if(switch4.checked){
- testService.valve_open(TestService.Valve_ID_CALIBRATION)
- }else{
- testService.valve_close(TestService.Valve_ID_CALIBRATION)
- }
- }
- }
- UserSwitch{
- id:switch5
- text: "传感阀 关"
- onCheckedChanged: {
- switch5.text = switch5.checked ? "传感阀 开":"传感阀 关"
- }
- onClicked: {
- if(switch5.checked){
- testService.valve_open(TestService.Valve_ID_PRESSURESENSOR)
- }else{
- testService.valve_close(TestService.Valve_ID_PRESSURESENSOR)
- }
- }
- }
- UserSwitch{
- id:switch6
- text: "真空阀 关"
- onCheckedChanged: {
- switch6.text = switch6.checked ? "真空阀 开":"真空阀 关"
- }
- onClicked: {
- if(switch6.checked){
- testService.valve_open(TestService.Valve_ID_VACUUM)
- }else{
- testService.valve_close(TestService.Valve_ID_VACUUM)
- }
- }
- }
- UserSwitch{
- id:switch7
- text: "泄气阀 关"
- onCheckedChanged: {
- switch7.text = switch7.checked ? "泄气阀 开":"泄气阀 关"
- }
- onClicked: {
- if(switch7.checked){
- testService.valve_open(TestService.Valve_ID_VENT)
- }else{
- testService.valve_close(TestService.Valve_ID_VENT)
- }
- }
- }
- UserSwitch{
- id:switch8
- text: "进气阀 关"
- onCheckedChanged: {
- switch8.text = switch8.checked ? "进气阀 开":"进气阀 关"
- }
- onClicked: {
- if(switch8.checked){
- testService.valve_open(TestService.Valve_ID_INTAKE)
- }else{
- testService.valve_close(TestService.Valve_ID_INTAKE)
- }
- }
- }
- UserSwitch{
- id:switchall
- text: "全关"
- onCheckedChanged: {
- switchall.text = switch8.checked ? "全关":"全开"
- if(switchall.checked){
- testService.valve_open(TestService.Valve_ID_All)
- switch1.checked=true
- switch2.checked=true
- switch3.checked=true
- switch4.checked=true
- switch5.checked=true
- switch6.checked=true
- switch7.checked=true
- switch8.checked=true
- }else{
- testService.valve_close(TestService.Valve_ID_All)
- switch1.checked=false
- switch2.checked=false
- switch3.checked=false
- switch4.checked=false
- switch5.checked=false
- switch6.checked=false
- switch7.checked=false
- switch8.checked=false
- }
- }
- }
- }
- }
- DynamicGroupBox{
- id:adjust_control
- title: "调节阀控制"
- width: 800
- height: 100
- Row{
- anchors.verticalCenter: parent.verticalCenter
- anchors.left: parent.left
- spacing: 20
- Text {
- id: text1
- //anchors.top: parent.top
- //anchors.bottom: parent.bottom
- //anchors.centerIn: parent
- anchors.verticalCenter: parent.verticalCenter
- text: qsTr("调压阀:")
- font.pixelSize: 20
- }
- UserButton {
- id: adjustbutton;
- text: "调压";
- font.pixelSize: 20
- anchors.verticalCenter: parent.verticalCenter
- implicitWidth: 100
- implicitHeight: 60
- onClicked: {
- //var str_number = voltage.text
- var num = Number(voltage.text)
- if((num>0) && (num<1000)){
- testService.adjust_Pressure(voltage.text)
- }else{
- console.log("input voltage invalid")
- log.show("Voltage invalid, please retry")
- }
- }
- }
- InputLine{
- id:voltage
- paraName: "Voltage:"
- paraLength: 60
- anchors.verticalCenter: parent.verticalCenter
- validator:RegExpValidator {
- regExp: /[0-9]*/
- }
- onTextChanged: {
- //root.manufacture = text
- }
- }
- }
- }
- DynamicGroupBox{
- id:pressure
- title: "实时压力"
- width: 800
- height: 100
- Row{
- anchors.verticalCenter: parent.verticalCenter
- anchors.left: parent.left
- spacing: 20
- Timer {
- id: timer;
- interval: 1000;//设置定时器定时时间为500ms,默认1000ms
- repeat: true //是否重复定时,默认为false
- running: false //是否开启定时,默认是false,当为true的时候,进入此界面就开始定时
- triggeredOnStart: false // 是否开启定时就触发onTriggered,一些特殊用户可以用来设置初始值。
- onTriggered: {
- lcd_pressure.text = testService.read_PressureValue();
- }
- //restart ,start,stop,定时器的调用方式,顾名思义
- }
- UserButton {
- id: readbutton;
- text: "开始";
- font.pixelSize: 20
- anchors.verticalCenter: parent.verticalCenter
- implicitWidth: 100
- implicitHeight: 60
- onEnabledChanged: {
- if(timer.running){
- timer.stop()
- text= "开始"
- }else{
- //timer.start()
- //text= "停止"
- }
- }
- onClicked: {
- if(timer.running){
- timer.stop()
- text= "开始"
- }else{
- timer.start()
- text= "停止"
- }
- //lcd_pressure.text = pressvalue.toFixed(3).toString()
- }
- }
- Rectangle{
- id:pressureWindow
- //anchors.fill: parent
- anchors.verticalCenter: parent.verticalCenter
- width: 120
- height: 40
- //color: "white"
- radius: 4
- LCDNumber{
- id:lcd_pressure
- anchors.centerIn: parent
- //anchors.verticalCenter: parent.verticalCenter
- text: "5.00"
- fontsize: 40
- }
- }
- Text {
- id: kpa
- anchors.left: lcd_pressure.right
- anchors.verticalCenter: parent.verticalCenter
- text: qsTr("kPa")
- //font: 40
- font.bold: true
- font.pixelSize: 25
- }
- }
- }
- DynamicGroupBox{
- id:selftest
- title: "系统自测"
- width: 800
- height: 100
- Row{
- anchors.verticalCenter: parent.verticalCenter
- anchors.left: parent.left
- spacing: 30
- UserButton {
- id: selftest_button;
- text: "开始";
- font.pixelSize: 20
- //height: 40
- //width: 160
- implicitWidth: 100
- implicitHeight: 60
- onClicked: {
- //var str_number = voltage.text
- if(false == bSelfTest_Started){
- //bSelfTest_Started = true;
- //selftest_result.text= "测试通过"
- if(timer.running){
- timer.stop()
- }
- var ret = testService.tselfstart(0, 0)
- if(ret){
- bSelfTest_Started = true;
- readbutton.enabled = false;
- adjustbutton.enabled = false;
- text = "停止"
- selfTest_State_str=""
- selfTest_Result_str=""
- //timer.start()
- }else{
- }
- }else{
- var ret1 = testService.tstop(0);
- if(ret1){
- bSelfTest_Started = false;
- //selftest_result.text = ""
- text = "开始"
- readbutton.enabled = true;
- adjustbutton.enabled = true;
- //timer.stop()
- }
- }
- }
- }
- Text {
- id: selftest_state
- anchors.verticalCenter: parent.verticalCenter
- text: qsTr("自测状态:")+selfTest_State_str
- font.pixelSize: 20
- }
- Text {
- id: selftest_result
- anchors.verticalCenter: parent.verticalCenter
- text: qsTr("自测结果:")+selfTest_Result_str
- font.pixelSize: 20
- }
- }
- }
- }
- }
- // }
- }
|