First time user and non english speaker here. Please be kind.
I'm trying to write a FB that control a pump which as a sensor on the motor axis to monitor its movement.
I've written the code so that during init of the FB I can reference to the hardware I/O.
FUNCTION_BLOCK PumpControl
VAR
sensor : REFERENCE TO BOOL;
motor : REFERENCE TO BOOL;
END_VAR
Now I have to implement another FB that control a group of three pump
FUNCTION_BLOCK TankControl
VAR
pump1 : REFERENCE TO PumpControl;
pump2 : REFERENCE TO PumpControl;
pump3 : REFERENCE TO PumpControl;
END_VAR
In my main I create the pumps, the tank and all the variables
PROGRAM MAIN
VAR
input1 AT %I* : BOOL;
output1 AT %Q* : BOOL;
pumpH2O : PumpControl(sensor := input1, motor := output1);
input2 AT %I* : BOOL;
output2 AT %Q* : BOOL;
pumpS1 : PumpControl(sensor := input2, motor := output2);
input3 AT %I* : BOOL;
output3 AT %Q* : BOOL;
pumpS2 : PumpControl(sensor := input2, motor := output2);
mainTank : TankControl(pump1 := pumpH2O, pump2 := pumpS1, pump3 := pumpS2);
END_VAR
If I'm right I have to create properties for all the referenced variables to make it work.
In the MAIN code I want to call mainTank() to perform all the action involved.
At the moment I have no access to the hardware and cannot try it myself.
Is this going to work?