Search in sources :

Example 1 with GenericCANProtocolLogic

use of org.apache.plc4x.java.can.generic.protocol.GenericCANProtocolLogic in project plc4x by apache.

the class GenericCANDriver method getStackConfigurer.

@Override
protected ProtocolStackConfigurer<Message> getStackConfigurer(Transport transport) {
    if (!(transport instanceof CANTransport)) {
        throw new PlcRuntimeException("Generic CAN Driver requires CAN Transport instance");
    }
    CANTransport<Message> canTransport = (CANTransport<Message>) transport;
    return CustomProtocolStackConfigurer.builder(canTransport.getMessageType(), canTransport::getMessageInput).withProtocol(cfg -> {
        GenericCANProtocolLogic protocolLogic = new GenericCANProtocolLogic();
        ConfigurationFactory.configure(cfg, protocolLogic);
        return new CANDriverAdapter<>(protocolLogic, canTransport.getMessageType(), canTransport.adapter(), new GenericCANFrameDataHandler(canTransport::getTransportFrameBuilder));
    }).withDriverContext(cfg -> new GenericCANDriverContext()).withPacketSizeEstimator(cfg -> canTransport.getEstimator()).littleEndian().build();
}
Also used : GeneratedDriverBase(org.apache.plc4x.java.spi.connection.GeneratedDriverBase) Configuration(org.apache.plc4x.java.spi.configuration.Configuration) CANTransport(org.apache.plc4x.java.transport.can.CANTransport) CANDriverAdapter(org.apache.plc4x.java.can.adapter.CANDriverAdapter) GenericCANFrameDataHandler(org.apache.plc4x.java.can.generic.transport.GenericCANFrameDataHandler) GenericCANDriverContext(org.apache.plc4x.java.can.generic.context.GenericCANDriverContext) PlcValueHandler(org.apache.plc4x.java.api.value.PlcValueHandler) Message(org.apache.plc4x.java.spi.generation.Message) IEC61131ValueHandler(org.apache.plc4x.java.spi.values.IEC61131ValueHandler) GenericCANProtocolLogic(org.apache.plc4x.java.can.generic.protocol.GenericCANProtocolLogic) GenericCANConfiguration(org.apache.plc4x.java.can.generic.configuration.GenericCANConfiguration) PlcRuntimeException(org.apache.plc4x.java.api.exceptions.PlcRuntimeException) ConfigurationFactory(org.apache.plc4x.java.spi.configuration.ConfigurationFactory) CustomProtocolStackConfigurer(org.apache.plc4x.java.spi.connection.CustomProtocolStackConfigurer) ProtocolStackConfigurer(org.apache.plc4x.java.spi.connection.ProtocolStackConfigurer) BaseOptimizer(org.apache.plc4x.java.spi.optimizer.BaseOptimizer) GenericCANFieldHandler(org.apache.plc4x.java.can.generic.field.GenericCANFieldHandler) Transport(org.apache.plc4x.java.spi.transport.Transport) PlcRuntimeException(org.apache.plc4x.java.api.exceptions.PlcRuntimeException) Message(org.apache.plc4x.java.spi.generation.Message) GenericCANDriverContext(org.apache.plc4x.java.can.generic.context.GenericCANDriverContext) CANDriverAdapter(org.apache.plc4x.java.can.adapter.CANDriverAdapter) GenericCANProtocolLogic(org.apache.plc4x.java.can.generic.protocol.GenericCANProtocolLogic) CANTransport(org.apache.plc4x.java.transport.can.CANTransport) GenericCANFrameDataHandler(org.apache.plc4x.java.can.generic.transport.GenericCANFrameDataHandler)

Aggregations

PlcRuntimeException (org.apache.plc4x.java.api.exceptions.PlcRuntimeException)1 PlcValueHandler (org.apache.plc4x.java.api.value.PlcValueHandler)1 CANDriverAdapter (org.apache.plc4x.java.can.adapter.CANDriverAdapter)1 GenericCANConfiguration (org.apache.plc4x.java.can.generic.configuration.GenericCANConfiguration)1 GenericCANDriverContext (org.apache.plc4x.java.can.generic.context.GenericCANDriverContext)1 GenericCANFieldHandler (org.apache.plc4x.java.can.generic.field.GenericCANFieldHandler)1 GenericCANProtocolLogic (org.apache.plc4x.java.can.generic.protocol.GenericCANProtocolLogic)1 GenericCANFrameDataHandler (org.apache.plc4x.java.can.generic.transport.GenericCANFrameDataHandler)1 Configuration (org.apache.plc4x.java.spi.configuration.Configuration)1 ConfigurationFactory (org.apache.plc4x.java.spi.configuration.ConfigurationFactory)1 CustomProtocolStackConfigurer (org.apache.plc4x.java.spi.connection.CustomProtocolStackConfigurer)1 GeneratedDriverBase (org.apache.plc4x.java.spi.connection.GeneratedDriverBase)1 ProtocolStackConfigurer (org.apache.plc4x.java.spi.connection.ProtocolStackConfigurer)1 Message (org.apache.plc4x.java.spi.generation.Message)1 BaseOptimizer (org.apache.plc4x.java.spi.optimizer.BaseOptimizer)1 Transport (org.apache.plc4x.java.spi.transport.Transport)1 IEC61131ValueHandler (org.apache.plc4x.java.spi.values.IEC61131ValueHandler)1 CANTransport (org.apache.plc4x.java.transport.can.CANTransport)1