.import "modbus.js" as ModbusJs


var running = false
var runningBackup = false
var openPressureTimeMax = 30
var sealPressureTimemax = 15
var exit = false

var capsizeOpenPresure = 10
var capsizeSetPressure = 32

function positiveTestStop(controlSerial,pressureDisplaySigFun,spy,log){

    ModbusJs.pressureSensorCtrl(controlSerial,"高压")
    console.log("打开高压传感器阀门")
    //关闭正压罐进气阀门
    ModbusJs.positivePressureTankInputCtrl(controlSerial,false)
    console.log("关闭正压罐进气阀门")
    //打开正压罐头泄气阀门
    ModbusJs.positivePressureTankOutputCtrl(controlSerial,true)
    console.log("打开正压罐头泄气阀门")
    //查看高压传感器值 等待正压罐头压力降到最低值
    var timeout = 0
    do{
        //重新开始时 停止测试
        if(runningBackup === false && running === true){
            console.log("停止测试")
            ModbusJs.closeAllValve(controlSerial)
            return
        }
        if(exit === true)
            return


        var obj = ModbusJs.highPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("高压传感器通讯错误")
            return false
        }
        // signal 压力显示函数
        pressureDisplaySigFun(obj.pressureNumber)
        //延时
        spy.wait(900)
        timeout++

    }while(obj.pressureNumber > 0.1 && timeout < 180)
    ModbusJs.closeAllValve(controlSerial)
    console.log("关闭 关闭所有阀门")
}

function negativeTestStop(controlSerial,pressureDisplaySigFun,spy,log){

    //打开负压呼吸阀测试口阀门 逻辑有改变 从一开始就打开 不然无法泄压
    ModbusJs.nbreathValveTestIo(controlSerial,true)
    console.log("打开负压呼吸阀测试口阀门")
    //关闭负压罐进气阀门
    ModbusJs.negativePressureTankInputCtrl(controlSerial,false)
    console.log("关闭负压罐进气阀门")
    //关闭 负压泵
    ModbusJs.negativePumpPowerCtrl(controlSerial,false)
    console.log("关闭 负压泵")
    //打开负压罐头泄气阀门
    ModbusJs.negativePressureTankOutputCtrl(controlSerial,true)
    console.log("打开负压罐头泄气阀门")
    //查看负压传感器值 等待负压罐头压力降到最低值
    var timeout = 0
    do{
        //重新开始时 停止测试
        if(runningBackup === false && running === true){
            console.log("停止测试")
            ModbusJs.closeAllValve(controlSerial)
            return
        }
        if(exit === true)
            return

        //var obj = ModbusJs.negativePressureSensorReadReq(sensorSerial)
        var obj =ModbusJs.lowPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("低压传感器通讯错误")
            return false
        }
        // signal 压力显示函数
        pressureDisplaySigFun(obj.pressureNumber)
        //延时
        spy.wait(900)
        timeout++
    }while(obj.pressureNumber < -0.1 && timeout < 180)
    ModbusJs.closeAllValve(controlSerial)
    console.log("关闭 关闭所有阀门")
}



//正压开启压力和密封试验
/*  openPressureModel       测试开启压力过程表模型
 *  sealPressureModel       测试密封压力过程表模型
 *  pressureDisplaySigFun   压力显示信号函数
 *  resultSigFun            结果显示信号函数
 */
