Complete the code to create an OPC server connection.
opc_server = OPCClient('[1]')
The OPCClient needs the exact OPC server name to connect. 'OPCServer1' is the correct server name here.
Complete the code to read a tag value from the OPC server.
value = opc_server.read('[1]')
To read data, you specify the tag name. 'Tag1' is a valid tag identifier.
Fix the error in the code to write a value to an OPC tag.
opc_server.write('[1]', 100)
The first argument must be the tag name. 'Tag1' is correct to specify the tag to write to.
Fill both blanks to create a subscription and set the update rate.
subscription = opc_server.create_subscription('[1]') subscription.update_rate = [2]
The subscription is created for a tag name like 'Tag1'. The update rate is set in milliseconds, here 1000 ms.
Fill all three blanks to read multiple tags and store their values in a dictionary.
tags = ['[1]', '[2]'] values = {tag: opc_server.read(tag) for tag in tags if tag [3] 'Tag1'}
The tags list includes 'Tag1' and 'Tag2'. The dictionary comprehension filters tags not equal to 'Tag1' using '!='.