Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Implementation of the Open Charge Point Protocol in C# (.NET 8)

License

NotificationsYou must be signed in to change notification settings

fabyr/ocpp-sharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An implementation of theOpen Charge Point Protocol (OCPP) in C#.

Currently supported versions:

  • Ocpp 1.6
  • Ocpp 2.0.1

Table of contents

Dependencies

  • Newtonsoft.Json
  • .NET 8

Features

  • C# classes for all messages of the OCPP-Protocol.
  • Easy to set up server and event system for processing messages.

What it isn't

It's not a ready-to-go backend server. You still have to implement what happens once an OCPP-Message has been received and how respond accordingly.

Possible use cases

  • Automating certain ocpp-communication
  • Emulating a charge point
  • Implementation of a basic backend server for charge points

Running the examples

A minimalistic client and server example can be found under/ocpp-sharp.examples

Start the server:

cd ./ocpp-sharp.examples/serverdotnet run

And then a client:

cd ./ocpp-sharp.examples/clientdotnet run

The examples are preconfigured to connect to each other onlocalhost:8000
and exchange some example messages.

Basic server code

usingOcppSharp.Server;usingOcppSharp.Protocol.Version16.RequestPayloads;usingOcppSharp.Protocol.Version16.ResponsePayloads;usingOcppSharp.Protocol;namespaceOcppApp;publicclassProgram{publicstaticvoidMain(string[]args){// Set up a server to listen on port 80// Stations will be connecting to ws://<Hostname>/ocpp16/<Station ID>OcppSharpServerserver=new("/ocpp16",ProtocolVersion.OCPP16,80);server.RegisterHandler<BootNotificationRequest>((server,sender,request)=>{Console.WriteLine($"Received BootNotification! (Message ID ={request.FullRequest!.MessageId})");Console.WriteLine($"Vendor:{request.ChargePointVendor}");Console.WriteLine($"Serial Number:{request.ChargePointSerialNumber}");// ...// Always need to send a responsereturnnewBootNotificationResponse(){CurrentTime=DateTime.Now,Interval=90// Heartbeat Interval};});server.Start();Console.WriteLine("Server started!");Console.ReadLine();server.Stop();}}

Motivation

This project was part of a private OCPP-Backend project.It was then split up into its own project here.

About

Implementation of the Open Charge Point Protocol in C# (.NET 8)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp