Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modelica.Blocks.MathBoolean.{And, Nand} have wrong behaviour for empty input #2860

Closed
HansOlsson opened this issue Mar 20, 2019 · 2 comments
Closed
Assignees
Labels
L: Blocks Issue addresses Modelica.Blocks
Milestone

Comments

@HansOlsson
Copy link
Contributor

When looking at #682 I found that Nand-block documentation says that no inputs gives the output "false" - but the result is "true". It should likely be corrected together with #682.

@HansOlsson HansOlsson added L: Blocks Issue addresses Modelica.Blocks documentation Issue addresses the documentation labels Mar 20, 2019
@beutlich
Copy link
Member

beutlich commented Apr 9, 2019

With #2888 applied, it is MathBoolean.And that needs to be updated, while Nand will be correct then:

  block And "Logical 'and': y = u[1] and u[2] and ... and u[nu]"
    extends Modelica.Blocks.Interfaces.PartialBooleanMISO;

  equation
    y = Modelica.Math.BooleanVectors.allTrue(
                              u);
    annotation (defaultComponentName="and1", Icon(graphics={Text(
              extent={{-76,40},{60,-40}},
              textString="and")}),
      Documentation(info="<html>
<p>
The output is <strong>true</strong> if all inputs are <strong>true</strong>, otherwise
the output is <strong>false</strong>.
</p>

<p>
The input connector is a vector of Boolean input signals.
When a connection line is drawn, the dimension of the input
vector is enlarged by one and the connection is automatically
connected to this new free index (thanks to the
connectorSizing annotation).
</p>

<p>
The usage is demonstrated, e.g., in example
<a href=\"modelica://Modelica.Blocks.Examples.BooleanNetwork1\">Modelica.Blocks.Examples.BooleanNetwork1</a>.
</p>

<p>
If no connection to the input connector \"u\" is present,
the output is set to <strong>true</strong>: y=true.
</p>
</html>"));
  end And;

@beutlich beutlich self-assigned this Apr 9, 2019
@beutlich beutlich added this to the MSL4.0.0 milestone Apr 9, 2019
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue Apr 9, 2019
beutlich added a commit to beutlich/ModelicaStandardLibrary that referenced this issue May 5, 2019
@beutlich
Copy link
Member

beutlich commented Jun 13, 2019

Resolved in master by #2916: The behaviour of And and Nand block was changed to return true on non-connected input connector, respectively false. In that sense, it no longer is a pure documentation issue.

We could argue, that we might want to add All and Nall blocks restoring the existing behaviour (and with conversions And->All and Nand->Nall applied to not break compatibility).

@HansOlsson @MartinOtter Feel free to reopen if you prefer any other implementation.

@beutlich beutlich removed the documentation Issue addresses the documentation label Jun 13, 2019
@beutlich beutlich changed the title Modelica.Blocks.MathBoolean.Nand has wrong documentation for empty input Modelica.Blocks.MathBoolean.{And, Nand} have wrong behaviour for empty input Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: Blocks Issue addresses Modelica.Blocks
Projects
None yet
Development

No branches or pull requests

2 participants