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> <artifactId>nimbus-jose-jwt</artifactId>
<version>6.0</version> <version>6.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.github.dathlin</groupId>
<artifactId>HslCommunication</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies> </dependencies>

View File

@ -1,5 +1,10 @@
package test; 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.sap.conn.jco.JCoTable;
import com.zzjee.sap.SapRFC; import com.zzjee.sap.SapRFC;
import org.jeecgframework.codegenerate.window.CodeWindow; import org.jeecgframework.codegenerate.window.CodeWindow;
@ -21,23 +26,50 @@ import java.util.Map;
public class JeecgOneGUI { public class JeecgOneGUI {
public static void main(String[] args) throws ParseException { public static void main(String[] args) throws ParseException {
// CodeWindow codeWindow = new CodeWindow(); SiemensPLCS siemensPLCS = SiemensPLCS.S200Smart;
// codeWindow.pack(); SiemensS7Net siemensS7Net = null;
// try { String defaultAddress = "M5.0";
// SapRFC saprfc = SapRFC.getInstance(); siemensS7Net = new SiemensS7Net(siemensPLCS);
// saprfc.prepare("ZZKMES_FM_PP112"); siemensS7Net.setIpAddress("192.168.1.99");
// saprfc.execCall(); siemensS7Net.setPort(102);
//// saprfc.getParamTableList() OperateResult connect = siemensS7Net.ConnectServer();
// JCoTable tab = saprfc.getParamTableList("ES_OUTPUT"); if(connect.IsSuccess){
// System.out.print("rows:" + tab.getNumRows()); System.out.println("connect success");
// } catch (Exception e) { }else{
// System.out.print(e.getMessage()); 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);
} }
} }