package com.fzzy.protocol.bhzn.v0.cmd;
|
|
|
import com.fzzy.api.utils.BytesUtil;
|
import com.fzzy.protocol.bhzn.v0.server.BhznGrainV0ServerUtils;
|
|
/**
|
* 命令生成
|
*
|
* @author vince
|
*/
|
public class CommandBuild {
|
|
private final static CommandBuild instance = new CommandBuild();
|
|
private CommandBuild() {
|
}
|
|
public static CommandBuild getInstance() {
|
return instance;
|
}
|
|
/**
|
* PC回复 心跳啊 收到信息
|
*
|
* @param grainAddr
|
* @return
|
*/
|
public static String getMsgHeartReply(String grainAddr) {
|
|
StringBuffer sb = new StringBuffer();
|
|
//开始符号
|
sb.append(BhznGrainV0ServerUtils.MSG_START);
|
sb.append(BhznGrainV0ServerUtils.MSG_START2);
|
|
//分机地址
|
int i = Integer.parseInt(grainAddr);
|
sb.append(BytesUtil.tran_LH(BytesUtil.intToHexStr(i)));
|
|
//发送方地址
|
sb.append("0001");
|
|
//命令ID
|
sb.append(BhznGrainV0ServerUtils.FUNCTION_ID_F2);
|
|
//数据长度-01
|
sb.append("01");
|
|
//数据区--任意值
|
sb.append("01");
|
|
//获取校验码
|
sb.append(BhznGrainV0ServerUtils.getCheck(sb.toString()));
|
|
//结尾符
|
sb.append(BhznGrainV0ServerUtils.MSG_END_16);
|
|
return sb.toString();
|
}
|
|
/**
|
* 粮情采集命令
|
*
|
* @param grainAddr 粮情分机地址
|
* @param deptId 仓库编号地址
|
* @return
|
*/
|
public static String getMsgCheck(String grainAddr, String deptId) {
|
|
StringBuffer sb = new StringBuffer();
|
|
//开始符号
|
sb.append(BhznGrainV0ServerUtils.MSG_START);
|
sb.append(BhznGrainV0ServerUtils.MSG_START2);
|
|
//分机地址
|
int i = Integer.parseInt(grainAddr);
|
sb.append(BytesUtil.tran_LH(BytesUtil.intToHexStr(i)));
|
|
//发送方地址
|
sb.append("0001");
|
|
//命令ID
|
sb.append(BhznGrainV0ServerUtils.FUNCTION_ID_83);
|
|
//数据长度-01
|
sb.append("01");
|
|
//数据区--主机里面配置的仓库编码
|
i = Integer.parseInt(deptId);
|
sb.append(BytesUtil.intToHexStr1(i));
|
|
//获取校验码
|
sb.append(BhznGrainV0ServerUtils.getCheck(sb.toString()));
|
|
//结尾符
|
sb.append(BhznGrainV0ServerUtils.MSG_END_16);
|
|
return sb.toString();
|
}
|
|
/**
|
* PC回复 仓温仓湿 收到信息
|
*
|
* @param grainAddr
|
* @return
|
*/
|
public static String getMsgTHReply(String grainAddr) {
|
|
StringBuffer sb = new StringBuffer();
|
|
//开始符号
|
// sb.append(BhznGrainV0ServerUtils.MSG_START);
|
sb.append(BhznGrainV0ServerUtils.MSG_START2);
|
|
//分机地址
|
int i = Integer.parseInt(grainAddr);
|
sb.append(BytesUtil.tran_LH(BytesUtil.intToHexStr(i)));
|
|
//发送方地址
|
sb.append("0001");
|
|
//命令ID
|
sb.append(BhznGrainV0ServerUtils.FUNCTION_ID_93);
|
|
//数据长度-01
|
sb.append("01");
|
|
//数据区--任意值
|
sb.append("01");
|
|
//获取校验码
|
sb.append(BhznGrainV0ServerUtils.getCheck(sb.toString()));
|
|
//结尾符
|
sb.append(BhznGrainV0ServerUtils.MSG_END_16);
|
|
return sb.toString();
|
}
|
|
/**
|
* PC回复粮温收到信息
|
*
|
* @param grainAddr
|
* @return
|
*/
|
public static String getMsgGrainReply(String grainAddr) {
|
StringBuffer sb = new StringBuffer();
|
|
//开始符号
|
sb.append(BhznGrainV0ServerUtils.MSG_START);
|
sb.append(BhznGrainV0ServerUtils.MSG_START2);
|
|
//分机地址
|
int i = Integer.parseInt(grainAddr);
|
sb.append(BytesUtil.tran_LH(BytesUtil.intToHexStr(i)));
|
|
//发送方地址
|
sb.append("0001");
|
|
//命令ID
|
sb.append(BhznGrainV0ServerUtils.FUNCTION_ID_92);
|
|
//数据长度-01
|
sb.append("01");
|
|
//数据区--任意值
|
sb.append("01");
|
|
//获取校验码
|
sb.append(BhznGrainV0ServerUtils.getCheck(sb.toString()));
|
|
//结尾符
|
sb.append(BhznGrainV0ServerUtils.MSG_END_16);
|
|
return sb.toString();
|
}
|
}
|