mqtt/mqtt_client_gen.py
changeset 3998 0145c60b9560
parent 3995 84a668564748
child 3999 1479acf750e2
equal deleted inserted replaced
3997:364e09f5faea 3998:0145c60b9560
   312             clientID        = config["clientID"],
   312             clientID        = config["clientID"],
   313             decl            = "",
   313             decl            = "",
   314             topics          = "",
   314             topics          = "",
   315             cleanup         = "",
   315             cleanup         = "",
   316             init            = "",
   316             init            = "",
       
   317             init_pubsub     = "",
   317             retrieve        = "",
   318             retrieve        = "",
   318             publish         = "",
   319             publish         = "",
   319             publish_changes = ""
   320             publish_changes = ""
   320         )
   321         )
   321 
   322 
   342             C_type, iec_size_prefix = MQTT_IEC_types[iec_type]
   343             C_type, iec_size_prefix = MQTT_IEC_types[iec_type]
   343             c_loc_name = "__Q" + iec_size_prefix + locstr + "_" + str(iec_number)
   344             c_loc_name = "__Q" + iec_size_prefix + locstr + "_" + str(iec_number)
   344 
   345 
   345             formatdict["decl"] += """
   346             formatdict["decl"] += """
   346 DECL_VAR({iec_type}, {C_type}, {c_loc_name})""".format(**locals())
   347 DECL_VAR({iec_type}, {C_type}, {c_loc_name})""".format(**locals())
   347             formatdict["init"] += """
   348             formatdict["init_pubsub"] += """
   348     INIT_PUBLICATION({Topic}, {QoS}, {C_type}, {c_loc_name}, {Retained})""".format(**locals())
   349     INIT_PUBLICATION({Topic}, {QoS}, {C_type}, {c_loc_name}, {Retained})""".format(**locals())
   349             formatdict["publish"] += """
   350             formatdict["publish"] += """
   350         WRITE_VALUE({c_loc_name}, {C_type})""".format(**locals())
   351         WRITE_VALUE({c_loc_name}, {C_type})""".format(**locals())
   351             formatdict["publish_changes"] += """
   352             formatdict["publish_changes"] += """
   352             PUBLISH_CHANGE({Topic}, {QoS}, {C_type}, {c_loc_name}, {Retained})""".format(**locals())
   353             PUBLISH_CHANGE({Topic}, {QoS}, {C_type}, {c_loc_name}, {Retained})""".format(**locals())
   358             c_loc_name = "__I" + iec_size_prefix + locstr + "_" + str(iec_number)
   359             c_loc_name = "__I" + iec_size_prefix + locstr + "_" + str(iec_number)
   359             formatdict["decl"] += """
   360             formatdict["decl"] += """
   360 DECL_VAR({iec_type}, {C_type}, {c_loc_name})""".format(**locals())
   361 DECL_VAR({iec_type}, {C_type}, {c_loc_name})""".format(**locals())
   361             formatdict["topics"] += """
   362             formatdict["topics"] += """
   362     INIT_TOPIC({Topic}, {iec_type}, {c_loc_name})""".format(**locals())
   363     INIT_TOPIC({Topic}, {iec_type}, {c_loc_name})""".format(**locals())
   363             formatdict["init"] += """
   364             formatdict["init_pubsub"] += """
   364     INIT_SUBSCRIPTION({Topic}, {QoS})""".format(**locals())
   365     INIT_SUBSCRIPTION({Topic}, {QoS})""".format(**locals())
   365             formatdict["retrieve"] += """
   366             formatdict["retrieve"] += """
   366         READ_VALUE({c_loc_name}, {C_type})""".format(**locals())
   367         READ_VALUE({c_loc_name}, {C_type})""".format(**locals())
   367 
   368 
   368         Ccode = c_template.format(**formatdict)
   369         Ccode = c_template.format(**formatdict)