【光链路分析四】OTDR文件解读接口二次开发说明

sor文件的解读提供二次开发接口
步骤如下:
1、上传你的sor、trc文件
2、通过服务器下载解析后的json文件
3、根据你自己得需要获取信息

示例代码`

function uploadFile() {
var time = new Date().getTime();
var file = document.getElementById(‘file’).files;
var fileType = file[0].name.split(".")[file[0].name.split(".").length-1];
if(fileType==‘trc’||fileType==‘sor’){
}else{
alert(‘无法解析该文件!’);
return;
}
var key = time+“9$@888888@ 9132999999999 9132999999999 9132999999999@888888@ 9 " + f i l e T y p e + " 9 9"+fileType+"9 9"+fileType+"9@888888”;
var newfile = new File([file[0]], key);
var formData = new FormData();
formData.append(key, newfile);
loadLayer();
$.ajax({
url: “联系我索要地址”,
type: “POST”,
data: formData,
contentType: false,
processData: false,
success: function (data) {
var fileUrl = “联系我索要地址/”+data.substr(8,25);
readJson(fileUrl);
},
error: function () {
alert(“上传失败!”);
}
});
}
function showolm(ooindex){

stage.clear();
stage.frames = 24;       
var  scene = new JTopo.Scene(stage); 
scene.clear();
 
canvas.width = $(window).width();
canvas.heirht = 300; 
var startPos = 50;
var endPos = 0;
var lineWidth = 200;

var  nodes =[];
 for(var i=0;i<otdrJson[ooindex]._ListEvent.length;i++)
 {
     var event = otdrJson[ooindex]._ListEvent[i];
     var txt =(event.SpanLength/1000).toFixed(3) +"km\n\n" 
                +(event.SpanLoss=='-'?'-':(event.SpanLoss*1).toFixed(3)) +"dB\n\n" 
                +eventTypeChange(event.Type)
     var node = addEventNode(startPos +(i)*lineWidth, 100,80,80, txt);
     scene.add(node);
     nodes.push(node);
 }

 for(var j=0;j<  nodes.length;j++){
 
  if(j< nodes.length-1){
     var section = otdrJson[ooindex]._ListSection[j];
    var txta=(section.Length/1000).toFixed(3)+"km"
    var txtb =(section.Loss=='-'?'-':(section.Loss*1).toFixed(3))+"dB" 
     var txtc =(i==0?0:(section.Loss/section.Length*1000).toFixed(3))+"dB/km";
        var linka = addLine(nodes[j],nodes[j+1], txta,0);
        var linkb = addLine(nodes[j],nodes[j+1], txtb,18);
         var linkc = addLine(nodes[j],nodes[j+1], txtc,35);
        scene.add(linka);
         scene.add(linkb);
         scene.add(linkc);
    }  
 }   

}`
function loadSummary() {
var base = document.getElementById(‘base’);
var mark = document.getElementById(‘mark’);
var testParam = document.getElementById(‘testParam’);
var result = document.getElementById(‘result’);
var testOption = document.getElementById(‘testOption’);
var baseRows = base.rows;
var markRows = mark.rows;
var testParamRows = testParam.rows;
var resultRows = result.rows;
var testOptionRows = testOption.rows;
//通用标识
var date = new Date(otdrJson[Index]._Identification.TestDate.substr(6,13)/1).toLocaleString();
baseRows[1].cells[1].innerHTML = otdrJson[Index]._Identification.FileName;
baseRows[2].cells[1].innerHTML = date.split(’ ‘)[0];
baseRows[3].cells[1].innerHTML = date.split(’ ‘)[1];
baseRows[4].cells[1].innerHTML = otdrJson[Index]._Identification.ProjectName;
baseRows[5].cells[1].innerHTML = otdrJson[Index]._Identification.Customer;
baseRows[6].cells[1].innerHTML = otdrJson[Index]._Identification.Company;
baseRows[7].cells[1].innerHTML = otdrJson[Index]._Identification.OperateAName;
baseRows[8].cells[1].innerHTML = otdrJson[Index]._Identification.OperateBName;
//标识
markRows[1].cells[1].innerHTML = otdrJson[Index]._Identification.UnitModel;
markRows[2].cells[1].innerHTML = otdrJson[Index]._Identification.UnitSerialNumber;
markRows[3].cells[1].innerHTML = otdrJson[Index]._Identification.CableID;
markRows[4].cells[1].innerHTML = otdrJson[Index]._Identification.FiberID;
markRows[5].cells[1].innerHTML = otdrJson[Index]._Identification.LocationA;
markRows[6].cells[1].innerHTML = otdrJson[Index]._Identification.LocationB;
//测试参数
testParamRows[1].cells[1].innerHTML = otdrJson[Index]._Summary.WaveLength1000000000+“nm”;
testParamRows[2].cells[1].innerHTML = (otdrJson[Index]._Summary.Range/1000).toFixed(3
)+“km”;
testParamRows[3].cells[1].innerHTML = otdrJson[Index]._Summary.Pulse
1000000+“μs”;
testParamRows[4].cells[1].innerHTML = otdrJson[Index]._Summary.Duration.TotalSeconds+“s”;
testParamRows[5].cells[1].innerHTML = otdrJson[Index]._Summary.Highresolutionfalse?“否”:“是”;
testParamRows[6].cells[1].innerHTML = (otdrJson[Index]._Summary.Resolution/1).toFixed(3)+“m”;
//测试结果
resultRows[1].cells[1].innerHTML = (otdrJson[Index]._Summary.SpanLength/1000).toFixed(3)+“km”;
resultRows[2].cells[1].innerHTML = (otdrJson[Index]._Summary.SpanLoss/1).toFixed(3)+“dB”;
resultRows[3].cells[1].innerHTML = (otdrJson[Index]._Summary.AverageLoss1000).toFixed(3)+“dB/km”;
resultRows[4].cells[1].innerHTML = (otdrJson[Index]._Summary.AverageSpliceLoss/1).toFixed(3)+“dB”;
resultRows[5].cells[1].innerHTML = (otdrJson[Index]._Summary.MaximumSpliceLoss/1).toFixed(3)+“dB”;
resultRows[6].cells[1].innerHTML = (otdrJson[Index]._Summary.SpanORL/1).toFixed(3)+“dB”;
//测试设置
testOptionRows[1].cells[1].innerHTML = (otdrJson[Index]._Summary.IOR/1).toFixed(6);
testOptionRows[2].cells[1].innerHTML = (otdrJson[Index]._Summary.BackScatter/1).toFixed(3)+“dB”;
testOptionRows[3].cells[1].innerHTML = (otdrJson[Index]._Summary.HelixFactor/1).toFixed(2)+"%";
testOptionRows[4].cells[1].innerHTML = (otdrJson[Index]._Summary.SpliceLossThreshold/1).toFixed(3)+“dB”;
testOptionRows[5].cells[1].innerHTML = (otdrJson[Index]._Summary.ReflectanceThreshold/1).toFixed(3)+“dB”;
testOptionRows[6].cells[1].innerHTML = (otdrJson[Index]._Summary.EndOfFiberThreshold/1).toFixed(3)+“dB”;
testOptionRows[7].cells[1].innerHTML = (otdrJson[Index]._Summary.FiberCoreSize
10000).toFixed(3)+“μm”;
}
function loadThreshold() {
var threshold = document.getElementById(‘threshold’);
var rows = threshold.rows;
//阈值
rows[0].cells[0].innerHTML = ‘阈值(’+otdrJson[Index]._WaveLength+’)’;
rows[2].cells[1].childNodes[0].checked = otdrJson[Index]._Thresholds.UnidirConnectLoss.Applicable;
rows[2].cells[2].innerHTML = otdrJson[Index]._Thresholds.UnidirConnectLoss.Fail+".000dB";
rows[2].cells[3].innerHTML = otdrJson[Index]._Thresholds.UnidirConnectLoss.Warning+".000dB";
rows[3].cells[1].childNodes[0].checked = otdrJson[Index]._Thresholds.UnidirSpliceLoss.Applicable;
rows[3].cells[2].innerHTML = otdrJson[Index]._Thresholds.UnidirSpliceLoss.Fail+".000dB";
rows[3].cells[3].innerHTML = otdrJson[Index]._Thresholds.UnidirSpliceLoss.Warning+".000dB";
rows[4].cells[1].childNodes[0].checked = otdrJson[Index]._Thresholds.Reflectance.Applicable;
rows[4].cells[2].innerHTML = otdrJson[Index]._Thresholds.Reflectance.Fail+".000dB";
rows[4].cells[3].innerHTML = otdrJson[Index]._Thresholds.Reflectance.Warning+".000dB";
rows[5].cells[1].childNodes[0].checked = otdrJson[Index]._Thresholds.FiberSectionAttenuation.Applicable;
rows[5].cells[2].innerHTML = otdrJson[Index]._Thresholds.FiberSectionAttenuation.Fail1000+“00dB/km”;
rows[5].cells[3].innerHTML = otdrJson[Index]._Thresholds.FiberSectionAttenuation.Warning
1000+“00dB/km”;
rows[6].cells[1].childNodes[0].checked = otdrJson[Index]._Thresholds.SpanLoss.Applicable;
rows[6].cells[2].innerHTML = otdrJson[Index]._Thresholds.SpanLoss.Fail+".000dB";
rows[6].cells[3].innerHTML = otdrJson[Index]._Thresholds.SpanLoss.Warning+".000dB";
rows[7].cells[1].childNodes[0].checked = otdrJson[Index]._Thresholds.SpanLength.Applicable;
rows[7].cells[2].innerHTML = otdrJson[Index]._Thresholds.SpanLength.Fail+".000km";
rows[7].cells[3].innerHTML = otdrJson[Index]._Thresholds.SpanLength.Warning+".000km";
rows[8].cells[1].childNodes[0].checked = otdrJson[Index]._Thresholds.SpanOrl.Applicable;
rows[8].cells[2].innerHTML = otdrJson[Index]._Thresholds.SpanOrl.Fail+".000dB";
rows[8].cells[3].innerHTML = otdrJson[Index]._Thresholds.SpanOrl.Warning+".000dB";
}
function loadEvent() {
var events = document.getElementById(‘events’);
var tr = “
序号事件类型位置(km)损耗(dB)” +
反射率与前点距离(km)两点损耗(dB)” +
“两点衰减系数(dB/km)
累计损耗(dB)”;
var countLoss = 0;
for(var i=0;i<otdrJson[Index]._ListEvent.length;i++){
var event = otdrJson[Index]._ListEvent[i];
var section;
if(i>0){
countLoss += event.SpanLoss;
section = otdrJson[Index]._ListSection[i-1];
}else{
section={Loss:’-’,Length:0};
}
tr+=""+(i+1)+""+eventTypeChange(event.Type)
+"" +(event.SpanLength/1000).toFixed(3)
+""+(event.SpanLoss’-’?’-’:(event.SpanLoss1).toFixed(3))
+"
"+(event.Reflectivity==’-’?’-’:(event.Reflectivity1).toFixed(3))
+""+(section.Length/1000).toFixed(3)
+""+ (section.Loss==’-’?’-’:(section.Loss1).toFixed(3))
+"
"+(i==0?0:(section.Loss/section.Length1000).toFixed(3))
+""+((countLoss1).toFixed(3)==‘NaN’?’-’:(countLoss1).toFixed(3))+"";
}
events.innerHTML = tr;
}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜晚是传说

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值