Problem system.tag.writeBlocking and after system.tag.readBlocking

The writeBlocking must block the code until the write operation is finished? Why doesn't works?
In my example the same path after write operation are not the same.

I have Ignition 8.1.13 connected directly to CPU siemens 1500 with OPCUA of CPU.

this is the my scripting code:

		target_paths = [
		"[default]par1",
		"[default]par2",
		"[default]par3",
		"[default]par4",
		"[default]par5",
		"[default]par6",
		"[default]par7",
		"[default]par8"]
		
		recipe_paths =[
		"[default]dest1",
		"[default]dest2",
		"[default]dest3",
		"[default]dest4",
		"[default]dest5",
		"[default]dest6",
		"[default]dest7",
		"[default]dest8"]
		
		qualifiedValuesList = system.tag.readBlocking(recipe_paths)
		valuesList = []
		for element in qualifiedValuesList:
			valuesList.append(element.value)
			
		try:
			print "-------------------<<<<<<<<<<<2222222222222222>>>>>>>>>>>>>>-------------------"

			print "target_paths"
			print target_paths
			print "valuesList"
			print valuesList
		
			print "-------------------<<<<<<<<<<<22222222222222222>>>>>>>>>>>>>>-------------------"					
			risultato = system.tag.writeBlocking(target_paths, valuesList)
			print "risultato"
			print risultato
			
			letturadellascrittura = system.tag.readBlocking(target_paths)
			valori = []
			for element in letturadellascrittura:
				valori.append(element.value)
			print "valori letti"
			print valori
			print "-------------------<<<<<<<<<<<22222222222222222>>>>>>>>>>>>>>-----------------

.....--"

the results is this:
-------------------<<<<<<<<<<<2222222222222222>>>>>>>>>>>>>>-------------------
target_paths
['[default]dest1', '[default]dest2', '[default]dest3', '[default]dest4', '[default]dest5', '[default]dest6', '[default]dest7', '[default]dest8']
valuesList
[2537.5, 1877.75, 2207.625, 182.6999969482422, 329.875, 1323.0, 315.0, 399.0]
-------------------<<<<<<<<<<<22222222222222222>>>>>>>>>>>>>>-------------------
risultato
[Good, Good, Good, Good, Good, Good, Good, Good]
valori letti
[2994.25, 2436.0, 2715.125, 253.75, 279.125, 1323.0, 461.0, 400.20001220703125]
-------------------<<<<<<<<<<<22222222222222222>>>>>>>>>>>>>>-------------------

thanks

writeBlocking does block, but that doesn’t guarantee that the write to the device has occurred or that the value hasn’t been overwritten in the device.

It also doesn’t mean that the new value in the device has been picked up and read by Ignition.

I believe there is a read after write setting that you can enable to ask the tag system to read back the value after a write, if you really need this.

However, what is it that you’re really trying to accomplish?

I think the OPC server will take the values and send a good status, but because it runs on its own threading it might actually take some time for the change to be registered.

In this case, would it not be easier to check if every response is Good, and then use the new valuesList in the rest of your code? Rather than reading again?

The OPC Settings Optomistic Writes may be relevant here.

This, or using system.opc.writeValues and system.opc.readValues instead.

What's happening here is that yes, writeBlocking waits until we have a status result about the write from the OPC to return, but it does not update the actual value of the OPC tag (unless you have Optimistic Writes enabled). Only incoming OPC subscription updates will update the OPC tag value.

The subsequently issued readBlocking will just read the current tag value from memory, it will not reach out to the OPC server. This read can happen before you've received the next subscription update.

The system.opc functions bypass the tag/subscription system and just go directly to the server in both cases.

2 Likes