• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sensor.Sensor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sensor.Sensor的典型用法代码示例。如果您正苦于以下问题:Python Sensor类的具体用法?Python Sensor怎么用?Python Sensor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Sensor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: pystream_single

def pystream_single(args, unk):
    iparser = instalparser.makeInstalParser()
    iparser.instal_input = open(args.input_files[0], "r")
    if args.output_file:
        iparser.instal_output = open(args.output_file, "w")
    iparser.mode = "default"
    idocument = ""
    idocument = idocument + iparser.instal_input.read(-1)
    iparser.instal_parse(idocument)
    if args.domain_file:
        iparser.print_domain(args.domain_file)
    iparser.instal_print_all()
    iparser.instal_input.close()
    if args.output_file:
        iparser.instal_output.close()
    ##### start of multi-shot solving cycle
    if args.output_file and args.fact_file:
        institution = ["externals.lp", "time.lp", args.output_file]
        initial_state = open(args.fact_file, "r").readlines()
        print(initial_state)
        sensor = Sensor(iparser, dummy, initial_state, institution, args)
        # print("initially:")
        # for i in initial_state:
        #     print(i.name(),i.args())
        # print("events from:",args.event_file)
        # with open(args.event_file,'r') as events:
        #     for e in events:
        for event in fileinput.input(unk):
            sensor.solve(event)
开发者ID:cblop,项目名称:tropic,代码行数:29,代码来源:pystream.py


示例2: __init__

 def __init__( self ):
     self.streamID = "Environment"
     # Specify the STREAM-ID as it's specified in your stream definition on the SeaaS platform
     Sensor.__init__(self, self.streamID)
     # Copy/Paste from web portal
     # Call API to get LATEST stream information .....
     self.sensorValue[self.streamID] = {}
     #Override if it exists
     self.hasCCINdefinition = True
     
     self.stream_def["title"] = self.streamID
     self.stream_def["properties"] = {
                                     self.streamID: {
                                       "type": "object",
                                       "properties": {
                                         "temperature": {
                                           "type": "integer"
                                         },
                                         "humidity": {
                                           "type": "integer"
                                         },
                                         "airpressure": {
                                           "type": "integer"
                                         }
                                       },
                                       "additionalProperties": False
                                     }
                                   }
开发者ID:Enabling,项目名称:WiPy-LoPy,代码行数:28,代码来源:enco_sensor.py


示例3: __init__

 def __init__(self, sensorNode):
     """\brief Initializes the class
     \param sensorNode (\c SensorNode) A SensorNode object containing
     information to instantiate the class with
     """
     Sensor.__init__(self, sensorNode)
     self.__ipAddress = sensorNode.getInterfaces("infrastructure")[0].getIP()
开发者ID:benroeder,项目名称:HEN,代码行数:7,代码来源:sensatronics.py


示例4: main

def main(argv):

    config_file = None
   
    try:
        opts, args = getopt.getopt(argv,"hc:",["cfgfile="])
    except getopt.GetoptError:
        print 'repository.py -c <cfgfile>'
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print 'repository.py -c <cfgfile>'
            sys.exit()
        elif opt in ("-c", "--cfgfile"):
            config_file = arg
        
    if config_file is None:
        print 'repository.py -c <cfgfile>'
        sys.exit(2)

    repository = Repository(config_file)
    
    sensor = Sensor('ground', config_file)
    readings = sensor.get_readings()

    if readings is not None:
        s=json.dumps(readings, sort_keys=True, indent=4, separators=(',', ': '))
        print s
        repository.save_readings(readings)
开发者ID:halingo,项目名称:1wire-logger,代码行数:30,代码来源:repository.py


示例5: main

