Ejemplo n.º 1
0
    def _range(self, start, end, forced=False, add=0):
        if start is None:
            start = now()
        r = []

        if forced:
            # If this pass considers force-open times, only this matters
            r.append(self._forced_range(start, end))
        else:
            # Apply groups' times
            r.append(self._group_range(start, end))
            r.append(self._group_xrange(start, end))

            # First step finished.
            r = [range_intersection(*r)]
            # Now add any group "allowed" one-shots.
            for g in self.groups.all():
                r.append(g._allowed_range(start, end))
            r = [range_union(*r)]

            # Now add any group "not-allowed" one-shots.
            for g in self.groups.all():
                r.append(g._not_blocked_range(start, end))

            # Also apply my own exclusion times
            r.append(self._not_blocked_range(start, end))

        # Exclude times when this valve is already scheduled
        r.append(self._not_scheduled(start, end))

        # Only consider times when the controller can open the valve and
        # there's enough water for it to run
        r.append(self.controller._range(start, end, add=add))
        r.append(self.feed._range(start, end, self.flow, add=add))
        return range_intersection(*r)
Ejemplo n.º 2
0
	def _range(self,start,end, forced=False, add=0):
		if start is None:
			start = now()
		r = []

		if forced:
			# If this pass considers force-open times, only this matters
			r.append(self._forced_range(start,end))
		else:
			# Apply groups' times 
			r.append(self._group_range(start,end))
			r.append(self._group_xrange(start,end))

			# First step finished.
			r = [range_intersection(*r)]
			# Now add any group "allowed" one-shots.
			for g in self.groups.all():
				r.append(g._allowed_range(start,end))
			r = [range_union(*r)]

			# Now add any group "not-allowed" one-shots.
			for g in self.groups.all():
				r.append(g._not_blocked_range(start,end))

			# Also apply my own exclusion times
			r.append(self._not_blocked_range(start,end))

		# Exclude times when this valve is already scheduled
		r.append(self._not_scheduled(start,end))

		# Only consider times when the controller can open the valve and
		# there's enough water for it to run
		r.append(self.controller._range(start,end,add=add))
		r.append(self.feed._range(start,end,self.flow,add=add))
		return range_intersection(*r)
Ejemplo n.º 3
0
	def _range(self,start,end):
		r = []
		r.append(self._days_range(start,end))
		r.append(self._no_xdays_range(start,end))
		r = range_intersection(*r)
		if self.overrides.count():
			r = range_union(r,self._allowed_range(start,end))
		r = range_intersection(r,self._not_blocked_range(start,end))
		return r
Ejemplo n.º 4
0
	def _group_xrange(self,start,end):
		gx = []
		for g in self.groups.all():
			for gd in g.xdays.all():
				gx.append(gd._range(start,end))
		return range_invert(start,end-start,range_union(*gx))
Ejemplo n.º 5
0
	def _no_xdays_range(self,start,end):
		return range_invert(start,end-start, range_union(*(d._range(start,end) for d in self.xdays.all())))
Ejemplo n.º 6
0
	def _days_range(self,start,end):
		return range_union(*(d._range(start,end) for d in self.days.all()))
Ejemplo n.º 7
0
 def _range(self, start, end):
     return range_union(*(x._range(start, end) for x in self.times.all()))
Ejemplo n.º 8
0
Archivo: day.py Proyecto: M-o-a-T/moat
	def _range(self,start,end):
		return range_union(*(x._range(start,end) for x in self.times.all()))
Ejemplo n.º 9
0
 def _group_xrange(self, start, end):
     gx = []
     for g in self.groups.all():
         for gd in g.xdays.all():
             gx.append(gd._range(start, end))
     return range_invert(start, end - start, range_union(*gx))