Search in sources :

Example 1 with CANOpenProtocolLogic

use of org.apache.plc4x.java.canopen.protocol.CANOpenProtocolLogic in project plc4x by apache.

the class CANOpenPlcDriver method getStackConfigurer.

@Override
protected ProtocolStackConfigurer<Message> getStackConfigurer(Transport transport) {
    if (!(transport instanceof CANTransport)) {
        throw new PlcRuntimeException("CANopen driver requires a CAN transport instance");
    }
    final CANTransport<Message> canTransport = (CANTransport<Message>) transport;
    return CustomProtocolStackConfigurer.builder(canTransport.getMessageType(), canTransport::getMessageInput).withProtocol(cfg -> {
        CANOpenProtocolLogic protocolLogic = new CANOpenProtocolLogic();
        ConfigurationFactory.configure(cfg, protocolLogic);
        return new CANDriverAdapter<>(protocolLogic, canTransport.getMessageType(), canTransport.adapter(), new CANOpenFrameDataHandler(canTransport::getTransportFrameBuilder));
    }).withDriverContext(cfg -> new CANOpenDriverContext()).withPacketSizeEstimator(configuration1 -> canTransport.getEstimator()).littleEndian().build();
}
Also used : CANOpenFrameDataHandler(org.apache.plc4x.java.canopen.transport.CANOpenFrameDataHandler) SingleFieldOptimizer(org.apache.plc4x.java.spi.optimizer.SingleFieldOptimizer) PlcList(org.apache.plc4x.java.spi.values.PlcList) GeneratedDriverBase(org.apache.plc4x.java.spi.connection.GeneratedDriverBase) CANOpenDriverContext(org.apache.plc4x.java.canopen.context.CANOpenDriverContext) Configuration(org.apache.plc4x.java.spi.configuration.Configuration) CANTransport(org.apache.plc4x.java.transport.can.CANTransport) PlcValue(org.apache.plc4x.java.api.value.PlcValue) CANDriverAdapter(org.apache.plc4x.java.can.adapter.CANDriverAdapter) CANOpenFieldHandler(org.apache.plc4x.java.canopen.field.CANOpenFieldHandler) PlcValueHandler(org.apache.plc4x.java.api.value.PlcValueHandler) Message(org.apache.plc4x.java.spi.generation.Message) PlcField(org.apache.plc4x.java.api.model.PlcField) IEC61131ValueHandler(org.apache.plc4x.java.spi.values.IEC61131ValueHandler) CANOpenProtocolLogic(org.apache.plc4x.java.canopen.protocol.CANOpenProtocolLogic) PlcRuntimeException(org.apache.plc4x.java.api.exceptions.PlcRuntimeException) CANOpenConfiguration(org.apache.plc4x.java.canopen.configuration.CANOpenConfiguration) 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) Transport(org.apache.plc4x.java.spi.transport.Transport) PlcRuntimeException(org.apache.plc4x.java.api.exceptions.PlcRuntimeException) CANOpenFrameDataHandler(org.apache.plc4x.java.canopen.transport.CANOpenFrameDataHandler) Message(org.apache.plc4x.java.spi.generation.Message) CANDriverAdapter(org.apache.plc4x.java.can.adapter.CANDriverAdapter) CANOpenProtocolLogic(org.apache.plc4x.java.canopen.protocol.CANOpenProtocolLogic) CANTransport(org.apache.plc4x.java.transport.can.CANTransport) CANOpenDriverContext(org.apache.plc4x.java.canopen.context.CANOpenDriverContext)

Aggregations

PlcRuntimeException (org.apache.plc4x.java.api.exceptions.PlcRuntimeException)1 PlcField (org.apache.plc4x.java.api.model.PlcField)1 PlcValue (org.apache.plc4x.java.api.value.PlcValue)1 PlcValueHandler (org.apache.plc4x.java.api.value.PlcValueHandler)1 CANDriverAdapter (org.apache.plc4x.java.can.adapter.CANDriverAdapter)1 CANOpenConfiguration (org.apache.plc4x.java.canopen.configuration.CANOpenConfiguration)1 CANOpenDriverContext (org.apache.plc4x.java.canopen.context.CANOpenDriverContext)1 CANOpenFieldHandler (org.apache.plc4x.java.canopen.field.CANOpenFieldHandler)1 CANOpenProtocolLogic (org.apache.plc4x.java.canopen.protocol.CANOpenProtocolLogic)1 CANOpenFrameDataHandler (org.apache.plc4x.java.canopen.transport.CANOpenFrameDataHandler)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 SingleFieldOptimizer (org.apache.plc4x.java.spi.optimizer.SingleFieldOptimizer)1 Transport (org.apache.plc4x.java.spi.transport.Transport)1 IEC61131ValueHandler (org.apache.plc4x.java.spi.values.IEC61131ValueHandler)1