servertest.js 2.47 KB
Newer Older
Patrick's avatar
neu  
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
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");
var url = 'http://193.196.137.147:8990/simstadt/services/SimStadt2MonthlyenergyBalance?wsdl';
  var args = {
    gmlid: 'DEBW522AA0003113b', // an example of a building in Essen DENW22AL700004Lv
    cityID: 1,// Essen 3 // Stockach 1
    ui: {
      attic: true,
      atticHeating: true,
      basement: true,
      basementHeating: true,
      buildingType: "EFH", // other options: "RH", "MFH", "GFH", "HH"
      flatRoof: true,
      id: 'DEBW522AA0003113b', // equal with glmid
      latitude: 51.44679140365339, // an example of a building in Essen
      longitude: 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)
                res.json(result);
                return result;
            });
        });
    }   
    catch (err) {
        console.log('.../getSimS failed!\n' + err);
    }
  });