Xively提取当前数据流值

2024-09-29 22:25:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我可以使用以下代码提取数据流的最新值,但问题是,如果我在Xively仪表板控制台更改值或更新值,则代码无法捕获更改,但仍然显示旧值!

# main program entry point - runs continuously updating our datastream with the
def run():
  print "Starting Xively tutorial script"

  feed = api.feeds.get(FEED_ID)

  datastream = get_datastream(feed)
  datastream.max_value = None
  datastream.min_value = None

  while True:

    if DEBUG:
      print "Updating Xively feed with value: %s" 
      datastream.at = datetime.datetime.utcnow()
      datastream.update() 
      check_point = datastream.current_value
      print "AAGYa: %s" % check_point
      if check_point == '50':
         outPin = file("/sys/class/gpio/gpio44/value", "w")
         outPin.write("1")
      elif check_point == '':
         outPin = file("/sys/class/gpio/gpio44/value", "w")
         outPin.write("1")
      elif check_point == '':
         outPin = file("/sys/class/gpio/gpio44/value", "w")
         outPin.write("1")

run()

以下是get_datastream():

^{pr2}$

Tags: getgpiovaluecheckfeedsysclassfile

热门问题