def ready(self, rr):
     if ((self.waiting.elementOf(rr)).booleanValue()):
         self.waiting = self.waiting.difference(BSet(rr))
         if self.active.equal(BSet()):
             self.active = BSet(rr)
         else:
             self._ready = self._ready.union(BSet(rr))
Beispiel #2
0
    def route_reservation(self, r):
        _ld_resrt = self.resrt

        _ld_rsrtbl = self.rsrtbl
        _ld_resbl = self.resbl
        self.resrt = _ld_resrt.union(BSet(r))
        self.rsrtbl = _ld_rsrtbl.union(self.rtbl.rangeRestriction(BSet(r)))
        self.resbl = _ld_resbl.union(self.rtbl.inverse().relationImage(BSet(r)))
Beispiel #3
0
 def BACK_MOVE_2(self, b):
     _ld_OCC = self.OCC
     _ld_LBT = self.LBT
     _ld_rsrtbl = self.rsrtbl
     _ld_resbl = self.resbl
     self.OCC = _ld_OCC.difference(BSet(b))
     self.rsrtbl = _ld_rsrtbl.domainSubstraction(BSet(b))
     self.resbl = _ld_resbl.difference(BSet(b))
     self.LBT = _ld_LBT.difference(BSet(b)).union(BSet(self.TRK.functionCall(b)))
Beispiel #4
0
 def BACK_MOVE_1(self, b):
     _ld_OCC = self.OCC
     _ld_LBT = self.LBT
     _ld_rsrtbl = self.rsrtbl
     _ld_resbl = self.resbl
     self.OCC = _ld_OCC.difference(BSet(b))
     self.rsrtbl = _ld_rsrtbl.domainSubstraction(BSet(b))
     self.resbl = _ld_resbl.difference(BSet(b))
     self.LBT = _ld_LBT.difference(BSet(b))
 def new(self, pp):
     if ((BBoolean(
             BBoolean(
                 self._PID.elementOf(pp).booleanValue() and self.active.
                 notElementOf(pp).booleanValue()).booleanValue()
             and self._ready.union(
                 self.waiting).notElementOf(pp).booleanValue())
          ).booleanValue()):
         self.waiting = self.waiting.union(BSet(pp))
 def swap(self, pp):
     if self.active.unequal(BSet()):
         self.waiting = self.waiting.union(self.active)
         if self._ready.equal(BSet()):
             self.active = BSet()
         else:
             self.active = BSet(pp)
             self._ready = self._ready.difference(BSet(pp))
Beispiel #7
0
    def ComputeNumberOfPrimes(self):
        while (BBoolean(
                self.cur.greater(BInteger(1)).booleanValue()
                and self.cur.multiply(self.cur).lessEqual(
                    self.limit).booleanValue())).booleanValue():
            if (self.numbers.elementOf(self.cur)).booleanValue():
                n = self.cur
                set = BSet()
                while (n.lessEqual(self.limit.divide(
                        self.cur))).booleanValue():
                    set = set.union(BSet(self.cur.multiply(n)))
                    n = n.plus(BInteger(1))

                self.numbers = self.numbers.difference(set)

            self.cur = self.cur.plus(BInteger(1))

        res = self.numbers.card()
        return res
Beispiel #8
0
class TrafficLight:

    _colors = BSet(colors.red, colors.redyellow, colors.yellow, colors.green)

    def __init__(self):
        self.tl_cars = colors.red
        self.tl_peds = colors.red

    def cars_ry(self):
        if ((BBoolean(
                self.tl_cars.equal(colors.red).booleanValue()
                and self.tl_peds.equal(
                    colors.red).booleanValue())).booleanValue()):
            self.tl_cars = colors.redyellow

    def cars_y(self):
        if ((BBoolean(
                self.tl_cars.equal(colors.green).booleanValue()
                and self.tl_peds.equal(
                    colors.red).booleanValue())).booleanValue()):
            self.tl_cars = colors.yellow

    def cars_g(self):
        if ((BBoolean(
                self.tl_cars.equal(colors.redyellow).booleanValue()
                and self.tl_peds.equal(
                    colors.red).booleanValue())).booleanValue()):
            self.tl_cars = colors.green

    def cars_r(self):
        if ((BBoolean(
                self.tl_cars.equal(colors.yellow).booleanValue()
                and self.tl_peds.equal(
                    colors.red).booleanValue())).booleanValue()):
            self.tl_cars = colors.red

    def peds_r(self):
        if ((BBoolean(
                self.tl_peds.equal(colors.green).booleanValue()
                and self.tl_cars.equal(
                    colors.red).booleanValue())).booleanValue()):
            self.tl_peds = colors.red

    def peds_g(self):
        if ((BBoolean(
                self.tl_peds.equal(colors.red).booleanValue()
                and self.tl_cars.equal(
                    colors.red).booleanValue())).booleanValue()):
            self.tl_peds = colors.green

    def _get_tl_cars(self):
        return self.tl_cars

    def _get_tl_peds(self):
        return self.tl_peds
Beispiel #9
0
    def __init__(self):
        self.fst = BRelation(BTuple(ROUTES.R1, BLOCKS.L), BTuple(ROUTES.R2, BLOCKS.L), BTuple(ROUTES.R3, BLOCKS.L), BTuple(ROUTES.R4, BLOCKS.M), BTuple(ROUTES.R5, BLOCKS.M), BTuple(ROUTES.R6, BLOCKS.C), BTuple(ROUTES.R7, BLOCKS.G), BTuple(ROUTES.R8, BLOCKS.N), BTuple(ROUTES.R9, BLOCKS.G), BTuple(ROUTES.R10, BLOCKS.N))
        self.lst = BRelation(BTuple(ROUTES.R1, BLOCKS.C), BTuple(ROUTES.R2, BLOCKS.G), BTuple(ROUTES.R3, BLOCKS.N), BTuple(ROUTES.R4, BLOCKS.G), BTuple(ROUTES.R5, BLOCKS.N), BTuple(ROUTES.R6, BLOCKS.L), BTuple(ROUTES.R7, BLOCKS.L), BTuple(ROUTES.R8, BLOCKS.L), BTuple(ROUTES.R9, BLOCKS.M), BTuple(ROUTES.R10, BLOCKS.M))
        self.nxt = BRelation(BTuple(ROUTES.R1, BRelation(BTuple(BLOCKS.L, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.C))), BTuple(ROUTES.R2, BRelation(BTuple(BLOCKS.L, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.D), BTuple(BLOCKS.D, BLOCKS.E), BTuple(BLOCKS.E, BLOCKS.F), BTuple(BLOCKS.F, BLOCKS.G))), BTuple(ROUTES.R3, BRelation(BTuple(BLOCKS.L, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.D), BTuple(BLOCKS.D, BLOCKS.K), BTuple(BLOCKS.K, BLOCKS.J), BTuple(BLOCKS.J, BLOCKS.N))), BTuple(ROUTES.R4, BRelation(BTuple(BLOCKS.M, BLOCKS.H), BTuple(BLOCKS.H, BLOCKS.I), BTuple(BLOCKS.I, BLOCKS.K), BTuple(BLOCKS.K, BLOCKS.F), BTuple(BLOCKS.F, BLOCKS.G))), BTuple(ROUTES.R5, BRelation(BTuple(BLOCKS.M, BLOCKS.H), BTuple(BLOCKS.H, BLOCKS.I), BTuple(BLOCKS.I, BLOCKS.J), BTuple(BLOCKS.J, BLOCKS.N))), BTuple(ROUTES.R6, BRelation(BTuple(BLOCKS.C, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.L))), BTuple(ROUTES.R7, BRelation(BTuple(BLOCKS.G, BLOCKS.F), BTuple(BLOCKS.F, BLOCKS.E), BTuple(BLOCKS.E, BLOCKS.D), BTuple(BLOCKS.D, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.L))), BTuple(ROUTES.R8, BRelation(BTuple(BLOCKS.N, BLOCKS.J), BTuple(BLOCKS.J, BLOCKS.K), BTuple(BLOCKS.K, BLOCKS.D), BTuple(BLOCKS.D, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.L))), BTuple(ROUTES.R9, BRelation(BTuple(BLOCKS.G, BLOCKS.F), BTuple(BLOCKS.F, BLOCKS.K), BTuple(BLOCKS.K, BLOCKS.I), BTuple(BLOCKS.I, BLOCKS.H), BTuple(BLOCKS.H, BLOCKS.M))), BTuple(ROUTES.R10, BRelation(BTuple(BLOCKS.N, BLOCKS.J), BTuple(BLOCKS.J, BLOCKS.I), BTuple(BLOCKS.I, BLOCKS.H), BTuple(BLOCKS.H, BLOCKS.M))))
        self._ic_set_0 = BRelation()
        for _ic_b_1 in self._BLOCKS:
            for _ic_r_1 in Train_1_beebook_deterministic._ROUTES:
                if(BBoolean(self.nxt.domain().elementOf(_ic_r_1).booleanValue() and BBoolean(self.nxt.functionCall(_ic_r_1).domain().elementOf(_ic_b_1).booleanValue() or self.nxt.functionCall(_ic_r_1)._range().elementOf(_ic_b_1).booleanValue()).booleanValue())).booleanValue():
                    _ic_set_0 = self._ic_set_0.union(BRelation(BTuple(_ic_b_1, _ic_r_1)))

        self.rtbl = self._ic_set_0
        self.resrt = BSet()
        self.resbl = BSet()
        self.rsrtbl = BRelation()
        self.OCC = BSet()
        self.TRK = BRelation()
        self.frm = BSet()
        self.LBT = BSet()
