small test files
This commit is contained in:
parent
983c630e6a
commit
e0489f5ca8
@ -1,11 +1,10 @@
|
||||
import {ONE_NEW_LINE, TWO_NEW_LINES} from "./utils/constants.js";
|
||||
|
||||
const isInRange = (value, masterValue) => {
|
||||
return (masterValue["Low Limit"] <= value && value <= masterValue["High Limit"]);
|
||||
}
|
||||
const calculateDelta = (value, lowLimit) => {
|
||||
return Math.abs(lowLimit - value);
|
||||
}
|
||||
|
||||
function outOfTolerance(readings) {
|
||||
// Calculate Out of Tolerances
|
||||
for (const reading of readings) {
|
||||
@ -56,8 +55,8 @@ const KEEP = {
|
||||
function deviceDataToObj(lines, name, kind) {
|
||||
const keep = KEEP[kind]
|
||||
const deviceData = {
|
||||
"Name":name,
|
||||
"Master Values":{},
|
||||
"Name": name,
|
||||
"Master Values": {},
|
||||
"Gauge Reading": []
|
||||
};
|
||||
for (const line of lines) {
|
||||
@ -72,9 +71,9 @@ function deviceDataToObj(lines, name, kind) {
|
||||
for (const start of keep) {
|
||||
if (keyTrimmed.startsWith(start)) {
|
||||
if (keyTrimmed.includes("Master")) {
|
||||
// Master values occur twice, but due to the fact that this is
|
||||
// editing KeyValues not Indexes, it will replace
|
||||
// the masters with the second instance of these.
|
||||
// Master values occur twice, but due to the fact that this is
|
||||
// editing KeyValues not Indexes, it will replace
|
||||
// the masters with the second instance of these.
|
||||
// No manual checks to skip the first.
|
||||
deviceData["Master Values"][keyTrimmed] = {"v": value.trim()}
|
||||
} else {
|
||||
@ -88,7 +87,7 @@ function deviceDataToObj(lines, name, kind) {
|
||||
for (let i in deviceData["Gauge Reading"]) {
|
||||
i = parseInt(i)
|
||||
|
||||
const key = (kind === "Mass Flow Trans") ? `Master Reading ${i+1}` : `Master Value ${i+1}`
|
||||
const key = (kind === "Mass Flow Trans") ? `Master Reading ${i + 1}` : `Master Value ${i + 1}`
|
||||
deviceData["Gauge Reading"][i]["Master Value"] = deviceData["Master Values"][key]["v"]
|
||||
}
|
||||
delete deviceData["Master Values"]
|
||||
@ -148,6 +147,11 @@ const parseCalibrationData = (text, accuracy) => {
|
||||
}
|
||||
|
||||
function parseHardwareCalibration(content, accuracy) {
|
||||
// hack because we can't be sure that the file will end in two newlines, so might as well force it to add two
|
||||
// this way if there's only zero or one, we can still regex match on that
|
||||
content += "\r\n\r\n"
|
||||
|
||||
// Replace the newlines consistently on windows/linux
|
||||
content = content.replace(/\r\n/g, "\r").replace(/\n/g, "\r")
|
||||
const [instrument, ports] = content.split("|| Hardware Calibration Report ||");
|
||||
const instrumentInfo = parseInstrumentInfo(instrument);
|
||||
@ -157,5 +161,6 @@ function parseHardwareCalibration(content, accuracy) {
|
||||
}
|
||||
|
||||
export default function ParseHardwareCalibration(content, accuracy) {
|
||||
|
||||
return parseHardwareCalibration(content, accuracy);
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
|| Instrument Info ||
|
||||
|
||||
Instrument Name Chassis2 Adult
|
||||
Serial Number BBP1736
|
||||
Time 11:31:39
|
||||
Date 07/12/2022
|
||||
|
||||
|
||||
|| Hardware Calibration Report ||
|
||||
|
||||
Hardware 0
|
||||
===============================================================
|
||||
Test Port 1
|
||||
===========================================================
|
||||
|
||||
|
||||
Mass Flow Trans
|
||||
===========================================================
|
||||
Transducer Custom
|
||||
Input AIN 2
|
||||
Setpoint Pressure 1 25.000 psig
|
||||
Analog Value 1 8688254 cnts
|
||||
Master Value 1 0.041 sccm
|
||||
Linearity 0.129 %
|
||||
Last Cal Date 12/07/2020
|
||||
Last Cal Time 10:35:20
|
||||
Xdcr Filter Code Median
|
||||
Xdcr Typ Residual 108.000
|
||||
Xdcr Zero LL 0.000 cnts
|
||||
Xdcr Zero HL 0.000 cnts
|
||||
Xdcr Zero Lwin 0.000
|
||||
Xdcr Zero Hwin 0.000
|
||||
Xdcr Analog Min 0.000 cnts
|
||||
Xdcr Analog Max 0.000 cnts
|
||||
Xdcr Base Min 0.000
|
||||
Xdcr Base Max 0.000
|
||||
Setpoint Pressure 1 5.800 psig
|
||||
Instrument Pressure 1 5.824 psig
|
||||
Instrument Flow 1 0.038 sccm
|
||||
Master Value 1 0.000 sccm
|
||||
Master Reading 1 0.000 sccm
|
||||
Verify Date 07/12/2022
|
||||
Verify Time 10:54:56
|
||||
|
||||
|
||||
Pressure Transducer
|
||||
===========================================================
|
||||
Transducer CTS D34-441 45PSIA
|
||||
Input AIN 1
|
||||
Setpoint Pressure 1 0.000 psig
|
||||
Analog Value 1 10087020 cnts
|
||||
Master Value 1 0.001 psig
|
||||
XDCR Analog ATM 10086749
|
||||
Atm Pressure -0.000 bar
|
||||
Linearity 0.082 %
|
||||
Last Cal Date 12/07/2020
|
||||
Last Cal Time 09:03:38
|
||||
Xdcr Filter Code Med, J-Filter
|
||||
Xdcr Typ Residual 80.000
|
||||
Xdcr Zero LL 9654557.000 cnts
|
||||
Xdcr Zero HL 10485333.000 cnts
|
||||
Xdcr Zero Lwin -2.501 psig
|
||||
Xdcr Zero Hwin 2.499 psig
|
||||
Xdcr Analog Min 5699952.000 cnts
|
||||
Xdcr Analog Max 15110248.000 cnts
|
||||
Xdcr Base Min -4294967.000
|
||||
Xdcr Base Max 8589935.000
|
||||
Setpoint Pressure 1 0.000 psig
|
||||
Instrument Pressure 1 0.000 psig
|
||||
Master Value 1 0.000 psig
|
||||
Verify Date 07/12/2022
|
||||
Verify Time 08:14:59
|
||||
|
||||
|
||||
Test Port 2
|
||||
===========================================================
|
||||
|
||||
|
||||
Mass Flow Trans
|
||||
===========================================================
|
||||
Transducer Custom
|
||||
Input AIN 4
|
||||
Setpoint Pressure 1 25.000 psig
|
||||
Analog Value 1 8689552 cnts
|
||||
Master Value 1 0.054 sccm
|
||||
Linearity 0.166 %
|
||||
Last Cal Date 12/07/2020
|
||||
Last Cal Time 10:50:52
|
||||
Xdcr Filter Code Median
|
||||
Xdcr Typ Residual 83.000
|
||||
Xdcr Zero LL 0.000 cnts
|
||||
Xdcr Zero HL 0.000 cnts
|
||||
Xdcr Zero Lwin 0.000
|
||||
Xdcr Zero Hwin 0.000
|
||||
Xdcr Analog Min 0.000 cnts
|
||||
Xdcr Analog Max 0.000 cnts
|
||||
Xdcr Base Min 0.000
|
||||
Xdcr Base Max 0.000
|
||||
Setpoint Pressure 1 5.800 psig
|
||||
Instrument Pressure 1 5.780 psig
|
||||
Instrument Flow 1 0.049 sccm
|
||||
Master Value 1 0.000 sccm
|
||||
Master Reading 1 0.000 sccm
|
||||
Verify Date 07/12/2022
|
||||
Verify Time 11:01:54
|
||||
|
||||
|
||||
Pressure Transducer
|
||||
===========================================================
|
||||
Transducer CTS D34-441 45PSIA
|
||||
Input AIN 3
|
||||
Setpoint Pressure 1 0.000 psig
|
||||
Analog Value 1 10050243 cnts
|
||||
Master Value 1 0.001 psig
|
||||
XDCR Analog ATM 10050055
|
||||
Atm Pressure -0.000 bar
|
||||
Linearity 0.082 %
|
||||
Last Cal Date 12/07/2020
|
||||
Last Cal Time 09:11:34
|
||||
Xdcr Filter Code Med, J-Filter
|
||||
Xdcr Typ Residual 59.000
|
||||
Xdcr Zero LL 9654557.000 cnts
|
||||
Xdcr Zero HL 10485333.000 cnts
|
||||
Xdcr Zero Lwin -2.501 psig
|
||||
Xdcr Zero Hwin 2.499 psig
|
||||
Xdcr Analog Min 5699952.000 cnts
|
||||
Xdcr Analog Max 15110248.000 cnts
|
||||
Xdcr Base Min -4294967.000
|
||||
Xdcr Base Max 8589935.000
|
||||
Setpoint Pressure 1 0.000 psig
|
||||
Instrument Pressure 1 -0.000 psig
|
||||
Master Value 1 0.000 psig
|
||||
Verify Date 07/12/2022
|
||||
Verify Time 08:21:53
|
@ -1,15 +1,87 @@
|
||||
const fs = require('fs');
|
||||
import {readFiles} from "../utils/file_utils.js";
|
||||
|
||||
import ParseHardwareCalibration from "../Hardware"
|
||||
|
||||
|
||||
// const file = fs.readFileSync("src/parsers/__tests__/hardware_calibration/hardware_calibration.txt", 'utf8')
|
||||
|
||||
describe("Test for all files", () => {
|
||||
let files = readFiles("src/parsers/__tests__/hardware_calibration/");
|
||||
for (const file of files) {
|
||||
test(`Can parse ${file.name}`, () => {
|
||||
const calibrations = ParseHardwareCalibration(file.content, 0.05);
|
||||
console.log(calibrations)
|
||||
})
|
||||
}
|
||||
let files = readFiles("src/parsers/__tests__/hardware_calibration/");
|
||||
for (const file of files) {
|
||||
test(`Can parse ${file.name}`, () => {
|
||||
const calibrations = ParseHardwareCalibration(file.content, 0.05);
|
||||
console.log(calibrations)
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
describe("Testing proper shape", () => {
|
||||
test("It outputs an array of arrays", () => {
|
||||
const content = fs.readFileSync("src/parsers/__tests__/hardware_calibration/smallest.txt", 'utf8');
|
||||
const calibrations = ParseHardwareCalibration(content, 0.05);
|
||||
expect(calibrations).toEqual(
|
||||
{
|
||||
"Calibration": {
|
||||
"Test Port 1": {
|
||||
"Mass Flow Trans": {
|
||||
"Gauge Reading": [{
|
||||
"Delta": 0,
|
||||
"High Limit": 0,
|
||||
"In Range": false,
|
||||
"Low Limit": 0,
|
||||
"Master Value": 0,
|
||||
"Out Of Tolerance": 0,
|
||||
"Unit": "sccm",
|
||||
"Value": 0
|
||||
}], "Name": "Custom", "Verify Date": "07/12/2022", "Verify Time": "10:54:56"
|
||||
},
|
||||
"Pressure Transducer": {
|
||||
"Gauge Reading": [{
|
||||
"Delta": 2250,
|
||||
"High Limit": 2250,
|
||||
"In Range": false,
|
||||
"Low Limit": -2250,
|
||||
"Master Value": 0,
|
||||
"Out Of Tolerance": 2250,
|
||||
"Unit": "psig",
|
||||
"Value": 0
|
||||
}], "Name": "45PSIA", "Verify Date": "07/12/2022", "Verify Time": "08:14:59"
|
||||
}
|
||||
},
|
||||
"Test Port 2": {
|
||||
"Mass Flow Trans": {
|
||||
"Gauge Reading": [{
|
||||
"Delta": 0,
|
||||
"High Limit": 0,
|
||||
"In Range": false,
|
||||
"Low Limit": 0,
|
||||
"Master Value": 0,
|
||||
"Out Of Tolerance": 0,
|
||||
"Unit": "sccm",
|
||||
"Value": 0
|
||||
}], "Name": "Custom", "Verify Date": "07/12/2022", "Verify Time": "11:01:54"
|
||||
},
|
||||
"Pressure Transducer": {
|
||||
"Gauge Reading": [{
|
||||
"Delta": 2250,
|
||||
"High Limit": 2250,
|
||||
"In Range": false,
|
||||
"Low Limit": -2250,
|
||||
"Master Value": 0,
|
||||
"Out Of Tolerance": 2250,
|
||||
"Unit": "psig",
|
||||
"Value": -0
|
||||
}], "Name": "45PSIA", "Verify Date": "07/12/2022", "Verify Time": "08:21:53"
|
||||
}
|
||||
},
|
||||
},
|
||||
"Instrument": {
|
||||
"Date": "07/12/2022",
|
||||
"Instrument Name": "Chassis2 Adult",
|
||||
"Serial Number": "BBP1736",
|
||||
"Time": "11:31:39"
|
||||
}
|
||||
}
|
||||
);
|
||||
})
|
||||
});
|
@ -15,7 +15,7 @@ describe("Test for all files", () => {
|
||||
expect(transducer).toHaveProperty("Gauge Reading")
|
||||
expect(transducer).not.toHaveProperty("Master Value")
|
||||
|
||||
expect(transducer["Gauge Reading"].length).toBeGreaterThan(1);
|
||||
expect(transducer["Gauge Reading"].length).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -50,6 +50,64 @@ describe("Testing Errors", () => {
|
||||
ParseTransducer(`|| Transducer Verify Report ||\nTRANSDUCER1\n===============================================================\nTransducer 1 CTS D34-442 115FigNewtons`, 0);
|
||||
}
|
||||
expect(e).toThrowError(Error("Unknown Type of Test, do not know unit: FIGNEWTONS"))
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("Testing proper shape", () => {
|
||||
test("It outputs an array of arrays", () => {
|
||||
const content = fs.readFileSync("src/parsers/__tests__/transducer_verify/smallest.txt.txt", 'utf8');
|
||||
const transducers = ParseTransducer(content, 0.05);
|
||||
expect(transducers).toEqual(
|
||||
[
|
||||
{
|
||||
Instrument: {
|
||||
Accuracy: 0.0005,
|
||||
Value: 115,
|
||||
Unit: 'PSIA',
|
||||
'Part Number': 'CTS D34-442',
|
||||
'Limit ABS': 57.5,
|
||||
'Transducer Name': 'Transducer 1',
|
||||
'Transducer Type': 'Pressure',
|
||||
'Verify Date': '07/20/22',
|
||||
'Verify Time': '11:20:26'
|
||||
},
|
||||
'Gauge Reading': [
|
||||
{
|
||||
"Delta": 57.5,
|
||||
"High Limit": 57.5,
|
||||
"In Range": true,
|
||||
"Low Limit": -57.5,
|
||||
"Master Value": 0,
|
||||
"Out Of Tolerance": 0,
|
||||
"Value": 0,
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
Instrument: {
|
||||
Accuracy: 0.0005,
|
||||
Value: 250,
|
||||
Unit: 'SCCM',
|
||||
'Part Number': 'CTS A12-221',
|
||||
'Limit ABS': 125,
|
||||
'Transducer Name': 'Transducer 2',
|
||||
'Transducer Type': 'Flow',
|
||||
'Verify Date': '07/15/21',
|
||||
'Verify Time': '14:55:10'
|
||||
},
|
||||
'Gauge Reading': [
|
||||
{
|
||||
"Delta": 125,
|
||||
"High Limit": 125,
|
||||
"In Range": true,
|
||||
"Low Limit": -125,
|
||||
"Master Value": 0,
|
||||
"Out Of Tolerance": 0,
|
||||
"Value": -0,
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
||||
})
|
||||
});
|
@ -0,0 +1,21 @@
|
||||
|| Transducer Verify Report ||
|
||||
TRANSDUCER1
|
||||
===============================================================
|
||||
Transducer 1 CTS D34-442 115PSIA
|
||||
Setpoint Pressure 1 0.000 psig
|
||||
Instrument Pressure 1 0.000 psig
|
||||
Master Value 1 0.000 psig
|
||||
Verify Date 07/20/22
|
||||
Verify Time 11:20:26
|
||||
|
||||
TRANSDUCER2
|
||||
===============================================================
|
||||
Transducer 2 CTS A12-221 250SCCM
|
||||
Setpoint Pressure 1 20.000 psig
|
||||
Instrument Pressure 1 20.154 psig
|
||||
Instrument Flow 1 -0.082 sccm
|
||||
Master Reading 1 0.000 sccm
|
||||
Master Value 1 0.000 sccm
|
||||
Verify Date 07/15/21
|
||||
Verify Time 14:55:10
|
||||
|
Loading…
Reference in New Issue
Block a user