Giter Club home page Giter Club logo

ocpp's Introduction

Open Charge Point Protocol for Scala Build Status

You can find more details on the official website

Includes

  • CentralSystemService.wsdl generated scala beans
  • ChargePointService.wsdl generated scala beans
  • CentralSystemClient for both 1.2 and 1.5 versions
  • Helper methods to work with ocpp
  • OCPP 1.2
  • OCPP 1.5
  • Spray based service to handle OCPP requests
  • Functionality to parse and create OCPP JSON messages
  • A high-level interface for an OCPP 1.5-JSON client

Setup

  1. Add this repository to your pom.xml:
    <repository>
        <id>thenewmotion</id>
        <name>The New Motion Repository</name>
        <url>http://nexus.thenewmotion.com/content/repositories/releases-public</url>
    </repository>
  1. Add dependency to your pom.xml:

OCPP 1.2

    <dependency>
        <groupId>com.thenewmotion.chargenetwork</groupId>
        <artifactId>ocpp-1.2_2.10</artifactId>
        <version>4.0</version>
    </dependency>

OCPP 1.5

    <dependency>
        <groupId>com.thenewmotion.chargenetwork</groupId>
        <artifactId>ocpp-1.5_2.10</artifactId>
        <version>4.0</version>
    </dependency>

Spray OCPP

    <dependency>
        <groupId>com.thenewmotion.chargenetwork</groupId>
        <artifactId>ocpp-spray_2.10</artifactId>
        <version>4.0</version>
    </dependency>

OCPP 1.5-JSON

  <dependency>
        <groupId>com.thenewmotion.chargenetwork</groupId>
        <artifactId>ocpp-json_2.10</artifactId>
        <version>4.0</version>

Usage

There is an example OCPP 1.5-JSON client application in ocpp-json/src/test/scala/com/thenewmotion/example, reproduced here for your convenience:

package com.thenewmotion.example

import java.net.URI
import com.typesafe.scalalogging.slf4j.Logging
import com.thenewmotion.ocpp.messages._
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
import com.thenewmotion.ocpp.json.{OcppError, PayloadErrorCode, OcppException, OcppJsonClient}

object JsonClientTestApp extends App {
  val connection = new OcppJsonClient("Test Charger", new URI("http://localhost:8080/ocppws")) with Logging {

    def onRequest(req: ChargePointReq): Future[ChargePointRes] = Future {
      req match {
        case GetLocalListVersionReq =>
          GetLocalListVersionRes(AuthListNotSupported)
        case _ =>
          throw OcppException(PayloadErrorCode.NotSupported, "Demo app doesn't support that")
      }
    }

    def onError(err: OcppError) = logger.warn(s"OCPP error: ${err.error} ${err.description}")

    def onDisconnect = logger.warn("WebSocket disconnect")
  }

  connection.send(BootNotificationReq(
    chargePointVendor = "The New Motion",
    chargePointModel = "Lolo 47.6",
    chargePointSerialNumber = Some("123456"),
    chargeBoxSerialNumber = None,
    firmwareVersion = None,
    iccid = None,
    imsi = None,
    meterType = None,
    meterSerialNumber = None))

  Thread.sleep(7000)

  connection.close()
}

Acknowledgements

Most of the example messages in the ocpp-json unit tests were taken from GIR ocppjs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.