Esempio n. 1
0
def checkstopcondition(element):
	#print "Evaluating End of Blocking period ++++++++++++"
	actionmodeafterfirst=interruptdbmod.searchdata("element",element,"actionmode_afterfirst")
	#print "actionafter " , actionmodeafterfirst
	sensor=interruptdbmod.searchdata("element",element,"sensor")


	
	if actionmodeafterfirst=="Extend blocking state" or actionmodeafterfirst=="Extend and Follow-up": # extend the pre-emption blocking period
		seonsormode=interruptdbmod.searchdata("element",element,"sensor_mode")
		#print "SENSORMODE" , seonsormode
		recordkey=hardwaremod.HW_INFO_NAME
		recordvalue=sensor	
		keytosearch=hardwaremod.HW_CTRL_PIN
		PIN=hardwaremod.searchdata(recordkey,recordvalue,keytosearch)
		reading=hardwaremod.readinputpin(PIN)		

		if seonsormode=="First Edge + Level":	
			keytosearch=hardwaremod.HW_CTRL_LOGIC
			logic=hardwaremod.searchdata(recordkey,recordvalue,keytosearch)			
			# pin high according to the set logic
			#print "logic:", logic , " reading:"  ,reading
			if (logic=="pos" and reading=="1")or(logic=="neg" and reading=="0"):
				return False

		elif seonsormode=="Second Edge + Level (inv)":
			keytosearch=hardwaremod.HW_CTRL_LOGIC
			logic=hardwaremod.searchdata(recordkey,recordvalue,keytosearch)			
			#pin LOW according to the set logic
			#print "logic:", logic , " reading:"  ,reading
			if (logic=="pos" and reading=="0")or(logic=="neg" and reading=="1"):
				return False


	return True		
def checkstopcondition(element):
    print "Evaluating End of Blocking period ++++++++++++"
    actionmodeafterfirst = interruptdbmod.searchdata("element", element,
                                                     "actionmode_afterfirst")
    print actionmodeafterfirst
    if actionmodeafterfirst == "Extend blocking state" or actionmodeafterfirst == "Extend and Follo-up":  # extend only the pre-emption blocking period, no action
        seonsormode = interruptdbmod.searchdata("element", element,
                                                "sensor_mode")
        print seonsormode
        if seonsormode == "Edge + Level":
            sensor = interruptdbmod.searchdata("element", element, "sensor")
            recordkey = hardwaremod.HW_INFO_NAME
            recordvalue = sensor
            keytosearch = hardwaremod.HW_CTRL_PIN
            PIN = hardwaremod.searchdata(recordkey, recordvalue, keytosearch)
            reading = hardwaremod.readinputpin(PIN)
            keytosearch = hardwaremod.HW_CTRL_LOGIC
            logic = hardwaremod.searchdata(recordkey, recordvalue, keytosearch)
            # pin high according to the set logic
            print "logic:", logic, " reading:", reading
            if logic == "pos" and reading == "1":
                return False
            if logic == "neg" and reading == "0":
                return False

    return True
Esempio n. 3
0
def eventcallback(PIN):
    #t.sleep(0.005)
    reading = hardwaremod.readinputpin(PIN)
    refsensor = statusdataDBmod.read_status_data(PIN_attributes, PIN,
                                                 "refsensor")
    logic = statusdataDBmod.read_status_data(PIN_attributes, PIN, "logic")
    #print "reference sensor:" , refsensor, "logic ", logic
    #print PIN_attributes

    # first Edge detection, can have two impleemntations depend on the "logic" setting
    # in case logic=pos we have pull-down resistor, so the normal state is LOW, the first edge will be from LOW to HIGH
    # in case logic<>pos we have pull-up resistor, so the normal state is High, the first edge will be from HIGH to LOW
    if refsensor != "":
        #["First Edge" , "First Edge + Level", "Second Edge" , "Second Edge + Level (inv)", "both Edges"]

        #detecting first edge
        if logic == "pos":
            if reading == "1":
                #print "*************************  First edge detected on PIN:", PIN
                mode = "First Edge"
            elif reading == "0":
                #print "*************************  Second edge detected on PIN:", PIN
                mode = "Second Edge"
        else:
            if reading == "0":
                #print "*************************  First edge detected on PIN:", PIN
                mode = "First Edge"
            elif reading == "1":
                #print "*************************  Second edge detected on PIN:", PIN
                mode = "Second Edge"

        interruptcheck(refsensor, mode)
def eventcallback(PIN):
    t.sleep(0.05)
    reading = hardwaremod.readinputpin(PIN)
    recordkey = hardwaremod.HW_CTRL_PIN
    recordvalue = str(PIN)
    keytosearch = hardwaremod.HW_INFO_NAME
    refsensor = hardwaremod.searchdata(recordkey, recordvalue, keytosearch)
    print "reference sensor:", refsensor
    if reading == "1":
        print "*************************  Rising edge detected on PIN:", PIN
        if refsensor != "":
            interruptcheck(refsensor)
    else:
        print "Falling edge detected on PIN", PIN
    if refsensor != "":
        x = threading.Thread(target=savedata, args=(refsensor, reading))
        x.start()
Esempio n. 5
0
def eventcallback(PIN):
    bouncetimeSec = statusdataDBmod.read_status_data(PIN_attributes, PIN,
                                                     "bouncetimeSec")
    t.sleep(bouncetimeSec)
    reading = hardwaremod.readinputpin(PIN)
    refsensor = statusdataDBmod.read_status_data(PIN_attributes, PIN,
                                                 "refsensor")
    logic = statusdataDBmod.read_status_data(PIN_attributes, PIN, "logic")
    #print "reference sensor:" , refsensor, "logic ", logic
    #print PIN_attributes

    # first Edge detection, can have two impleemntations depend on the "logic" setting
    # in case logic=pos we have pull-down resistor, so the normal state is LOW, the first edge will be from LOW to HIGH
    # in case logic<>pos we have pull-up resistor, so the normal state is High, the first edge will be from HIGH to LOW
    if refsensor != "":
        #["First Edge" , "First Edge + Level", "Second Edge" , "Second Edge + Level (inv)", "both Edges"]

        #print "Logic " , logic , " reading ", reading , " bouncetimeSec " , bouncetimeSec
        #detecting first edge
        if logic == "pos":
            if reading == "1":
                #print "*************************  First edge detected on PIN:", PIN
                mode = "First Edge"
            elif reading == "0":
                #print "*************************  Second edge detected on PIN:", PIN
                mode = "Second Edge"
        else:
            if reading == "0":
                #print "*************************  First edge detected on PIN:", PIN
                mode = "First Edge"
            elif reading == "1":
                #print "*************************  Second edge detected on PIN:", PIN
                mode = "Second Edge"

        #print "interrupt --------------------> ", mode

        interruptcheck(refsensor, mode, PIN)

    # update status variables for the frequency sensor ----
    sensorinterruptcount = statusdataDBmod.read_status_data(
        SENSOR_data, PIN, "InterruptCount")
    sensorinterruptcount = sensorinterruptcount + 1
    statusdataDBmod.write_status_data(SENSOR_data, PIN, "InterruptCount",
                                      sensorinterruptcount)