function BarcodeManager(side, logPath) {
	var sides = {
		"south": 0,
		"west": 1,
		"north": 2,
		"east": 3,
		"front": 0,
		"left": 1,
		"back": 2,
		"right": 3
	};
	// Which barcode index to use (see VWorks plate object), default to 3:
	if(!isNaN(parseInt(side, 10))) {
		this.side = parseInt(side, 10);
	} else if(side.trim().toLowerCase() in sides) {
		this.side = sides[side.trim().toLowerCase()];
	} else {
		this.side = 3;
	}
	// Where to put the logfiles:
	this.logPath = logPath || "C:/VWorks Workspace/Barcode_logs/";

	// Return a string with the current date and time
	// format YY-MM-DD HH:MM:SS
	this.timestamp = function() {
		var d = new Date();
		var date = [d.getFullYear(), d.getMonth()+1, d.getDate(), d.getHours(),
				d.getMinutes(), d.getSeconds()];
		// Convert to string and pad with zeroes, i.e. 8 -> "08":
		for(var i=date.length; i-->0;) {
			var x = date[i];
			date[i] = (x > 9) ? x + "" : "0" + x;
		}
		return date.slice(0,3).join("-") + " " + date.slice(3).join(":");
	};

	this.datestamp = function() {
		var d = new Date();
		var date = [d.getFullYear(), d.getMonth()+1, d.getDate()];
		// Convert to string and pad with zeroes, i.e. 8 -> "08":
		for(var i=date.length; i-->0;) {
			var x = date[i];
			date[i] = (x > 9) ? x + "" : "0" + x;
		}
		return date.slice(0,3).join("-");
	};

	this.hasBc = function(plateObj) {
		//var bc = (typeof plateObj === "string") ? plateObj : plateObj.barcode[this.side];
		var bc = plateObj.barcode[this.side];
		// Check if undefined/null (VWorks may use string 'undefined'):
		var hasBc = (typeof bc !== "undefined" && bc !== null && bc !== "undefined");
		// Check for number or non-blank string:
		hasBc = hasBc && (!isNaN(parseFloat(bc)) || !!bc.trim());
		return hasBc;
	};

	this.printBc = function(plateObj) {
		//var bc = (typeof plateObj === "string") ? plateObj : plateObj.barcode[this.side];
		var bc = plateObj.barcode[this.side];
		print(bc || "<no barcode>");
	};

	this.bcMatches = function(plateObj, barcode) {
		//var bc = (typeof plateObj === "string") ? plateObj : plateObj.barcode[this.side];
		var bc = plateObj.barcode[this.side];
		return (bc === barcode);
	};

	this.logBc = function(plateObj, taskObj, text) {
		var bc = plateObj.barcode[this.side];
		var plate = plateObj.name;
		var pro = taskObj.getProtocolName();
		var t = (typeof text === "undefined") ? "" : "\t" + text;
		var logStr = this.timestamp() + "\t" + pro + "\t" + plate + "\t" + bc + t;
		appendFile(this.logPath + "barcode_log_" + this.datestamp() + ".log", logStr);
	};
}
/**
 * Functions for dealing with plate barcodes in VWorks
 * @author Joel Gruselius
 * @class
 * @param {string} side - The side of the plate where the barcode
 * @param {string} logPath - Full path to where to save the log file
 */