function positiveTestStart(currentIndex,tabView,processWindow,controlSerial,sensorSerial,openPressureModel,sealPressureModel,pressureDisplaySigFun,resultSigFun,spy,log){

    var setPressure = 20
    //自检
    runningBackup = running
    var openPressureNumber
    var sealPressureNumber

    //setp 1
    // 关闭所有测试口
    ModbusJs.turnOffAllTestIO(controlSerial)
    console.log("关闭所有测试口")
    ModbusJs.pressureSensorCtrl(controlSerial,"高压")
    console.log("打开高压传感器阀门")
    //关闭正压罐进气阀门
    ModbusJs.positivePressureTankInputCtrl(controlSerial,false)
    console.log("关闭正压罐进气阀门")
    //setp 2
    //查看低压传感器值 等待正压罐头压力降到最低值
    processWindow.show("等待压力降到0")
    //打开正压罐头泄气阀门
    ModbusJs.positivePressureTankOutputCtrl(controlSerial,true)
    console.log("打开正压罐头泄气阀门")
    var timeout = 0
    do{
        if(running === false){
            console.log("停止测试")
            return false
        }
        var obj = ModbusJs.highPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("高压传感器通讯错误")
            return false
        }
        // signal 压力显示函数
        pressureDisplaySigFun(obj.pressureNumber)
        //延时
        spy.wait(900)
        timeout++
    }while(obj.pressureNumber > 0.1 && timeout < 180)
    if(timeout === 180){
        log.show("泄压超时")
        ModbusJs.closeAllValve(controlSerial)
        console.log("关闭所有阀门")
        return false
    }
    console.log("压力降压到 0 kPa")

    //setp 3
    /*********测试开启压力*************/
    ModbusJs.pressureSensorCtrl(controlSerial,"低压")
    console.log("打开低压传感器阀门")
    obj = ModbusJs.testFixedPressure(controlSerial,setPressure)
    ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
    console.log("比例调压阀压力值:",obj.voltage)

    var bigAcive = true
    ModbusJs.bigTuningValveControl(controlSerial,true)
    console.log("打开 粗调开关")

    processWindow.show("开启压力试验开始")
    console.log("开启压力测试开始")
