0.5.1 • Published 3 years ago

lcr600 v0.5.1

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

LectroCount® LCR®600

You should connect to LCR600 with RS-232. Won't work with Serial TTL Voltage level

List of event names:

  • data emitted when received data from LCR 600 is succesfully parsed
  • failed emitted when received data from LCR 600 cant be parsed, only contains LCR return code to troubleshoot
  • switch emitted when LCR 600 switch position is changed
  • field name emitted when value from number data type is changed. example of field names: GrossQty_NE, NetQty_NE, etc

Installation

npm install lcr600

Usage

const lcr600 = require('lcr600');
const LCR600 = new lcr600({
		hostAddress: 0xff,
		LCRNodeAddress: 0x01,
		port: "/dev/ttyUSB0",
		baud: 19200,
		debug: true
	});

Configuration

FieldDefaultDescription
hostAddressOptional0xffHost address
LCRNodeAddressOptional0x00LCR Node Address
portMandatory-Port used to communicate with LCR600
baudOptional19200LCR600 Baud Rate
debugOptionalfalseDebugging Serial Communication

Example

const config = {
	hostAddress: 0xff, // if this field is left empty, would be default to 0xff
	LCRNodeAddress: 0x01, // LCR address device used
	port: "/dev/ttyUSB0", // COM port where device is connected
	baud: 19200, // default baud rate for LCR 600
	debug: true // optional. Default to false
};

const lcr600 = require('lcr600');
const LCR600 = new lcr600(config, config.debug);

// listener for each summary
LCR600.on('GrossCount_NE', received => {
	const data = {
			...received,
			attributes: {
				unitId: LCR600.getAttribute('UnitID_UL'),
				meterId: LCR600.getAttribute('MeterID_WM'),
				qtyUnit: LCR600.getAttribute('QtyUnits_WM'),
			},
		};

	console.dir(data, {depth:4});
	console.log('---------------------------------------');
});

// successfully parsing data
LCR600.on('data', (received) => {
	console.log('data:', received);
	console.log('---------------------------------------');
});

// failed when parsing data, only contains code for debugging purpose
LCR600.on('failed', received => {
	console.error('failed:', received);
	console.log('---------------------------------------');
});

// switch pos changed
LCR600.on('switch', received => {
	console.log('switch:', received);
	console.log('---------------------------------------');
});

(async() => {
	const interval = config.interval || 100;

	// connect to Serialport
	await LCR600.connect();

	// get Product Id and Set synchronization
	await LCR600.getProductID(true);

	// Set attributes data from LCR600
	await LCR600.requestAttribute('QtyUnits_WM');
	await LCR600.requestAttribute('UnitID_UL');
	await LCR600.requestAttribute('MeterID_WM');

	console.log('List set attributes:', LCR600.getAttribute());
	console.log('---------------------------------------');

	// use setTimeout instead of setInterval due to async
	const __loop = async () => {
		await LCR600.getData('GrossCount_NE');
		setTimeout(__loop, interval);
	};

	// start infinite loop
	__loop();

})();

FIELDS

Field NameField NumberType
ProductNumber_DL0LIST+0
ProductCode_DL1TEXT
GrossQty_NE2VOLUME
NetQty_NE3VOLUME
FlowRate_NE4VOLUME
ProductDescriptor_DL11TEXT
ShiftGross_NE13VOLUME
ShiftNet_NE14VOLUME
GrossTotal_WM17VOLUME
NetTotal_WM18VOLUME
UnitID_UL24TEXT
Temp_WM33SFLOAT
TempOffset_WM34SFLOAT
TempScale_WM35LIST+10
MeterID_WM36TEXT
QtyUnits_WM38LIST+4
Decimals_WM39LIST+14
FlowDirection_WM40LIST+21
TimeUnit_WM41LIST+11
CalibrationEvent_NE42LONG
ConfigurationEvent_NE43LONG
GrossCount_NE44VOLUME
NetCount_NE45VOLUME
AvgFlowRate126VOLUME
CompFlowRate127VOLUME

LIST TYPES

LIST+4
NumberDescription
1LITRE
2CUBIC METER
3POUND
4KILOGRAM
5BARREL
6(empty)
LIST+10
NumberDescription
0°C
1°F
LIST+11
NumberDescription
0PER SECOND
1PER MINUTE
2PER HOUR
LIST+14
NumberDescription
02 Digits
11 Digit
20 Digit
LIST+21
NumberDescription
0RIGHT
1LEFT
0.5.1

3 years ago

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0-1

3 years ago

0.1.0-2

3 years ago

0.1.0

3 years ago