Java-OCA-OCPP icon indicating copy to clipboard operation
Java-OCA-OCPP copied to clipboard

Quick start guide

Open goRaspy opened this issue 8 years ago • 20 comments

Hi, Your project and your approach seems very interesting ( http://www.chargetime.eu/ ). A lot of things seems functional and I am very interested to try what is existing and try to communicate with a (real) JSON 1.6 charging station.

I tried to compile the project with MAVEN (without success) and I do not really understand how begin. Could you detail a little bit this point ?

Regards

goRaspy avatar Jun 01 '17 16:06 goRaspy

Hi there

Thank you for the kind words.

I would love to compose a get started guide, maybe you can join us on gitter (link in readme) and we can make one together. That would be cool. :-)

  • Thomas

TVolden avatar Jun 01 '17 17:06 TVolden

Thats seems a very good idea ! I will join gitter right now :)

goRaspy avatar Jun 02 '17 07:06 goRaspy

Hi! I'm working on a project with EV charging stations and stumbled upon this protocol. Have you made any progress on the starting guide? My coding knowledge is mainly in C and all this doesn't really make sense to me. Thus, any help in getting started would be much appreciated!

rainIand avatar Jun 26 '17 08:06 rainIand

Hi Rainland,

That is nice to hear. I haven't made any progress on the start guide yet. I have written something down in the wiki page for this project: https://github.com/ChargeTimeEU/Java-OCA-OCPP/wiki/Getting-started

I would love to make a more friendly start guide. As I suggested earlier, I would propose that I help in the chat and then extend the start guide with the new knowledge I gain.

In related news, I'm working on an application for the protocol that people can use to try it out and maybe extend on. I'll create a new project here on github for it once I get the initial structure/design right.

TVolden avatar Jun 26 '17 10:06 TVolden

I have pushed an experimental application, so you can setup a server: https://github.com/ChargeTimeEU/ChargeTime-HQ

TVolden avatar Jul 23 '17 22:07 TVolden

I could setup the server up and running by using https://github.com/ChargeTimeEU/ChargeTime-HQ.

Then i tried sending some request using below client. But I get s as null after running this code client.send(request).whenComplete((s, ex) -> System.out.println(s) );

Could you please help.

package eu.chargetime.hq.gui;

import eu.chargetime.ocpp.Client; import eu.chargetime.ocpp.JSONClient; import eu.chargetime.ocpp.feature.profile.ClientCoreEventHandler; import eu.chargetime.ocpp.feature.profile.ClientCoreProfile; import eu.chargetime.ocpp.model.Request; import eu.chargetime.ocpp.model.core.*;

/*

  • ChargeTime.eu - Java-OCA-OCPP
  • Copyright (C) 2015-2016 Thomas Volden [email protected]
  • MIT License
  • Copyright (c) 2016 Thomas Volden
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the "Software"), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Software, and to permit persons to whom the Software is
  • furnished to do so, subject to the following conditions:
  • The above copyright notice and this permission notice shall be included in all
  • copies or substantial portions of the Software.
  • THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  • FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  • AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  • LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  • OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  • SOFTWARE. */

public class JSONClientSample { private Client client; private ClientCoreProfile core;

public static void main(String args[]) throws Exception {
    JSONClientSample jSONClientSample = new JSONClientSample();
    jSONClientSample.connect();
    jSONClientSample.sendBootNotification();
    jSONClientSample.disconnect();
}

public void connect() throws Exception {

    // The core profile is mandatory
    core = new ClientCoreProfile(new ClientCoreEventHandler() {
        @Override
        public ChangeAvailabilityConfirmation handleChangeAvailabilityRequest(ChangeAvailabilityRequest request) {

            System.out.println(request);
            // ... handle event

            return new ChangeAvailabilityConfirmation(AvailabilityStatus.Accepted);
        }

        @Override
        public GetConfigurationConfirmation handleGetConfigurationRequest(GetConfigurationRequest request) {

            System.out.println(request);
            // ... handle event

            return null; // returning null means unsupported feature
        }

        @Override
        public ChangeConfigurationConfirmation handleChangeConfigurationRequest(ChangeConfigurationRequest request) {

            System.out.println(request);
            // ... handle event

            return null; // returning null means unsupported feature
        }

        @Override
        public ClearCacheConfirmation handleClearCacheRequest(ClearCacheRequest request) {

            System.out.println(request);
            // ... handle event

            return null; // returning null means unsupported feature
        }

        @Override
        public DataTransferConfirmation handleDataTransferRequest(DataTransferRequest request) {

            System.out.println(request);
            // ... handle event

            return null; // returning null means unsupported feature
        }

        @Override
        public RemoteStartTransactionConfirmation handleRemoteStartTransactionRequest(RemoteStartTransactionRequest request) {

            System.out.println(request);
            // ... handle event

            return null; // returning null means unsupported feature
        }

        @Override
        public RemoteStopTransactionConfirmation handleRemoteStopTransactionRequest(RemoteStopTransactionRequest request) {

            System.out.println(request);
            // ... handle event

            return null; // returning null means unsupported feature
        }

        @Override
        public ResetConfirmation handleResetRequest(ResetRequest request) {

            System.out.println(request);
            // ... handle event

            return null; // returning null means unsupported feature
        }

        @Override
        public UnlockConnectorConfirmation handleUnlockConnectorRequest(UnlockConnectorRequest request) {

            System.out.println(request);
            // ... handle event

            return null; // returning null means unsupported feature
        }
    });
    client = new JSONClient(core, "chargeboxIdentity");
    client.connect("ws://localhost:8887", null);
}

public void sendBootNotification() throws Exception {

    // Use the feature profile to help create event
    Request request = core.createBootNotificationRequest("some vendor", "some model");

    // Client returns a promise which will be filled once it receives a confirmation.
    client.send(request).whenComplete((s, ex) -> {
        System.out.println(s);
    });
}

public void disconnect() {
    client.disconnect();
}

}

