PLC 测试

master
erzhongxmu 2022-09-11 21:47:32 +08:00
parent 6980da3d1e
commit 270d54c78f
2 changed files with 52 additions and 16 deletions

View File

@ -943,7 +943,11 @@
<artifactId>nimbus-jose-jwt</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>com.github.dathlin</groupId>
<artifactId>HslCommunication</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies>

View File

@ -1,5 +1,10 @@
package test;
import HslCommunication.BasicFramework.SoftBasic;
import HslCommunication.Core.Types.OperateResult;
import HslCommunication.Core.Types.OperateResultExOne;
import HslCommunication.Profinet.Siemens.SiemensPLCS;
import HslCommunication.Profinet.Siemens.SiemensS7Net;
import com.sap.conn.jco.JCoTable;
import com.zzjee.sap.SapRFC;
import org.jeecgframework.codegenerate.window.CodeWindow;
@ -21,23 +26,50 @@ import java.util.Map;
public class JeecgOneGUI {
public static void main(String[] args) throws ParseException {
// CodeWindow codeWindow = new CodeWindow();
// codeWindow.pack();
// try {
// SapRFC saprfc = SapRFC.getInstance();
// saprfc.prepare("ZZKMES_FM_PP112");
// saprfc.execCall();
//// saprfc.getParamTableList()
// JCoTable tab = saprfc.getParamTableList("ES_OUTPUT");
// System.out.print("rows:" + tab.getNumRows());
// } catch (Exception e) {
// System.out.print(e.getMessage());
SiemensPLCS siemensPLCS = SiemensPLCS.S200Smart;
SiemensS7Net siemensS7Net = null;
String defaultAddress = "M5.0";
siemensS7Net = new SiemensS7Net(siemensPLCS);
siemensS7Net.setIpAddress("192.168.1.99");
siemensS7Net.setPort(102);
OperateResult connect = siemensS7Net.ConnectServer();
if(connect.IsSuccess){
System.out.println("connect success");
}else{
System.out.println("connect error");
}
// OperateResultExOne<Float> floatOperateResultExOne = siemensS7Net.ReadFloat(defaultAddress);
// if(floatOperateResultExOne.IsSuccess){
// System.out.println("read success");
// System.out.println(floatOperateResultExOne.Content);
// }else{
// System.out.println(floatOperateResultExOne.Content);
// }
// defaultAddress = "M5.0";
// siemensS7Net.Write(defaultAddress,false);
// defaultAddress = "VD320";
// float speed = (float) 5.00;
// siemensS7Net.Write(defaultAddress,speed);
// defaultAddress = "VD300";
// float position = (float) -50.00;//方向
// siemensS7Net.Write(defaultAddress,position);
// defaultAddress = "M5.0";
// siemensS7Net.Write(defaultAddress,true);
defaultAddress = "M7.0";
siemensS7Net.Write(defaultAddress,false);
defaultAddress = "VD420";
float speed = (float) 5.00;
siemensS7Net.Write(defaultAddress,speed);
defaultAddress = "VD400";
float position = (float) 50.00;//换向
siemensS7Net.Write(defaultAddress,position);
defaultAddress = "M7.0";
siemensS7Net.Write(defaultAddress,true);
Calendar now = DateUtils.getCalendar();
Calendar scrq = DateUtils.parseCalendar("2021-04-05","yyyy-MM-dd");
int rq = DateUtils.dateDiff('d',now,scrq);
System.out.println(rq);
}
}