00Bock / MSG

automatic global monitoring system for micro smart grids
0 stars 0 forks source link

Live-Daten aus DAI-Labor beziehen #9

Closed 00Bock closed 10 years ago

00Bock commented 10 years ago

HTTP-get request schreiben, um die Daten von DAI zu beziehen. Aktive Auslesung der Daten, keine passive Datei.

ID-requests

siehe Mail vom 6.8. von Voß.

Wie gehen wir vor?

00Bock commented 10 years ago

Mail vom 6.8.:

"Principally a REST-Service instead of the so far used SOAP-services is no problem, and also JSON instead of XML is no problem. Providing the service as requested would principally not be a problem, but especially since you plan to extend the service during the project we have some concerns with the current setup, and want to discuss those with you in order to make the service as flexible and future-proof as possible for the project:

  1. Mapping form Schneider-ID to Strings on our side: The Strings you want to have in the JSON are only relevant on your side, while the IDs are known to all of us. Currently it would mean for us to keep a mapping from Strings -> ID in sync with your side. Every time that list changes on your side (e.g. something new is added, some String changes), we would have to change it in our code and redeploy the system.

So I would suggest to work with the IDs as identifiers only. Here an example of how we could provide the JSON then:

{ "Time": "2013-08-02 14:24", "IDs": [ 5, 6, 8, 10, .... ] "Values": [ 0.11, 0.12, 15.716, 13.777, .... ] }

                           Time could remain the time string of the request. IDs are an array of the IDS and Values contains the corresponding values in the same order.
  1. Fixed set of requested points: Similar to the argument above we would have to keep a list of points you want to have provided in sync with you and have it hardcoded, meaning a deployment every time you want a new point. So it would be better if you can pass the Ids of the points you want as an argument with every request you do!

So if we want to stick with a HTTP GET request, you could provide the above array of IDs in the URL as follows: http://:/? IDs[]=5& IDs[]=6& IDs[]=8& IDs[]=10….

We could flexibly simply return all the latest values to the ids you provided in the GET-request! Then no hardcoding would be possible on our side!

If we don’t expect too many changes the original set up would still be possible, but I believe the proposed approach is much more flexible, as we don’t need to keep lists hardcoded. And I am pretty sure that it will change quite a bit over the year!

If your client is not as flexible in working with the above approach, we could also think about using a database table that you populate with the IDs and Strings you need! But I believe the above sketched approach is the more flexible and elegant."

mabecko commented 10 years ago

Der Zugriff per http-request auf eine lokale Datei funktioniert (siehe unten). Sobald der Webservice von DAI steht, sollten wir ausprobieren, ob der Zugriff per http-get-request auch funktioniert.

var json = (function() {
            var json = null;
            $.ajax({
                'async': false,
                'global': false,
                'url': "data/data_producer.json",
                'dataType': "json",
                'success': function (data) {
                    json = data;
                }
            });
            console.log("Daten werden geladen...");
            return json;
        })();

WICHTIG: Mauricio hat darauf hingeweisen, dass die Daten aus Sicherheitsgründen nicht für jeden verfügbar sein sollten. Darum sollte sich eigentlich das DAI kümmern. Wir sollten aber darauf achten, dass so etwas wie eine Verschlüsselung eingerichtet wird.

00Bock commented 10 years ago

Das funktionierte doch jetzt? Kann man doch den Issue schliessen?

mabecko commented 10 years ago

Ja, die Daten können mit dem Code geladen werden. Dafür muss man aktuell im Gäste-WLAN in der Plattform eingeloggt sein. Das ist nicht logisch aber geht aus netzwerktechnischen Gründen gerade nicht anders.

Ansprechpartner für weitere Infos ist Mauricio.