//    //打开正压呼吸阀测试口阀门
//    ModbusJs.pbreathValveTestIo(controlSerial,true)
//    console.log("打开正压呼吸阀测试口阀门")
    //关闭正压罐头泄气阀门
    ModbusJs.positivePressureTankOutputCtrl(controlSerial,false)
    console.log("关闭正压罐头泄气阀门")
    //打开进气阀门
    ModbusJs.positivePressureTankInputCtrl(controlSerial,true)
    console.log("打开进气阀门")
    tabView.currentIndex = currentIndex
    var openCnt = 0
    var min = 0
    var max = 100  //低压最大范围
    var prevTime  = Date.now()
    do{
        if(running === false){
            console.log("停止测试")
            return false
        }
        //obj = ModbusJs.lowPressureSensorReadReq(sensorSerial)
        obj = ModbusJs.lowPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("低压传感器通讯错误")
            return false
        }

        //粗调压力值
        var bigLevel = setPressure-1
        //达到压力值时打开测试口
        if(obj.pressureNumber > bigLevel && bigAcive === true){
            bigAcive = false
            ModbusJs.bigTuningValveControl(controlSerial,false)
            ModbusJs.bigTuningValveControl(controlSerial,false)
            console.log("关闭 粗调开关")
            //打开正压呼吸阀测试口阀门
            ModbusJs.pbreathValveTestIo(controlSerial,true)
            console.log("打开正压呼吸阀测试口阀门")
        }

        spy.wait(10)
        var curTime  = Date.now()
        var deltaTime = curTime - prevTime
        if(deltaTime > 900){
            prevTime = curTime
            openCnt++
            pressureDisplaySigFun(obj.pressureNumber)
            // add  pressure table
            var table={}
            table.pressure=obj.pressureNumber
            //开启压力模型赋值
            openPressureModel.append(table)
           // console.log("openPressureTimeMax:",openPressureTimeMax)
            processWindow.text("开启压力试验时间"+(openPressureTimeMax-openCnt)+"s")
        }

    }while(obj.pressureNumber <=max && openCnt < openPressureTimeMax)

    //正压：6～12kPa  得到开启压力
    if(obj.pressureNumber >=min &&  obj.pressureNumber <= max && openCnt ===openPressureTimeMax){
        openPressureNumber = obj.pressureNumber.toString()
        var result={}
        result.openPressureNumber = openPressureNumber
        result.sealPressureNumber = ""
        resultSigFun(result)
        console.log("开启压力:",openPressureNumber)
    }
    else{
        if(obj.pressureNumber < min){
            openPressureNumber=obj.pressureNumber+"<"+min+"kPa"
        }
        else if(obj.pressureNumber > max){
            openPressureNumber=obj.pressureNumber+">"+max+"kPa"
        }

        result={}
        result.openPressureNumber = openPressureNumber
        result.sealPressureNumber = ""
        resultSigFun(result)

        //关闭正压罐进气阀门
        ModbusJs.positivePressureTankInputCtrl(controlSerial,false)
        console.log("关闭正压罐进气阀门")
        console.log("开启压力:",openPressureNumber)
        console.log("开启压力测试结束")

        return false
    }
    console.log("开启压力测试结束")

    //setp 4
    /*********测试密封压力*************/
    console.log("密封压力开始")
    processWindow.show("密封压力试验开始")
    //关闭正压罐进气阀门
    ModbusJs.positivePressureTankInputCtrl(controlSerial,false)
    console.log("关闭正压罐进气阀门")
    //保持600s
    var holdTimeCnt=0
    tabView.currentIndex = currentIndex+3
    do{
        if(running === false){
            console.log("停止测试")
            return false
        }
        //obj = ModbusJs.lowPressureSensorReadReq(sensorSerial)
        obj = ModbusJs.lowPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("低压传感器通讯错误")
            return false
        }
        //密封压力模型赋值
        table={}
        table.pressure=obj.pressureNumber
        sealPressureModel.append(table)
        //压力实时显示
        pressureDisplaySigFun(obj.pressureNumber)
        spy.wait(900)
        holdTimeCnt++
        processWindow.text("密封压力试验时间"+(sealPressureTimemax-holdTimeCnt)+"s")
    }while(holdTimeCnt < sealPressureTimemax ) //传感器值是否能一直稳定住？？？？？？

    sealPressureNumber = obj.pressureNumber.toString()
    result={}
    result.openPressureNumber = openPressureNumber
    result.sealPressureNumber = sealPressureNumber
    resultSigFun(result)
    console.log("密封压力结束")


    //setp 5
    ModbusJs.pressureSensorCtrl(controlSerial,"高压")
    console.log("打开高压传感器阀门")
    //打开正压罐头泄气阀门
    ModbusJs.positivePressureTankOutputCtrl(controlSerial,true)
    console.log("打开正压罐头泄气阀门")
    console.log("等待压力 0kPa")
    //查看低压传感器值 等待正压罐头压力降到最低值
    processWindow.show("试验结束，泄气中")
    timeout = 0
    do{
        if(running === false){
            console.log("停止测试")
            return false
        }

        obj = ModbusJs.highPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("高压传感器通讯错误")
            return false
        }
        // signal 压力显示函数
        pressureDisplaySigFun(obj.pressureNumber)
        //延时
        spy.wait(900)
        timeout++
    }while(obj.pressureNumber > 0.1 && timeout < 180)

    //关闭正压罐头泄气阀门

    //setp 6
    console.log("压力 0kPa")
    ModbusJs.closeAllValve(controlSerial)
    console.log("关闭所有阀门")

    return true

}
//负压开启压力和密封试验
/*  openPressureModel       测试开启压力过程表模型
 *  sealPressureModel       测试密封压力过程表模型
 *  pressureDisplaySigFun   压力显示信号函数
 *  resultSigFun            结果显示信号函数
 */

