Customized data points server side scrips write and read

TO WRITE

var pointLabel = “”;
var labelFontColor = “#333333”;
var labelFontWeight = “bold”;
var labelBackgroundColor = “#CCCCCC”;
var labelWidth = “0px”;
var labelHeight = “20px”;
var labelFontSize = “20px”;
var labelAlignment = “left”;
var labelMargin = “1px”;
var pointWidth = “73px”;
var pointHeight = “14px”;
var pointFontSize = “13px”;
var pointFontColor = “#000099”;
var pointAlignment = “center”;
var pointMargin = “0px”;
var decimalPlaces = 1;
var minValue = 0.00;
var maxValue = 100.00;
var step = 0.1;
var valueInRange = Math.min(Math.max(value, minValue), maxValue);
var pointBackgroundColor = “#FFFFFF”;
var fieldBorderColor = “#CCCCCC”;

var s = “<label for=”" + point.id + “” style=“color:” + labelFontColor + “; font-weight:” + labelFontWeight + “; background-color:” + labelBackgroundColor + “; width:” + labelWidth + “; height:” + labelHeight + “; font-size: " + labelFontSize + “; text-align: " + labelAlignment + “; margin: " + labelMargin + “”>” + pointLabel + “<input type=“text” id=”” + point.id + “” size=“6” style=“text-align:” + pointAlignment + “; font-weight:bold;background-color:” + pointBackgroundColor + “; width:” + pointWidth + “; height:” + pointHeight + “; font-size: " + pointFontSize + “; color: " + pointFontColor + “; margin: " + pointMargin + “; border: 1px solid " + fieldBorderColor + “” onChange='var v=parseFloat(this.value.replace(”,”,”.”)).toFixed(” + decimalPlaces + “);if(v<” + minValue.toFixed(decimalPlaces) + “){v=” + minValue.toFixed(decimalPlaces) + “;}else if(v>” + maxValue.toFixed(decimalPlaces) + “){v=” + maxValue.toFixed(decimalPlaces) + “;}else{v=Math.round(v/” + step + “)*” + step + “;}mango.view.setPoint(”+ point.id +", “”+ pointComponent.id +"", v);return false;'value=" + valueInRange.toFixed(decimalPlaces).toString().replace(".",",") + " >";

return s;

TO READ
var point_label = “”;
var preffix = “”;
var suffix = “”;
var decimal_places = 3;
var font_size = 16;
var use_bold = true;
var border_color = “#888888”;
var background_color = “#FFFFFF”;
var label_color = “#480f03”;
var values_color = “#444444”;
var label_width = 0;
var label_height = 17;
var label_margin = 2;
var data_width = 73;
var data_height = 14;
var data_margin = 1;
var single_line_mode = true;
var data_alignment = “center”;
var font_family = “Vedrana, Arial, Helvetica, sans-serif”;

var display_value = preffix + value.toFixed(decimal_places) + suffix;
var flex_direction = single_line_mode ? “row” : “column”;
var font_weight = use_bold ? “bold” : “normal”;
var div_id = “data-point” + pointComponent.id;

var s = “”;

s += “

”;
s += “” + point_label + “”;
s += “” + display_value + “”;
s += “
”;

s += “”;
s += “#” + div_id + " {";
s += "background: " + background_color + “;”;
s += “border: 1px solid;”;
s += "border-color: " + border_color + “;”;
s += "font-family: " + font_family + “;”;
s += "font-weight: " + font_weight + “;”;
s += "font-size: " + font_size + “px;”;
s += “display: flex;”;
s += “flex-direction: " + flex_direction + “;”;
s += “justify-content: center;”;
s += “align-items: center;”;
s += “}”;
s += “#” + div_id + " span:first-child {”;
s += “margin-right: " + label_margin + “px;”;
s += “}”;
s += “#” + div_id + " span {”;
s += "margin: 0px " + data_margin + “px;”;
s += “}”;
s += “”;

return s;

1 curtida

Customized BUTTON for binary data points

var label = “STOP”;
var height = 25;
var width = 50;
var value_on_click = true;
var enable_confirm_prompt = true;
var confirm_message = “Change value?”;
var label_font_size = “14px”;
var label_font_weight = “bold”;
var background_color = “#ff1a1a”;

if (getDataPointType(point.id) != “BINARY”)
return “The selected data point is not binary. Please select a binary data point.”

var confirm = “if (window.confirm(”" + confirm_message + “”)) ";
var pc_id = pointComponent.id;
var command = “”;
command += “var setPoint = ViewDwr.setViewPoint;”
command += “if (window.location.pathname.includes(“views.shtm”)) {”;
command += “show(c” + pc_id + “Changing);”;
command += “setPoint(” + pc_id + ", " + value_on_click + “, function() {”;
command += “setPoint(” + pc_id + ", " + !value_on_click + “, function() {”;
command += “hide(c” + pc_id + “Changing);”;
command += “});”;
command += “});”;
command += “}”;
command += “else if (window.location.pathname.includes(“public_view.htm”)) {”;
command += “setPoint = ViewDwr.setViewPointAnon;”;
command += “show(c” + pc_id + “Changing);”;
command += "setPoint(mango.view.anon.viewId, " + pc_id + ", " + value_on_click + “, function() {”;
command += "setPoint(mango.view.anon.viewId, " + pc_id + ", " + value_on_click + “, function() {”;
command += “hide(c” + pc_id + “Changing);”;
command += “});”;
command += “});”;
command += “}”;
if (enable_confirm_prompt)
command = confirm + “{” + command + “}”;

var s = “”;
s += "<input type=‘button’ ";
s += “onclick=’” + command + "’ ";
s += “style='height:” + height + “px; width:”+ width + “px; font-size:” + label_font_size + “; font-weight:” + label_font_weight + “; background-color:” + background_color + ";’ ";
s += “value=’” + label + "’ ";
s += “>”;
return s;

function getDataPointType(identifier) {
var types = {
0: “UNKNOWN”,
1: “BINARY”,
2: “MULTISTATE”,
3: “NUMERIC”,
4: “ALPHANUMERIC”,
5: “IMAGE”
}
var dpDAO = new com.serotonin.mango.db.dao.DataPointDao();
var dp = dpDAO.getDataPoint(identifier);
var locator = dp.getPointLocator();
return types[locator.getDataTypeId()];
}

1 curtida