Menu

Embedded programmable java instance

Help
2014-08-14
2014-08-14
  • Jørgen Bundgaard Wanscher

    I am working on a project where we are producing specialized hardware controlled by a java application through the modbus protocol.

    For automated testing purposes (only software without the actual hardware) we would like to instantiate a properly configured slave instance from the test code. I can see that I have to use the ModbuspalPane class, but it is unclear how to go from there to set up coils and registers when I have created a ModbusPal.slave instance.

    Best regards

    Jørgen

     

    Last edit: Jørgen Bundgaard Wanscher 2014-08-14
  • Jørgen Bundgaard Wanscher

    Seems like I figured most of it out by skimming the source code - hurray for OSS :-)

    1. Instantiate a slave (ModbusPal.slave.ModbusSlave)
      slave = new ModbusSlave(0);
    2. Setup Coils and Holding registers through getCoils and getHoldingRegisters methods on the slave instance.
      slave.getCoils().create(....)
      slave.getHoldingRegisters.create(....)
    3. Create a project (ModbusPalProject)
      ModbusPalProject project = new ModbusPalProject();
    4. Use the submitModbusSlave method on the project instance to attach the configured slave
      project.submitModbusSlave(slave);
    5. Make the pane instance and use the newly created project
      modbuspal = ModbusPalGui.getInstance(instanceKey);
      modbuspal.setProject(project);
    6. Now use the start and stop commands on the pane to control operation of the slave

    Open issues:
    a) How do I programmatically change the port number of the slave/project
    b) How do I programmatically change the name of the project
    - note that both open issues could be solved by saving to XML and then modifying the XML and reloading, or by modifying the modbuspal source code but I hope there is an easier way to achieve a) and b) :-)

     

Log in to post a comment.