14 |
14 |
15 import util.paths as paths |
15 import util.paths as paths |
16 from POULibrary import POULibrary |
16 from POULibrary import POULibrary |
17 from docutil import open_svg |
17 from docutil import open_svg |
18 |
18 |
|
19 HMI_TYPES_DESC = { |
|
20 "HMI_CLASS":{}, |
|
21 "HMI_LABEL":{}, |
|
22 "HMI_STRING":{}, |
|
23 "HMI_INT":{}, |
|
24 "HMI_REAL":{} |
|
25 } |
|
26 |
|
27 HMI_TYPES = HMI_TYPES_DESC.keys() |
19 |
28 |
20 class SVGHMILibrary(POULibrary): |
29 class SVGHMILibrary(POULibrary): |
21 def GetLibraryPath(self): |
30 def GetLibraryPath(self): |
22 return paths.AbsNeighbourFile(__file__, "pous.xml") |
31 return paths.AbsNeighbourFile(__file__, "pous.xml") |
23 |
32 |
|
33 def Generate_C(self, buildpath, varlist, IECCFLAGS): |
|
34 |
|
35 # Filter known HMI types |
|
36 hmi_types_instances = [v for v in varlist if v["derived"] in HMI_TYPES] |
|
37 |
|
38 # TODO deduce HMI tree |
|
39 |
|
40 # TODO generate C code to observe/access HMI tree variables |
|
41 svghmi_c_filepath = paths.AbsNeighbourFile(__file__, "svghmi.c") |
|
42 svghmi_c_file = open(svghmi_c_filepath, 'r') |
|
43 svghmi_c_code = svghmi_c_file.read() |
|
44 svghmi_c_file.close() |
|
45 svghmi_c_code = svghmi_c_code % { "the code": "/* TODO */"} |
|
46 |
|
47 gen_svghmi_c_path = os.path.join(buildpath, "svghmi.c") |
|
48 gen_svghmi_c = open(gen_svghmi_c_path, 'w') |
|
49 gen_svghmi_c.write(svghmi_c_code) |
|
50 gen_svghmi_c.close() |
|
51 |
|
52 return (["svghmi"], [(gen_svghmi_c_path, IECCFLAGS)], True), "" |
24 |
53 |
25 class SVGHMI(object): |
54 class SVGHMI(object): |
26 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
55 XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
27 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
56 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
28 <xsd:element name="SVGHMI"> |
57 <xsd:element name="SVGHMI"> |
68 when _generate_softPLC have been called |
97 when _generate_softPLC have been called |
69 @param locations: ignored |
98 @param locations: ignored |
70 @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
99 @return: [(C_file_name, CFLAGS),...] , LDFLAGS_TO_APPEND |
71 """ |
100 """ |
72 |
101 |
73 # TODO : get variable list from Controller |
102 # TODO fetch HMI tree from library |
74 # self.GetCTRoot().blah |
|
75 # TODO deduce HMI tree |
|
76 |
103 |
77 svgfile = self._getSVGpath() |
104 svgfile = self._getSVGpath() |
78 if os.path.exists(svgfile): |
105 if os.path.exists(svgfile): |
79 # TODO : call xslt transform on Inkscape's SVG to generate |
106 # TODO : call xslt transform on Inkscape's SVG to generate |
80 # - Errors on HMI semantics |
107 # - Errors on HMI semantics |