TunnelCollection<PartP2PBCPower> outs = getOutputs();
double outputs = 0;
for (PartP2PBCPower g : outs)
{
IBatteryObject o = g.getTargetBattery();
if ( o != null )
{
outputs = outputs + 1.0;
}
}
if ( outputs < 0.0000001 )
return 0;
for (PartP2PBCPower g : outs)
{
IBatteryObject o = g.getTargetBattery();
if ( o != null )
{
double fraction = originalInput / outputs;
if ( cycleLimitMode )
fraction = o.addEnergy( fraction );
else
fraction = o.addEnergy( fraction, ignoreCycleLimit );
mj -= fraction;
}
}
if ( mj > 0 )
{
for (PartP2PBCPower g : outs)
{
IBatteryObject o = g.getTargetBattery();
if ( o != null )
{
if ( cycleLimitMode )
mj = mj - o.addEnergy( mj );
else
mj = mj - o.addEnergy( mj, ignoreCycleLimit );
}
}
}
return originalInput - mj;