mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Added simple SMD reel calculator.
This commit is contained in:
parent
fe405aae1e
commit
e2ee0df58a
4 changed files with 268 additions and 0 deletions
50
public/img/smd_reel/smd_reel.svg
Normal file
50
public/img/smd_reel/smd_reel.svg
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 900 507" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
|
||||
<g transform="matrix(1.29526,0,0,2.575,-706.721,-1134.75)">
|
||||
<rect x="722.374" y="614.876" width="460.626" height="12.831" style="fill:rgb(232,195,195);stroke:black;stroke-width:1.47px;"/>
|
||||
</g>
|
||||
<g transform="matrix(2.47059,0,0,2.47059,-1589.33,-639.978)">
|
||||
<circle cx="741.941" cy="361.788" r="92.702" style="fill:rgb(232,195,195);stroke:black;stroke-width:1.21px;"/>
|
||||
</g>
|
||||
<g transform="matrix(1.11111,0,0,1.11111,-601.35,-150.274)">
|
||||
<circle cx="760.545" cy="363.713" r="77.947" style="fill:white;stroke:black;stroke-width:2.7px;"/>
|
||||
</g>
|
||||
<g transform="matrix(1.36082,0,0,0.625363,-184.313,-33.9859)">
|
||||
<path d="M263.085,465.076L263.085,485.285L252.767,462.831L263.085,440.377L263.085,460.585L366.907,460.585L366.907,440.377L377.225,462.831L366.907,485.285L366.907,465.076L263.085,465.076Z" style="stroke:black;stroke-width:2.83px;"/>
|
||||
</g>
|
||||
<g transform="matrix(2.2607e-17,0.369201,-0.342857,2.09939e-17,1002.06,349.624)">
|
||||
<path d="M273.618,465.076L273.618,485.285L252.767,462.831L273.618,440.377L273.618,460.585L356.374,460.585L356.374,440.377L377.225,462.831L356.374,485.285L356.374,465.076L273.618,465.076Z" style="stroke:black;stroke-width:8.42px;"/>
|
||||
</g>
|
||||
<g transform="matrix(0.676546,6.16298e-33,-5.6467e-33,0.342857,496.388,266.097)">
|
||||
<path d="M264.146,465.076L264.146,485.285L252.767,462.831L264.146,440.377L264.146,460.585L365.846,460.585L365.846,440.377L377.225,462.831L365.846,485.285L365.846,465.076L264.146,465.076Z" style="stroke:black;stroke-width:5.59px;"/>
|
||||
</g>
|
||||
<g transform="matrix(2.36581,2.77063,-0.364351,0.311115,-334.355,-761.661)">
|
||||
<path d="M255.719,465.076L255.719,485.285L252.767,462.831L255.719,440.377L255.719,460.585L374.273,460.585L374.273,440.377L377.225,462.831L374.273,485.285L374.273,465.076L255.719,465.076Z" style="fill:rgb(245,0,255);stroke:rgb(253,0,255);stroke-width:1.15px;"/>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,-461.743,-125.734)">
|
||||
<text x="721.091px" y="367.241px" style="font-family:'Arial-BoldMT', 'Arial', sans-serif;font-weight:700;font-size:48px;">d0</text>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,138.197,111.084)">
|
||||
<text x="721.091px" y="367.241px" style="font-family:'Arial-BoldMT', 'Arial', sans-serif;font-weight:700;font-size:48px;">a</text>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,-24.9149,40.3543)">
|
||||
<text x="721.091px" y="367.241px" style="font-family:'Arial-BoldMT', 'Arial', sans-serif;font-weight:700;font-size:48px;">b</text>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,-578.889,-246.499)">
|
||||
<text x="721.091px" y="367.241px" style="font-family:'Arial-BoldMT', 'Arial', sans-serif;font-weight:700;font-size:48px;fill:rgb(253,0,255);">d1</text>
|
||||
</g>
|
||||
<rect x="447.599" y="448.763" width="43.981" height="12.405" style="stroke:black;stroke-width:3px;"/>
|
||||
<g transform="matrix(1,0,0,1,70.1433,0.721732)">
|
||||
<rect x="447.599" y="448.763" width="43.981" height="12.405" style="stroke:black;stroke-width:3px;"/>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,135.325,0)">
|
||||
<rect x="447.599" y="448.763" width="43.981" height="12.405" style="stroke:black;stroke-width:3px;"/>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,203.889,0)">
|
||||
<rect x="447.599" y="448.763" width="43.981" height="12.405" style="stroke:black;stroke-width:3px;"/>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,280.393,0)">
|
||||
<rect x="447.599" y="448.763" width="43.981" height="12.405" style="stroke:black;stroke-width:3px;"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.9 KiB |
26
src/Controller/ToolsController.php
Normal file
26
src/Controller/ToolsController.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
/**
|
||||
* @Route("/tools")
|
||||
* @package App\Controller
|
||||
*/
|
||||
class ToolsController extends AbstractController
|
||||
{
|
||||
|
||||
/**
|
||||
* @Route("/reel_calc", name="tools_reel_calculator")
|
||||
* @return Response
|
||||
*/
|
||||
public function reelCalculator() : Response
|
||||
{
|
||||
return $this->render("Tools/ReelCalculator/main.html.twig");
|
||||
}
|
||||
}
|
126
templates/Tools/ReelCalculator/main.html.twig
Normal file
126
templates/Tools/ReelCalculator/main.html.twig
Normal file
|
@ -0,0 +1,126 @@
|
|||
{% extends "main_card.html.twig" %}
|
||||
|
||||
{% block title %}{% trans %}tools.reel_calc.title{% endtrans %}{% endblock %}
|
||||
|
||||
{% block card_title %}
|
||||
<i class="fas fa-ruler"></i> {% trans %}tools.reel_calc.title{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block card_content %}
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<img src="{{ asset('img/smd_reel/smd_reel.svg') }}" alt="Sizes explanation" class="img-fluid img-thumbnail">
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<div class="form-group row">
|
||||
<label for="reel_dia_inner" class="col-sm-4 col-form-label">{% trans %}tools.reel_calc.inner_dia{% endtrans %} <var>d<sub>0</sub></var>:</label>
|
||||
<div class="col-sm-8 input-group">
|
||||
<input class="form-control" id="reel_dia_inner" value="60" type="number" min="0">
|
||||
<div class="input-group-append">
|
||||
<span class="input-group-text">mm</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="reel_dia_outer" class="col-sm-4 col-form-label">{% trans %}tools.reel_calc.outer_dia{% endtrans %} <var>d<sub>1</sub></var>:</label>
|
||||
<div class="col-sm-8 input-group">
|
||||
<input class="form-control" id="reel_dia_outer" type="number" min="0">
|
||||
<div class="input-group-append">
|
||||
<span class="input-group-text">mm</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="reel_tape_thick" class="col-sm-4 col-form-label">{% trans %}tools.reel_calc.tape_thick{% endtrans %} <var>a</var>:</label>
|
||||
<div class="col-sm-8 input-group">
|
||||
<input class="form-control" id="reel_tape_thick" type="number" min="0,8" value="0.6">
|
||||
<div class="input-group-append">
|
||||
<span class="input-group-text">mm</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label for="reel_part_distance" class="col-sm-4 col-form-label">{% trans %}tools.reel_calc.part_distance{% endtrans %} <var>b</var>:</label>
|
||||
<div class="col-sm-8 input-group">
|
||||
<input class="form-control" id="reel_part_distance" value="4" type="number" min="0">
|
||||
<div class="input-group-append">
|
||||
<span class="input-group-text">mm</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-8 offset-sm-4 input-group">
|
||||
<button type="button" onclick="updateReelCalc()" class="btn btn-primary">{% trans %}tools.reel_calc.update{% endtrans %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="reel_part_distance" class="col-sm-4 col-form-label">{% trans %}tools.reel_calc.parts_per_meter{% endtrans %}:</label>
|
||||
<div class="col-sm-8 input-group">
|
||||
<span class="form-control-plaintext" id="result_parts_per_meter"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="reel_part_distance" class="col-sm-4 col-form-label">{% trans %}tools.reel_calc.result_length{% endtrans %}:</label>
|
||||
<div class="col-sm-8 input-group">
|
||||
<span class="form-control-plaintext" id="result_length"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label for="reel_part_distance" class="col-sm-4 col-form-label">{% trans %}tools.reel_calc.result_amount{% endtrans %}:</label>
|
||||
<div class="col-sm-8 input-group">
|
||||
<span class="form-control-plaintext" id="result_amount"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
function updateReelCalc() {
|
||||
var dia_inner = document.getElementById('reel_dia_inner').value;
|
||||
var dia_outer = document.getElementById('reel_dia_outer').value;
|
||||
var tape_thickness = document.getElementById('reel_tape_thick').value;
|
||||
var part_distance = document.getElementById('reel_part_distance').value;
|
||||
|
||||
if (dia_inner == "" || dia_outer == "" || tape_thickness == "") {
|
||||
bootbox.alert("{% trans %}tools.reel_calc.missing_values.error{% endtrans %}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (dia_outer**dia_outer < dia_inner**dia_inner) {
|
||||
bootbox.alert("{% trans %}tools.reel_calc.outer_greater_inner_error{% endtrans %}");
|
||||
return;
|
||||
}
|
||||
|
||||
var length = Math.PI * (dia_outer * dia_outer - dia_inner * dia_inner ) / (4 * tape_thickness);
|
||||
|
||||
var legth_formatted = length.toFixed(2) + ' mm';
|
||||
|
||||
if (length > 1000) {
|
||||
length_formatted = (length / 1000).toFixed(2) + ' m';
|
||||
} else if (length > 10) {
|
||||
length_formatted = (length / 10).toFixed(2) + ' cm';
|
||||
}
|
||||
|
||||
document.getElementById('result_length').textContent = length_formatted;
|
||||
|
||||
//Skip if no part_distance was given
|
||||
if (part_distance == "" || part_distance == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var parts_per_meter = 1 / (part_distance / 1000);
|
||||
|
||||
document.getElementById('result_parts_per_meter').textContent = parts_per_meter.toFixed(2) + ' 1/m';
|
||||
|
||||
var parts_amount = (length/1000) * parts_per_meter;
|
||||
|
||||
document.getElementById('result_amount').textContent = Math.floor(parts_amount);
|
||||
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -9225,5 +9225,71 @@ Element 3</target>
|
|||
<target>File extension not allowed for this attachment type.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="Wqa3lsL" name="tools.reel_calc.title">
|
||||
<segment>
|
||||
<source>tools.reel_calc.title</source>
|
||||
<target>SMD Reel calculator</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="mdO7lU4" name="tools.reel_calc.inner_dia">
|
||||
<segment>
|
||||
<source>tools.reel_calc.inner_dia</source>
|
||||
<target>Inner diameter</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="y9vRCcc" name="tools.reel_calc.outer_dia">
|
||||
<segment>
|
||||
<source>tools.reel_calc.outer_dia</source>
|
||||
<target>Outer diameter</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="BjeRVFq" name="tools.reel_calc.tape_thick">
|
||||
<segment>
|
||||
<source>tools.reel_calc.tape_thick</source>
|
||||
<target>Tape thickness</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="ip4Wa3T" name="tools.reel_calc.part_distance">
|
||||
<segment>
|
||||
<source>tools.reel_calc.part_distance</source>
|
||||
<target>Part distance</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="Ysn3sXm" name="tools.reel_calc.update">
|
||||
<segment>
|
||||
<source>tools.reel_calc.update</source>
|
||||
<target>Update</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="epp3lk7" name="tools.reel_calc.parts_per_meter">
|
||||
<segment>
|
||||
<source>tools.reel_calc.parts_per_meter</source>
|
||||
<target>Parts per meter</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="3R0ANJW" name="tools.reel_calc.result_length">
|
||||
<segment>
|
||||
<source>tools.reel_calc.result_length</source>
|
||||
<target>Tape length</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="SvtCM.I" name="tools.reel_calc.result_amount">
|
||||
<segment>
|
||||
<source>tools.reel_calc.result_amount</source>
|
||||
<target>Approx. parts count</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="wwAQjbO" name="tools.reel_calc.outer_greater_inner_error">
|
||||
<segment>
|
||||
<source>tools.reel_calc.outer_greater_inner_error</source>
|
||||
<target>Error: Outer diameter must be greater than inner diameter!</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="t3mMhMS" name="tools.reel_calc.missing_values.error">
|
||||
<segment>
|
||||
<source>tools.reel_calc.missing_values.error</source>
|
||||
<target>Please fill in all values!</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue