Frequently Asked Question
OCPP stands for Open Charge Point Protocol. It is a standardized communication protocol used in the electric vehicle charging infrastructure industry. OCPP provides a common language for communication between charging stations and central management systems or charging network operators.
This feature is implemented in the Typhoon HIL Control Center 2023.3 and is available to use in the SCADA application as a Python library. The library is open source and can be accessed from https://github.com/mobilityhouse/ocpp.
A wrapper python script was developed in order to make it easier for users to start using it. The python code in attached in this article and is detailed explained below. In this, it is simulated a central system with OCPP Server side, to control and test chargers also running with OCPP protocol.
The provided Python code sets up an OCPP (Open Charge Point Protocol) server using websockets to communicate with electric vehicle (EV) charging stations. The server receives messages from connected charge points, processes them, and responds accordingly. Below is a breakdown of the main components and functionalities of the code:
- Importing required modules: The code imports various modules necessary for its functionality, such as
signal
,asyncio
,queue
,logging
,websockets
, and several classes and enums from theocpp
package. - Global Variables: The code defines several global variables, including
ocpp_info
,sendCommand
,loop
,ocppCommandQueue
,ocppResponseQueue
, andcharge_point_vendor
,charge_point_model
. - Custom Charge Point Class: The code defines a custom charge point class called
MyChargePoint
, which inherits fromChargePoint
class provided by theocpp
package. This class implements various OCPP actions like BootNotification, Heartbeat, StatusNotification, Authorize, DataTransfer, MeterValues, StartTransaction, and StopTransaction. Each method within this class is decorated with the@on(Action.ActionName)
decorator to specify the action it handles. - Helper Functions: The code defines several helper functions like
get_connected_charge_points
,get_charge_points_status
,call_get_device_configuration
,wait_get_device_configuration
, etc. These functions handle various tasks like getting connected charge points, getting charge point status, calling OCPP commands, and waiting for their responses. - Websocket Server Setup: The
main
function sets up a websocket server to listen for incoming connections from charge points. When a new charge point connects or an existing charge point reconnects, theon_connect
coroutine is called. - Server Loop: The server handles multiple charge points concurrently using asyncio. Each charge point runs in its own coroutine (
cp_start
), and the main server loop awaits connections from new charge points while managing the send/receive commands using thesendCommands
coroutine. main
Function: Themain
function sets up the websocket server on IP address 0.0.0.0 and port 5000. It also registers signal handlers for graceful shutdown.
In the SCADA panel, the main macro widget called occp tests execute the main loop asynchronously, making it the entry point of the program.
Overall, this code serves as an OCPP server capable of communicating with multiple electric vehicle charging stations concurrently and handling various OCPP actions initiated by these stations.