Issues with "Int-Bool-Int Signal Mapper" Component in Visual Components

Problem Description:

I am using the “Int-Bool-Int Signal Mapper” component in Visual Components to map boolean signals to integer values and vice versa. However, I am facing an issue where only one bit of the output integer is being set, even though I expect multiple bits to be updated based on the input boolean signals.

Goal:

I would like to use the port number to determine the position of each boolean value in an integer, where:

  • The input port number determines the position in the integer value (e.g., port 0 maps to bit 0, port 1 to bit 1, etc.).
  • The boolean signal from each input port should map to a bit in the resulting integer, turning the bit ON (1) if the signal is TRUE and OFF (0) if the signal is FALSE.
  • The final result should be an integer where each bit represents the corresponding input port’s boolean signal.

Issue:

Currently, I am only getting a single bit set in the output integer, and I am unable to combine multiple boolean signals into a single integer value. For example, if I have four input boolean signals, I expect the output integer to have a corresponding bit set for each input signal, but only one bit (the first bit) is being set.

Code (Modified Attempt):

from vcScript import *

comp = getComponent()

    #Getting behaviors

inputs = comp.findBehaviour(“Inputs”)
outputs = comp.findBehaviour(“Outputs”)

inputPorts = [comp.findBehaviour(“Input{}”.format(i)) for i in range(4)] # 4 input ports
outputPort = comp.findBehaviour(“Output”) # Single output port

holdTime = comp.getProperty(“SignalHoldTime”)
numInputs = len(inputPorts) # Number of input signals

def OnRun():
while 1:
# Wait for any input signal to be triggered
triggerCondition(lambda: any(input.Value for input in inputPorts))

    integerValue = 0  # Initialize integer value
    
    # Loop through all input ports to map them to integer
    for i in range(numInputs):
        portIndex = i  # Get the port index (0, 1, 2, 3)
        signalValue = inputPorts[portIndex].Value  # Get boolean signal
        
        # Map the boolean value to the corresponding integer bit
        if signalValue:
            integerValue |= (1 << portIndex)  # Set bit if signal is True
        else:
            integerValue &= ~(1 << portIndex)  # Clear bit if signal is False
    
    # Output the final integer value
    outputs.output(integerValue)
    
    # Delay to hold the value for a set time
    delay(holdTime.Value)
    
    # Reset the output signal
    outputs.output(0)

Request:

Could you please help me resolve the issue of correctly mapping multiple boolean signals into a single integer output? I would appreciate any suggestions or solutions for handling multiple input signals and combining them into a single integer output.