Beispiel #10
0
 def __init__(self):
     NATSET = BSet.interval(BInteger(0), BInteger(5))
     self.T2v = BInteger(0)
     self.T3_evaluated = BBoolean(True)
     self.T3_enabled = BBoolean(True)
     self.T1_state = T1state.T1_EN
     self.T2_state = T2state.T2_EN
     self.T3_state = T3state.T3_READY
     self.T1_writevalue = BInteger(0)
     self.T2_writevalue = BInteger(0)
     self.T2_readvalue = BInteger(0)
     self.T2_readpriority = BInteger(0)
     self.T3_readvalue = BInteger(0)
     self.T3_readpriority = BInteger(0)
     self.T1_timer = BInteger(2)
     self.T2_timer = BInteger(3)
     self.BUSwrite = BRelation(BTuple(BInteger(0), BInteger(0)))
     self.BUSvalue = BInteger(0)
     self.BUSpriority = BInteger(0)
     self.T2_mode = T2mode.T2MODE_SENSE
Beispiel #11
0
 def FRONT_MOVE_2(self, b):
     self.OCC = self.OCC.union(BSet(self.TRK.functionCall(b)))
Beispiel #12
0
 def T2ReleaseBus(self, ppriority):
     _ld_BUSwrite = self.BUSwrite
     self.BUSwrite = _ld_BUSwrite.domainSubstraction(BSet(ppriority))
     self.T2_state = T2state.T2_WAIT
Beispiel #13
0
 def T3ReleaseBus(self, ppriority):
     _ld_BUSwrite = self.BUSwrite
     self.BUSwrite = _ld_BUSwrite.domainSubstraction(BSet(ppriority))
     self.T3_state = T3state.T3_RELEASE
 def _del(self, pp):
     if ((self.waiting.elementOf(pp)).booleanValue()):
         self.waiting = self.waiting.difference(BSet(pp))
