Class TrdpSessionFactory

java.lang.Object
com.trdp.config.TrdpSessionFactory

public class TrdpSessionFactory extends Object
Factory that creates fully configured TRDP sessions from a parsed DeviceConfig. Wires telegram definitions into publishers and subscribers with automatic dataset marshalling.

Usage:

DeviceConfig config = TrdpConfig.load(Path.of("trdp-config.xml"));
BusInterface bi = config.getBusInterfaces().get(0);

try (ConfiguredPdSession session = TrdpSessionFactory.configurePd(config, bi, listener)) {
    session.start();
    session.putData(1000, Map.of("speed", 42L, "doorOpen", true));
}
See Also:
  • Method Details

    • configurePd

      public static TrdpSessionFactory.ConfiguredPdSession configurePd(DeviceConfig config, BusInterface busInterface, PdEventListener listener) throws IOException
      Creates a configured PD session from a bus interface definition.

      Iterates all PD telegrams in the bus interface and registers publishers (type "source"), subscribers (type "sink"), or both (type "source-sink"). The returned session is ready to TrdpSessionFactory.ConfiguredPdSession.start().

      Parameters:
      config - the parsed device configuration (for dataset resolution)
      busInterface - the bus interface to configure
      listener - the event listener for all subscribers
      Returns:
      a configured session with publishers, subscribers, and a dataset marshaller
      Throws:
      IOException - if socket or multicast group operations fail
    • configureMd

      public static TrdpSessionFactory.ConfiguredMdSession configureMd(DeviceConfig config, BusInterface busInterface, MdRequestHandler handler) throws IOException
      Creates a configured MD session from a bus interface definition.

      Creates an MdRequester and MdReplier wired with interface-level socket options (host-ip, TTL, QoS) and per-telegram overrides from MdParameter and ComParameter.

      Parameters:
      config - the parsed device configuration (for dataset resolution)
      busInterface - the bus interface to configure
      handler - the request handler for the replier
      Returns:
      a configured MD session with requester, replier, and marshaller
      Throws:
      IOException - if socket creation fails