Skip to content

2.1:季节模式参数自动切换

场景:根据“夏季/冬季”模式开关,自动切换暖通空调系统运行参数。
运算:
当Season == “Summer“时,执行 供水温度设定 = 7℃;回水温度设定 = 12℃。
当Season == “Winter“时,执行 供水温度设定 = 45℃;回水温度设定 = 40℃。
目的:实现运行模式的“一键切换”,避免人工逐个修改参数,确保系统按最优工况运行。

javascript
const {getVariant,executeSql,exePgSqlR,exePgSqlCUD,exeSqliteSqlR,exeSqliteSqlCUD,getCurrentOrLastValue,setVariantValue,watch,watchAlarm,table,executeDataSourceSql,sendWxTextMessage,sendWxMessage,sendDingTextMessage,sendDingMessage,alarm } = require("GlobalConfig");//头文件请勿删除
const {getFormulaGroupList,getFormulaList,delFormula,getLastDownFormula,addFormula,editFormula,downloadFormula} = require("FormulaApi");//头文件请勿删除

// 需要监听的变量
const watchKeys = ["Season"]

/**
 * 监听变量的值变化事件
 * @param {Array} names 变量名数组
 * @param {Function} callback 回调函数
 */
watch(watchKeys, (name, value) => {
    if( `Season`.value === 'Summer' ){
        `供水温度设定`.value  = "7℃"
        `回水温度设定`.value  = "12℃"
    }  else if ( value === 'Winter' ) {
        `供水温度设定`.value  = "45℃"
        `回水温度设定`.value  = "40℃"
    }
});

2.2:下班模式顺序关机

场景:接收到下班信号后,按安全顺序延时关闭厂房内各区域设备。
运算:
WorkEnd == 1触发。
立即关闭所有空调主机。
延时5分钟后,关闭车间照明。
再延时2分钟后,关闭非必要电源插座回路。
目的:实现自动化、顺序化的节能关机,保障设备安全(如让空调冷凝器有足够时间散热),避免能源浪费。

javascript
const {getVariant,executeSql,exePgSqlR,exePgSqlCUD,exeSqliteSqlR,exeSqliteSqlCUD,getCurrentOrLastValue,setVariantValue,watch,watchAlarm,table,executeDataSourceSql,sendWxTextMessage,sendWxMessage,sendDingTextMessage,sendDingMessage,alarm } = require("GlobalConfig");//头文件请勿删除
const {getFormulaGroupList,getFormulaList,delFormula,getLastDownFormula,addFormula,editFormula,downloadFormula} = require("FormulaApi");//头文件请勿删除

// 需要监听的变量
const watchKeys = ["WorkEnd"]
let timer1 = null
let timer2 = null

/**
 * 监听变量的值变化事件
 * @param {Array} names 变量名数组
 * @param {Function} callback 回调函数
 */
watch(watchKeys, (name, value) => {
    if( `WorkEnd`.value === 1){
        // 接收到下班信号后,按安全顺序延时关闭厂房内各区域设备。
        `空调主机状态`.value = 0

        // 清除未执行完成的定时器
        if ( timer1 ) {
            clearTimeout(timer1)
            timer1 = null
        }
        if ( timer2 ) {
            clearTimeout(timer2)
            timer2 = null
        }

        // 开启定时器,延时关闭
        // 五分钟之后关闭
        timer1 = setTimeout(()=> {
            `车间照明状态`.value = 0
            timer1 = null
        }, 5 * 60 * 1000)
        // 七分钟之后关闭
        timer2 = setTimeout(()=> {
            `非必要电源插座回路状态`.value = 0
            timer2 = null
        }, 7 * 60 * 1000)
    }
});

SCADA帮助文档