Пример #1
0
    def assign_priorities(cls):
        variables = []
        variables.append(None)
        variables_ids = {}
        var_procs_read = []
        var_procs_read.append(None)
        var_procs_write = []
        var_procs_write.append(None)
        preproc = []
        postproc = []
        postproc_ids = {}

        for hv in cls.__handler_variables:
            #print "hv", hv.id
            vi = 0
            if hv == None:
                continue
            for v in hv.variables:
                #print "v", v, hv.changeable[vi]
                id = variables_ids.get(v)
                #print "id", id
                if id == None:
                    i = len(variables)
                    #print "i", i
                    variables.append(v)
                    variables_ids[v] = i
                    var_procs_read.append([])
                    var_procs_write.append([])
                    if hv.changeable[vi] == False:
                        var_procs_read[i].append(hv.id)
                    else:
                        var_procs_write[i].append(hv.id)
                else:
                    found = False
                    if hv.changeable[vi] == False:
                        for vp in var_procs_read[id]:
                            if vp == hv.id:
                                found = True
                        if found == False:
                            var_procs_read[id].append(hv.id)
                    else:
                        for vp in var_procs_write[id]:
                            if vp == hv.id:
                                found = True
                        if found == False:
                            var_procs_write[id].append(hv.id)

                vi += 1
        """print "----"
		vi = 0
		for v in variables:
			if v != None:
				print "v", v
				for w in var_procs_write[vi]:
					print "w", w
				for r in var_procs_read[vi]:
					print "r", r
			vi += 1
		print "----"""

        vi = 0
        for v in variables:
            if v != None:
                for w in var_procs_write[vi]:
                    for r in var_procs_read[vi]:
                        #print r , "->", w
                        preproc.append(r)
                        postproc_ids[w] = len(postproc)
                        postproc.append(w)
            vi += 1
        return
        l = len(preproc)
        i = 0
        while i < l:
            if postproc_ids.get(preproc[i]):
                print "found"
            else:
                t = preproc[i][:1]
                id = int(preproc[i][1:])
                priority = 1
                #print t + str (id), priority
                if t == 'T':
                    TriggerProvider.set_priority(id, priority)
                elif t == 'C':
                    ConditionProvider.set_priority(id, priority)
                t = postproc[i][:1]
                id = int(postproc[i][1:])
                priority += 1
                #print t + str (id), priority
                if t == 'T':
                    TriggerProvider.set_priority(id, priority)
                elif t == 'C':
                    ConditionProvider.set_priority(id, priority)
            i += 1

        cls.__priorities_assigned = True
Пример #2
0
	def assign_priorities (cls):
		variables = []
		variables.append (None)
		variables_ids = {}
		var_procs_read = []
		var_procs_read.append (None)
		var_procs_write = []
		var_procs_write.append (None)
		preproc = []
		postproc = []
		postproc_ids = {}

		for hv in cls.__handler_variables:
			#print "hv", hv.id
			vi = 0
			if hv == None:
				continue
			for v in hv.variables:
				#print "v", v, hv.changeable[vi]
				id = variables_ids.get (v)
				#print "id", id
				if id == None:
					i = len (variables)
					#print "i", i
					variables.append (v)
					variables_ids[v] = i
					var_procs_read.append ([])
					var_procs_write.append ([])
					if hv.changeable[vi] == False:
						var_procs_read[i].append (hv.id)
					else:
						var_procs_write[i].append (hv.id)
				else:
					found = False
					if hv.changeable[vi] == False:
						for vp in var_procs_read[id]:
							if vp == hv.id:
								found = True
						if found == False:
							var_procs_read[id].append (hv.id)
					else:
						for vp in var_procs_write[id]:
							if vp == hv.id:
								found = True
						if found == False:
							var_procs_write[id].append (hv.id)

				vi += 1

		"""print "----"
		vi = 0
		for v in variables:
			if v != None:
				print "v", v
				for w in var_procs_write[vi]:
					print "w", w
				for r in var_procs_read[vi]:
					print "r", r
			vi += 1
		print "----"""

		vi = 0
		for v in variables:
			if v != None:
				for w in var_procs_write[vi]:
					for r in var_procs_read[vi]:
						#print r , "->", w
						preproc.append (r)
						postproc_ids[w] = len (postproc)
						postproc.append (w)
			vi += 1
		return
		l = len (preproc)
		i = 0
		while i < l:
			if postproc_ids.get (preproc[i]):
				print "found"
			else:
				t = preproc[i][:1]
				id = int (preproc[i][1:])
				priority = 1
				#print t + str (id), priority
				if t == 'T':
					TriggerProvider.set_priority (id, priority)
				elif t == 'C':
					ConditionProvider.set_priority (id, priority)
				t = postproc[i][:1]
				id = int (postproc[i][1:])
				priority += 1
				#print t + str (id), priority
				if t == 'T':
					TriggerProvider.set_priority (id, priority)
				elif t == 'C':
					ConditionProvider.set_priority (id, priority)
			i += 1

		cls.__priorities_assigned = True