|
@@ -9,23 +9,25 @@ import java.text.DecimalFormat;
|
|
|
public class PlcUtil {
|
|
public class PlcUtil {
|
|
|
|
|
|
|
|
public static void getDataA(S7PLC plc){
|
|
public static void getDataA(S7PLC plc){
|
|
|
- int cur = plc.readInt32("DB1.184.0");
|
|
|
|
|
|
|
+ int cur = plc.readInt32("DB41.32.0");
|
|
|
|
|
|
|
|
MesClient.param1.setText(String.valueOf(MesClient.aMax));
|
|
MesClient.param1.setText(String.valueOf(MesClient.aMax));
|
|
|
|
|
|
|
|
if(MesClient.sortA < cur){
|
|
if(MesClient.sortA < cur){
|
|
|
MesClient.sortA = cur;
|
|
MesClient.sortA = cur;
|
|
|
- if (cur == 16){
|
|
|
|
|
- plc.writeUInt16("DB1.DBW54",2);
|
|
|
|
|
|
|
+ if (cur == 16){ // 切换产品2配方
|
|
|
|
|
+ plc.writeUInt16("DB40.2",2);
|
|
|
|
|
+// plc.writeUInt16("DB40.4",3);
|
|
|
|
|
+// plc.writeUInt32("DB41.32",0);
|
|
|
}
|
|
}
|
|
|
- int fout = plc.readInt32("DB1.144.0");
|
|
|
|
|
- Float sout = plc.readFloat32("DB1.148.0");
|
|
|
|
|
|
|
+ int fout = plc.readInt32("DB41.24.0");
|
|
|
|
|
+ Float sout = plc.readFloat32("DB41.28.0");
|
|
|
|
|
|
|
|
- int fmin = plc.readInt32("DB1.26.0");
|
|
|
|
|
- Float smin = plc.readFloat32("DB1.34.0");
|
|
|
|
|
|
|
+ int fmin = plc.readInt32("DB41.0.0") - plc.readInt32("DB41.8.0");
|
|
|
|
|
+ Float smin = plc.readFloat32("DB41.12.0") - plc.readFloat32("DB41.20.0");
|
|
|
|
|
|
|
|
- int fmax = plc.readInt32("DB1.22.0");
|
|
|
|
|
- Float smax = plc.readFloat32("DB1.30.0");
|
|
|
|
|
|
|
+ int fmax = plc.readInt32("DB41.0.0") + plc.readInt32("DB41.4.0");
|
|
|
|
|
+ Float smax = plc.readInt32("DB41.12.0") + plc.readFloat32("DB41.16.0");
|
|
|
|
|
|
|
|
String qty = "0";
|
|
String qty = "0";
|
|
|
if(getResultDingA(plc).equals("OK")){
|
|
if(getResultDingA(plc).equals("OK")){
|
|
@@ -61,21 +63,21 @@ public class PlcUtil {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void getDataB(S7PLC plc){
|
|
public static void getDataB(S7PLC plc){
|
|
|
- int cur = plc.readInt32("DB1.714.0");
|
|
|
|
|
|
|
+ int cur = plc.readInt32("DB51.32.0");
|
|
|
|
|
|
|
|
MesClient.param3.setText(String.valueOf(MesClient.bMax));
|
|
MesClient.param3.setText(String.valueOf(MesClient.bMax));
|
|
|
|
|
|
|
|
if(MesClient.sortB < cur){
|
|
if(MesClient.sortB < cur){
|
|
|
MesClient.sortB = cur;
|
|
MesClient.sortB = cur;
|
|
|
|
|
|
|
|
- int fout = plc.readInt32("DB1.674.0");
|
|
|
|
|
- Float sout = plc.readFloat32("DB1.678.0");
|
|
|
|
|
|
|
+ int fout = plc.readInt32("DB51.24.0");
|
|
|
|
|
+ Float sout = plc.readFloat32("DB51.28.0");
|
|
|
|
|
|
|
|
- int fmin = plc.readInt32("DB1.556.0");
|
|
|
|
|
- Float smin = plc.readFloat32("DB1.564.0");
|
|
|
|
|
|
|
+ int fmin = plc.readInt32("DB51.0.0") - plc.readInt32("DB51.8.0");
|
|
|
|
|
+ Float smin = plc.readFloat32("DB51.12.0") - plc.readFloat32("DB51.20.0");
|
|
|
|
|
|
|
|
- int fmax = plc.readInt32("DB1.552.0");
|
|
|
|
|
- Float smax = plc.readFloat32("DB1.560.0");
|
|
|
|
|
|
|
+ int fmax = plc.readInt32("DB51.0.0") + plc.readInt32("DB51.4.0");
|
|
|
|
|
+ Float smax = plc.readFloat32("DB51.12.0") + plc.readFloat32("DB51.16.0");
|
|
|
|
|
|
|
|
String qty = "0";
|
|
String qty = "0";
|
|
|
if(getResultDingB(plc).equals("OK")){
|
|
if(getResultDingB(plc).equals("OK")){
|
|
@@ -164,8 +166,8 @@ public class PlcUtil {
|
|
|
public static Boolean setPowerOn(S7PLC plc){
|
|
public static Boolean setPowerOn(S7PLC plc){
|
|
|
Boolean ret = false;
|
|
Boolean ret = false;
|
|
|
try{
|
|
try{
|
|
|
- plc.writeBoolean("DB4.DBX0.1",true);
|
|
|
|
|
- plc.writeBoolean("DB4.DBX204.0",true);
|
|
|
|
|
|
|
+ plc.writeBoolean("DB40.0.0",true);
|
|
|
|
|
+ plc.writeBoolean("DB50.0.0",true);
|
|
|
ret = true;
|
|
ret = true;
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -201,7 +203,8 @@ public class PlcUtil {
|
|
|
public static Boolean setPowerOff(S7PLC plc){
|
|
public static Boolean setPowerOff(S7PLC plc){
|
|
|
Boolean ret = false;
|
|
Boolean ret = false;
|
|
|
try{
|
|
try{
|
|
|
- plc.writeBoolean("DB4.DBX0.1",true);
|
|
|
|
|
|
|
+ plc.writeBoolean("DB40.0.0",false);
|
|
|
|
|
+ plc.writeBoolean("DB50.0.0",false);
|
|
|
ret = true;
|
|
ret = true;
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -213,7 +216,7 @@ public class PlcUtil {
|
|
|
public static Boolean setPowerOffA(S7PLC plc){
|
|
public static Boolean setPowerOffA(S7PLC plc){
|
|
|
Boolean ret = false;
|
|
Boolean ret = false;
|
|
|
try{
|
|
try{
|
|
|
- plc.writeBoolean("DB4.DBX0.1",false);
|
|
|
|
|
|
|
+ plc.writeBoolean("DB40.0.0",false);
|
|
|
ret = true;
|
|
ret = true;
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -225,7 +228,7 @@ public class PlcUtil {
|
|
|
public static Boolean setPowerOffB(S7PLC plc){
|
|
public static Boolean setPowerOffB(S7PLC plc){
|
|
|
Boolean ret = false;
|
|
Boolean ret = false;
|
|
|
try{
|
|
try{
|
|
|
- plc.writeBoolean("DB4.DBX204.0",false);
|
|
|
|
|
|
|
+ plc.writeBoolean("DB50.0.0",false);
|
|
|
ret = true;
|
|
ret = true;
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -237,9 +240,13 @@ public class PlcUtil {
|
|
|
|
|
|
|
|
public static void setTask(S7PLC plc,int setNumA,int setNumB){
|
|
public static void setTask(S7PLC plc,int setNumA,int setNumB){
|
|
|
try{
|
|
try{
|
|
|
- plc.writeUInt16("DB1.DBW54",1);
|
|
|
|
|
- plc.writeInt32("DB1.184.0",0);
|
|
|
|
|
- plc.writeInt32("DB1.714.0",0);
|
|
|
|
|
|
|
+ plc.writeUInt16("DB40.2",1);
|
|
|
|
|
+ plc.writeUInt16("DB40.4",setNumA);
|
|
|
|
|
+ plc.writeInt32("DB41.32.0",0);
|
|
|
|
|
+
|
|
|
|
|
+ plc.writeUInt16("DB50.2",1);
|
|
|
|
|
+ plc.writeUInt16("DB50.4",setNumB);
|
|
|
|
|
+ plc.writeInt32("DB51.32.0",0);
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -248,9 +255,9 @@ public class PlcUtil {
|
|
|
public static String getResultDingA(S7PLC plc){
|
|
public static String getResultDingA(S7PLC plc){
|
|
|
String ret = "OK";
|
|
String ret = "OK";
|
|
|
try{
|
|
try{
|
|
|
- boolean retang = plc.readBoolean("DB1.314.1");
|
|
|
|
|
- boolean retang2 = plc.readBoolean("DB1.314.3");
|
|
|
|
|
- if(retang || retang2){
|
|
|
|
|
|
|
+ byte retang = plc.readByte("DB41.26");
|
|
|
|
|
+ int rent = (int) retang;
|
|
|
|
|
+ if(rent == 0){
|
|
|
ret = "NG";
|
|
ret = "NG";
|
|
|
}
|
|
}
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
@@ -263,9 +270,9 @@ public class PlcUtil {
|
|
|
public static String getResultDingB(S7PLC plc){
|
|
public static String getResultDingB(S7PLC plc){
|
|
|
String ret = "OK";
|
|
String ret = "OK";
|
|
|
try{
|
|
try{
|
|
|
- boolean retbng = plc.readBoolean("DB1.844.1");
|
|
|
|
|
- boolean retbng2 = plc.readBoolean("DB1.844.3");
|
|
|
|
|
- if(retbng || retbng2){
|
|
|
|
|
|
|
+ byte retang = plc.readByte("DB51.26");
|
|
|
|
|
+ int rent = (int) retang;
|
|
|
|
|
+ if(rent == 0){
|
|
|
ret = "NG";
|
|
ret = "NG";
|
|
|
}
|
|
}
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
@@ -277,7 +284,7 @@ public class PlcUtil {
|
|
|
|
|
|
|
|
public static boolean plcReachable(S7PLC plc){
|
|
public static boolean plcReachable(S7PLC plc){
|
|
|
try{
|
|
try{
|
|
|
- plc.readBoolean("DB4.DBX0.1");
|
|
|
|
|
|
|
+ plc.readBoolean("DB40.0.0");
|
|
|
return true;
|
|
return true;
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
return false;
|
|
return false;
|