function negativeTestStart(currentIndex,tabView,processWindow,controlSerial,sensorSerial,
                           openPressureModel,sealPressureModel,
                           pressureDisplaySigFun,resultSigFun,spy,log)
{

    runningBackup = running
    //自检
    var openPressureNumber
    var sealPressureNumber
    //setp 1
    // 关闭所有测试口
    ModbusJs.negativePumpPowerCtrl(controlSerial,false)
    console.log("关闭 负压泵")
    ModbusJs.turnOffAllTestIO(controlSerial)
    console.log("关闭所有测试口")
    //打开负压呼吸阀测试口阀门 逻辑有改变 从一开始就打开 不然无法泄压
    ModbusJs.nbreathValveTestIo(controlSerial,true)
    console.log("打开负压呼吸阀测试口阀门")
    ModbusJs.pressureSensorCtrl(controlSerial,"负压")
    console.log("打开负压传感器阀门")
    //关闭负压罐进气阀门
    ModbusJs.negativePressureTankInputCtrl(controlSerial,false)
    console.log("关闭负压罐进气阀门 微调")
    processWindow.show("等待压力到0kPa")
    //打开负压罐头泄气阀门
    ModbusJs.negativePressureTankOutputCtrl(controlSerial,true)
    console.log("打开负压罐头泄气阀门")
    //setp 2
    //查看负压传感器值 等待负压压罐头压力至0kPa
    var timeout = 0
    do{
        if(running === false){
            console.log("停止测试")
            return false
        }
        //var obj = ModbusJs.negativePressureSensorReadReq(sensorSerial)
        var obj =ModbusJs.lowPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("低压传感器通讯错误")
            return false
        }
        //signal 压力显示函数
        console.log(obj.pressureNumber)
        pressureDisplaySigFun(obj.pressureNumber)
        //延时
        spy.wait(900)
        timeout++
    }while(obj.pressureNumber < 0 && timeout < 180)
    if(timeout === 180){
        log.show("泄压超时")
        ModbusJs.closeAllValve(controlSerial)
        console.log("关闭所有阀门")
        return false
    }
    console.log("压力到 0 kPa")

    //setp 3
    /*********测试开启压力*************/
    ModbusJs.negativePumpPowerCtrl(controlSerial,true)
    console.log("打开 负压泵")
    processWindow.show("开启压力试验开始")
    console.log("开启压力测试开始")
    //打开负压呼吸阀测试口阀门 全称微调 不需要打开 逻辑有改变
//    ModbusJs.nbreathValveTestIo(controlSerial,true)
//    console.log("打开负压呼吸阀测试口阀门")
    //关闭负压罐泄气阀门
    ModbusJs.negativePressureTankOutputCtrl(controlSerial,false)
    console.log("关闭负压罐泄气阀门")
    //关闭 负压罐进气阀门
    ModbusJs.negativePressureTankInputCtrl(controlSerial,false)
    console.log("关闭负压罐进气阀门 微调")
    tabView.currentIndex = currentIndex
    var openCnt = 0
    //    var min = -4
    //    var max = -2
    var min = -10
    var max = 5

    do{
        if(running === false){
            console.log("停止测试")
            return false
        }

        //obj = ModbusJs.negativePressureSensorReadReq(sensorSerial)
        obj =ModbusJs.lowPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("负压传感器通讯错误")
            return false
        }
        pressureDisplaySigFun(obj.pressureNumber)
        // add  pressure table
        var table={}
        table.pressure=obj.pressureNumber
        //开启压力模型赋值
        openPressureModel.append(table)
        spy.wait(900)
        openCnt++
        //console.log("openCnt:",openCnt)
        processWindow.text("开启压力试验时间"+(openPressureTimeMax-openCnt)+"s")
    }while(obj.pressureNumber >= min && openCnt < openPressureTimeMax)

    //得到开启压力
    if(obj.pressureNumber >=min &&  obj.pressureNumber <= max && openCnt ===openPressureTimeMax){
        openPressureNumber = obj.pressureNumber.toString()
        var result={}
        result.openPressureNumber = openPressureNumber
        result.sealPressureNumber = ""
        resultSigFun(result)
        console.log("开启压力:",openPressureNumber)
    }
    else{
        if(obj.pressureNumber < min){
            openPressureNumber=obj.pressureNumber+"<"+min
        }
        else if(obj.pressureNumber > max){
            openPressureNumber=obj.pressureNumber+">"+max
        }

        result={}
        result.openPressureNumber = openPressureNumber
        result.sealPressureNumber = ""
        resultSigFun(result)

        //关闭负压罐进气阀门
        ModbusJs.negativePressureTankInputCtrl(controlSerial,false)
        console.log("关闭负压罐进气阀门 微调")
        console.log("开启压力:",openPressureNumber)
        console.log("开启压力测试结束")
        return false
    }
    console.log("开启压力测试结束")

    //setp 4
    /*********测试密封压力*************/
    console.log("密封压力开始")
    processWindow.show("密封压力试验开始")
    //关闭负压罐进气阀门
    ModbusJs.negativePressureTankInputCtrl(controlSerial,false)
    console.log("关闭负压罐进气阀门 微调")
    ModbusJs.negativePumpPowerCtrl(controlSerial,false)
    console.log("关闭 负压泵")

    var holdTimeCnt=0
    tabView.currentIndex =currentIndex+3
    do{
        if(running === false){
            console.log("停止测试")
            return false
        }
        obj =ModbusJs.lowPressureSensorReadReq(sensorSerial)
        //obj = ModbusJs.negativePressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("负压传感器通讯错误")
            return false
        }
        //密封压力模型赋值
        table={}
        table.pressure=obj.pressureNumber
        sealPressureModel.append(table)
        //压力实时显示
        pressureDisplaySigFun(obj.pressureNumber)
        spy.wait(900)
        holdTimeCnt++
        processWindow.text("密封压力试验时间"+(sealPressureTimemax-holdTimeCnt)+"s")
    }while(holdTimeCnt < sealPressureTimemax )

    sealPressureNumber = obj.pressureNumber.toString()
    result={}
    result.openPressureNumber = openPressureNumber
    result.sealPressureNumber = sealPressureNumber
    resultSigFun(result)
    console.log("密封压力结束")


    //setp 5
    //关闭负压罐进气阀门
    ModbusJs.negativePressureTankInputCtrl(controlSerial,false)
    console.log("关闭负压罐进气阀门 微调")
    //打开负压罐头泄气阀门
    ModbusJs.negativePressureTankOutputCtrl(controlSerial,true)
    console.log("打开负压罐头泄气阀门")
    ModbusJs.negativePumpPowerCtrl(controlSerial,false)
    console.log("关闭 负压泵")
    console.log("等待压力 0kPa")
    //查看负压传感器值 等待负压罐到0kPa
    processWindow.show("试验结束，泄气中")
    timeout = 0
    do{
        if(running === false){
            console.log("停止测试")
            return
        }
        obj =ModbusJs.lowPressureSensorReadReq(sensorSerial)
        //obj = ModbusJs.negativePressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("负压传感器通讯错误")
            return false
        }
        // signal 压力显示函数
        pressureDisplaySigFun(obj.pressureNumber)
        //延时
        spy.wait(900)
        timeout++
    }while(obj.pressureNumber < 0  && timeout<180)
    //关闭负压罐头泄气阀门

    //setp 6
    console.log("压力 0kPa")
    ModbusJs.closeAllValve(controlSerial)
    console.log("关闭所有阀门")
    return true

}




