I have this code and before the prints, I want to show the value of the two tags (tgCanal and tgSector) in case of the tag pathCanal has a value and then show it the label lblCanalTag and lblSectorTag but is not working.
Where is this script running? There are lots of places scripts can be run, but only a few places that can interact with vision windows.
Right now your if statement on line 4 will always be true because you’re not reading the value of a tag.
It’s more efficient to do all your tag reads at once.
system.tag.readBlocking returns a list of QualifiedValues.
a. To read one path, you do this: system.tag.readBlocking(["[default]tagFolder/tagName")[0].value
Every component has properties. You can’t just write a value to a component. You have to write to the appropriate property.
If your tagpaths aren’t dynamic, maybe something like this:
pathCanal="[default]app_tags/Componentes/ArranquePedidos/Alarma_Canal_Vacio"
pathSector="[default]app_tags/Componentes/ArranquePedidos/Alarma_Sector_Vacio"
canalValue,sectorValue = system.tag.readBlocking(
[pathCanal,pathSector]
)
if canalValue.value:
system.nav.centerWindow('User Management/mensajeAlarma')
lblCanalTag = system.gui.getParentWindow(event).getComponentForPath('Root Container.lblCanalTag')
lblSectorTag = system.gui.getParentWindow(event).getComponentForPath('Root Container.lbSectorTag')
# these will only be correct if this type of component has a value property.
# lblCanalTag.text would also be something to try.
lblCanalTag.value=canalValue.value
lblSectorTag.value=sectorValue.value
print canalValue.value
print sectorValue.value