# HG changeset patch # User Edouard Tisserant # Date 1671673640 -3600 # Node ID f68449d64d1c34dfcd2dbc56f289957235d0a981 # Parent 51c2d434e10e442bd721e73eec03f4c2bea80178# Parent 7fbcc7b741b7ad8d75f0e8bdfe08c6c8086d70eb Merged default in wxPython4 branch diff -r 51c2d434e10e -r f68449d64d1c exemples/csv_read/beremiz.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exemples/csv_read/beremiz.xml Thu Dec 22 02:47:20 2022 +0100 @@ -0,0 +1,5 @@ + + + + + diff -r 51c2d434e10e -r f68449d64d1c exemples/csv_read/plc.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exemples/csv_read/plc.xml Thu Dec 22 02:47:20 2022 +0100 @@ -0,0 +1,341 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CSV_NAME_0 + + + + + + + CSV_ROWIDX + + + + + + + CSV_COLIDX + + + + + + + CSV_NAME_1 + + + + + + + CSV_ROWSTR + + + + + + + CSV_COLSTR + + + + + + + + + + + CSV_RES_0 + + + + + + + + + + + CSV_ACK_0 + + + + + + + + + + + CSV_ACK_1 + + + + + + + + + + + CSV_RES_1 + + + + + + + CSV_RELOAD_BTN + + + + + + + + + + + + + + + + + + diff -r 51c2d434e10e -r f68449d64d1c exemples/csv_read/project_files/my_int_csv.csv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exemples/csv_read/project_files/my_int_csv.csv Thu Dec 22 02:47:20 2022 +0100 @@ -0,0 +1,15 @@ +1,1.01,1.02,1.03,1.04,1.05,1.06 +1.1,1.11,1.12,1.13,1.14,1.15,1.16 +1.2,1.21,1.22,1.23,1.24,1.25,1.26 +1.3,1.31,1.32,1.33,1.34,1.35,1.36 +1.4,1.41,1.42,1.43,1.44,1.45,1.46 +1.5,1.51,1.52,1.53,1.54,1.55,1.56 +1.6,1.61,1.62,1.63,1.64,1.65,1.66 +1.7,1.71,1.72,1.73,1.74,1.75,1.76 +1.8,1.81,1.82,1.83,1.84,1.85,1.86 +1.9,1.91,1.92,1.93,1.94,1.95,1.96 +2,2.01,2.02,2.03,2.04,2.05,2.06 +2.1,2.11,2.12,2.13,2.14,2.15,2.16 +2.2,2.21,2.22,2.23,2.24,2.25,2.26 +2.3,2.31,2.32,2.33,2.34,2.35,2.36 +2.4,2.41,2.42,2.43,2.44,2.45,2.46 diff -r 51c2d434e10e -r f68449d64d1c exemples/csv_read/project_files/my_int_csv.ods Binary file exemples/csv_read/project_files/my_int_csv.ods has changed diff -r 51c2d434e10e -r f68449d64d1c exemples/csv_read/project_files/my_str_csv.csv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exemples/csv_read/project_files/my_str_csv.csv Thu Dec 22 02:47:20 2022 +0100 @@ -0,0 +1,8 @@ +Title,Ingredient A,Ingredient B,Ingredient C,Ingredient D,Ingredient E,Ingredient F,Ingredient G +Recipe 1,1,2,3,4,5,6,7 +Recipe 2,2,3,4,5,6,7,8 +Recipe 3,3,4,5,6,7,8,9 +Recipe 4,4,5,6,7,8,9,10 +Recipe 5,5,6,7,8,9,10,11 +Recipe 6,6,7,8,9,10,11,12 +Recipe 7,7,8,9,10,11,12,13 diff -r 51c2d434e10e -r f68449d64d1c exemples/csv_read/project_files/my_str_csv.ods Binary file exemples/csv_read/project_files/my_str_csv.ods has changed diff -r 51c2d434e10e -r f68449d64d1c exemples/csv_read/svghmi_0@svghmi/baseconfnode.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exemples/csv_read/svghmi_0@svghmi/baseconfnode.xml Thu Dec 22 02:47:20 2022 +0100 @@ -0,0 +1,2 @@ + + diff -r 51c2d434e10e -r f68449d64d1c exemples/csv_read/svghmi_0@svghmi/confnode.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exemples/csv_read/svghmi_0@svghmi/confnode.xml Thu Dec 22 02:47:20 2022 +0100 @@ -0,0 +1,2 @@ + + diff -r 51c2d434e10e -r f68449d64d1c exemples/csv_read/svghmi_0@svghmi/svghmi.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exemples/csv_read/svghmi_0@svghmi/svghmi.svg Thu Dec 22 02:47:20 2022 +0100 @@ -0,0 +1,1787 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + 8 + + + + + + + 8 + + + + + + 8 + + + + + Row# + Column# + + file.csv + + + File name + + + + + + + Q + + + + W + + + + E + + + + R + + + + T + + + + Y + + + + U + + + + I + + + + O + + + + P + + + + A + + + + S + + + + D + + + + F + + + + G + + + + H + + + + J + + + + K + + + + L + + + + Z + + + + X + + + + C + + + + V + + + + B + + + + N + + + + M + + + + . + : + + + + ; + , + + + + 1 + + + + 2 + + + + 3 + + + + 4 + + + + 5 + + + + 6 + + + + 7 + + + + 8 + + + + 9 + - + + + + 0 + + + + + + + Esc + + + + + + + + + + + + + Caps + Lock + + + + Caps + Lock + + + + text + + + + Shift + + Shift + + + + Shift + + Shift + + + information + + + + + number + + + + + + + + 7 + + + + 4 + + + + 1 + + + + 8 + + + + 5 + + + + 2 + + + + 9 + + + + 6 + + + + 3 + + + + 0 + + + + + Esc + + + + + + + + +/- + + information + + + . + + + Result: + + Ingredient A + + + + Recipe 1 + + + Row name + Column name + + file.csv + + + File name + + 8 + + + + + Result: + + + + + + + Reload CSVs + + + + Upload csv at http://localhost:8009/settings/ + diff -r 51c2d434e10e -r f68449d64d1c py_ext/pous.xml --- a/py_ext/pous.xml Thu Dec 22 02:46:08 2022 +0100 +++ b/py_ext/pous.xml Thu Dec 22 02:47:20 2022 +0100 @@ -1,10 +1,10 @@ - + - + @@ -17,6 +17,1646 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 'CSVRdStr("' + + + + + + + FILE_NAME + + + + + + + '","' + + + + + + + ROW + + + + + + + '","' + + + + + + + COLUMN + + + + + + + '")' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OLDCODE + + + + + + + OLDCODE + + + + + + + OLDCODE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pyext_csv_update + + + + + + + + + + + ACK + + + + + + + + + + + + + RESULT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + '#' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TRIG + + + + + + + + + + + ACK + + + + + + + + + + + RESULT + + + + + + + 'pyext_csv_reload()' + + + + + + + + + + + pyext_csv_update + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 'CSVRdInt("' + + + + + + + FILE_NAME + + + + + + + '",' + + + + + + + ROW + + + + + + + ',' + + + + + + + COLUMN + + + + + + + ')' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OLDCODE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OLDCODE + + + + + + + OLDCODE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pyext_csv_update + + + + + + + + + + + + + ACK + + + + + + + + + + + + + RESULT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + '#' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -445,6 +2085,19 @@ - + + + + + + + + + + + + + + diff -r 51c2d434e10e -r f68449d64d1c py_ext/py_ext.py --- a/py_ext/py_ext.py Thu Dec 22 02:46:08 2022 +0100 +++ b/py_ext/py_ext.py Thu Dec 22 02:47:20 2022 +0100 @@ -30,6 +30,98 @@ from py_ext.PythonFileCTNMixin import PythonFileCTNMixin import util.paths as paths +pyext_python_lib_code = """ + +import csv +from collections import OrderedDict + +csv_int_files = {} +def CSVRdInt(fname, rowidx, colidx): + \"\"\" + Return value at row/column pointed by integer indexes + Assumes data starts at first row and first column, no headers. + \"\"\" + global csv_int_files + data = csv_int_files.get(fname, None) + if data is None: + data = list() + try: + csvfile = open(fname, 'rb') + except IOError: + return "#FILE_NOT_FOUND" + try: + dialect = csv.Sniffer().sniff(csvfile.read(1024)) + csvfile.seek(0) + reader = csv.reader(csvfile, dialect) + for row in reader: + data.append(row) + except csv.Error: + return "#CSV_ERROR" + finally: + csvfile.close() + csv_int_files[fname] = data + + try: + row = data[rowidx] + except IndexError: + return "#ROW_NOT_FOUND" + + try: + return row[colidx] + except IndexError: + return "#COL_NOT_FOUND" + + +csv_str_files = {} +def CSVRdStr(fname, rowname, colname): + \"\"\" + Return value at row/column pointed by a pair of names as string + Assumes first row is column headers and first column is row name. + \"\"\" + global csv_str_files + entry = csv_str_files.get(fname, None) + if entry is None: + data = dict() + try: + csvfile = open(fname, 'rb') + except IOError: + return "#FILE_NOT_FOUND" + try: + dialect = csv.Sniffer().sniff(csvfile.read(1024)) + csvfile.seek(0) + reader = csv.reader(csvfile, dialect) + headers = dict([(name, index) for index, name in enumerate(reader.next()[1:])]) + for row in reader: + data[row[0]] = row[1:] + except csv.Error: + return "#CSV_ERROR" + finally: + csvfile.close() + csv_str_files[fname] = (headers, data) + else: + headers, data = entry + + try: + row = data[rowname] + except KeyError: + return "#ROW_NOT_FOUND" + + try: + colidx = headers[colname] + except KeyError: + return "#COL_NOT_FOUND" + + try: + return row[colidx] + except IndexError: + return "#COL_NOT_FOUND" + +def pyext_csv_reload(): + global csv_int_files, csv_str_files + csv_int_files.clear() + csv_str_files.clear() + +""" class PythonLibrary(POULibrary): def GetLibraryPath(self): @@ -57,7 +149,13 @@ pythonfile.write(plc_python_code) pythonfile.close() - return (["py_ext"], [(Gen_Pythonfile_path, IECCFLAGS)], True), "" + runtimefile_path = os.path.join(buildpath, "runtime_00_pyext.py") + runtimefile = open(runtimefile_path, 'w') + runtimefile.write(pyext_python_lib_code) + runtimefile.close() + return ((["py_ext"], [(Gen_Pythonfile_path, IECCFLAGS)], True), "", + ("runtime_00_pyext.py", open(runtimefile_path, "rb"))) + class PythonFile(PythonFileCTNMixin): diff -r 51c2d434e10e -r f68449d64d1c svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Thu Dec 22 02:46:08 2022 +0100 +++ b/svghmi/gen_index_xhtml.xslt Thu Dec 22 02:47:20 2022 +0100 @@ -2160,7 +2160,7 @@ } - + undeafen(index){ @@ -2170,6 +2170,10 @@ this.incoming[index] = undefined; + // TODO: add timestamp argument to dispatch, so that defered data do not appear wrong on graphs + + this.lastdispatch[index] = Date.now(); + this.do_dispatch(new_val, old_val, index); } @@ -5588,7 +5592,7 @@ animate: function(){ - this.value_elt.textContent = String(this.display); + multiline_to_svg_text(this.value_elt, String(this.display)); }, @@ -5626,7 +5630,7 @@ - this.value_elt.textContent = ""; + multiline_to_svg_text(this.value_elt, ""); }, @@ -9269,6 +9273,8 @@ + console.log("dispatch(",value,oldval, index, time); + // naive local buffer impl. // data is updated only when graph is visible diff -r 51c2d434e10e -r f68449d64d1c svghmi/widget_input.ysl2 --- a/svghmi/widget_input.ysl2 Thu Dec 22 02:46:08 2022 +0100 +++ b/svghmi/widget_input.ysl2 Thu Dec 22 02:47:20 2022 +0100 @@ -92,7 +92,7 @@ if "$have_value" { | animate: function(){ - | this.value_elt.textContent = String(this.display); + | multiline_to_svg_text(this.value_elt, String(this.display)); | }, } @@ -114,7 +114,7 @@ } if "$have_value" { - | this.value_elt.textContent = ""; + | multiline_to_svg_text(this.value_elt, ""); } | }, }