本文整理汇总了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)
示例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
}
}
示例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()
示例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)
示例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."
示例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
示例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)
示例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
示例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
示例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
示例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)
示例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
示例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
示例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))
示例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