當前位置: 首頁>>代碼示例>>Python>>正文


Python ATT_IOT類代碼示例

本文整理匯總了Python中ATT_IOT的典型用法代碼示例。如果您正苦於以下問題:Python ATT_IOT類的具體用法?Python ATT_IOT怎麽用?Python ATT_IOT使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ATT_IOT類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: assetID

import ATT_IOT as IOT 							   #provide cloud support
from time import sleep                             #pause the app

#set up the SmartLiving IoT platform
IOT.DeviceId = ""
IOT.ClientId = ""
IOT.ClientKey = ""

lightSensor = 0                                  #the PIN number of the lichtsensor, also used to construct a Unique assetID (DeviceID+nr)

#set up the pins
grovepi.pinMode(lightSensor,"INPUT")

#callback: handles values sent from the cloudapp to the device

#make certain that the device & it's features are defined in the cloudapp
IOT.connect()
IOT.addAsset(lightSensor, "lightSensor", "Light Sensor", False, "integer")
IOT.subscribe()              							#starts the bi-directional communication

#main loop: run as long as the device is turned on
while True:
    try:
        lightValue =  grovepi.analogRead(lightSensor)
        print( "LightSensor = " + str(lightValue))
        IOT.send(lightValue, lightSensor)
        sleep(5)

    except IOError:
        print ""
開發者ID:miodragArsic,項目名稱:first-app,代碼行數:30,代碼來源:lightsensor.py

示例2: ping

def ping():
    """
    Send a ping to the server
    """
    global _nextPingAt
    _nextPingAt = datetime.datetime.now() + datetime.timedelta(0, PingFrequency)
    IOT.sendCommandTo(_pingCounter, IOT.DeviceId, WatchDogAssetId)
開發者ID:allthingstalk,項目名稱:raspberrypi-python-client,代碼行數:7,代碼來源:nw_watchdog.py

示例3: on_message

def on_message(id, value):
    global nextVal
    if id.endswith(str(Out1Id)) == True:			
        print("value received: " + value)		  # the value that we receive from the cloud is a string
        IOT.send(value, Out1Id)                #provide feedback to the cloud that the operation was successful, the value is still a string, so we can simply send it back to the cloud.
        nextVal = int(value)					# convert the received data, which is a string, into an integer
    else:
        print("unknown actuator: " + id)
開發者ID:miodragArsic,項目名稱:first-app,代碼行數:8,代碼來源:int_actuator.py

示例4: on_message

def on_message(id, value):
    if id.endswith(str(Led)) == True:
        value = value.lower()                           #make certain that the value is in lower case, for 'True' vs 'true'
        if value == "true":
            grovepi.digitalWrite(Led, 1)
            IOT.send("true", Led)                #provide feedback to the cloud that the operation was succesful
        elif value == "false":
            grovepi.digitalWrite(Led, 0)
            IOT.send("false", Led)               #provide feedback to the cloud that the operation was succesful
        else:
            print("unknown value: " + value)
開發者ID:miodragArsic,項目名稱:first-app,代碼行數:11,代碼來源:shopWindow.py

示例5: TurnWaterOn

def TurnWaterOn():
    global WaterRelaisState
    """Turn the water on"""
    try:
        GPIO.output(WaterRelaisPin, False)  # pin takes reversed value.
        WaterRelaisState = True
        if (
            IsConnected
        ):  # no need to try and send the state if not yet connected, will be updated when connection is successfull
            IOT.send("true", WaterRelaisPin)
    except:
        logging.exception("failed to turn water on")
開發者ID:ATT-JBO,項目名稱:GrowMachine,代碼行數:12,代碼來源:GrowMachine.py

示例6: SwitchLightsOff

def SwitchLightsOff():
    """Switch the lights off"""
    global LightRelaisState
    try:
        LightRelaisState = False
        GPIO.output(LightsRelaisPin, True)  # pin is reversed value
        if (
            IsConnected
        ):  # no need to try and send the state if not yet connected, will be updated when connection is successfull
            IOT.send("false", LightsRelaisPin)
    except:
        logging.exception("failed to switch lights off")
開發者ID:ATT-JBO,項目名稱:GrowMachine,代碼行數:12,代碼來源:GrowMachine.py

示例7: setBacklight

def setBacklight(value):
    '''turn on/off the backlight
       value: string ('true' or 'false')
       returns: true when input was succesfully processed, otherwise false
    '''
    if value == "true":
        GPIO.output(LISIPAROIPin, GPIO.HIGH)
    elif value == "false":
        GPIO.output(LISIPAROIPin, GPIO.LOW)
    else:
        print("unknown value: " + value)
    IOT.send(value, ToggleLISIPAROIId)                #provide feedback to the cloud that the operation was succesful
開發者ID:ATT-JBO,項目名稱:RPICameraRemote,代碼行數:12,代碼來源:RPICameraRemote.py

示例8: on_message

def on_message(id, value):
    if id.endswith(Out1Id) == True:
        value = value.lower()                        #make certain that the value is in lower case, for 'True' vs 'true'
        if value == "true":
            print("true on " + Out1Name)
            IOT.send("true", Out1Id)                #provide feedback to the cloud that the operation was succesful
        elif value == "false":
            print("false on " + Out1Name)
            IOT.send("false", Out1Id)                #provide feedback to the cloud that the operation was succesful
        else:
            print("unknown value: " + value)
    else:
        print("unknown actuator: " + id)
開發者ID:MichielDeMey,項目名稱:gif_python,代碼行數:13,代碼來源:ATT_Win_Demo.py

示例9: on_message

