L-mobile I Digitalisierte Softwarelösungen
Imre Szecsődi
Friday, 30.09.2019
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
weather,location=us-midwest temperature=82 1465839830100400200
| -------------------- -------------- |
| | | |
| | | |
+-----------+--------+-+---------+-+---------+
|measurement|,tag_set| |field_set| |timestamp|
+-----------+--------+-+---------+-+---------+
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
api.openweathermap.org/data/2.5/weather?zip=94040,us
L-mobile I Digitalisierte Softwarelösungen
{
"coord": {"lon": -122.08,"lat": 37.39},
"weather": [
{
"id": 800,
"main": "Clear",
"description": "clear sky",
"icon": "01d"
}
],
"base": "stations",
"main": {
"temp": 296.71,
"pressure": 1013,
"humidity": 53,
"temp_min": 294.82,
"temp_max": 298.71
},
"visibility": 16093,
"wind": {
"speed": 1.5,
"deg": 350
},
"clouds": {
"all": 1
},
"dt": 1560350645,
"sys": {
"type": 1,
"id": 5122,
"message": 0.0139,
"country": "US",
"sunrise": 1560343627,
"sunset": 1560396563
},
"timezone": -25200,
"id": 420006353,
"name": "Mountain View",
"cod": 200
}
L-mobile I Digitalisierte Softwarelösungen
<script type="text/javascript">
RED.nodes.registerType('weather-node', {
category: 'Weather',
color: '#cfcbce',
defaults: {
name: {value: ""},
url: {value: "api.openweathermap.org/data/2.5/weather"},
key: {value: "", "required": true},
"method-of-gathering-data": {value: "city"},
"country-code-check": {value: ""},
"city-name": {value: ""},
"country-code": {value: ""},
lon: {value: 0, validate:RED.validators.number()},
lat: {value: 0, validate:RED.validators.number()},
"city-id": {value: 0, validate:RED.validators.number()}
},
inputs: 1,
outputs: 1,
icon: "file.png",
label: function () {
return this.name || "OpenWeatherMap Connector";
},
L-mobile I Digitalisierte Softwarelösungen
oneditprepare: function () {
$("#node-input-method-of-gathering-data").change(function () {
if ($(this).val() === "id") {
$("#city-name-div").hide();
$("#coord-div").hide();
$("#city-id-div").show();
} else if ($(this).val() === "coord") {
$("#city-name-div").hide();
$("#coord-div").show();
$("#city-id-div").hide();
} else {
$("#city-name-div").show();
$("#coord-div").hide();
$("#city-id-div").hide();
}
});
$("#node-input-country-code-check").change(function () {
if ($(this).is(":checked")) {
$("#node-input-country-code").prop("disabled", false);
} else {
$("#node-input-country-code").prop("disabled", true);
}
});
}
});
</script>
L-mobile I Digitalisierte Softwarelösungen
<script type="text/x-red" data-template-name="weather-node">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-url"><i class="fa fa-globe"></i> API URL</label>
<input type="text" name="url" id="node-input-url" placeholder="api.openweathermap.org/data/2.5/weather">
</div>
<div class="form-row">
<label for="node-input-key"><i class="fa fa-key"></i> API Key</label>
<input type="text" id="node-input-key">
</div>
<div class="form-row">
<label for="node-input-method-of-gathering-data"><i class="fa fa-download"></i> Method of gathering data</label>
<select name="method-of-gathering-data" id="node-input-method-of-gathering-data" style="display: inline-block; width: auto; vertical-align: top;">
<option value="city" selected="selected" >City Name</option>
<option value="coord">Coordinate</option>
<option value="id">City ID</option>
</select>
<div id="city-name-div">
<div class="form-row">
<label for="node-input-city-name">City Name</label>
<input type="text" name="city-name" id="node-input-city-name">
</div>
<div class="form-row">
<input type="checkbox" name="country-code-check" id="node-input-country-code-check" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-country-code-check" style="width: 70%">Use country code</label>
</div>
<div class="form-row">
<label for="node-input-country-code">Country code</label>
<input type="text" name="country-code" id="node-input-country-code" disabled>
</div>
</div>
<div id="coord-div" hidden >
<div class="form-row">
<label for="node-input-lon">Longitude</label>
<input type="text" name="node-input-lon" id="node-input-lon">
</div>
<div class="form-row">
<label for="node-input-lat">Latitude</label>
<input type="text" name="lat" id="node-input-lat">
</div>
</div>
<div id="city-id-div" hidden class="form-row">
<label for="node-input-city-id">City ID</label>
<input type="text" name="city-id" id="node-input-city-id">
</div>
</div>
</script>
L-mobile I Digitalisierte Softwarelösungen
<script type="text/x-red" data-help-name="weather-node">
<p>Open Weather Map connector</p>
</script>
L-mobile I Digitalisierte Softwarelösungen
import {Red} from "node-red";
import * as request from "request";
async function getWeatherData(config: object) {
return new Promise((resolve, reject) => {
let uri = `http://${config["url"]}?`;
if(config["method-of-gathering-data"] === "city") {
uri += `q=${config['city-name']}`;
if(config['country-code-check']) {
uri += `,${config['country-code']}`
}
} else if (config["method-of-gathering-data"] === "coord") {
uri += `lat=${config["lat"]}&lon=${config['lon']}`;
} else {
uri += `id=${config["city-id"]}`;
}
uri += `&APPID=${config['key']}`;
request(uri, {method: "get"}, (error, response, body) => {
if(error) {
reject(error);
return;
}
let data = { response: response, body: body};
resolve(data);
});
});
}
L-mobile I Digitalisierte Softwarelösungen
function redFunction(RED: Red) {
function owmGetData(config) {
RED.nodes.createNode(this, config);
let node = this;
node.on("input", async function (msg) {
msg.payload = await getWeatherData(config);
node.send(msg);
})
}
RED.nodes.registerType("weather-node", owmGetData);
}
export = redFunction;
L-mobile I Digitalisierte Softwarelösungen
{
"zipf": 2,
"binomial": 15,
"exponential": 4,
"poission": 2
}
L-mobile I Digitalisierte Softwarelösungen
Code | Name | Type | Unit |
---|---|---|---|
binomial | binomial | float | |
poission | poission | float | |
zipf | zipf | float | |
exponential | exponential | float |
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen
L-mobile I Digitalisierte Softwarelösungen