Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
You Retrieve sensor data from a specific REST endpoint are required to produce a software solution, using the programming language of your choice, to address the following requirements:

• . This would be achieved by using a HTTP GET issued against the following URL:
https://ws1.chic.ulster.ac.uk/SensorCentral/REST/SensorDataRangeNanos/flgSh9oHnutzvZVOnnixFNjXIda2zula_101_101?startTs=1594297110372000000&endTs=1594297110372000000[^] . The format of the data is described in Appendix A.

• Process the retrieved data and store it in a database of your choice. This should be stored using a high-resolution index appropriate for the data type. You should store both metadata about the sensor/device and records within the payload.

• Create a user interface that can access the sensor/device payload records stored in your database and visualise these as three time-series traces on one graph.

• For each of the three traces, calculate the maximum value, minimum value, standard deviation and variance over the entire length of each series. Display the four values for each series in your user interface.

• Assuming that the three traces measure values of spatially orthogonal components of a vector, add a further graph to your user interface to display the magnitude of the vector.

• Assuming that the three traces are synchronised and correlated, develop an algorithm to count the number of peaks that occur in the value of the magnitude of the vector over the entire length of the series, and display this number in the user interface.

What I have tried:

import requests
import json

url = "https://ws1.chic.ulster.ac.uk/SensorCentral/REST/SensorDataRangeNanos/flgSh9oHnutzvZVOnnixFNjXIda2zula_101_101?startTs=1594297110372000000&endTs=1594297110372000000"

response = requests.get(url)
data = response.text
parsed = json.loads(data)

print(json.dumps)
%print(json.dumps(parsed, indent=1))
Posted
Updated 18-Jul-20 9:52am
v4
Comments
Patrice T 17-Jul-20 20:59pm    
And you have a question ?
Member 14891535 17-Jul-20 21:15pm    
Yes, how should I start and continue?
Richard MacCutchan 18-Jul-20 4:16am    
Follow the advice I gave you yesterday.
Richard MacCutchan 18-Jul-20 8:08am    
One of the things I have discovered looking at the source data, is that the format of the JSON data is not correct. There are double quotes surrounding the array after blobJson, which should not be there. Also the item names are surrounded by single rather than double quotes.

[edit]
After reading the above again, I see that this is how the data is presented, so it is up to you to correct the format before decoding the second part. But as I suggested earlier this looks like quite an advanced project, so unless you are an experienced programmer you probably want to find something a little less complicated.
Member 14891535 18-Jul-20 8:12am    
Do you mean (There are double quotes surrounding the array after blobJson,) in the original dataset in the URL? if yes, the URL is provided, I cannot change it.

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
 
Share this answer
 
Comments
Member 14891535 18-Jul-20 4:55am    
Yes, i am fully understand this. I am panic.

I had tried my first steps:

import requests
import json

url = "https://ws1.chic.ulster.ac.uk/SensorCentral/REST/SensorDataRangeNanos/flgSh9oHnutzvZVOnnixFNjXIda2zula_101_101?startTs=1594297110372000000&endTs=1594297110372000000"

response = requests.get(url)
data = response.text
parsed = json.loads(data)

print(json.dumps)
%print(json.dumps(parsed, indent=1))


(Above code is I written myself after searching for almost 3 days)
I have no idea where I can search and do second steps.
OriginalGriff 18-Jul-20 6:03am    
Start with your course notes: you will have covered the material in the last lecture or last couple of lectures, homework is always related to recent teaching - that's it's job; to make sure you were paying attention and reinforce the learning you have been given.

Searching the internet for an exact solution isn't going to work - you need to look at teh question carefully, re-read your notes and start thinking!
Member 14891535 18-Jul-20 6:22am    
I understand this. This is not related to coursework assignment. Is a competition.
I had break this to several questions where I got stuck.

https://www.codeproject.com/Questions/5274079/How-to-store-a-retrieved-data-in-a-database-of-my

I am not asking full solutions.
OriginalGriff 18-Jul-20 6:35am    
"This is not related to coursework assignment. Is a competition."
That counts as homework: it's possibly worse that cheating your school, because all the other entries put their own hard work into it and you didn't.

