OCPP S 1.2 Add on - motown-io/motown GitHub Wiki

Responsibility

The OCPP S 1.2 Add-on handles the communication to and from Charging Stations that support the Open ChargePoint Protocol v1.2.

As the predecessor of OCPP v1.5 this OCPP version provides a little less functionality (strikethrough is not supported in OCPP v1.2):

Calls initiated by the Charging Station: Authorize, Boot Notification, Data Transfer, Diagnostics Status Notification, Firmware Status Notification, Heartbeat, Meter Values, Start Transaction, Status Notification and Stop Transaction.

Calls initiated by Motown: Cancel Reservation, Change Availability, Change Configuration, Clear Cache, Data Transfer, Get Configuration, Get Diagnostics, Get Local List Version, Remote Start Transaction, Remote Stop Transaction, Reserve Now, Reset, Send Local List, Unlock Connector and Update Firmware.

The Charging Station communication will get 'linked' to this specific add-on upon receipt of the Charging Station's BootNotification. Allowing Motown to support different versions of the OCPP protocol in parallel.

Technology

The OCPP standard is implemented using the Simple Object Access Protocol(SOAP), specifically SOAP v1.2 with WS-Addressing.

The server and client side of the webservice have been built with Apache CXF.

Configuring the add-on

All configuration samples below are Spring based. Spring is not required but it makes configuration a lot easier.

JPA

Make sure a JPA entity manager factory is running.

The JPA entities reside in package:

  • io.motown.ocpp.viewmodel.persistence.entities

The repositories reside in package:

  • io.motown.ocpp.viewmodel.persistence.repositories

Sample JPA configuration:

    <jdbc:embedded-database id="ocppWebservicesDataSource" type="HSQL"/>

    <bean id="entityManagerFactoryOcppWebServices"
              class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="ocppWebservicesDataSource"/>
        <property name="packagesToScan" value="io.motown.ocpp.viewmodel.persistence.entities"/>
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="database" value="HSQL"/>
                <property name="generateDdl" value="true"/>
            </bean>
        </property>
    </bean>

    <bean id="chargingStationRepositoryOcppWebServices"
                class="io.motown.ocpp.viewmodel.persistence.repositories.ChargingStationRepository">
          <property name="entityManagerFactory" ref="entityManagerFactoryOcppWebServices"/>
    </bean>

    <bean id="reservationIdentifierRepositoryOcppWebServices"
                class="io.motown.ocpp.viewmodel.persistence.repositories.ReservationIdentifierRepository">
          <property name="entityManagerFactory" ref="entityManagerFactoryOcppWebServices"/>
    </bean>

    <bean id="transactionRepositoryOcppWebServices"
                class="io.motown.ocpp.viewmodel.persistence.repositories.TransactionRepository">
          <property name="entityManagerFactory" ref="entityManagerFactoryOcppWebServices"/>
    </bean>

    <bean id="ocppWebServicesTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
          <property name="entityManagerFactory" ref="entityManagerFactoryOcppWebServices"/>
    </bean>

Domain service

The domain service (io.motown.ocpp.viewmodel.domain.DomainService) contains the logic for accessing the repositories, and sending commands to the Motown Core.

Sample configuration:

    <bean id="ocppDomainService" class="io.motown.ocpp.viewmodel.domain.DomainService">
        <property name="chargingStationRepository" ref="chargingStationRepositoryOcppWebServices"/>
        <property name="commandGateway" ref="domainCommandGateway"/>
        <property name="eventWaitingGateway" ref="eventWaitingGateway"/>
        <property name="entityManagerFactory" ref="entityManagerFactoryOcppWebServices"/>
        <property name="heartbeatInterval" value="900"/>
        <property name="reservationIdentifierRepository" ref="reservationIdentifierRepositoryOcppWebServices"/>
        <property name="transactionRepository" ref="transactionRepositoryOcppWebServices"/>
        <property name="userIdentitiesWithAllPermissions" ref="userIdentitiesWithAllPermissions"/>
    </bean>

    <bean id="domainCommandGateway" class="org.axonframework.commandhandling.gateway.CommandGatewayFactoryBean">
        <property name="commandBus" ref="commandBus"/>
        <property name="gatewayInterface" value="io.motown.ocpp.viewmodel.domain.DomainCommandGateway"/>
    </bean>

    <bean id="configurationCommandGateway" class="org.axonframework.commandhandling.gateway.CommandGatewayFactoryBean">
        <property name="commandBus" ref="commandBus"/>
        <property name="gatewayInterface" value="io.motown.ocpp.viewmodel.configuration.ConfigurationCommandGateway"/>
    </bean>

    <bean id="eventWaitingGateway" class="io.motown.domain.utils.axon.EventWaitingGateway">
        <property name="commandBus" ref="commandBus"/>
        <property name="eventBus" ref="eventBus"/>
    </bean>

OCPP Central System service

The OCPP Central System service is the service the Charging Stations will be using to communicate with the backoffice.

Sample configuration:

    <!-- The central system implementation -->
    <bean id="centralSystemServiceOcpp12" class="io.motown.ocpp.v12.soap.centralsystem.MotownCentralSystemService">
        <property name="domainService" ref="ocppDomainService"/>
        <!-- Continuations are used for calls with a potentially high duration like Authorize and incoming DataTransfer (which consult 'other' systems). This specifies the timeout in ms for suspending, so the transport thread can handle other requests. -->
        <property name="continuationTimeout" value="100"/>
        <!-- The fallback heartbeat interval in seconds that gets returned to the Charging Station upon a BootNotification without address information. -->
        <property name="heartbeatIntervalFallback" value="900"/>
        <!-- Contains a specific soap header reader that obtains the Charging Station Address from the header -->
        <property name="soapHeaderReader">
            <bean class="io.motown.ocpp.soaputils.header.CXFSoapHeaderReader"/>
        </property>
        <!-- Add-on id is a string value which is used to identify an add-on when multiple add-ons of the same type are running -->
        <property name="addOnId" value="1"/>
    </bean>

    <!-- Endpoint configuration -->
    <jaxws:endpoint implementor="#centralSystemServiceOcpp12"
                    address="/centralSystemServiceOcpp12"/>

OCPP Charging Station client

The OCPP client is used for communication towards Charging Stations.

Sample configuration:

    <!-- The OCPP client configuration -->
    <bean id="chargingStationOcpp12ProxyFactory"
          class="io.motown.ocpp.v12.soap.chargepoint.ChargingStationProxyFactory"/>

    <bean id="ocpp12SoapClient" class="io.motown.ocpp.v12.soap.chargepoint.ChargingStationOcpp12SoapClient">
        <property name="domainService" ref="ocppDomainService"/>
        <property name="chargingStationProxyFactory" ref="chargingStationOcpp12ProxyFactory"/>
        <property name="identifyingTokenConverterService">
            <bean class="io.motown.ocpp.v12.soap.chargepoint.IdentifyingTokenConverterService"/>
        </property>
    </bean>

Webservice exposure

In order to expose the service interface, the Apache CXF servlet should be included in your web.xml.

Sample web.xml configuration

    <servlet>
        <servlet-name>CXFServlet</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
    </servlet>

    <servlet-mapping>
        <servlet-name>CXFServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>

According to the mapping and configuration above, the endpoint of the service will be http://<server>/services/centralSystemServiceOcpp12. The WSDL can be obtained from http://<server>/services/centralSystemServiceOcpp12?wsdl.

⚠️ **GitHub.com Fallback** ⚠️