fiberhome: fix ver sinal
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
41a8d1b6c5
commit
d037dc2f86
2 files changed
+121
-12
No files matched your search
+34
-12
@@ -663,27 +663,49 @@ class FiberhomeManager {
|
|||||||
|
|
||||||
// Processar LST-OMDDM (potência ótica)
|
// Processar LST-OMDDM (potência ótica)
|
||||||
if (resposta.comando && resposta.comando.includes('LST-OMDDM')) {
|
if (resposta.comando && resposta.comando.includes('LST-OMDDM')) {
|
||||||
// Buscar pela tabela de potência ótica no formato visto
|
// Buscar pela tabela de potência ótica no formato do manual TL1
|
||||||
|
// Formato: ONUID RxPower RxPowerR TxPower TxPowerR CurrTxBias CurrTxBiasR
|
||||||
|
// Temperature TemperatureR Voltage VoltageR PTxPower PRxPower
|
||||||
|
// Onde:
|
||||||
|
// - RxPower (índice 1) = Sinal recebido pela OLT (ONU → OLT)
|
||||||
|
// - PRxPower (índice 12) = Sinal recebido pela ONU (OLT → ONU) - Este é mostrado no UNM2000
|
||||||
const linhasTabela = dados.split('\n').filter(linha =>
|
const linhasTabela = dados.split('\n').filter(linha =>
|
||||||
linha.includes('\t') &&
|
linha.includes('\t') &&
|
||||||
!linha.includes('ONUID\tRxPower') && // header
|
!linha.includes('ONUID\tRxPower') && // header
|
||||||
linha.match(/--\t[+-]?\d+[,.]?\d*/) // linha com dados
|
linha.match(/[+-]?\d+[,.]?\d*/) // linha com dados
|
||||||
);
|
);
|
||||||
|
|
||||||
if (linhasTabela.length > 0) {
|
if (linhasTabela.length > 0) {
|
||||||
// Formato: ONUID RxPower RxPowerR TxPower TxPowerR ...
|
|
||||||
// Exemplo: -- -19,94 Normal 5,16 High 11,70 Normal ...
|
|
||||||
const campos = linhasTabela[0].split('\t');
|
const campos = linhasTabela[0].split('\t');
|
||||||
if (campos.length >= 4) {
|
this.logger.debug(`📊 LST-OMDDM campos extraídos: ${campos.length} campos`, campos);
|
||||||
const rxPower = campos[1]?.replace(',', '.');
|
|
||||||
const txPower = campos[3]?.replace(',', '.');
|
|
||||||
|
|
||||||
if (rxPower && rxPower !== '--' && !isNaN(parseFloat(rxPower))) {
|
// RxPower (ONU → OLT) - índice 1
|
||||||
resultado.rxPower = `${rxPower} dBm`;
|
const rxPowerOlt = campos[1]?.replace(',', '.').trim();
|
||||||
}
|
// TxPower (OLT → ONU transmitido pela OLT) - índice 3
|
||||||
if (txPower && txPower !== '--' && !isNaN(parseFloat(txPower))) {
|
const txPowerOlt = campos[3]?.replace(',', '.').trim();
|
||||||
resultado.txPower = `${txPower} dBm`;
|
// PTxPower (ONU → OLT transmitido pela ONU) - índice 11
|
||||||
|
const ptxPower = campos[11]?.replace(',', '.').trim();
|
||||||
|
// PRxPower (OLT → ONU recebido pela ONU) - índice 12 - ESTE É O CORRETO!
|
||||||
|
const prxPower = campos[12]?.replace(',', '.').trim();
|
||||||
|
|
||||||
|
// Usar PRxPower como RX principal (sinal que a ONU recebe da OLT)
|
||||||
|
if (prxPower && prxPower !== '--' && !isNaN(parseFloat(prxPower))) {
|
||||||
|
resultado.rxPower = `${prxPower} dBm`;
|
||||||
|
this.logger.debug(`✅ RX Power da ONU (PRxPower): ${prxPower} dBm`);
|
||||||
|
} else if (rxPowerOlt && rxPowerOlt !== '--' && !isNaN(parseFloat(rxPowerOlt))) {
|
||||||
|
// Fallback para RxPower se PRxPower não estiver disponível
|
||||||
|
resultado.rxPower = `${rxPowerOlt} dBm`;
|
||||||
|
this.logger.debug(`⚠️ Usando RxPower da OLT como fallback: ${rxPowerOlt} dBm`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Usar PTxPower como TX principal (sinal que a ONU transmite para a OLT)
|
||||||
|
if (ptxPower && ptxPower !== '--' && !isNaN(parseFloat(ptxPower))) {
|
||||||
|
resultado.txPower = `${ptxPower} dBm`;
|
||||||
|
this.logger.debug(`✅ TX Power da ONU (PTxPower): ${ptxPower} dBm`);
|
||||||
|
} else if (txPowerOlt && txPowerOlt !== '--' && !isNaN(parseFloat(txPowerOlt))) {
|
||||||
|
// Fallback para TxPower se PTxPower não estiver disponível
|
||||||
|
resultado.txPower = `${txPowerOlt} dBm`;
|
||||||
|
this.logger.debug(`⚠️ Usando TxPower da OLT como fallback: ${txPowerOlt} dBm`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/**
|
||||||
|
* Teste para validar a correção do RX Power das ONUs FiberHome
|
||||||
|
*
|
||||||
|
* Problema: Bot mostrava -23.02 dBm, mas UNM2000 mostrava -20.22 dBm
|
||||||
|
* Causa: O bot estava usando RxPower (sinal na OLT) ao invés de PRxPower (sinal na ONU)
|
||||||
|
* Solução: Extrair PRxPower (coluna 12) do comando LST-OMDDM
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Simular resposta do comando LST-OMDDM conforme o manual
|
||||||
|
const respostaSimulada = `
|
||||||
|
FH_10.78.20.120 2024-02-10 14:30:00
|
||||||
|
M CTAG COMPLD
|
||||||
|
total_blocks=1
|
||||||
|
block_number=1
|
||||||
|
block_records=1
|
||||||
|
|
||||||
|
List of Optical Power Info
|
||||||
|
----------------------------------------------------------
|
||||||
|
ONUID RxPower RxPowerR TxPower TxPowerR CurrTxBias CurrTxBiasR Temperature TemperatureR Voltage VoltageR PTxPower PRxPower
|
||||||
|
5 -23.02 Normal 1.76 Normal 15.80 Normal 62.37 Normal 3.40 Normal 1.85 -20.22
|
||||||
|
-----------------------------------------------------------
|
||||||
|
`;
|
||||||
|
|
||||||
|
console.log('🧪 Teste de Extração do RX Power Correto\n');
|
||||||
|
console.log('=' .repeat(60));
|
||||||
|
|
||||||
|
// Processar resposta
|
||||||
|
const linhasTabela = respostaSimulada.split('\n').filter(linha =>
|
||||||
|
linha.includes('\t') &&
|
||||||
|
!linha.includes('ONUID\tRxPower') && // header
|
||||||
|
linha.match(/[+-]?\d+[,.]?\d*/) // linha com dados
|
||||||
|
);
|
||||||
|
|
||||||
|
if (linhasTabela.length > 0) {
|
||||||
|
const campos = linhasTabela[0].split('\t');
|
||||||
|
|
||||||
|
console.log(`\n📊 Total de campos extraídos: ${campos.length}`);
|
||||||
|
console.log('\nCampos encontrados:');
|
||||||
|
campos.forEach((campo, idx) => {
|
||||||
|
console.log(` [${idx}]: "${campo}"`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Extrair valores conforme manual TL1
|
||||||
|
const onuId = campos[0]?.trim();
|
||||||
|
const rxPowerOlt = campos[1]?.replace(',', '.').trim(); // Sinal ONU → OLT (recebido pela OLT)
|
||||||
|
const rxPowerStatus = campos[2]?.trim();
|
||||||
|
const txPowerOlt = campos[3]?.replace(',', '.').trim(); // Sinal OLT → ONU (transmitido pela OLT)
|
||||||
|
const ptxPower = campos[11]?.replace(',', '.').trim(); // Sinal ONU → OLT (transmitido pela ONU)
|
||||||
|
const prxPower = campos[12]?.replace(',', '.').trim(); // Sinal OLT → ONU (recebido pela ONU) ⭐
|
||||||
|
|
||||||
|
console.log('\n' + '='.repeat(60));
|
||||||
|
console.log('📡 VALORES EXTRAÍDOS:');
|
||||||
|
console.log('='.repeat(60));
|
||||||
|
console.log(`ONU ID: ${onuId}`);
|
||||||
|
console.log(`\n🔴 ANTIGO (INCORRETO):`);
|
||||||
|
console.log(` RxPower (OLT recebe): ${rxPowerOlt} dBm - Status: ${rxPowerStatus}`);
|
||||||
|
console.log(` TxPower (OLT envia): ${txPowerOlt} dBm`);
|
||||||
|
|
||||||
|
console.log(`\n🟢 NOVO (CORRETO):`);
|
||||||
|
console.log(` PRxPower (ONU recebe): ${prxPower} dBm ⭐ <- Mostrado no UNM2000`);
|
||||||
|
console.log(` PTxPower (ONU envia): ${ptxPower} dBm`);
|
||||||
|
|
||||||
|
console.log('\n' + '='.repeat(60));
|
||||||
|
console.log('✅ RESULTADO ESPERADO:');
|
||||||
|
console.log('='.repeat(60));
|
||||||
|
console.log(`Bot deve mostrar: 📡 RX Power: ${prxPower} dBm`);
|
||||||
|
console.log(`UNM2000 mostra: 📡 RX Power: -20.22 dBm`);
|
||||||
|
console.log(`\n${prxPower === '-20.22' ? '✅ VALORES COMPATÍVEIS!' : '❌ VALORES DIFERENTES'}`);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log('❌ Nenhuma linha de dados encontrada');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('\n' + '='.repeat(60));
|
||||||
|
console.log('📖 REFERÊNCIA DO MANUAL:');
|
||||||
|
console.log('='.repeat(60));
|
||||||
|
console.log('Comando: LST-OMDDM');
|
||||||
|
console.log('Formato de saída:');
|
||||||
|
console.log(' ONUID RxPower RxPowerR TxPower TxPowerR CurrTxBias CurrTxBiasR');
|
||||||
|
console.log(' Temperature TemperatureR Voltage VoltageR PTxPower PRxPower');
|
||||||
|
console.log('');
|
||||||
|
console.log('Campos importantes:');
|
||||||
|
console.log(' - RxPower: Potência recebida pela OLT (ONU → OLT)');
|
||||||
|
console.log(' - PRxPower: Potência recebida pela ONU (OLT → ONU) ⭐');
|
||||||
|
console.log(' - TxPower: Potência transmitida pela OLT (OLT → ONU)');
|
||||||
|
console.log(' - PTxPower: Potência transmitida pela ONU (ONU → OLT)');
|
||||||
|
console.log('='.repeat(60));
|
||||||
Reference in new issue
Block a user