Mise de oeuvre de JSON - RPC server
Bonjour!
Je souhaite créer une page en html par exemple affichant des lignes dans lesquelles sont affichés des valeurs issues d'interrogations de serveurs RPC distants à IP fixes via JSON.
Ainsi, chaque ligne représenteras un serveur interrogé et afficheras un nom fixe que j'aurais défini dans le code suivi de l'heure de la mise à jour, suivi des données reçus par le JSON (tout cela en ligne).
Chaque ligne se rafraîchiras automatiquement entre 10sec ou 60sec.
L'adresse cible est une adresse IP fixe.
Selon la documentation : http://files.sma.de/dl/2585/SWebBoxRPC-BEN092713.pdf le code est ainsi :
Citation:
Provides an object with the following system data:
• POWER
• DAILY-YIELD
• TOTAL-YIELD
• STATUS
• ERROR
Structure:
Code:
1 2 3 4 5 6
| {
"version": "1.0",
"proc": "GetPlantOverview",
"id": "ID",
"format": "FORMAT"
} |
Sample request:
Code:
1 2 3 4 5 6
| {
"version": "1.0",
"proc": "GetPlantOverview",
"id": "1",
"format": "JSON"
} |
Sample response:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
{
"version": "1.0",
"proc": "GetPlantOverview",
"id": "1",
"result":
{
"overview":
[
{
"meta": "GriPwr",
"name": "Momentanleistung",
"value": "4250",
"unit": "W"
},
{
"meta": "GriEgyTdy",
"name": "Tagesenergie",
"value": "45.23",
"unit": "kWh"
},
{
"meta": "GriEgyTot",
"name": "Gesamtenergie",
"value": "7821",
"unit": "kWh"
},
{
"meta": "OpStt",
"name": "Status",
"value": "MPP",
"unit": null
},
{
"meta": "Msg",
"name": "Fehler",
"value": null,
"unit": null
}
]
}
} |
The following data is sent:
POWER = 4250 W,
DAILY-YIELD = 45.23 kWh,
TOTAL-YIELD = 7821 kWh,
Status = MPP,
no error
J'ai testé avec le RPC Client, cela fonctionne à merveille :
24/09/2011 11:16:03: Sending:
Code:
1 2 3 4 5 6
| {
"version" : "1.0",
"proc" : "GetPlantOverview",
"id" : "2",
"format" : "JSON"
} |
24/09/2011 11:16:04: Received:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| {
"format" : "JSON",
"result" :
{
"overview" :
[
{
"unit" : "W",
"meta" : "GriPwr",
"name" : "GriPwr",
"value" : "69547"
},
{
"unit" : "kWh",
"meta" : "GriEgyTdy",
"name" : "GriEgyTdy",
"value" : "87.454"
},
{
"unit" : "kWh",
"meta" : "GriEgyTot",
"name" : "GriEgyTot",
"value" : "365846.616"
},
{
"unit" : "",
"meta" : "OpStt",
"name" : "OpStt",
"value" : ""
},
{
"unit" : "",
"meta" : "Msg",
"name" : "Msg",
"value" : ""
}
]
},
"proc" : "GetPlantOverview",
"version" : "1.0",
"id" : "2"
} |
Cependant, mes connaissances sont très limités et intégrer plusieurs JSON dans une même page semble unique.
Pourriez vous m'aider à le mettre en oeuvre au niveau du code HTML??
Grand merci et bonne journée