Sample of system.tag.writeToTag

Hi,

I need to write a boolean value to the tag but I don’t know how.
Could you give me a sample so that I can write a boolean value to my PLC?

If I should use this function, could you give me a sample?
system.tag.writeToTag

Regards.

system.tag.write("tagpath",True)

Hi,

Thanks, now I’m can enable other tag. The problem is that keeps in true. I need to get a kind of feedback of this tag that I’m using the code below.

Please, Check the code bellow.

I need that the code: system.tag.write("[BRA_POSTPRESS]BRA_BUNDLE/LOWER_LINE/gDataLabelerA", True), give me a status of this variable that I’m using and not set this value.

Do you have some sugestion?

Please, Check the code bellow.

import system

# we acquire a logger
logger = system.util.getLogger("LBL_A_SendLabel.Tag.Change.Script")

logger.debug("Starting Tag Change Script")

if currentValue.value == 1 and not initialChange:

	barcode		= system.tag.read("[BRA_POSTPRESS]BRA_CALCULATED/LABELS/LOWER_LINE/BARCODE")
	barcode		= barcode.value
	name		= system.tag.read("[BRA_POSTPRESS]BRA_CALCULATED/LABELS/LOWER_LINE/PRODUCT_NAME")
	name		= name.value
	bundle		= system.tag.read("[BRA_POSTPRESS]BRA_CALCULATED/LABELS/LOWER_LINE/STACKS_PER_BUNDLE")
	bundle		= bundle.value
	size		= system.tag.read("[BRA_POSTPRESS]BRA_KL540_LL/copys_bundle")
	size		= size.value
	produced	= system.tag.read("[BRA_POSTPRESS]BRA_BUNDLE/LOWER_LINE/BundleCounter")
	produced	= produced.value
	date		= system.tag.read("[BRA_POSTPRESS]BRA_SYSTEM/OPC_TimeStamp")
	date		= date.value
	weight		= system.tag.read("[BRA_POSTPRESS]BRA_CALCULATED/LABELS/LOWER_LINE/WEIGHT")
	weight		= weight.value
	expected	= system.tag.read("[BRA_POSTPRESS]BRA_CALCULATED/LABELS/LOWER_LINE/TOTAL_BUNDLES")
	expected	= expected.value
	data		= shared.CONSTANTS.label.generic(barcode,name,bundle,size,produced,date,weight,expected)	

	'''filename = system.file.getTempFile("txt") 
	system.file.writeFile(filename, data)'''
	
	a_auto		= system.tag.read("[BRA_POSTPRESS]BRA_BUNDLE/LOWER_LINE/Label_Aire_A_Auto")
	a_start		= system.tag.read("[BRA_POSTPRESS]BRA_BUNDLE/LOWER_LINE/Label_Aire_A_Start")
	a_online	= a_auto.value and a_start.value
	
	if a_online == 1:
		system.tag.write("[BRA_POSTPRESS]BRA_BUNDLE/LOWER_LINE/gDataLabelerA", True)

I think your problem is here:

barcode	= system.tag.read("[BRA_POSTPRESS]BRA_CALCULATED/LABELS/LOWER_LINE/BARCODE")

(and all the other instances of system.tag.read).

system.tag.read() returns an object. You need to add “.value” to the end of the call to pull the value out of the resulting object.