Spaces:
Running

calc / index.html
emeryassis's picture
arrumar isto: placeholder="Ex: 0.2" step="0.1" value="0.2" > esta aparente - Follow Up Deployment
6398a1a verified
Raw History Blame Contribute Delete
23.9 kB
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculadora de Potência Óptica - FTTH</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.fade-in {
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.input-highlight {
transition: all 0.3s ease;
box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.input-highlight:focus {
box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
border-color: #34d399;
}
.input-highlight:hover {
border-color: #4b5563;
}
</style>
</head>
<body class="bg-gray-900 min-h-screen text-gray-100">
<div class="container mx-auto px-4 py-8 max-w-4xl">
<!-- Header -->
<header class="text-center mb-10 fade-in">
<h1 class="text-3xl md:text-4xl font-bold text-green-400 mb-2">
<i class="fas fa-fiber-optic mr-2"></i>Calculadora FTTH
</h1>
<p class="text-gray-600 text-lg">Calcule a potência óptica em redes de fibra óptica</p>
<div class="w-20 h-1 bg-indigo-500 mx-auto mt-4 rounded-full"></div>
</header>
<!-- Calculator Card -->
<div class="bg-gray-800 rounded-xl shadow-lg shadow-green-500/10 overflow-hidden fade-in">
<div class="flex flex-col md:flex-row">
<!-- Input Section -->
<div class="w-full md:w-1/2 p-6 bg-gradient-to-br from-gray-800 to-gray-900 border-r border-gray-700">
<h2 class="text-xl font-semibold text-green-400 mb-4 flex items-center">
<i class="fas fa-calculator mr-2 text-green-400"></i> Parâmetros de Entrada
</h2>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1" for="transmitterPower">
Potência do Transmissor (dBm)
</label>
<div class="relative">
<input
id="transmitterPower"
type="number"
class="input-highlight w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-400 text-gray-100"
placeholder="Ex: 3"
step="0.01"
value="3"
>
<div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-gray-400">
dBm
</div>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1" for="fiberLength">
Comprimento da Fibra (km)
</label>
<div class="relative">
<input
id="fiberLength"
type="number"
class="input-highlight w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-400 text-gray-100"
placeholder="Ex: 10"
step="0.1"
value="10"
>
<div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-gray-400">
km
</div>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1" for="attenuation">
Atenuação da Fibra (dB/km)
</label>
<div class="relative">
<input
id="attenuation"
type="number"
class="input-highlight w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-400 text-gray-100"
placeholder="Ex: 0.35"
step="0.01"
value="0.35"
>
<div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-gray-400">
dB/km
</div>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1" for="connectors">
Número de Conectores
</label>
<input
id="connectors"
type="number"
class="input-highlight w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-400 text-gray-100 transition-all hover:border-gray-500"
placeholder="Ex: 2"
value="2"
>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1" for="connectorLoss">
Perda por Conector (dB)
</label>
<div class="relative">
<input
id="connectorLoss"
type="number"
class="input-highlight w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-400 text-gray-100"
placeholder="Ex: 0.5"
step="0.1"
value="0.5"
>
<div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-gray-400">
dB
</div>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1" for="splices">
Número de Emendas
</label>
<input
id="splices"
type="number"
class="input-highlight w-full px-4 py-2 bg-gray-800 border border-gray-700 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-400 text-gray-100 transition-all hover:border-gray-500"
placeholder="Ex: 3"
value="3"
>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1" for="spliceLoss">
Perda por Emenda (dB)
</label>
<div class="relative">
<input
id="spliceLoss"
type="number"
class="input-highlight w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-400 text-gray-100"
placeholder="Ex: 0.2"
step="0.1"
value="0.2"
>
<div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-gray-400">
dB
</div>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1" for="systemMargin">
Margem do Sistema (dB)
</label>
<div class="relative">
<input
id="systemMargin"
type="number"
class="input-highlight w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-green-400 text-gray-100"
placeholder="Ex: 3"
step="0.1"
value="3"
>
<div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none text-gray-400">
dB
</div>
</div>
</div>
</div>
<button
id="calculateBtn"
class="mt-6 w-full bg-green-600 hover:bg-green-700 text-gray-900 font-medium py-2 px-4 rounded-lg transition duration-300 flex items-center justify-center hover:shadow-lg hover:shadow-green-500/20"
>
<i class="fas fa-calculator mr-2"></i> Calcular Potência
</button>
</div>
<!-- Results Section -->
<div class="w-full md:w-1/2 p-6">
<h2 class="text-xl font-semibold text-green-400 mb-4 flex items-center">
<i class="fas fa-chart-line mr-2 text-green-400"></i> Resultados
</h2>
<div class="space-y-4" id="results">
<div class="text-center py-10">
<i class="fas fa-lightbulb text-4xl text-yellow-300 mb-3"></i>
<p class="text-gray-500">Insira os parâmetros e clique em "Calcular Potência" para ver os resultados</p>
</div>
</div>
<div class="mt-6 bg-green-900/30 border-l-4 border-green-400 p-4 rounded hidden" id="warningBox">
<div class="flex">
<div class="flex-shrink-0">
<i class="fas fa-exclamation-triangle text-green-400 mt-1"></i>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-green-400">Atenção</h3>
<div class="mt-2 text-sm text-green-300">
<p id="warningText">A potência no receptor está abaixo dos níveis recomendados para uma conexão estável.</p>
</div>
</div>
</div>
</div>
<div class="mt-6 bg-gray-700 p-4 rounded-lg">
<h4 class="font-medium text-green-400 mb-2 flex items-center">
<i class="fas fa-info-circle mr-2 text-green-400"></i> Referências
</h4>
<ul class="text-sm text-gray-300 space-y-1">
<li><span class="font-medium">GPON</span>: -8 dBm a -27 dBm (Receptor)</li>
<li><span class="font-medium">XG-PON</span>: -13 dBm a -28 dBm (Receptor)</li>
<li><span class="font-medium">Margem de Sistema</span>: 3-6 dB recomendado</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Explanation Section -->
<div class="mt-10 bg-gray-800 rounded-xl shadow-lg shadow-green-500/10 overflow-hidden fade-in">
<div class="p-6">
<h2 class="text-xl font-semibold text-green-400 mb-4 flex items-center">
<i class="fas fa-book-open mr-2 text-green-400"></i> Sobre o Cálculo
</h2>
<div class="prose prose-invert max-w-none">
<p class="text-gray-300">
A potência óptica no receptor em redes FTTH (Fiber To The Home) é calculada considerando vários fatores de perda ao longo do enlace óptico.
</p>
<h3 class="text-lg font-medium text-gray-800 mt-4">Fórmula Utilizada</h3>
<div class="bg-gray-700 p-4 rounded-lg overflow-x-auto">
<code class="text-sm text-green-400">
P<sub>R</sub> = P<sub>T</sub> - (α × L) - (N<sub>c</sub> × γ<sub>c</sub>) - (N<sub>s</sub> × γ<sub>s</sub>) - M<sub>sys</sub>
</code>
</div>
<h3 class="text-lg font-medium text-gray-800 mt-4">Onde:</h3>
<ul class="text-gray-300 space-y-1 pl-5 list-disc">
<li><strong>P<sub>R</sub></strong>: Potência no receptor (dBm)</li>
<li><strong>P<sub>T</sub></strong>: Potência do transmissor (dBm)</li>
<li><strong>α</strong>: Atenuação da fibra (dB/km)</li>
<li><strong>L</strong>: Comprimento do enlace (km)</li>
<li><strong>N<sub>c</sub></strong>: Número de conectores</li>
<li><strong>γ<sub>c</sub></strong>: Perda por conector (dB)</li>
<li><strong>N<sub>s</sub></strong>: Número de emendas</li>
<li><strong>γ<sub>s</sub></strong>: Perda por emenda (dB)</li>
<li><strong>M<sub>sys</sub></strong>: Margem do sistema (dB)</li>
</ul>
<h3 class="text-lg font-medium text-gray-800 mt-4">Considerações</h3>
<p class="text-gray-600">
Valores típicos de atenuação para fibras monomodo são de 0.35 dB/km em 1310 nm e 0.25 dB/km em 1550 nm. Perdas em conectores variam entre 0.2 dB a 0.75 dB, dependendo da qualidade.
</p>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Calculate button click handler
document.getElementById('calculateBtn').addEventListener('click', calculatePower);
// Also calculate when pressing Enter in any input
const inputs = document.querySelectorAll('input');
inputs.forEach(input => {
input.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
calculatePower();
}
});
});
function calculatePower() {
// Get input values
const transmitterPower = parseFloat(document.getElementById('transmitterPower').value);
const fiberLength = parseFloat(document.getElementById('fiberLength').value);
const attenuation = parseFloat(document.getElementById('attenuation').value);
const connectors = parseInt(document.getElementById('connectors').value);
const connectorLoss = parseFloat(document.getElementById('connectorLoss').value);
const splices = parseInt(document.getElementById('splices').value);
const spliceLoss = parseFloat(document.getElementById('spliceLoss').value);
const systemMargin = parseFloat(document.getElementById('systemMargin').value);
// Validate inputs
if (isNaN(transmitterPower) || isNaN(fiberLength) || isNaN(attenuation) ||
isNaN(connectors) || isNaN(connectorLoss) || isNaN(splices) ||
isNaN(spliceLoss) || isNaN(systemMargin)) {
alert('Por favor, preencha todos os campos com valores numéricos válidos.');
return;
}
// Calculate power budget
const fiberLoss = attenuation * fiberLength;
const totalConnectorLoss = connectors * connectorLoss;
const totalSpliceLoss = splices * spliceLoss;
const receivedPower = transmitterPower - fiberLoss - totalConnectorLoss - totalSpliceLoss - systemMargin;
const totalLoss = fiberLoss + totalConnectorLoss + totalSpliceLoss + systemMargin;
// Display results
const resultsHTML = `
<div class="grid grid-cols-1 gap-4">
<div class="bg-gray-700 p-4 rounded-lg border border-gray-600">
<div class="flex justify-between items-center">
<span class="text-sm font-medium text-gray-700">Potência no Receptor:</span>
<span class="text-lg font-bold ${receivedPower > -27 ? 'text-green-600' : 'text-red-600'}">${receivedPower.toFixed(2)} dBm</span>
</div>
<div class="w-full bg-gray-200 rounded-full h-2.5 mt-2">
<div class="bg-gradient-to-r from-green-400 ${receivedPower > -8 ? 'via-yellow-400 to-red-600' : 'to-green-600'}"
style="width: ${Math.min(Math.max(0, (27 + receivedPower) / 35 * 100), 100)}%"></div>
</div>
<div class="flex justify-between text-xs text-gray-500 mt-1">
<span>-27 dBm</span>
<span>-8 dBm</span>
</div>
</div>
<div class="bg-white border border-gray-200 rounded-lg p-4">
<div class="space-y-2">
<div class="flex justify-between">
<span class="text-sm text-gray-600">Perda na Fibra (${attenuation} dB/km × ${fiberLength} km):</span>
<span class="text-sm font-medium">${fiberLoss.toFixed(2)} dB</span>
</div>
<div class="flex justify-between">
<span class="text-sm text-gray-600">Perda em Conectores (${connectors} × ${connectorLoss} dB):</span>
<span class="text-sm font-medium">${totalConnectorLoss.toFixed(2)} dB</span>
</div>
<div class="flex justify-between">
<span class="text-sm text-gray-600">Perda em Emendas (${splices} × ${spliceLoss} dB):</span>
<span class="text-sm font-medium">${totalSpliceLoss.toFixed(2)} dB</span>
</div>
<div class="flex justify-between">
<span class="text-sm text-gray-600">Margem do Sistema:</span>
<span class="text-sm font-medium">${systemMargin.toFixed(2)} dB</span>
</div>
<div class="border-t border-gray-200 my-1"></div>
<div class="flex justify-between">
<span class="text-sm text-gray-600 font-medium">Perda Total:</span>
<span class="text-sm font-bold">${totalLoss.toFixed(2)} dB</span>
</div>
</div>
</div>
<div class="bg-blue-50 p-3 rounded-lg flex items-start">
<i class="fas fa-info-circle text-blue-400 mt-1 mr-3"></i>
<div>
<p class="text-sm text-gray-700">
Essa potência é ${receivedPower > -27 ? 'adequada' : 'insuficiente'} para GPON na faixa de ${transmitterPower > 0 ? 'downlink' : 'uplink'}.
</p>
</div>
</div>
</div>
`;
document.getElementById('results').innerHTML = resultsHTML;
// Show warning if power is too low
const warningBox = document.getElementById('warningBox');
const warningText = document.getElementById('warningText');
if (receivedPower < -27) {
warningText.textContent = "A potência no receptor está abaixo dos níveis recomendados para uma conexão estável (-27 dBm). Considere reduzir o comprimento da fibra ou usar um transmissor mais potente.";
warningBox.classList.remove('hidden');
} else if (receivedPower > -8) {
warningText.textContent = "A potência no receptor está acima dos níveis recomendados (-8 dBm). Isso pode saturar o receptor. Considere usar um atenuador óptico.";
warningBox.classList.remove('hidden');
} else {
warningBox.classList.add('hidden');
}
}
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=emeryassis/calc" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>