47 lines
1.6 KiB
Java
47 lines
1.6 KiB
Java
|
|
package com.cbsd.client.branch;
|
|||
|
|
|
|||
|
|
import com.cbsd.client.branch.IBranchConditionInterface;
|
|||
|
|
|
|||
|
|
import java.util.Map;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 分支条件脚本示例, 实现 IBranchConditionInterface 接口
|
|||
|
|
* 根据通道绑定的ICD的协议中的字段,对数据进行判断返回需要跳转的指令名称
|
|||
|
|
*/
|
|||
|
|
public class BranchConditionTemplate implements IBranchConditionInterface {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 分支条件
|
|||
|
|
*
|
|||
|
|
* @param originalCommand 原始指令数据
|
|||
|
|
* @param preTreatmentCommand 预处理指令数据,若无预处理,则为原始指令数据
|
|||
|
|
* @param repeatCount 重复次数
|
|||
|
|
* @param hitCount 命中次数
|
|||
|
|
* @param latestHitTime 最后命中时间
|
|||
|
|
* @param dataMap 数据集合,key为协议字段属性名(label),value为物理值
|
|||
|
|
* @return 需要跳转的指令名称,为空则为不跳转
|
|||
|
|
*/
|
|||
|
|
@Override
|
|||
|
|
public String branchCondition(String originalCommand, String preTreatmentCommand, int repeatCount, int hitCount, String latestHitTime, Map<String, String> dataMap) {
|
|||
|
|
String temperatureStr = dataMap.get("temperature");
|
|||
|
|
if (temperatureStr != null && !temperatureStr.isEmpty()){
|
|||
|
|
double temperature = Double.parseDouble(temperatureStr);
|
|||
|
|
if (temperature > 25){
|
|||
|
|
//此处为指令名称
|
|||
|
|
return "打开降温指令";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 描述
|
|||
|
|
*
|
|||
|
|
* @return 描述内容
|
|||
|
|
*/
|
|||
|
|
@Override
|
|||
|
|
public String comment() {
|
|||
|
|
return "当温度高于25摄氏度时跳转 打开降温指令";
|
|||
|
|
}
|
|||
|
|
}
|