In [102]:
import rsplib as rsp

In [116]:
e = rsp.Experiment()
repetition=10
qname = "Q11"
experimentName = "/experiment11.json"

e.add_engine('http://csparql.westeurope.cloudapp.azure.com', 80, rsp.Dialects.CSPARQL)

q = e.add_query(qname, "query", rsp.Dialects.CSPARQL)
q.set_select_clause("ASK")
q.set_where_clause("{ {?obId1 a ?ob.?obId1 <http://purl.oclc.org/NET/ssnx/ssn#observedProperty> ?p1.?obId1 <http://purl.oclc.org/NET/sao/hasValue> ?v1.?obId1 <http://purl.oclc.org/NET/ssnx/ssn#observedBy> <http://www.insight-centre.org/dataset/SampleEventService#AarhusWeatherData0>.}Filter (!bound(?obId1))}")
e.add_windowed_stream(qname,"AarhusWeatherData0", "http://triplewave1.westeurope.cloudapp.azure.com:4000/sgraph", '3s','1s' )

#e.add_graph(qname, "SensorRepository", "https://rsplab.blob.core.windows.net/static/SensorRepository.rdf", serialization="RDF/XML", default='true')
#e.add_graph(qname, "AarhusLibraryEvents", "https://rsplab.blob.core.windows.net/static/AarhusLibraryEvents.rdf", serialization="RDF/XML", default='true')


Out[116]:
<rsplib.Experiment at 0x7f87ccf73be0>

In [117]:
q


Out[117]:
{'name': 'Q11', 'body': 'SELECT ASK FROM STREAM <AarhusWeatherData0> [RANGE 3s STEP 1s]\n\nWHERE { {?obId1 a ?ob.?obId1 <http://purl.oclc.org/NET/ssnx/ssn#observedProperty> ?p1.?obId1 <http://purl.oclc.org/NET/sao/hasValue> ?v1.?obId1 <http://purl.oclc.org/NET/ssnx/ssn#observedBy> <http://www.insight-centre.org/dataset/SampleEventService#AarhusWeatherData0>.}Filter (!bound(?obId1))}', 'dialect': 'CSPARQL', 'type': 'query'}

In [118]:
import json

base_dir = "./experiment_csparql"
def jdefault(o):
        return o.__dict__()
    
with open(base_dir+experimentName, "w") as myfile:
    myfile.write(json.dumps(e, default=jdefault, indent=4, sort_keys=True))

In [119]:
rsp.execute(e)


{"name":"csparql","host":"csparql/","runUUID":"0ca67236-2776-11e7-8ce9-000d3a27a904","port":8182,"empty_results":false,"inference":false,"timestam_function":false,"backloop":true,"num_streams":2,"num_datasets":1,"num_queries":1}
Registering stream: AarhusWeatherData0
"AarhusWeatherData0 already exists"
Registering query Q11 
"Error while registering query body"
Error while registering query body
Registering observers for Q11
"Q11 ID is not associated to any registered query"
"Q11 ID is not associated to any registered query"
[{"id":"Q12","type":"QUERY","status":"RUNNING"}]
Out[119]:
<rsplib.ExperimentExecution at 0x7f87ccf73e10>

In [ ]: