chrisJohn404/ljswitchboard-device_scanner · open_all_device_scanner.js
javascript logo
function closeInactiveDevices(bundle) {
        debugSS('in closeInactiveDevices');
        var defered = q.defer();

        self.deviceManager.closeDevicesOpenedByScanner()
        .then(function() {
            defered.resolve(bundle);
        })
        .catch(function() {
            defered.resolve(bundle);
        });
        return defered.promise;
    }
Similar code snippets
1.
chrisJohn404/ljswitchboard-device_scanner · open_all_device_scanner.js
Match rating: 68.33% · See similar code snippets
javascript logo
function() {
        // console.log('Close Device...', self.openParameters);
        self.log('in closeDevice');
        var defered = q.defer();
        if(self.isActive) {
            // Don't close active devices.
            defered.resolve();
        } else {
            if(!self.isMockDevice) {
                ljmUtils.closeDevice(
                    self.handle,
                    function(data) {
                        // console.log('Closed Device Info', data);
                        defered.resolve();
                    });
                // defered.resolve();
            } else {
                defered.resolve();
                // mockDeviceScanningLib.getDeviceInfo(
                // self.handle,
                // self.requiredInfo,
                // function(data) {
                //     parseDeviceInfo(data, self.requiredInfo);
                //     self.collectedDeviceData = data;
                //     self.collectedDeviceData.isActive = self.isActive;
                //     self.collectedDeviceData.isMockDevice = true;
                //     defered.resolve();
                // });
                // Don't bother closing??
            }
        }
        return defered.promise;
    }
2.
chrisJohn404/ljswitchboard-device_scanner · mock_device_scanner.js
Match rating: 65.35% · See similar code snippets
javascript logo
function(deviceInfo) {
		var defered = q.defer();
		addDeviceSync(deviceInfo);
		defered.resolve();
		return defered.promise;
	}
3.
chrisJohn404/ljswitchboard-ljm_device_curator · device_curator.js
Match rating: 64.98% · See similar code snippets
javascript logo
function() {
		var defered = q.defer();
		
		prepareToCloseDevice();
		
		// Close the LJM device.
		ljmDevice.close(
			function(err) {
				defered.reject(err);
			}, function(res) {
				defered.resolve(res);
			}
		);
		return defered.promise;
	}
4.
chrisJohn404/ljswitchboard-ljm_device_curator · device_curator.js
Match rating: 59.8% · See similar code snippets
javascript logo
function() {
		var defered = q.defer();

		// Disable LJM Function Calls
        self.deviceConnectionSuspended = true;

        // Declare device Disconnected
        self.declareDeviceDisconnected();

        // Disconnect from device & declare device to be disconnected.
        var device = self.getDevice();
		var handle = device.handle;
        var dt = device.deviceType;
		var ct = device.connectionType;
		var id = device.identifier;
        device.close(function(err) {
            defered.reject();
        }, function() {
			// Temporarily restore handle & other device info...
            device.handle = handle;
			device.deviceType = dt;
			device.connectionType = ct;
			device.identifier = id;

			defered.resolve();
        });
		return defered.promise;
	}
5.
chrisJohn404/ljswitchboard-ljm_device_curator · device_curator.js
Match rating: 57.61% · See similar code snippets
javascript logo
function(address, value) {
		var defered = q.defer();
		if(allowExecution()) {
			ljmDevice.write(
				address,
				value,
				function(err) {
					captureDeviceError('write', err, {
						'address': address, 'value': value
					});
					defered.reject(err);
				},
				defered.resolve
			);
		} else {
			setImmediate(function() {
				defered.reject(driver_const.LJN_DEVICE_NOT_CONNECTED);
			});
		}
		return defered.promise;
	}
6.
chrisJohn404/ljswitchboard-ljm_device_curator · t7_calibration_operations.js
Match rating: 54.8% · See similar code snippets
javascript logo
function() {
        var defered = q.defer();
        if(curatedDevice.savedAttributes.FIRMWARE_VERSION > driver_const.T7_LIMITED_FW_VERSION) {
            curatedDevice.readMany(ainList)
            .then(function(res) {
                res.forEach(function(reading) {
                    if(reading !== 0) {
                        highSpeedStatus = true;
                    }
                });
                defered.resolve();
            }, defered.reject);
        } else {
            curatedDevice.readMultiple(ainList)
            .then(function(res) {
                res.forEach(function(reading) {
                    if(!reading.isErr) {
                        if(reading.data !== 0) {
                            highSpeedStatus = true;
                        }
                    }
                });
                defered.resolve();
            }, defered.reject);
        }
        return defered.promise;
    }
7.
chrisJohn404/ljswitchboard-ljm_device_curator · register_watcher.js
Match rating: 53.86% · See similar code snippets
javascript logo
function() {
		var defered = q.defer();
		var watcherKeys = Object.keys(self.watchers);
		defered.resolve(watcherKeys);
		return defered.promise;
	}
8.
chrisJohn404/ljswitchboard-ljm_device_curator · device_curator.js
Match rating: 53.06% · See similar code snippets
javascript logo
function(address) {
		var defered = q.defer();
		var info = modbusMap.getAddressInfo(address);
		var regName = info.data.name;
		if(self.cachedValues[regName]) {
			var res = data_parser.parseResult(
				address,
				self.cachedValues[regName],
				self.savedAttributes.deviceType
			);
			defered.resolve(res);
		} else {
			self.sRead(address)
			.then(defered.resolve, defered.reject);
			// defered.resolve({});
		}
		return defered.promise;
	}
9.
chrisJohn404/ljswitchboard-ljm_device_curator · device_curator.js
Match rating: 50.84% · See similar code snippets
javascript logo
function(addresses, values) {
		var defered = q.defer();
		var writes = [];
		var i;
		for(i = 0; i < addresses.length; i ++) {
			writes.push({'address': addresses[i],'val':values[i]});
		}
		self.performMultipleWrites(writes)
		.then(defered.resolve, defered.reject);
		return defered.promise;
	}
10.
chrisJohn404/ljswitchboard-ljm_device_curator · device_curator.js
Match rating: 49.17% · See similar code snippets
javascript logo
function(addresses, values) {
		var defered = q.defer();
		var encodedValues = values.map(function(value, i) {
			return data_parser.encodeValue(addresses[i], value);
		});
		self.qWriteMany(addresses, encodedValues)
		.then(function(res) {
			// If the write happens successfully then update the device cache
			updateDeviceValueCacheArray(addresses, values);
			defered.resolve(res);
		}, defered.reject);
		return defered.promise;
	}