def get_all_tags(ipAddress, slot): tags = [] comm = PLC(ipAddress, slot) ret = comm.GetTagList() comm.Close() if ret.Value is None: return jsonify(ret.Status) for tag in ret.Value: tags.append({"tagName": tag.TagName, "dataType": tag.DataType}) return jsonify({'tags': tags})
def getTags(): try: lbTags.delete(0, 'end') commGT = PLC() commGT.IPAddress = selectedIPAddress.get() if checkVarMicro800.get() == 0: commGT.ProcessorSlot = int(selectedProcessorSlot.get()) tags = commGT.GetTagList() if not tags is None: if not tags.Value is None: # save tags to a file if checkVarSaveTags.get() == 1: with open('tags_list.txt', 'w') as f: for t in tags.Value: if t.DataType == '': f.write(t.TagName + '\n') else: f.write(t.TagName + ' (DataType - ' + t.DataType + ')\n') for t in tags.Value: j = 1 if t.DataType == '': lbTags.insert(j, t.TagName) else: lbTags.insert(j, t.TagName + ' (DataType - ' + t.DataType + ')') j = j + 1 else: lbTags.insert(1, 'No Tags Retrieved') else: lbTags.insert(1, 'No Tags Retrieved') commGT.Close() commGT = None except Exception as e: if not commGT is None: commGT.Close() commGT = None if app_closing: pass else: print(str(e))