3 from __future__ import absolute_import |
3 from __future__ import absolute_import |
4 |
4 |
5 import os |
5 import os |
6 |
6 |
7 from editors.ConfTreeNodeEditor import ConfTreeNodeEditor |
7 from editors.ConfTreeNodeEditor import ConfTreeNodeEditor |
8 from .opcua_client_maker import OPCUAClientPanel, OPCUAClientModel |
8 from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT |
|
9 from .opcua_client_maker import OPCUAClientPanel, OPCUAClientModel, UA_IEC_types |
9 |
10 |
10 import util.paths as paths |
11 import util.paths as paths |
11 |
12 |
12 # Paths to open62541 assume that |
13 # Paths to open62541 assume that |
13 # - open62541 directory is aside beremiz directory |
14 # - open62541 directory is aside beremiz directory |
82 |
83 |
83 CFLAGS = ' '.join(['-I"' + path + '"' for path in Open62541IncludePaths]) |
84 CFLAGS = ' '.join(['-I"' + path + '"' for path in Open62541IncludePaths]) |
84 |
85 |
85 return [(c_path, CFLAGS)], LDFLAGS, True |
86 return [(c_path, CFLAGS)], LDFLAGS, True |
86 |
87 |
|
88 def GetVariableLocationTree(self): |
|
89 current_location = self.GetCurrentLocation() |
|
90 locstr = "_".join(map(str, current_location)) |
|
91 name = self.BaseParams.getName() |
|
92 entries = [] |
|
93 for direction, data in self.modeldata.iteritems(): |
|
94 iec_direction_prefix = {"input": "__I", "output": "__Q"}[direction] |
|
95 for row in data: |
|
96 dname, ua_nsidx, ua_nodeid_type, _ua_node_id, ua_type, iec_number = row |
|
97 iec_type, C_type, iec_size_prefix, ua_type_enum, ua_type = UA_IEC_types[ua_type] |
|
98 c_loc_name = iec_direction_prefix + iec_size_prefix + locstr + "_" + str(iec_number) |
|
99 entries.append({ |
|
100 "name": dname, |
|
101 "type": {"input": LOCATION_VAR_INPUT, "output": LOCATION_VAR_OUTPUT}[direction], |
|
102 "size": {"X":1, "B":8, "W":16, "D":32, "L":64}[iec_size_prefix], |
|
103 "IEC_type": iec_type, |
|
104 "var_name": c_loc_name, |
|
105 "location": iec_size_prefix + ".".join([str(i) for i in current_location]) + "." + str(iec_number), |
|
106 "description": "", |
|
107 "children": []}) |
|
108 return {"name": name, |
|
109 "type": LOCATION_CONFNODE, |
|
110 "location": ".".join([str(i) for i in current_location]) + ".x", |
|
111 "children": entries} |
|
112 |