Class TrdpSessionFactory
java.lang.Object
com.trdp.config.TrdpSessionFactory
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn MD session configured from XML with anMdRequester,MdReplier, aDatasetMarshaller, and per-telegram configuration.static classA PD session configured from XML with registered publishers, subscribers, and aDatasetMarshallerfor automatic payload encoding/decoding.static final recordPer-telegram MD configuration resolved from XML. -
Method Summary
Modifier and TypeMethodDescriptionconfigureMd(DeviceConfig config, BusInterface busInterface, MdRequestHandler handler) Creates a configured MD session from a bus interface definition.configurePd(DeviceConfig config, BusInterface busInterface, PdEventListener listener) Creates a configured PD session from a bus interface definition.
-
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 configurelistener- 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
MdRequesterandMdReplierwired with interface-level socket options (host-ip, TTL, QoS) and per-telegram overrides fromMdParameterandComParameter.- Parameters:
config- the parsed device configuration (for dataset resolution)busInterface- the bus interface to configurehandler- the request handler for the replier- Returns:
- a configured MD session with requester, replier, and marshaller
- Throws:
IOException- if socket creation fails
-