Hi everyone..,
I need some clarifications on vision client. i have faced some errors when i try to get a components values form windows in client. Our need is collect the all String value of component values in all window.I already explained that in previous part.That is Fetching a Components data from window and transfer that value to Translation Manager. Please visit that window what i'm saying and doing it for. I devleopt a script for get a values for a component on window. And we tested that script is run or not.But that script has run succesfully.That script is,
from com.inductiveautomation.factorypmi.application.components import BasicContainer
from java.lang import String
def printTextAndDataStrings(container):
ins_list = []
for component in container.getComponents():
if isinstance(component, BasicContainer):
printTextAndDataStrings(component)
if hasattr(component, 'text'):
val = component.text
ins_list.append(str(val))
if hasattr(component, 'Text'):
val = component.Text
ins_list.append(str(val))
if hasattr(component, 'data'):
dataset = component.data
if dataset.rowCount > 0 and dataset.columnCount >0:
for column in range(dataset.columnCount):
value = dataset.getValueAt(0, column)
if isinstance(value,(String, unicode)):
val = dataset.getColumnAsList(column)
for x in val:
# print x
ins_list.append(str(x))
if hasattr(component, 'Data'):
dataset = component.data
if dataset.rowCount > 0 and dataset.columnCount >0:
for column in range(dataset.columnCount):
value = dataset.getValueAt(0, column)
if isinstance(value,(String, unicode)):
val = dataset.getColumnAsList(column)
for x in val:
# print x
ins_list.append(str(x))
query = "SELECT Keyes FROM translation"
val = system.db.runQuery(query,"MySQL")
val1 = val.getColumnAsList(0)
list = []
for x in ins_list:
if x in val1:
pass
else:
list.append(str(x))
# print list
y = "('" + "'),('".join(list)+ "')"
print y
if y != "('')":
query = "insert into translation (Keyes) values {}".format(y)
run = system.db.runPrepUpdate(query,[],"MySQL")
print run
windows = system.gui.getWindowNames()
e_list = []
for path in windows:
e_list.append(path)
for x in e_list:
rootContainer = system.gui.getWindow(str(x)).rootContainer
printTextAndDataStrings(rootContainer)
i put that script in Button and when i clic that button that time it run. First it fetched all window name of vision window. then it use that to fetching the data. But, here get the string values when the window has opened. Once that window has closed it through the error. So, i opened all window on vision designer and tested the script, its working good. But, i launched the window and test that in cliend, it through error, Like "window_1" in not opened.
Thanks,