def inject_data_service(): target_code = flask.request.args.get("input", "") names = parse_ljsl.find_names(target_code) reg_maps = ljmmm.get_device_modbus_maps(expand_names=True, inc_orig=True) not_found_reg_names = [] tag_class_tuples = lj_scribe.find_classes_from_map(names, reg_maps, not_found_reg_names) tag_subtags_by_class = lj_scribe.fia_organize_tag_by_class(tag_class_tuples) target_code = lj_scribe.fix_not_found_reg_names(target_code, not_found_reg_names) original_names = map(lj_scribe.find_original_tag_str, names) summaries = map(lambda x: lj_scribe.render_tag_summary(*x), zip(tag_subtags_by_class, names, original_names)) original_names_to_summaries = zip(original_names, summaries) for (original_name, summary) in original_names_to_summaries: target_code = target_code.replace(original_name, summary) prefix = flask.render_template("scribe_prefix.html") postfix = flask.render_template("scribe_postfix.html") return prefix + target_code + postfix
def inject_data(): """Controls to Inject data about register records into an HTML template. @return: HTML form through which the HTML template can be filled and rendered. @rtype: str or flask response (redirect) """ if flask.request.method == "GET": return flask.render_template("inject_data.html") target_code = flask.request.form.get("input", "") names = parse_ljsl.find_names(target_code) reg_maps = ljmmm.get_device_modbus_maps(expand_names=True, inc_orig=True) dev_regs = reg_maps[lj_scribe.TARGET_DEVICE] tag_class_tuples = 0 tag_subtags_by_class = 0 # This is NOT the best way to fix this issue. # The code should use lj_scribe.TARGET_DEVICES!!! try: tag_class_tuples = lj_scribe.find_classes(names, dev_regs) except lj_scribe.RegisterNotFoundError as e: dev_regs = reg_maps[lj_scribe.TARGET_DEVICE_DIGIT] try: tag_class_tuples = lj_scribe.find_classes(names, dev_regs) tag_subtags_by_class = lj_scribe.organize_tag_by_class(tag_class_tuples, dev_regs) except lj_scribe.RegisterNotFoundError as e: return "Register %s not found in Modbus map." % e.missing_reg_name tag_subtags_by_class = lj_scribe.organize_tag_by_class(tag_class_tuples, dev_regs) original_names = map(lj_scribe.find_original_tag_str, names) summaries = map(lambda x: lj_scribe.render_tag_summary(*x), zip(tag_subtags_by_class, names, original_names)) original_names_to_summaries = zip(original_names, summaries) for (original_name, summary) in original_names_to_summaries: target_code = target_code.replace(original_name, summary) prefix = flask.render_template("scribe_prefix.html") postfix = flask.render_template("scribe_postfix.html") return prefix + target_code + postfix
import flask from flask import Markup, request from ljm_constants import ljmmm import lj_error_scribe import lj_scribe import lj_device_scribe import parse_ljsl import serialize app = flask.Flask(__name__) reg_data_compressed = ljmmm.get_registers_data(expand_names=False, inc_orig=False) reg_data_expanded = ljmmm.get_registers_data(expand_names=True, inc_orig=False) modbus_maps = ljmmm.get_device_modbus_maps() reg_maps = ljmmm.get_device_modbus_maps(expand_names=True, inc_orig=True) ALL_DEVICES_NAME = u"All Devices" ALL_TAGS_NAME = u"All Tags" INVALID_FILTER_ARGUMENTS = ["null", "undefined"] OPTION_TAG_TEMLPATE = "<option value=\"{tag}\">{tag}</option>" SELECTED_OPTION_TAB_TEMPLATE = "<option value=\"{tag}\" selected=\"selected\">" \ "{tag}</option>" ALLOWED_REDISPLAY_DOMAIN = "https://labjack.com" # NO_TAGS_NAME = "No Tags" @app.route("/") def show_ui(): """Display the JavaScript client for viewing MODBUS map information.
import json import os import flask from flask import Markup, request from ljm_constants import ljmmm import lj_scribe import parse_ljsl import serialize app = flask.Flask(__name__) reg_data_compressed = ljmmm.get_registers_data(expand_names=False, inc_orig=False) reg_data_expanded = ljmmm.get_registers_data(expand_names=True, inc_orig=False) modbus_maps = ljmmm.get_device_modbus_maps() ALL_DEVICES_NAME = "All Devices" ALL_TAGS_NAME = "All Tags" INVALID_FILTER_ARGUMENTS = ["null", "undefined"] OPTION_TAG_TEMLPATE = '<option value="{tag}">{tag}</option>' SELECTED_OPTION_TAB_TEMPLATE = '<option value="{tag}" selected="selected">' "{tag}</option>" ALLOWED_REDISPLAY_DOMAIN = "https://labjack.com" # NO_TAGS_NAME = "No Tags" @app.route("/") def show_ui(): """Display the JavaScript client for viewing MODBUS map information. @return: HTML register lookup table and controls. @rtype: str
import json import os import flask from flask import Markup, request from ljm_constants import ljmmm import lj_scribe import parse_ljsl import serialize app = flask.Flask(__name__) reg_data_compressed = ljmmm.get_registers_data(expand_names=False, inc_orig=False) reg_data_expanded = ljmmm.get_registers_data(expand_names=True, inc_orig=False) modbus_maps = ljmmm.get_device_modbus_maps() reg_maps = ljmmm.get_device_modbus_maps(expand_names=True, inc_orig=True) ALL_DEVICES_NAME = u"All Devices" ALL_TAGS_NAME = u"All Tags" INVALID_FILTER_ARGUMENTS = ["null", "undefined"] OPTION_TAG_TEMLPATE = "<option value=\"{tag}\">{tag}</option>" SELECTED_OPTION_TAB_TEMPLATE = "<option value=\"{tag}\" selected=\"selected\">" \ "{tag}</option>" ALLOWED_REDISPLAY_DOMAIN = "https://labjack.com" # NO_TAGS_NAME = "No Tags" @app.route("/") def show_ui(): """Display the JavaScript client for viewing MODBUS map information.