ChargeTimeEU / Java-OCA-OCPP

Open source client and server library of Open Charge-Point Protocol (OCPP) defined by openchargealliance.org (OCA)
MIT License
272 stars 174 forks source link

Quick start guide #21

Open goRaspy opened 7 years ago

goRaspy commented 7 years ago

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

TVolden commented 7 years ago

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. :-)

goRaspy commented 7 years ago

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

rainIand commented 7 years ago

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!

TVolden commented 7 years ago

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 commented 7 years ago

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

Dharam625 commented 7 years ago

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.*;

/*

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();
}

}

TVolden commented 7 years ago

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() ?

Dharam625 commented 7 years ago

@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 ?

TVolden commented 7 years ago

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

Dharam625 commented 7 years ago

@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 ?

BenSoHongKong commented 7 years ago

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.

svj13 commented 6 years ago

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

TVolden commented 6 years ago

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

morclin commented 6 years ago

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.

TVolden commented 6 years ago

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

morclin commented 6 years ago

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

TVolden commented 6 years ago

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).

morclin commented 6 years ago

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

workmyhappy commented 5 years ago

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

TVolden commented 5 years ago

Hi @workmyhappy,

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

Thomas