Beispiel #15
0
class Cruise_finite1_deterministic:

    _RSset = BSet(RSset.RSnone, RSset.RSpos, RSset.RSneg, RSset.RSequal)
    _ODset = BSet(ODset.ODnone, ODset.ODclose, ODset.ODveryclose)

    def __init__(self):
        self.CruiseAllowed = BBoolean(False)
        self.CruiseActive = BBoolean(False)
        self.VehicleAtCruiseSpeed = BBoolean(False)
        self.VehicleCanKeepSpeed = BBoolean(False)
        self.VehicleTryKeepSpeed = BBoolean(False)
        self.SpeedAboveMax = BBoolean(False)
        self.VehicleTryKeepTimeGap = BBoolean(False)
        self.NumberOfSetCruise = BInteger(0)
        self.CruiseSpeedAtMax = BBoolean(False)
        self.ObstacleDistance = ODset.ODnone
        self.ObstacleStatusJustChanged = BBoolean(False)
        self.CCInitialisationInProgress = BBoolean(False)
        self.CruiseSpeedChangeInProgress = BBoolean(False)
        self.ObstaclePresent = BBoolean(False)
        self.ObstacleRelativeSpeed = RSset.RSnone

    def CruiseBecomesNotAllowed(self):
        if ((self.CruiseAllowed.equal(BBoolean(True))).booleanValue()):
            self.CruiseAllowed = BBoolean(False)
            self.CruiseActive = BBoolean(False)
            self.VehicleCanKeepSpeed = BBoolean(False)
            self.VehicleTryKeepSpeed = BBoolean(False)
            self.VehicleAtCruiseSpeed = BBoolean(False)
            self.VehicleTryKeepTimeGap = BBoolean(False)
            self.CruiseSpeedAtMax = BBoolean(False)
            self.ObstacleDistance = ODset.ODnone
            self.NumberOfSetCruise = BInteger(0)
            self.ObstacleStatusJustChanged = BBoolean(False)
            self.CCInitialisationInProgress = BBoolean(False)
            self.CruiseSpeedChangeInProgress = BBoolean(False)

    def CruiseBecomesAllowed(self):
        if ((self.CruiseAllowed.equal(BBoolean(False))).booleanValue()):
            self.CruiseAllowed = BBoolean(True)

    def SetCruiseSpeed(self, vcks, csam):
        if ((self.CruiseAllowed.equal(BBoolean(True))).booleanValue()):
            _ld_NumberOfSetCruise = self.NumberOfSetCruise
            self.CruiseActive = BBoolean(True)
            self.VehicleCanKeepSpeed = vcks
            if ((self.SpeedAboveMax.equal(BBoolean(False))).booleanValue()):
                self.VehicleAtCruiseSpeed = BBoolean(True)
                self.CruiseSpeedAtMax = csam
            else:
                self.CruiseSpeedAtMax = BBoolean(True)
            self.ObstacleStatusJustChanged = BBoolean(True)
            if ((self.CruiseActive.equal(BBoolean(True))).booleanValue()):
                self.CruiseSpeedChangeInProgress = BBoolean(True)
            else:
                self.CCInitialisationInProgress = BBoolean(True)
            if ((_ld_NumberOfSetCruise.less(BInteger(1))).booleanValue()):
                self.NumberOfSetCruise = _ld_NumberOfSetCruise.plus(
                    BInteger(1))

    def CCInitialisationFinished(self, vtks, vtktg):
        if ((self.CCInitialisationInProgress.equal(
                BBoolean(True))).booleanValue()):
            self.VehicleTryKeepTimeGap = vtktg
            self.VehicleTryKeepSpeed = vtks

    def CCInitialisationDelayFinished(self):
        if ((BBoolean(
                BBoolean(
                    BBoolean(
                        BBoolean(
                            BBoolean(
                                self.CCInitialisationInProgress.equal(
                                    BBoolean(True)).booleanValue()
                                and BBoolean(
                                    BBoolean(
                                        BBoolean(
                                            self.VehicleTryKeepSpeed.equal(
                                                BBoolean(True)).booleanValue()
                                            or self.VehicleTryKeepTimeGap.
                                            equal(BBoolean(True)).booleanValue(
                                            )).booleanValue() or
                                        self.ObstacleStatusJustChanged.equal(
                                            BBoolean(True)).booleanValue()).
                                    booleanValue()
                                    or self.CruiseSpeedChangeInProgress.equal(
                                        BBoolean(True)).booleanValue()).
                                booleanValue()).booleanValue()
                            and BBoolean(not self.ObstacleDistance.equal(
                                ODset.ODnone).booleanValue()
                                         or self.VehicleTryKeepSpeed.equal(
                                             BBoolean(True)).booleanValue()).
                            booleanValue()).booleanValue()
                        and BBoolean(not BBoolean(
                            BBoolean(
                                BBoolean(
                                    self.ObstacleDistance.equal(
                                        ODset.ODclose).booleanValue() and self.
                                    ObstacleRelativeSpeed.unequal(RSset.RSpos).
                                    booleanValue()).booleanValue() and self.
                                ObstacleStatusJustChanged.equal(BBoolean(
                                    False)).booleanValue()).booleanValue()
                            and self.CruiseSpeedChangeInProgress.equal(
                                BBoolean(False)).booleanValue()
                        ).booleanValue() or self.VehicleTryKeepTimeGap.equal(
                            BBoolean(True)).booleanValue()).booleanValue()).
                    booleanValue() and BBoolean(not BBoolean(
                        BBoolean(
                            self.ObstacleDistance.equal(
                                ODset.ODveryclose).booleanValue()
                            and self.ObstacleStatusJustChanged.equal(
                                BBoolean(False)).booleanValue()).booleanValue(
                                ) and self.CruiseSpeedChangeInProgress.equal(
                                    BBoolean(False)).booleanValue()
                    ).booleanValue() or self.VehicleTryKeepTimeGap.equal(
                        BBoolean(True)).booleanValue()).booleanValue()).
                booleanValue() and BBoolean(not BBoolean(
                    BBoolean(
                        BBoolean(
                            self.ObstacleRelativeSpeed.equal(
                                RSset.RSpos).booleanValue() and
                            self.ObstacleDistance.unequal(ODset.ODveryclose).
                            booleanValue()).booleanValue()
                        and self.ObstacleStatusJustChanged.equal(
                            BBoolean(False)).booleanValue()).booleanValue()
                    and self.CruiseSpeedChangeInProgress.equal(
                        BBoolean(False)).booleanValue()).booleanValue()
                                            or self.VehicleTryKeepSpeed.equal(
                                                BBoolean(True)).booleanValue()
                                            ).booleanValue())).booleanValue()):
            self.CCInitialisationInProgress = BBoolean(True)

    def CruiseSpeedChangeFinished(self, vtks, vtktg):
        if ((BBoolean(
                BBoolean(
                    BBoolean(
                        BBoolean(
                            BBoolean(
                                BBoolean(
                                    BBoolean(
                                        BBoolean(
                                            BBoolean(
                                                BBoolean(
                                                    BUtils.BOOL.elementOf(
                                                        vtks).booleanValue()
                                                    and BUtils.BOOL.elementOf(
                                                        vtktg).booleanValue()).
                                                booleanValue() and BBoolean(
                                                    BBoolean(
                                                        BBoolean(
                                                            vtks.equal(
                                                                BBoolean(True)
                                                            ).booleanValue()
                                                            or vtktg.equal(
                                                                BBoolean(True)
                                                            ).booleanValue()).
                                                        booleanValue() or self.
                                                        ObstacleStatusJustChanged
                                                        .equal(BBoolean(True)).
                                                        booleanValue()).
                                                    booleanValue() or self.
                                                    CCInitialisationInProgress.
                                                    equal(BBoolean(
                                                        True)).booleanValue()).
                                                booleanValue()).booleanValue()
                                            and BBoolean(
                                                not self.ObstaclePresent.equal(
                                                    BBoolean(False)).
                                                booleanValue() or vtktg.equal(
                                                    BBoolean(False)).
                                                booleanValue()).booleanValue()
                                        ).booleanValue() and BBoolean(
                                            not self.ObstacleDistance.equal(
                                                ODset.ODnone).booleanValue()
                                            or vtks.equal(BBoolean(True)).
                                            booleanValue()).booleanValue()).
                                    booleanValue() and BBoolean(not BBoolean(
                                        BBoolean(
                                            BBoolean(
                                                self.ObstacleDistance.equal(
                                                    ODset.ODclose).
                                                booleanValue()
                                                and self.ObstacleRelativeSpeed.
                                                unequal(RSset.RSpos).
                                                booleanValue()).booleanValue()
                                            and self.ObstacleStatusJustChanged.
                                            equal(BBoolean(False)).
                                            booleanValue()).booleanValue() and
                                        self.CCInitialisationInProgress.equal(
                                            BBoolean(False)).booleanValue()
                                    ).booleanValue() or vtktg.equal(
                                        BBoolean(True)).booleanValue()).
                                    booleanValue()).booleanValue()
                                and BBoolean(not BBoolean(
                                    BBoolean(
                                        self.ObstacleDistance.equal(
                                            ODset.ODveryclose).booleanValue()
                                        and self.ObstacleStatusJustChanged.
                                        equal(BBoolean(False)).booleanValue()).
                                    booleanValue()
                                    and self.CCInitialisationInProgress.equal(
                                        BBoolean(False)).booleanValue()
                                ).booleanValue() or vtktg.equal(BBoolean(
                                    True)).booleanValue()).booleanValue()).
                            booleanValue() and BBoolean(not BBoolean(
                                BBoolean(
                                    BBoolean(
                                        self.ObstacleRelativeSpeed.equal(
                                            RSset.RSpos).booleanValue()
                                        and self.ObstacleDistance.unequal(
                                            ODset.ODveryclose).booleanValue()).
                                    booleanValue()
                                    and self.ObstacleStatusJustChanged.equal(
                                        BBoolean(False)).booleanValue()).
                                booleanValue()
                                and self.CCInitialisationInProgress.equal(
                                    BBoolean(False)).booleanValue()
                            ).booleanValue() or vtks.equal(
                                BBoolean(True)).booleanValue()).booleanValue()
                        ).booleanValue() and BBoolean(not BBoolean(
                            self.ObstacleRelativeSpeed.equal(
                                RSset.RSequal).booleanValue()
                            and self.ObstacleDistance.equal(ODset.ODnone).
                            booleanValue()).booleanValue() or vtktg.equal(
                                BBoolean(False)).booleanValue()).booleanValue(
                                )).booleanValue()
                    and BBoolean(not BBoolean(
                        self.ObstacleRelativeSpeed.equal(RSset.RSneg).
                        booleanValue() and self.ObstacleDistance.equal(
                            ODset.ODnone).booleanValue()).booleanValue()
                                 or vtktg.equal(BBoolean(False)).booleanValue(
                                 )).booleanValue()).booleanValue()
                and BBoolean(not BBoolean(
                    self.ObstacleRelativeSpeed.equal(
                        RSset.RSpos).booleanValue()
                    and self.ObstacleDistance.unequal(
                        ODset.ODveryclose).booleanValue()).booleanValue()
                             or vtktg.equal(BBoolean(False)).booleanValue()).
                booleanValue())).booleanValue()):
            if ((self.CruiseSpeedChangeInProgress.equal(
                    BBoolean(True))).booleanValue()):
                self.VehicleTryKeepTimeGap = vtktg
                self.VehicleTryKeepSpeed = vtks

    def CruiseSpeedChangeDelayFinished(self):
        if ((BBoolean(
                BBoolean(
                    BBoolean(
                        BBoolean(
                            BBoolean(
                                self.CruiseSpeedChangeInProgress.equal(
                                    BBoolean(True)).booleanValue()
                                and BBoolean(
                                    BBoolean(
                                        BBoolean(
                                            self.VehicleTryKeepSpeed.equal(
                                                BBoolean(True)).booleanValue()
                                            or self.VehicleTryKeepTimeGap.
                                            equal(BBoolean(True)).booleanValue(
                                            )).booleanValue() or
                                        self.ObstacleStatusJustChanged.equal(
                                            BBoolean(True)).booleanValue()).
                                    booleanValue()
                                    or self.CCInitialisationInProgress.equal(
                                        BBoolean(True)).booleanValue()).
                                booleanValue()).booleanValue()
                            and BBoolean(not self.ObstacleDistance.equal(
                                ODset.ODnone).booleanValue()
                                         or self.VehicleTryKeepSpeed.equal(
                                             BBoolean(True)).booleanValue()).
                            booleanValue()).booleanValue()
                        and BBoolean(not BBoolean(
                            BBoolean(
                                BBoolean(
                                    self.ObstacleDistance.equal(
                                        ODset.ODclose).booleanValue() and self.
                                    ObstacleRelativeSpeed.unequal(RSset.RSpos).
                                    booleanValue()).booleanValue() and self.
                                ObstacleStatusJustChanged.equal(BBoolean(
                                    False)).booleanValue()).booleanValue()
                            and self.CCInitialisationInProgress.equal(
                                BBoolean(False)).booleanValue()
                        ).booleanValue() or self.VehicleTryKeepTimeGap.equal(
                            BBoolean(True)).booleanValue()).booleanValue()).
                    booleanValue() and BBoolean(not BBoolean(
                        BBoolean(
                            self.ObstacleDistance.equal(
                                ODset.ODveryclose).booleanValue()
                            and self.ObstacleStatusJustChanged.equal(
                                BBoolean(False)).booleanValue()).booleanValue(
                                ) and self.CCInitialisationInProgress.equal(
                                    BBoolean(False)).booleanValue()
                    ).booleanValue() or self.VehicleTryKeepTimeGap.equal(
                        BBoolean(True)).booleanValue()).booleanValue()).
                booleanValue() and BBoolean(not BBoolean(
                    BBoolean(
                        BBoolean(
                            self.ObstacleRelativeSpeed.equal(
                                RSset.RSpos).booleanValue() and
                            self.ObstacleDistance.unequal(ODset.ODveryclose).
                            booleanValue()).booleanValue()
                        and self.ObstacleStatusJustChanged.equal(
                            BBoolean(False)).booleanValue()).booleanValue()
                    and self.CCInitialisationInProgress.equal(
                        BBoolean(False)).booleanValue()).booleanValue()
                                            or self.VehicleTryKeepSpeed.equal(
                                                BBoolean(True)).booleanValue()
                                            ).booleanValue())).booleanValue()):
            self.CruiseSpeedChangeInProgress = BBoolean(True)

    def CruiseOff(self):
        if ((self.CruiseActive.equal(BBoolean(True))).booleanValue()):
            self.CruiseActive = BBoolean(False)
            self.VehicleCanKeepSpeed = BBoolean(False)
            self.VehicleTryKeepSpeed = BBoolean(False)
            self.VehicleAtCruiseSpeed = BBoolean(False)
            self.VehicleTryKeepTimeGap = BBoolean(False)
            self.CruiseSpeedAtMax = BBoolean(False)
            self.ObstacleDistance = ODset.ODnone
            self.NumberOfSetCruise = BInteger(0)
            self.ObstacleStatusJustChanged = BBoolean(False)
            self.CCInitialisationInProgress = BBoolean(False)
            self.CruiseSpeedChangeInProgress = BBoolean(False)

    def ExternalForcesBecomesExtreme(self):
        if ((self.VehicleCanKeepSpeed.equal(BBoolean(True))).booleanValue()):
            self.VehicleCanKeepSpeed = BBoolean(False)

    def ExternalForcesBecomesNormal(self):
        if ((BBoolean(
                self.CruiseActive.equal(BBoolean(True)).booleanValue()
                and self.VehicleCanKeepSpeed.equal(
                    BBoolean(False)).booleanValue())).booleanValue()):
            self.VehicleCanKeepSpeed = BBoolean(True)

    def VehicleLeavesCruiseSpeed(self):
        if ((BBoolean(
                BBoolean(
                    self.VehicleAtCruiseSpeed.equal(
                        BBoolean(True)).booleanValue() and BBoolean(
                            self.VehicleCanKeepSpeed.equal(
                                BBoolean(False)).booleanValue()
                            and self.VehicleTryKeepSpeed.equal(BBoolean(True)).
                            booleanValue()).booleanValue()).booleanValue()
                or self.VehicleTryKeepSpeed.equal(
                    BBoolean(False)).booleanValue())).booleanValue()):
            self.VehicleAtCruiseSpeed = BBoolean(False)

    def VehicleReachesCruiseSpeed(self):
        if ((BBoolean(
                BBoolean(
                    self.CruiseActive.equal(BBoolean(True)).booleanValue()
                    and self.VehicleAtCruiseSpeed.equal(
                        BBoolean(False)).booleanValue()).booleanValue()
                and self.SpeedAboveMax.equal(
                    BBoolean(False)).booleanValue())).booleanValue()):
            self.VehicleAtCruiseSpeed = BBoolean(True)

    def VehicleExceedsMaxCruiseSpeed(self):
        if ((BBoolean(
                self.SpeedAboveMax.equal(BBoolean(False)).booleanValue()
                and BBoolean(
                    BBoolean(
                        self.CruiseActive.equal(
                            BBoolean(False)).booleanValue()
                        or self.VehicleCanKeepSpeed.equal(
                            BBoolean(False)).booleanValue()).booleanValue()
                    or BBoolean(
                        BBoolean(
                            self.ObstacleStatusJustChanged.equal(
                                BBoolean(False)).booleanValue()
                            and self.CCInitialisationInProgress.equal(
                                BBoolean(False)).booleanValue()).booleanValue(
                                ) and self.CruiseSpeedChangeInProgress.equal(
                                    BBoolean(False)).booleanValue()
                    )._not().booleanValue()).booleanValue())).booleanValue()):
            self.SpeedAboveMax = BBoolean(True)
            self.VehicleAtCruiseSpeed = BBoolean(False)

    def VehicleFallsBelowMaxCruiseSpeed(self):
        if ((self.SpeedAboveMax.equal(BBoolean(True))).booleanValue()):
            self.SpeedAboveMax = BBoolean(False)
            if ((BBoolean(
                    self.CruiseActive.equal(BBoolean(True)).booleanValue()
                    and self.CruiseSpeedAtMax.equal(
                        BBoolean(True)).booleanValue())).booleanValue()):
                self.VehicleAtCruiseSpeed = BBoolean(True)

    def ObstacleDistanceBecomesVeryClose(self):
        if ((BBoolean(
                self.ObstacleDistance.equal(ODset.ODclose).booleanValue()
                and self.ObstacleRelativeSpeed.equal(
                    RSset.RSneg).booleanValue())).booleanValue()):
            self.ObstacleDistance = ODset.ODveryclose
            self.ObstacleStatusJustChanged = BBoolean(True)

    def ObstacleDistanceBecomesClose(self):
        if ((BBoolean(
                BBoolean(
                    self.ObstaclePresent.equal(BBoolean(True)).booleanValue()
                    and self.CruiseActive.equal(
                        BBoolean(True)).booleanValue()).booleanValue()
                and BBoolean(
                    BBoolean(
                        self.ObstacleDistance.equal(
                            ODset.ODveryclose).booleanValue()
                        and self.ObstacleRelativeSpeed.equal(
                            RSset.RSpos).booleanValue()).booleanValue()
                    or BBoolean(
                        self.ObstacleDistance.equal(
                            ODset.ODnone).booleanValue()
                        and self.ObstacleRelativeSpeed.equal(
                            RSset.RSneg).booleanValue()).booleanValue()).
                booleanValue())).booleanValue()):
            self.ObstacleDistance = ODset.ODclose
            self.ObstacleStatusJustChanged = BBoolean(True)
            if ((self.ObstacleRelativeSpeed.equal(
                    RSset.RSpos)).booleanValue()):
                self.VehicleTryKeepTimeGap = BBoolean(False)

    def ObstacleDistanceBecomesBig(self):
        if ((BBoolean(
                self.ObstacleDistance.equal(ODset.ODclose).booleanValue()
                and self.ObstacleRelativeSpeed.equal(
                    RSset.RSpos).booleanValue())).booleanValue()):
            self.ObstacleStatusJustChanged = BBoolean(True)
            self.ObstacleDistance = ODset.ODnone
            self.VehicleTryKeepTimeGap = BBoolean(False)

    def ObstacleStartsTravelFaster(self):
        if ((BBoolean(
                self.ObstaclePresent.equal(BBoolean(True)).booleanValue()
                and self.ObstacleRelativeSpeed.equal(
                    RSset.RSequal).booleanValue())).booleanValue()):
            self.ObstacleRelativeSpeed = RSset.RSpos
            if ((self.CruiseActive.equal(BBoolean(True))).booleanValue()):
                self.ObstacleStatusJustChanged = BBoolean(True)

            if ((self.ObstacleDistance.unequal(
                    ODset.ODveryclose)).booleanValue()):
                self.VehicleTryKeepTimeGap = BBoolean(False)

    def ObstacleStopsTravelFaster(self):
        if ((self.ObstacleRelativeSpeed.equal(RSset.RSpos)).booleanValue()):
            self.ObstacleRelativeSpeed = RSset.RSequal
            if ((self.CruiseActive.equal(BBoolean(True))).booleanValue()):
                self.ObstacleStatusJustChanged = BBoolean(True)

    def ObstacleStartsTravelSlower(self):
        if ((self.ObstacleRelativeSpeed.equal(RSset.RSequal)).booleanValue()):
            self.ObstacleRelativeSpeed = RSset.RSneg
            if ((self.CruiseActive.equal(BBoolean(True))).booleanValue()):
                self.ObstacleStatusJustChanged = BBoolean(True)

    def ObstacleStopsTravelSlower(self):
        if ((self.ObstacleRelativeSpeed.equal(RSset.RSneg)).booleanValue()):
            self.ObstacleRelativeSpeed = RSset.RSequal
            if ((self.CruiseActive.equal(BBoolean(True))).booleanValue()):
                self.ObstacleStatusJustChanged = BBoolean(True)

    def ObstacleAppearsWhenCruiseActive(self, ors, od):
        if ((BBoolean(
                self.ObstaclePresent.equal(BBoolean(False)).booleanValue()
                and self.CruiseActive.equal(
                    BBoolean(True)).booleanValue())).booleanValue()):
            self.ObstaclePresent = BBoolean(True)
            self.ObstacleStatusJustChanged = BBoolean(True)
            self.ObstacleRelativeSpeed = ors
            self.ObstacleDistance = od

    def ObstacleAppearsWhenCruiseInactive(self, ors):
        if ((BBoolean(
                self.ObstaclePresent.equal(BBoolean(False)).booleanValue()
                and self.CruiseActive.equal(
                    BBoolean(False)).booleanValue())).booleanValue()):
            self.ObstaclePresent = BBoolean(True)
            self.ObstacleRelativeSpeed = ors
            self.ObstacleDistance = ODset.ODnone

    def ObstacleDisappears(self):
        if ((self.ObstaclePresent.equal(BBoolean(True))).booleanValue()):
            self.ObstaclePresent = BBoolean(False)
            self.ObstacleRelativeSpeed = RSset.RSnone
            if ((self.CruiseActive.equal(BBoolean(True))).booleanValue()):
                self.ObstacleStatusJustChanged = BBoolean(True)

            self.ObstacleDistance = ODset.ODnone
            self.VehicleTryKeepTimeGap = BBoolean(False)

    def VehicleManageObstacle(self, vtks, vtktg):
        if ((BBoolean(
                BBoolean(
                    BBoolean(
                        BBoolean(
                            BBoolean(
                                BBoolean(
                                    BBoolean(
                                        BBoolean(
                                            BBoolean(
                                                BBoolean(
                                                    BUtils.BOOL.elementOf(
                                                        vtks).booleanValue()
                                                    and BUtils.BOOL.elementOf(
                                                        vtktg).booleanValue()).
                                                booleanValue() and BBoolean(
                                                    BBoolean(
                                                        BBoolean(
                                                            vtks.equal(
                                                                BBoolean(True)
                                                            ).booleanValue()
                                                            or vtktg.equal(
                                                                BBoolean(True)
                                                            ).booleanValue()).
                                                        booleanValue() or self.
                                                        CCInitialisationInProgress
                                                        .equal(BBoolean(True)).
                                                        booleanValue()).
                                                    booleanValue() or self.
                                                    CruiseSpeedChangeInProgress
                                                    .equal(BBoolean(
                                                        True)).booleanValue()).
                                                booleanValue()).booleanValue()
                                            and BBoolean(
                                                not self.ObstaclePresent.equal(
                                                    BBoolean(False)).
                                                booleanValue() or vtktg.equal(
                                                    BBoolean(False)).
                                                booleanValue()).booleanValue()
                                        ).booleanValue() and BBoolean(
                                            not self.ObstacleDistance.equal(
                                                ODset.ODnone).booleanValue()
                                            or vtks.equal(BBoolean(True)).
                                            booleanValue()).booleanValue()).
                                    booleanValue() and BBoolean(not BBoolean(
                                        BBoolean(
                                            BBoolean(
                                                self.ObstacleDistance.equal(
                                                    ODset.ODclose).
                                                booleanValue()
                                                and self.ObstacleRelativeSpeed.
                                                unequal(RSset.RSpos).
                                                booleanValue()).booleanValue()
                                            and self.CCInitialisationInProgress
                                            .equal(BBoolean(False)).
                                            booleanValue()).booleanValue() and
                                        self.CruiseSpeedChangeInProgress.equal(
                                            BBoolean(False)).booleanValue()
                                    ).booleanValue() or vtktg.equal(
                                        BBoolean(True)).booleanValue()).
                                    booleanValue()).booleanValue()
                                and BBoolean(not BBoolean(
                                    BBoolean(
                                        self.ObstacleDistance.equal(
                                            ODset.ODveryclose).booleanValue()
                                        and self.CCInitialisationInProgress.
                                        equal(BBoolean(False)).booleanValue()).
                                    booleanValue()
                                    and self.CruiseSpeedChangeInProgress.equal(
                                        BBoolean(False)).booleanValue()
                                ).booleanValue() or vtktg.equal(BBoolean(
                                    True)).booleanValue()).booleanValue()).
                            booleanValue() and BBoolean(not BBoolean(
                                BBoolean(
                                    BBoolean(
                                        self.ObstacleRelativeSpeed.equal(
                                            RSset.RSpos).booleanValue()
                                        and self.ObstacleDistance.unequal(
                                            ODset.ODveryclose).booleanValue()).
                                    booleanValue()
                                    and self.CCInitialisationInProgress.equal(
                                        BBoolean(False)).booleanValue()).
                                booleanValue()
                                and self.CruiseSpeedChangeInProgress.equal(
                                    BBoolean(False)).booleanValue()
                            ).booleanValue() or vtks.equal(
                                BBoolean(True)).booleanValue()).booleanValue()
                        ).booleanValue() and BBoolean(not BBoolean(
                            self.ObstacleRelativeSpeed.equal(
                                RSset.RSequal).booleanValue()
                            and self.ObstacleDistance.equal(ODset.ODnone).
                            booleanValue()).booleanValue() or vtktg.equal(
                                BBoolean(False)).booleanValue()).booleanValue(
                                )).booleanValue()
                    and BBoolean(not BBoolean(
                        self.ObstacleRelativeSpeed.equal(RSset.RSneg).
                        booleanValue() and self.ObstacleDistance.equal(
                            ODset.ODnone).booleanValue()).booleanValue()
                                 or vtktg.equal(BBoolean(False)).booleanValue(
                                 )).booleanValue()).booleanValue()
                and BBoolean(not BBoolean(
                    self.ObstacleRelativeSpeed.equal(
                        RSset.RSpos).booleanValue()
                    and self.ObstacleDistance.unequal(
                        ODset.ODveryclose).booleanValue()).booleanValue()
                             or vtktg.equal(BBoolean(False)).booleanValue()).
                booleanValue())).booleanValue()):
            if ((self.ObstacleStatusJustChanged.equal(
                    BBoolean(True))).booleanValue()):
                self.VehicleTryKeepTimeGap = vtktg
                self.VehicleTryKeepSpeed = vtks

    def ObstacleBecomesOld(self):
        if ((BBoolean(
                BBoolean(
                    BBoolean(
                        BBoolean(
                            BBoolean(
                                self.ObstacleStatusJustChanged.equal(
                                    BBoolean(True)).booleanValue()
                                and BBoolean(
                                    BBoolean(
                                        BBoolean(
                                            self.VehicleTryKeepSpeed.equal(
                                                BBoolean(True)).booleanValue()
                                            or self.VehicleTryKeepTimeGap.
                                            equal(BBoolean(True)).booleanValue(
                                            )).booleanValue() or
                                        self.CCInitialisationInProgress.equal(
                                            BBoolean(True)).booleanValue()).
                                    booleanValue()
                                    or self.CruiseSpeedChangeInProgress.equal(
                                        BBoolean(True)).booleanValue()).
                                booleanValue()).booleanValue()
                            and BBoolean(not self.ObstacleDistance.equal(
                                ODset.ODnone).booleanValue()
                                         or self.VehicleTryKeepSpeed.equal(
                                             BBoolean(True)).booleanValue()).
                            booleanValue()).booleanValue()
                        and BBoolean(not BBoolean(
                            BBoolean(
                                BBoolean(
                                    self.ObstacleDistance.equal(
                                        ODset.ODclose).booleanValue() and self.
                                    ObstacleRelativeSpeed.unequal(RSset.RSpos).
                                    booleanValue()).booleanValue()
                                and self.CCInitialisationInProgress.equal(
                                    BBoolean(False)).booleanValue()).
                            booleanValue() and self.CruiseSpeedChangeInProgress
                            .equal(BBoolean(False)).booleanValue()
                        ).booleanValue() or self.VehicleTryKeepTimeGap.equal(
                            BBoolean(True)).booleanValue()).booleanValue()).
                    booleanValue() and BBoolean(not BBoolean(
                        BBoolean(
                            self.ObstacleDistance.equal(
                                ODset.ODveryclose).booleanValue()
                            and self.CCInitialisationInProgress.equal(
                                BBoolean(False)).booleanValue()).booleanValue(
                                ) and self.CruiseSpeedChangeInProgress.equal(
                                    BBoolean(False)).booleanValue()
                    ).booleanValue() or self.VehicleTryKeepTimeGap.equal(
                        BBoolean(True)).booleanValue()).booleanValue()).
                booleanValue() and BBoolean(not BBoolean(
                    BBoolean(
                        BBoolean(
                            self.ObstacleRelativeSpeed.equal(
                                RSset.RSpos).booleanValue() and
                            self.ObstacleDistance.unequal(ODset.ODveryclose).
                            booleanValue()).booleanValue()
                        and self.CCInitialisationInProgress.equal(
                            BBoolean(False)).booleanValue()).booleanValue()
                    and self.CruiseSpeedChangeInProgress.equal(
                        BBoolean(False)).booleanValue()).booleanValue()
                                            or self.VehicleTryKeepSpeed.equal(
                                                BBoolean(True)).booleanValue()
                                            ).booleanValue())).booleanValue()):
            self.ObstacleStatusJustChanged = BBoolean(False)

    def _get_CruiseAllowed(self):
        return self.CruiseAllowed

    def _get_CruiseActive(self):
        return self.CruiseActive

    def _get_VehicleAtCruiseSpeed(self):
        return self.VehicleAtCruiseSpeed

    def _get_VehicleCanKeepSpeed(self):
        return self.VehicleCanKeepSpeed

    def _get_VehicleTryKeepSpeed(self):
        return self.VehicleTryKeepSpeed

    def _get_SpeedAboveMax(self):
        return self.SpeedAboveMax

    def _get_VehicleTryKeepTimeGap(self):
        return self.VehicleTryKeepTimeGap

    def _get_CruiseSpeedAtMax(self):
        return self.CruiseSpeedAtMax

    def _get_ObstaclePresent(self):
        return self.ObstaclePresent

    def _get_ObstacleDistance(self):
        return self.ObstacleDistance

    def _get_ObstacleRelativeSpeed(self):
        return self.ObstacleRelativeSpeed

    def _get_ObstacleStatusJustChanged(self):
        return self.ObstacleStatusJustChanged

    def _get_CCInitialisationInProgress(self):
        return self.CCInitialisationInProgress

    def _get_CruiseSpeedChangeInProgress(self):
        return self.CruiseSpeedChangeInProgress

    def _get_NumberOfSetCruise(self):
        return self.NumberOfSetCruise
 def __init__(self):
     self.active = BSet()
     self._ready = BSet()
     self.waiting = BSet()
