mqtt/client.py
changeset 3984 883a85b9ebcc
parent 3980 96acfee19caf
child 3985 d0c5d77a33af
equal deleted inserted replaced
3983:466be4f52cb9 3984:883a85b9ebcc
     8 from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT
     8 from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT
     9 from .mqtt_client_gen import MQTTClientPanel, MQTTClientModel, MQTT_IEC_types, authParams
     9 from .mqtt_client_gen import MQTTClientPanel, MQTTClientModel, MQTT_IEC_types, authParams
    10 
    10 
    11 import util.paths as paths
    11 import util.paths as paths
    12 
    12 
    13 PahoMqttCPath = paths.ThirdPartyPath("MQTT")
    13 
    14 PahoMqttCLibraryPath = PahoMqttCPath 
    14 # assumes that "build" directory was created in paho.mqtt.c source directory,
    15 PahoMqttCIncludePaths = [PahoMqttCPath]
    15 # and cmake build was invoked from this directory
       
    16 PahoMqttCLibraryPath = paths.ThirdPartyPath("paho.mqtt.c", "build", "src")
       
    17 
       
    18 PahoMqttCIncludePaths = [
       
    19     paths.ThirdPartyPath("paho.mqtt.c", "build"),  # VersionInfo.h
       
    20     paths.ThirdPartyPath("paho.mqtt.c", "src")
       
    21 ]
    16 
    22 
    17 class MQTTClientEditor(ConfTreeNodeEditor):
    23 class MQTTClientEditor(ConfTreeNodeEditor):
    18     CONFNODEEDITOR_TABS = [
    24     CONFNODEEDITOR_TABS = [
    19         (_("MQTT Client"), "CreateMQTTClient_UI")]
    25         (_("MQTT Client"), "CreateMQTTClient_UI")]
    20 
    26 
   105     def CTNGenerate_C(self, buildpath, locations):
   111     def CTNGenerate_C(self, buildpath, locations):
   106         current_location = self.GetCurrentLocation()
   112         current_location = self.GetCurrentLocation()
   107         locstr = "_".join(map(str, current_location))
   113         locstr = "_".join(map(str, current_location))
   108         c_path = os.path.join(buildpath, "mqtt_client__%s.c" % locstr)
   114         c_path = os.path.join(buildpath, "mqtt_client__%s.c" % locstr)
   109 
   115 
   110         c_code = '#include "beremiz.h"\n'
   116         c_code = """
       
   117 #include "iec_types_all.h"
       
   118 #include "beremiz.h"
       
   119 """
   111         c_code += self.modeldata.GenerateC(c_path, locstr, self.GetConfig())
   120         c_code += self.modeldata.GenerateC(c_path, locstr, self.GetConfig())
   112 
   121 
   113         with open(c_path, 'w') as c_file:
   122         with open(c_path, 'w') as c_file:
   114             c_file.write(c_code)
   123             c_file.write(c_code)
   115 
   124