Exemplo n.º 1
0
    def _checkInterface(self):
        dispatcher.connect(self._notifyDriverReady, ZWaveWrapper.SIGNAL_DRIVER_READY)
        dispatcher.connect(self._notifySystemReady, ZWaveWrapper.SIGNAL_SYSTEM_READY)
        dispatcher.connect(self._notifyNodeReady, ZWaveWrapper.SIGNAL_NODE_READY)
        dispatcher.connect(self._notifyValueChanged, ZWaveWrapper.SIGNAL_VALUE_CHANGED)
        dispatcher.connect(self._notifyNodeAdded, ZWaveWrapper.SIGNAL_NODE_ADDED)
        self._initDialog(10,60,['Cancel'],'Progress')
        self._addDialogText(2,'Initializing OpenZWave')
        self._log.info('Initializing OpenZWave via wrapper')
        self._wrapper = ZWaveWrapper.getInstance(device=self._config['device'], config=self._config['config'], log=None)
        self._setTimer('initCheck', 3, self._checkIfInitialized)

        while not self._stop.isSet() and not self._wrapper.initialized:
            time.sleep(0.1)
Exemplo n.º 2
0
def initialization(device_path):
	getcontext().prec = 3
	executionTime = Decimal(0)
	maxExecutionTime = Decimal(60) # Maximum initialization time (in seconds)
	sleepTime = Decimal(0.1)

	w = ZWaveWrapper.getInstance(device = device_path, config = '../py-openzwave/openzwave/config/')

	feedback = "OK<br>"

	while bool(w.initialized) != True:
		executionTime = executionTime + Decimal(sleepTime)
		time.sleep(sleepTime)
		if executionTime > maxExecutionTime:
			seq = ['INITIALIZATION FAILED | Execution time: ', executionTime, ' seconds']
			feedback = ''.join(map(str, seq))
			break


	return feedback
Exemplo n.º 3
0
def prfeed(device_path):
	getcontext().prec = 3
	executionTime = Decimal(0)
	maxExecutionTime = Decimal(75) # Maximum initialization time (in seconds)
	sleepTime = Decimal(0.1)
	# -----------------------------------------------------------------------------------------------+
	# REMOVE zwcfg_*.xml FILE - DONE IN PHP BEFORE CALLING THIS FILE								 |
	# -----------------------------------------------------------------------------------------------+
	w = ZWaveWrapper.getInstance(device = device_path, config = '../openzwave/config/')

	feedback = "INITIALIZATION SUCCESS"

	while bool(w.initialized) != True:
		executionTime = executionTime + Decimal(sleepTime)
		time.sleep(sleepTime)
		if executionTime > maxExecutionTime:
			seq = ['INITIALIZATION FAILED | Execution time: ', executionTime, ' seconds']
			feedback = ''.join(map(str, seq))
			break
			
	return feedback
Exemplo n.º 4
0
def prfeed(device_path):
	data = []
	getcontext().prec = 3
	executionTime = Decimal(0)
	maxExecutionTime = Decimal(75) # Maximum initialization time (in seconds)
	sleepTime = Decimal(0.1)

	w = ZWaveWrapper.getInstance(device = device_path, config = '../openzwave/config/')

	feedback = "SUCCESS"
	# print sys.path
	#print "<br><br>Initializing devices, please wait ...<br>"
	while bool(w.initialized) != True:
		executionTime = executionTime + Decimal(sleepTime)
		time.sleep(sleepTime)
		if executionTime > maxExecutionTime:
			seq = ['INITIALIZATION FAILED | Execution time: ', executionTime, ' seconds']
			feedback = ''.join(map(str, seq))
			break
	
	if feedback == "SUCCESS":
		ln = w.nodes
		for n in ln:
			#data.append("<"); data.append("Node ID: "); data.append(w.nodes[n].nodeId); data.append(">");
			#data.append("<"); data.append("Is ON: "); data.append(w.nodes[n].isOn); data.append(">");
			#data.append("<"); data.append("Level: "); data.append(w.nodes[n].level); data.append(">");
			#data.append("<"); data.append("Name: "); data.append(w.nodes[n].name); data.append(">");
			#data.append("<"); data.append("Product Type: "); data.append(w.nodes[n].productType); data.append(">");
			#data.append("<"); data.append("Product: "); data.append(w.nodes[n].product); data.append(">");
			
			dataList = [w.nodes[n].nodeId]; dataList = ''.join(map(str, dataList)); data.append(dataList);
			dataList = [w.nodes[n].isOn]; dataList = ''.join(map(str, dataList)); data.append(dataList);
			dataList = [w.nodes[n].level]; dataList = ''.join(map(str, dataList)); data.append(dataList);

		return data
	else:
		return feedback
Exemplo n.º 5
0
def before_request():
    g.wrapper = ZWaveWrapper.getInstance(device='/dev/keyspan-2', config='../openzwave/config/', log=log)