New file |
| | |
| | | var eleCircle = new EleCircle('eleCircle', {}); |
| | | var signalGood = new Image(); |
| | | signalGood.src="image/eleCircle/signalGood.gif"; |
| | | var signalBad = new Image(); |
| | | signalBad.src="image/eleCircle/signalBad.gif"; |
| | | $(function() { |
| | | eleCircle.drawImg({ |
| | | startX: 10, |
| | | startY: 30, |
| | | width: 30, |
| | | height: 30, |
| | | isShow:false, |
| | | id: 'signal' |
| | | }); |
| | | |
| | | // 最上方的横线 |
| | | eleCircle.drawLine({ |
| | | startX: 220, |
| | | startY: 80, |
| | | endX: 440, |
| | | endY: 80, |
| | | strokeStyle: '#000', |
| | | fillStyle: '#000', |
| | | id: 'L1' |
| | | }); |
| | | |
| | | // 横线下的第一个竖线 |
| | | // eleCircle.drawLine({ |
| | | // startX: 120, |
| | | // startY: 80, |
| | | // endX: 120, |
| | | // endY: 150, |
| | | // strokeStyle: '#000', |
| | | // id: 'L11' |
| | | // }); |
| | | |
| | | // 横线下的第二个竖线 |
| | | eleCircle.drawLine({ |
| | | startX: 220, |
| | | startY: 80, |
| | | endX: 220, |
| | | endY: 150, |
| | | strokeStyle: '#000', |
| | | id: 'L12' |
| | | }); |
| | | |
| | | // 横线下的第三个竖线 |
| | | eleCircle.drawLine({ |
| | | startX: 380, |
| | | startY: 80, |
| | | endX: 380, |
| | | endY: 170, |
| | | strokeStyle: '#000', |
| | | id: 'l13' |
| | | }); |
| | | |
| | | |
| | | // BATC+端后的横线 |
| | | eleCircle.drawLine({ |
| | | startX: 456, |
| | | startY: 80, |
| | | endX: 740, |
| | | endY: 80, |
| | | strokeStyle: '#000', |
| | | fillStyle: '#000', |
| | | id: 'L2' |
| | | }); |
| | | |
| | | // BATC+端 |
| | | eleCircle.drawBAT({ |
| | | startX: 440, |
| | | startY: 80, |
| | | fillStyle: '#000', |
| | | strokeStyle: '#0000DD', |
| | | name: 'BATC+端', |
| | | id: 'BATCAnode' |
| | | }); |
| | | |
| | | // BATC+端后的横线第一根竖线 |
| | | eleCircle.drawLine({ |
| | | startX: 586, |
| | | startY: 80, |
| | | endX: 586, |
| | | endY: 190, |
| | | strokeStyle: '#000', |
| | | fillStyle: '#000', |
| | | id: 'L21' |
| | | }); |
| | | |
| | | // BATC+端后的横线第二根竖线 |
| | | eleCircle.drawLine({ |
| | | startX: 740, |
| | | startY: 80, |
| | | endX: 740, |
| | | endY: 190, |
| | | strokeStyle: '#000', |
| | | fillStyle: '#000', |
| | | id: 'l22' |
| | | }); |
| | | // DCDC模块 |
| | | eleCircle.drawDCDC({ |
| | | startX:120, |
| | | startY:150, |
| | | name: '放电单元', |
| | | id: 'DCDC1' |
| | | }); |
| | | // DCDC升压电下的竖线 |
| | | eleCircle.drawLine({ |
| | | startX: 120, |
| | | startY: 250, |
| | | endX: 120, |
| | | endY: 320, |
| | | strokeStyle: '#000', |
| | | id: 'L14' |
| | | }); |
| | | // DCDC模块 |
| | | eleCircle.drawDCDC({ |
| | | startX:220, |
| | | startY:150, |
| | | name: '充电单元', |
| | | id: 'DCDC2' |
| | | }); |
| | | // DCDC稳流下的竖线 |
| | | eleCircle.drawLine({ |
| | | startX: 220, |
| | | startY: 250, |
| | | endX: 220, |
| | | endY: 320, |
| | | strokeStyle: '#000', |
| | | id: 'L15' |
| | | }); |
| | | |
| | | // DCDC模块下的横线 |
| | | eleCircle.drawLine({ |
| | | startX: 120, |
| | | startY: 320, |
| | | endX: 250, |
| | | endY: 320, |
| | | strokeStyle: '#000', |
| | | id: 'L3' |
| | | }); |
| | | |
| | | |
| | | // 绘制整流器 |
| | | eleCircle.drawRectifier({ |
| | | startX: 586, |
| | | startY:190, |
| | | name: '整&流&器', |
| | | id:'rectifierInfor1' |
| | | }); |
| | | |
| | | |
| | | |
| | | // Km开关后的横线 |
| | | eleCircle.drawLine({ |
| | | startX: 305, |
| | | startY: 320, |
| | | endX: 440, |
| | | endY: 320, |
| | | strokeStyle: '#000', |
| | | id: 'L4' |
| | | }); |
| | | |
| | | // BATC-端后的横线 |
| | | eleCircle.drawLine({ |
| | | startX: 456, |
| | | startY: 320, |
| | | endX: 480, |
| | | endY: 320, |
| | | strokeStyle: '#000', |
| | | id: 'L5' |
| | | }); |
| | | // BATD+端 |
| | | eleCircle.drawBAT({ |
| | | startX: 440, |
| | | startY: 320, |
| | | fillStyle: '#000', |
| | | strokeStyle: '#0000DD', |
| | | name: 'BATD+端', |
| | | id: 'BATDAnode' |
| | | }); |
| | | |
| | | // BATC-端后的横线的第一个横线电池在这个地方 |
| | | eleCircle.drawLine({ |
| | | startX: 480, |
| | | startY: 320, |
| | | endX: 480, |
| | | endY: 360, |
| | | strokeStyle: '#000', |
| | | id: 'L51' |
| | | }); |
| | | |
| | | eleCircle.drawLine({ |
| | | startX: 480, |
| | | startY: 440, |
| | | endX: 480, |
| | | endY: 460, |
| | | strokeStyle: '#000', |
| | | id: 'L52' |
| | | }); |
| | | |
| | | // 电池 |
| | | eleCircle.drawEle({ |
| | | startX: 480, |
| | | startY: 360, |
| | | direction: 'down', |
| | | value: '0V', |
| | | name:'电&池&组', |
| | | id:"groupEle" |
| | | }); |
| | | |
| | | // 电池后的横线 |
| | | eleCircle.drawLine({ |
| | | startX: 480, |
| | | startY: 460, |
| | | endX: 440, |
| | | endY: 460, |
| | | strokeStyle: '#000', |
| | | id: 'L6' |
| | | }); |
| | | |
| | | |
| | | // BAT-端前横线 |
| | | eleCircle.drawLine({ |
| | | startX: 440, |
| | | startY: 460, |
| | | lineWidth: 2, |
| | | endX: 305, |
| | | endY: 460, |
| | | strokeStyle: '#000', |
| | | id: 'L6' |
| | | }); |
| | | |
| | | // kc开关端前横线 |
| | | eleCircle.drawLine({ |
| | | startX: 250, |
| | | startY: 460, |
| | | lineWidth: 2, |
| | | endX: 40, |
| | | endY: 460, |
| | | strokeStyle: '#000', |
| | | id: 'L7' |
| | | }); |
| | | |
| | | |
| | | // BAT-端前横线上的竖线 |
| | | eleCircle.drawLine({ |
| | | startX: 40, |
| | | startY: 460, |
| | | lineWidth: 2, |
| | | endX: 40, |
| | | endY: 200, |
| | | strokeStyle: '#000', |
| | | id: 'L61' |
| | | }); |
| | | // DCDC升压左侧横线 |
| | | eleCircle.drawLine({ |
| | | startX: 40, |
| | | startY: 200, |
| | | lineWidth: 2, |
| | | endX: 70, |
| | | endY: 200, |
| | | strokeStyle: '#000', |
| | | id: 'L8' |
| | | }); |
| | | // BAT-端 |
| | | eleCircle.drawBAT({ |
| | | startX: 440, |
| | | startY: 460, |
| | | fillStyle: '#000', |
| | | strokeStyle: '#0000DD', |
| | | name: 'BAT-端', |
| | | nPosition: 'down', |
| | | id: 'BATCathode' |
| | | }); |
| | | |
| | | // 绘制整流器后的线条 |
| | | eleCircle.drawLine({ |
| | | startX: 586, |
| | | startY: 290, |
| | | endX: 586, |
| | | endY: 460, |
| | | strokeStyle: '#000', |
| | | }); |
| | | // 整流器左横线 |
| | | eleCircle.drawLine({ |
| | | startX: 556, |
| | | startY: 460, |
| | | endX: 480, |
| | | endY: 460, |
| | | strokeStyle: '#000', |
| | | }); |
| | | |
| | | |
| | | |
| | | // 绘制ko开关后的线 |
| | | eleCircle.drawLine({ |
| | | startX: 380, |
| | | startY: 226, |
| | | endX: 380, |
| | | endY: 320, |
| | | strokeStyle: '#000', |
| | | }); |
| | | |
| | | |
| | | // 绘制用电负载模块 |
| | | eleCircle.drawEleLoad({ |
| | | startX: 740, |
| | | startY: 190, |
| | | name: '用&电&负&载', |
| | | }); |
| | | // 用电负载下的线 |
| | | eleCircle.drawLine({ |
| | | startX: 740, |
| | | startY: 290, |
| | | endX: 740, |
| | | endY: 460, |
| | | strokeStyle: '#000', |
| | | }); |
| | | // 向左的横线 |
| | | eleCircle.drawLine({ |
| | | startX: 740, |
| | | startY: 460, |
| | | endX: 556, |
| | | endY: 460, |
| | | strokeStyle: '#000', |
| | | }); |
| | | |
| | | // 二极管上方的横线 |
| | | eleCircle.drawLine({ |
| | | startX: 380, |
| | | startY: 135, |
| | | endX: 430, |
| | | endY: 135, |
| | | strokeStyle: '#000', |
| | | }); |
| | | // 二极管上方的竖线 |
| | | eleCircle.drawLine({ |
| | | startX: 430, |
| | | startY: 135, |
| | | endX: 430, |
| | | endY: 160, |
| | | strokeStyle: '#000', |
| | | }); |
| | | |
| | | |
| | | |
| | | |
| | | // 二极管下方的竖线 |
| | | eleCircle.drawLine({ |
| | | startX: 430, |
| | | startY: 220, |
| | | endX: 430, |
| | | endY: 250, |
| | | strokeStyle: '#000', |
| | | }); |
| | | |
| | | // 二极管下方的横线 |
| | | eleCircle.drawLine({ |
| | | startX: 430, |
| | | startY: 250, |
| | | endX: 380, |
| | | endY: 250, |
| | | strokeStyle: '#000', |
| | | }); |
| | | |
| | | |
| | | // BATC+端上方的虚线 |
| | | eleCircle.drawDotLine({ |
| | | startX: 448, |
| | | startY: 72, |
| | | endX: 448, |
| | | endY: 60, |
| | | }); |
| | | |
| | | // BATC+端上方的虚线(横线) |
| | | eleCircle.drawDotLine({ |
| | | startX: 448, |
| | | startY: 60, |
| | | endX: 20, |
| | | endY: 60, |
| | | }); |
| | | |
| | | // BATC+端下方的虚线 |
| | | eleCircle.drawDotLine({ |
| | | startX: 448, |
| | | startY: 88, |
| | | endX: 448, |
| | | endY: 312, |
| | | }); |
| | | |
| | | |
| | | // BATD+端下方的虚线 |
| | | eleCircle.drawDotLine({ |
| | | startX: 448, |
| | | startY: 328, |
| | | endX: 448, |
| | | endY: 452, |
| | | }); |
| | | |
| | | // BAT-端下方的虚线 |
| | | eleCircle.drawDotLine({ |
| | | startX: 448, |
| | | startY: 468, |
| | | endX: 448, |
| | | endY: 510, |
| | | }); |
| | | |
| | | // BAT-端下方的虚线 |
| | | eleCircle.drawDotLine({ |
| | | startX: 448, |
| | | startY: 468, |
| | | endX: 448, |
| | | endY: 510, |
| | | }); |
| | | // BAT-端下方的虚线(横线) |
| | | eleCircle.drawDotLine({ |
| | | startX: 448, |
| | | startY: 510, |
| | | endX: 20, |
| | | endY: 510, |
| | | }); |
| | | |
| | | // 最左侧虚线 |
| | | eleCircle.drawDotLine({ |
| | | startX: 20, |
| | | startY: 60, |
| | | endX: 20, |
| | | endY: 510, |
| | | name: '' |
| | | }); |
| | | |
| | | // 绘制二极管Do |
| | | eleCircle.drawDiode({ |
| | | startX: 430, |
| | | startY: 160, |
| | | id: 'diode' |
| | | }); |
| | | |
| | | // 绘制ko开关 |
| | | eleCircle.drawSwitchBtn({ |
| | | startX: 380, |
| | | startY: 170, |
| | | strokeStyle: '#000', |
| | | fillStyle: '#0000DD', |
| | | direction: 'up', |
| | | name: 'k1', |
| | | nPosition: 'left', |
| | | txtLength: -1, |
| | | id: 'ko' |
| | | }); |
| | | |
| | | // km 开关 |
| | | eleCircle.drawSwitchBtn({ |
| | | startX: 305, |
| | | startY: 320, |
| | | direction: 'right', |
| | | stats: 'off', |
| | | strokeStyle: '#000', |
| | | fillStyle: '#0000DD', |
| | | name: 'k2', |
| | | nPosition: 'up', |
| | | id: 'km' |
| | | }); |
| | | |
| | | // kC开关 |
| | | eleCircle.drawSwitchBtn({ |
| | | startX: 305, |
| | | startY: 460, |
| | | direction: 'right', |
| | | stats: 'off', |
| | | strokeStyle: '#000', |
| | | fillStyle: '#0000DD', |
| | | name: 'k3', |
| | | id: 'kc' |
| | | }); |
| | | |
| | | // 拓扑图名称 |
| | | /*eleCircle.drawText({ |
| | | id: 'title', |
| | | startX: 400, |
| | | startY: 40, |
| | | name: '设备浮充状态电流方向', |
| | | });*/ |
| | | |
| | | // 设备内部温度 |
| | | eleCircle.drawText({ |
| | | id: 'tmp', |
| | | startX: 270, |
| | | startY: 100, |
| | | name: '设备温度:0℃', |
| | | }); |
| | | |
| | | // dcdc模块告警 |
| | | eleCircle.drawText({ |
| | | id: 'dcdcWarn', |
| | | startX: 250, |
| | | startY: 390, |
| | | name: 'DCDC模块告警:0x8000/0x8000', |
| | | }); |
| | | |
| | | var currentObj = { |
| | | id: 'current' |
| | | }; |
| | | var floatCharge = { |
| | | points:[ |
| | | [320, 40], [540, 40],[540, 520], |
| | | [430, 520], [430, 360],[320,360] |
| | | ], |
| | | clockwise: 0, |
| | | name: '设备浮充状态电流方向' |
| | | } |
| | | |
| | | currentObj = $.extend({}, currentObj, floatCharge); |
| | | // 绘制电流的的回路 |
| | | eleCircle.drawCurrent(currentObj); |
| | | |
| | | |
| | | // 绘制在线电压 |
| | | eleCircle.drawText({ |
| | | startX: 663, |
| | | startY: 110, |
| | | name: '0V', |
| | | fontSize: 20, |
| | | lineWidth: 20, |
| | | fontWeight: 'bold', |
| | | id: 'onlineVol' |
| | | }); |
| | | |
| | | // 绘制地电压 |
| | | eleCircle.drawText({ |
| | | startX: 663, |
| | | startY: 450, |
| | | name: '', |
| | | fontSize: 20, |
| | | lineWidth: 20, |
| | | fontWeight: 'bold' |
| | | }); |
| | | |
| | | // 绘制电池电流 |
| | | eleCircle.drawText({ |
| | | startX: 510, |
| | | startY: 120, |
| | | name: '0A', |
| | | fillStyle: '#0000DD', |
| | | fontSize: 20, |
| | | lineWidth: 20, |
| | | fontWeight: 'bold', |
| | | id: 'eleCurrent' |
| | | }); |
| | | |
| | | // 负载电流 |
| | | eleCircle.drawText({ |
| | | id: 'loaderCurr', |
| | | startX: 600, |
| | | startY: 50, |
| | | name: '最大负载电流:0A', |
| | | }); |
| | | |
| | | // 最大核容电流 |
| | | // eleCircle.drawText({ |
| | | // id: 'disCurrMax', |
| | | // startX: 600, |
| | | // startY: 70, |
| | | // name: '最大核容电流:0A', |
| | | // }); |
| | | |
| | | // 本站续航时长 |
| | | eleCircle.drawText({ |
| | | id: 'xuHangTime', |
| | | startX: 600, |
| | | startY: 70, |
| | | name: '本站续航时长:0min', |
| | | }); |
| | | |
| | | // 浮充电流方向 |
| | | var floatCurr = [ |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine:[{ |
| | | startP:[480, 440], |
| | | endP: [480, 460] |
| | | },{ |
| | | startP:[480, 460], |
| | | endP:[586, 460] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine:[{ |
| | | startP:[586, 460], |
| | | endP:[526, 290] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[586, 190], |
| | | endP: [586, 80] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP:[586, 80], |
| | | endP: [456, 80] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP:[440, 80], |
| | | endP: [380, 80] |
| | | },{ |
| | | startP:[380, 80], |
| | | endP: [380, 170] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP:[380, 226], |
| | | endP: [380, 320] |
| | | },{ |
| | | startP:[380, 320], |
| | | endP: [440, 320] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP:[456, 320], |
| | | endP: [480, 320] |
| | | },{ |
| | | startP:[480, 320], |
| | | endP:[480, 360] |
| | | }] |
| | | } |
| | | ]; |
| | | |
| | | // 放电测试 |
| | | var disChargeCurr = [ |
| | | { |
| | | moveLine: [{ |
| | | startP:[480, 360], |
| | | endP:[480, 320] |
| | | },{ |
| | | startP:[480, 320], |
| | | endP:[456, 320] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [440, 320], |
| | | endP: [305, 320] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [250, 320], |
| | | endP: [120, 320] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [120, 320], |
| | | endP: [120, 250] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [120, 150], |
| | | endP: [120, 80] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [120, 80], |
| | | endP: [220, 80] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [220, 80], |
| | | endP: [440, 80] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [456, 80], |
| | | endP: [740, 80] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [740, 80], |
| | | endP: [740, 190] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [740, 290], |
| | | endP: [740, 460] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [740, 460], |
| | | endP: [586, 460] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP:[586, 460], |
| | | endP:[480, 460] |
| | | },{ |
| | | startP:[480, 460], |
| | | endP:[480, 440] |
| | | }] |
| | | } |
| | | |
| | | ]; |
| | | |
| | | |
| | | // 稳流充电电流 |
| | | var constCurr = [ |
| | | { |
| | | moveLine:[{ |
| | | startP:[480, 440], |
| | | endP: [480, 460] |
| | | },{ |
| | | startP:[480, 460], |
| | | endP:[586, 460] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine:[{ |
| | | startP:[586, 460], |
| | | endP:[526, 290] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP:[586, 190], |
| | | endP: [586, 80] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP:[586, 80], |
| | | endP: [456, 80] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP:[440, 80], |
| | | endP: [380, 80] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [380, 80], |
| | | endP: [220, 80] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [220, 80], |
| | | endP: [220, 150] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [220, 250], |
| | | endP: [220, 320] |
| | | },{ |
| | | startP: [220, 320], |
| | | endP: [250, 320] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [305, 320], |
| | | endP: [440, 320] |
| | | }] |
| | | }, |
| | | { |
| | | moveLine: [{ |
| | | startP: [456, 320], |
| | | endP: [480, 320] |
| | | },{ |
| | | startP: [480, 320], |
| | | endP: [480, 360] |
| | | }] |
| | | }, |
| | | ]; |
| | | |
| | | eleCircle.drawRectList(floatCurr); |
| | | }); |
| | | |
| | | |
| | | //elecircle-status |
| | | ;(function($, window, documment, gl) { |
| | | // 设置当前模块的命名空间为circleStatus |
| | | gl.namespace('circleStatus'); |
| | | // 定义电路拓扑图状态类 |
| | | var Status = function(ele, options) { |
| | | this.ele = ele; |
| | | this.options = options; |
| | | |
| | | this._init(); |
| | | |
| | | if(this.options.length != 0) { |
| | | this.show(); |
| | | } |
| | | }; |
| | | // 声明原型变量 |
| | | var _prop = Status.prototype; |
| | | // 初始化内容 |
| | | _prop._init = function() { |
| | | // 清理当前容器的内容 |
| | | this.ele.hide(); |
| | | this.ele.text(""); |
| | | // 使用js的方式生成特定的元素 |
| | | var _ul = $('<ul></ul>'); |
| | | // 遍历options |
| | | for(var i=0; i<this.options.length; i++) { |
| | | var _opts = this.options[i]; |
| | | var _li = $('<li></li>'); |
| | | this._setLi(_li, _opts); |
| | | _ul.append(_li); |
| | | } |
| | | this.ele.append(_ul); |
| | | }; |
| | | |
| | | // 设置配置项 |
| | | _prop.setOpts = function(options) { |
| | | this.options = options; |
| | | |
| | | this._init(); |
| | | |
| | | if(this.options.length != 0) { |
| | | this.show(); |
| | | } |
| | | }; |
| | | |
| | | // 根据配置项的值获取li |
| | | _prop._setLi = function(li, option) { |
| | | var _i, _a = $('<a></a>'); |
| | | // 清空li |
| | | li.text(""); |
| | | // 内容仅有两种 |
| | | if(option.type == 'bool') { |
| | | // 当前是告警 |
| | | if(option.status == 0) { |
| | | li.addClass('elecircle-status-warn'); |
| | | _i = $('<i class="fa '+option.warn.icon+'"></i>'); |
| | | _a = $('<a>'+option.warn.text+'</a>'); |
| | | }else { |
| | | li.removeClass('elecircle-status-warn'); |
| | | _i = $('<i class="fa '+option.normal.icon+'"></i>'); |
| | | _a = $('<a>'+option.normal.text+'</a>'); |
| | | } |
| | | li.append(_i); |
| | | }else if(option.type == 'list') { |
| | | if(isFunction(option.imgCallback)) { |
| | | var img = option.imgCallback(option.status);; |
| | | _a.append(img); |
| | | } |
| | | var list = option.content.list[option.status]?option.content.list[option.status]:'未知'; |
| | | var txt = option.content.text+list; |
| | | _a.append(txt); |
| | | }else if(option.type == 'text') { |
| | | var txt = option.content.text; |
| | | _a.append(txt); |
| | | } |
| | | |
| | | li.append(_a); |
| | | |
| | | if(option.notShow) { |
| | | li.hide(); |
| | | }else { |
| | | li.show(); |
| | | } |
| | | }; |
| | | |
| | | // 根据配置项的值获取 |
| | | // 显示 |
| | | _prop.show = function() { |
| | | this.ele.show(); |
| | | }; |
| | | |
| | | // 隐藏 |
| | | _prop.hide = function() { |
| | | this.ele.hide(); |
| | | }; |
| | | |
| | | // 根据设置状态内容 |
| | | _prop.setStatus = function(name, status, notShow) { |
| | | var _itemList = this.ele.find('li'); |
| | | // 遍历配置项 |
| | | for(var i =0; i<this.options.length; i++) { |
| | | var _opts = this.options[i]; // 获取当前循环的变量 |
| | | // 根据名称确定更改的内容 |
| | | if(_opts.name == name) { |
| | | var _tmp = $.extend({}, _opts); // 获取全新对象,避免引用传递 |
| | | // 设置显示内容 |
| | | _tmp.status = status; |
| | | |
| | | // 设置是否显示 |
| | | if(notShow) { |
| | | _tmp.notShow = true; |
| | | }else { |
| | | _tmp.notShow = false; |
| | | } |
| | | |
| | | this._setLi(_itemList.eq(i), _tmp); // 更新li的内容 |
| | | } |
| | | } |
| | | |
| | | }; |
| | | |
| | | // 设置文本内容 |
| | | _prop.setText = function(name, text, notShow) { |
| | | var _itemList = this.ele.find('li'); |
| | | // 遍历配置项 |
| | | for(var i =0; i<this.options.length; i++) { |
| | | var _opts = this.options[i]; // 获取当前循环的变量 |
| | | // 根据名称确定更改的内容 |
| | | if(_opts.name == name) { |
| | | var _tmp = $.extend({}, _opts); // 获取全新对象,避免引用传递 |
| | | _tmp.content.text = text; |
| | | |
| | | // 设置是否显示 |
| | | if(notShow) { |
| | | _tmp.notShow = true; |
| | | }else { |
| | | _tmp.notShow = false; |
| | | } |
| | | |
| | | this._setLi(_itemList.eq(i), _tmp); // 更新li的内容 |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // 更新配置项的值 |
| | | _prop.updateOpts = function(name, options, update) { |
| | | // 遍历配置项 |
| | | for(var i =0; i<options.length; i++) { |
| | | var _opts = options[i]; // 获取当前循环的变量 |
| | | // 根据名称确定更改的内容 |
| | | if(_opts.name == name) { |
| | | $.extend(_opts, update); |
| | | } |
| | | } |
| | | }; |
| | | var options = [ |
| | | { |
| | | name: 'workstatus', |
| | | type: 'list', |
| | | notShow: false, |
| | | imgCallback: gl.statusImg.getImg, |
| | | status: 0, |
| | | content: { |
| | | list:gl.DEV61850.workstates, |
| | | text: '工作状态:' |
| | | } |
| | | }, |
| | | { |
| | | name: 'msg', // 通讯 |
| | | status: 1, |
| | | type: 'bool', |
| | | normal: { |
| | | icon: 'fa-plug', |
| | | text: '设备通讯正常' |
| | | }, |
| | | warn: { |
| | | icon: 'fa-plug', |
| | | text: '设备通讯异常' |
| | | } |
| | | }, |
| | | { |
| | | name: 'tmp', // 通讯 |
| | | status: 1, |
| | | type: 'bool', |
| | | normal: { |
| | | icon: 'fa-thermometer-half', |
| | | text: '设备温度正常' |
| | | }, |
| | | warn: { |
| | | icon: 'fa-thermometer-full', |
| | | text: '设备过温告警' |
| | | } |
| | | }, |
| | | { |
| | | name: 'stop', |
| | | type: 'list', |
| | | notShow: false, |
| | | imgCallback: '', |
| | | status: 0, |
| | | content: { |
| | | list: gl.DEV61850.stopreasons, |
| | | text: '核容终止原因:' |
| | | } |
| | | } |
| | | ]; |
| | | // 61850配置项 |
| | | gl.circleStatus.e61850Opts = options; |
| | | |
| | | var optionsBts = [ |
| | | { |
| | | name: 'workstatus', |
| | | type: 'list', |
| | | notShow: false, |
| | | //imgCallback: gl.statusImg.getImg, |
| | | status: 0, |
| | | content: { |
| | | list:gl.BTS9100.workstates, |
| | | text: '设备状态:' |
| | | } |
| | | }, |
| | | { |
| | | name: 'stop', |
| | | type: 'list', |
| | | status: 0, |
| | | notShow: false, |
| | | content: { |
| | | list:gl.BTS9100.alarmstates, |
| | | text: '上一次核容终止原因:' |
| | | } |
| | | }, |
| | | { |
| | | name: 'count', |
| | | type: 'text', |
| | | status: 0, |
| | | notShow: false, |
| | | content: { |
| | | text: '通信计数:' |
| | | } |
| | | }, |
| | | { |
| | | name: 'percent', |
| | | type: 'text', |
| | | status: 0, |
| | | notShow: false, |
| | | content: { |
| | | text:'通信丢包率:' |
| | | } |
| | | }, |
| | | { |
| | | name: 'sdCard', |
| | | type: 'text', |
| | | status: 0, |
| | | notShow: false, |
| | | content: { |
| | | text: 'SD卡状态:???' |
| | | } |
| | | }, |
| | | { |
| | | name:'devVersion', |
| | | type: 'text', |
| | | status: 0, |
| | | notShow: false, |
| | | content: { |
| | | text: '设备版本号:???' |
| | | } |
| | | }, |
| | | { |
| | | name: 'signal', |
| | | type: 'text', |
| | | status: 0, |
| | | notShow: true, |
| | | content: { |
| | | text: '信号强度:' |
| | | } |
| | | } |
| | | ]; |
| | | // bts9100配置项 |
| | | gl.circleStatus.btsOpts = optionsBts; |
| | | |
| | | // 61850拓扑图状态 |
| | | var status = new Status($('#eleCircleStatus'), options); |
| | | gl.circleStatus.status = status; |
| | | |
| | | // BTS9100拓扑图状态 |
| | | var statusBts = new Status($('#eleCircleStatus'), optionsBts); |
| | | gl.circleStatus.statusBts = statusBts; |
| | | |
| | | // 设置全局验证设备类型的正则表达式 |
| | | var globalPattern = { |
| | | LD9: /^40190/, |
| | | equip61850: /^61850/, |
| | | BTS:/^(9100)|(9600)|(9616)/, |
| | | BTSSreen: /^9611/, |
| | | equip4016:/^4016/ |
| | | }; |
| | | gl.circleStatus.globalPattern = gl.equipType?gl.equipType.type:globalPattern; |
| | | // BTS拓扑图显示 |
| | | function BTSCircle(batt, model, mygraph, callback) { |
| | | var lasttype = mygraph.graphtype; |
| | | var _str = ""; |
| | | if(model.code == 1) { |
| | | var data = model.data[0]; |
| | | var alarmstatus = data.dev_alarmstate; //[0:'无',1:'暂停',2:'放电测试',3:'放电等待',4:'限流充电',5:'直流充电',6:'充电等待',7:'测试时间到',8:'测试容量到',9:'单体下限到',10:'组端下限到',11:'市电异常',12:'存储卡不足',13:'负载温度高',14:'电流异常',15:'远程通信坏',16:'负载通信坏',17:'选择通信坏',18:'负载电流坏',19:'内存申请坏',20:'未知']; |
| | | var workstatus =parseInt(data.dev_workstate) ; //[0:'在线监测',1:'放电测试',2:'充电测试',3:'内阻测试',4:'未知']; |
| | | // console.log(workstatus); |
| | | // console.log(data.dev_testgroupnum+'***'+(batt.GroupIndexInFBSDevice+1)+'***'+mygraph.battstate); |
| | | // 判断workstatus |
| | | switch(workstatus) { |
| | | case 0: { // 浮充状态 |
| | | mygraph.graphtype = 0; |
| | | _str = '(开关闭合)'; |
| | | if(mygraph.battstate == 3){ |
| | | mygraph.graphtype = 6; |
| | | _str = '(开关断开)'; //停电放电的情况 |
| | | } |
| | | // 当前设备是BTS设备 |
| | | if(data.dev_res_test_state != 0) { |
| | | _str += '(内阻测试)'; |
| | | } |
| | | } |
| | | break; |
| | | case 1:{ // 放电测试 |
| | | if(data.dev_testgroupnum>0 && (data.dev_testgroupnum == (batt.GroupIndexInFBSDevice+1))){ |
| | | mygraph.graphtype = 1; |
| | | _str = '(开关断开)'; |
| | | }else{ |
| | | if(mygraph.battstate == 3){ |
| | | mygraph.graphtype = 1; |
| | | _str = '(开关断开)'; |
| | | }else{ |
| | | mygraph.graphtype = 0; |
| | | _str = '(开关闭合)'; |
| | | } |
| | | } |
| | | |
| | | // 当前设备是BTS设备 |
| | | if(data.dev_testtype == 81) { |
| | | _str += '(KD测试)'; |
| | | mygraph.graphtype = 5; |
| | | } |
| | | } |
| | | break; |
| | | case 2: { |
| | | //辨别当前电池组是否在充电 |
| | | if(mygraph.battstate == 2 || ((data.dev_testgroupnum >0) && data.dev_testgroupnum == (batt.GroupIndexInFBSDevice+1))){ |
| | | //充电 |
| | | if(alarmstatus == 1 || alarmstatus == 2 || alarmstatus == 3 || alarmstatus == 4 || alarmstatus == 6){ |
| | | //限流充电 -->常闭接触器断开 |
| | | mygraph.graphtype = 2; |
| | | _str = '(开关断开)'; |
| | | }else{ |
| | | //直流充电 -->常闭接触器闭合 |
| | | mygraph.graphtype = 3 ; |
| | | _str = '(开关闭合)'; |
| | | } |
| | | }else{ |
| | | mygraph.graphtype = 0; |
| | | _str = '(开关闭合)'; |
| | | } |
| | | } |
| | | break; |
| | | default:{ |
| | | //未知 |
| | | mygraph.graphtype = 4 ; |
| | | _str = '(未知)'; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | // 设置左上方内容 |
| | | if(typeof callback == 'function') { |
| | | callback.apply({}, [batt, data, mygraph]); |
| | | } |
| | | }else { |
| | | // console.log(123); |
| | | mygraph.graphtype = 4 ; |
| | | _str = '(未连接)'; |
| | | // 回调函数 |
| | | if(typeof callback == 'function') { |
| | | callback(); |
| | | } |
| | | } |
| | | // console.log(lasttype+"**"+mygraph.graphtype); |
| | | // 判断是否更新拓扑图 |
| | | if(lasttype != mygraph.graphtype){ |
| | | mygraph.ischange = 1; |
| | | |
| | | } |
| | | //console.log(mygraph); |
| | | return _str; |
| | | } |
| | | gl.circleStatus.BTSCircle = BTSCircle; |
| | | |
| | | |
| | | // 61850拓扑图显示 |
| | | function BTS61850Circle(batt, model, mygraph, callback) { |
| | | var _str = ""; |
| | | var lasttype = mygraph.graphtype; |
| | | if(model.code == 1) { |
| | | var data = model.data[0]; |
| | | //var alarmstatus = data.dev_alarmstate; //[0:'无',1:'暂停',2:'放电测试',3:'放电等待',4:'限流充电',5:'直流充电',6:'充电等待',7:'测试时间到',8:'测试容量到',9:'单体下限到',10:'组端下限到',11:'市电异常',12:'存储卡不足',13:'负载温度高',14:'电流异常',15:'远程通信坏',16:'负载通信坏',17:'选择通信坏',18:'负载电流坏',19:'内存申请坏',20:'未知']; |
| | | var workstatus = parseInt(data.dev_workstate) ; //[0:'在线监测',1:'放电测试',2:'充电测试',3:'内阻测试',4:'未知']; |
| | | |
| | | //workstatus = 3; |
| | | switch(workstatus) { |
| | | case 0:{ //浮充状态拓扑图 |
| | | mygraph.graphtype = 0; |
| | | _str = '(开关闭合)'; |
| | | } |
| | | break; |
| | | case 4:{ //浮充状态(内阻测试)拓扑图 |
| | | mygraph.graphtype = 0; |
| | | _str = '(开关闭合)'; |
| | | // 当前设备是否是内阻测试 |
| | | _str += '(内阻测试)'; |
| | | } |
| | | break; |
| | | case 1:{ //充电状态拓扑图 |
| | | mygraph.graphtype = 2; |
| | | _str = '(开关断开)'; |
| | | |
| | | } |
| | | break; |
| | | case 2:{ //放电状态拓扑图 |
| | | mygraph.graphtype = 1; |
| | | _str = '(开关断开)'; |
| | | } |
| | | break; |
| | | case 3:{ //放电状态拓扑图 |
| | | mygraph.graphtype = 6; |
| | | _str = '(开关闭合)'; |
| | | } |
| | | break; |
| | | case 5:{ //放电状态(KD测试)拓扑图 |
| | | mygraph.graphtype = 1; |
| | | _str = '(开关断开)'; |
| | | _str += '(KD测试)'; |
| | | mygraph.graphtype = 5; |
| | | } |
| | | break; |
| | | default:{ |
| | | //未知 |
| | | mygraph.graphtype = 4 ; |
| | | _str = '(未知)'; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | // 执行callback函数 |
| | | if(typeof callback == 'function') { |
| | | callback.apply({}, [batt, data, mygraph]); |
| | | } |
| | | |
| | | }else { |
| | | mygraph.graphtype = 4 ; |
| | | _str = '(未连接)'; |
| | | |
| | | // 回调函数更新拓扑图内容 |
| | | if(typeof callback == 'function') { |
| | | callback(); |
| | | } |
| | | } |
| | | |
| | | // 判断是否更新拓扑图 |
| | | if(lasttype != mygraph.graphtype){ |
| | | mygraph.ischange = 1; |
| | | } |
| | | |
| | | return _str; |
| | | } |
| | | |
| | | gl.circleStatus.BTS61850Circle = BTS61850Circle; |
| | | |
| | | |
| | | // 验证设备类型 |
| | | function regEquipType(eId, pattern) { |
| | | // 遍历所有的形参 |
| | | for(var i=1; i<arguments.length;i++) { |
| | | if(arguments[i].test(eId)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | })(jQuery, window, document, GLOBAL, undefined); |
New file |
| | |
| | | // 电池组图片 |
| | | var eleGroupImg = new Image(); |
| | | eleGroupImg.src="image/eleCircle/elegroup.png"; |
| | | |
| | | //用电负载 |
| | | var loadImg = new Image(); |
| | | loadImg.src = "image/eleCircle/load.png"; |
| | | |
| | | //整流器图标 |
| | | var screenImg = new Image(); |
| | | screenImg.src = "image/eleCircle/screen.png"; |
| | | ;(function($, window, document, gl) { |
| | | // 设置命名空间 |
| | | gl.namespace('statusImg'); |
| | | // orange |
| | | var orangeImg = new Image(); |
| | | orangeImg.src = "image/eleCircle/orange.png"; |
| | | |
| | | // red |
| | | var redImg = new Image(); |
| | | redImg.src = 'image/eleCircle/red.png'; |
| | | |
| | | // blue |
| | | var greenImg = new Image(); |
| | | greenImg.src = 'image/eleCircle/green.png'; |
| | | |
| | | // gray |
| | | var gayImg = new Image(); |
| | | gayImg.src = 'image/eleCircle/gray.png'; |
| | | |
| | | // 根据设备放电模块获取图标 |
| | | function getdisChargeImg(status) { |
| | | var i = parseInt(status); |
| | | var rs = gayImg; |
| | | switch(i) { |
| | | case 1: // 核容测试 |
| | | case 5: // kd |
| | | rs = orangeImg; |
| | | break; |
| | | case 2: // 预充电 |
| | | rs = greenImg; |
| | | break; |
| | | } |
| | | |
| | | return rs; |
| | | } |
| | | |
| | | // 根据设备充电状态获取图标 |
| | | function getChargeImg(status) { |
| | | var i = parseInt(status); |
| | | var rs = gayImg; |
| | | switch(i) { |
| | | case 1: // 核容测试 |
| | | case 5: // kd |
| | | rs = greenImg; |
| | | break; |
| | | case 2: |
| | | rs = orangeImg; |
| | | break; |
| | | } |
| | | |
| | | return rs; |
| | | } |
| | | |
| | | // 根据设备工作状态图标 |
| | | function getImg(status) { |
| | | var i = parseInt(status); |
| | | var rs = gayImg; |
| | | switch(i) { |
| | | case 0: |
| | | case 4: |
| | | rs = greenImg |
| | | break; |
| | | case 1: |
| | | case 2: |
| | | case 5: |
| | | rs = orangeImg; |
| | | break; |
| | | case 3: |
| | | rs = redImg; |
| | | break; |
| | | } |
| | | |
| | | return rs; |
| | | } |
| | | |
| | | // 将函数绑定到GLOBAL.statusImg命名空间下 |
| | | gl.statusImg.getdisChargeImg = getdisChargeImg; |
| | | |
| | | gl.statusImg.getChargeImg = getChargeImg; |
| | | |
| | | gl.statusImg.getImg = getImg; |
| | | |
| | | })(jQuery, window, document, GLOBAL); |
| | | |
| | | |
| | | var nStatusImg = GLOBAL.statusImg; |
| | | |
| | | var EleCircle = function(canvas, options) { |
| | | this.canvas = document.getElementById(canvas); |
| | | this.context = this.canvas.getContext('2d'); |
| | | this.opts = []; |
| | | this.timer = ''; |
| | | this.start(); |
| | | this.groupVol = '0V'; |
| | | this.eleCurrent = '0A'; |
| | | }; |
| | | // 绘制电路图的线 |
| | | EleCircle.prototype.drawLine = function(options) { |
| | | var defaults = { |
| | | startX: 0, |
| | | startY: 0, |
| | | endX:0, |
| | | endY: 0, |
| | | lineWidth: 4, |
| | | strokeStyle: '#000', |
| | | fillStyle: '#000', |
| | | id:'' |
| | | }; |
| | | var opts = $.extend({}, defaults, options || {}); |
| | | this.context.strokeStyle = opts.strokeStyle; |
| | | this.context.fillStyle = opts.fillStyle; |
| | | this.context.lineWidth = opts.lineWidth; |
| | | |
| | | this.context.beginPath(); |
| | | this.context.moveTo(opts.startX, opts.startY); |
| | | this.context.lineTo(opts.endX, opts.endY); |
| | | this.context.closePath(); |
| | | |
| | | this.context.stroke(); |
| | | |
| | | var lineInfo = { |
| | | options: opts, |
| | | type:'drawLine', |
| | | }; |
| | | |
| | | this.opts.push(lineInfo); |
| | | }; |
| | | |
| | | // 绘制BAT端 |
| | | EleCircle.prototype.drawBAT = function(options) { |
| | | var defaults = { |
| | | startX: 0, |
| | | startY: 0, |
| | | endX:0, |
| | | endY: 0, |
| | | width: 16, |
| | | lineWidth: 4, |
| | | strokeStyle: '#000', |
| | | fillStyle: '#000', |
| | | nPosition: 'up', |
| | | name: '', |
| | | id:'' |
| | | }; |
| | | |
| | | var opts = $.extend({}, defaults, options || {}); |
| | | |
| | | this.context.fillStyle = opts.fillStyle; |
| | | this.context.strokeStyle = opts.strokeStyle; |
| | | this.context.lineWidth = opts.lineWidth; |
| | | |
| | | this.context.fillRect(opts.startX, opts.startY-opts.width/2, opts.width, opts.width); |
| | | |
| | | this.context.strokeRect(opts.startX, opts.startY-opts.width/2, opts.width, opts.width); |
| | | |
| | | this.context.fillStyle = '#000'; |
| | | this.context.font="12px Arial"; |
| | | if(opts.nPosition == 'up') { |
| | | this.context.fillText(opts.name, opts.startX+opts.width+5,opts.startY-opts.width/2); |
| | | }else { |
| | | this.context.fillText(opts.name, opts.startX+opts.width+5,opts.startY+opts.width); |
| | | } |
| | | |
| | | |
| | | var BATInfor = { |
| | | options: opts, |
| | | type:'drawBAT', |
| | | }; |
| | | this.opts.push(BATInfor); |
| | | }; |
| | | |
| | | // 绘制DCDC模块 |
| | | EleCircle.prototype.drawDCDC = function(options) { |
| | | var defaults = { |
| | | startX: 0, |
| | | startY: 0, |
| | | endX:0, |
| | | endY: 0, |
| | | width: 100, |
| | | lineWidth: 1, |
| | | strokeStyle: '#000', |
| | | fillStyle: '#000', |
| | | statusImg: -1, |
| | | name: '', |
| | | id:'' |
| | | }; |
| | | |
| | | var opts = $.extend({}, defaults, options || {}); |
| | | |
| | | this.context.strokeStyle = opts.strokeStyle; |
| | | this.context.lineWidth = opts.lineWidth; |
| | | this.context.strokeRect(opts.startX - opts.width/2, opts.startY, opts.width, opts.width); |
| | | |
| | | |
| | | var lineHeight = 16; |
| | | var textList = opts.name.split('&'); |
| | | this.context.font = 14 |
| | | this.context.fillStyle= opts.fillStyle; |
| | | for(var i=0; i<textList.length; i++) { |
| | | this.context.fillText(textList[i], opts.startX-20, opts.startY+opts.width/2-16+lineHeight); |
| | | lineHeight += 16; |
| | | } |
| | | |
| | | // 绘制图片 |
| | | if(opts.id=="DCDC1") { |
| | | this.context.drawImage(nStatusImg.getdisChargeImg(opts.statusImg), opts.startX-38, opts.startY+opts.width/2-12); |
| | | }else { |
| | | this.context.drawImage(nStatusImg.getChargeImg(opts.statusImg), opts.startX-38, opts.startY+opts.width/2-12); |
| | | } |
| | | |
| | | |
| | | var DCDCInfor = { |
| | | options: opts, |
| | | type:'drawDCDC', |
| | | }; |
| | | this.opts.push(DCDCInfor); |
| | | |
| | | }; |
| | | |
| | | // 绘制整流器 |
| | | EleCircle.prototype.drawRectifier = function (options) { |
| | | var defaults = { |
| | | startX: 0, |
| | | startY: 0, |
| | | endX:0, |
| | | endY: 0, |
| | | width: 25, |
| | | height: 50, |
| | | lineWidth: 1, |
| | | strokeStyle: '#000', |
| | | fillStyle: '#000', |
| | | name: '', |
| | | value: '0.0V', |
| | | id:'' |
| | | }; |
| | | |
| | | var opts = $.extend({}, defaults, options || {}); |
| | | this.context.drawImage(screenImg, opts.startX-30, opts.startY-3, 65, 105); |
| | | // var step = 1/opts.height; |
| | | // this.context.strokeStyle = opts.strokeStyle; |
| | | // this.context.lineWidth = opts.lineWidth; |
| | | // this.context.beginPath(); |
| | | // this.context.moveTo(opts.startX+opts.width, opts.startY+opts.height); //从椭圆的左端点开始绘制 |
| | | // |
| | | // for (var i = 0; i < 2 * Math.PI; i += step) { |
| | | // this.context.lineTo(opts.startX + opts.width * Math.cos(i), opts.startY+opts.height+opts.height * Math.sin(i)); |
| | | // } |
| | | // this.context.closePath(); |
| | | // this.context.stroke(); |
| | | |
| | | // 设置整流器的文本和正负极 |
| | | var lineHeight = 16; |
| | | var textList = opts.name.split('&'); |
| | | this.context.font = '14px Arial'; |
| | | this.context.fillStyle= opts.fillStyle; |
| | | for(var i=0; i<textList.length; i++) { |
| | | this.context.fillText(textList[i], opts.startX+35, opts.startY+20+lineHeight); |
| | | lineHeight += 16; |
| | | } |
| | | this.context.font = '30px Arial'; |
| | | this.context.fillStyle="#FF0000"; |
| | | this.context.fillText('+', opts.startX-32, opts.startY); |
| | | this.context.fillStyle="#000"; |
| | | this.context.fillText('-', opts.startX-32, opts.startY+opts.height*2.1); |
| | | |
| | | this.context.font = '20px Arial'; |
| | | this.context.fillStyle = "#FF0000"; |
| | | this.context.fillText(opts.value, opts.startX+10, opts.startY); |
| | | |
| | | var rectifierInfor = { |
| | | options: opts, |
| | | type:'drawRectifier', |
| | | }; |
| | | this.opts.push(rectifierInfor); |
| | | }; |
| | | |
| | | /** |
| | | * 绘制电路图的开关 |
| | | */ |
| | | EleCircle.prototype.drawSwitchBtn = function(options) { |
| | | var defaults = { |
| | | startX: 0, |
| | | startY: 0, |
| | | direction: 'left', |
| | | radius: 5, |
| | | stats: 'on', |
| | | lineWidth: 3, |
| | | name: "", |
| | | nPosition: 'down', |
| | | txtLength: -1, |
| | | fillStyle: '#000', |
| | | strokeStyle: '#000', |
| | | value: '0v', |
| | | isShowValue2: false, |
| | | value2: '触点异常', |
| | | value2Color: '#FFD700', |
| | | value2Length: -1, |
| | | isBg: true, |
| | | bgColor: '#FFFFFF', |
| | | id: '' |
| | | }; |
| | | var opts = $.extend({}, defaults, options || {}); |
| | | |
| | | // 根据开关的类型和快关的状态设置value的值获取线包电压 |
| | | /*var lineVol = '线包电压:'; |
| | | if(opts.id == 'ko') { |
| | | if(opts.stats == 'on') { |
| | | lineVol =lineVol + '0V'; |
| | | }else { |
| | | lineVol =lineVol + this.groupVol; |
| | | } |
| | | }else { |
| | | if(opts.stats == 'on') { |
| | | lineVol =lineVol + this.groupVol; |
| | | }else { |
| | | lineVol =lineVol + '0V'; |
| | | } |
| | | }*/ |
| | | |
| | | |
| | | |
| | | // 开关开始的圆圈的圆心坐标 |
| | | var startRadiusX = opts.startX; |
| | | var startRadiusY = opts.startY; |
| | | |
| | | // 开关的线条 |
| | | var lineStartX = opts.startX; |
| | | var lineStartY = opts.startY; |
| | | var lineEndX = opts.startX; |
| | | var lineEndY = opts.startY; |
| | | |
| | | // 开关结束的圆圈的圆心坐标 |
| | | var endRadiusX = opts.startX; |
| | | var endRadiusY = opts.startY; |
| | | var myWidth = opts.startX; |
| | | var myHeight = opts.startY; |
| | | |
| | | var txtStartX = opts.startX; |
| | | var txtStartY = opts.startY; |
| | | // 判断开关的方向 |
| | | switch(opts.direction) { |
| | | case 'right': |
| | | startRadiusX = opts.startX - opts.radius; // 设置圆心坐标 |
| | | |
| | | lineStartX = startRadiusX - opts.radius; // 设置开关线的开始坐标 |
| | | |
| | | |
| | | lineEndX = opts.startX-opts.radius*10; // 设置开关线的结束坐标 |
| | | if(opts.stats == 'on') { |
| | | lineEndY = opts.startY - opts.radius; |
| | | }else { |
| | | lineEndY = opts.startY - opts.radius*3; |
| | | } |
| | | |
| | | endRadiusX = opts.startX-opts.radius*10; |
| | | endRadiusY = opts.startY; |
| | | myWidth = opts.radius*11; |
| | | myHeight = opts.radius*2; |
| | | |
| | | txtStartX = opts.startX - 6*opts.radius; |
| | | txtStartY = opts.startY + 8*opts.radius; |
| | | break; |
| | | case 'up': |
| | | startRadiusY = opts.startY + opts.radius; // 设置圆心坐标 |
| | | |
| | | lineStartY =opts.startY+opts.radius*10; // 设置开关线的开始坐标 |
| | | lineEndY = startRadiusY + opts.radius; // 设置开关线的结束坐标 |
| | | if(opts.stats == 'on') { |
| | | lineEndX = opts.startX + opts.radius; |
| | | }else { |
| | | lineEndX = opts.startX + opts.radius*3; |
| | | } |
| | | |
| | | endRadiusX = opts.startX; |
| | | endRadiusY = opts.startY+opts.radius*10; |
| | | |
| | | myWidth = opts.radius*2; |
| | | myHeight = opts.radius*11; |
| | | txtStartY = opts.startY + 10*opts.radius; |
| | | break; |
| | | case 'down': |
| | | startRadiusY = opts.startY + opts.radius; // 设置圆心坐标 |
| | | |
| | | lineStartY = startRadiusY + opts.radius; // 设置开关线的开始坐标 |
| | | |
| | | |
| | | lineEndY = opts.startY+opts.radius*10; // 设置开关线的结束坐标 |
| | | if(opts.stats == 'on') { |
| | | lineEndX = opts.startX + opts.radius; |
| | | }else { |
| | | lineEndX = opts.startX + opts.radius*3; |
| | | } |
| | | |
| | | endRadiusX = opts.startX; |
| | | endRadiusY = opts.startY+opts.radius*10; |
| | | myWidth = opts.radius*2; |
| | | myHeight = opts.radius*11; |
| | | break; |
| | | default: |
| | | startRadiusX = opts.startX + opts.radius; // 设置圆心坐标 |
| | | |
| | | lineStartX = startRadiusX + opts.radius; // 设置开关线的开始坐标 |
| | | |
| | | |
| | | lineEndX = opts.startX+opts.radius*10; // 设置开关线的结束坐标 |
| | | if(opts.stats == 'on') { |
| | | lineEndY = opts.startY - opts.radius; |
| | | }else { |
| | | lineEndY = opts.startY - opts.radius*3; |
| | | } |
| | | |
| | | endRadiusX = opts.startX+opts.radius*10; |
| | | endRadiusY = opts.startY; |
| | | myWidth = opts.radius*11; |
| | | myHeight = opts.radius*2; |
| | | break; |
| | | } |
| | | |
| | | this.context.lineWidth = opts.lineWidth; |
| | | this.context.fillStyle=opts.fillStyle; |
| | | this.context.strokeStyle = opts.strokeStyle; |
| | | this.context.beginPath(); |
| | | this.context.arc(startRadiusX, startRadiusY, opts.radius, 0, Math.PI*2, false); |
| | | this.context.closePath(); |
| | | this.context.fill(); |
| | | |
| | | this.context.beginPath(); |
| | | this.context.arc(startRadiusX, startRadiusY, opts.radius, 0, Math.PI*2, false); |
| | | this.context.closePath(); |
| | | this.context.stroke(); |
| | | |
| | | this.context.beginPath(); |
| | | this.context.moveTo(lineStartX, lineStartY); |
| | | this.context.lineTo(lineEndX, lineEndY); |
| | | this.context.closePath(); |
| | | this.context.stroke(); |
| | | |
| | | |
| | | this.context.beginPath(); |
| | | this.context.arc(endRadiusX, endRadiusY, opts.radius, 0, Math.PI*2, false); |
| | | this.context.closePath(); |
| | | this.context.fill(); |
| | | |
| | | this.context.beginPath(); |
| | | this.context.arc(endRadiusX, endRadiusY, opts.radius, 0, Math.PI*2, false); |
| | | this.context.closePath(); |
| | | this.context.stroke(); |
| | | |
| | | // 添加文本描述 |
| | | setEleCircleName(this.context, { |
| | | startX: txtStartX, |
| | | startY: txtStartY, |
| | | txtLength: opts.txtLength, |
| | | pos: opts.nPosition, |
| | | name: opts.name |
| | | }); |
| | | |
| | | if(opts.isShowValue2) { |
| | | setEleCircleName(this.context, { |
| | | startX: txtStartX+5, |
| | | startY: startRadiusY - 35, |
| | | txtLength: opts.value2Length, |
| | | fontSize: 12, |
| | | pos: 'right', |
| | | isBg: true, |
| | | name: opts.value2, |
| | | fillStyle: opts.value2Color |
| | | }); |
| | | } |
| | | |
| | | |
| | | // 设置value的值 |
| | | var valueTxtX = 0; |
| | | var valueTxtY = 0; |
| | | |
| | | switch(opts.direction) { |
| | | case 'right': |
| | | valueTxtX = startRadiusX; |
| | | valueTxtY = startRadiusY+ 25; |
| | | break; |
| | | default: |
| | | valueTxtX = endRadiusX+5; |
| | | valueTxtY = endRadiusY + 45; |
| | | break; |
| | | } |
| | | |
| | | // 绘制背景色 |
| | | /*this.context.beginPath(); |
| | | this.context.fillStyle = '#FFFFFF'; |
| | | var strWidth = getStringWidth(lineVol); |
| | | this.context.rect(valueTxtX,valueTxtY-12,strWidth,14); |
| | | this.context.fill(); |
| | | |
| | | this.context.strokStyle = '#0000DD'; |
| | | this.context.fillStyle = '#0000DD'; |
| | | this.context.font = 'bold 12px Arial'; |
| | | this.context.fillText(lineVol, valueTxtX, valueTxtY);*/ |
| | | |
| | | var switchBtnInfor = { |
| | | options: opts, |
| | | type:'drawSwitchBtn', |
| | | }; |
| | | this.opts.push(switchBtnInfor); |
| | | }; |
| | | |
| | | // 绘制电池 |
| | | EleCircle.prototype.drawEle = function(options) { |
| | | var defaults = { |
| | | startX: 0, |
| | | startY: 0, |
| | | name: '', |
| | | direction: 'right', |
| | | width: 10, |
| | | scale: 6, // 宽高比例1:10 |
| | | space: 3, // 空白点补齐的宽度 |
| | | lineHeight: 16, |
| | | fontSize: 14, |
| | | value: '0V', |
| | | fillStyle: { |
| | | bgcolor: '#0066FF' |
| | | }, |
| | | label: { |
| | | show: true, |
| | | color: '#000', |
| | | position: 'top' |
| | | }, |
| | | }; |
| | | this.drawEle.data = {}; |
| | | var opts = $.extend({}, defaults, options || {}); |
| | | opts.fillStyle = $.extend({}, defaults.fillStyle, options.fillStyle || {}); // 更新填充的颜色 |
| | | opts.label = $.extend({},defaults.label, options.label || {} ); // 更新label的样式 |
| | | //console.info(opts); |
| | | var firstEle = { |
| | | x: opts.startX, |
| | | y: opts.startY, |
| | | x1: opts.startX, |
| | | y1: opts.startY |
| | | }; |
| | | |
| | | var spaceDot = []; |
| | | |
| | | var lastEle = { |
| | | x: opts.startX, |
| | | y: opts.startY, |
| | | x1: opts.startX, |
| | | y1: opts.startY |
| | | } |
| | | |
| | | var width = opts.width; |
| | | var height = opts.width*opts.scale; |
| | | |
| | | var width1 = opts.width; |
| | | var height1 = opts.width*opts.scale/2; |
| | | switch(opts.direction) { |
| | | case 'left': |
| | | // 第一个电池的正极起始坐标 |
| | | firstEle.x = opts.startX + (opts.space+5)*opts.width; |
| | | firstEle.y = opts.startY - opts.width*opts.scale/2; |
| | | |
| | | firstEle.x1 = opts.startX + (opts.space+3.5)*opts.width; |
| | | firstEle.y1 = opts.startY - opts.width*opts.scale/4; |
| | | |
| | | // 第二个电池的正极起始坐标 |
| | | lastEle.x = opts.startX + opts.width*2.5; |
| | | lastEle.y = opts.startY - opts.width*opts.scale/2; |
| | | |
| | | lastEle.x1 = opts.startX + opts.width; |
| | | lastEle.y1 = opts.startY - opts.width*opts.scale/4; |
| | | |
| | | for(var i=0; i<opts.space; i++) { |
| | | var dot = {}; |
| | | dot.x = opts.startX + (2.5*opts.width + i*opts.width+0.5*opts.width); |
| | | dot.y = opts.startY - opts.width/2; |
| | | spaceDot.push(dot); |
| | | } |
| | | |
| | | break; |
| | | case 'right': |
| | | // 第一个电池的正极起始坐标 |
| | | firstEle.x = opts.startX - (opts.space+5)*opts.width; |
| | | firstEle.y = opts.startY - opts.width*opts.scale/2; |
| | | |
| | | firstEle.x1 = opts.startX - (opts.space+3.5)*opts.width; |
| | | firstEle.y1 = opts.startY - opts.width*opts.scale/4; |
| | | |
| | | // 第二个电池的正极起始坐标 |
| | | lastEle.x = opts.startX - opts.width*2.5; |
| | | lastEle.y = opts.startY - opts.width*opts.scale/2; |
| | | |
| | | lastEle.x1 = opts.startX - opts.width; |
| | | lastEle.y1 = opts.startY - opts.width*opts.scale/4; |
| | | |
| | | for(var i=0; i<opts.space; i++) { |
| | | var dot = {}; |
| | | dot.x = opts.startX - (2.5*opts.width + i*opts.width+0.5*opts.width); |
| | | dot.y = opts.startY - opts.width/2; |
| | | |
| | | spaceDot.push(dot); |
| | | } |
| | | break; |
| | | default: |
| | | // 第一个电池的正极起始坐标 |
| | | firstEle.x = opts.startX - opts.width*opts.scale/2; |
| | | firstEle.y = opts.startY; |
| | | |
| | | firstEle.x1 = opts.startX - opts.width*opts.scale/4; |
| | | firstEle.y1 = opts.startY + opts.width*1.5; |
| | | |
| | | // 第二个电池的正极起始坐标 |
| | | lastEle.x = opts.startX - opts.width*opts.scale/2; |
| | | lastEle.y = opts.startY + (opts.space+2.5)*opts.width; |
| | | |
| | | lastEle.x1 = opts.startX - opts.width*opts.scale/4; |
| | | lastEle.y1 = opts.startY + (opts.space+4)*opts.width; |
| | | |
| | | for(var i=0; i<opts.space; i++) { |
| | | var dot = {}; |
| | | dot.x = opts.startX - opts.width/2; |
| | | dot.y = opts.startY + (2.5*opts.width + i*opts.width+0.5*opts.width); |
| | | |
| | | spaceDot.push(dot); |
| | | } |
| | | |
| | | width = opts.width*opts.scale; |
| | | height = opts.width; |
| | | width1 = opts.width*opts.scale/2; |
| | | height1 = opts.width; |
| | | break; |
| | | } |
| | | this.context.fillStyle = opts.fillStyle.bgcolor; |
| | | this.context.drawImage(eleGroupImg, firstEle.x, firstEle.y); |
| | | // this.context.fillRect(firstEle.x, firstEle.y, width, height); |
| | | // this.context.fillRect(firstEle.x1, firstEle.y1, width1, height1); |
| | | |
| | | for(var i=0; i<spaceDot.length; i++) { |
| | | this.context.fillRect(spaceDot[i].x, spaceDot[i].y, opts.width/2, opts.width/2); |
| | | } |
| | | |
| | | this.context.drawImage(eleGroupImg, lastEle.x, lastEle.y); |
| | | //this.context.fillRect(lastEle.x, lastEle.y, width, height); |
| | | //this.context.fillRect(lastEle.x1, lastEle.y1, width1, height1); |
| | | |
| | | var txtStartX = firstEle.x+opts.width*opts.scale +5; |
| | | var txtStartY = firstEle.y+(2.5+opts.scale/2)*opts.width - 32; |
| | | |
| | | var txtLists = opts.name.split('&'); |
| | | for(var i=0; i<txtLists.length; i++) { |
| | | this.context.fillText(txtLists[i], txtStartX, txtStartY+i*opts.lineHeight); |
| | | } |
| | | |
| | | this.context.font = 'bold 14px Arial'; |
| | | this.context.fillText(opts.value, opts.startX+5, opts.startY-5); |
| | | |
| | | |
| | | var eleInfor = { |
| | | options: opts, |
| | | type:'drawEle', |
| | | }; |
| | | this.opts.push(eleInfor); |
| | | }; |
| | | |
| | | // 绘制用电负载 |
| | | EleCircle.prototype.drawEleLoad = function(options) { |
| | | var defaults = { |
| | | startX: 0, |
| | | startY: 0, |
| | | width: 80, |
| | | height: 80, |
| | | lineWidth: 1, |
| | | fillStyle: '#000', |
| | | strokeStyle: '#000', |
| | | name: '' |
| | | }; |
| | | var opts = $.extend({}, defaults, options || {}); |
| | | this.context.drawImage(loadImg, opts.startX-30, opts.startY-3, 60, 105); |
| | | |
| | | // this.context.lineWidth = opts.lineWidth; |
| | | // this.context.strokeStyle = opts.strokeStyle; |
| | | // this.context.strokeRect(opts.startX-opts.width/2, opts.startY, opts.width, opts.height); |
| | | // this.context.font = '14px Arial'; |
| | | // this.context.fillText(opts.name, opts.startX-24, opts.startY+opts.height/2); |
| | | // 设置整流器的文本和正负极 |
| | | var lineHeight = 16; |
| | | var textList = opts.name.split('&'); |
| | | this.context.font = '14px Arial'; |
| | | this.context.fillStyle= opts.fillStyle; |
| | | for(var i=0; i<textList.length; i++) { |
| | | this.context.fillText(textList[i], opts.startX+35, opts.startY+20+lineHeight); |
| | | lineHeight += 16; |
| | | } |
| | | |
| | | var eleLoadInfor = { |
| | | options: opts, |
| | | type:'drawEleLoad', |
| | | } |
| | | this.opts.push(eleLoadInfor); |
| | | }; |
| | | |
| | | EleCircle.prototype.drawDiode = function (options) { |
| | | var defaults = { |
| | | startX: 0, |
| | | startY: 0, |
| | | height: 20, |
| | | lineWidth: 1, |
| | | fillStyle: '#000', |
| | | strokeStyle: '#000', |
| | | name: '', |
| | | id: '', |
| | | isShowValue: false, |
| | | value: '异常', |
| | | valueColor: '#FF0000' |
| | | }; |
| | | var opts = $.extend({}, defaults, options || {}); |
| | | |
| | | this.context.lineWidth = opts.lineWidth; |
| | | this.context.strokeStyle = opts.strokeStyle; |
| | | this.context.fillStyle = opts.fillStyle; |
| | | |
| | | this.context.beginPath(); |
| | | this.context.moveTo(opts.startX, opts.startY); |
| | | this.context.lineTo(opts.startX, opts.startY+opts.height); |
| | | this.context.closePath(); |
| | | this.context.stroke(); |
| | | |
| | | this.context.beginPath(); |
| | | this.context.moveTo(opts.startX-opts.height/2, opts.startY+opts.height); |
| | | this.context.lineTo(opts.startX+opts.height/2, opts.startY+opts.height); |
| | | this.context.closePath(); |
| | | this.context.stroke(); |
| | | |
| | | this.context.beginPath(); |
| | | this.context.moveTo(opts.startX, opts.startY+opts.height); |
| | | this.context.lineTo(opts.startX-Math.tan(Math.PI/6)*opts.height, opts.startY+opts.height*2); |
| | | this.context.lineTo(opts.startX+Math.tan(Math.PI/6)*opts.height, opts.startY+opts.height*2); |
| | | this.context.closePath(); |
| | | this.context.fill(); |
| | | |
| | | this.context.beginPath(); |
| | | this.context.moveTo(opts.startX, opts.startY+opts.height*2); |
| | | this.context.lineTo(opts.startX, opts.startY+opts.height*3); |
| | | this.context.closePath(); |
| | | this.context.stroke(); |
| | | |
| | | setEleCircleName(this.context, { |
| | | startX: opts.startX+8, |
| | | startY: opts.startY+opts.height*2.6, |
| | | name:'D1', |
| | | pos: 'right', |
| | | txtLength:-1 |
| | | }); |
| | | |
| | | if(opts.isShowValue) { |
| | | setEleCircleName(this.context, { |
| | | startX: opts.startX+10, |
| | | startY: opts.startY+35, |
| | | name:opts.value, |
| | | fontSize: 12, |
| | | isBg:true, |
| | | fontWeight: 'bold', |
| | | lineWidth: 4, |
| | | fillStyle: opts.valueColor, |
| | | pos: 'right', |
| | | txtLength:-1 |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | var diodeInfor = { |
| | | options: opts, |
| | | type:'drawDiode', |
| | | } |
| | | this.opts.push(diodeInfor); |
| | | }; |
| | | |
| | | // 绘制虚线 |
| | | EleCircle.prototype.drawDotLine = function (options){ |
| | | var defaults = { |
| | | startX:100, |
| | | startY: 100, |
| | | endX: 0, |
| | | endY: 0, |
| | | dotWidth: 2, |
| | | whiteWidth: 5, |
| | | lineWidth: 1, |
| | | direction: 'left', |
| | | strokeStyle: '#000', |
| | | name: '', |
| | | }; |
| | | |
| | | var opts = $.extend({}, defaults, options||{}); |
| | | |
| | | this.context.lineWidth = opts.lineWidth; |
| | | this.context.strokeStyle = opts.strokeStyle; |
| | | this.context.setLineDash([opts.dotWidth, opts.whiteWidth]); |
| | | |
| | | this.context.beginPath(); |
| | | this.context.moveTo(opts.startX, opts.startY); |
| | | this.context.lineTo(opts.endX, opts.endY); |
| | | this.context.closePath(); |
| | | this.context.stroke(); |
| | | |
| | | this.context.setLineDash([]); // 恢复实线 |
| | | |
| | | if(opts.name.length > 0) { |
| | | this.context.beginPath(); |
| | | this.context.fillStyle = '#FFFFFF'; |
| | | this.context.rect(opts.startX-20,opts.startY+16*2+156, 30,32); |
| | | this.context.fill(); |
| | | } |
| | | |
| | | |
| | | var textList = opts.name.split('&'); |
| | | this.context.fillStyle = opts.strokeStyle; |
| | | var lineHeight = 16; |
| | | for(var i=0; i<textList.length; i++) { |
| | | this.context.fillText(textList[i], opts.startX-20, opts.startY+lineHeight*i+200); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // 存储内容 |
| | | var dotLineInfor = { |
| | | options: opts, |
| | | type:'drawDotLine', |
| | | }; |
| | | this.opts.push(dotLineInfor); |
| | | |
| | | |
| | | }; |
| | | |
| | | // 绘制电流 |
| | | EleCircle.prototype.drawCurrent = function(options) { |
| | | return; |
| | | var defaults = { |
| | | points:[], |
| | | current: { |
| | | start: 0, |
| | | end: 1, |
| | | point:[] |
| | | }, |
| | | dotWidth: 14, |
| | | whiteWidth: 12, |
| | | lineWidth: 4, |
| | | clockwise: 1, // 1顺时针, 0逆时针 |
| | | direction: 'v', // points坐标的第一条线的方向 |
| | | step: 8, |
| | | isCanMove: 1, |
| | | strokeStyle: '#533F03', |
| | | name: '', |
| | | isChange: 0, |
| | | id: '' |
| | | }; |
| | | |
| | | var opts = $.extend({}, defaults, options||{}); |
| | | |
| | | // 如果数据改变就修改电流的框图的样式 |
| | | if(opts.isChange) { |
| | | opts.current = { |
| | | start: 0, |
| | | end: 1, |
| | | point:[] |
| | | }; |
| | | opts.isChange = 0; |
| | | } |
| | | |
| | | this.context.lineWidth = opts.lineWidth; |
| | | this.context.strokeStyle = opts.strokeStyle; |
| | | this.context.setLineDash([opts.dotWidth, opts.whiteWidth]); |
| | | this.context.beginPath(); |
| | | if(opts.points.length >= 2) { |
| | | this.context.moveTo(opts.points[0][0], opts.points[0][1]); |
| | | for(var i=1; i<opts.points.length; i++) { |
| | | this.context.lineTo(opts.points[i][0], opts.points[i][1]); |
| | | } |
| | | } |
| | | this.context.closePath(); |
| | | this.context.stroke(); |
| | | |
| | | this.context.setLineDash([]); // 恢复实线 |
| | | // 设置临时的对象 |
| | | var temp = {}, |
| | | current = opts.current; |
| | | if(current.point.length == 0) { |
| | | current.point = getCenterPoint(opts.points[current.start], opts.points[current.end]); |
| | | } |
| | | |
| | | |
| | | var currentDirect = 'right'; |
| | | if(opts.isCanMove == 1) { |
| | | // 判断当前位置所在的线是横线还是竖线 |
| | | if(opts.points[current.start][0] == opts.points[current.end][0]) { // x轴相等说明是竖线 |
| | | // 判断当前线是在左还是再右 |
| | | if(opts.points[current.start][1] < opts.points[current.end][1]) { // 该竖线在右边 |
| | | // 根据电流是顺时针还是逆时针对当前位置进行计算 |
| | | if(opts.clockwise) { |
| | | current.point[1] = current.point[1] + opts.step; |
| | | currentDirect = 'down'; |
| | | }else { |
| | | current.point[1] = current.point[1] - opts.step; |
| | | currentDirect = 'up'; |
| | | } |
| | | }else { |
| | | // 根据电流是顺时针还是逆时针对当前位置进行计算 |
| | | if(opts.clockwise) { |
| | | current.point[1] = current.point[1] - opts.step; |
| | | currentDirect = 'up'; |
| | | }else { |
| | | current.point[1] = current.point[1] + opts.step; |
| | | currentDirect = 'down'; |
| | | } |
| | | } |
| | | }else { |
| | | // 判断当前横线是在上方还是再下方 |
| | | if(opts.points[current.start][0] < opts.points[current.end][0]) { // 该横线在上方 |
| | | // 根据电流是顺时针还是逆时针对当前位置进行计算 |
| | | if(opts.clockwise) { |
| | | current.point[0] = current.point[0] + opts.step; |
| | | currentDirect = 'left'; |
| | | }else { |
| | | current.point[0] = current.point[0] - opts.step; |
| | | currentDirect = 'right'; |
| | | } |
| | | }else{ |
| | | // 根据电流是顺时针还是逆时针对当前位置进行计算 |
| | | if(opts.clockwise) { |
| | | current.point[0] = current.point[0] - opts.step; |
| | | currentDirect = 'right'; |
| | | }else { |
| | | current.point[0] = current.point[0] + opts.step; |
| | | currentDirect = 'left'; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var isOnLine = getPointState(opts.points[current.start], opts.points[current.end], current.point); |
| | | // 根据当前点的位置查询是否需要进入下面一条线 |
| | | if(!isOnLine) { |
| | | // 判断是逆时针还是顺时针处理进入拐点位置 |
| | | if(opts.clockwise) { |
| | | current.start = current.end; |
| | | current.end = (current.end == (opts.points.length-1))?0:current.end+1; |
| | | current.point[0] = opts.points[current.start][0]; |
| | | current.point[1] = opts.points[current.start][1]; |
| | | }else { |
| | | current.end = current.start; |
| | | current.start = (current.start == 0)?opts.points.length-1: current.start-1; |
| | | current.point[0] = opts.points[current.end][0]; |
| | | current.point[1] = opts.points[current.end][1]; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | temp.startX = current.point[0]; |
| | | temp.startY = current.point[1]; |
| | | temp.direction = currentDirect; // 设置箭头的方向 |
| | | temp.isChange = !isOnLine; |
| | | temp.fillStyle = opts.fillStyle; |
| | | // 根据points的坐标集合生成自己想要的特定的集合 |
| | | this.drawCurrentDirect(temp); |
| | | |
| | | var centerPt = getCenterPoint(opts.points[0], opts.points[1]); |
| | | |
| | | // 绘制电流描述信息 |
| | | setEleCircleName(this.context, { |
| | | startX:centerPt[0], |
| | | startY:centerPt[1], |
| | | pos: 'up', |
| | | name: opts.name, |
| | | fillStyle: opts.txtFillStyle, |
| | | }); |
| | | |
| | | // 存储内容 |
| | | var currentLineInfor = { |
| | | options: opts, |
| | | type:'drawCurrent', |
| | | } |
| | | this.opts.push(currentLineInfor); |
| | | }; |
| | | |
| | | |
| | | /* |
| | | * 生成电流方向指示器 |
| | | * @param Array point 点的坐标轴 |
| | | * @param string 所在线 是横线(h)还是竖线(v) |
| | | * @param string 电流是顺时针()还是 |
| | | */ |
| | | EleCircle.prototype.drawCurrentDirect = function (options) { |
| | | return; |
| | | var defaults = { |
| | | startX: 0, |
| | | startY: 0, |
| | | lineWidth: 1, |
| | | width: 60, |
| | | isChange: false, // 该点是否在拐点 |
| | | direction: 'left', // 箭头的方向 |
| | | strokeStyle: '#000', |
| | | fillStyle: '#533F03' |
| | | }; |
| | | |
| | | var opts = $.extend({}, defaults, options || {}); |
| | | this.context.lineWidth = opts.lineWidth; |
| | | this.context.strokeStyle = opts.strokeStyle; |
| | | this.context.fillStyle = opts.fillStyle; |
| | | |
| | | var triangle = []; |
| | | |
| | | |
| | | switch(opts.direction) { |
| | | case 'right': |
| | | if(opts.isChange) { |
| | | opts.startX - opts.width; |
| | | } |
| | | var dot1 = [opts.startX, opts.startY]; |
| | | var dot2 = [opts.startX+opts.width/3, opts.startY+opts.width/3*Math.tan(Math.PI/6)]; |
| | | var dot3 = [opts.startX+opts.width/5, opts.startY]; |
| | | var dot4 = [opts.startX+opts.width/3, opts.startY-opts.width/3*Math.tan(Math.PI/6)]; |
| | | triangle.push(dot1); |
| | | triangle.push(dot2); |
| | | triangle.push(dot3); |
| | | triangle.push(dot4); |
| | | break; |
| | | case 'down': |
| | | if(opts.isChange) { |
| | | opts.startY + opts.width; |
| | | } |
| | | var dot1 = [opts.startX, opts.startY]; |
| | | var dot2 = [opts.startX-opts.width/3*Math.tan(Math.PI/6), opts.startY-opts.width/3]; |
| | | var dot3 = [opts.startX, opts.startY-opts.width/5]; |
| | | var dot4 = [opts.startX+opts.width/3*Math.tan(Math.PI/6), opts.startY-opts.width/3]; |
| | | triangle.push(dot1); |
| | | triangle.push(dot2); |
| | | triangle.push(dot3); |
| | | triangle.push(dot4); |
| | | break; |
| | | case 'up': |
| | | if(opts.isChange) { |
| | | opts.startY - opts.width; |
| | | } |
| | | var dot1 = [opts.startX, opts.startY]; |
| | | var dot2 = [opts.startX-opts.width/3*Math.tan(Math.PI/6), opts.startY+opts.width/3]; |
| | | var dot3 = [opts.startX, opts.startY+opts.width/5]; |
| | | var dot4 = [opts.startX+opts.width/3*Math.tan(Math.PI/6), opts.startY+opts.width/3]; |
| | | triangle.push(dot1); |
| | | triangle.push(dot2); |
| | | triangle.push(dot3); |
| | | triangle.push(dot4); |
| | | break; |
| | | default: |
| | | if(opts.isChange) { |
| | | opts.startX + opts.width; |
| | | } |
| | | var dot1 = [opts.startX, opts.startY]; |
| | | var dot2 = [opts.startX-opts.width/3, opts.startY+opts.width/3*Math.tan(Math.PI/6)]; |
| | | var dot3 = [opts.startX-opts.width/5, opts.startY]; |
| | | var dot4 = [opts.startX-opts.width/3, opts.startY-opts.width/3*Math.tan(Math.PI/6)]; |
| | | triangle.push(dot1); |
| | | triangle.push(dot2); |
| | | triangle.push(dot3); |
| | | triangle.push(dot4); |
| | | break; |
| | | } |
| | | |
| | | this.context.beginPath(); |
| | | this.context.moveTo(triangle[0][0], triangle[0][1]); |
| | | for(var i=1;i<triangle.length; i++) { |
| | | this.context.lineTo(triangle[i][0], triangle[i][1]); |
| | | } |
| | | this.context.closePath(); |
| | | this.context.fill(); |
| | | |
| | | |
| | | this.context.beginPath(); |
| | | this.context.moveTo(triangle[0][0], triangle[0][1]); |
| | | for(var i=1;i<triangle.length; i++) { |
| | | this.context.lineTo(triangle[i][0], triangle[i][1]); |
| | | } |
| | | this.context.closePath(); |
| | | this.context.stroke(); |
| | | } |
| | | |
| | | // 绘制文本 |
| | | EleCircle.prototype.drawText = function(options) { |
| | | var defaluts = { |
| | | startX: 0, |
| | | startY: 0, |
| | | lineWidth: 4, |
| | | fontSize: 14, |
| | | fontWeight: '', |
| | | strokeStyle: '#000', |
| | | fillStyle: '#000', |
| | | name:'', |
| | | id: '', |
| | | }; |
| | | |
| | | var opts = $.extend({}, defaluts, options || {}); |
| | | |
| | | var textStartX = opts.startX; |
| | | var textStartY = opts.startY; |
| | | var txtLength = opts.name.length*opts.fontSize; |
| | | textStartX = textStartX - txtLength/4; |
| | | |
| | | // 绘制背景色 |
| | | this.context.beginPath(); |
| | | this.context.fillStyle = '#FFFFFF'; |
| | | var strWidth = getStringWidth(opts.name); |
| | | this.context.rect(textStartX,textStartY-opts.fontSize,strWidth,opts.fontSize); |
| | | this.context.fill(); |
| | | |
| | | this.context.lineWidth = opts.lineWidth; |
| | | this.context.strokeStyle = opts.strokeStyle; |
| | | this.context.fillStyle = opts.fillStyle; |
| | | this.context.font = opts.fontSize+'px Arial'; |
| | | this.context.font += ' '+opts.fontWeight; |
| | | |
| | | |
| | | |
| | | this.context.fillText(opts.name, textStartX, textStartY); |
| | | |
| | | // 存储内容 |
| | | var txtInfor = { |
| | | options: opts, |
| | | type:'drawText', |
| | | } |
| | | this.opts.push(txtInfor); |
| | | } |
| | | |
| | | // 绘制图片 |
| | | EleCircle.prototype.drawImg = function(options) { |
| | | var defaluts = { |
| | | img: '', |
| | | startX: 0, |
| | | startY: 0, |
| | | width: 30, |
| | | height: 30, |
| | | lineWidth: 4, |
| | | fontSize: 14, |
| | | fontWeight: '', |
| | | strokeStyle: '#000', |
| | | fillStyle: '#000', |
| | | isShow: true, |
| | | name:'', |
| | | id: '', |
| | | }; |
| | | |
| | | var opts = $.extend({}, defaluts, options || {}); |
| | | |
| | | if(opts.img != '' && opts.isShow) { |
| | | this.context.drawImage(opts.img, opts.startX, opts.startY, opts.width, opts.height); |
| | | |
| | | this.context.lineWidth = opts.lineWidth; |
| | | this.context.strokeStyle = opts.strokeStyle; |
| | | this.context.fillStyle = opts.fillStyle; |
| | | this.context.font = opts.fontSize+'px Arial'; |
| | | this.context.fillText(opts.name, opts.startX+30, opts.startY+25); |
| | | } |
| | | |
| | | // 存储内容 |
| | | var txtInfor = { |
| | | options: opts, |
| | | type:'drawImg', |
| | | }; |
| | | this.opts.push(txtInfor); |
| | | |
| | | |
| | | }; |
| | | |
| | | // 重新绘制图 |
| | | EleCircle.prototype.redraw =function() { |
| | | this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); |
| | | var opts = []; |
| | | // 循环的方式将this.opts的值给临时变量opts避免引用传递 |
| | | for(var i=0; i<this.opts.length; i++) { |
| | | var temp = $.extend({}, this.opts[i]); |
| | | opts.push(temp); |
| | | } |
| | | |
| | | this.opts = []; |
| | | |
| | | for(var i=0; i<opts.length; i++) { |
| | | this[opts[i].type](opts[i].options); |
| | | } |
| | | }; |
| | | |
| | | // 开启一直监测电池状态内容 |
| | | EleCircle.prototype.start = function() { |
| | | this.stop(); |
| | | this.redraw(); |
| | | this.timer = setInterval(function() { |
| | | this.redraw(); |
| | | }.bind(this), 100); |
| | | } |
| | | |
| | | // 关闭电池状态监控 |
| | | EleCircle.prototype.stop = function() { |
| | | clearInterval(this.timer); |
| | | } |
| | | |
| | | |
| | | // 隐藏电路拓扑图 |
| | | EleCircle.prototype.hide = function() { |
| | | var $canvas = $(this.canvas); |
| | | $canvas.parent().hide(); |
| | | this.stop(); |
| | | } |
| | | |
| | | // 显示电路拓扑图 |
| | | EleCircle.prototype.show = function() { |
| | | var $canvas = $(this.canvas); |
| | | $canvas.parent().show(); |
| | | this.start(); |
| | | } |
| | | |
| | | //绘制点 |
| | | EleCircle.prototype.drawRect = function (options) { |
| | | var defaults = { |
| | | startX: 0, |
| | | startY: 0, |
| | | moveLine:[], |
| | | fillColor: '#FF0000', |
| | | index: 0, |
| | | init: true, |
| | | isList: false, |
| | | step: 4 |
| | | }; |
| | | |
| | | var opts = $.extend({}, defaults, options); |
| | | var cxt = this.context; |
| | | |
| | | if(opts.init) { |
| | | opts.init = false; |
| | | opts.index = 0; |
| | | var _startP = opts.moveLine[0].startP |
| | | opts.startX = _startP[0]; |
| | | opts.startY = _startP[1]; |
| | | } |
| | | |
| | | // 获取起始点和结束点坐标 |
| | | var startP = opts.moveLine[opts.index].startP; |
| | | var endP = opts.moveLine[opts.index].endP; |
| | | |
| | | // 绘制亮点 |
| | | cxt.fillStyle = opts.fillColor; |
| | | cxt.beginPath(); |
| | | cxt.arc(opts.startX, opts.startY, 6, 0, Math.PI*2, true); |
| | | cxt.closePath(); |
| | | cxt.fill(); |
| | | |
| | | |
| | | // 横向线条上 |
| | | if(startP[1] == endP[1]) { |
| | | // 开始点在左侧 |
| | | if(startP[0] <endP[0]) { |
| | | opts.startX += opts.step; |
| | | |
| | | // 超出就换下一组并切换开始点 |
| | | if(opts.startX > endP[0]) { |
| | | // 不是最后一组点 |
| | | if(opts.index != (opts.moveLine.length-1)) { |
| | | opts.index += 1; |
| | | }else { |
| | | opts.index = 0; |
| | | } |
| | | opts.startX = opts.moveLine[opts.index].startP[0]; |
| | | opts.startY = opts.moveLine[opts.index].startP[1]; |
| | | } |
| | | }else { |
| | | opts.startX -= opts.step; |
| | | |
| | | // 超出就换下一组并切换开始点 |
| | | if(opts.startX < endP[0]) { |
| | | // 不是最后一组点 |
| | | if(opts.index != (opts.moveLine.length-1)) { |
| | | opts.index += 1; |
| | | }else { |
| | | opts.index = 0; |
| | | } |
| | | opts.startX = opts.moveLine[opts.index].startP[0]; |
| | | opts.startY = opts.moveLine[opts.index].startP[1]; |
| | | } |
| | | } |
| | | }else { |
| | | // 开始点在上方 |
| | | if(startP[1] <endP[1]) { |
| | | opts.startY += opts.step; |
| | | |
| | | // 超出就换下一组并切换开始点 |
| | | if(opts.startY > endP[1]) { |
| | | // 不是最后一组点 |
| | | if(opts.index != (opts.moveLine.length-1)) { |
| | | opts.index += 1; |
| | | }else { |
| | | opts.index = 0; |
| | | } |
| | | |
| | | opts.startX = opts.moveLine[opts.index].startP[0]; |
| | | opts.startY = opts.moveLine[opts.index].startP[1]; |
| | | } |
| | | }else { |
| | | opts.startY -= opts.step; |
| | | // 超出就换下一组并切换开始点 |
| | | if(opts.startY < endP[1]) { |
| | | // 不是最后一组点 |
| | | if(opts.index != (opts.moveLine.length-1)) { |
| | | opts.index += 1; |
| | | }else { |
| | | opts.index = 0; |
| | | } |
| | | |
| | | opts.startX = opts.moveLine[opts.index].startP[0]; |
| | | opts.startY = opts.moveLine[opts.index].startP[1]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 存储内容 |
| | | var _tmp = { |
| | | type: 'drawRect', |
| | | options: opts |
| | | }; |
| | | this.opts.push(_tmp); |
| | | }; |
| | | |
| | | //绘制多点 |
| | | EleCircle.prototype.drawRectList = function(lists) { |
| | | // 移除旧的通过lists添加的点 |
| | | this._delRectList(); |
| | | |
| | | // 遍历lists重新绘制亮点 |
| | | for(var i=0; i<lists.length; i++) { |
| | | lists[i].isList = true; |
| | | this.drawRect(lists[i]); |
| | | } |
| | | }; |
| | | |
| | | // 删除通过列表添加的电流的点 |
| | | EleCircle.prototype._delRectList = function() { |
| | | for(var i=0;i<this.opts.length; i++) { |
| | | if(this.opts[i].event = 'drawRect') { |
| | | if(this.opts[i].options.isList) { |
| | | this.opts.splice(i, 1); |
| | | this._delRectList(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 设置文本的值 |
| | | function setEleCircleName(context, options) { |
| | | // startX和StartY是被描述无的中心 |
| | | var defaults = { |
| | | startX: 0, |
| | | startY: 0, |
| | | name: '', |
| | | width: 0, |
| | | height: 0, |
| | | pos: 'left', |
| | | lineHeight: 16, |
| | | lineWidth: 1, |
| | | fontSize: 14, |
| | | txtLength: -1, |
| | | fillStyle: '#000', |
| | | isBg:false, |
| | | bgColor: '#FFFFFF', |
| | | fontWeight: '' |
| | | } |
| | | |
| | | var opts = $.extend({}, defaults, options || {}); |
| | | |
| | | // 判断一行的字数 |
| | | var tLength = (opts.txtLength ==-1)?opts.name.length: |
| | | (opts.txtLength>opts.name.length)?opts.name.length:opts.txtLength; |
| | | |
| | | // 分割name字符串 |
| | | var reg= new RegExp(".{"+tLength+"}", 'g'); |
| | | var rs=opts.name.match(reg); |
| | | if(opts.name.substring(rs.join('').length).length>0) { |
| | | rs.push(opts.name.substring(rs.join('').length)); |
| | | } |
| | | |
| | | var txtWidth = opts.fontSize*tLength; |
| | | var txtHeight = opts.lineHeight*rs.length; |
| | | // 文本开始描绘的位置 |
| | | var txtX = opts.startX; |
| | | var txtY = opts.startY; |
| | | switch(opts.pos) { |
| | | case 'left': |
| | | textX = opts.startX - txtWidth; |
| | | textY = opts.startY - txtHeight/2; |
| | | break; |
| | | case 'up': |
| | | textX = opts.startX - txtWidth/2; |
| | | textY = opts.startY - txtHeight-5; |
| | | break; |
| | | case 'down': |
| | | textX = opts.startX - txtWidth/2; |
| | | textY = opts.startY - txtHeight+5; |
| | | break; |
| | | default: |
| | | textX = opts.startX +5; |
| | | textY = opts.startY - txtHeight/2; |
| | | break; |
| | | } |
| | | if(opts.isBg) { |
| | | // 绘制背景色 |
| | | context.beginPath(); |
| | | context.fillStyle = '#FFFFFF'; |
| | | var strWidth = getStringWidth(rs[0]); |
| | | context.rect(textX,textY-12,strWidth,12); |
| | | context.fill(); |
| | | } |
| | | |
| | | |
| | | |
| | | context.lineWidth = opts.lineWidth; |
| | | context.font = opts.fontSize+'px Arial'; |
| | | context.font += " "+opts.fontWeight; |
| | | context.fillStyle= opts.fillStyle; |
| | | for(var i=0; i<rs.length;i++) { |
| | | context.fillText(rs[i], textX, textY+opts.lineHeight*i); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | // 根据两个坐标轴获取其中心点 |
| | | function getCenterPoint(point1, point2) { |
| | | var rs = []; |
| | | var x = (point1[0]+point2[0])/2; |
| | | var y = (point1[1]+point2[1])/2; |
| | | rs.push(x); |
| | | rs.push(y); |
| | | return rs; |
| | | } |
| | | |
| | | // 获取当前点是否在某条线段上 |
| | | function getPointState(start, end, point) { |
| | | var rs = true, |
| | | max = 0, |
| | | min = 0; |
| | | if(start[0] == end[0]) { |
| | | max = (start[1] > end[1])?start[1]:end[1]; |
| | | min = (start[1] < end[1])?start[1]:end[1]; |
| | | rs = (point[1]<=max && point[1]>=min)? true: false; |
| | | }else { |
| | | max = (start[0] > end[0])?start[0]:end[0]; |
| | | min = (start[0] < end[0])?start[0]:end[0]; |
| | | rs = (point[0]<=max && point[0]>=min)? true: false; |
| | | } |
| | | return rs; |
| | | } |
| | | |
| | | // 通过对象id获取对象然后修改对应的属性值的属性值对对象进行修改 |
| | | function changeEleCircleOpt(eleCircle, id, options) { |
| | | // 遍历eleCircle对象的集合根据id的值修改内容 |
| | | for(var i=0; i<eleCircle.opts.length; i++) { |
| | | if(eleCircle.opts[i].options.id == id) { |
| | | eleCircle.opts[i].options = $.extend({}, eleCircle.opts[i].options, options || {}); |
| | | } |
| | | } |
| | | //eleCircle.redraw(); |
| | | } |
| | | |
| | | // 更改电路图电流的状态 |
| | | function changeCurrentState(values) { |
| | | //console.info(changeCurrentState.isChange); |
| | | var member = [ |
| | | // 浮充 放电测试 稳流充电 直连充电 设备未连接 kd 停电放电 |
| | | 'floatCharge', 'discharge', 'constCharge', 'directCharge', 'unLink', 'kd', 'powerCutDis' |
| | | ]; |
| | | |
| | | var state = member[values]; |
| | | |
| | | if(changeCurrentState.isChange == 1) { |
| | | var opts = eleCircle.opts; |
| | | var currentObj = { |
| | | floatCharge:{ |
| | | points:[ |
| | | [320, 40], [540, 40],[540, 520], |
| | | [430, 520], [430, 360],[320,360] |
| | | ], |
| | | fillStyle: '#533F03', |
| | | isCanMove: 1, |
| | | clockwise: 0, |
| | | txtFillStyle: '#000', |
| | | name: '设备浮充状态电流方向' |
| | | }, |
| | | discharge: { |
| | | points:[ |
| | | [80, 40], [770, 40],[770, 520], |
| | | [430, 520], [430, 360],[80,360] |
| | | ], |
| | | fillStyle: '#FF0000', |
| | | isCanMove: 1, |
| | | clockwise: 1, |
| | | txtFillStyle: '#000', |
| | | name: '设备放电测试时电流方向' |
| | | }, |
| | | constCharge: { |
| | | points:[ |
| | | [245, 40], [570, 40],[570, 520], |
| | | [430, 520], [430, 360],[245,360] |
| | | ], |
| | | fillStyle: '#533F03', |
| | | isCanMove: 1, |
| | | clockwise: 0, |
| | | txtFillStyle: '#000', |
| | | name: '设备稳流充电时电流方向' |
| | | }, |
| | | directCharge: { |
| | | points:[ |
| | | [320, 40], [540, 40],[540, 520], |
| | | [430, 520], [430, 360],[320,360] |
| | | ], |
| | | fillStyle: '#533F03', |
| | | isCanMove: 1, |
| | | clockwise: 0, |
| | | txtFillStyle: '#000', |
| | | name: '设备直连充电时电流方向' |
| | | }, |
| | | unLink: { |
| | | points:[ |
| | | [320, 40], [540, 40],[540, 520], |
| | | [430, 520], [430, 360],[320,360] |
| | | ], |
| | | fillStyle: '#FF0000', |
| | | isCanMove: 0, |
| | | clockwise: 0, |
| | | txtFillStyle: '#FF0000', |
| | | name: '设备未连接' |
| | | }, |
| | | kd: { |
| | | name: 'K1/D1测试' |
| | | }, |
| | | powerCutDis: { |
| | | points:[ |
| | | [320, 40], [540, 40],[540, 520], |
| | | [430, 520], [430, 360],[320,360] |
| | | ], |
| | | fillStyle: '#FF0000', |
| | | isCanMove: 1, |
| | | clockwise: 1, |
| | | txtFillStyle: '#000', |
| | | name: '设备停电放电' |
| | | } |
| | | }; |
| | | |
| | | var currentDotLists = { |
| | | floatCharge: [ // 浮充电流 |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine:[{ |
| | | startP:[586, 460], |
| | | endP:[480, 460] |
| | | },{ |
| | | startP:[480, 460], |
| | | endP: [480, 440] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine:[{ |
| | | startP: [586, 290], |
| | | endP:[586, 460] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[586, 80], |
| | | endP: [586, 190] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[456, 80], |
| | | endP: [586, 80] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[380, 80], |
| | | endP: [440, 80] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[220, 150], |
| | | endP: [220, 80] |
| | | },{ |
| | | startP:[220, 80], |
| | | endP: [380, 80] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[240, 320], |
| | | endP: [220, 320] |
| | | },{ |
| | | startP:[220, 320], |
| | | endP: [220, 250] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[440, 320], |
| | | endP: [380, 320] |
| | | },{ |
| | | startP:[380, 320], |
| | | endP: [300, 320] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[480, 360], |
| | | endP:[480, 320] |
| | | },{ |
| | | startP:[480, 320], |
| | | endP: [456, 320] |
| | | }] |
| | | }, |
| | | |
| | | ], |
| | | discharge:[ |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [{ |
| | | startP:[480, 440], |
| | | endP:[480, 460] |
| | | },{ |
| | | startP:[480, 460], |
| | | endP:[456, 460] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [{ |
| | | startP:[456, 460], |
| | | endP:[380, 460] |
| | | },{ |
| | | startP:[380, 460], |
| | | endP:[300, 460] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [{ |
| | | startP:[240, 460], |
| | | endP:[0, 460] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [{ |
| | | startP:[40, 460], |
| | | endP:[40, 200] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [{ |
| | | startP:[40, 200], |
| | | endP:[70, 200] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [{ |
| | | startP:[120, 250], |
| | | endP:[120, 320] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [{ |
| | | startP:[120, 320], |
| | | endP:[240, 320] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [{ |
| | | startP:[300, 320], |
| | | endP:[445, 320] |
| | | },{ |
| | | startP:[380, 320], |
| | | endP:[445, 320] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [{ |
| | | startP:[450, 320], |
| | | endP:[480, 320] |
| | | },{ |
| | | startP:[480, 320], |
| | | endP:[480, 360] |
| | | }] |
| | | }, |
| | | ], |
| | | directCharge: [ |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine:[{ |
| | | startP:[480, 440], |
| | | endP: [480, 460] |
| | | },{ |
| | | startP:[480, 460], |
| | | endP:[586, 460] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine:[{ |
| | | startP:[586, 460], |
| | | endP:[526, 290] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[586, 190], |
| | | endP: [586, 80] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[586, 80], |
| | | endP: [456, 80] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[440, 80], |
| | | endP: [380, 80] |
| | | },{ |
| | | startP:[380, 80], |
| | | endP: [380, 170] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[380, 226], |
| | | endP: [380, 320] |
| | | },{ |
| | | startP:[380, 320], |
| | | endP: [440, 320] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[456, 320], |
| | | endP: [480, 320] |
| | | },{ |
| | | startP:[480, 320], |
| | | endP:[480, 360] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine:[{ |
| | | startP:[586, 80], |
| | | endP: [740, 80] |
| | | },{ |
| | | startP:[740, 80], |
| | | endP: [740, 190] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[740, 290], |
| | | endP: [740, 460] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[740, 460], |
| | | endP: [586, 460] |
| | | }] |
| | | } |
| | | ], |
| | | constCharge: [ |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine:[{ |
| | | startP:[480, 440], |
| | | endP: [480, 460] |
| | | },{ |
| | | startP:[480, 460], |
| | | endP:[586, 460] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine:[{ |
| | | startP:[586, 460], |
| | | endP:[526, 290] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[586, 190], |
| | | endP: [586, 80] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[586, 80], |
| | | endP: [456, 80] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[440, 80], |
| | | endP: [380, 80] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [380, 80], |
| | | endP: [220, 80] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [220, 80], |
| | | endP: [220, 150] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [220, 250], |
| | | endP: [220, 320] |
| | | },{ |
| | | startP: [220, 320], |
| | | endP: [250, 320] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [305, 320], |
| | | endP: [440, 320] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [456, 320], |
| | | endP: [480, 320] |
| | | },{ |
| | | startP: [480, 320], |
| | | endP: [480, 360] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine:[{ |
| | | startP:[586, 80], |
| | | endP: [740, 80] |
| | | },{ |
| | | startP:[740, 80], |
| | | endP: [740, 190] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[740, 290], |
| | | endP: [740, 460] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP:[740, 460], |
| | | endP: [586, 460] |
| | | }] |
| | | } |
| | | ], |
| | | unLink: [], |
| | | kd: [ |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [380, 80], |
| | | endP: [380, 170] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [380, 226], |
| | | endP: [380, 320] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [380, 320], |
| | | endP: [305, 320] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [250, 320], |
| | | endP: [120, 320] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [120, 320], |
| | | endP: [120, 250] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [120, 150], |
| | | endP: [120, 80] |
| | | }] |
| | | }, |
| | | { |
| | | fillColor:'#3d90df', |
| | | moveLine: [{ |
| | | startP: [120, 80], |
| | | endP: [380, 80] |
| | | }] |
| | | } |
| | | ], |
| | | powerCutDis:[ |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [ |
| | | { |
| | | startP: [480, 360], |
| | | endP: [480, 320] |
| | | }, |
| | | { |
| | | startP: [480, 320], |
| | | endP: [456, 320] |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [ |
| | | { |
| | | startP: [440, 320], |
| | | endP: [380, 320] |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [ |
| | | { |
| | | startP: [380, 320], |
| | | endP: [380, 226] |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [ |
| | | { |
| | | startP: [380, 170], |
| | | endP: [380, 80] |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [ |
| | | { |
| | | startP: [380, 80], |
| | | endP: [440, 80] |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [ |
| | | { |
| | | startP: [456, 80], |
| | | endP: [740, 80] |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [ |
| | | { |
| | | startP: [740, 80], |
| | | endP: [740, 190] |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [ |
| | | { |
| | | startP: [740, 290], |
| | | endP: [740, 460] |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [ |
| | | { |
| | | startP: [740, 460], |
| | | endP: [586, 460] |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | fillColor:'#FF0000', |
| | | moveLine: [ |
| | | { |
| | | startP: [586, 460], |
| | | endP: [480, 460] |
| | | }, |
| | | { |
| | | startP: [480, 460], |
| | | endP: [480, 440] |
| | | } |
| | | ] |
| | | }, |
| | | ] |
| | | }; |
| | | |
| | | var currList = currentDotLists[state]; |
| | | eleCircle.drawRectList(currList) |
| | | |
| | | var switchBtn = { |
| | | floatCharge:{ |
| | | open:{stats: 'on'}, // 常开接触器 |
| | | close: {stats: 'off'} // 常闭接触器 |
| | | }, |
| | | discharge: { |
| | | open:{stats: 'on'}, |
| | | close: {stats: 'off'} |
| | | }, |
| | | constCharge: { |
| | | open:{stats: 'on'}, |
| | | close: {stats: 'off'} |
| | | }, |
| | | directCharge:{ |
| | | open:{stats: 'off'}, |
| | | close: {stats: 'on'} |
| | | }, |
| | | unLink: { |
| | | open:{stats: 'off'}, |
| | | close: {stats: 'on'} |
| | | }, |
| | | kd: { |
| | | open:{stats: 'on'}, |
| | | close:{stats: 'on'} |
| | | }, |
| | | powerCutDis: { |
| | | open: {stats: 'off'}, |
| | | close: {stats: 'on'} |
| | | } |
| | | |
| | | } |
| | | |
| | | var eleCurrent = { |
| | | floatCharge:{ |
| | | fillStyle: '#000' |
| | | }, |
| | | discharge: { |
| | | fillStyle: '#FF0000' |
| | | }, |
| | | constCharge: { |
| | | fillStyle: '#000' |
| | | }, |
| | | directCharge:{ |
| | | fillStyle: '#000' |
| | | }, |
| | | unLink: { |
| | | fillStyle: '#FF0000' |
| | | }, |
| | | kd: { |
| | | fillStyle: '#000' |
| | | }, |
| | | powerCutDis: { |
| | | fillStyle: '#FF0000' |
| | | } |
| | | }; |
| | | |
| | | var btnObj = switchBtn[state]; |
| | | |
| | | |
| | | var titleList = { |
| | | floatCharge:{ |
| | | fillStyle: '#000', |
| | | name: '设备浮充状态' |
| | | }, |
| | | discharge: { |
| | | fillStyle: '#000', |
| | | name: '设备放电测试' |
| | | }, |
| | | constCharge: { |
| | | fillStyle: '#000', |
| | | name: '设备稳流充电' |
| | | }, |
| | | directCharge: { |
| | | fillStyle: '#000', |
| | | name: '设备直连充电' |
| | | }, |
| | | unLink: { |
| | | fillStyle: '#FF0000', |
| | | name: '设备未连接' |
| | | }, |
| | | kd: { |
| | | fillStyle: '#000', |
| | | name: 'K1/D1测试' |
| | | }, |
| | | powerCutDis: { |
| | | fillStyle: '#000', |
| | | name: '设备停电放电' |
| | | } |
| | | }; |
| | | |
| | | changeEleCircleOpt(eleCircle, 'title', titleList[state]); // 拓扑图内容 |
| | | |
| | | //console.info(btnObj.open); |
| | | // 设置电流的状态改变了 |
| | | var temp= { |
| | | isChange: 1, |
| | | } |
| | | |
| | | var currentColor = eleCurrent[state]; |
| | | |
| | | temp = $.extend({}, currentObj[state], temp); |
| | | // 根据状态 |
| | | changeEleCircleOpt(eleCircle, 'current', temp); |
| | | |
| | | // 更新电路图中开关的状态 |
| | | changeEleCircleOpt(eleCircle, 'ko', btnObj.close); // 常闭开关 |
| | | changeEleCircleOpt(eleCircle, 'km', btnObj.open); // 常开开关 |
| | | changeEleCircleOpt(eleCircle, 'kc', btnObj.open); // 常开开关 |
| | | |
| | | changeEleCircleOpt(eleCircle, 'eleCurrent', currentColor); |
| | | } |
| | | changeCurrentState.isChange = 0; // 恢复状态为0 |
| | | } |
| | | |
| | | changeCurrentState.isChange = 0; // 设置默认的值为不改变 |
| | | |
| | | // 检测文本的长度 |
| | | function getStringWidth(str, fontsize) { |
| | | var _fontSize = fontsize?fontsize:12; // 默认为12像素 |
| | | var _width = 0; |
| | | // 遍历字符串中每个字符 |
| | | for(var i=0; i<str.length; i++) { |
| | | var chart = str.charAt(i); |
| | | if(isNaN(chart)) { |
| | | _width += _fontSize; |
| | | }else { |
| | | _width += _fontSize/2; |
| | | } |
| | | } |
| | | |
| | | return _width; |
| | | } |