Pre

block Pre "Breaks algebraic loops by an infinitesimal small time delay (y = pre(u): event iteration continues until u = pre(u))"
    parameter Boolean pre_u_start = false "Start value of pre(u) at initial time";

    extends Blocks.Interfaces.partialBooleanSISO;
initial equation
    pre(u) = pre_u_start;
equation
    y = pre(u);

    annotation (
        defaultComponentName = "pre1",
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Text(
                    extent = {
                        {-90, 40}, 
                        {90, -40}},
                    textString = "pre")}),
        Documentation(info = "<html>\n<p>\nThis block delays the Boolean input by an infinitesimal small time delay and\ntherefore breaks algebraic loops. In a network of logical blocks, in every\n\"closed connection loop\" at least one logical block must have a delay,\nsince algebraic systems of Boolean equations are not solvable.\n</p>\n\n<p>\nThe \"Pre\" block returns the value of the \"input\" signal from the\nlast \"event iteration\". The \"event iteration\" stops, once both\nvalues are identical (u = pre(u)).\n</p>\n</html>"));
end Pre;