Read memory CLP zelio

0

I am having a great difficulty in developing an application in which I should, through the modbusTCP protocol, read what the Zelp clp model sends me, where it communicates with a sensor that when triggered sends through the clp a value in which I can not access . This is the first time I work with PLC and I do not have much sense of how to proceed because I did not find much on the net.

The following is what I already have:

import generic.ModbusException;
import modbusTCP.ModbusTCP;

public class TesteCLP {

    private ModbusTCP modbus;
    private String IP;

    public TesteCLP(){
        initClp();
        setPrateleira(1);
    }

    public void initClp()  {
        /***************************
         * Inicializando CLP
         */
        try {
            IP = "172.16.17.65";
            System.out.println("Configurando CLP: " + IP);

            modbus = new ModbusTCP(IP, 2);





        } catch (Exception ex) {

            System.out.println("Falha ao carregar configurações do CLP.");
            System.exit(1);
        }
    }

    public boolean setPrateleira(int andar) {

        int tentativas = 0;
        while (tentativas < 10) {
            try {
                modbus.connect();

                boolean bol = modbus.readCoil(501);

                return true;
            } catch (ModbusException e) {

                System.out.println("Falha ao comunicar com CLP [" + IP
                        + "]. Tentativa: " + (++tentativas));
                System.out.println("Reconectando... [" + (tentativas) + "]");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
            } finally {
                try {
                    if (modbus != null)
                        modbus.close();
                } catch (ModbusException e) {
                    System.out.println("Falha ao fechar conexão do CLP.");
                }
            }
        }
        return false;

    }

    public static void main(String[] args) {
        new TesteCLP();
    }
}
    
asked by anonymous 18.06.2015 / 15:38

0 answers