# THE SOFTWARE. from pyvirtualbench import PyVirtualBench, PyVirtualBenchException # This examples demonstrates how to generate and read static digital signals # using the Digital (Dig) lines on a VirtualBench. try: # You will probably need to replace "myVirtualBench" with the name of your device. # By default, the device name is the model number and serial number separated by a hyphen; e.g., "VB8012-309738A". # You can see the device's name in the VirtualBench Application under File->About channels_to_write = "myVirtualBench/dig/0:3" channels_to_read = "myVirtualBench/dig/4:7" data_to_write = [True, False, True, True] virtualbench = PyVirtualBench() dio = virtualbench.acquire_digital_input_output(channels_to_write) for i in range(10): dio.write(channels_to_write, data_to_write) print("[%d] Wrote to %s: %s" % (i, channels_to_write, data_to_write)) print("[%d] Read from %s: %s" % (i, channels_to_read, dio.read(channels_to_read))) dio.release() except PyVirtualBenchException as e: print("Error/Warning %d occurred\n%s" % (e.status, e)) finally: virtualbench.release()