Skip to content

Commit

Permalink
Merge pull request #166 from chinyihan/Exponential_Error
Browse files Browse the repository at this point in the history
Exponential Error and Conditional Fixing
  • Loading branch information
nicolaisi authored Jul 3, 2024
2 parents 3e65d5e + e5e9e63 commit 5f18d91
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class SaveHandler(tornado.web.RequestHandler):
def post(self):
json_obj = json_decode(self.request.body)

with open("style.yaml", 'wb', encoding='utf8') as output:
with open("style.yaml", 'wb') as output:
output.write(yaml.safe_dump(json_obj, encoding='utf-8',
allow_unicode=True, default_flow_style=False))
response = {"success": "Data entry inserted."}
Expand Down
18 changes: 10 additions & 8 deletions js_plugins/adei.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,15 @@ function parse_adei(key, value, timestamp, invalid) {
// since delta is converted to seconds, we need to convert invalid to seconds as well
invalid = invalid / 1000.0;


if (data_decimal_numbers != undefined && data_decimal_numbers >= 0) {
value = (Math.round(value * 100) / 100).toFixed(data_decimal_numbers);
}


if (data_smaller_than != undefined && data_larger_than != undefined) {

if (value > data_smaller_than && value < data_larger_than) {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
} else if (data_smaller_than == '' && data_larger_than == '') {
$("#" + key + "> .value").css('color', 'black');
$("#" + key + "> .unit-name").css('color', 'black');
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
} else if (value < data_smaller_than && data_larger_than == '') {
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
Expand All @@ -64,14 +60,20 @@ function parse_adei(key, value, timestamp, invalid) {
}
}


if (data_exp != undefined && data_exp == "true") {
if (data_decimal_numbers != undefined && data_decimal_numbers > 0) {
value = parseFloat(value).toExponential(data_decimal_numbers);
} else {
value = parseFloat(value).toExponential();
}
} else {
if (data_decimal_numbers != undefined && data_decimal_numbers >= 0) {
value = (Math.round(value * 100) / 100).toFixed(data_decimal_numbers);
}
}


if (invalid != undefined && invalid < delta) {
$("#" + key + "> .value").css('color', 'grey');
$("#" + key + "> .unit-name").css('color', 'grey');
Expand Down
4 changes: 2 additions & 2 deletions js_plugins/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function parse_calc(key, response) {
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
} else if (data_smaller_than == '' && data_larger_than == '') {
$("#" + key + "> .value").css('color', 'black');
$("#" + key + "> .unit-name").css('color', 'black');
$("#" + key + "> .value").css('color', 'green');
$("#" + key + "> .unit-name").css('color', 'green');
} else if (value < data_smaller_than && data_larger_than == '') {
$("#" + key + "> .value").css('color', 'red');
$("#" + key + "> .unit-name").css('color', 'red');
Expand Down

0 comments on commit 5f18d91

Please sign in to comment.