mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-18 13:39:31 +02:00
Wire gauge calc
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
export default {
|
||||
title: 'American Wire Gauge',
|
||||
columns: [
|
||||
{
|
||||
diameter: {
|
||||
title: 'Diameter',
|
||||
type: 'number',
|
||||
unit: 'mm'
|
||||
}
|
||||
}
|
||||
],
|
||||
data: {
|
||||
'0000': { diameter: 11.684 },
|
||||
'000': { diameter: 10.405 },
|
||||
'00': { diameter: 9.266 },
|
||||
'0': { diameter: 8.251 },
|
||||
'(4/0)': { diameter: 11.684 },
|
||||
'(3/0)': { diameter: 10.405 },
|
||||
'(2/0)': { diameter: 9.266 },
|
||||
'(1/0)': { diameter: 8.251 },
|
||||
'1': { diameter: 7.348 },
|
||||
'2': { diameter: 6.544 },
|
||||
'3': { diameter: 5.827 },
|
||||
'4': { diameter: 5.189 },
|
||||
'5': { diameter: 4.621 },
|
||||
'6': { diameter: 4.115 },
|
||||
'7': { diameter: 3.665 },
|
||||
'8': { diameter: 3.264 },
|
||||
'9': { diameter: 2.906 },
|
||||
'10': { diameter: 2.588 },
|
||||
'11': { diameter: 2.305 },
|
||||
'12': { diameter: 2.053 },
|
||||
'13': { diameter: 1.828 },
|
||||
'14': { diameter: 1.628 },
|
||||
'15': { diameter: 1.45 },
|
||||
'16': { diameter: 1.291 },
|
||||
'17': { diameter: 1.15 },
|
||||
'18': { diameter: 1.024 },
|
||||
'19': { diameter: 0.912 },
|
||||
'20': { diameter: 0.812 },
|
||||
'21': { diameter: 0.723 },
|
||||
'22': { diameter: 0.644 },
|
||||
'23': { diameter: 0.573 },
|
||||
'24': { diameter: 0.511 },
|
||||
'25': { diameter: 0.455 },
|
||||
'26': { diameter: 0.405 },
|
||||
'27': { diameter: 0.361 },
|
||||
'28': { diameter: 0.321 },
|
||||
'29': { diameter: 0.286 },
|
||||
'30': { diameter: 0.255 },
|
||||
'31': { diameter: 0.227 },
|
||||
'32': { diameter: 0.202 },
|
||||
'33': { diameter: 0.18 },
|
||||
'34': { diameter: 0.16 },
|
||||
'35': { diameter: 0.143 },
|
||||
'36': { diameter: 0.127 },
|
||||
'37': { diameter: 0.113 },
|
||||
'38': { diameter: 0.101 },
|
||||
'39': { diameter: 0.0897 },
|
||||
'40': { diameter: 0.0799 }
|
||||
}
|
||||
};
|
@@ -1,3 +1,10 @@
|
||||
export const allDataTables: { [key: string]: { [key: string]: any } } = {
|
||||
'american-wire-gauge': {}
|
||||
import type { DataTable } from '../types';
|
||||
import wiregauge from './wire_gauge';
|
||||
import material_electrical_properties from './material_electrical_properties';
|
||||
|
||||
const allDataTables: { [key: string]: DataTable } = {
|
||||
'wire-gauge': wiregauge,
|
||||
'material-electrical-properties': material_electrical_properties
|
||||
};
|
||||
|
||||
export default allDataTables;
|
||||
|
@@ -10,11 +10,11 @@ export default {
|
||||
}
|
||||
],
|
||||
data: {
|
||||
copper: {
|
||||
resistivity: 1.68e-8
|
||||
Copper: {
|
||||
resistivity_20c: 1.68e-8
|
||||
},
|
||||
aluminum: {
|
||||
resistivity: 2.82e-8
|
||||
Aluminum: {
|
||||
resistivity_20c: 2.82e-8
|
||||
}
|
||||
}
|
||||
};
|
||||
|
75
src/datatables/data/wire_gauge.ts
Normal file
75
src/datatables/data/wire_gauge.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import type { DataTable } from '../types';
|
||||
|
||||
const data: DataTable = {
|
||||
title: 'American Wire Gauge',
|
||||
columns: [
|
||||
{
|
||||
diameter: {
|
||||
title: 'Diameter',
|
||||
type: 'number',
|
||||
unit: 'mm'
|
||||
},
|
||||
area: {
|
||||
title: 'Area',
|
||||
type: 'number',
|
||||
unit: 'mm^2'
|
||||
}
|
||||
}
|
||||
],
|
||||
data: {
|
||||
'0000 AWG': { diameter: 11.684 },
|
||||
'000 AWG': { diameter: 10.405 },
|
||||
'00 AWG': { diameter: 9.266 },
|
||||
'0 AWG': { diameter: 8.251 },
|
||||
'(4/0) AWG': { diameter: 11.684 },
|
||||
'(3/0) AWG': { diameter: 10.405 },
|
||||
'(2/0) AWG': { diameter: 9.266 },
|
||||
'(1/0) AWG': { diameter: 8.251 },
|
||||
'1 AWG': { diameter: 7.348 },
|
||||
'2 AWG': { diameter: 6.544 },
|
||||
'3 AWG': { diameter: 5.827 },
|
||||
'4 AWG': { diameter: 5.189 },
|
||||
'5 AWG': { diameter: 4.621 },
|
||||
'6 AWG': { diameter: 4.115 },
|
||||
'7 AWG': { diameter: 3.665 },
|
||||
'8 AWG': { diameter: 3.264 },
|
||||
'9 AWG': { diameter: 2.906 },
|
||||
'10 AWG': { diameter: 2.588 },
|
||||
'11 AWG': { diameter: 2.305 },
|
||||
'12 AWG': { diameter: 2.053 },
|
||||
'13 AWG': { diameter: 1.828 },
|
||||
'14 AWG': { diameter: 1.628 },
|
||||
'15 AWG': { diameter: 1.45 },
|
||||
'16 AWG': { diameter: 1.291 },
|
||||
'17 AWG': { diameter: 1.15 },
|
||||
'18 AWG': { diameter: 1.024 },
|
||||
'19 AWG': { diameter: 0.912 },
|
||||
'20 AWG': { diameter: 0.812 },
|
||||
'21 AWG': { diameter: 0.723 },
|
||||
'22 AWG': { diameter: 0.644 },
|
||||
'23 AWG': { diameter: 0.573 },
|
||||
'24 AWG': { diameter: 0.511 },
|
||||
'25 AWG': { diameter: 0.455 },
|
||||
'26 AWG': { diameter: 0.405 },
|
||||
'27 AWG': { diameter: 0.361 },
|
||||
'28 AWG': { diameter: 0.321 },
|
||||
'29 AWG': { diameter: 0.286 },
|
||||
'30 AWG': { diameter: 0.255 },
|
||||
'31 AWG': { diameter: 0.227 },
|
||||
'32 AWG': { diameter: 0.202 },
|
||||
'33 AWG': { diameter: 0.18 },
|
||||
'34 AWG': { diameter: 0.16 },
|
||||
'35 AWG': { diameter: 0.143 },
|
||||
'36 AWG': { diameter: 0.127 },
|
||||
'37 AWG': { diameter: 0.113 },
|
||||
'38 AWG': { diameter: 0.101 },
|
||||
'39 AWG': { diameter: 0.0897 },
|
||||
'40 AWG': { diameter: 0.0799 }
|
||||
}
|
||||
};
|
||||
|
||||
for (const key in data.data) {
|
||||
data.data[key].area = Math.PI * data.data[key].diameter ** 2;
|
||||
}
|
||||
|
||||
export default data;
|
@@ -1,17 +1,18 @@
|
||||
import type { DataTable } from './types.ts';
|
||||
import { allDataTables } from './data/index';
|
||||
|
||||
export async function getDataTable(name: string): Promise<DataTable> {
|
||||
const x = await import(`./${name}`);
|
||||
return x.default;
|
||||
const allDataTables = (await import('./data/index')).default;
|
||||
return allDataTables[name];
|
||||
}
|
||||
|
||||
export async function listDataTables(): Promise<{ name: string }[]> {
|
||||
const x: { name: string }[] = [];
|
||||
for (const key in allDataTables) {
|
||||
x.push({ name: key });
|
||||
}
|
||||
return x;
|
||||
/* Used in case later we want any kind of computed extra data */
|
||||
export function dataTableLookup(table: DataTable, key: string): any {
|
||||
return table.data[key];
|
||||
}
|
||||
|
||||
export async function listDataTables(): Promise<{ [name: string]: DataTable }> {
|
||||
const allDataTables = (await import('./data/index')).default;
|
||||
return allDataTables;
|
||||
}
|
||||
|
||||
export { DataTable };
|
||||
|
@@ -4,16 +4,14 @@ Used for calculator presets
|
||||
|
||||
*/
|
||||
export interface DataTable {
|
||||
[key: string]: {
|
||||
title: string;
|
||||
/* A JSON schema properties */
|
||||
columns: {
|
||||
title: string;
|
||||
/* A JSON schema properties */
|
||||
columns: {
|
||||
[key: string]: any;
|
||||
};
|
||||
data: {
|
||||
[key: string]: {
|
||||
[key: string]: any;
|
||||
};
|
||||
data: {
|
||||
[key: string]: {
|
||||
[key: string]: any;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import ohmslaw from './ohms_law';
|
||||
import voltagedropinwire from './wire_voltage_drop';
|
||||
|
||||
export default [ohmslaw];
|
||||
export default [ohmslaw, voltagedropinwire];
|
||||
|
@@ -0,0 +1,59 @@
|
||||
import type { GenericCalcType } from './types';
|
||||
const voltagedropinwire: GenericCalcType = {
|
||||
title: 'Round trip voltage drop in cable',
|
||||
name: 'cable-voltage-drop',
|
||||
formula: 'x = (((p * L) / (A/10**6) ) *2) * I**2',
|
||||
selections: [
|
||||
{
|
||||
title: 'Material',
|
||||
source: 'material-electrical-properties',
|
||||
default: 'Copper',
|
||||
bind: {
|
||||
p: 'resistivity_20c'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: 'Wire Gauge',
|
||||
source: 'wire-gauge',
|
||||
default: '24 AWG',
|
||||
bind: {
|
||||
A: 'area'
|
||||
}
|
||||
}
|
||||
],
|
||||
variables: [
|
||||
{
|
||||
name: 'L',
|
||||
title: 'Length',
|
||||
unit: 'm',
|
||||
default: 1
|
||||
},
|
||||
{
|
||||
name: 'A',
|
||||
title: 'Wire Area',
|
||||
unit: 'mm',
|
||||
default: 1
|
||||
},
|
||||
|
||||
{
|
||||
name: 'I',
|
||||
title: 'Current',
|
||||
unit: 'A',
|
||||
default: 1
|
||||
},
|
||||
{
|
||||
name: 'p',
|
||||
title: 'Resistivity',
|
||||
unit: 'Ω/m3',
|
||||
default: 1
|
||||
},
|
||||
{
|
||||
name: 'x',
|
||||
title: 'Voltage Drop',
|
||||
unit: 'V'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export default voltagedropinwire;
|
||||
|
@@ -18,7 +18,7 @@ import { UpdateField } from '@components/options/ToolOptions';
|
||||
import { InitialValuesType } from './types';
|
||||
import type { GenericCalcType } from './data/types';
|
||||
import type { DataTable } from 'datatables';
|
||||
import { getDataTable } from 'datatables';
|
||||
import { getDataTable, dataTableLookup } from 'datatables';
|
||||
|
||||
import nerdamer from 'nerdamer';
|
||||
import 'nerdamer/Algebra';
|
||||
@@ -77,8 +77,6 @@ export default async function makeTool(
|
||||
currentValues: InitialValuesType,
|
||||
updateFieldFunc: UpdateField<InitialValuesType>
|
||||
) => {
|
||||
const newValsBoundToPreset = { ...valsBoundToPreset };
|
||||
|
||||
const newPresets = { ...currentValues.presets };
|
||||
newPresets[selection] = preset;
|
||||
updateFieldFunc('presets', newPresets);
|
||||
@@ -86,7 +84,7 @@ export default async function makeTool(
|
||||
// Clear old selection
|
||||
for (const key in valsBoundToPreset) {
|
||||
if (valsBoundToPreset[key] === selection) {
|
||||
delete newValsBoundToPreset[key];
|
||||
delete valsBoundToPreset[key];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,13 +92,19 @@ export default async function makeTool(
|
||||
(sel) => sel.title === selection
|
||||
);
|
||||
|
||||
if (preset != '<custom>') {
|
||||
if (preset && preset != '<custom>') {
|
||||
if (selectionData) {
|
||||
for (const key in selectionData.bind) {
|
||||
newValsBoundToPreset[key] = selection;
|
||||
valsBoundToPreset[key] = selection;
|
||||
|
||||
if (currentValues.outputVariable === key) {
|
||||
handleSelectedTargetChange('', updateFieldFunc);
|
||||
}
|
||||
|
||||
updateVarField(
|
||||
key,
|
||||
dataTables[selectionData.source].data[preset][
|
||||
|
||||
dataTableLookup(dataTables[selectionData.source], preset)[
|
||||
selectionData.bind[key]
|
||||
],
|
||||
currentValues,
|
||||
@@ -108,14 +112,11 @@ export default async function makeTool(
|
||||
);
|
||||
}
|
||||
} else {
|
||||
setValsBoundToPreset(newValsBoundToPreset);
|
||||
throw new Error(
|
||||
`Preset "${preset}" is not valid for selection "${selection}"`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
setValsBoundToPreset(newValsBoundToPreset);
|
||||
};
|
||||
|
||||
calcData.variables.forEach((variable) => {
|
||||
@@ -138,13 +139,16 @@ export default async function makeTool(
|
||||
if (selection.default == '<custom>') return;
|
||||
for (const key in selection.bind) {
|
||||
initialValues.vars[key] = {
|
||||
value:
|
||||
dataTables[selection.source].data[selection.default][
|
||||
selection.bind[key]
|
||||
],
|
||||
unit: dataTables[selection.source].cols[selection.bind[key]].unit
|
||||
value: dataTableLookup(
|
||||
dataTables[selection.source],
|
||||
selection.default
|
||||
)[selection.bind[key]],
|
||||
|
||||
unit:
|
||||
dataTables[selection.source].columns[selection.bind[key]]?.unit ||
|
||||
''
|
||||
};
|
||||
valsBoundToPreset[key] = selection.default;
|
||||
valsBoundToPreset[key] = selection.title;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -182,9 +186,12 @@ export default async function makeTool(
|
||||
disablePortal
|
||||
id="combo-box-demo"
|
||||
value={values.presets[preset.title]}
|
||||
options={Object.keys(
|
||||
dataTables[preset.source].data
|
||||
).sort()}
|
||||
options={[
|
||||
'<custom>',
|
||||
...Object.keys(
|
||||
dataTables[preset.source].data
|
||||
).sort()
|
||||
]}
|
||||
sx={{ width: 300 }}
|
||||
onChange={(event, newValue) => {
|
||||
handleSelectedPresetChange(
|
||||
@@ -207,7 +214,7 @@ export default async function makeTool(
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Input Variables',
|
||||
title: 'Variables',
|
||||
component: (
|
||||
<Table>
|
||||
<TableHead>
|
||||
@@ -221,7 +228,7 @@ export default async function makeTool(
|
||||
<TableBody>
|
||||
{calcData.variables.map((variable) => (
|
||||
<TableRow key={variable.name}>
|
||||
<TableCell>{variable.name}</TableCell>
|
||||
<TableCell>{variable.title}</TableCell>
|
||||
<TableCell>
|
||||
<TextFieldWithDesc
|
||||
title={variable.title}
|
||||
@@ -253,6 +260,9 @@ export default async function makeTool(
|
||||
<Radio
|
||||
value={variable.name}
|
||||
checked={values.outputVariable === variable.name}
|
||||
disabled={
|
||||
valsBoundToPreset[variable.name] !== undefined
|
||||
}
|
||||
onClick={() =>
|
||||
handleSelectedTargetChange(
|
||||
variable.name,
|
||||
|
@@ -18,7 +18,7 @@ allGenericCalcs.forEach((x) => {
|
||||
tools.push(
|
||||
defineTool('number', {
|
||||
name: x.title,
|
||||
path: 'generic-calc/x.name',
|
||||
path: 'generic-calc/' + x.name,
|
||||
icon: '',
|
||||
description: '',
|
||||
shortDescription: '',
|
||||
|
Reference in New Issue
Block a user