Getting & Testing many valve states


I have about 150 valve states that I need to retrieve. I will use these states to allow / not allow certain other actions to happen.
Example: Valve1 will not open if valve 2 is also open

Whats the cleanest way to accomplish this?
I’ve considered assigning each digital output or input in a table manually, but it would be many lines of code. I’ve also thought about using the “GetAllModuleStates” command, but I’m not sure how to utilize the 32 bit int’s that are inserted in the table from that command.

Does it matter in terms of performance which route is taken? If the GetAllModuleStates is the best method, what is a good command to test the bits?

Performance is probably not an issue here since valves are slow devices, so I would recommend going with the method that is easy to maintain and the intent is clear.

What will be clearer to your future self: Using the IO unit commands (MoveIoUnitToNumTableEx, GetIoUnitAsBinaryValue64, etc) and then test the bits?
Or assign your valves to a pointer table and loop through that? (and that method will work with any type of IO module you happen to be using and across different IO units).

As far as assigning things manually, if you have some basic spreadsheet skills, you can make quick work of it with some formulas to build the OptoScript needed for the assignment.

I would take a pause and think for a moment about the HMI for the process.
How will your users interact with the process/valve state?
Do they need to change the rules on the fly etc?

Once you think about that aspect, it will guide you in the PAC Control side I suspect.

Personal note, as controls people, we usually start thinking about the controls first and over 30+ years of doing this stuff I often find that’s the wrong end to start with.

Begin with the end in mind The end is the HMI. So start with the page layout that will control or display the status of 150 valves and go back from there.

I ended up using MoveIoUnitToNumTableEx and then assigned each index to a variable. This seemed like the more robust way.

Also @Beno , there are 32 valves total, but each valve consists of 2 digital in’s (open/closed status), and a digital out.