//倾覆性密封试验
function capsizeTestStart(processWindow,controlSerial,sensorSerial,
                          sealPressureModel,pressureDisplaySigFun,resultSigFun,spy,log)
{
    //setp 1
    // 关闭所有测试口
    ModbusJs.turnOffAllTestIO(controlSerial)
    console.log("关闭所有测试口")
    ModbusJs.pressureSensorCtrl(controlSerial,"高压")
    console.log("打开高压传感器阀门")
    //关闭正压罐进气阀门
    ModbusJs.positivePressureTankInputCtrl(controlSerial,false)
    console.log("关闭正压罐进气阀门")
    //setp 2
    //查看高压传感器值 等待正压罐头压力降到最低值
    processWindow.show("等待压力降到0")
    //打开正压罐头泄气阀门
    ModbusJs.positivePressureTankOutputCtrl(controlSerial,true)
    console.log("打开正压罐头泄气阀门")
    var timeout = 0
    do{
        if(running === false){
            console.log("停止测试")
            return false
        }
        var obj = ModbusJs.highPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("高压传感器通讯错误")
            return false
        }
        // signal 压力显示函数
        pressureDisplaySigFun(obj.pressureNumber)
        //延时
        spy.wait(900)
        timeout++
    }while(obj.pressureNumber > 0.1 && timeout < 180)
    console.log("压力降压到 0 kPa")
    if(timeout === 180){
        log.show("泄压超时")
        ModbusJs.closeAllValve(controlSerial)
        console.log("关闭所有阀门")
        return false
    }

    //setp 3
    /*********调整压力*************/
    processWindow.show("进气压力"+capsizeSetPressure+"kPa")
    ModbusJs.pressureSensorCtrl(controlSerial,"低压")
    console.log("打开低压传感器阀门")
    obj = ModbusJs.testFixedPressure(controlSerial,capsizeSetPressure+2)
    ModbusJs.proportionalControlWrite(controlSerial,obj.voltage)
    console.log("比例调压阀压力值:",obj.voltage)
    //关闭正压罐头泄气阀门
    ModbusJs.positivePressureTankOutputCtrl(controlSerial,false)
    console.log("关闭正压罐头泄气阀门")
    //打开进气阀门
    ModbusJs.positivePressureTankInputCtrl(controlSerial,true)
    console.log("打开进气阀门")
    var cnt = 0
    var prevTime  = Date.now()
    var bigAcive = true
    var max = 50
    ModbusJs.bigTuningValveControl(controlSerial,true)
    console.log("开启 粗调开关")
    do{
        if(running === false){
            console.log("停止测试")
            return false
        }
        obj = ModbusJs.lowPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("低压传感器通讯错误")
            return false
        }



        spy.wait(10)
        var curTime  = Date.now()
        var deltaTime = curTime - prevTime
        if(deltaTime > 900){
            prevTime = curTime
            pressureDisplaySigFun(obj.pressureNumber)
            cnt++
        }

        //粗调压力值
        var bigLevel = capsizeSetPressure-1
        if(obj.pressureNumber > bigLevel && bigAcive === true){
            bigAcive = false
            ModbusJs.bigTuningValveControl(controlSerial,false)
            ModbusJs.bigTuningValveControl(controlSerial,false)
            console.log("关闭 粗调开关")
            break;
        }

