<commit_before>global.XMLHttpRequest = require('xhr2');
global.WebSocket = require('ws');
var DeviceHive = require('./devicehive.client');

var Client = function (options){
	var DH = new DeviceHive(options.apiurl , options.accessKey);

	this.DH = DH;
	this.command = "gpio/write";
	this.parameters1 = { "5":1 };
	this.parameters0 = { "5":0 };
};

Client.prototype.start = function (cb,handler){
	var self = this;

	

	console.log("trying to open chanell!");
	self.DH.openChannel(function (err, res) {
	            if (err) {
	                console.log(err);
	            }
	            console.log("trying to send command!");
				self.DH.sendCommand('esp-device',self.command, self.parameters1 ,function(err, res) {
					if(err){
						console.log(err);
					}
					console.log("equipment sendNotification " + "esp-device" + " " + self.command);
					console.log(res);
					return;
				});

				setTimeout( function(){
					self.DH.sendCommand('esp-device',self.command, self.parameters0 ,function(err, res) {
						if(err){
							console.log(err);
						}
						console.log("equipment sendNotification " + "esp-device" + " " + self.command);
						console.log(res);
						return;
					});
					self.DH.closeChannel(
						function(err,res){
							if(err){
								console.log("failed to close websocket channel");
							}
							else console.log(res);
						}
					);

				},3000);
	        }, 
	        "websocket"
	);
};


module.exports = Client;<commit_msg>add test suport for commands<commit_after>global.XMLHttpRequest = require('xhr2');
global.WebSocket = require('ws');
var DeviceHive = require('./devicehive.client');
var Commands = require('./commands');

var Client = function (options){
	var DH = new DeviceHive(options.apiurl , options.accessKey);
	var commands = new Commands(DH);
	
	this.commands=commands;
	this.DH = DH;

};

Client.prototype.start = function (cb,handler){
	var self = this;
	var data = {
		device : "esp-device",
		command : "gpio/write" ,
		parameters : { "5":1 } 
	}
	

	console.log("trying to open chanell!");
	self.DH.openChannel(function (err, res) {
	            if (err) {
	                console.log(err);
	            }
	            console.log("trying to send command!");
				self.commands.SendCommand(data);



				/*self.DH.sendCommand('esp-device',self.command, self.parameters1 ,function(err, res) {
					if(err){
						console.log(err);
					}
					console.log("equipment sendNotification " + "esp-device" + " " + self.command);
					console.log(res);
					return;
				}); */

				/*setTimeout( function(){
					self.DH.sendCommand('esp-device',self.command, self.parameters0 ,function(err, res) {
						if(err){
							console.log(err);
						}
						console.log("equipment sendNotification " + "esp-device" + " " + self.command);
						console.log(res);
						return;
					});
					self.DH.closeChannel(
						function(err,res){
							if(err){
								console.log("failed to close websocket channel");
							}
							else console.log(res);
						}
					);

				},3000);*/
	        }, 
	        "websocket"
	);
};


module.exports = Client;
{'fraction_non_alphanumeric': 0.16101968376895773, 'fraction_numerical': 0.007099064214262665, 'mean_word_length': 2.5714285714285716, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4453668', 'n_tokens_mistral': 1280, 'n_tokens_neox': 972, 'n_words': 182}