def on_message(id, value):
    if id.endswith(str(ActuatorPin)) == True:
        value = value.lower()                        #make certain that the value is in lower case, for 'True' vs 'true'
        if value == "true":
            GPIO.output(ActuatorPin, True)
            IOT.send("true", ActuatorPin)                #provide feedback to the cloud that the operation was succesful
        elif value == "false":
            GPIO.output(ActuatorPin, False)
            IOT.send("false", ActuatorPin)                #provide feedback to the cloud that the operation was succesful
        else:
            print("unknown value: " + value)
    else:
        print("unknown actuator: " + id)
開發者ID:miodragArsic,項目名稱:first-app,代碼行數:13,代碼來源:NoShield_Demo.py

示例10: setRecord

def setRecord(value):
    if _isPreview: 
        print("preview not allowed during recording, shutting down preview.")
        setPreview(False)
    if value == "true":
        camera.resolution = (1920, 1080)              #set to max resulotion for record
        camera.start_recording('video' + datetime.date.today().strftime("%d_%b_%Y_%H_%M%_S") + '.h264')
    elif value == "false":
        camera.stop_recording()
        camera.resolution = (640, 480)              #reset resulotion for preview
    else:
        print("unknown value: " + value)
    IOT.send(value, RecordId)                #provide feedback to the cloud that the operation was succesful
開發者ID:ATT-JBO,項目名稱:RPICameraRemote,代碼行數:13,代碼來源:RPICameraRemote.py

示例11: setPreview

def setPreview(value):
    if _isRecording:
        print("recording not allowed during preview, shutting down recording.")
        setRecord(False)
    if value == "true":
        _isPreview = True
        streamer.start_preview()
    elif value == "false":
        _isPreview = False
        streamer.stop_preview()
    else:
        print("unknown value: " + value)
    IOT.send(value, PreviewId)                #provide feedback to the cloud that the operation was succesful
開發者ID:ATT-JBO,項目名稱:RPICameraRemote,代碼行數:13,代碼來源:RPICameraRemote.py

示例12: TurnWaterOff

def TurnWaterOff():
    """Turn the water off"""
    global WaterRelaisState
    try:
        if WaterRelaisState == True:
            GPIO.output(WaterRelaisPin, True)  # pin takes reversed value
            WaterRelaisState = False
            if (
                IsConnected
            ):  # no need to try and send the state if not yet connected, will be updated when connection is successfull
                IOT.send("false", WaterRelaisPin)
    except:
        logging.exception("failed to turn water off")
開發者ID:ATT-JBO,項目名稱:GrowMachine,代碼行數:13,代碼來源:GrowMachine.py

示例13: setup

def setup(mylist):
    R=int(mylist[1])
    A=int(mylist[2])
    E=int(mylist[3])
    IOT.connect()
    
    for x in range(0, R):
        dtype = "RaspberryPi" + str(x)
        print("complete device name: "+dtype)
        devlist=IOT.createDevice(dtype, "lightSensor", True)
        with open('devicess.txt', 'a') as file_:
            file_.write(devlist[1] + " "+devlist [0] + '\n')

    for x in range(0, A):
        dtype = "Arduino" +str(x)
        devlist=IOT.createDevice(dtype, "lightSensor", True)
        with open('devicess.txt', 'a') as file_:
            file_.write(devlist[1] + " "+devlist [0] + '\n')

    for x in range(0, E):
        dtype = "IntelDevice"+str(x)
        devlist=IOT.createDevice(dtype, "lightSensor", True)
        with open('devicess.txt', 'a') as file_:
            file_.write(devlist[1] + " "+devlist [0] + '\n')
        IOT.deleteDevice()
開發者ID:samrudh,項目名稱:finalRound_teamOops_IndiaHacks,代碼行數:25,代碼來源:create_d_test.py

示例14: on_message

def on_message(id, value):
    if id.endswith(str(ToggleLISIPAROIId)) == True:
        value = value.lower()                        #make certain that the value is in lower case, for 'True' vs 'true'
        setBacklight(value)
    elif id.endswith(str(PreviewId)) == True:
        value = value.lower()                        #make certain that the value is in lower case, for 'True' vs 'true'
        setPreview(value)
    elif id.endswith(str(RecordId)) == True:
        value = value.lower()                        #make certain that the value is in lower case, for 'True' vs 'true'
        setRecord(value)
    elif id.endswith(str(StreamServerId)) == True:
        streamer.streamServerIp = value
        IOT.send(value, StreamServerId)                #provide feedback to the cloud that the operation was succesful
    elif id.endswith(str(PictureId)) == True:
        if value.lower() == "true":
            takePicture()
    else:
        print("unknown actuator: " + id)
開發者ID:ATT-JBO,項目名稱:RPICameraRemote,代碼行數:18,代碼來源:RPICameraRemote.py

示例15: setConfigSeason

def setConfigSeason(value):
    try:
        global scheduler
        IOT.send(
            value, ConfigSeasonId
        )  # first return value, in case something went wrong, the config is first stored, so upon restart, the correct config is retrieved.
        configs = ConfigParser()  # save the configuration
        configs.set("general", "season", value)
        with open(ConfigFile, "w") as f:
            configs.write(f)
        if scheduler:
            scheduler.shutdown(
                wait=False
            )  # stop any pending jobs so we can recreate them with the new config later on.
            scheduler = None
        SetClock(value.lower())
        StartScheduler()
    except:
        logging.exception("failed to store new season config")
開發者ID:ATT-JBO,項目名稱:GrowMachine,代碼行數:19,代碼來源:GrowMachine.py


注:本文中的ATT_IOT類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。