|
From: <ni...@us...> - 2010-11-09 12:45:07
|
Revision: 94
http://openautomation.svn.sourceforge.net/openautomation/?rev=94&view=rev
Author: nilss1
Date: 2010-11-09 12:45:00 +0000 (Tue, 09 Nov 2010)
Log Message:
-----------
changed mutex to not lock on reading
Modified Paths:
--------------
PyWireGate/trunk/owfs_connector/OWFS_Connector.py
Modified: PyWireGate/trunk/owfs_connector/OWFS_Connector.py
===================================================================
--- PyWireGate/trunk/owfs_connector/OWFS_Connector.py 2010-11-09 09:48:10 UTC (rev 93)
+++ PyWireGate/trunk/owfs_connector/OWFS_Connector.py 2010-11-09 12:45:00 UTC (rev 94)
@@ -204,9 +204,10 @@
self.debug("Reading from path %s" % owfspath)
try:
## read uncached and put into local-list
+ data = self.owfs.read(owfspath)
try:
self.mutex.acquire()
- self.busmaster[busname]['sensors'][sensor][get] = self.owfs.read(owfspath)
+ self.busmaster[busname]['sensors'][sensor][get] = data
finally:
self.mutex.release()
except:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ni...@us...> - 2010-11-15 23:09:27
|
Revision: 134
http://openautomation.svn.sourceforge.net/openautomation/?rev=134&view=rev
Author: nilss1
Date: 2010-11-15 23:09:17 +0000 (Mon, 15 Nov 2010)
Log Message:
-----------
if a present interface is defined, the sensor is put to all busmaster queues until found
Modified Paths:
--------------
PyWireGate/trunk/owfs_connector/OWFS_Connector.py
Modified: PyWireGate/trunk/owfs_connector/OWFS_Connector.py
===================================================================
--- PyWireGate/trunk/owfs_connector/OWFS_Connector.py 2010-11-15 21:59:52 UTC (rev 133)
+++ PyWireGate/trunk/owfs_connector/OWFS_Connector.py 2010-11-15 23:09:17 UTC (rev 134)
@@ -229,6 +229,7 @@
'type':sensortype,
'cycle':cycle,
'nextrun':0,
+ 'present': True,
'interfaces': self.supportedsensors[sensortype]['interfaces']
}
finally:
@@ -251,18 +252,21 @@
def _read(self,busname,sensor):
- for get in self.sensors[sensor]['interfaces'].keys():
+ for iface in self.sensors[sensor]['interfaces'].keys():
+ if not self.sensors[sensor]['present'] and iface <> "present":
+ ## if not present check only for present
+ continue
## make an id for the sensor (OW:28.043242a32_temperature
- id = "%s:%s_%s" % (self.instanceName,sensor,get)
+ id = "%s:%s_%s" % (self.instanceName,sensor,iface)
## get the Datastore Object and look for config
obj = self.WG.DATASTORE.get(id)
sensortype = self.sensors[sensor]['type']
## recheck config
- self.checkConfigDefaults(obj,self.supportedsensors[sensortype]['interfaces'][get])
+ self.checkConfigDefaults(obj,self.supportedsensors[sensortype]['interfaces'][iface])
- owfspath = "/uncached/%s/%s%s" % (sensor,get,obj.config.get('resolution',''))
+ owfspath = "/uncached/%s/%s%s" % (sensor,iface,obj.config.get('resolution',''))
self.debug("Reading from path %s" % owfspath)
data = None
@@ -277,6 +281,9 @@
if data:
self.debug("%s: %r" % (id,data))
self.WG.DATASTORE.update(id,data)
+ if iface == "present" and str(data) <> "1":
+ self.sensors[sensor]['present'] = False
+
self._addQueue(busname,sensor)
def _addQueue(self,busname,sensor):
@@ -284,7 +291,12 @@
self.debug("ADDED %s on %s with %s (%d)s" % (sensor,busname, time.asctime(time.localtime(cycletime)),self.sensors[sensor]['cycle']))
## FIXME: not present iButtons should be added to all Busmaster Queues
#if self.sensors[sensor]['']
- self.busmaster[busname]['readQueue'].put((cycletime,sensor))
+ if self.sensors[sensor]['present']:
+ self.busmaster[busname]['readQueue'].put((cycletime,sensor))
+ else:
+ for busmaster in self.busmaster.keys():
+ ## add to all busmaster queues
+ self.busmaster[busmaster]['readQueue'].put((cycletime,sensor))
def _readThread(self,busname):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ni...@us...> - 2010-11-18 14:07:48
|
Revision: 136
http://openautomation.svn.sourceforge.net/openautomation/?rev=136&view=rev
Author: nilss1
Date: 2010-11-18 14:07:41 +0000 (Thu, 18 Nov 2010)
Log Message:
-----------
send busmaster id to ibutton DSobject * Fixed a bug which lets the Thread stop
Modified Paths:
--------------
PyWireGate/trunk/owfs_connector/OWFS_Connector.py
Modified: PyWireGate/trunk/owfs_connector/OWFS_Connector.py
===================================================================
--- PyWireGate/trunk/owfs_connector/OWFS_Connector.py 2010-11-17 12:07:57 UTC (rev 135)
+++ PyWireGate/trunk/owfs_connector/OWFS_Connector.py 2010-11-18 14:07:41 UTC (rev 136)
@@ -89,7 +89,7 @@
try:
cfg,interface,config = key.split("_",2)
self.supportedsensors[sensor]['interfaces'][interface]['config'][config] = sensorconfig[sensor][key]
- print self.supportedsensors[sensor]['interfaces'][interface]
+ self.debug("Interface %s-%s config: %r" % (sensor,interface,self.supportedsensors[sensor]['interfaces'][interface]['config']))
except KeyError:
pass
@@ -175,7 +175,6 @@
finally:
self.mutex.release()
self.findsensors(bus)
- self.checkBusCycleTime(bus)
except:
## ignore all OWFS Errors
pass
@@ -207,36 +206,38 @@
except:
## nothing found
pass
-
+ if sensor[:2] == "81":
+ ## this must be the Busmaster .. threre should only be one
+ self.busmaster[path]['busmaster'] = sensor
+
if sensortype not in self.supportedsensors:
self.debug("unsupported Type: %r" % sensortype)
- continue
-
+ continue
+
if 'interfaces' not in self.supportedsensors[sensortype]:
self.debug("Sensor Type: %r has no supported Interfaces" % sensortype)
continue
- sensorlist = "sensors"
cycle = 600
if 'cycle' in self.supportedsensors[sensortype]:
cycle = self.supportedsensors[sensortype]['cycle']
try:
self.mutex.acquire()
- print "Sensortype: %s config: %r" % (sensortype,self.supportedsensors[sensortype]['interfaces'])
+ self.debug("Sensortype: %s config: %r" % (sensortype,self.supportedsensors[sensortype]['interfaces']))
self.sensors[sensor] = {
'type':sensortype,
'cycle':cycle,
'nextrun':0,
- 'present': True,
+ 'present': self.busmaster[path].get('busmaster',True),
'interfaces': self.supportedsensors[sensortype]['interfaces']
}
finally:
self.mutex.release()
self._addQueue(path,sensor)
-
+
def read(self):
for busname in self.busmaster.keys():
if not self.busmaster[busname]['readQueue'].empty():
@@ -278,11 +279,15 @@
#self.WG.errorlog("Reading from path %s failed" % owfspath)
self.log("Reading from path %s failed" % owfspath)
+ if iface == "present":
+ if str(data) <> "1":
+ self.sensors[sensor]['present'] = False
+ else:
+ data = self.busmaster[busname].get('busmaster',True)
+
if data:
self.debug("%s: %r" % (id,data))
self.WG.DATASTORE.update(id,data)
- if iface == "present" and str(data) <> "1":
- self.sensors[sensor]['present'] = False
self._addQueue(busname,sensor)
@@ -294,6 +299,8 @@
if self.sensors[sensor]['present']:
self.busmaster[busname]['readQueue'].put((cycletime,sensor))
else:
+ if 'present' not in self.sensors[sensor]['interfaces']:
+ return
for busmaster in self.busmaster.keys():
## add to all busmaster queues
self.busmaster[busmaster]['readQueue'].put((cycletime,sensor))
@@ -306,6 +313,7 @@
if not self.isrunning:
break
time.sleep(.1)
+ self.debug("Queue for bus %s : %r" % (busname, self.busmaster[busname]['readQueue']))
rtime, sensor = self.busmaster[busname]['readQueue'].get()
self._read(busname,sensor)
finally:
@@ -325,7 +333,7 @@
# Check whether the queue is empty
def _empty(self):
return not self.queue
-
+
# Check whether the queue is full
def _full(self):
return self.maxsize > 0 and len(self.queue) == self.maxsize
@@ -348,4 +356,7 @@
next = next[0]
else:
next = 0
- return (next <= time.time())
\ No newline at end of file
+ return (next <= time.time())
+
+ def __repr__(self):
+ return repr(self.queue)
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|