Value is changed in numeric entry field when run perspective project but it is not updated in tag Browser or not changed value update in OPC

Hello
I have added this script in Add Transform->Script so now datatype mismatch error (For FloatArray data type)is not occured , when I run project and change numeric entry field then value is changed but in tag browser it is not reflected changed value, why this is happening any reason behind this? If anyone knows this then let me know.

this is my Script:

def transform(self, value, quality, timestamp):

	opcTagPath = "[Sample_Tags]TO_LVF_CIT_N[0].value"
	currentValues = system.tag.readBlocking([opcTagPath])[0].value
	last_char = self.name[-1]
	if last_char.isdigit():
	    elementIndex = int(last_char) - 1
	        # Update the specific element in the array based on the Numeric Entry     
                         Field's name
	    currentValues[elementIndex] = float(value)
	        # Write the updated array back to the OPC tag
	    system.tag.writeBlocking([opcTagPath], [currentValues])
	
	return value

So when I added script via Add Transform->Script then Bidirectional button is disable , so why it is not write changed value

Here self.name retrives the name property of the component, which is unique identifier for that component

Swathi, when you are pasting code you need to select the code block and press the </> button. Most of your code formatted correctly because there were leading spaces but the first line did not.

What does self.name look like? Is it [Sample_Tags]TO_LVF_CIT_N[0] as shown in the sample code?

You probably should not return value. It's already there.

Transforms are fundamentally unidirectional.

1 Like

ok so that changed values are not written, so is there any other way to add this script without this transform? Because onchange event is not there in configure events.

Here self.name retrives the name property of the component, which is unique identifier for that component

Hello I have one doubt regarding data type mismatch error
Here I have attched two images
51

The values of TO_LVF_CIT that are coming from OPC UA is in float array so when I see entries in tag browser then it will show Error_typeConversion so that I have cretaed new OPC tag via tag browser in which i have select Float Array as a datatype so it's values are showing properly

Now I bind one by one value in different numeric entry field and add this script in onActionPerfromed but still datatype mismatch error occured when i run project and change numeric entry field value , so any reason behind this?

def runAction(self, event):
	# Specify the OPC tag path for the first element
		
	opcTagPath = "[Sample_Tags]TO_LVF_CIT_N[0]"
	currentValue = system.tag.readBlocking([opcTagPath])[0].value	
	newValue = float(self.props.value)
	
	logger = system.util.logger("MyScriptLogger")		
	try:		
		logger.info("Updating tag: {}, newValue: {}".format(opcTagPath, newValue))		
	except Exception as e:	
		logger.error("Error updating OPC tag: {}".format(e), exc_info=True)
			
	system.tag.writeBlocking([opcTagPath], [newValue])

any version related issues are there that not support Float array data type??