chamber-api-handler
v1.1.1
Published
How to use
Downloads
143
Readme
How to use
import { ChamberHandler } from chamber-api-handler;
async function main() {
const handler = new ChamberHandler();
try {
// Open TCP connection
await handler.openTcpConnection();
// Perform a single point operation
const singlePointResponse = await handler.singlePoint(30, 50, 0, 30, 0, 0, 0, 0, 0, 0);
console.log('Single Point Response:', singlePointResponse);
// Read a PGM file
const file = await handler.readPGM('one-poin.pgm');
console.log('File:', file);
// Get the current status
const status = await handler.getStatus();
console.log('Status:', status);
// Get the list of programs before renaming
const listBefore = await handler.getList();
console.log('List Before:', listBefore);
// Rename the PGM file
const renameResponse = await handler.renamePGM('one-poin.pgm', 'testing.pgm');
console.log('Rename Response:', renameResponse);
// Get the list of programs after renaming
const listAfter = await handler.getList();
console.log('List After:', listAfter);
// Get data before running the program
const readBefore = await handler.getData();
console.log('Data Before:', readBefore);
// Jump to the next section
const jumpResponse = await handler.jumpNextSection();
console.log('Jump Response:', jumpResponse);
// Get data after jumping to the next section
const readAfter = await handler.getData();
console.log('Data After:', readAfter);
// Wait for 5 seconds
await new Promise((resolve) => setTimeout(resolve, 5000));
// Stop the handler
const stopResponse = await handler.stop();
console.log('Stop Response:', stopResponse);
// Read the renamed PGM file
const read = await handler.readPGM('testing.pgm');
console.log('Read Response:', read);
// Delete the renamed PGM file
const deletePgmResponse = await handler.deletePGM('testing.pgm');
console.log('Delete PGM Response:', deletePgmResponse);
// Get the final list of programs
const listFinal = await handler.getList();
console.log('List Final:', listFinal);
} catch (error) {
console.error('An error occurred:', error);
} finally {
// Close TCP connection
await handler.closeTcpConnection();
}
}