当前位置: 首页>>代码示例>>Python>>正文


Python sensor.Sensor类代码示例

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


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


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