Dharam625 avatar Jul 30 '17 06:07 Dharam625

Hi @Dharam625,

Can I get you to open a separate issue on this? It's just easier to handle that way. Also, do you have a stack trace I can analyze?

My first though is, have you called connect() before you call sendBootNotification() ?

TVolden avatar Jul 30 '17 07:07 TVolden

@TVolden Yes I did call connect() before sendBootNotification(). I dont mind opening a separate issue. You can have a look on main function above to see series of functions I had called.

Below is stack trace:

eu.chargetime.ocpp.CallErrorException at eu.chargetime.ocpp.Client$1.handleError(Client.java:97) at eu.chargetime.ocpp.Session$CommunicatorEventHandler.onError(Session.java:182) at eu.chargetime.ocpp.Communicator$EventHandler.receivedMessage(Communicator.java:244) at eu.chargetime.ocpp.WebSocketTransmitter$1.onMessage(WebSocketTransmitter.java:60) at org.java_websocket.client.WebSocketClient.onWebsocketMessage(WebSocketClient.java:312) at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:368) at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:157) at org.java_websocket.client.WebSocketClient.interruptableRun(WebSocketClient.java:230) at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:188) at java.lang.Thread.run(Thread.java:748)

I also tried to do the same using JSONClientSample and JSONServerSample but there also i got the same exception.

Do i need to set specific values for venor, model ?

Dharam625 avatar Jul 30 '17 08:07 Dharam625

Hi @Dharam625,

Sorry for the slow reply.

It must be because the server sends a not supported error. If you modify the ChargeTime HQ to return a BootNotificationConfirmation, then you should see results.

https://github.com/ChargeTimeEU/ChargeTime-HQ/blob/master/ocpp/src/main/java/eu/chargetime/hq/ocpp/profile/CoreEventHandler.java

TVolden avatar Aug 01 '17 06:08 TVolden

@TVolden thanks :) I got it working. I am trying to mock the centralized system to see the basic functionality. Any hint on this ? Or some part of the code which i can refer ?

Dharam625 avatar Aug 01 '17 09:08 Dharam625

Hi everyone and authors :-D, I am digging into OCPP and happened to see this valuable resources. Saying hi and hope we can share and have fun here! - Ben From Hong Kong.

BenSoHongKong avatar Aug 11 '17 06:08 BenSoHongKong

Hello

I am new to OCPP, and I've been struggling to find existing implementations that are easy to set up and build. I am not new to programming, but I have been finding a lot of difficulty setting any of these programs up :(

This project is more straight forward than any of the others I have tried to get going, but I'm still not 100% sure how/what I am trying to set up, and how I can expect it to work/know when it is working.

Are you able to help me out with getting this project running? I can run the tests, but that's about it

svj13 avatar Dec 07 '17 21:12 svj13

Hi Sarah,

I'll do my best to assist. Have you looked at the start guide in the wiki?

I have set up a gitter for the project, it's easier to help there. https://gitter.im/ChargeTimeEU/Java-OCA-OCPP

TVolden avatar Dec 09 '17 06:12 TVolden

Hi everyone, Great, thanks first. I am trying to test the communication Client-Server.(using both simulations) I still get the same problem as described above, it seems because the server sends a not supported error. how should the ChargeTime HQ be modified to return a BootNotificationConfirmation.

morclin avatar Apr 04 '18 09:04 morclin

Hi Morclin,

It's been some time since I looked at HQ. I'll read up on it later, and get back to you.

Thomas

TVolden avatar Apr 04 '18 11:04 TVolden

Hi Thomas, thanks for the quick reply, I appreciate it.

morclin avatar Apr 04 '18 11:04 morclin

Hi Morclin,

I never got far with the code, but you should be able to intercept requests if you look in: https://github.com/ChargeTimeEU/ChargeTime-HQ/blob/master/ocpp/src/main/java/eu/chargetime/hq/ocpp/handlers/CoreEventHandler.java

It's pretty much the same as my example file, except I have some adapters (which I forgot the logic behind).

TVolden avatar Apr 04 '18 18:04 TVolden

Hi Thomas, thanks :) i am working on it.

morclin avatar Apr 09 '18 09:04 morclin

Hi everyone I am new to ocpp .But I trying learning everyday
Prom form Thailand.

workmyhappy avatar Nov 07 '18 10:11 workmyhappy

Hi @workmyhappy,

Happy to hear. Please join us on gitter. :)

Thomas

TVolden avatar Nov 07 '18 11:11 TVolden