| | |
| | | import java.util.List; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public class PlcParameter2 extends Thread { |
| | | @Autowired |
| | | StorageCageService storageCageService; |
| | | |
| | | |
| | | // 用于存储应用程序的配置信息 |
| | | private Configuration config; |
| | | |
| | | // 创建一个自定义的 S7 控制器消息处理器对象 |
| | | MessageHandler customS7Control = new MessageHandler(); |
| | | // 用于存储应用程序的配置信息 |
| | | private Configuration config; |
| | | |
| | | |
| | | public PlcParameter2() throws IOException { |
| | |
| | | List<String> addressList1 = Arrays.asList(config.getProperty("Parameter2.id").split(",")); |
| | | |
| | | List<String> paramlist = S7control.getinstance().readStrings(addressList1); |
| | | // System.out.println("addressList:" + paramlist); |
| | | // System.out.println(paramlist); |
| | | |
| | | //手动状态 |
| | | List<String> addresses = Arrays.asList(config.getProperty("Parameter2.state").split(",")); |
| | |
| | | |
| | | |
| | | List<Short> data4 = S7control.getinstance().readWords(addresses4); |
| | | |
| | | //System.out.println(data); |
| | | // List<Long> TIME2 = Collections.singletonList(S7control.getinstance().readtime("DB100.194")); |
| | | // System.out.println("addressList:" + TIME2); |
| | | |
| | |
| | | // List<Short> data4 = new ArrayList<>(Arrays.asList(values4)); |
| | | // |
| | | // |
| | | // JSONObject jsonObject = new JSONObject(); |
| | | // short[] params = new short[data2.size()]; |
| | | // for (int i = 0; i < data2.size(); i++) { |
| | | // boolean value = data2.get(i); |
| | | // params[i] = value ? (short) 1 : (short) 0; |
| | | // } |
| | | //// |
| | | // short[] anniuparams = new short[anniuread.size()]; |
| | | // for (int i = 0; i < anniuread.size(); i++) { |
| | | // boolean value = anniuread.get(i); |
| | | // anniuparams[i] = value ? (short) 1 : (short) 0; |
| | | // } |
| | | //boolean转为0 1 |
| | | short[] params = customS7Control.convertBooleanListToShortArray(data2); |
| | | short[] anniuparams = customS7Control.convertBooleanListToShortArray(anniuread); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | short[] params = new short[data2.size()]; |
| | | for (int i = 0; i < data2.size(); i++) { |
| | | boolean value = data2.get(i); |
| | | params[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | // |
| | | short[] anniuparams = new short[anniuread.size()]; |
| | | for (int i = 0; i < anniuread.size(); i++) { |
| | | boolean value = anniuread.get(i); |
| | | anniuparams[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | jsonObject.append("params", params); |
| | | jsonObject.append("params", paramlist); |
| | | jsonObject.append("params", data); |
| | |
| | | |
| | | |
| | | if (webserver != null) { |
| | | |
| | | |
| | | List<String> messages = webserver.getMessages(); |
| | | |
| | |
| | | // 将布尔值添加到布尔值列表中 |
| | | sValue.add(val); |
| | | System.out.println("messageValue: " + Arrays.asList(val) + " added to the list"); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } catch (NumberFormatException e) { |
| | |
| | | } catch (Exception e) { |
| | | System.err.println("An error occurred while writing bit to PLC: " + e.getMessage()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //急停 |
| | |
| | | } catch (Exception e) { |
| | | System.err.println("An error occurred while writing bit to PLC: " + e.getMessage()); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //存片等待延迟 |