"I am not asking full solutions."
But you also haven't tried anything other than try to find a site that will let you "search and do second steps".

If you can't do this yet, leave it until you can: if you can't store data in a database yet, then you are going to be completely lost with later steps - you haven't learned enough (or gained enough experience to be comfortable with() complicated stuff yet.
This is the same question as How to retrieve only the first 2 data from a specific REST endpoint (no the entire data) Python[^], which you posted yesterday. And I already gave you a suggestion for how to extract the data.

In fact this is the third time you have posted this question.
 
Share this answer
 
Comments
Member 14891535 18-Jul-20 5:09am    
yes, I understand, In fact, I couldnt solve it even I had tried.

parsed = json.loads(data)

print(json.dumps(parsed, indent=1))
Richard MacCutchan 18-Jul-20 5:21am    
there is no point in repeating the same thing over again. I explained to you yesterday that you need to load the JSON data and examine it to see how it is converted into Python objects. Until you have done that you are not going to make any progress.

And having read this assignment I wonder if it is aimed at more advanced developers.
Member 14891535 18-Jul-20 5:31am    
Okay, thanks. i think I move on to next steps. I do understand and read the link you provided. Thanks.
As I have finally figured out the format of the data and how to decode it I offer the following:
Python
# decode the response from the REST service
restjson=json.loads(httpresponse)

# get the string of sensor data
rawblob=restjson[0]['blobJson']

# replace single quotes with double quotes
blobjson=rawblob.replace('\'','"')

# decode the array of sensor readings
sensordata=json.loads(blobjson)

print('List the first two entries of sensordata:')
for x in sensordata[:2]:
    print('\t', x)

print('\nList the individual items of the first entry:')
for k,v in sensordata[0].items():
    print('\t', k, ":", v)

From that you should be able to figure out what to do next.
 
Share this answer
 
v2
Comments
Member 14891535 18-Jul-20 8:41am    
Thanks. What is the meaning of httpresponse? I suppose to be:

url = "https://ws1.chic.ulster.ac.uk/SensorCentral/REST/SensorDataRangeNanos/flgSh9oHnutzvZVOnnixFNjXIda2zula_101_101?startTs=1594297110372000000&endTs=1594297110372000000"

response = requests.get(url)
data = response.text
parsed = json.loads(data)

restjson=json.load(data)
Richard MacCutchan 18-Jul-20 8:50am    
That is just the name I used for the string returned from the URL.
Member 14891535 18-Jul-20 9:02am    
The string name I put is either data, URL, but still cannot get through AttributeError Traceback (most recent call last)
<ipython-input-36-ec02c085a96e> in <module>()
9
10 # decode the response from the REST service
---> 11 restjson=json.load(response)
Member 14891535 18-Jul-20 9:05am    
I found the mistake. is restjson=json.loads(data) and not restjson=json.load
(data)
Richard MacCutchan 18-Jul-20 9:07am    
Sorry, that was my mistake in copying from the test code.
Ofcourse you should continue, but best is to get clear about which language you want to use. You better ask which libraries are recommended for that task, so you have some proper database, networking and ui tools.

But anyway - it is your task. So divide it in small chunks which you can solve and read the assigment task very carefully. Misunderstandings are one source of bugs. Find some useful IDE. Here you find Python IDE article and for C++ the Visual Studio is best.

Good luck
 
Share this answer
 
Comments
Member 14891535 18-Jul-20 4:55am    
I will edit my questions.

Yes, i am fully understand this. I am panic.

I had tried my first steps:

import requests
import json

url = "https://ws1.chic.ulster.ac.uk/SensorCentral/REST/SensorDataRangeNanos/flgSh9oHnutzvZVOnnixFNjXIda2zula_101_101?startTs=1594297110372000000&endTs=1594297110372000000"

response = requests.get(url)
data = response.text
parsed = json.loads(data)

print(json.dumps)
%print(json.dumps(parsed, indent=1))


(Above code is I written myself after searching for almost 3 days)
I have no idea where I can search and do second steps.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900