<commit_before>var machine = require('./machine').machine;
var default_feed_rate = 300;

function move_direction(direction) {
	machine.jog(direction);
}

function jog_direction(direction) {
	machine.jog(direction);
}

function stop() {
	machine.stopJog();
}


exports.send_gcode = function(req, res, next) {
	if (machine.status.state === 'idle')
	{
		if (req.params.cmd !== undefined )
		{
			machine.gcode(req.params.cmd);
    		res.json({'success': req.params.cmd})
		}
		else if (req.body) {
			machine.gcode(req.body);
			res.json({'success': req.params.cmd})

		}
		else {
			res.json({'error':'No cmd argument'});	
		}
	}
	else {
		res.json({'error':'A file is running'});	
	}
};

exports.send_sbp = function(req, res, next) {
	if (machine.status.state === 'idle')
	{
		if (req.params.cmd !== undefined )
		{
			machine.sbp(req.params.cmd);
    		res.json({'success': req.params.cmd})
		}
		else if (req.body) {
			machine.sbp(req.body);
			res.json({'success': req.params.cmd})

		}
		else {
			res.json({'error':'No cmd argument'});	
		}
	}
	else {
		res.json({'error':'A file is running'});	
	}
};


exports.move = function(req, res, next) {
	if (req.params.move !== undefined )
	{
		move_direction(req.params.move);			
		res.json({'success': 'moving in '+req.params.move+' direction'});
	}
	else {
		stop();
		res.json({'error':'Need at least one argument'});	
	}
};

exports.jog = function(req, res, next) {
	if (req.params.move !== undefined ) {
		jog_direction(req.params.move);
		res.json({'success': 'Moving in '+req.params.move+' direction'});
	}
	else {
		stop();
		res.json({'error':'Need at least one argument'});	
	}
};

exports.goto = function(req, res, next) {
   	if (machine.status.state === 'idle')
	{
		if (req.params.x !== undefined || req.params.y !== undefined || req.params.z !== undefined || req.params.a !== undefined || req.params.b !== undefined || req.params.c !== undefined)
		{
			var gcode_string = 'G01';
			if (req.params.x !== undefined )
				gcode_string += ' X'+ req.params.x;
			if (req.params.y !== undefined )
				gcode_string += ' Y'+ req.params.y;
		 	if (req.params.z !== undefined )
				gcode_string += ' Z'+ req.params.z;
			if (req.params.a !== undefined )
				gcode_string += ' A'+ req.params.x;
			if (req.params.b !== undefined )
				gcode_string += ' B'+ req.params.y;
		 	if (req.params.c !== undefined )
				gcode_string += ' C'+ req.params.z;			
			if (req.params.f !== undefined )
				gcode_string += ' F'+ req.params.f;
			else 
				gcode_string +=' F'+default_feed_rate;

			machine.driver.gcode(gcode_string);
    			res.json({'success': gcode_string})
		}
		else
		{
			res.json({'error':'Need at least one argument'});	
		}
	}
	else
	{
		res.json({'error':'A file is running'});	
	}
};
<commit_msg>correction of the jog & move stop request<commit_after>var machine = require('./machine').machine;
var default_feed_rate = 300;

function move_direction(direction) {
	machine.jog(direction);
}

function jog_direction(direction) {
	machine.jog(direction);
}

function stop() {
	machine.stopJog();
}


exports.send_gcode = function(req, res, next) {
	if (machine.status.state === 'idle')
	{
		if (req.params.cmd !== undefined )
		{
			machine.gcode(req.params.cmd);
    		res.json({'success': req.params.cmd})
		}
		else if (req.body) {
			machine.gcode(req.body);
			res.json({'success': req.params.cmd})

		}
		else {
			res.json({'error':'No cmd argument'});	
		}
	}
	else {
		res.json({'error':'A file is running'});	
	}
};

exports.send_sbp = function(req, res, next) {
	if (machine.status.state === 'idle')
	{
		if (req.params.cmd !== undefined )
		{
			machine.sbp(req.params.cmd);
    		res.json({'success': req.params.cmd})
		}
		else if (req.body) {
			machine.sbp(req.body);
			res.json({'success': req.params.cmd})

		}
		else {
			res.json({'error':'No cmd argument'});	
		}
	}
	else {
		res.json({'error':'A file is running'});	
	}
};


exports.move = function(req, res, next) {
	if(req.params.move ==="stop"){
		stop();
		res.json({'success':'stop'});
	}
	else if (req.params.move !== undefined )
	{
		move_direction(req.params.move);			
		res.json({'success': 'moving in '+req.params.move+' direction'});
	}
	else {
		stop();
		res.json({'error':'Need at least one argument'});	
	}
};

exports.jog = function(req, res, next) {
	if(req.params.move ==="stop"){
		stop();
		res.json({'success':'stop'});
	}
	else if (req.params.move !== undefined ) {
		jog_direction(req.params.move);
		res.json({'success': 'Moving in '+req.params.move+' direction'});
	}
	else {
		stop();
		res.json({'error':'Need at least one argument'});	
	}
};

exports.goto = function(req, res, next) {
   	if (machine.status.state === 'idle')
	{
		if (req.params.x !== undefined || req.params.y !== undefined || req.params.z !== undefined || req.params.a !== undefined || req.params.b !== undefined || req.params.c !== undefined)
		{
			var gcode_string = 'G01';
			if (req.params.x !== undefined )
				gcode_string += ' X'+ req.params.x;
			if (req.params.y !== undefined )
				gcode_string += ' Y'+ req.params.y;
		 	if (req.params.z !== undefined )
				gcode_string += ' Z'+ req.params.z;
			if (req.params.a !== undefined )
				gcode_string += ' A'+ req.params.a;
			if (req.params.b !== undefined )
				gcode_string += ' B'+ req.params.b;
		 	if (req.params.c !== undefined )
				gcode_string += ' C'+ req.params.c;			
			if (req.params.f !== undefined )
				gcode_string += ' F'+ req.params.f;
			else 
				gcode_string +=' F'+default_feed_rate;

			machine.driver.gcode(gcode_string);
    			res.json({'success': gcode_string})
		}
		else
		{
			res.json({'error':'Need at least one argument'});	
		}
	}
	else
	{
		res.json({'error':'A file is running'});	
	}
};

{'fraction_non_alphanumeric': 0.20129415879678209, 'fraction_numerical': 0.0017488632388947185, 'mean_word_length': 3.3064759036144578, 'pattern_counts': {'":': 0, '<': 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': '4772559', 'n_tokens_mistral': 2381, 'n_tokens_neox': 2140, 'n_words': 402}