class scheduler_deterministic:

    _PID = BSet(PID.process1, PID.process2, PID.process3)

    def __init__(self):
        self.active = BSet()
        self._ready = BSet()
        self.waiting = BSet()

    def new(self, pp):
        if ((BBoolean(
                BBoolean(
                    self._PID.elementOf(pp).booleanValue() and self.active.
                    notElementOf(pp).booleanValue()).booleanValue()
                and self._ready.union(
                    self.waiting).notElementOf(pp).booleanValue())
             ).booleanValue()):
            self.waiting = self.waiting.union(BSet(pp))

    def _del(self, pp):
        if ((self.waiting.elementOf(pp)).booleanValue()):
            self.waiting = self.waiting.difference(BSet(pp))

    def ready(self, rr):
        if ((self.waiting.elementOf(rr)).booleanValue()):
            self.waiting = self.waiting.difference(BSet(rr))
            if self.active.equal(BSet()):
                self.active = BSet(rr)
            else:
                self._ready = self._ready.union(BSet(rr))

    def swap(self, pp):
        if self.active.unequal(BSet()):
            self.waiting = self.waiting.union(self.active)
            if self._ready.equal(BSet()):
                self.active = BSet()
            else:
                self.active = BSet(pp)
                self._ready = self._ready.difference(BSet(pp))

    def _get_active(self):
        return self.active

    def _get__ready(self):
        return self._ready

    def _get_waiting(self):
        return self.waiting
