堆垛机信号读取
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.ruoyi.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CustomThread<T> {
|
||||
public Thread thread;
|
||||
public T runnable;
|
||||
}
|
||||
105
ruoyi-admin/src/main/java/com/ruoyi/common/domain/HslRead.java
Normal file
105
ruoyi-admin/src/main/java/com/ruoyi/common/domain/HslRead.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.ruoyi.common.domain;
|
||||
|
||||
import HslCommunication.BasicFramework.SoftBasic;
|
||||
import HslCommunication.Core.Net.IReadWriteNet;
|
||||
import HslCommunication.Core.Types.OperateResult;
|
||||
import HslCommunication.Core.Types.OperateResultExOne;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class HslRead {
|
||||
|
||||
private static SimpleDateFormat dateFormat = new SimpleDateFormat("[HH:mm:ss] ");
|
||||
|
||||
/**
|
||||
* 将结果信息显示出来,在界面里进行显示
|
||||
* @param result 等待显示的结果信息
|
||||
* @param x
|
||||
* @param address 读取的地址数据
|
||||
* @param textBox 显示结果的文本框
|
||||
* @param scrollPane 支持滚动条的控件
|
||||
* @param <T> 类型对象
|
||||
* @return
|
||||
* @return
|
||||
* @return
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static <T> T ReadResultRender(OperateResultExOne<T> result ) {
|
||||
|
||||
T x = null ;
|
||||
if (result.IsSuccess) {
|
||||
if (result.Content.getClass().isArray()) {
|
||||
|
||||
} else {
|
||||
x= (T) result.Content;
|
||||
}
|
||||
} else {
|
||||
|
||||
JOptionPane.showMessageDialog(
|
||||
null,
|
||||
dateFormat.format(new Date()) + "] Read Failed\r\nReason:" + result.ToMessageShowString(),
|
||||
"Result",
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public static int WriteResultRender(OperateResult result, String address ) { //void
|
||||
int x=0;
|
||||
if (result.IsSuccess) {
|
||||
// JOptionPane.showMessageDialog(
|
||||
// null,
|
||||
// dateFormat.format(new Date()) + "[" + address + "] Write Success",
|
||||
// "Result",
|
||||
// JOptionPane.PLAIN_MESSAGE);
|
||||
x=1;
|
||||
} else {
|
||||
// JOptionPane.showMessageDialog(
|
||||
// null,
|
||||
// dateFormat.format(new Date()) + "[" + address + "] Write Failed\r\nReason:" + result.ToMessageShowString(),
|
||||
// "Result",
|
||||
// JOptionPane.WARNING_MESSAGE);
|
||||
x=2;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public static void BulkReadRenderResult(IReadWriteNet readWrite, JTextField addTextBox, JTextField lengthTextBox, JTextArea resultTextBox ) {
|
||||
try {
|
||||
OperateResultExOne<byte[]> read = readWrite.Read(addTextBox.getText(), Short.parseShort(lengthTextBox.getText()));
|
||||
if (read.IsSuccess) {
|
||||
resultTextBox.setText("Result:" + SoftBasic.ByteToHexString(read.Content));
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "Read Failed:" + read.ToMessageShowString(), "Result", JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
JOptionPane.showMessageDialog(null, "Read Failed:" + ex.getMessage(), "Result", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetPanelEnabled(JPanel panel, boolean enable) {
|
||||
Component[] components = panel.getComponents();
|
||||
|
||||
//System.out.println("Component Length:" + components.length);
|
||||
for (Component component : components) {
|
||||
if (component instanceof JPanel) {
|
||||
SetPanelEnabled((JPanel) component, enable);
|
||||
} else {
|
||||
component.setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String IpAddressInputWrong = "IpAddress input wrong";
|
||||
public static String PortInputWrong = "Port input wrong";
|
||||
public static String SlotInputWrong = "Slot input wrong";
|
||||
public static String BaudRateInputWrong = "Baud rate input wrong";
|
||||
public static String DataBitsInputWrong = "Data bit input wrong";
|
||||
public static String StopBitInputWrong = "Stop bit input wrong";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ruoyi.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class PlcConnectInfo {
|
||||
|
||||
private String ip;
|
||||
private Integer port;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.ruoyi.common.domain;
|
||||
|
||||
/**
|
||||
* 发送数据的实体类
|
||||
* @num 长度
|
||||
* @num2 值
|
||||
*/
|
||||
public class SendData {
|
||||
private static final int DINT = 4;
|
||||
private static final int INT = 2;
|
||||
private int num;
|
||||
private int num2;
|
||||
|
||||
public SendData(int num, int num2) {
|
||||
this.num = num;
|
||||
this.num2 = num2;
|
||||
}
|
||||
|
||||
public SendData(int num, String num2) {
|
||||
this.num = num;
|
||||
this.num2 = Integer.parseInt(num2);
|
||||
}
|
||||
|
||||
public int getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(int num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public int getNum2() {
|
||||
return num2;
|
||||
}
|
||||
|
||||
public void setNum2(int num2) {
|
||||
this.num2 = num2;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user