equal
deleted
inserted
replaced
14 |
14 |
15 # assumes that "build" directory was created in paho.mqtt.c source directory, |
15 # assumes that "build" directory was created in paho.mqtt.c source directory, |
16 # and cmake build was invoked from this directory |
16 # and cmake build was invoked from this directory |
17 PahoMqttCLibraryPath = paths.ThirdPartyPath("paho.mqtt.c", "build", "src") |
17 PahoMqttCLibraryPath = paths.ThirdPartyPath("paho.mqtt.c", "build", "src") |
18 |
18 |
19 PahoMqttCIncludePaths = [ |
19 frozen_path = paths.ThirdPartyPath("frozen") |
|
20 |
|
21 MqttCIncludePaths = [ |
20 paths.ThirdPartyPath("paho.mqtt.c", "build"), # VersionInfo.h |
22 paths.ThirdPartyPath("paho.mqtt.c", "build"), # VersionInfo.h |
21 paths.ThirdPartyPath("paho.mqtt.c", "src") |
23 paths.ThirdPartyPath("paho.mqtt.c", "src"), |
|
24 frozen_path |
22 ] |
25 ] |
23 |
26 |
24 class MQTTClientEditor(ConfTreeNodeEditor): |
27 class MQTTClientEditor(ConfTreeNodeEditor): |
25 CONFNODEEDITOR_TABS = [ |
28 CONFNODEEDITOR_TABS = [ |
26 (_("MQTT Client"), "CreateMQTTClient_UI")] |
29 (_("MQTT Client"), "CreateMQTTClient_UI")] |
92 |
95 |
93 def GetTypes(self): |
96 def GetTypes(self): |
94 datatype_candidates = self.GetCTRoot().GetDataTypes() |
97 datatype_candidates = self.GetCTRoot().GetDataTypes() |
95 return datatype_candidates |
98 return datatype_candidates |
96 |
99 |
|
100 def GetDataTypeInfos(self, typename): |
|
101 tagname = "D::"+typename |
|
102 return self.GetCTRoot().GetDataTypeInfos(tagname) |
|
103 |
97 def GetConfig(self): |
104 def GetConfig(self): |
98 def cfg(path): |
105 def cfg(path): |
99 try: |
106 try: |
100 attr=self.GetParamsAttributes("MQTTClient."+path) |
107 attr=self.GetParamsAttributes("MQTTClient."+path) |
101 except ValueError: |
108 except ValueError: |
148 c_code = """ |
155 c_code = """ |
149 #include "iec_types_all.h" |
156 #include "iec_types_all.h" |
150 #include "beremiz.h" |
157 #include "beremiz.h" |
151 """ |
158 """ |
152 config = self.GetConfig() |
159 config = self.GetConfig() |
153 c_code += self.modeldata.GenerateC(c_path, locstr, config) |
160 c_code += self.modeldata.GenerateC(c_path, locstr, config, self.GetDataTypeInfos) |
154 |
161 |
155 with open(c_path, 'w') as c_file: |
162 with open(c_path, 'w') as c_file: |
156 c_file.write(c_code) |
163 c_file.write(c_code) |
157 |
164 |
158 if config["AuthType"] == "x509": |
165 if config["AuthType"] == "x509": |
162 static_lib = "libpaho-mqtt3c.a" |
169 static_lib = "libpaho-mqtt3c.a" |
163 libs = [] |
170 libs = [] |
164 |
171 |
165 LDFLAGS = [' "' + os.path.join(PahoMqttCLibraryPath, static_lib) + '"'] + libs |
172 LDFLAGS = [' "' + os.path.join(PahoMqttCLibraryPath, static_lib) + '"'] + libs |
166 |
173 |
167 CFLAGS = ' '.join(['-I"' + path + '"' for path in PahoMqttCIncludePaths]) |
174 CFLAGS = ' '.join(['-I"' + path + '"' for path in MqttCIncludePaths]) |
168 |
175 |
169 return [(c_path, CFLAGS)], LDFLAGS, True |
176 # TODO: add frozen only if using JSON |
|
177 frozen_c_path = os.path.join(frozen_path, "frozen.c") |
|
178 |
|
179 return [(c_path, CFLAGS), (frozen_c_path, CFLAGS)], LDFLAGS, True |
170 |
180 |
171 def GetVariableLocationTree(self): |
181 def GetVariableLocationTree(self): |
172 current_location = self.GetCurrentLocation() |
182 current_location = self.GetCurrentLocation() |
173 locstr = "_".join(map(str, current_location)) |
183 locstr = "_".join(map(str, current_location)) |
174 name = self.BaseParams.getName() |
184 name = self.BaseParams.getName() |