Beispiel #18
0
 def route_formation(self, r):
     self.frm = self.frm.union(BSet(r))
Beispiel #19
0
class Train_1_beebook_deterministic:



    _BLOCKS = BSet(BLOCKS.A, BLOCKS.B, BLOCKS.C, BLOCKS.D, BLOCKS.E, BLOCKS.F, BLOCKS.G, BLOCKS.H, BLOCKS.I, BLOCKS.J, BLOCKS.K, BLOCKS.L, BLOCKS.M, BLOCKS.N)
    _ROUTES = BSet(ROUTES.R1, ROUTES.R2, ROUTES.R3, ROUTES.R4, ROUTES.R5, ROUTES.R6, ROUTES.R7, ROUTES.R8, ROUTES.R9, ROUTES.R10)

    def __init__(self):
        self.fst = BRelation(BTuple(ROUTES.R1, BLOCKS.L), BTuple(ROUTES.R2, BLOCKS.L), BTuple(ROUTES.R3, BLOCKS.L), BTuple(ROUTES.R4, BLOCKS.M), BTuple(ROUTES.R5, BLOCKS.M), BTuple(ROUTES.R6, BLOCKS.C), BTuple(ROUTES.R7, BLOCKS.G), BTuple(ROUTES.R8, BLOCKS.N), BTuple(ROUTES.R9, BLOCKS.G), BTuple(ROUTES.R10, BLOCKS.N))
        self.lst = BRelation(BTuple(ROUTES.R1, BLOCKS.C), BTuple(ROUTES.R2, BLOCKS.G), BTuple(ROUTES.R3, BLOCKS.N), BTuple(ROUTES.R4, BLOCKS.G), BTuple(ROUTES.R5, BLOCKS.N), BTuple(ROUTES.R6, BLOCKS.L), BTuple(ROUTES.R7, BLOCKS.L), BTuple(ROUTES.R8, BLOCKS.L), BTuple(ROUTES.R9, BLOCKS.M), BTuple(ROUTES.R10, BLOCKS.M))
        self.nxt = BRelation(BTuple(ROUTES.R1, BRelation(BTuple(BLOCKS.L, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.C))), BTuple(ROUTES.R2, BRelation(BTuple(BLOCKS.L, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.D), BTuple(BLOCKS.D, BLOCKS.E), BTuple(BLOCKS.E, BLOCKS.F), BTuple(BLOCKS.F, BLOCKS.G))), BTuple(ROUTES.R3, BRelation(BTuple(BLOCKS.L, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.D), BTuple(BLOCKS.D, BLOCKS.K), BTuple(BLOCKS.K, BLOCKS.J), BTuple(BLOCKS.J, BLOCKS.N))), BTuple(ROUTES.R4, BRelation(BTuple(BLOCKS.M, BLOCKS.H), BTuple(BLOCKS.H, BLOCKS.I), BTuple(BLOCKS.I, BLOCKS.K), BTuple(BLOCKS.K, BLOCKS.F), BTuple(BLOCKS.F, BLOCKS.G))), BTuple(ROUTES.R5, BRelation(BTuple(BLOCKS.M, BLOCKS.H), BTuple(BLOCKS.H, BLOCKS.I), BTuple(BLOCKS.I, BLOCKS.J), BTuple(BLOCKS.J, BLOCKS.N))), BTuple(ROUTES.R6, BRelation(BTuple(BLOCKS.C, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.L))), BTuple(ROUTES.R7, BRelation(BTuple(BLOCKS.G, BLOCKS.F), BTuple(BLOCKS.F, BLOCKS.E), BTuple(BLOCKS.E, BLOCKS.D), BTuple(BLOCKS.D, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.L))), BTuple(ROUTES.R8, BRelation(BTuple(BLOCKS.N, BLOCKS.J), BTuple(BLOCKS.J, BLOCKS.K), BTuple(BLOCKS.K, BLOCKS.D), BTuple(BLOCKS.D, BLOCKS.B), BTuple(BLOCKS.B, BLOCKS.A), BTuple(BLOCKS.A, BLOCKS.L))), BTuple(ROUTES.R9, BRelation(BTuple(BLOCKS.G, BLOCKS.F), BTuple(BLOCKS.F, BLOCKS.K), BTuple(BLOCKS.K, BLOCKS.I), BTuple(BLOCKS.I, BLOCKS.H), BTuple(BLOCKS.H, BLOCKS.M))), BTuple(ROUTES.R10, BRelation(BTuple(BLOCKS.N, BLOCKS.J), BTuple(BLOCKS.J, BLOCKS.I), BTuple(BLOCKS.I, BLOCKS.H), BTuple(BLOCKS.H, BLOCKS.M))))
        self._ic_set_0 = BRelation()
        for _ic_b_1 in self._BLOCKS:
            for _ic_r_1 in Train_1_beebook_deterministic._ROUTES:
                if(BBoolean(self.nxt.domain().elementOf(_ic_r_1).booleanValue() and BBoolean(self.nxt.functionCall(_ic_r_1).domain().elementOf(_ic_b_1).booleanValue() or self.nxt.functionCall(_ic_r_1)._range().elementOf(_ic_b_1).booleanValue()).booleanValue())).booleanValue():
                    _ic_set_0 = self._ic_set_0.union(BRelation(BTuple(_ic_b_1, _ic_r_1)))

        self.rtbl = self._ic_set_0
        self.resrt = BSet()
        self.resbl = BSet()
        self.rsrtbl = BRelation()
        self.OCC = BSet()
        self.TRK = BRelation()
        self.frm = BSet()
        self.LBT = BSet()

    def route_reservation(self, r):
        _ld_resrt = self.resrt

        _ld_rsrtbl = self.rsrtbl
        _ld_resbl = self.resbl
        self.resrt = _ld_resrt.union(BSet(r))
        self.rsrtbl = _ld_rsrtbl.union(self.rtbl.rangeRestriction(BSet(r)))
        self.resbl = _ld_resbl.union(self.rtbl.inverse().relationImage(BSet(r)))

    def route_freeing(self, r):
        _ld_resrt = self.resrt

        _ld_frm = self.frm
        self.resrt = _ld_resrt.difference(BSet(r))
        self.frm = _ld_frm.difference(BSet(r))

    def FRONT_MOVE_1(self, r):
        _ld_OCC = self.OCC
        _ld_LBT = self.LBT
        self.OCC = _ld_OCC.union(BSet(self.fst.functionCall(r)))
        self.LBT = _ld_LBT.union(BSet(self.fst.functionCall(r)))

    def FRONT_MOVE_2(self, b):
        self.OCC = self.OCC.union(BSet(self.TRK.functionCall(b)))

    def BACK_MOVE_1(self, b):
        _ld_OCC = self.OCC
        _ld_LBT = self.LBT
        _ld_rsrtbl = self.rsrtbl
        _ld_resbl = self.resbl
        self.OCC = _ld_OCC.difference(BSet(b))
        self.rsrtbl = _ld_rsrtbl.domainSubstraction(BSet(b))
        self.resbl = _ld_resbl.difference(BSet(b))
        self.LBT = _ld_LBT.difference(BSet(b))

    def BACK_MOVE_2(self, b):
        _ld_OCC = self.OCC
        _ld_LBT = self.LBT
        _ld_rsrtbl = self.rsrtbl
        _ld_resbl = self.resbl
        self.OCC = _ld_OCC.difference(BSet(b))
        self.rsrtbl = _ld_rsrtbl.domainSubstraction(BSet(b))
        self.resbl = _ld_resbl.difference(BSet(b))
        self.LBT = _ld_LBT.difference(BSet(b)).union(BSet(self.TRK.functionCall(b)))

    def point_positionning(self, r):
        self.TRK = self.TRK.domainSubstraction(self.nxt.functionCall(r).domain()).rangeSubstraction(self.nxt.functionCall(r)._range()).union(self.nxt.functionCall(r))

    def route_formation(self, r):
        self.frm = self.frm.union(BSet(r))


    def _get_LBT(self):
        return self.LBT

    def _get_TRK(self):
        return self.TRK

    def _get_frm(self):
        return self.frm

    def _get_OCC(self):
        return self.OCC

    def _get_resbl(self):
        return self.resbl

    def _get_resrt(self):
        return self.resrt

    def _get_rsrtbl(self):
        return self.rsrtbl