def main():
    global sensor
    sensor = Sensor()
    try:
        sensor.connect()
    except:
        print("Error connecting to sensor")
        raise
        return

    #cv.namedWindow("Threshold", cv.WINDOW_AUTOSIZE);
    cv.namedWindow("Contours", cv.WINDOW_AUTOSIZE);
    nfunc = np.vectorize(normalize)
    images = get_next_image()
    baseline_frame = images[-1]
    baseline = baseline_frame['image']
    width = baseline_frame['cols']
    height = baseline_frame['rows']
    while 1:
        images = get_next_image();
        frame = images[-1]
        pixels = np.array(frame['image'])
        pixels_zeroed = np.subtract(baseline, pixels);
        min = np.amin(pixels_zeroed)
        max = np.amax(pixels_zeroed)
        pixels_normalized = nfunc(pixels_zeroed, min, max)
        large = sp.ndimage.zoom(pixels_normalized, 10, order=1)
        large = large.astype(np.uint8);
        large = cv.medianBlur(large,7)
        #large = cv.GaussianBlur(large,(7,7),0)
        #stuff, blobs = cv.threshold(large,150,255,cv.THRESH_BINARY)
        stuff, blobs = cv.threshold(large,160,255,cv.THRESH_BINARY+cv.THRESH_OTSU)
        contours, hierarchy = cv.findContours(blobs, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
        out = np.zeros((height*10,width*10,3), np.uint8)
        cv.drawContours(out,contours,-1,(255,255,0),3)

        regions_found = len(contours)

        contours = np.vstack(contours).squeeze()
        rect = cv.minAreaRect(contours)
        box = cv.cv.BoxPoints(rect)
        box = np.int0(box)
        cv.drawContours(out,[box],0,(0,255,255),2)

        #cv.imshow("Threshold", blobs);
        cv.imshow("Contours", out)
        cv.waitKey(1)

        x = rect[0][0]
        y = rect[0][1]
        angle = rect[2];

        if(regions_found < 10):
            send(x, y, angle)

        time.sleep(0.4)

    sensor.close()
    print "Done. Everything cleaned up."
开发者ID:G-ram,项目名称:portal,代码行数:59,代码来源:main.py


示例6: __init__

 def __init__(self):
     Sensor.__init__(self)
     self.have_serial = False
     try:
         self.ser = serial.Serial(port=self.PORT, baudrate=115200, timeout=1)
         self.have_serial = True
     except:
         pass
开发者ID:Vitalica,项目名称:bbb_vitalica,代码行数:8,代码来源:pulseox_sensor.py


示例7: __init__

 def __init__(self, dataset, datadir='.'):
     """
     Initialization.
     :param dataset: Filename.
     :param datadir: Directory of the file default '.'
     """
     self.scans, width = self.load_data(datadir, dataset)
     Sensor.__init__(self, width, self.scan_rate_hz, self.viewangle, self.distance_no_detection_mm,
                     self.detectionMargin, self.offsetMillimeters)
开发者ID:RoamingSpirit,项目名称:SLAM,代码行数:9,代码来源:xtion.py


示例8: __init__

    def __init__(self):
        """@todo: to be defined1. """
        Sensor.__init__(self)
        self.have_sensor = False

        try:
            self.i2c = Adafruit_I2C(self.I2C_ADDRESS)
            self.have_sensor = True
        except:
            pass
开发者ID:Vitalica,项目名称:bbb_vitalica,代码行数:10,代码来源:temp_sensor.py


示例9: __init__

    def __init__(self, name, sensor_id, port, baud, time_source, data_handlers):
        '''Save properties for opening serial port later.'''
        Sensor.__init__(self, 'green_seeker', name, sensor_id, time_source, data_handlers)

        self.port = port
        self.baud = baud
        
        self.read_timeout = 2
               
        self.stop_reading = False # If true then sensor will stop reading data.
        self.connection = None
        
        self.max_closing_time = self.read_timeout + 1
开发者ID:Phenomics-KSU,项目名称:pisc,代码行数:13,代码来源:green_seeker.py


示例10: __init__

    def __init__(self, name, sensor_id, time_source, position_source, data_handlers):
        '''Constructor.'''
        Sensor.__init__(self, 'position', name, sensor_id, time_source, data_handlers)
        
        self.position_source = position_source
        
        self.stop_passing = False # If true then sensor will passing data to handlers.

        self.is_open = False # internally flag to keep track of whether or not sensor is open.
        
        self.last_utc_time = 0 # last position timestamp that was passed onto data handlers.

        self.max_closing_time = 3 # seconds
开发者ID:Phenomics-KSU,项目名称:pisc,代码行数:13,代码来源:position_passer.py


示例11: __init__

    def __init__(self):
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connection = socket.socket()

        self.width = 0
        self.scan_rate_hz = 0
        self.viewangle = 0
        self.distance_no_detection_mm = 0
        self.detection_margin = 0
        self.offset_millimeters = 0

        self.initialize()

        Sensor.__init__(self, self.width, self.scan_rate_hz, self.viewangle,
                        self.distance_no_detection_mm, self.detection_margin, self.offset_millimeters)
开发者ID:RoamingSpirit,项目名称:SLAM,代码行数:15,代码来源:networksensor.py


示例12: info

    def info(inData):
        from user import User
        from sensor import Sensor
        from station import Station
        pureData=Auth.select(inData)

        userInfo={}
        sensorInfo={}
        stationInfo={}
        #print(pureData)

        for tmp in pureData['data']:
            t=tmp['sensorId']
            if(not(t in sensorInfo)):
                curSensor=Sensor.select({'id': t})
                sensorInfo[t]=curSensor
            tmp['sensorName']=sensorInfo[t]['data'][0]['name']

            t=sensorInfo[t]['data'][0]['stationId']
            if(not(t in stationInfo)):
                curStation=Station.select({id: t})
                stationInfo[t]=curStation
            tmp['stationName']=stationInfo[t]['data'][0]['name']

            t=tmp['userId']
            if(not(t in userInfo)):
                curUser=User.select({'id':t})
                userInfo[t]=curUser
            tmp['userName']=userInfo[t]['data'][0]['username']


        return pureData
开发者ID:wncbb,项目名称:trainWeb,代码行数:32,代码来源:auth.py


示例13: delete_station2

    def delete_station2(inData):
        '''
        :param inData:
        :return:{
            2:'there is no id in inData',
            3:'there is no such id'
        }
        '''
        ret=0
        if(not inData.has_key('id')):
            ret=2
            return ret

        query=session.query(Station)
        tmpStation=query.filter(Station.id==inData['id']).first()
        if(tmpStation==None):
            ret=3
            return ret
        else:
            from sensor import Sensor
            tmpAllSensor=Sensor.select({'stationId': tmpStation.id})
            for tmpSensor in tmpAllSensor['pureData']:
                tmpSensor.stationId=0
            session.delete(tmpStation)
            session.commit()
            ret=1
            return ret
开发者ID:wncbb,项目名称:trainWeb,代码行数:27,代码来源:station.py


示例14: load_sensors

    def load_sensors(self):
        if "sensors" not in config:
            print("can not find the sensors segment in setting.cfg")
            return

        all_sensors = config["sensors"]
        for sensor_id in all_sensors:
            if sensor_id not in self.__sensors__:
                sensor_object = all_sensors[sensor_id]
                if "kind" in sensor_object:
                    sensor_object_kind = sensor_object["kind"]
                    if sensor_object_kind in self.__models__:
                        new_sensor = SensorLogic.copy_with_info(self.__models__[sensor_object_kind], sensor_id, sensor_object["name"])
                        self.__sensors__[sensor_id] = new_sensor
                    else:
                        new_sensor = Sensor(sensor_object_kind, sensor_id, sensor_object["name"])
                        if sensor_object["type"] is "action":
                            on_action = SAction("on")
                            off_action = SAction("off")
                            new_sensor.add_action(on_action)
                            new_sensor.add_action(off_action)
                        else:
                            value_property = SProperty("value", 0, None, 0)
                            new_sensor.add_property(value_property)
                        self.__sensors__[sensor_id] = new_sensor
                else:
                    print("{0:s} sensor in setting.cfg lost kind property".format(sensor_id))
开发者ID:CiscoDoBrasil,项目名称:deviot-gateway,代码行数:27,代码来源:sensormanager.py


示例15: sample

 def sample(self):
     s = Sensor.sample(self)
     # Exceeded the max value...probably out of range.
     if s > self.maxVal:
         ret = Sensor.UNKNOWN
     else:
         ret = s * self.rangeInMeters / self.maxVal
     
     return ret
开发者ID:gtagency,项目名称:localization-dummy,代码行数:9,代码来源:rangefinder.py


示例16: run_sensor

def run_sensor(player):
    sensor = Sensor()
    last_reading = sensor.get_light_sensor_reading()
    current_reading = sensor.get_light_sensor_reading()

    start_time = datetime.now()
    while True:
        reading = sensor.get_light_sensor_reading()
        print reading, last_reading, current_reading
        last_reading = current_reading
        current_reading = reading
        if current_reading - last_reading > 100:
            player.play()
            start_time = datetime.now()

        if (datetime.now() - start_time).seconds > 30 and player.is_playing():
            player.stop()

        yield From(asyncio.sleep(0.1))
开发者ID:kristjanjonsson,项目名称:elevator-music,代码行数:19,代码来源:app.py


示例17: delStation

 def delStation(inData):
     '''
     :param: inData
     :return: {1:'success', 2:'failed', 3:'permission denied', 4:'param wrong'}
     ''' 
     from user import User
     from sensor import Sensor
     if(('UserId' in inData) and ('StationId' in inData)):
         updateUserLevel = session.query(User.level).filter(User.id == inData['UserId'], User.valid == 1).first()
         if(updateUserLevel == None or int(updateUserLevel[0] != 0)):
             return 3
         else:
             session.query(Station).filter(Station.id == inData['StationId'], Station.valid == 1).update({'valid':0, 'time':datetime.now()})
             delSensorId = session.query(Sensor.id).filter(Sensor.stationId == inData['StationId'], Sensor.valid == 1).all()
             for sensorId in delSensorId:
                 Sensor.delSensor({'UserId':inData['UserId'], 'SensorId':int(sensorId[0])})
             session.commit()
             return 1
     else:
         return 4
开发者ID:wncbb,项目名称:trainWeb,代码行数:20,代码来源:station.py


示例18: algoritmoReducao

 def algoritmoReducao(self, colunas, numTotEpocas, numAmostrasCiclo):
     sensor = Sensor(self.ARQUIVO)
     
     for var in colunas:
         saida = []
         erroAc = []
         medidas = []
         
         variavel = sensor.obterLeitura(var, 0, numTotEpocas-1)
         if(self.remOutlier):
             variavel = Estatistica.removeOutliers(variavel)
         
         numIter = int(ceil(float(numTotEpocas)/numAmostrasCiclo))
         erro = 0
         limSup = limInf = 0
         
         i = 1
         while(i <= numIter):
             limInf = (i-1)*numAmostrasCiclo
             limSup = i*numAmostrasCiclo-1
             if(limSup >= numTotEpocas):
                 limSup = (numTotEpocas%numAmostrasCiclo)+limInf-1
             
             medidas = variavel[limInf:limSup+1]
             
             informacoes = Estatistica.regSimples(range(limInf+1, limSup+2), medidas, True)
             saida = saida.__add__(informacoes[2])
             erro = informacoes[4]
             erroAc.append(erro)
             i += 1 
         
         residuo = Estatistica.erroResidual(variavel, saida);
                     
         DIC = {'variavel': VARIAVEL[var%len(VARIAVEL)], 'media': Estatistica.media(erroAc), 'minimo': Estatistica.minimo(erroAc),
                'maximo': Estatistica.maximo(erroAc), 'eqm': sum(erroAc), 'pkt-gerados': numIter, 'mecanismo': 'Regressao'}
         Log.registraLog(ARQUIVO_SAIDA, FORMAT, DIC)
         
         if(self.plot):
             Estatistica.plotar((range(1, numTotEpocas+1), range(1, numTotEpocas+1)), (variavel, saida), "Filtro Medio", "Epoca", VARIAVEL[var%len(VARIAVEL)], ["Valores Reais", "Valores Preditos"])
         
     return [numIter, saida, variavel, residuo]
开发者ID:Tallisson,项目名称:reducao-dados,代码行数:41,代码来源:reducao.py


示例19: Slice

class Slice(Thread):
    def __init__(self, local=False, interval=INTERVAL):
        Thread.__init__(self)
        self.done = None
        self.interval = interval
        self.local = local
        self.sensor = Sensor()

    def run(self):
        self.done = Event()
        while not self.done.wait(self.interval):
            info = self.sensor.read()
            if info:
                if self.local:
                    print info
                else:
                    self.send(info)
            else:
                print('The sensor could not be read')

    def send(self, info):
        # search for the server service
        service_matches = bt.find_service(uuid=UUID)

        if not service_matches:
            print('The server could not be found')

        first_match = service_matches[0]
        port = first_match['port']
        name = first_match['name']
        host = first_match['host']

        print('Attempting to connect to \'%s\' on %s' % (name, host))

        # Create the client socket
        sock = bt.BluetoothSocket(bt.RFCOMM)
        sock.connect((host, port))
        print('The connection has been accepted by the server')

        sock.send(str(info))
        print('The information has been sent')

        sock.close()
        print('The client socket has been closed')

    def stop(self):
        try:
            self.done.set()
        except AttributeError:
            print('The client cannot be stopped. It is not running')
        else:
            print('The client has been stopped')
开发者ID:felipedau,项目名称:blueberrywsn,代码行数:52,代码来源:slice.py


示例20: Alarm

class Alarm(object):

    def __init__(self):
        self._low_pressure_threshold = 17
        self._high_pressure_threshold = 21
        self._sensor = Sensor()
        self._is_alarm_on = False

    def check(self):
        psi_pressure_value = self._sensor.sample_pressure()
        if psi_pressure_value < self._low_pressure_threshold or self._high_pressure_threshold < psi_pressure_value:
            self._is_alarm_on = True

    @property
    def is_alarm_on(self):
        return self._is_alarm_on
开发者ID:pandelegeorge,项目名称:python-tdd,代码行数:16,代码来源:alarm.py



注:本文中的sensor.Sensor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python msg.CameraInfo类代码示例发布时间:2022-05-27
下一篇:
Python sensor.snapshot函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap