tests and such
This commit is contained in:
parent
a5291031aa
commit
cb34c835a6
3
benchtop-fe/.babelrc
Normal file
3
benchtop-fe/.babelrc
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"presets": ["@babel/preset-env"]
|
||||
}
|
4679
benchtop-fe/package-lock.json
generated
4679
benchtop-fe/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -19,7 +19,12 @@
|
||||
"vue-html2pdf": "^1.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.23.2",
|
||||
"@vitejs/plugin-vue": "^4.2.3",
|
||||
"@vue/test-utils": "^2.4.1",
|
||||
"@vue/vue3-jest": "^29.2.6",
|
||||
"babel-jest": "^29.7.0",
|
||||
"jest": "^29.7.0",
|
||||
"vite": "^4.4.5"
|
||||
}
|
||||
}
|
||||
|
@ -303,6 +303,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
{{ output() }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -310,6 +313,9 @@ import { ref, defineProps } from "vue";
|
||||
import html2pdf from "html2pdf.js";
|
||||
import BenchTopLogoUrl from "../../assets/BenchTopLogo.png";
|
||||
import Al2pCertUrl from "../../assets/al2pCert.png";
|
||||
|
||||
import parseTransducer from "../../parsers/Transducer"
|
||||
|
||||
const hide = ref(false);
|
||||
|
||||
const props = defineProps({
|
||||
@ -383,9 +389,20 @@ const exportToPDF = () => {
|
||||
html2pdf().from(element).set(opt).save();
|
||||
};
|
||||
|
||||
const dt = (d) => {
|
||||
|
||||
};
|
||||
const output = () => {
|
||||
let content = ""
|
||||
if (props.upload !== undefined && props.upload.files.length > 0) {
|
||||
const acc = props.environment.accuracy
|
||||
content = parseTransducer(props.upload.files[0]["value"], acc)
|
||||
}
|
||||
|
||||
return {
|
||||
"form1": content
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
@ -3,16 +3,14 @@
|
||||
<div class="left">
|
||||
<div class="grid">
|
||||
<div class="grid-item item card">
|
||||
<UploadForm @uploadForm="uploadForm" />
|
||||
<CustomerForm @customerForm="customerForm" />
|
||||
<EnvironmentForm @environmentForm="environmentForm" />
|
||||
</div>
|
||||
<div class="grid-item item card">
|
||||
<CustomerForm @customerForm="customerForm" />
|
||||
<UploadForm @uploadForm="uploadForm" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid">
|
||||
<div class="grid-item item card">
|
||||
<EnvironmentForm @environmentForm="environmentForm" />
|
||||
</div>
|
||||
<div class="grid-item item card">
|
||||
<InstrumentForm
|
||||
v-if="!show_new_instrument"
|
||||
@ -24,7 +22,6 @@
|
||||
@newInstrumentForm="newInstrumentForm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid-item item card">
|
||||
<CalibrationDeviceForm
|
||||
v-if="!show_new_calibration"
|
||||
@ -37,6 +34,7 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
<PDF
|
||||
|
@ -4,7 +4,8 @@
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Report Type
|
||||
<td>
|
||||
Report Type
|
||||
<select
|
||||
name="report_type"
|
||||
v-model="report_type"
|
||||
@ -12,59 +13,66 @@
|
||||
id="id_report_type"
|
||||
>
|
||||
<option value="-" selected>----Select-----</option>
|
||||
<option value="TV">Transducer Verify</option>
|
||||
<option value="HC">Hardware Calibration</option>
|
||||
<option value="Transducer Verify">Transducer Verify</option>
|
||||
<option value="Hardware Calibration">Hardware Calibration</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="report_type != '-' || showUpload">
|
||||
<td>
|
||||
<button class="custom-button" @click="openFileInput" v-if="showUpload">
|
||||
Select First File
|
||||
<button
|
||||
class="custom-button"
|
||||
@click="openFileInput"
|
||||
v-if="showUpload"
|
||||
>
|
||||
Select {{ report_type }} File
|
||||
</button>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="files.length > 0">
|
||||
<td>
|
||||
<ul>
|
||||
<li v-for="(file, index) in files" :key="index" class="file-list">
|
||||
<button class="custom-button red" @click="removeUpload(index)">x</button> {{ file.name }}
|
||||
<div>
|
||||
<label>
|
||||
<button class="custom-button red" @click="removeUpload(index)">
|
||||
X
|
||||
</button>
|
||||
<span>{{ file.name }}</span>
|
||||
<div class="kind btn-group">
|
||||
<input
|
||||
type="radio"
|
||||
class="btn-check"
|
||||
:id="'both_kind_' + index"
|
||||
:name="'kind_' + index"
|
||||
value="both"
|
||||
@change="kindChange('both', file)"
|
||||
/>
|
||||
Both
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
:name="'kind_' + index"
|
||||
value="left"
|
||||
@change="kindChange('left', file)"
|
||||
/>
|
||||
As Left
|
||||
</label>
|
||||
<label>
|
||||
<label class="btn btn-primary" :for="'both_kind_' + index"> Both </label>
|
||||
|
||||
<input
|
||||
type="radio"
|
||||
class="btn-check"
|
||||
:id="'af_kind_' + index"
|
||||
:name="'kind_' + index"
|
||||
value="found"
|
||||
@change="kindChange('found', file)"
|
||||
/>
|
||||
<label class="btn btn-primary" :for="'af_kind_' + index">
|
||||
As Found
|
||||
</label>
|
||||
<input
|
||||
type="radio"
|
||||
class="btn-check"
|
||||
:id="'al_kind_' + index"
|
||||
:name="'kind_' + index"
|
||||
value="left"
|
||||
@change="kindChange('left', file)"
|
||||
/>
|
||||
<label class="btn btn-primary" :for="'al_kind_' + index"> As Left </label>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<input
|
||||
@ -77,12 +85,6 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
/*
|
||||
|
||||
RADIO BUTTONS ARE FUCKED
|
||||
|
||||
|
||||
*/
|
||||
import { ref, computed, watchEffect } from "vue";
|
||||
|
||||
const report_type = ref("-"),
|
||||
@ -94,7 +96,7 @@ const showUpload = computed({
|
||||
get() {
|
||||
/// default select
|
||||
if (report_type.value === "-") {
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
// no more more than 2 files
|
||||
@ -156,3 +158,16 @@ watchEffect(() => {
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding-left: 0;
|
||||
}
|
||||
button {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
.kind {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
|
7
benchtop-fe/src/jest.config.js
Normal file
7
benchtop-fe/src/jest.config.js
Normal file
@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
// ... other Jest configurations ...
|
||||
|
||||
transform: {
|
||||
'^.+\\.js$': 'babel-jest',
|
||||
},
|
||||
};
|
@ -1,20 +1,22 @@
|
||||
inRange = (index, value, masterValues) => {
|
||||
const inRange = (index, value, masterValues) => {
|
||||
return (
|
||||
masterValues[index]["Low Limit"] <= value && value <= masterValues[index]["High Limit"]
|
||||
);
|
||||
}
|
||||
|
||||
delta = (index, value, masterValues) => {
|
||||
const delta = (index, value, masterValues) => {
|
||||
return Math.abs(masterValues[index]["Low Limit"] - value);
|
||||
}
|
||||
|
||||
export default parseTransducer = (content, accuracy) => {
|
||||
export default function parseTransducer(content, accuracy){
|
||||
accuracy = accuracy / 100.0; // Comes in as Percent
|
||||
const transducerData = [];
|
||||
|
||||
// Split the content into sections based on the blank line
|
||||
const sections = content.trim().split("\n\n");
|
||||
|
||||
debugger
|
||||
|
||||
for (const section of sections) {
|
||||
// Split each section into lines
|
||||
const lines = section.trim().split("\n");
|
||||
@ -25,7 +27,7 @@ export default parseTransducer = (content, accuracy) => {
|
||||
|
||||
// Extract the Transducer number and Transducer type
|
||||
const transducerLine = filteredLines.shift().trim();
|
||||
const [, transducerName, partNumber] = transducerLine.split(null, 2);
|
||||
const [_, transducerName, partNumber] = transducerLine.split(null, 2);
|
||||
|
||||
// Get part number and values
|
||||
let value = null;
|
||||
|
@ -0,0 +1,8 @@
|
||||
const fs = require('fs');
|
||||
import parseTransducer from "../Transducer"
|
||||
|
||||
const file = fs.readFileSync("src/parsers/__tests__/transducer_verify.txt", 'utf8')
|
||||
|
||||
test('Check if 1 equals 1', () => {
|
||||
parseTransducer(file, 0.05)
|
||||
});
|
86
benchtop-fe/src/parsers/__tests__/transducer_verify.txt
Normal file
86
benchtop-fe/src/parsers/__tests__/transducer_verify.txt
Normal file
@ -0,0 +1,86 @@
|
||||
|| Transducer Verify Report ||
|
||||
TRANSDUCER1
|
||||
===============================================================
|
||||
Transducer 1 CTS D34-442 115PSIA
|
||||
Setpoint Pressure 1 0.000 psig
|
||||
Setpoint Pressure 2 20.000 psig
|
||||
Setpoint Pressure 3 40.000 psig
|
||||
Setpoint Pressure 4 60.000 psig
|
||||
Setpoint Pressure 5 80.000 psig
|
||||
Setpoint Pressure 6 100.000 psig
|
||||
Instrument Pressure 1 0.000 psig
|
||||
Instrument Pressure 2 20.002 psig
|
||||
Instrument Pressure 3 39.997 psig
|
||||
Instrument Pressure 4 60.010 psig
|
||||
Instrument Pressure 5 80.001 psig
|
||||
Instrument Pressure 6 100.002 psig
|
||||
Master Value 1 0.000 psig
|
||||
Master Value 2 20.000 psig
|
||||
Master Value 3 40.000 psig
|
||||
Master Value 4 60.000 psig
|
||||
Master Value 5 80.000 psig
|
||||
Master Value 6 100.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
|
||||
Setpoint Pressure 2 20.000 psig
|
||||
Setpoint Pressure 3 20.000 psig
|
||||
Setpoint Pressure 4 20.000 psig
|
||||
Setpoint Pressure 5 20.000 psig
|
||||
Setpoint Pressure 6 20.000 psig
|
||||
Setpoint Pressure 7 20.000 psig
|
||||
Setpoint Pressure 8 20.000 psig
|
||||
Setpoint Pressure 9 20.000 psig
|
||||
Setpoint Pressure 10 20.000 psig
|
||||
Setpoint Pressure 11 20.000 psig
|
||||
Instrument Pressure 1 20.154 psig
|
||||
Instrument Pressure 2 20.153 psig
|
||||
Instrument Pressure 3 20.152 psig
|
||||
Instrument Pressure 4 20.150 psig
|
||||
Instrument Pressure 5 20.148 psig
|
||||
Instrument Pressure 6 20.145 psig
|
||||
Instrument Pressure 7 20.144 psig
|
||||
Instrument Pressure 8 20.141 psig
|
||||
Instrument Pressure 9 20.139 psig
|
||||
Instrument Pressure 10 20.138 psig
|
||||
Instrument Pressure 11 20.136 psig
|
||||
Instrument Flow 1 -0.082 sccm
|
||||
Instrument Flow 2 24.802 sccm
|
||||
Instrument Flow 3 49.664 sccm
|
||||
Instrument Flow 4 74.836 sccm
|
||||
Instrument Flow 5 99.416 sccm
|
||||
Instrument Flow 6 125.289 sccm
|
||||
Instrument Flow 7 150.205 sccm
|
||||
Instrument Flow 8 175.290 sccm
|
||||
Instrument Flow 9 200.165 sccm
|
||||
Instrument Flow 10 224.748 sccm
|
||||
Instrument Flow 11 249.825 sccm
|
||||
Master Reading 1 0.000 sccm
|
||||
Master Reading 2 25.000 sccm
|
||||
Master Reading 3 50.000 sccm
|
||||
Master Reading 4 75.000 sccm
|
||||
Master Reading 5 100.000 sccm
|
||||
Master Reading 6 125.000 sccm
|
||||
Master Reading 7 150.000 sccm
|
||||
Master Reading 8 175.000 sccm
|
||||
Master Reading 9 200.000 sccm
|
||||
Master Reading 10 225.000 sccm
|
||||
Master Reading 11 250.000 sccm
|
||||
Master Value 1 0.000 sccm
|
||||
Master Value 2 25.000 sccm
|
||||
Master Value 3 50.000 sccm
|
||||
Master Value 4 75.000 sccm
|
||||
Master Value 5 100.000 sccm
|
||||
Master Value 6 125.000 sccm
|
||||
Master Value 7 150.000 sccm
|
||||
Master Value 8 175.000 sccm
|
||||
Master Value 9 200.000 sccm
|
||||
Master Value 10 225.000 sccm
|
||||
Master Value 11 250.000 sccm
|
||||
Verify Date 07/15/21
|
||||
Verify Time 14:55:10
|
||||
|
Loading…
Reference in New Issue
Block a user