Beispiel #20
0
 def FRONT_MOVE_1(self, r):
     _ld_OCC = self.OCC
     _ld_LBT = self.LBT
     self.OCC = _ld_OCC.union(BSet(self.fst.functionCall(r)))
     self.LBT = _ld_LBT.union(BSet(self.fst.functionCall(r)))
Beispiel #21
0
    def route_freeing(self, r):
        _ld_resrt = self.resrt

        _ld_frm = self.frm
        self.resrt = _ld_resrt.difference(BSet(r))
        self.frm = _ld_frm.difference(BSet(r))
Beispiel #22
0
 def __init__(self):
     self.numbers = BSet.interval(BInteger(2), BInteger(2000000))
     self.cur = BInteger(2)
     self.limit = BInteger(2000000)
Beispiel #23
0
class CAN_BUS_tlc:

    _T1state = BSet(T1state.T1_EN, T1state.T1_CALC, T1state.T1_SEND,
                    T1state.T1_WAIT)
    _T2mode = BSet(T2mode.T2MODE_SENSE, T2mode.T2MODE_TRANSMIT,
                   T2mode.T2MODE_RELEASE)
    _T2state = BSet(T2state.T2_EN, T2state.T2_RCV, T2state.T2_PROC,
                    T2state.T2_CALC, T2state.T2_SEND, T2state.T2_WAIT,
                    T2state.T2_RELEASE)
    _T3state = BSet(T3state.T3_READY, T3state.T3_WRITE, T3state.T3_RELEASE,
                    T3state.T3_READ, T3state.T3_PROC, T3state.T3_WAIT)

    def __init__(self):
        NATSET = BSet.interval(BInteger(0), BInteger(5))
        self.T2v = BInteger(0)
        self.T3_evaluated = BBoolean(True)
        self.T3_enabled = BBoolean(True)
        self.T1_state = T1state.T1_EN
        self.T2_state = T2state.T2_EN
        self.T3_state = T3state.T3_READY
        self.T1_writevalue = BInteger(0)
        self.T2_writevalue = BInteger(0)
        self.T2_readvalue = BInteger(0)
        self.T2_readpriority = BInteger(0)
        self.T3_readvalue = BInteger(0)
        self.T3_readpriority = BInteger(0)
        self.T1_timer = BInteger(2)
        self.T2_timer = BInteger(3)
        self.BUSwrite = BRelation(BTuple(BInteger(0), BInteger(0)))
        self.BUSvalue = BInteger(0)
        self.BUSpriority = BInteger(0)
        self.T2_mode = T2mode.T2MODE_SENSE

    def T1Evaluate(self):
        self.T1_timer = BInteger(0)
        self.T1_state = T1state.T1_CALC

    def T1Calculate(self, p):
        self.T1_writevalue = p
        self.T1_state = T1state.T1_SEND

    def T1SendResult(self, ppriority, pv):
        _ld_BUSwrite = self.BUSwrite
        self.BUSwrite = _ld_BUSwrite.override(BRelation(BTuple(ppriority, pv)))
        self.T1_state = T1state.T1_WAIT

    def T1Wait(self, pt):
        self.T1_timer = pt
        self.T1_state = T1state.T1_EN

    def T2Evaluate(self):
        self.T2_timer = BInteger(0)
        self.T2_state = T2state.T2_RCV

    def T2ReadBus(self, ppriority, pv):
        self.T2_readvalue = pv
        self.T2_readpriority = ppriority
        self.T2_state = T2state.T2_PROC

    def T2Reset(self):
        _ld_T2v = self.T2v
        self.T2_writevalue = _ld_T2v
        self.T2v = BInteger(0)
        self.T2_state = T2state.T2_SEND
        self.T2_mode = T2mode.T2MODE_TRANSMIT

    def T2Complete(self):
        self.T2_state = T2state.T2_RELEASE
        self.T2_mode = T2mode.T2MODE_SENSE

    def T2ReleaseBus(self, ppriority):
        _ld_BUSwrite = self.BUSwrite
        self.BUSwrite = _ld_BUSwrite.domainSubstraction(BSet(ppriority))
        self.T2_state = T2state.T2_WAIT

    def T2Calculate(self):
        self.T2v = self.T2_readvalue
        self.T2_state = T2state.T2_WAIT

    def T2WriteBus(self, ppriority, pv):
        _ld_BUSwrite = self.BUSwrite
        self.BUSwrite = _ld_BUSwrite.override(BRelation(BTuple(ppriority, pv)))
        self.T2_state = T2state.T2_WAIT

    def T2Wait(self, pt):
        self.T2_timer = pt
        self.T2_state = T2state.T2_EN

    def T3Initiate(self):
        self.T3_state = T3state.T3_WRITE
        self.T3_enabled = BBoolean(False)

    def T3Evaluate(self):
        self.T3_state = T3state.T3_READ

    def T3writebus(self, ppriority, pv):
        _ld_BUSwrite = self.BUSwrite
        self.BUSwrite = _ld_BUSwrite.override(BRelation(BTuple(ppriority, pv)))
        self.T3_state = T3state.T3_WAIT

    def T3Read(self, ppriority, pv):
        self.T3_readvalue = pv
        self.T3_readpriority = ppriority
        self.T3_state = T3state.T3_PROC

    def T3Poll(self):
        self.T3_state = T3state.T3_WAIT

    def T3ReleaseBus(self, ppriority):
        _ld_BUSwrite = self.BUSwrite
        self.BUSwrite = _ld_BUSwrite.domainSubstraction(BSet(ppriority))
        self.T3_state = T3state.T3_RELEASE

    def T3Wait(self):
        self.T3_state = T3state.T3_READY
        self.T3_evaluated = BBoolean(True)

    def T3ReEnableWait(self):
        self.T3_state = T3state.T3_READY
        self.T3_evaluated = BBoolean(True)
        self.T3_enabled = BBoolean(True)

    def Update(self, pmax):
        _ld_T2_timer = self.T2_timer
        _ld_T1_timer = self.T1_timer
        self.BUSvalue = self.BUSwrite.functionCall(pmax)
        self.BUSpriority = pmax
        self.T1_timer = _ld_T1_timer.minus(BInteger(1))
        self.T2_timer = _ld_T2_timer.minus(BInteger(1))
        self.T3_evaluated = BBoolean(False)

    def _get_BUSpriority(self):
        return self.BUSpriority

    def _get_BUSvalue(self):
        return self.BUSvalue

    def _get_BUSwrite(self):
        return self.BUSwrite

    def _get_T1_state(self):
        return self.T1_state

    def _get_T1_timer(self):
        return self.T1_timer

    def _get_T1_writevalue(self):
        return self.T1_writevalue

    def _get_T2_mode(self):
        return self.T2_mode

    def _get_T2_readpriority(self):
        return self.T2_readpriority

    def _get_T2_readvalue(self):
        return self.T2_readvalue

    def _get_T2_state(self):
        return self.T2_state

    def _get_T2_timer(self):
        return self.T2_timer

    def _get_T2_writevalue(self):
        return self.T2_writevalue

    def _get_T2v(self):
        return self.T2v

    def _get_T3_enabled(self):
        return self.T3_enabled

    def _get_T3_evaluated(self):
        return self.T3_evaluated

    def _get_T3_readpriority(self):
        return self.T3_readpriority

    def _get_T3_readvalue(self):
        return self.T3_readvalue

    def _get_T3_state(self):
        return self.T3_state