i had a kind-of similar scenario a few months ago. the equipment was for a water treatment installation, not compressed air. there were 3 different circumstances (resulting in 2 different input sources) that an common output (a 30kW pump VSD) was to be controlled under. normal situation was to control the pump on the % of the tank level, the other situations were to control the pump on the volume of water required (m3/h). as m3/h was calculated, the natural thing was to have the input set as host. so the pid loop would go from controlling the tank at 50% to then controlling the volume to either 35m3/h to 60m3/h. so in auto, if you suddenly change the setpoint from 50 to 35 or 60 and your input from say 20(%) to 35(m3/h), depending on your PID values, this could cause an undesirable change in output.
to make the transition seamless (ie stop the pump from jumping dramatically due to the PID changes) the PID was put into manual mode, setpoint and input updated and then put back into auto.
the configuration was to have 1 PID loop configured on the brain with the input from host and the P,I,D,sp and scan rate values were configured as variables. depending on the situation, the appropriate input and PID values were written to the brain. the only catch was to make sure the transition from the old set of values to the new set of values bumpless, hence the reason the loop was put into manual, the new values were updated and then the control loop put back into auto. the pump has some major power about it and if it jumped suddenly, the rest of the upstream/downstream pumps and control loops would jump around (which was undesirable)
if you wanted to keep the PID loop autonomous, (ie keep going if comms are lost to the I/O unit) instead of writing the input to the PID loop, you could simply write the mem map location of the input the PID loop should be using.
eg: say your PID loop is configured in slot 0. to change the location of the input, write to mmp address 0xF2100044 (MemMap Address for Input) the memmap address of the input (say module 4, input 0’s scaled units ) 0xF0264000. unless power is cycled to the unit or you resend the I/O unit configuration, this will stay persistent (ive used this method as well and it works great)
then coding would be to monitor the situation, if you detect a change is required, put the PID into manual, update the inputs MMP location and PID values, and then put back into auto. if your system expands, then you just have to add the appropriate new variables. no pointers required. if the situation occurs where there are 2 tanks running, then you just have to decide on the default input.
in the case you have identified, my inclination would be have a single PID loop with the output to be the common exit valve and to store the MMP locations of the vessels inputs. when the tank is called for, put the PID into manual, write the new PI&D values to the loop, write the new mmp location for the PID loop input and then put the loop back into auto. this should hopefully make switching between PID loops seamless.
the obvious problem is the default. what to use? depending on your program, if there is a power cycle, the outputs go to 0 anyway and the program starts ‘afresh’. you specify what you want as default from the beginning and alls good. if the unit loses comms (or you do a strategy update), you don’t want the I/O unit to be reinitialized as this will write the default values to the PID loop. a couple of tricks around this (make sure you have the default configuration already stored to flash before you do this) is to untick the checkbox ‘Enable Communications from Control Engine’ under the Edit I/O Unit dialog (this will stop the IO unit getting a configuration sent to it when the strategy is started). you will have to manually enable the comms to the IO unit when the strategy runs.
then if the unit goes offline, before getting it back online issue the command SetIoUnitConfiguredFlag(IO Unit) so when you issue EnableCommunicationsToIoUnit(IoUnit); the configuration will stay present (same PID loop settings).
i hope this makes sense and helps you in your process.