first commit

This commit is contained in:
lihansani
2026-07-13 13:39:10 +08:00
commit 5bbf1f5c78
391 changed files with 169766 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
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为协议字段属性名labelvalue为物理值
* @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摄氏度时跳转 打开降温指令";
}
}

View File

@@ -0,0 +1,45 @@
package com.cbsd.client.check;
import com.cbsd.client.check.ICheckInterface;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 检查脚本示例, 实现 ICheckInterface 接口
*/
public class CheckTemplate implements ICheckInterface {
/**
* 检查
*
* @param originalCommand 原始指令数据
* @param preTreatmentCommand 预处理指令数据,若无预处理,则为原始指令数据
* @param repeatCount 重复次数
* @param hitCount 命中次数
* @param latestHitTime 最后命中时间
* @param dataMap 数据集合key为协议字段属性名labelvalue为物理值
* @return 日志信息列表
*/
@Override
public List<String> check(String originalCommand, String preTreatmentCommand, int repeatCount, int hitCount, String latestHitTime, Map<String, String> dataMap) {
List<String> list = new ArrayList<>();
String temperatureStr = dataMap.get("temperature");
if (temperatureStr != null && !temperatureStr.isEmpty()) {
double temperature = Double.parseDouble(temperatureStr);
list.add("检查温度:" + temperature + "");
}
return list;
}
/**
* 描述
*
* @return 描述内容
*/
@Override
public String comment() {
return "打印检查日志";
}
}

View File

@@ -0,0 +1,49 @@
package com.cbsd.client.parse;
import com.cbsd.client.parse.IParseDataInterface;
import java.util.ArrayList;
import java.util.List;
/**
* 解析脚本示例, 实现 IParseDataInterface 接口
*/
public class ParseTemplate implements IParseDataInterface{
/**
* 从数据解析物理值
*
* @param sn 当前字段序号
* @param sourceData 源数据
* @param fieldData 当前字段数据
* @param endian BIG大端序 LITTLE小端序
* @param binStr 二进制字符串
* @return 解析后的数据值
*/
@Override
public String parsePhysicalFromData(int sn, byte[] sourceData, byte[] fildData, String endian, String binStr) {
List<String> serialPortDataHexList = new ArrayList<>();
for (byte b : fildData) {
int h = (b >>> 4) & 0xF;
int l = b & 0xF;
char ch = (char) ((h < 10) ? ('0' + h) : ('A' + h - 10));
char cl = (char) ((l < 10) ? ('0' + l) : ('A' + l - 10));
String sb = String.valueOf(ch) + cl;
serialPortDataHexList.add(sb);
}
//温度
String temperatureChar = serialPortDataHexList.get(0) + serialPortDataHexList.get(1);
double temperature = Integer.parseInt(temperatureChar, 16) / 10.0;
return String.valueOf(temperature);
}
/**
* 描述
*
* @return 描述内容
*/
@Override
public String comment() {
return "温湿度解析第一个字节乘256+第二个字节结果除10";
}
}

View File

@@ -0,0 +1,45 @@
package com.cbsd.client.pretreatment;
import com.cbsd.client.pretreatment.CalculateUtils;
import com.cbsd.client.pretreatment.IPreTreatmentInterface;
import java.util.Map;
/**
* 预处理脚本示例, 实现 IPreTreatmentInterface 接口
* 累加预处理
*/
public class PreTreatmentTemplate implements IPreTreatmentInterface {
/**
* 预处理
*
* @param command 指令内容
* @param repeatCount 重复次数
* @param hitCount 命中次数
* @param latestHitTime 最后命中时间
* @param dataMap 数据集合key为协议字段属性名labelvalue为物理值
* @param calculateUtils 计算工具类
* @return 结果
*/
@Override
public String pretreatment(String command, int repeatCount, int hitCount, String latestHitTime, Map<String, String> dataMap, CalculateUtils calculateUtils) {
String resultCommand = "";
if (hitCount < 10) {
resultCommand += "0" + hitCount;
} else {
resultCommand = String.valueOf(hitCount);
}
return resultCommand;
}
/**
* 描述
*
* @return 描述内容
*/
@Override
public String comment() {
return "根据命中次数累加拼接";
}
}

View File

@@ -0,0 +1,42 @@
package com.cbsd.client.verification;
import com.cbsd.client.verification.IVerificationInterface;
import com.cbsd.client.verification.VerifyUtils;
/**
* 校验脚本示例, 实现 IVerificationInterface 接口
*/
public class VerificationTemplate implements IVerificationInterface {
/**
* 校验数据
*
* @param data 校验数据
* @param verify 校验位
* @param verifyUtils 校验工具类
* @return 校验结果
*/
@Override
public boolean verification(byte[] data, byte[] verify, VerifyUtils verifyUtils) {
try {
byte[] verifyCRC = new byte[data.length + verify.length];
System.arraycopy(data, 0, verifyCRC, 0, data.length);
System.arraycopy(verify, 0, verifyCRC, data.length, verify.length);
return verifyUtils.verifyCRC(verifyCRC);
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 描述
*
* @return 描述内容
*/
@Override
public String comment() {
return "";
}
}

Binary file not shown.