//        pressureDisplaySigFun(obj.pressureNumber)
//        spy.wait(900)
//        cnt++
//        console.log("obj.pressureNumber:",obj.pressureNumber)
    }while(obj.pressureNumber <= max && cnt < 180 )
    if(cnt === 180){
        log.show("进气时间超时")
        return false
    }

    //setp 3
    /*********密封试验开始*************/
    processWindow.show("密封压力试验开始")
    console.log("密封压力试验开始")
    //关闭进气阀门
    ModbusJs.positivePressureTankInputCtrl(controlSerial,false)
    console.log("关闭进气阀门")
    //打开正压呼吸阀测试口阀门
    ModbusJs.pbreathValveTestIo(controlSerial,true)
    console.log("打开正压呼吸阀测试口阀门")

    cnt = 0
    do{
        if(running === false){
            console.log("停止测试")
            return false
        }
        obj = ModbusJs.lowPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("低压传感器通讯错误")
            return false
        }
        pressureDisplaySigFun(obj.pressureNumber)
        // add  pressure table
        var table={}
        table.pressure=obj.pressureNumber
        //密封模型赋值
        sealPressureModel.append(table)
        spy.wait(900)
        cnt++
        processWindow.text("密封压力试验时间"+(sealPressureTimemax-cnt)+"s")
    }while( cnt < sealPressureTimemax )
    var result={}
    result.sealPressureNumber = obj.pressureNumber
    resultSigFun(result)

    //setp 5
    processWindow.show("试验结束，泄气中")
    ModbusJs.pressureSensorCtrl(controlSerial,"低压")
    console.log("打开低压传感器阀门")
    //打开正压罐头泄气阀门
    ModbusJs.positivePressureTankOutputCtrl(controlSerial,true)
    console.log("打开正压罐头泄气阀门")
    //关闭进气阀门
    ModbusJs.positivePressureTankInputCtrl(controlSerial,false)
    console.log("关闭进气阀门")
    console.log("等待压力 0kPa")
    //查看高压传感器值 等待正压罐头压力降到最低值
    timeout =0
    do{
        if(running === false){
            console.log("停止测试")
            return false
        }
        obj = ModbusJs.lowPressureSensorReadReq(sensorSerial)
        if(obj.ret === false){
            log.show("低压传感器通讯错误")
            return false
        }
        // signal 压力显示函数
        pressureDisplaySigFun(obj.pressureNumber)
        //延时
        spy.wait(900)
        timeout++
    }while(obj.pressureNumber > 0.1  && timeout < 180)

    //setp 6
    console.log("压力 0kPa")
    ModbusJs.closeAllValve(controlSerial)
    console.log("关闭所有阀门")

    return true


}














