servertest.js 3.69 KB
Newer Older
Patrick's avatar
Patrick committed
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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
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 || 8083);
console.log("on 8080");
var url = 'http://193.196.137.147:8990/orchestration/services/SimStadt2MonthlyenergyBalance?wsdl';
  var args = {
    gmlid: 'DENW22AL80000AQv', // an example of a building in Essen DENW22AL700004Lv ----DEBW522AA0003113b---in Stockach
    cityID: 3,// Essen 3 // Stockach 1
    ui: {
      attic: true,
      atticHeating: true,
      basement: true,
      basementHeating: true,
      buildingType: "EFH", // other options: "RH", "MFH", "GFH", "HH"
      flatRoof: true,
      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
      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;
         console.log("data ==============")
         console.log(data.id);
        args.gmlid = data.id
         console.log(data[0]);
         console.log(data[1]);
         console.log("args ==============")
         console.log(args);
        //asdf
        const returnedTarget = Object.assign(args.ui,data);
         args.ui = data;
         args.gmlid = data.id;
         console.log("returned ==============")
         console.log(returnedTarget)
         console.log("args ==============")
         console.log(args);
        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)
                return res.send(result);
                // res.json(result);
                // return result;
            });
        });
    }   
    catch (err) {
        console.log('.../getSimS failed!\n' + err);
    }
  });
 


/* *************
  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);
//     });
//   });
// });