Skip to content

Commit

Permalink
Merge pull request #94 from boschglobal/task-70
Browse files Browse the repository at this point in the history
Align Terminology of VSS model classes / public API
  • Loading branch information
wba2hi authored Mar 14, 2024
2 parents b170d26 + 474602b commit af19daf
Show file tree
Hide file tree
Showing 81 changed files with 1,794 additions and 1,510 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ fun connectInsecure(host: String, port: Int) {
```kotlin
fun fetch() {
lifecycleScope.launch {
val property = Property("Vehicle.Speed", listOf(Field.FIELD_VALUE))
val response = dataBrokerConnection?.fetch(property) ?: return@launch
val request = FetchRequest("Vehicle.Speed", listOf(Field.FIELD_VALUE))
val response = dataBrokerConnection?.fetch(request) ?: return@launch
val entry = entriesList.first() // Don't forget to handle empty responses
val value = entry.value
val speed = value.float
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@

import androidx.annotation.NonNull;

import org.eclipse.kuksa.CoroutineCallback;
import org.eclipse.kuksa.DataBrokerConnection;
import org.eclipse.kuksa.DataBrokerConnector;
import org.eclipse.kuksa.DisconnectListener;
import org.eclipse.kuksa.PropertyListener;
import org.eclipse.kuksa.VssSpecificationListener;
import org.eclipse.kuksa.model.Property;
import org.eclipse.kuksa.connectivity.databroker.DataBrokerConnection;
import org.eclipse.kuksa.connectivity.databroker.DataBrokerConnector;
import org.eclipse.kuksa.connectivity.databroker.listener.DisconnectListener;
import org.eclipse.kuksa.connectivity.databroker.listener.VssPathListener;
import org.eclipse.kuksa.connectivity.databroker.listener.VssNodeListener;
import org.eclipse.kuksa.connectivity.databroker.request.FetchRequest;
import org.eclipse.kuksa.connectivity.databroker.request.SubscribeRequest;
import org.eclipse.kuksa.connectivity.databroker.request.UpdateRequest;
import org.eclipse.kuksa.connectivity.databroker.request.VssNodeFetchRequest;
import org.eclipse.kuksa.connectivity.databroker.request.VssNodeSubscribeRequest;
import org.eclipse.kuksa.coroutine.CoroutineCallback;
import org.eclipse.kuksa.proto.v1.KuksaValV1.GetResponse;
import org.eclipse.kuksa.proto.v1.KuksaValV1.SetResponse;
import org.eclipse.kuksa.proto.v1.Types;
import org.eclipse.kuksa.proto.v1.Types.Datapoint;
import org.eclipse.kuksa.testapp.databroker.connection.DataBrokerConnectorFactory;
import org.eclipse.kuksa.testapp.databroker.model.ConnectionInfo;
import org.eclipse.kuksa.vsscore.model.VssSpecification;
import org.eclipse.kuksa.vsscore.model.VssNode;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -91,82 +92,69 @@ public void onError(@NonNull Throwable error) {
}

@Override
public void fetch(@NonNull Property property, @NonNull CoroutineCallback<GetResponse> callback) {
public void fetch(@NonNull FetchRequest request, @NonNull CoroutineCallback<GetResponse> callback) {
if (dataBrokerConnection == null) {
return;
}

dataBrokerConnection.fetch(property, callback);
dataBrokerConnection.fetch(request, callback);
}

@Override
public <T extends VssSpecification> void fetch(
@NonNull T specification,
public <T extends VssNode> void fetch(
@NonNull VssNodeFetchRequest<T> request,
@NonNull CoroutineCallback<T> callback
) {
if (dataBrokerConnection == null) {
return;
}

dataBrokerConnection.fetch(specification, callback);
dataBrokerConnection.fetch(request, callback);
}

@Override
public void update(
@NonNull Property property,
@NonNull Datapoint datapoint,
@NonNull UpdateRequest request,
@NonNull CoroutineCallback<SetResponse> callback
) {
if (dataBrokerConnection == null) {
return;
}

dataBrokerConnection.update(property, datapoint, callback);
dataBrokerConnection.update(request, callback);
}

@Override
public void subscribe(@NonNull Property property, @NonNull PropertyListener propertyListener) {
public void subscribe(@NonNull SubscribeRequest request, @NonNull VssPathListener listener) {
if (dataBrokerConnection == null) {
return;
}

dataBrokerConnection.subscribe(property, propertyListener);
dataBrokerConnection.subscribe(request, listener);
}

@Override
public <T extends VssSpecification> void subscribe(
@NonNull T specification,
@NonNull VssSpecificationListener<T> specificationListener
public <T extends VssNode> void subscribe(
@NonNull VssNodeSubscribeRequest<T> request,
@NonNull VssNodeListener<T> vssNodeListener
) {
if (dataBrokerConnection == null) {
return;
}

ArrayList<Types.Field> fields = new ArrayList<>() {
{
add(Types.Field.FIELD_VALUE);
}
};

dataBrokerConnection.subscribe(specification, fields, specificationListener);
dataBrokerConnection.subscribe(request, vssNodeListener);
}

@Override
public <T extends VssSpecification> void unsubscribe(
@NonNull T specification,
@NonNull VssSpecificationListener<T> specificationListener
public <T extends VssNode> void unsubscribe(
@NonNull VssNodeSubscribeRequest<T> request,
@NonNull VssNodeListener<T> vssNodeListener
) {
if (dataBrokerConnection == null) {
return;
}

ArrayList<Types.Field> fields = new ArrayList<>() {
{
add(Types.Field.FIELD_VALUE);
}
};

dataBrokerConnection.unsubscribe(specification, fields, specificationListener);
dataBrokerConnection.unsubscribe(request, vssNodeListener);
}

public void disconnect() {
Expand Down Expand Up @@ -206,9 +194,9 @@ public void unregisterDisconnectListener(@NonNull DisconnectListener listener) {
}

@Override
public void unsubscribe(@NonNull Property property, @NonNull PropertyListener propertyListener) {
public void unsubscribe(@NonNull SubscribeRequest request, @NonNull VssPathListener listener) {
if (dataBrokerConnection != null) {
dataBrokerConnection.unsubscribe(property, propertyListener);
dataBrokerConnection.unsubscribe(request, listener);
}
}
}
Loading

0 comments on commit af19daf

Please sign in to comment.