tests and such

This commit is contained in:
Tyrel Souza 2023-10-13 10:58:08 -04:00
parent a5291031aa
commit cb34c835a6
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E
10 changed files with 4888 additions and 70 deletions

3
benchtop-fe/.babelrc Normal file
View File

@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}

File diff suppressed because it is too large Load Diff

View File

@ -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"
}
}

View File

@ -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>

View File

@ -2,17 +2,15 @@
<div class="flextainer">
<div class="left">
<div class="grid">
<div class="grid-item item card">
<UploadForm @uploadForm="uploadForm" />
</div>
<div class="grid-item item card">
<CustomerForm @customerForm="customerForm" />
</div>
</div>
<div class="grid">
<div class="grid-item item card">
<EnvironmentForm @environmentForm="environmentForm" />
</div>
<div class="grid-item item card">
<UploadForm @uploadForm="uploadForm" />
</div>
</div>
<div class="grid">
<div class="grid-item item card">
<InstrumentForm
v-if="!show_new_instrument"
@ -24,28 +22,28 @@
@newInstrumentForm="newInstrumentForm"
/>
</div>
</div>
<div class="grid-item item card">
<CalibrationDeviceForm
v-if="!show_new_calibration"
@calibrationForm="calibrationForm"
@showNewCalibration="showNewCalibration"
/>
<NewCalibrationDeviceForm
v-if="show_new_calibration"
@newCalibrationForm="newCalibrationForm"
/>
<div class="grid-item item card">
<CalibrationDeviceForm
v-if="!show_new_calibration"
@calibrationForm="calibrationForm"
@showNewCalibration="showNewCalibration"
/>
<NewCalibrationDeviceForm
v-if="show_new_calibration"
@newCalibrationForm="newCalibrationForm"
/>
</div>
</div>
</div>
<div class="right">
<PDF
:upload="upload_form_data"
:customer="customer_form_data"
:environment="environment_form_data"
:instrument="new_instrument_form_data"
:calibration="new_calibration_form_data"
/>
<PDF
:upload="upload_form_data"
:customer="customer_form_data"
:environment="environment_form_data"
:instrument="new_instrument_form_data"
:calibration="new_calibration_form_data"
/>
</div>
</div>
</template>

View File

@ -4,7 +4,8 @@
<table class="table">
<tbody>
<tr>
<td>Report Type
<td>
Report Type
<select
name="report_type"
v-model="report_type"
@ -12,77 +13,78 @@
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)"
/>
As Found
</label>
</div>
<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
ref="doc"
type="file"
style="display: none"
@change="readFile($event)"
/>
ref="doc"
type="file"
style="display: none"
@change="readFile($event)"
/>
</div>
</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>

View File

@ -0,0 +1,7 @@
module.exports = {
// ... other Jest configurations ...
transform: {
'^.+\\.js$': 'babel-jest',
},
};

View File

@ -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;

View File

@ -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)
});

View 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