Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class CommandStreamInfo implements ICommandStreamInfo
protected DataEncoding recordEncoding;
protected DataComponent resultStruct;
protected DataEncoding resultEncoding;
protected DataComponent feasibilityResultStruct;
protected DataEncoding feasibilityResultEncoding;


@Override
Expand Down Expand Up @@ -118,6 +120,14 @@ public DataEncoding getResultEncoding()
return resultEncoding;
}

@Override
public DataComponent getFeasibilityResultStructure() {
return feasibilityResultStruct;
}

public DataEncoding getFeasibilityResultEncoding() {
return feasibilityResultEncoding;
}

@Override
public boolean hasResult()
Expand Down Expand Up @@ -221,6 +231,16 @@ public B withValidTime(TimeExtent validTime)
return (B)this;
}

public B withFeasibilityResultDescription(DataComponent feasibilityResultStruct) {
instance.feasibilityResultStruct = feasibilityResultStruct;
return (B)this;
}

public B withFeasibilityResultEncoding(DataEncoding feasibilityResultEncoding) {
instance.feasibilityResultEncoding = feasibilityResultEncoding;
return (B)this;
}


@Override
public T build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,28 @@ default boolean hasInlineResult()
* null if no inline result is generated by this command channel.
*/
DataEncoding getResultEncoding();



/**
* @return True if the control stream generate feasibility information
* for commands, false otherwise
*/
default boolean hasFeasibilityResult()
{
return getFeasibilityResultStructure() != null;
}

/**
* @return The structure of the feasibility result data, or null if no
* feasibility information is generated by this command channel.
*/
DataComponent getFeasibilityResultStructure();

/**
* @return The recommended encoding for the feasibility result data, or
* null if no feasibility information is generated by this command channel.
*/
DataEncoding getFeasibilityResultEncoding();

/**
* @return The full name of the controlstream combining the system UID and the input name
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,15 @@ public DataEncoding getResultEncoding()
{
return delegate.getResultEncoding();
}

@Override
public DataComponent getFeasibilityResultStructure()
{
return delegate.getFeasibilityResultStructure();
}

@Override
public DataEncoding getFeasibilityResultEncoding() {
return delegate.getFeasibilityResultEncoding();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.stream.Stream;

import net.opengis.swe.v20.DataComponent;
import org.sensorhub.api.command.ICommandStreamInfo;
import org.sensorhub.api.common.BigId;
import org.sensorhub.api.datastore.DataStoreException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,18 @@ public void serialize(BigId key, ICommandData cmd, boolean showLinks, JsonWriter
writer.name("id").value(cmdId);
}

writer.name("control@id").value(controlId);
writer.name("controlstream@id").value(controlId);

if (cmd.hasFoi())
{
var foiId = idEncoders.getFoiIdEncoder().encodeID(cmd.getFoiID());
writer.name("foi@id").value(foiId);
writer.name("samplingFeature@id").value(foiId);
}

// TODO: needs "procedure@link" referencing the associated procdure

writer.name("issueTime").value(cmd.getIssueTime().toString());
writer.name("userId").value(cmd.getSenderID());
writer.name("sender").value(cmd.getSenderID());

// print out current status
if (key != null)
Expand All @@ -174,11 +176,11 @@ public void serialize(BigId key, ICommandData cmd, boolean showLinks, JsonWriter
.build())
.findFirst().orElse(null);
if (status != null)
writer.name("status").value(status.getStatusCode().toString());
writer.name("currentStatus").value(status.getStatusCode().toString());
}

// create or reuse existing params writer and write param data
writer.name("params");
writer.name("parameters");
var paramWriter = paramsWriters.computeIfAbsent(cmd.getCommandStreamID(),
k -> getSweCommonWriter(k, writer, ctx.getPropertyFilter()) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ public ICommandStreamInfo deserialize(JsonReader reader) throws IOException
{
DataComponent commandStruct = null;
DataComponent resultStruct = null;
DataComponent feasibilityResultStruct = null;
DataEncoding commandEncoding = new TextEncodingImpl();
DataEncoding resultEncoding = new TextEncodingImpl();
DataEncoding feasibilityResultEncoding = new TextEncodingImpl();

try
{
Expand All @@ -89,7 +91,7 @@ public ICommandStreamInfo deserialize(JsonReader reader) throws IOException
{
var prop = reader.nextName();

if ("paramsSchema".equals(prop))
if ("parametersSchema".equals(prop))
{
commandStruct = sweBindings.readDataComponent(reader);
commandStruct.setName(SWECommonUtils.NO_NAME);
Expand All @@ -107,6 +109,16 @@ else if ("resultEncoding".equals(prop))
{
resultEncoding = sweBindings.readEncoding(reader);
}
else if("feasibilityResultSchema".equals(prop))
{
// TODO: feasibility results are dropped currently
feasibilityResultStruct = sweBindings.readDataComponent(reader);
feasibilityResultStruct.setName(SWECommonUtils.NO_NAME);
}
else if("feasibilityResultEncoding".equals(prop))
{
feasibilityResultEncoding = sweBindings.readEncoding(reader);
}
else
reader.skipValue();
}
Expand All @@ -128,6 +140,8 @@ else if ("resultEncoding".equals(prop))
.withRecordEncoding(commandEncoding)
.withResultDescription(resultStruct)
.withResultEncoding(resultEncoding)
.withFeasibilityResultDescription(feasibilityResultStruct)
.withFeasibilityResultEncoding(feasibilityResultEncoding)
.build();
}

Expand All @@ -141,7 +155,7 @@ public void serialize(CommandStreamKey key, ICommandStreamInfo dsInfo, boolean s
// param structure & encoding
try
{
writer.name("paramsSchema");
writer.name("parametersSchema");
sweBindings.writeDataComponent(writer, dsInfo.getRecordStructure(), false);
}
catch (Exception e)
Expand All @@ -162,6 +176,20 @@ public void serialize(CommandStreamKey key, ICommandStreamInfo dsInfo, boolean s
throw new IOException("Error writing command structure", e);
}
}

// feasibility result schema
if (dsInfo.hasFeasibilityResult())
{
try
{
writer.name("feasibilityResultSchema");
sweBindings.writeDataComponent(writer, dsInfo.getFeasibilityResultStructure(), false);
}
catch (Exception e)
{
throw new IOException("Error writing feasibility result structure", e);
}
}

writer.endObject();
writer.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected JsonObject createControlJson(DataComponent paramStruct) throws Excepti
{
var sweBindings = new SWEJsonBindings();
writer.name("schema").beginObject();
writer.name("paramsSchema");
writer.name("parametersSchema");
sweBindings.writeDataComponent(writer, paramStruct, false);

writer.endObject();
Expand Down
Loading