Data Interface

Summary

Momoda data infterface connect Momoda to third party systems, it can be used to scene initialization, push alarm, control objects, such as create, move, transform, remove, etc., in realtime.

There are three catelogies in Momoda data infterface, namely:

  • I Interface
  • M Interface
  • R Interface

I Interface

I (short for Initialize) interface is used for scene initialization. Data push through I Interface will loaded by Momoda client automatically.

Usage

url http://{Your Momoda Server IP}:8080/goods/save
http method GET or POST
parameters
  • g.sid: scene ID
  • g.oid: object ID
  • g.props: object initialization data

HTTP GET

  • request
1
     http://127.0.0.1:8080/goods/save?g.sid=20170320095733039126770&g.oid=cabinet1&g.props={"Initialized Data":"Initialized Data"}

Note

request will push init data in JSON data {“Initialized Data”:”Initialized Data”} to object cabinet1 in scene 20170320095733039126770

  • server response

    response

  • sample request in html/javascript
 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
 <!DOCTYPE html>

 <html>

 <head>

 <script src="jquery-1.11.1.min.js">

 </script>

 <script>

 $(document).ready(function(){

 $("button").click(function(){

 $.get('http://127.0.0.1:8080/goods/save?g.sid=20170320095733039126770&g.oid=cabinet1&g.props={"Initialized Data":"Initialized Data"}',

     function(data) { alert("Data:" + data);}

         );

 });

 });

 </script>

 </head>

 <body>

 <button>Submit data</button>

 </body>

 </html>

HTTP POST

  • request
    • url, http://*{Your Momoda Server IP}*:8080/goods/save
    • POST message:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    {
    
            g.sid:20170320095733039126770
    
            g.oid:cabinet1
    
            g.props:{"Initialized Data":"Initialized Data"}
    
    }
    

Note

request will push init data in JSON format {“Initialized Data”:”Initialized Data”} to object cabinet1 in scene 20170320095733039126770


  • server response

    response
  • sample request in html/javascript

 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
43
44
45
 <!DOCTYPE html>

 <html>

 <head>

 <script src="jquery-1.11.1.min.js">

 </script>

 <script>

 $(document).ready(function(){

 $("button").click(function(){

     $.post("http://127.0.0.1:8080/goods/save",

     {

     "g.sid":"20170320095733039126770",

     "g.oid":"cabinet1",

     "g.props":'{"Initialized Data":"Initialized Data"}'    },

     function(data) { alert("Data:" + data);}

         );

 });

 });

 </script>

 </head>

 <body>

 <button>Submit data</button>

 </body>

 </html>

M Interface

use the’M interface’to push realtime data to the scene, typical user case could be showing realtime information upon sensor objects. For instance, shows realtime alarms of fire/gas sensor, realtime location of cargo, current reading of temperature, etc.

Warning

Data pushed to M Interface is stored in Momoda server’s message queue, and there are no message replay for the queue, so if a Momoda client is newly connected to server, it only shows the current message/data in queue.

Usage

url http://{Your Momoda Server IP}:8080/data/putdata
http method GET or POST
parameters {JSON Message}

HTTP GET

  • request
1
http://127.0.0.1:8080/data/putdata?param={"20170320095733039126770":{"cabinet1": {"monitoring data":"monitoring data"}}}

Note

request will push init data in JSON data {“monitoring data”:”monitoring data”} to object cabinet1 in scene 20170320095733039126770

  • server response

    response
  • sample request in html/javascript

 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
 <!DOCTYPE html>

 <html>

 <head>

 <script src="jquery-1.11.1.min.js">

 </script>

 <script>

 $(document).ready(function(){

 $("button").click(function(){

     $.get('http://127.0.0.1:8080/data/putdata?param={"20170320095733039126770":{"cabinet1": {"monitoring data":"monitoring data"}}}',

     function(data) { alert("Data:" + data);}

         );

 });

 });

 </script>

 </head>

 <body>

 <button>Submit data</button>

 </body>

 </html>

HTTP POST

  • request
    • url, http://*{Your Momoda Server IP}*:8080/data/putdata
    • POST message:
    1
    2
    3
    4
    {
    
        param:{"20170320095733039126770":{"cabinet1":{"monitoring data":"monitoring data"}
    }
    

Note

request will push init data in JSON format {“monitoring data”:”monitoring data”} to object cabinet1 in scene 20170320095733039126770


  • sample request

    response

  • sample request in html/javascript
 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
<!DOCTYPE html>

<html>

<head>

<script src="jquery-1.11.1.min.js">

</script>

<script>

$(document).ready(function(){

$("button").click(function(){

    $.post("http://127.0.0.1:8080/data/putdata",

    {

param:'{"20170320095733039126770":{"cabinet1":{"monitoring data":"monitoring data"}}}'    },

    function(data) { alert("Data:" + data);}

        );

});

});

</script>

</head>

<body>

<button>Submit data</button>

</body>

</html>

R Interface

Remove any initialization data in a scene.

Usage

url http://{Your Momoda Server IP}:8080/goods/remove
http method GET
parameters
  • sid scene ID

HTTP GET

  • request
1
http://127.0.0.1:8080/goods/remove?sid=20170320095733039126770&oid=cabinet1

Note

request will remove all initialization data from object cabinet1 in scene 20170320095733039126770


  • server response

    response

  • sample request in html/javascript
 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
 <!DOCTYPE html>

 <html>

 <head>

 <script src="jquery-1.11.1.min.js">

 </script>

 <script>

 $(document).ready(function(){

 $("button").click(function(){

     $.get('http://127.0.0.1:8080/goods/remove?sid=20170320095733039126770&oid=cabinet1',

     function(data) { alert("Data:" + data);}

         );

 });

 });

 </script>

 </head>

 <body>

 <button>Submit data</button>

 </body>

 </html>