Пример #1
0
 def __add__(self, e):
     Errors.checkEvent(e, "event addition")
     #       print("Event merge: " + str(self) + " " + str(e))
     if self.value is None:
         return e
     else:
         return self
Пример #2
0
    def _update(self):
        if self._alive:
            #            print("Object: " + str(self) + " signals: " + str(self._signals))
            for k, v in self._signals.items():
                #                print("Objects: " + str(self) + " is updating: " + k)
                v.now()
            thunks = []

            #Evaluate one time reactions:
            for c in self._1Reactions:
                #                print("Object: " + str(self) + " is updating: " + str(c[0]))
                temp = c[0].now()
                Errors.checkEvent(temp, "One time reaction in " + self._name)
                if temp.occurs():
                    #print("    " + str(temp) + " is being added to thunks")
                    thunks.append(Reaction(c[1], self, temp.value))
                    self._1Reactions.remove(c)
                    break

            if (len(thunks) >= 2):
                print("Multiple one time reactions in a heartbeat in object " +
                      self._name)

            #Evaluate recurring reactions
            # print("Number of reactions in " + self._name + " " + str(len(self._gReactions)))
            for d in self._gReactions:
                temp = d[0].now()
                Errors.checkEvent(temp, "recurring reaction in " + self._name)
                #                print("Object: " + str(self) + " is updating: " + str(d[0]))
                if temp.occurs():
                    #print("    " + repr(temp) + " is being added to thunks")
                    #print("Thunks" + str(thunks) + " " + str(d))
                    thunks.append(Reaction(d[1], self, temp.value))

            #push to the actuall object
            self._updater(self)
            return thunks
Пример #3
0
    def _update(self):
        if self._alive:
#            print("Object: " + str(self) + " signals: " + str(self._signals))
            for k, v in self._signals.items():
#                print("Objects: " + str(self) + " is updating: " + k)
                v.now()
            thunks = []

            #Evaluate one time reactions:
            for c in self._1Reactions:
#                print("Object: " + str(self) + " is updating: " + str(c[0]))
                temp = c[0].now()
                Errors.checkEvent(temp, "One time reaction in " + self._name)
                if temp.occurs():
                    #print("    " + str(temp) + " is being added to thunks")
                    thunks.append(Reaction(c[1], self, temp.value))
                    self._1Reactions.remove(c)
                    break

            if (len(thunks) >= 2):
                print("Multiple one time reactions in a heartbeat in object " + self._name)

            #Evaluate recurring reactions
            # print("Number of reactions in " + self._name + " " + str(len(self._gReactions)))
            for d in self._gReactions:
                temp = d[0].now()
                Errors.checkEvent(temp, "recurring reaction in " + self._name)
#                print("Object: " + str(self) + " is updating: " + str(d[0]))
                if temp.occurs():
                    #print("    " + repr(temp) + " is being added to thunks")
                    #print("Thunks" + str(thunks) + " " + str(d))
                    thunks.append(Reaction(d[1], self, temp.value))

            #push to the actuall object
            self._updater(self)
            return thunks