45 changed files with 2043 additions and 286 deletions
@ -0,0 +1,127 @@ |
|||
package com.xr.iec61850clent.models.entity; |
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 摄像头管理 |
|||
* |
|||
* @TableName device_camera |
|||
*/ |
|||
@TableName(value = "device_camera") |
|||
@Data |
|||
public class DeviceCamera implements Serializable { |
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@TableId(type = IdType.AUTO) |
|||
private Integer id; |
|||
|
|||
/** |
|||
* 摄像头编号 |
|||
*/ |
|||
private String deviceNo; |
|||
|
|||
/** |
|||
* 类型(1 usb 2 mipi 3 球机 4 枪机) |
|||
*/ |
|||
private String deviceType; |
|||
|
|||
/** |
|||
* IP |
|||
*/ |
|||
private String deviceIp; |
|||
|
|||
/** |
|||
* 端口 |
|||
*/ |
|||
private String devicePort; |
|||
|
|||
/** |
|||
* 账号 |
|||
*/ |
|||
private String account; |
|||
|
|||
/** |
|||
* 密码 |
|||
*/ |
|||
private String password; |
|||
|
|||
private String x; |
|||
|
|||
private String y; |
|||
|
|||
private String z; |
|||
|
|||
/** |
|||
* 摄像头型号 |
|||
*/ |
|||
private String deviceModel; |
|||
|
|||
/** |
|||
* 安装位置 |
|||
*/ |
|||
private String position; |
|||
|
|||
/** |
|||
* 品牌 |
|||
*/ |
|||
private String brand; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
private String remarks; |
|||
|
|||
/** |
|||
* 状态(0未使用 1已使用) |
|||
*/ |
|||
private String status; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createUser; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createTime; |
|||
|
|||
/** |
|||
* 修改人 |
|||
*/ |
|||
private String updateUser; |
|||
|
|||
/** |
|||
* 修改时间 |
|||
*/ |
|||
private Date updateTime; |
|||
|
|||
/** |
|||
* 传输间隔 |
|||
*/ |
|||
private Integer transmissionInterval; |
|||
|
|||
/** |
|||
* 对焦时间 |
|||
*/ |
|||
private Integer warmup; |
|||
|
|||
@TableField(exist = false) |
|||
private List<String> ids; |
|||
|
|||
@TableField(exist = false) |
|||
private static final long serialVersionUID = 1L; |
|||
/** |
|||
* 算法类型 |
|||
*/ |
|||
@TableField(exist = false) |
|||
private String algorithmType; |
|||
} |
|||
@ -0,0 +1,260 @@ |
|||
package com.xr.iec61850clent.models.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Arrays; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* @TableName focal_length_config |
|||
*/ |
|||
@TableName(value ="focal_length_config") |
|||
@Data |
|||
public class FocalLengthConfig implements Serializable { |
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@TableId(type = IdType.AUTO) |
|||
private Integer id; |
|||
|
|||
/** |
|||
* 表计配置编号 |
|||
*/ |
|||
private Integer configId; |
|||
|
|||
/** |
|||
* 焦距名称 |
|||
*/ |
|||
private String focalName; |
|||
|
|||
/** |
|||
* 焦距tabs下标 |
|||
*/ |
|||
private String focalIndex; |
|||
|
|||
/** |
|||
* 截图框宽 |
|||
*/ |
|||
private Double copperWid; |
|||
|
|||
/** |
|||
* 截图框高 |
|||
*/ |
|||
private Double copperHei; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Double copperX; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Double copperY; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Double copperX2; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Double copperY2; |
|||
|
|||
/** |
|||
* clock 1指针表计,2数字表计,3状态类 |
|||
*/ |
|||
private String configType; |
|||
|
|||
/** |
|||
* 表计范围起 |
|||
*/ |
|||
private Double meterMin; |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private Double meterMax; |
|||
|
|||
private Double scale; |
|||
|
|||
/** |
|||
* 旋转角度 |
|||
*/ |
|||
private Integer rotate; |
|||
|
|||
/** |
|||
* 状态类状态数量 |
|||
*/ |
|||
private Integer stateNum; |
|||
|
|||
/** |
|||
* 保存状态类多个状态的结果集 |
|||
*/ |
|||
private String parameter; |
|||
|
|||
/** |
|||
* 解析得测试结果 |
|||
*/ |
|||
private String result; |
|||
|
|||
/** |
|||
* 算法:0圆形表计1扇形表计 |
|||
*/ |
|||
private Integer algorithm; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createUser; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createTime; |
|||
|
|||
/** |
|||
* 修改人 |
|||
*/ |
|||
private String updateUser; |
|||
|
|||
@TableField(exist = false) |
|||
private String gb; |
|||
|
|||
@TableField(exist = false) |
|||
private String gbcs; |
|||
|
|||
@TableField(exist = false) |
|||
private Integer zzsl; |
|||
|
|||
@TableField(exist = false) |
|||
private String needleSeg; |
|||
|
|||
@TableField(exist = false) |
|||
private String invalidChars; |
|||
|
|||
@TableField(exist = false) |
|||
private Integer expectedLen; |
|||
|
|||
/** |
|||
* 修改时间 |
|||
*/ |
|||
private Date updateTime; |
|||
@TableField(exist = false) |
|||
private List<Map<String,String>> meterZz; |
|||
|
|||
/** |
|||
* 焦距图片 |
|||
*/ |
|||
private byte[] focalPicture; |
|||
|
|||
@TableField(exist = false) |
|||
private String basePicture; |
|||
|
|||
@TableField(exist = false) |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Override |
|||
public boolean equals(Object that) { |
|||
if (this == that) { |
|||
return true; |
|||
} |
|||
if (that == null) { |
|||
return false; |
|||
} |
|||
if (getClass() != that.getClass()) { |
|||
return false; |
|||
} |
|||
FocalLengthConfig other = (FocalLengthConfig) that; |
|||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) |
|||
&& (this.getConfigId() == null ? other.getConfigId() == null : this.getConfigId().equals(other.getConfigId())) |
|||
&& (this.getFocalName() == null ? other.getFocalName() == null : this.getFocalName().equals(other.getFocalName())) |
|||
&& (this.getFocalIndex() == null ? other.getFocalIndex() == null : this.getFocalIndex().equals(other.getFocalIndex())) |
|||
&& (this.getCopperWid() == null ? other.getCopperWid() == null : this.getCopperWid().equals(other.getCopperWid())) |
|||
&& (this.getCopperHei() == null ? other.getCopperHei() == null : this.getCopperHei().equals(other.getCopperHei())) |
|||
&& (this.getCopperX() == null ? other.getCopperX() == null : this.getCopperX().equals(other.getCopperX())) |
|||
&& (this.getCopperY() == null ? other.getCopperY() == null : this.getCopperY().equals(other.getCopperY())) |
|||
&& (this.getConfigType() == null ? other.getConfigType() == null : this.getConfigType().equals(other.getConfigType())) |
|||
&& (this.getMeterMin() == null ? other.getMeterMin() == null : this.getMeterMin().equals(other.getMeterMin())) |
|||
&& (this.getMeterMax() == null ? other.getMeterMax() == null : this.getMeterMax().equals(other.getMeterMax())) |
|||
&& (this.getRotate() == null ? other.getRotate() == null : this.getRotate().equals(other.getRotate())) |
|||
&& (this.getStateNum() == null ? other.getStateNum() == null : this.getStateNum().equals(other.getStateNum())) |
|||
&& (this.getParameter() == null ? other.getParameter() == null : this.getParameter().equals(other.getParameter())) |
|||
&& (this.getResult() == null ? other.getResult() == null : this.getResult().equals(other.getResult())) |
|||
&& (this.getAlgorithm() == null ? other.getAlgorithm() == null : this.getAlgorithm().equals(other.getAlgorithm())) |
|||
&& (this.getCreateUser() == null ? other.getCreateUser() == null : this.getCreateUser().equals(other.getCreateUser())) |
|||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) |
|||
&& (this.getUpdateUser() == null ? other.getUpdateUser() == null : this.getUpdateUser().equals(other.getUpdateUser())) |
|||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) |
|||
&& (Arrays.equals(this.getFocalPicture(), other.getFocalPicture())); |
|||
} |
|||
|
|||
@Override |
|||
public int hashCode() { |
|||
final int prime = 31; |
|||
int result = 1; |
|||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); |
|||
result = prime * result + ((getConfigId() == null) ? 0 : getConfigId().hashCode()); |
|||
result = prime * result + ((getFocalName() == null) ? 0 : getFocalName().hashCode()); |
|||
result = prime * result + ((getFocalIndex() == null) ? 0 : getFocalIndex().hashCode()); |
|||
result = prime * result + ((getCopperWid() == null) ? 0 : getCopperWid().hashCode()); |
|||
result = prime * result + ((getCopperHei() == null) ? 0 : getCopperHei().hashCode()); |
|||
result = prime * result + ((getCopperX() == null) ? 0 : getCopperX().hashCode()); |
|||
result = prime * result + ((getCopperY() == null) ? 0 : getCopperY().hashCode()); |
|||
result = prime * result + ((getConfigType() == null) ? 0 : getConfigType().hashCode()); |
|||
result = prime * result + ((getMeterMin() == null) ? 0 : getMeterMin().hashCode()); |
|||
result = prime * result + ((getMeterMax() == null) ? 0 : getMeterMax().hashCode()); |
|||
result = prime * result + ((getRotate() == null) ? 0 : getRotate().hashCode()); |
|||
result = prime * result + ((getStateNum() == null) ? 0 : getStateNum().hashCode()); |
|||
result = prime * result + ((getParameter() == null) ? 0 : getParameter().hashCode()); |
|||
result = prime * result + ((getResult() == null) ? 0 : getResult().hashCode()); |
|||
result = prime * result + ((getAlgorithm() == null) ? 0 : getAlgorithm().hashCode()); |
|||
result = prime * result + ((getCreateUser() == null) ? 0 : getCreateUser().hashCode()); |
|||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); |
|||
result = prime * result + ((getUpdateUser() == null) ? 0 : getUpdateUser().hashCode()); |
|||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); |
|||
result = prime * result + (Arrays.hashCode(getFocalPicture())); |
|||
return result; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
StringBuilder sb = new StringBuilder(); |
|||
sb.append(getClass().getSimpleName()); |
|||
sb.append(" ["); |
|||
sb.append("Hash = ").append(hashCode()); |
|||
sb.append(", id=").append(id); |
|||
sb.append(", configId=").append(configId); |
|||
sb.append(", focalName=").append(focalName); |
|||
sb.append(", focalIndex=").append(focalIndex); |
|||
sb.append(", copperWid=").append(copperWid); |
|||
sb.append(", copperHei=").append(copperHei); |
|||
sb.append(", copperX=").append(copperX); |
|||
sb.append(", copperY=").append(copperY); |
|||
sb.append(", configType=").append(configType); |
|||
sb.append(", meterMin=").append(meterMin); |
|||
sb.append(", meterMax=").append(meterMax); |
|||
sb.append(", rotate=").append(rotate); |
|||
sb.append(", stateNum=").append(stateNum); |
|||
sb.append(", parameter=").append(parameter); |
|||
sb.append(", result=").append(result); |
|||
sb.append(", algorithm=").append(algorithm); |
|||
sb.append(", createUser=").append(createUser); |
|||
sb.append(", createTime=").append(createTime); |
|||
sb.append(", updateUser=").append(updateUser); |
|||
sb.append(", updateTime=").append(updateTime); |
|||
sb.append(", focalPicture=").append(focalPicture); |
|||
sb.append(", serialVersionUID=").append(serialVersionUID); |
|||
sb.append("]"); |
|||
return sb.toString(); |
|||
} |
|||
} |
|||
@ -0,0 +1,301 @@ |
|||
package com.xr.iec61850clent.models.iec61850run; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.beanit.iec61850bean.*; |
|||
import com.beanit.iec61850bean.internal.cli.*; |
|||
import com.xr.iec61850clent.common.util.ModeUtil; |
|||
import com.xr.iec61850clent.common.util.SpringUtils; |
|||
import com.xr.iec61850clent.common.util.UploadUtil; |
|||
import com.xr.iec61850clent.models.entity.*; |
|||
import com.xr.iec61850clent.models.service.*; |
|||
import org.springframework.scheduling.annotation.Scheduled; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.awt.image.BufferedImage; |
|||
import java.io.IOException; |
|||
import java.net.InetAddress; |
|||
import java.net.UnknownHostException; |
|||
import java.util.*; |
|||
|
|||
import static java.lang.Thread.sleep; |
|||
|
|||
@Component |
|||
public class Iec61850Scheduled { |
|||
|
|||
private static final ActionProcessor actionProcessor = new ActionProcessor(new ActionExecutor()); |
|||
private static volatile ClientAssociation association; |
|||
private static ServerModel serverModel; |
|||
private int conner =0; |
|||
String[] args = new String[] {"param1", "param2", "param3"}; |
|||
|
|||
@Scheduled(cron = "0 0/1 * * * ?")//每10分钟执行一次
|
|||
public void run(){ |
|||
StringCliParameter hostParam = new CliParameterBuilder("-h") .setDescription("要访问的服务器的IP域地址。").buildStringParameter("host","192.168.1.93"); |
|||
IntCliParameter portParam = new CliParameterBuilder("-p").setDescription("要连接的端口。").buildIntParameter("port", 102); |
|||
StringCliParameter modelFileParam= new CliParameterBuilder("-m").setDescription("要从中读取模型的SCL文件的文件名。如果省略此参数,则在连接后将从服务器设备读取模型。").buildStringParameter("model-file"); |
|||
List<CliParameter> cliParameters = new ArrayList<>(); |
|||
cliParameters.add(hostParam); |
|||
cliParameters.add(portParam); |
|||
cliParameters.add(modelFileParam); |
|||
|
|||
CliParser cliParser = |
|||
new CliParser( |
|||
"iec61850bean-console-client", "用于访问IEC61850 MMS服务器的客户端应用程序。"); |
|||
cliParser.addParameters(cliParameters); |
|||
|
|||
// try {
|
|||
// cliParser.parseArguments(args);
|
|||
// } catch (CliParseException e1) {
|
|||
// System.err.println("分析命令行参数时出错:" + e1.getMessage());
|
|||
// System.out.println(cliParser.getUsageString());
|
|||
// System.exit(1);
|
|||
// }
|
|||
|
|||
InetAddress address; |
|||
try { |
|||
address = InetAddress.getByName(hostParam.getValue()); |
|||
} catch (UnknownHostException e) { |
|||
System.out.println("未知主机:" + hostParam.getValue()); |
|||
return; |
|||
} |
|||
|
|||
ClientSap clientSap = new ClientSap(); |
|||
try { |
|||
association = clientSap.associate(address, portParam.getValue(), null, new EventListener()); |
|||
conner = 0; |
|||
} catch (IOException e) { |
|||
System.out.println("host"+"第"+(conner+1)+"次无法连接到远程主机。"); |
|||
conner++; |
|||
try{ |
|||
sleep(60000); |
|||
}catch (Exception p){ |
|||
p.printStackTrace(); |
|||
} |
|||
run(); |
|||
} |
|||
|
|||
Runtime.getRuntime() |
|||
.addShutdownHook( |
|||
new Thread() { |
|||
@Override |
|||
public void run() { |
|||
association.close(); |
|||
} |
|||
}); |
|||
|
|||
System.out.println("192.168.1.93已成功连接"); |
|||
|
|||
if (modelFileParam.isSelected()) { |
|||
System.out.println("正在从文件中读取模型。。。"); |
|||
|
|||
try { |
|||
serverModel = SclParser.parse(modelFileParam.getValue()).get(0); |
|||
} catch (SclParseException e1) { |
|||
System.out.println("分析SCL文件时出错: " + e1.getMessage()); |
|||
return; |
|||
} |
|||
|
|||
association.setServerModel(serverModel); |
|||
|
|||
System.out.println("成功读取模型"); |
|||
|
|||
} else { |
|||
System.out.println("正在检索模型。。。"); |
|||
|
|||
try { |
|||
serverModel = association.retrieveModel(); |
|||
} catch (ServiceError e) { |
|||
System.out.println("服务错误: " + e.getMessage()); |
|||
return; |
|||
} catch (IOException e) { |
|||
System.out.println("致命错误: " + e.getMessage()); |
|||
return; |
|||
} |
|||
|
|||
System.out.println("成功读取模型"); |
|||
System.out.println(serverModel); |
|||
Lds5000Service lds5000Service = SpringUtils.getBean(Lds5000Service.class); |
|||
MeterConfigService meterConfigService=SpringUtils.getBean(MeterConfigService.class); |
|||
MeterReadingRecordService meterReadingRecordService=SpringUtils.getBean(MeterReadingRecordService.class); |
|||
MeterTypeService meterTypeService=SpringUtils.getBean(MeterTypeService.class); |
|||
FocalLengthConfigService configService = SpringUtils.getBean(FocalLengthConfigService.class); |
|||
DeviceCameraService deviceCameraService = SpringUtils.getBean(DeviceCameraService.class); |
|||
try { |
|||
DataSet dSet = serverModel.getDataSet("TEMPLATELD0/LLN0.dsMeasureInfo1"); |
|||
association.getDataSetValues(dSet); |
|||
System.out.println("更新模型成功!"); |
|||
System.out.println(Arrays.toString(new Collection[]{serverModel.getDataSets()})); |
|||
List<DataSet> dataSets=new ArrayList<>(serverModel.getDataSets()); |
|||
for (DataSet dataSet:dataSets){ |
|||
List<FcModelNode> fas=dataSet.getMembers(); |
|||
for (FcModelNode node:fas){ |
|||
Lds5000 lds5000= ModeUtil.getLdsVlue("192.168.1.93",node); |
|||
if(lds5000==null){ |
|||
continue; |
|||
} |
|||
if(lds5000.getClentIp().equals("192.168.1.57")){ |
|||
System.out.println("-----------------------"); |
|||
} |
|||
QueryWrapper<Lds5000> queryWrapper=new QueryWrapper<>(); |
|||
queryWrapper.eq("node",lds5000.getNode()); |
|||
queryWrapper.eq("clent_ip","192.168.1.93"); |
|||
Lds5000 lds=lds5000Service.getOne(queryWrapper); |
|||
if (lds != null) { |
|||
lds.setUpdateTime(new Date()); |
|||
lds.setF(lds5000.getF()); |
|||
lds5000Service.updateById(lds); |
|||
MeterConfig config=meterConfigService.getById(lds5000.getMeterId()); |
|||
QueryWrapper<FocalLengthConfig> query=new QueryWrapper<>(); |
|||
query.eq("config_id",config.getId()); |
|||
FocalLengthConfig fa= configService.getOne(query); |
|||
if(config!=null){ |
|||
String fileName = config.getId()+new Date().getTime()+".jpg"; |
|||
String url = "http://"+lds5000.getClientIp()+":8080/tao/snapshot"; |
|||
BufferedImage bufferedImage = UploadUtil.urlByImage(url); |
|||
MeterType type=meterTypeService.getById(config.getTypeId()); |
|||
MeterReadingRecord meterReadingRecord=new MeterReadingRecord(); |
|||
meterReadingRecord.setMeterId(config.getId()); |
|||
meterReadingRecord.setReadingType(lds5000.getType()); |
|||
if(node.getFc().name().equals("MX")){ |
|||
String value = "0"; |
|||
float f = Float.valueOf(lds5000.getF()); |
|||
if(config.getTypeId() == 3 || config.getTypeId() == 5 || config.getTypeId() == 7){//油位计,保留2位小数
|
|||
value = String.format("%.2f", f); |
|||
} |
|||
if(config.getTypeId() == 4 || config.getTypeId() == 11){//开关计数器
|
|||
//处理为整数
|
|||
int s = (int) f; |
|||
value = s+""; |
|||
} |
|||
if(config.getTypeId() == 8){//档位数据处理
|
|||
//处理为整数
|
|||
int s = Math.round(f); |
|||
if(s>8){ |
|||
int t = s-8; |
|||
if(t<9){ |
|||
value=t+""; |
|||
} |
|||
if(t == 9){ |
|||
value = "9A"; |
|||
} |
|||
if(t == 10){ |
|||
value = "9B"; |
|||
} |
|||
if(t == 11){ |
|||
value = "9C"; |
|||
} |
|||
if(t>11){ |
|||
value = t-2+""; |
|||
} |
|||
}else { |
|||
value=s+""; |
|||
} |
|||
} |
|||
if(config.getTypeId() == 10){//放电计数器
|
|||
int s = Math.round(f); |
|||
if(s>=10){ |
|||
value = 0+""; |
|||
} |
|||
} |
|||
if(config.getIsJz() == 1){ |
|||
value = config.getJzVal(); |
|||
} |
|||
meterReadingRecord.setReadingValue(value); |
|||
}else{ |
|||
meterReadingRecord.setReadingValue(lds5000.getStVal()); |
|||
} |
|||
|
|||
BufferedImage buffer = UploadUtil.drawRectangleAndText(bufferedImage, |
|||
fa.getCopperX(),fa.getCopperY(),fa.getCopperX2(),fa.getCopperWid(),fa.getCopperHei(),meterReadingRecord.getReadingValue(),config.getMeterName()); |
|||
String url1 = UploadUtil.uploadImage(buffer,config.getId(),fileName); |
|||
meterReadingRecord.setMeterTypeName(type.getTypeAlias()); |
|||
meterReadingRecord.setMeterCode(config.getMeterCode()); |
|||
meterReadingRecord.setReadingTime(new Date()); |
|||
meterReadingRecord.setCreateUser("SYSTEM"); |
|||
meterReadingRecord.setCreateTime(new Date()); |
|||
meterReadingRecord.setReadingUrl(url1); |
|||
meterReadingRecord.setMeterTypeId(config.getTypeId()); |
|||
meterReadingRecord.setOwningInterval(config.getOwningInterval()); |
|||
if(config.getIsJz()!=1){ |
|||
meterReadingRecordService.save(meterReadingRecord); |
|||
} |
|||
//abnormalReadingJudgment(meterReadingRecord);
|
|||
} |
|||
}else{ |
|||
lds5000.setCreateTime(new Date()); |
|||
lds5000Service.save(lds5000); |
|||
} |
|||
} |
|||
} |
|||
QueryWrapper<MeterConfig> queryWrapper=new QueryWrapper<>(); |
|||
queryWrapper.eq("is_jz",1); |
|||
queryWrapper.eq("status",1); |
|||
List<MeterConfig> meterConfigs = meterConfigService.list(queryWrapper); |
|||
for (MeterConfig config:meterConfigs){ |
|||
DeviceCamera camera = deviceCameraService.getById(config.getCameraId()); |
|||
String fileName = config.getId()+new Date().getTime()+".jpg"; |
|||
MeterReadingRecord meterReadingRecord=new MeterReadingRecord(); |
|||
meterReadingRecord.setMeterId(config.getId()); |
|||
meterReadingRecord.setReadingType(config.getTypeId()); |
|||
meterReadingRecord.setReadingTime(new Date()); |
|||
meterReadingRecord.setReadingType(2); |
|||
meterReadingRecord.setReadingValue(config.getJzVal()); |
|||
meterReadingRecord.setMeterTypeName(""); |
|||
meterReadingRecord.setMeterCode(config.getMeterCode()); |
|||
meterReadingRecord.setReadingTime(new Date()); |
|||
meterReadingRecord.setCreateUser("SYSTEM"); |
|||
meterReadingRecord.setCreateTime(new Date()); |
|||
QueryWrapper<FocalLengthConfig> query=new QueryWrapper<>(); |
|||
query.eq("config_id",config.getId()); |
|||
FocalLengthConfig fa= configService.getOne(query); |
|||
String url2 = "http://"+camera.getDeviceIp()+":8080/tao/snapshot"; |
|||
BufferedImage bufferedImage = UploadUtil.urlByImage(url2); |
|||
BufferedImage buffer = UploadUtil.drawRectangleAndText(bufferedImage, |
|||
fa.getCopperX(),fa.getCopperY(),fa.getCopperX2(),fa.getCopperWid(),fa.getCopperHei(),meterReadingRecord.getReadingValue(),config.getMeterName()); |
|||
String url1 = UploadUtil.uploadImage(buffer,config.getId(),fileName); |
|||
meterReadingRecord.setReadingUrl(url1); |
|||
meterReadingRecord.setMeterTypeId(config.getTypeId()); |
|||
meterReadingRecord.setOwningInterval(config.getOwningInterval()); |
|||
meterReadingRecordService.save(meterReadingRecord); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
association.close(); |
|||
} |
|||
} |
|||
|
|||
private static class ActionExecutor implements ActionListener { |
|||
@Override |
|||
public void actionCalled(String actionKey) throws ActionException { |
|||
} |
|||
@Override |
|||
public void quit() { |
|||
System.out.println("** 正在关闭连接。"); |
|||
association.close(); |
|||
} |
|||
} |
|||
|
|||
private static class EventListener implements ClientEventListener { |
|||
|
|||
@Override |
|||
public void newReport(Report report) { |
|||
System.out.println("\n----------------"); |
|||
System.out.println("收到的报告: "); |
|||
System.err.println(report); |
|||
System.out.println("------------------"); |
|||
} |
|||
|
|||
@Override |
|||
public void associationClosed(IOException e) { |
|||
System.out.print("接收到连接关闭信号。原因: "); |
|||
if (!e.getMessage().isEmpty()) { |
|||
System.out.println(e.getMessage()); |
|||
} else { |
|||
System.out.println("unknown"); |
|||
} |
|||
actionProcessor.close(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.xr.iec61850clent.models.mapper; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.xr.iec61850clent.models.entity.DeviceCamera; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.apache.ibatis.annotations.Select; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author admin |
|||
* @description 针对表【device_camera(摄像头管理)】的数据库操作Mapper |
|||
* @createDate 2023-02-21 11:22:23 |
|||
* @Entity com.xr.device_car.modules.analysis.entity.DeviceCamera |
|||
*/ |
|||
@DS("db2") |
|||
@Mapper |
|||
public interface DeviceCameraMapper extends BaseMapper<DeviceCamera> { |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,20 @@ |
|||
package com.xr.iec61850clent.models.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.xr.iec61850clent.models.entity.FocalLengthConfig; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* @author asus |
|||
* @description 针对表【focal_length_config】的数据库操作Mapper |
|||
* @createDate 2023-03-08 17:05:15 |
|||
* @Entity com.xr.device_car.modules.analysis.entity.FocalLengthConfig |
|||
*/ |
|||
@Mapper |
|||
public interface FocalLengthConfigMapper extends BaseMapper<FocalLengthConfig> { |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,14 @@ |
|||
package com.xr.iec61850clent.models.service; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.xr.iec61850clent.models.entity.DeviceCamera; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author admin |
|||
* @description 针对表【device_camera(摄像头管理)】的数据库操作Service |
|||
* @createDate 2023-02-21 11:22:23 |
|||
*/ |
|||
public interface DeviceCameraService extends IService<DeviceCamera> { |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
package com.xr.iec61850clent.models.service; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.xr.iec61850clent.models.entity.FocalLengthConfig; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author asus |
|||
* @description 针对表【focal_length_config】的数据库操作Service |
|||
* @createDate 2023-03-08 17:05:15 |
|||
*/ |
|||
public interface FocalLengthConfigService extends IService<FocalLengthConfig> { |
|||
|
|||
List<FocalLengthConfig> getImgFocalList(QueryWrapper<FocalLengthConfig> queryWrappe); |
|||
|
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package com.xr.iec61850clent.models.service.impl; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.xr.iec61850clent.models.entity.DeviceCamera; |
|||
import com.xr.iec61850clent.models.mapper.DeviceCameraMapper; |
|||
import com.xr.iec61850clent.models.service.DeviceCameraService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author admin |
|||
* @description 针对表【device_camera(摄像头管理)】的数据库操作Service实现 |
|||
* @createDate 2023-02-21 11:22:23 |
|||
*/ |
|||
@Service |
|||
@DS("db2") |
|||
public class DeviceCameraServiceImpl extends ServiceImpl<DeviceCameraMapper, DeviceCamera> implements DeviceCameraService { |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
@ -0,0 +1,43 @@ |
|||
package com.xr.iec61850clent.models.service.impl; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.xr.iec61850clent.models.entity.FocalLengthConfig; |
|||
import com.xr.iec61850clent.models.mapper.FocalLengthConfigMapper; |
|||
import com.xr.iec61850clent.models.service.FocalLengthConfigService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.Base64; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author asus |
|||
* @description 针对表【focal_length_config】的数据库操作Service实现 |
|||
* @createDate 2023-03-08 17:05:15 |
|||
*/ |
|||
@Service |
|||
@DS("db2") |
|||
public class FocalLengthConfigServiceImpl extends ServiceImpl<FocalLengthConfigMapper, FocalLengthConfig> |
|||
implements FocalLengthConfigService { |
|||
|
|||
@Override |
|||
public List<FocalLengthConfig> getImgFocalList(QueryWrapper<FocalLengthConfig> queryWrappe) { |
|||
List<FocalLengthConfig> list = ((FocalLengthConfigMapper)this.baseMapper).selectList(queryWrappe); |
|||
for(FocalLengthConfig config:list){ |
|||
if(config.getFocalPicture()!=null){ |
|||
String base64 = Base64.getEncoder().encodeToString(config.getFocalPicture()); |
|||
if(base64.contains("data:image/jpg;base64,")){ |
|||
config.setBasePicture(base64); |
|||
}else{ |
|||
config.setBasePicture("data:image/jpg;base64,"+base64); |
|||
} |
|||
} |
|||
} |
|||
return list; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
Binary file not shown.
@ -0,0 +1,15 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.xr.iec61850clent.models.mapper.FocalLengthConfigMapper"> |
|||
<sql id="Base_Column_List"> |
|||
id,config_id,focal_name, |
|||
focal_index,copper_wid,copper_hei, |
|||
copper_x,copper_y,config_type, |
|||
meter_min,meter_max,rotate, |
|||
state_num,parameter,result,scale, |
|||
algorithm,create_user,create_time, |
|||
update_user,update_time,focal_picture |
|||
</sql> |
|||
</mapper> |
|||
@ -0,0 +1,126 @@ |
|||
package com.xr.drone.demo; |
|||
|
|||
import java.io.IOException; |
|||
import java.text.SimpleDateFormat; |
|||
|
|||
import com.jnrsmcu.sdk.netdevice.IDataListener; |
|||
import com.jnrsmcu.sdk.netdevice.LoginData; |
|||
import com.jnrsmcu.sdk.netdevice.NodeData; |
|||
import com.jnrsmcu.sdk.netdevice.ParamData; |
|||
import com.jnrsmcu.sdk.netdevice.ParamIdsData; |
|||
import com.jnrsmcu.sdk.netdevice.ParamItem; |
|||
import com.jnrsmcu.sdk.netdevice.RSServer; |
|||
import com.jnrsmcu.sdk.netdevice.RealTimeData; |
|||
import com.jnrsmcu.sdk.netdevice.StoreData; |
|||
import com.jnrsmcu.sdk.netdevice.TelecontrolAck; |
|||
import com.jnrsmcu.sdk.netdevice.TimmingAck; |
|||
import com.jnrsmcu.sdk.netdevice.TransDataAck; |
|||
import com.jnrsmcu.sdk.netdevice.WriteParamAck; |
|||
|
|||
public class Demo { |
|||
|
|||
public static void main(String[] args) throws IOException, |
|||
InterruptedException { |
|||
//RSServer rsServer = RSServer.Initiate(2404);// 初始化
|
|||
RSServer rsServer = RSServer.Initiate(2404,"C:\\Users\\PC\\Desktop\\JavaSDKV2.2.2\\param.dat"); |
|||
rsServer.addDataListener(new IDataListener() {// 添加监听
|
|||
@Override |
|||
public void receiveTimmingAck(TimmingAck data) {// 校时指令应答处理
|
|||
System.out.println("校时应答->设备编号:" + data.getDeviceId() |
|||
+ "\t执行结果:" + data.getStatus()); |
|||
} |
|||
|
|||
@Override |
|||
public void receiveTelecontrolAck(TelecontrolAck data) {// 遥控指令应答处理
|
|||
System.out.println("遥控应答->设备编号:" + data.getDeviceId() |
|||
+ "\t继电器编号:" + data.getRelayId() + "\t执行结果:" |
|||
+ data.getStatus()); |
|||
} |
|||
|
|||
@Override |
|||
public void receiveStoreData(StoreData data) {// 已存储数据接收处理
|
|||
// 遍历节点数据。数据包括网络设备的数据以及各个节点数据。温湿度数据存放在节点数据中
|
|||
for (NodeData nd : data.getNodeList()) { |
|||
SimpleDateFormat sdf = new SimpleDateFormat( |
|||
"yy-MM-dd HH:mm:ss"); |
|||
String str = sdf.format(nd.getRecordTime()); |
|||
System.out.println("存储数据->设备地址:" + data.getDeviceId() |
|||
+ "\t节点:" + nd.getNodeId() + "\t温度:" + nd.getTem() |
|||
+ "\t湿度:" + nd.getHum() + "\t存储时间:" + str); |
|||
} |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveRealtimeData(RealTimeData data) {// 实时数据接收处理
|
|||
// 遍历节点数据。数据包括网络设备的数据以及各个节点数据。温湿度数据存放在节点数据中
|
|||
for (NodeData nd : data.getNodeList()) { |
|||
System.out.println("实时数据->设备地址:" + data.getDeviceId() |
|||
+ "\t节点:" + nd.getNodeId() + "\t温度:" + nd.getTem() |
|||
+ "\t湿度:" + nd.getHum() + "\t经度:" + data.getLng() |
|||
+ "\t纬度:" + data.getLat() + "\t坐标类型:" |
|||
+ data.getCoordinateType() + "\t继电器状态:" |
|||
+ data.getRelayStatus()); |
|||
} |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveLoginData(LoginData data) {// 登录数据接收处理
|
|||
System.out.println("登录->设备地址:" + data.getDeviceId()); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveParamIds(ParamIdsData data) { |
|||
String str = "设备参数编号列表->设备编号:" + data.getDeviceId() |
|||
+ "\t参数总数量:" + data.getTotalCount() + "\t本帧参数数量:" |
|||
+ data.getCount() + "\r\n"; |
|||
for (int paramId : data.getPararmIdList())// 遍历设备中参数id编号
|
|||
{ |
|||
str += paramId + ","; |
|||
} |
|||
System.out.println(str); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveParam(ParamData data) { |
|||
String str = "设备参数->设备编号:" + data.getDeviceId() + "\r\n"; |
|||
|
|||
for (ParamItem pararm : data.getParameterList()) { |
|||
str += "参数编号:" |
|||
+ pararm.getParamId() |
|||
+ "\t参数描述:" |
|||
+ pararm.getDescription() |
|||
+ "\t参数值:" |
|||
+ (pararm.getValueDescription() == null ? pararm |
|||
.getValue() : pararm.getValueDescription() |
|||
.get(pararm.getValue())) + "\r\n"; |
|||
} |
|||
System.out.println(str); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveWriteParamAck(WriteParamAck data) { |
|||
String str = "下载设备参数->设备编号:" + data.getDeviceId() + "\t参数数量:" |
|||
+ data.getCount() + "\t" |
|||
+ (data.isSuccess() ? "下载成功" : "下载失败"); |
|||
System.out.println(str); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveTransDataAck(TransDataAck data) { |
|||
String str = "数据透传->设备编号:" + data.getDeviceId() + "\t响应结果:" |
|||
+ data.getData() + "\r\n字节数:" + data.getTransDataLen(); |
|||
System.out.println(str); |
|||
|
|||
} |
|||
}); |
|||
rsServer.start(); |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,477 @@ |
|||
package com.xr.drone.demo; |
|||
|
|||
import java.awt.event.ActionEvent; |
|||
import java.awt.event.ActionListener; |
|||
import java.awt.event.ItemEvent; |
|||
import java.awt.event.ItemListener; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
import javax.swing.JButton; |
|||
import javax.swing.JCheckBox; |
|||
import javax.swing.JFrame; |
|||
import javax.swing.JLabel; |
|||
import javax.swing.JOptionPane; |
|||
import javax.swing.JScrollPane; |
|||
import javax.swing.JTextArea; |
|||
import javax.swing.JTextField; |
|||
import javax.swing.SwingUtilities; |
|||
|
|||
import com.jnrsmcu.sdk.netdevice.IDataListener; |
|||
import com.jnrsmcu.sdk.netdevice.LoginData; |
|||
import com.jnrsmcu.sdk.netdevice.NodeData; |
|||
import com.jnrsmcu.sdk.netdevice.ParamData; |
|||
import com.jnrsmcu.sdk.netdevice.ParamIdsData; |
|||
import com.jnrsmcu.sdk.netdevice.ParamItem; |
|||
import com.jnrsmcu.sdk.netdevice.RSServer; |
|||
import com.jnrsmcu.sdk.netdevice.RealTimeData; |
|||
import com.jnrsmcu.sdk.netdevice.StoreData; |
|||
import com.jnrsmcu.sdk.netdevice.TelecontrolAck; |
|||
import com.jnrsmcu.sdk.netdevice.TimmingAck; |
|||
import com.jnrsmcu.sdk.netdevice.TransDataAck; |
|||
import com.jnrsmcu.sdk.netdevice.WriteParamAck; |
|||
|
|||
import javax.swing.GroupLayout; |
|||
import javax.swing.GroupLayout.Alignment; |
|||
import javax.swing.JPanel; |
|||
import javax.swing.border.LineBorder; |
|||
|
|||
import java.awt.Color; |
|||
|
|||
import javax.swing.border.TitledBorder; |
|||
import javax.swing.LayoutStyle.ComponentPlacement; |
|||
|
|||
public class SwingDemo extends JFrame { |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private static final long serialVersionUID = -7855826301914463533L; |
|||
private JTextField txtPort; |
|||
private JScrollPane scrollPane; |
|||
private JTextArea textArea; |
|||
private JButton btnStart; |
|||
private JButton btnStop; |
|||
private JCheckBox chkRelay0; |
|||
private JCheckBox chkRelay1; |
|||
private JCheckBox chkRelay2; |
|||
private JCheckBox chkRelay3; |
|||
private JCheckBox chkRelay4; |
|||
private JCheckBox chkRelay5; |
|||
private JCheckBox chkRelay6; |
|||
private JCheckBox chkRelay7; |
|||
private JButton btnTimming; |
|||
private JButton btnCallStore; |
|||
private RSServer rsServer;// 定义监听服务对象
|
|||
private IDataListener listener = new IDataListener() { |
|||
|
|||
@Override |
|||
public void receiveTimmingAck(TimmingAck data) {// 校时指令应答处理
|
|||
textArea.append("校时应答->设备编号:" + data.getDeviceId() + "\t执行结果:" |
|||
+ data.getStatus() + "\r\n"); |
|||
} |
|||
|
|||
@Override |
|||
public void receiveTelecontrolAck(TelecontrolAck data) {// 遥控指令应答处理
|
|||
textArea.append("遥控应答->设备编号:" + data.getDeviceId() + "\t继电器编号:" |
|||
+ data.getRelayId() + "\t执行结果:" + data.getStatus() + "\r\n"); |
|||
} |
|||
|
|||
@Override |
|||
public void receiveStoreData(StoreData data) {// 已存储数据接收处理
|
|||
// 遍历节点数据。数据包括网络设备的数据以及各个节点数据。温湿度数据存放在节点数据中
|
|||
for (NodeData nd : data.getNodeList()) { |
|||
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm:ss"); |
|||
String str = sdf.format(nd.getRecordTime()); |
|||
|
|||
textArea.append("存储数据->设备地址:" + data.getDeviceId() + "\t节点:" |
|||
+ nd.getNodeId() + "\t温度:" + nd.getTem() + "\t湿度:" |
|||
+ nd.getHum() + "\t存储时间:" + str+"\t坐标类型:"+nd.getCoordinateType()+"\t经度:"+nd.getLng()+"\t纬度:"+nd.getLat() + "\r\n"); |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveRealtimeData(RealTimeData data) {// 实时数据接收处理
|
|||
// 遍历节点数据。数据包括网络设备的数据以及各个节点数据。温湿度数据存放在节点数据中
|
|||
for (NodeData nd : data.getNodeList()) { |
|||
textArea.append("实时数据->设备地址:" + data.getDeviceId() + "\t节点:" |
|||
+ nd.getNodeId() + "\t温度:" + nd.getTem() + "\t湿度:" |
|||
+ nd.getHum() + "\t经度:" + data.getLng() + "\t纬度:" |
|||
+ data.getLat() + "\t坐标类型:" + data.getCoordinateType() |
|||
+ "\t继电器状态" + data.getRelayStatus() + "\t浮点型数据:" |
|||
+ nd.getFloatValue() + "\t32位有符号数据:" |
|||
+ nd.getSignedInt32Value() + "\t32位无符号数据:" |
|||
+ nd.getUnSignedInt32Value() + "\r\n"); |
|||
} |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveLoginData(LoginData data) {// 登录数据接收处理
|
|||
textArea.append("登录->设备地址:" + data.getDeviceId() + "\r\n"); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveParamIds(ParamIdsData data) { |
|||
String str = "设备参数编号列表->设备编号:" + data.getDeviceId() + "\t参数总数量:" |
|||
+ data.getTotalCount() + "\t本帧参数数量:" + data.getCount() |
|||
+ "\r\n"; |
|||
for (int paramId : data.getPararmIdList())// 遍历设备中参数id编号
|
|||
{ |
|||
str += paramId + ","; |
|||
} |
|||
textArea.append(str + "\r\n"); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveParam(ParamData data) { |
|||
String str = "设备参数->设备编号:" + data.getDeviceId() + "\r\n"; |
|||
|
|||
for (ParamItem pararm : data.getParameterList()) { |
|||
str += "参数编号:" |
|||
+ pararm.getParamId() |
|||
+ "\t参数描述:" |
|||
+ pararm.getDescription() |
|||
+ "\t参数值:" |
|||
+ (pararm.getValueDescription() == null ? pararm |
|||
.getValue() : pararm.getValueDescription().get( |
|||
pararm.getValue())) + "\r\n"; |
|||
} |
|||
textArea.append(str + "\r\n"); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveWriteParamAck(WriteParamAck data) { |
|||
String str = "下载设备参数->设备编号:" + data.getDeviceId() + "\t参数数量:" |
|||
+ data.getCount() + "\t" |
|||
+ (data.isSuccess() ? "下载成功" : "下载失败"); |
|||
textArea.append(str + "\r\n"); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void receiveTransDataAck(TransDataAck data) { |
|||
String str = "数据透传->设备编号:" + data.getDeviceId() + "\t响应结果:" |
|||
+ data.getData() + "\r\n字节数:" + data.getTransDataLen(); |
|||
textArea.append(str + "\r\n"); |
|||
|
|||
} |
|||
}; |
|||
|
|||
private JTextField txtDeviceId; |
|||
private JTextField txtParamIds; |
|||
private JTextField txtParamId; |
|||
private JTextField txtParamVal; |
|||
private JPanel panel_2; |
|||
private JLabel label_4; |
|||
private JTextField txtTransData; |
|||
private JButton btnTrans; |
|||
|
|||
public SwingDemo() { |
|||
setTitle("Demo"); |
|||
setResizable(false); |
|||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|||
setSize(653, 710); |
|||
setLocationRelativeTo(null); |
|||
|
|||
JLabel lblNewLabel = new JLabel("\u7AEF\u53E3:"); |
|||
lblNewLabel.setBounds(10, 10, 40, 15); |
|||
|
|||
txtPort = new JTextField(); |
|||
txtPort.setBounds(45, 7, 66, 21); |
|||
txtPort.setText("2404"); |
|||
txtPort.setColumns(10); |
|||
|
|||
btnStart = new JButton("\u542F\u52A8"); |
|||
btnStart.setBounds(135, 6, 85, 23); |
|||
btnStart.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent arg0) { |
|||
|
|||
btnStart.setEnabled(false); |
|||
new Thread(new Runnable() { |
|||
|
|||
@Override |
|||
public void run() { |
|||
|
|||
rsServer = RSServer.Initiate(Integer.parseInt(txtPort |
|||
.getText()),"C:\\Users\\PC\\Desktop\\JavaSDKV2.2.2\\param.dat");// 初始化
|
|||
|
|||
rsServer.addDataListener(listener);// 添加数据监听事件
|
|||
try { |
|||
rsServer.start(); |
|||
} catch (InterruptedException e) { |
|||
// TODO Auto-generated catch block
|
|||
e.printStackTrace(); |
|||
}// 启动监听服务
|
|||
} |
|||
}).start(); |
|||
} |
|||
|
|||
}); |
|||
|
|||
btnStop = new JButton("\u505C\u6B62"); |
|||
btnStop.setBounds(237, 6, 85, 23); |
|||
btnStop.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent arg0) { |
|||
btnStart.setEnabled(true); |
|||
rsServer.stop(); |
|||
} |
|||
}); |
|||
|
|||
scrollPane = new JScrollPane(); |
|||
scrollPane.setBounds(10, 400, 624, 275); |
|||
|
|||
textArea = new JTextArea(); |
|||
scrollPane.setViewportView(textArea); |
|||
|
|||
JLabel label = new JLabel("\u8BBE\u5907\u5730\u5740:"); |
|||
label.setBounds(10, 48, 66, 15); |
|||
|
|||
txtDeviceId = new JTextField(); |
|||
txtDeviceId.setBounds(75, 45, 84, 21); |
|||
txtDeviceId.setText("10000000"); |
|||
txtDeviceId.setColumns(10); |
|||
|
|||
btnTimming = new JButton("\u6821\u65F6"); |
|||
btnTimming.setBounds(336, 6, 85, 23); |
|||
btnTimming.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent arg0) { |
|||
int deviceId = Integer.parseInt(txtDeviceId.getText()); |
|||
rsServer.timming(deviceId); |
|||
} |
|||
}); |
|||
|
|||
btnCallStore = new JButton("\u53EC\u5524\u6570\u636E"); |
|||
btnCallStore.setBounds(428, 6, 90, 23); |
|||
btnCallStore.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent e) { |
|||
int deviceId = Integer.parseInt(txtDeviceId.getText()); |
|||
|
|||
rsServer.callStoreData(deviceId); |
|||
} |
|||
}); |
|||
|
|||
JPanel panel = new JPanel(); |
|||
panel.setBounds(10, 84, 624, 57); |
|||
panel.setBorder(new TitledBorder(null, |
|||
"\u7EE7\u7535\u5668\u63A7\u5236", TitledBorder.LEADING, |
|||
TitledBorder.TOP, null, null)); |
|||
|
|||
JPanel panel_1 = new JPanel(); |
|||
panel_1.setBounds(10, 147, 624, 112); |
|||
panel_1.setBorder(new TitledBorder(null, "\u8BBE\u5907\u53C2\u6570", |
|||
TitledBorder.LEADING, TitledBorder.TOP, null, null)); |
|||
|
|||
panel_2 = new JPanel(); |
|||
panel_2.setBounds(10, 269, 624, 113); |
|||
panel_2.setBorder(new TitledBorder(null, "\u6570\u636E\u900F\u4F20", |
|||
TitledBorder.LEADING, TitledBorder.TOP, null, null)); |
|||
panel_2.setLayout(null); |
|||
|
|||
label_4 = new JLabel( |
|||
"\u900F\u4F20\u6570\u636E\uFF0C16\u8FDB\u5236\u5B57\u7B26\u4E32"); |
|||
label_4.setBounds(10, 23, 419, 15); |
|||
panel_2.add(label_4); |
|||
|
|||
txtTransData = new JTextField(); |
|||
txtTransData.setBounds(10, 48, 604, 21); |
|||
panel_2.add(txtTransData); |
|||
txtTransData.setColumns(10); |
|||
|
|||
btnTrans = new JButton("\u6570\u636E\u900F\u4F20"); |
|||
btnTrans.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent arg0) { |
|||
int deviceId = Integer.parseInt(txtDeviceId.getText()); |
|||
|
|||
rsServer.trans(deviceId, txtTransData.getText()); |
|||
} |
|||
}); |
|||
btnTrans.setBounds(10, 79, 93, 23); |
|||
panel_2.add(btnTrans); |
|||
panel_1.setLayout(null); |
|||
|
|||
JLabel label_1 = new JLabel( |
|||
"\u53C2\u6570\u7F16\u53F7\uFF0C\u7528\u4E8E\u8BFB\u53D6\u8BBE\u5907\u53C2\u6570\uFF08\u591A\u4E2A\u7F16\u53F7\u7528\u82F1\u6587,\u5206\u9694\uFF09"); |
|||
label_1.setBounds(10, 22, 421, 15); |
|||
panel_1.add(label_1); |
|||
|
|||
txtParamIds = new JTextField(); |
|||
txtParamIds.setText("1,2,3,4,5,6,7,8,9,10"); |
|||
txtParamIds.setBounds(10, 47, 421, 21); |
|||
panel_1.add(txtParamIds); |
|||
txtParamIds.setColumns(10); |
|||
|
|||
JLabel label_2 = new JLabel("\u53C2\u6570\u7F16\u53F7"); |
|||
label_2.setBounds(10, 78, 54, 15); |
|||
panel_1.add(label_2); |
|||
|
|||
txtParamId = new JTextField(); |
|||
txtParamId.setBounds(68, 75, 66, 21); |
|||
panel_1.add(txtParamId); |
|||
txtParamId.setColumns(10); |
|||
|
|||
JLabel label_3 = new JLabel("\u53C2\u6570\u503C"); |
|||
label_3.setBounds(144, 78, 54, 15); |
|||
panel_1.add(label_3); |
|||
|
|||
txtParamVal = new JTextField(); |
|||
txtParamVal.setBounds(202, 75, 66, 21); |
|||
panel_1.add(txtParamVal); |
|||
txtParamVal.setColumns(10); |
|||
|
|||
JButton btnReadParametersList = new JButton( |
|||
"\u8BFB\u53D6\u8BBE\u5907\u53C2\u6570\u5217\u8868"); |
|||
btnReadParametersList.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent arg0) { |
|||
int deviceId = Integer.parseInt(txtDeviceId.getText()); |
|||
rsServer.callParamList(deviceId);// 发送召唤设备参数列表指令
|
|||
} |
|||
}); |
|||
btnReadParametersList.setBounds(460, 18, 142, 23); |
|||
panel_1.add(btnReadParametersList); |
|||
|
|||
JButton btnReadParameters = new JButton( |
|||
"\u8BFB\u53D6\u8BBE\u5907\u53C2\u6570"); |
|||
btnReadParameters.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent arg0) { |
|||
int deviceId = Integer.parseInt(txtDeviceId.getText()); |
|||
List<Integer> ids = new ArrayList<Integer>(); |
|||
String[] idArray = txtParamIds.getText().split(","); |
|||
for (String str : idArray) { |
|||
try { |
|||
ids.add(Integer.parseInt(str)); |
|||
} catch (Exception e) { |
|||
} |
|||
} |
|||
if (ids.size() >= 115) { |
|||
|
|||
JOptionPane.showMessageDialog(null, "一次读取参数数量不能超过115个", |
|||
"提示", JOptionPane.INFORMATION_MESSAGE); |
|||
return; |
|||
} |
|||
rsServer.callParam(deviceId, ids); |
|||
|
|||
} |
|||
}); |
|||
btnReadParameters.setBounds(460, 46, 142, 23); |
|||
panel_1.add(btnReadParameters); |
|||
|
|||
JButton btnWriteParameters = new JButton( |
|||
"\u4E0B\u8F7D\u8BBE\u5907\u53C2\u6570"); |
|||
btnWriteParameters.addActionListener(new ActionListener() { |
|||
public void actionPerformed(ActionEvent arg0) { |
|||
|
|||
int deviceId = Integer.parseInt(txtDeviceId.getText()); |
|||
List<ParamItem> parameters = new ArrayList<ParamItem>(); |
|||
|
|||
try { |
|||
|
|||
parameters.add(ParamItem.New( |
|||
Integer.parseInt(txtParamId.getText()), |
|||
txtParamVal.getText())); |
|||
} catch (Exception ex) { |
|||
JOptionPane.showMessageDialog(null, ex.getMessage(), "提示", |
|||
JOptionPane.INFORMATION_MESSAGE); |
|||
return; |
|||
} |
|||
if (parameters.size() > 115) { |
|||
|
|||
JOptionPane.showMessageDialog(null, "一次性下发参数数量不能超过115个", |
|||
"提示", JOptionPane.INFORMATION_MESSAGE); |
|||
return; |
|||
} |
|||
rsServer.writeParam(deviceId, parameters); |
|||
} |
|||
}); |
|||
btnWriteParameters.setBounds(460, 74, 142, 23); |
|||
panel_1.add(btnWriteParameters); |
|||
|
|||
chkRelay0 = new JCheckBox("\u7EE7\u7535\u56680"); |
|||
panel.add(chkRelay0); |
|||
|
|||
chkRelay1 = new JCheckBox("\u7EE7\u7535\u56681"); |
|||
panel.add(chkRelay1); |
|||
|
|||
chkRelay2 = new JCheckBox("\u7EE7\u7535\u56682"); |
|||
panel.add(chkRelay2); |
|||
|
|||
chkRelay3 = new JCheckBox("\u7EE7\u7535\u56683"); |
|||
panel.add(chkRelay3); |
|||
|
|||
chkRelay4 = new JCheckBox("\u7EE7\u7535\u56684"); |
|||
panel.add(chkRelay4); |
|||
|
|||
chkRelay5 = new JCheckBox("\u7EE7\u7535\u56685"); |
|||
panel.add(chkRelay5); |
|||
|
|||
chkRelay6 = new JCheckBox("\u7EE7\u7535\u56686"); |
|||
panel.add(chkRelay6); |
|||
|
|||
chkRelay7 = new JCheckBox("\u7EE7\u7535\u56687"); |
|||
panel.add(chkRelay7); |
|||
chkRelay7.addItemListener(new ChkItemListener(7)); |
|||
chkRelay6.addItemListener(new ChkItemListener(6)); |
|||
chkRelay5.addItemListener(new ChkItemListener(5)); |
|||
chkRelay4.addItemListener(new ChkItemListener(4)); |
|||
chkRelay3.addItemListener(new ChkItemListener(3)); |
|||
chkRelay2.addItemListener(new ChkItemListener(2)); |
|||
chkRelay1.addItemListener(new ChkItemListener(1)); |
|||
chkRelay0.addItemListener(new ChkItemListener(0)); |
|||
getContentPane().setLayout(null); |
|||
getContentPane().add(txtPort); |
|||
getContentPane().add(lblNewLabel); |
|||
getContentPane().add(btnStart); |
|||
getContentPane().add(btnStop); |
|||
getContentPane().add(btnTimming); |
|||
getContentPane().add(btnCallStore); |
|||
getContentPane().add(txtDeviceId); |
|||
getContentPane().add(label); |
|||
getContentPane().add(panel_1); |
|||
getContentPane().add(panel); |
|||
getContentPane().add(panel_2); |
|||
getContentPane().add(scrollPane); |
|||
} |
|||
|
|||
class ChkItemListener implements ItemListener { |
|||
|
|||
private int relayId = 0; |
|||
|
|||
public ChkItemListener(int relayId) { |
|||
this.relayId = relayId; |
|||
} |
|||
|
|||
@Override |
|||
public void itemStateChanged(ItemEvent e) { |
|||
JCheckBox jcb = (JCheckBox) e.getItem(); |
|||
int deviceId = Integer.parseInt(txtDeviceId.getText()); |
|||
if (jcb.isSelected()) { |
|||
|
|||
try { |
|||
rsServer.telecontrol(deviceId, relayId, 0, 0); |
|||
} catch (Exception e1) { |
|||
e1.printStackTrace(); |
|||
} |
|||
|
|||
} else { |
|||
try { |
|||
rsServer.telecontrol(deviceId, relayId, 1, 0); |
|||
} catch (Exception e1) { |
|||
e1.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
new SwingDemo().setVisible(true); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
package com.xr.drone.modules.entity.mqtt; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class MqttTop { |
|||
|
|||
private String ts; |
|||
|
|||
private TopDetail topDetail; |
|||
|
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
package com.xr.drone.modules.entity.mqtt; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class TopDetail { |
|||
|
|||
private String devName; |
|||
|
|||
private String devMac; |
|||
|
|||
private String battery; |
|||
|
|||
private String snapType; |
|||
|
|||
private String localtime; |
|||
|
|||
private String imageSize; |
|||
|
|||
private String image; |
|||
|
|||
} |
|||
Loading…
Reference in new issue