ocppjs – An experimental OCPP Simulator


Simulator for the Open Charge Point Protocol — the protocol by which a Charge Point of an electric vehicle communicates with a Central System — supporting both OCPP-S (standard OCPP, using SOAP over HTTP) and the new OCPP-J (“new” OCPP, using a Wamp inspired protocol over WebSockets). Version 1.2 and 1.5 of OCPP are supported.

Once you have your Central System Service running, use it as follows:

$ node gir-ocppjs.js start_cp ws:// BRAMUS-123
> [2013-10-31 23:02:55] Connected to Central System.
> bootnotification chargePointVendor="DBT" chargePointModel="NQC-ACDC"
> [2013-10-31 23:03:06] cp#BRAMUS-123: >>cs [2,"iYeg02bC9K4YNb8kjbo5fqyiJ7VTqN6a","BootNotification",{"chargePointVendor":"DBT","chargePointModel":"NQC-ACDC","chargePointSerialNumber":"gir.vat.mx.000e48","chargeBoxSerialNumber":"gir.vat.mx.000e48","firmwareVersion":"1.0.49","iccid":"","imsi":"","meterType":"DBT NQC-ACDC","meterSerialNumber":"gir.vat.mx.000e48"}]
> [2013-10-31 23:03:06] cp#BRAMUS-123: <<cs [3,"iYeg02bC9K4YNb8kjbo5fqyiJ7VTqN6a",{"status":"Accepted","currentTime":"2013-10-31T22:03:10.000000Z","heartbeatInterval":1200}]
> heartbeat
> [2013-10-31 23:03:13] cp#BRAMUS-123: >>cs [2,"Lo7JIBdE4CncZ8TfC9Xx6rDrWGPY4XH4","Heartbeat",{}]
> [2013-10-31 23:03:13] cp#BRAMUS-123: <<cs [3,"Lo7JIBdE4CncZ8TfC9Xx6rDrWGPY4XH4",{"currentTime":"2013-10-31T22:03:17.000000Z"}]
> quit
> [2013-10-31 23:03:18] End of simulation : interrupted by user.

The project also allows one to simulate a Central System.

ocppjs – An experimental OCPP Simulator →

Sails.js — Realtime MVC Framework for Node.js


Sails.js makes it easy to build custom, enterprise-grade Node.js apps. It is designed to resemble the MVC architecture from frameworks like Ruby on Rails, but with support for the more modern, data-oriented style of web app development. It’s especially good for building realtime features like chat.

Built on top of express. Installation via npm

sudo npm -g install sails

The introductory video will come in handy

Sails.js →

node-orm2 — Node.js Object Relational Mapping

ORM Package for Node.js. Works with MySQL, PostgreSQL and SQLite.

var orm = require('orm');

orm.connect("mysql://username:password@host/database", function (err, db) {
    if (err) throw err;

    var Person = db.define('person', {
        name      : String,
        surname   : String,
        age       : Number,
        male      : Boolean,
        continent : [ 'Europe', 'America', 'Asia', 'Africa', 'Australia', 'Antartica' ], // ENUM type
        photo     : Buffer, // BLOB/BINARY
        data      : Object // JSON encoded
    }, {
        methods: {
            fullName: function () {
                return this.name + ' ' + this.surname;
        validations: {
            age: orm.validators.rangeNumber(18, undefined, 'under-age')

    Person.find({ surname: "Doe" }, function (err, people) {
        // SQL: "SELECT * FROM person WHERE surname = 'Doe'"

        console.log("People found: %d", people.length);
        console.log("First person: %s, age %d", people[0].fullName(), people[0].age);

        people[0].age = 16;
        people[0].save(function (err) {
            // err.msg = 'under-age';

Don’t let the alpha tag fool you; I’ve used (and have contributed to) node-orm2 in a project before (along with express, mysql and when — killer combination) and must say it’s really stable.

node-orm2 →


<h1>{{ pagename|title }}</h1>
{% for author in authors %}
  <li{% if loop.first%} class="first"{% endif %}>
    {{ author }}
{% else %}
  <li>There are no authors.</li>
{% endfor %}
var template  = require('swig');
var tmpl = template.compileFile('/path/to/template.html');
    pagename: 'awesome people',
    authors: ['Paul', 'Jim', 'Jane']

A Node.js and Browser-based JavaScript Template Engine

Reminds me of PHP’s Twig (which would explain the name)

Swig →

React: Event-driven, non-blocking I/O with PHP

Inspired upon Node.js:


require 'vendor/autoload.php';

$stack = new React\Espresso\Stack(function ($request, $response) {
    $response->writeHead(200, array('Content-Type' => 'text/plain'));
    $response->end('Hello World\n');

echo 'Server running at' . PHP_EOL;

React →