const pointerClass = require("@brightsign/pointer");
var pointer = new pointerClass();
const pointerCalibClass = require("@brightsign/pointercalibration");
var pointerCalib = new pointerCalibClass();
var bsMessage = new BSMessagePort();
var present = {
mouse: undefined,
TouchScreen: undefined
}
function runThis() {
pointerCalib.startEventLogging().then(() => {
console.log("Started Event Logger.");
bsMessage.PostBSMessage({
startLogger: "Success"
});
}).catch((err) => {
console.log("ERROR: " + err);
bsMessage.PostBSMessage({
startLogger: "Failed"
});
});
function eventInfo() {
pointerCalib.getDiagnosticInfoHTML(false, true).then((val) => {
console.log("----------------------------Events Info-----------------------------")
console.log(val);
}).catch((err) => {
console.log("ERROR: " + err);
});
}
function checkPeripherals() {
pointer.isMousePresent().then((val) => {
console.log("Checking to see if a mouse if present.");
present.Mouse = val;
if (val === false) {
console.log("No mouse attached.");
console.log("value: " + val);
bsMessage.PostBSMessage({
mouse: "Success"
});
} else if (val === true) {
console.log("Mouse Detected.");
console.log("value: " + val);
bsMessage.PostBSMessage({
mouse: "Success"
});
} else {
console.log("Recieved unexpected return value.");
console.log("value: " + val);
bsMessage.PostBSMessage({
mouse: "Failed"
});
}
}).catch((err) => {
console.log("ERROR: " + err);
bsMessage.PostBSMessage({
mouse: "Failed"
});
});
pointer.isMultiTouchPresent().then((val) => {
present.TouchScreen = val;
if (val === true) {
console.log("TouchScreen found.");
console.log(val);
bsMessage.PostBSMessage({
touch: "Success"
});
} else {
console.log("TouchScreen not found.");
console.log(val);
bsMessage.PostBSMessage({
touch: "Success"
});
}
}).catch((err) => {
console.log("ERROR: " + err);
console.log("isMultiTouchPresent failed.");
bsMessage.PostBSMessage({
touch: "Failed"
});
});
}
function Calibrate() {
pointerCalib.setCalibrationRanges(0, 1920, 0, 1080).then((val) => {
console.log("Range has been set.");
bsMessage.PostBSMessage({
CalibRange: "Success"
});
}).catch((err) => {
console.log("ERROR: " + err);
console.log("SetCalibrationRanges Failed.");
bsMessage.PostBSMessage({
CalibRange: "Failed"
});
});
pointerCalib.startCalibration().then((value) => {
console.log("Starting Calibration:");
bsMessage.PostBSMessage({
Calib: "Success"
});
pointerCalib.getCalibrationStatus().then((val) => {
console.log("Calibration Status: " + val);
bsMessage.PostBSMessage({
CalibStat: "Success"
});
}).catch((err) => {
console.log("ERROR: " + err);
console.log("getCalibrationStatus Failed.");
bsMessage.PostBSMessage({
CalibStat: "Failed"
});
});
}).catch((err) => {
console.log("ERROR: " + err);
console.log("startCalibration Failed.");
bsMessage.PostBSMessage({
Calib: "Failed"
});
});
}
function CheckandClear() {
pointerCalib.isCalibrated().then((value) => {
console.log("Checking for calibration.");
if (value === true) {
console.log("Calibrated: " + value);
bsMessage.PostBSMessage({
isCalib: "Success"
});
pointerCalib.clearStoredCalibration().then((val) => {
console.log("Attempting to clear calibration.");
if (value === true) {
console.log("Calibration Cleared: " + val);
bsMessage.PostBSMessage({
clearCalib: "Success"
});
} else {
console.log("Calibration Cleared: " + val);
bsMessage.PostBSMessage({
clearCallib: "Success"
});
}
}).catch((err) => {
console.log("ERROR: " + err);
console.log("Failed to clear calibration.");
bsMessage.PostBSMessage({
clearCalib: "Failed"
});
});
} else {
console.log("Calibrated: " + value);
bsMessage.PostBSMessage({
isCalib: "Success"
});
}
}).catch((err) => {
console.log("ERROR: " + err);
console.log("Calibration Check Failed.");
bsMessage.PostBSMessage({
isCalib: "Failed"
});
});
}
function diagInfHTML() {
pointerCalib.getDiagnosticInfoHTML(true, true).then((value) => {
console.log("Success in getting diagnostics info. Printing below.");
console.log("Info: " + value);
bsMessage.PostBSMessage({
getDiagInf: "Success"
});
}).catch((err) => {
console.log("ERROR: " + err);
console.log("Failed to get diagnostics information.");
bsMessage.PostBSMessage({
getDiagInf: "Failed"
});
});
}
bsMessage.PostBSMessage({
BSMessagePort: "CREATED"
});
setTimeout(checkPeripherals, 1000);
setTimeout(() => {
if (present.TouchScreen === true) {
setTimeout(Calibrate, 4000);
setTimeout(CheckandClear, 8000);
} else {
console.log("TouchScreen Not Found. Calibration Tests Skipped.");
console.log("TouchScreen Value: " + present.TouchScreen);
console.log("Mouse Value: " + present.Mouse);
bsMessage.PostBSMessage({
CalibTest: "Skipped"
});
}
}, 3000);
setTimeout(diagInfHTML, 10000);
setTimeout(eventInfo, 11500);
setTimeout(() => {
console.log("Ending Test.");
pointerCalib.stopEventLogging().then(() => {
console.log("Stopped Event Logger.");
bsMessage.PostBSMessage({
stopLogger: "Success"
});
}).catch((err) => {
console.log("ERROR STOPPING EVENT LOGGER: " + err);
bsMessage.PostBSMessage({
stopLogger: "Failed"
});
});
}, 12000);
setTimeout(() => {
bsMessage.PostBSMessage({
BSMessagePort: "COMPLETE"
});
}, 16000);
} |