Functions for dealing with plate barcodes in VWorks
@author Joel Gruselius
@class
@param {string} side - The side of the plate where the barcode
@param {string} logPath - Full path to where to save the log file
Functions for dealing with plate barcodes in VWorks @author Joel Gruselius @class @param { string } side - The side of the plate where the barcode @param { string } logPath - Full path to where to save the log file
function BarcodeManager(side, logPath) {
	var sides = {
		"south": 0,
		"west": 1,
		"north": 2,
		"east": 3,
		"front": 0,
		"left": 1,
		"back": 2,
		"right": 3
	};
	if(!isNaN(parseInt(side, 10))) {
		this.side = parseInt(side, 10);
	} else if(side.trim().toLowerCase() in sides) {
		this.side = sides[side.trim().toLowerCase()];
	} else {
		this.side = 3;
	}
	this.logPath = logPath || "C:/VWorks Workspace/Barcode_logs/";
	this.timestamp = function() {
		var d = new Date();
		var date = [d.getFullYear(), d.getMonth()+1, d.getDate(), d.getHours(),
				d.getMinutes(), d.getSeconds()];
		for(var i=date.length; i-->0;) {
			var x = date[i];
			date[i] = (x > 9) ? x + "" : "0" + x;
		}
		return date.slice(0,3).join("-") + " " + date.slice(3).join(":");
	};
	this.datestamp = function() {
		var d = new Date();
		var date = [d.getFullYear(), d.getMonth()+1, d.getDate()];
		for(var i=date.length; i-->0;) {
			var x = date[i];
			date[i] = (x > 9) ? x + "" : "0" + x;
		}
		return date.slice(0,3).join("-");
	};
	this.hasBc = function(plateObj) {
		var bc = plateObj.barcode[this.side];
		var hasBc = (typeof bc !== "undefined" && bc !== null && bc !== "undefined");
		hasBc = hasBc && (!isNaN(parseFloat(bc)) || !!bc.trim());
		return hasBc;
	};
	this.printBc = function(plateObj) {
		var bc = plateObj.barcode[this.side];
		print(bc || "<no barcode>");
	};
	this.bcMatches = function(plateObj, barcode) {
		var bc = plateObj.barcode[this.side];
		return (bc === barcode);
	};
	this.logBc = function(plateObj, taskObj, text) {
		var bc = plateObj.barcode[this.side];
		var plate = plateObj.name;
		var pro = taskObj.getProtocolName();
		var t = (typeof text === "undefined") ? "" : "\t" + text;
		var logStr = this.timestamp() + "\t" + pro + "\t" + plate + "\t" + bc + t;
		appendFile(this.logPath + "barcode_log_" + this.datestamp() + ".log", logStr);
	};
}
function BarcodeManager ( side , logPath ) { var sides = { "south" : 0 , "west" : 1 , "north" : 2 , "east" : 3 , "front" : 0 , "left" : 1 , "back" : 2 , "right" : 3 } ; if ( ! isNaN ( parseInt ( side , 10 ) ) ) { this . side = parseInt ( side , 10 ) ; } else if ( side . trim ( ) . toLowerCase ( ) in sides ) { this . side = sides [ side . trim ( ) . toLowerCase ( ) ] ; } else { this . side = 3 ; } this . logPath = logPath || "C:/VWorks Workspace/Barcode_logs/" ; this . timestamp = function ( ) { var d = new Date ( ) ; var date = [ d . getFullYear ( ) , d . getMonth ( ) + 1 , d . getDate ( ) , d . getHours ( ) , d . getMinutes ( ) , d . getSeconds ( ) ] ; for ( var i = date . length ; i -- > 0 ; ) { var x = date [ i ] ; date [ i ] = ( x > 9 ) ? x + "" : "0" + x ; } return date . slice ( 0 , 3 ) . join ( "-" ) + " " + date . slice ( 3 ) . join ( ":" ) ; } ; this . datestamp = function ( ) { var d = new Date ( ) ; var date = [ d . getFullYear ( ) , d . getMonth ( ) + 1 , d . getDate ( ) ] ; for ( var i = date . length ; i -- > 0 ; ) { var x = date [ i ] ; date [ i ] = ( x > 9 ) ? x + "" : "0" + x ; } return date . slice ( 0 , 3 ) . join ( "-" ) ; } ; this . hasBc = function ( plateObj ) { var bc = plateObj . barcode [ this . side ] ; var hasBc = ( typeof bc !== "undefined" && bc !== null && bc !== "undefined" ) ; hasBc = hasBc && ( ! isNaN ( parseFloat ( bc ) ) || ! ! bc . trim ( ) ) ; return hasBc ; } ; this . printBc = function ( plateObj ) { var bc = plateObj . barcode [ this . side ] ; print ( bc || "<no barcode>" ) ; } ; this . bcMatches = function ( plateObj , barcode ) { var bc = plateObj . barcode [ this . side ] ; return ( bc === barcode ) ; } ; this . logBc = function ( plateObj , taskObj , text ) { var bc = plateObj . barcode [ this . side ] ; var plate = plateObj . name ; var pro = taskObj . getProtocolName ( ) ; var t = ( typeof text === "undefined" ) ? "" : "\t" + text ; var logStr = this . timestamp ( ) + "\t" + pro + "\t" + plate + "\t" + bc + t ; appendFile ( this . logPath + "barcode_log_" + this . datestamp ( ) + ".log" , logStr ) ; } ; }
Functions for dealing with plate barcodes in VWorks
 @author Joel Gruselius
 @class
 @param {string} side - The side of the plate where the barcode
 @param {string} logPath - Full path to where to save the log file
Functions for dealing with plate barcodes in VWorks @author Joel Gruselius @class @param { string } side - The side of the plate where the barcode @param { string } logPath - Full path to where to save the log file
// Which barcode index to use (see VWorks plate object), default to 3: // Where to put the logfiles: // Return a string with the current date and time // format YY-MM-DD HH:MM:SS // Convert to string and pad with zeroes, i.e. 8 -> "08": // Convert to string and pad with zeroes, i.e. 8 -> "08": //var bc = (typeof plateObj === "string") ? plateObj : plateObj.barcode[this.side]; // Check if undefined/null (VWorks may use string 'undefined'): // Check for number or non-blank string: //var bc = (typeof plateObj === "string") ? plateObj : plateObj.barcode[this.side]; //var bc = (typeof plateObj === "string") ? plateObj : plateObj.barcode[this.side];