mqtt/client.py
changeset 3991 28354ba489b9
parent 3986 98bd0bb33ce4
child 4001 5e0660d394e3
equal deleted inserted replaced
3990:24656e0e8732 3991:28354ba489b9
   135 
   135 
   136     def GetVariableLocationTree(self):
   136     def GetVariableLocationTree(self):
   137         current_location = self.GetCurrentLocation()
   137         current_location = self.GetCurrentLocation()
   138         locstr = "_".join(map(str, current_location))
   138         locstr = "_".join(map(str, current_location))
   139         name = self.BaseParams.getName()
   139         name = self.BaseParams.getName()
       
   140 
   140         entries = []
   141         entries = []
   141         for direction, data in self.modeldata.iteritems():
   142         children = []
   142             iec_direction_prefix = {"input": "__I", "output": "__Q"}[direction]
   143 
   143             for row in data:
   144         for row in self.modeldata["output"]:
   144                 dname, ua_nsidx, ua_nodeid_type, _ua_node_id, ua_type, iec_number = row
   145             Topic, QoS, _Retained, iec_type, iec_number = row
   145                 iec_type, C_type, iec_size_prefix, ua_type_enum, ua_type = MQTT_IEC_types[ua_type]
   146             entries.append((Topic, QoS, iec_type, iec_number, "Q", LOCATION_VAR_OUTPUT))
   146                 c_loc_name = iec_direction_prefix + iec_size_prefix + locstr + "_" + str(iec_number)
   147 
   147                 entries.append({
   148         for row in self.modeldata["input"]:
   148                     "name": dname,
   149             Topic, QoS, iec_type, iec_number = row
   149                     "type": {"input": LOCATION_VAR_INPUT, "output": LOCATION_VAR_OUTPUT}[direction],
   150             entries.append((Topic, QoS, iec_type, iec_number, "I", LOCATION_VAR_INPUT))
   150                     "size": {"X":1, "B":8, "W":16, "D":32, "L":64}[iec_size_prefix],
   151 
   151                     "IEC_type": iec_type,
   152         for Topic, QoS, iec_type, iec_number, iec_dir_prefix, loc_type in entries:
   152                     "var_name": c_loc_name,
   153             C_type, iec_size_prefix = MQTT_IEC_types[iec_type]
   153                     "location": iec_size_prefix + ".".join([str(i) for i in current_location]) + "." + str(iec_number),
   154             c_loc_name = "__" + iec_dir_prefix + iec_size_prefix + locstr + "_" + str(iec_number)
   154                     "description": "",
   155             children.append({
   155                     "children": []})
   156                 "name": Topic,
       
   157                 "type": loc_type,
       
   158                 "size": {"X":1, "B":8, "W":16, "D":32, "L":64}[iec_size_prefix],
       
   159                 "IEC_type": iec_type,
       
   160                 "var_name": c_loc_name,
       
   161                 "location": "%" + iec_dir_prefix + iec_size_prefix + ".".join([str(i) for i in current_location]) + "." + str(iec_number),
       
   162                 "description": "",
       
   163                 "children": []})
       
   164 
   156         return {"name": name,
   165         return {"name": name,
   157                 "type": LOCATION_CONFNODE,
   166                 "type": LOCATION_CONFNODE,
   158                 "location": ".".join([str(i) for i in current_location]) + ".x",
   167                 "location": ".".join([str(i) for i in current_location]) + ".x",
   159                 "children": entries}
   168                 "children": children}
   160 
   169