import numpy as np import win32com.client import time import timeit from datetime import datetime # Instantiate the client object client = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient') # Perform the operation Server_name='Matrikon.OPC.Simulation.1' Read_Tags=['Random.Int1','Random.Int2','Random.Int4','Random.Real4','Random.Real8','Random.UInt1','Random.UInt2','Random.UInt4','Bucket Brigade.Int1','Bucket Brigade.Int2','Bucket Brigade.Int4','Bucket Brigade.Real4', 'Bucket Brigade.Real8','Bucket Brigade.UInt1','Bucket Brigade.UInt2','Bucket Brigade.UInt4','Saw-toothed Waves.Int1','Saw-toothed Waves.Int2','Saw-toothed Waves.Int4','Saw-toothed Waves.Real4','Saw-toothed Waves.Real8', 'Saw-toothed Waves.UInt1','Saw-toothed Waves.UInt2','Saw-toothed Waves.UInt4','Square Waves.Int1','Square Waves.Int2','Square Waves.Int4','Square Waves.Real4','Square Waves.Real8', 'Square Waves.UInt1','Square Waves.UInt2','Square Waves.UInt4'] Write_Tags=['Write Only.Int1','Write Only.Int2','Write Only.Int4','Write Only.Real4','Write Only.Real8','Write Only.UInt1','Write Only.UInt2','Write Only.UInt4'] print('Read\Write Tag numbers: ', len(Read_Tags),len(Write_Tags)) for i in range(1000): value=[] start1=timeit.default_timer() for j in range(len(Read_Tags)): #print(j) value.append(client.ReadItemValue('', Server_name, Read_Tags[j])) end1=timeit.default_timer() #value=client.ReadItemValue('', Server_name, Tags[j]) #value = client.ReadItemValue('', Server_name, Tags) # Display results start2=timeit.default_timer() for j in range(len(Write_Tags)): #print(j) client.WriteItemValue('', Server_name,Write_Tags[j],6) end2=timeit.default_timer() print('$$$$$$ Read and Write time: ', end1-start1,end2-start2) #print('value: ', value) #time.sleep(1) print('END')