object_zero_indexing.py
1 """ 2 Example: Object indexing 3 4 This example shows how to begin P1AM object references at 0 instead of at 1. 5 6 This example works with all P1000 Series Modules 7 _____ _____ 8 | P || S | 9 | 1 || L | 10 | A || O | 11 | M || T | 12 | - || | 13 | 2 || 0 | 14 | 0 || 1 | 15 | 0 || | 16 ¯¯¯¯¯ ¯¯¯¯¯ 17 Written by FACTS Engineering 18 Copyright (c) 2023 FACTS Engineering, LLC 19 Licensed under the MIT license. 20 """ 21 22 import time 23 import P1AM 24 25 # Pass in the zero_indexing argument as True to start indexing at 0 for channels and 26 # slots. This makes it easier to do iterable loops through objects. 27 # With the default indexing the base and module objects will have their zero index 28 # element as None i.e. base[0] = None 29 30 base = P1AM.Base(zero_indexing=True) # Intializes base. Returns the base object. 31 32 first_module = base[0] # this is the module next to the CPU 33 first_channel = first_module[0] # this is the first channel on the module 34 35 # Print a list of every channel and module in the base. All prints will be 0 referenced 36 # as well so they match what is seen in the code 37 for module in base: 38 print(module) 39 for channel in module.inputs: 40 print(channel) 41 for channel in module.outputs: 42 print(channel) 43 44 while True: 45 pass