serverSimS.js 3.69 KB
Newer Older
Patrick's avatar
Patrick committed
1
2
3
4
5
6
7
8
9
10
11
12
13
const http = require('http');
const fs = require('fs');
const express = require('express')
const app = express();
const bodyParser = require('body-parser')
const soap = require('soap');
app.use(bodyParser.urlencoded({ extended: false })) 
app.use(bodyParser.json())
const request = require('ajax-request');

app.use(express.static('vcm'));
app.listen(process.env.PORT || 8080);
console.log("on 8080");
Patrick's avatar
Patrick committed
14
var url = 'http://193.196.137.147:8990/orchestration/services/SimStadt2MonthlyenergyBalance?wsdl';
Patrick's avatar
Patrick committed
15
  var args = {
Patrick's avatar
Patrick committed
16
17
    gmlid: 'DENW22AL80000AQv', // an example of a building in Essen DENW22AL700004Lv ----DEBW522AA0003113b---in Stockach
    cityID: 3,// Essen 3 // Stockach 1
Patrick's avatar
Patrick committed
18
19
20
21
22
23
24
    ui: {
      attic: true,
      atticHeating: true,
      basement: true,
      basementHeating: true,
      buildingType: "EFH", // other options: "RH", "MFH", "GFH", "HH"
      flatRoof: true,
Patrick's avatar
Patrick committed
25
26
27
      id: 'DENW22AL80000AQv', // equal with glmid
      latitude: 50.774414,//51.44679140365339, // an example of a building in Essen
      longitude: 6.086995,//6.967781962878631, // an example of a building in Essen
Patrick's avatar
Patrick committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
      refurbishment: "statuQuo", // other options: "medium", "advanced"
      simulationName: "MonthlyEnergyBalance", // just use this value for Heat/Cooling Demand
      storeyCount: 3,
      timestep: 1, // dummy integer, not yet integrated but mandatory
      usageProfile: "Single Family House", // // other options: "Multi Family House"
      yearOfConstruction: 1946
    }
   
  };

  app.post('/getSimS', function(req,res){

    try {

        const data = req.body;
Patrick's avatar
Patrick committed
43
44
         console.log("data ==============")
         console.log(data.id);
Patrick's avatar
Patrick committed
45
        args.gmlid = data.id
Patrick's avatar
Patrick committed
46
47
48
49
         console.log(data[0]);
         console.log(data[1]);
         console.log("args ==============")
         console.log(args);
Patrick's avatar
Patrick committed
50
51
        //asdf
        const returnedTarget = Object.assign(args.ui,data);
Patrick's avatar
Patrick committed
52
53
54
55
56
57
         args.ui = data;
         args.gmlid = data.id;
         console.log("returned ==============")
         console.log(returnedTarget)
         console.log("args ==============")
         console.log(args);
Patrick's avatar
Patrick committed
58
59
60
61
62
63
        soap.createClient(url, function(err, client) {
            client.getMonthlyEnergyBalance(args, function(err, result) {
                if (err) throw err;
                console.log(result);
                // const obj = JSON.parse(result);
                // console.log(obj)
Patrick's avatar
Patrick committed
64
65
66
                return res.send(result);
                // res.json(result);
                // return result;
Patrick's avatar
Patrick committed
67
68
69
70
71
72
73
74
75
76
            });
        });
    }   
    catch (err) {
        console.log('.../getSimS failed!\n' + err);
    }
  });
 


Patrick's avatar
Patrick committed
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* *************
  WSDL SimStadt (Preston)
************* */
// router.get('/monthlyEnergyBalance', function(req, res) {
//   var url = 'http://193.196.137.147:8990/orchestration/services/SimStadt2MonthlyenergyBalance?wsdl'
//   var args = {
//     gmlid: 'DENW22AL80000AQv', // req.params.gmlID,
//     cityID: 3,// Essen
//     ui: {
//       attic: true,
//       atticHeating:	true,
//       basement:	true,
//       basementHeating: true,
//       buildingType:	"EFH", // "RH" , "MFH" , "GFH" , "HH"
//       flatRoof:	true,
//       id:	"DENW22AL80000AQv",
//       latitude:	50.774414,
//       longitude: 6.086995,
//       refurbishment:	"statuQuo", // "medium", "advanced"
//       simulationName:	"MonthlyEnergyBalance",
//       storeyCount:	3,
//       timestep:	1, // dummy integer, not yet integrated but mandatory
//       usageProfile:	"Single Family House", // "Multi Family House"
//       yearOfConstruction:	1946
//     }
//   };
//   soap.createClient(url, function(err, client) {
//     client.getMonthlyEnergyBalance(args, function(err, result) {
//       if (err) throw err;
//       return res.send(result);
//     });
//   });
// });