Ich verstehe nicht, wie der Server und der Client der OCA-OCPP-Bibliothek für Java mit dem EV-Ladegerät arbeiten. Ich verstehe nicht, welchen Port ich verwenden muss, um WebSocket anzufordern und wie das EV -Ladegerät (Mennekes) konfiguriert wird. Ich möchte keinen Client haben, der zwei separate Verbindungen verwalten muss, einen für den Server und den anderen für das EV -Ladegerät. < /P>
public class OCPPClient {
private IClientAPI client;
private ClientCoreProfile core;
private JSONConfiguration configuration;
private WssSocket wssSocket;
public void connect(String ipChargingPoint, String port) throws Exception {
// The core profile is mandatory
core = new ClientCoreProfile(new ClientCoreEventHandler() {})
configuration = JSONConfiguration.get();
configuration.setParameter(JSONConfiguration.USERNAME_PARAMETER, "operator");
configuration.setParameter(JSONConfiguration.PASSWORD_PARAMETER, "CX1zRpdK");
configuration.setParameter(JSONConfiguration.TCP_NO_DELAY_PARAMETER, false);
configuration.setParameter(JSONConfiguration.PROXY_PARAMETER, null);
configuration.setParameter(JSONConfiguration.PING_INTERVAL_PARAMETER, 300);
configuration.setParameter(JSONConfiguration.WEBSOCKET_WORKER_COUNT, 4);
configuration.setParameter(JSONConfiguration.CONNECT_TIMEOUT_IN_MS_PARAMETER, 10000);
wssSocket = new WssSocket();
wssSocket.uri(new URI("ws://" + ipChargingPoint + ":" + port));
client = new JSONClient(core, "137640200473", wssSocket, configuration);
client.connect("ws://" + ipChargingPoint + ":" + port, 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 IClientAPI getClient() {
return client;
}
public void disconnect() {
client.disconnect();
}
}
< /code>
@Data
public class OCPPServer {
private JSONServer server;
private ServerCoreProfile core;
private Map clients = new HashMap();
private JSONConfiguration configuration;
public void started() throws Exception
{
if (server != null)
return;
configuration = JSONConfiguration.get();
configuration.setParameter(JSONConfiguration.USERNAME_PARAMETER, "operator");
configuration.setParameter(JSONConfiguration.PASSWORD_PARAMETER, "CX1zRpdK");
configuration.setParameter(JSONConfiguration.TCP_NO_DELAY_PARAMETER, true);
configuration.setParameter(JSONConfiguration.PROXY_PARAMETER, 3000);
configuration.setParameter(JSONConfiguration.PING_INTERVAL_PARAMETER, 300);
configuration.setParameter(JSONConfiguration.WEBSOCKET_WORKER_COUNT, 4);
configuration.setParameter(JSONConfiguration.CONNECT_TIMEOUT_IN_MS_PARAMETER, 10000);
// The core profile is mandatory
core = new ServerCoreProfile(new ServerCoreEventHandler() {});
server = new JSONServer(core,configuration);
server.open("172.28.2.83", 3000, new ServerEvents() {})
System.out.println("Server started and listening on 172.28.2.83:3000");
}
public void sendClearCacheRequestToClient(String idStation) throws Exception {
// Récupérer le client correspondant à l'ID de la station
OCPPClient client = clients.get(idStation);
if (client != null) {
// Utiliser le profil de fonctionnalité pour aider à créer l'événement
ClearCacheRequest request = core.createClearCacheRequest();
// Le client renvoie une promesse qui sera remplie une fois qu'il recevra une confirmation.
client.getClient().send(request).whenComplete((confirmation, ex) -> {
if (ex != null) {
System.out.println("Failed to send ClearCacheRequest to client: " + ex.getMessage());
} else {
//Le serveur a reçu une confirmation de la station de recharge
System.out.println("ClearCacheRequest sent to client: " + confirmation);
}
});
} else {
System.out.println("No client found for station ID: " + idStation);
}
}
public void stop(){
server.close();
}
public int getActiveSessions() {
return clients.size();
}
public void createSessions(String idStation, String ipStation, String port ) {
OCPPClient client = new OCPPClient();
if(server == null){
try {
started();
} catch (Exception e) {
e.printStackTrace();
}
}
try {
client.connect(ipStation, port); // Assurez-vous que l'adresse IP de la station est correcte
System.out.println("Connected to ws://" + ipStation + " on port " + port);
clients.put(idStation, client);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public OCPPClient getClient(String uuid) {
return clients.get(uuid);
}
}
< /code>
class OCPPConnectionTest {
@Test
void testClientServerConnection() throws Exception {
OCPPServer server = new OCPPServer();
// Start the server
server.started();
assertEquals(0, server.getActiveSessions());
// Connect the client and send boot notification
server.createSessions("1", "172.28.2.57", "3000");
server.getClient("1").sendBootNotification();
// Verify that the server has an active session
assertEquals(1, server.getActiveSessions());
}
}
Ich verstehe nicht, wie der Server und der Client der OCA-OCPP-Bibliothek für Java mit dem EV-Ladegerät arbeiten. Ich verstehe nicht, welchen Port ich verwenden muss, um WebSocket anzufordern und wie das EV -Ladegerät (Mennekes) konfiguriert wird. [url=viewtopic.php?t=30561]Ich möchte[/url] keinen Client haben, der zwei separate Verbindungen verwalten muss, einen für den Server und den anderen für das EV -Ladegerät. < /P> [code]public class OCPPClient { private IClientAPI client; private ClientCoreProfile core; private JSONConfiguration configuration; private WssSocket wssSocket;
public void connect(String ipChargingPoint, String port) throws Exception {
// The core profile is mandatory core = new ClientCoreProfile(new ClientCoreEventHandler() {})
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)); }
// The core profile is mandatory core = new ServerCoreProfile(new ServerCoreEventHandler() {});
server = new JSONServer(core,configuration); server.open("172.28.2.83", 3000, new ServerEvents() {}) System.out.println("Server started and listening on 172.28.2.83:3000");
}
public void sendClearCacheRequestToClient(String idStation) throws Exception { // Récupérer le client correspondant à l'ID de la station OCPPClient client = clients.get(idStation);
if (client != null) { // Utiliser le profil de fonctionnalité pour aider à créer l'événement ClearCacheRequest request = core.createClearCacheRequest();
// Le client renvoie une promesse qui sera remplie une fois qu'il recevra une confirmation. client.getClient().send(request).whenComplete((confirmation, ex) -> { if (ex != null) { System.out.println("Failed to send ClearCacheRequest to client: " + ex.getMessage()); } else { //Le serveur a reçu une confirmation de la station de recharge System.out.println("ClearCacheRequest sent to client: " + confirmation); } }); } else { System.out.println("No client found for station ID: " + idStation); } }
public void stop(){ server.close(); }
public int getActiveSessions() { return clients.size(); }
public void createSessions(String idStation, String ipStation, String port ) { OCPPClient client = new OCPPClient(); if(server == null){ try { started(); } catch (Exception e) { e.printStackTrace(); } } try { client.connect(ipStation, port); // Assurez-vous que l'adresse IP de la station est correcte System.out.println("Connected to ws://" + ipStation + " on port " + port); clients.put(idStation, client); } catch (Exception e) { throw new RuntimeException(e); } }
normalerweise beim Schreiben einer Netzwerk-/Socket -Schnittstelle in C würde man die Funktionsfamilie von NTOH und hton verwenden, um zwischen der Reihenfolge der Host -Byte -Byte- und Netzwerk...
normalerweise beim Schreiben einer Netzwerk-/Socket -Schnittstelle in C würde man die Funktionsfamilie von NTOH und hton verwenden, um zwischen der Reihenfolge der Host -Byte -Byte- und Netzwerk...
Ich bin neu bei OCPP (Open -Lad -Point -Protokoll), und ich habe erhebliche Schwierigkeiten, mit dem Tauchen mit dem Betreff zu beginnen. Jede Hilfe wird stark angeeignet. Zum Beispiel maximale...
Ich entwickle ein System zur Überwachung von Geldtransfers. Markaz ).
In Zukunft werden immer mehr Kriterien hinzugefügt, und für jedes neue Kriterium wird
ein neuer Beobachter erstellt, um seine...