增加对 ? 的支持
This commit is contained in:
parent
1cf41bd897
commit
860d5df52a
@ -215,7 +215,7 @@ text.high-impedance {
|
||||
}
|
||||
|
||||
text.unknown {
|
||||
fill: hsl(287, 100%, 67%);
|
||||
fill: #f48771;
|
||||
}
|
||||
|
||||
text.pc {
|
||||
|
@ -27,13 +27,13 @@ const screenWidthPixel = window.screen.width * getRatio() / 100;
|
||||
// rgba 颜色通道,都是预设的颜色
|
||||
export const gl_Colors_template = [
|
||||
[0, 0, 0, 0 ], // 0: 空
|
||||
[0, 0, 255, 1], // 1: 未知态 X 默认颜色
|
||||
[0, 0, 255, 1], // 1: 未知态 默认颜色
|
||||
[51, 230, 26, 1], // 2: value = 0 用于 width = 1 的信号 默认颜色
|
||||
[51, 230, 26, 1], // 3: value = 1 用于 width = 1 的信号 默认颜色
|
||||
[230, 51, 51, 1], // 4: 高阻态 Z 默认颜色
|
||||
[230, 51, 51, 1], // 4: 高阻态 X 默认颜色
|
||||
[124, 77, 255, 1], // 5: vec 用于 width > 1 的信号
|
||||
[255, 0, 255, 1], // 6: yellow
|
||||
[255, 0, 255, 1], // 7: strange purple
|
||||
[244, 135, 113, 1], // 7: unknown,vec 未知状态,混杂了 x 的数值
|
||||
[0, 255, 0, 0.5], // 8: (l L) weak 0
|
||||
[255, 0, 255, 0.5], // 9: (h H) weak 1
|
||||
[255, 0, 0, 0.5], // 10: (w W) weak unknown
|
||||
|
@ -205,15 +205,11 @@ class WebGL2WaveRender {
|
||||
* maskVertices: Int32Array
|
||||
* }}
|
||||
*/
|
||||
makeVecVertex(link, wave, time, debug = false) {
|
||||
makeVecVertex(link, wave, time) {
|
||||
const lookup = this.globalLookup;
|
||||
const vecRenderFn = this.selectVecRenderFn(lookup, link, wave, time);
|
||||
const { lineVertices, maskVertices } = vecRenderFn(lookup, link, wave, time);
|
||||
|
||||
if (debug) {
|
||||
console.log(lineVertices);
|
||||
}
|
||||
|
||||
return {
|
||||
lineVertices: new Int32Array(lineVertices),
|
||||
maskVertices: new Int32Array(maskVertices)
|
||||
|
@ -293,7 +293,6 @@ export class JSValueRender {
|
||||
// 未知
|
||||
default: return '?';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -292,6 +292,10 @@ export function renderAsCommonDigital(lookup, link, wave, time) {
|
||||
const lineVertices = [];
|
||||
const maskVertices = [];
|
||||
|
||||
// 获取外部自定义颜色
|
||||
// 这部分颜色只会染色非异常部分的信号
|
||||
let userDefineCommonColor = getUserDefineCommonColor(lookup, link);
|
||||
|
||||
for (let i = 0; i < length; ++ i) {
|
||||
const [t1, val, mask] = wave[i];
|
||||
const t2 = (i === (length - 1)) ? time : wave[i + 1][0];
|
||||
@ -306,15 +310,21 @@ export function renderAsCommonDigital(lookup, link, wave, time) {
|
||||
const a2 = {x: t1, y: 1, shift: 1};
|
||||
const a3 = {x: t2, y: 1, shift: 2};
|
||||
|
||||
// 选择当前的颜色
|
||||
// 颜色的定义在 gl_Colors_template 中
|
||||
// 默认为 5,vec 专用颜色
|
||||
let color = 5;
|
||||
const renderOptions = lookup.currentSignalRenderOptions;
|
||||
if (mask) {
|
||||
color = 4;
|
||||
} else if (renderOptions.has(link)) {
|
||||
const option = renderOptions.get(link);
|
||||
if (typeof option.color === 'number') {
|
||||
color = option.color;
|
||||
if (val) {
|
||||
// ? 代表 unknown,比如 b1xx0xx0xx1xx000xxxx0 这种,一部分高阻的就是
|
||||
color = 7;
|
||||
} else {
|
||||
// 颜色 4 代表高阻态
|
||||
color = 4;
|
||||
}
|
||||
} else if (userDefineCommonColor !== undefined) {
|
||||
color = userDefineCommonColor;
|
||||
}
|
||||
|
||||
const points = [ a1, p1, a3, a2, p0, a0 ];
|
||||
@ -474,21 +484,29 @@ function getMappingFunc(formatCode, maxVal, minVal) {
|
||||
* @returns {VecRenderNumberVertices}
|
||||
*/
|
||||
export function renderAsLadderAnalog(lookup, link, wave, time) {
|
||||
const renderOptions = lookup.currentSignalRenderOptions;
|
||||
const formatCode = getValFormatCode(lookup, link);
|
||||
const signal = lookup.link2CurrentWires.get(link);
|
||||
const width = signal.size;
|
||||
|
||||
const { maxVal, minVal } = getMaxMinByFormat(link, wave, time, formatCode, width);
|
||||
const coordinateTransform = getMappingFunc(formatCode, maxVal, minVal);
|
||||
|
||||
// 数值解释器,负责将对应的数值翻译成渲染用的 y
|
||||
const valueRender = new JSValueRender(link, width);
|
||||
|
||||
// 获取外部自定义颜色
|
||||
// 这部分颜色只会染色非异常部分的信号
|
||||
let userDefineCommonColor = getUserDefineCommonColor(lookup, link);
|
||||
|
||||
function makeLadderAnalogRenderParam(link, wave, time) {
|
||||
const [t1, val, mask] = wave;
|
||||
|
||||
if (mask) {
|
||||
// 不定态
|
||||
return { y: -1, color: 4 };
|
||||
// 颜色 4 代表高阻态
|
||||
// 7 代表 unknown,比如 b1xx0xx0xx1xx000xxxx0 这种,一部分高阻的就是
|
||||
let color = val ? 7 : 4;
|
||||
|
||||
return { y: -1, color };
|
||||
}
|
||||
|
||||
// 根据当前格式进行转换
|
||||
@ -497,11 +515,8 @@ export function renderAsLadderAnalog(lookup, link, wave, time) {
|
||||
const y = coordinateTransform(numVal);
|
||||
const colorParam = { y, color: 5 };
|
||||
|
||||
if (renderOptions.has(link)) {
|
||||
const option = renderOptions.get(link);
|
||||
if (typeof option.color === 'number') {
|
||||
colorParam.color = option.color;
|
||||
}
|
||||
if (userDefineCommonColor !== undefined) {
|
||||
colorParam.color = userDefineCommonColor;
|
||||
}
|
||||
|
||||
return colorParam;
|
||||
@ -631,6 +646,24 @@ function getSlope(p1, p2, p3) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 获取用户定义这个信号的颜色,只选择正常部分的颜色
|
||||
* @param {GlobalLookup} lookup
|
||||
* @param {string} link
|
||||
* @returns {number | undefined}
|
||||
*/
|
||||
function getUserDefineCommonColor(lookup, link) {
|
||||
const renderOptions = lookup.currentSignalRenderOptions;
|
||||
if (renderOptions.has(link)) {
|
||||
const option = renderOptions.get(link);
|
||||
if (typeof option.color === 'number') {
|
||||
return option.color;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Analog (Line) 模拟状
|
||||
* @param {GlobalLookup} lookup
|
||||
@ -640,7 +673,6 @@ function getSlope(p1, p2, p3) {
|
||||
* @returns {VecRenderNumberVertices}
|
||||
*/
|
||||
export function renderAsLineAnalog(lookup, link, wave, time) {
|
||||
const renderOptions = lookup.currentSignalRenderOptions;
|
||||
const formatCode = getValFormatCode(lookup, link);
|
||||
const signal = lookup.link2CurrentWires.get(link);
|
||||
const width = signal.size;
|
||||
@ -651,14 +683,24 @@ export function renderAsLineAnalog(lookup, link, wave, time) {
|
||||
const length = wave.length;
|
||||
const lineVertices = [];
|
||||
const maskVertices = [];
|
||||
|
||||
// 数值解释器,负责将对应的数值翻译成渲染用的 y
|
||||
const valueRender = new JSValueRender(link, width);
|
||||
|
||||
// 获取外部自定义颜色
|
||||
// 这部分颜色只会染色非异常部分的信号
|
||||
let userDefineCommonColor = getUserDefineCommonColor(lookup, link);
|
||||
|
||||
function makeLineAnalogRenderParam(link, wave, time) {
|
||||
const [t1, val, mask] = wave;
|
||||
|
||||
if (mask) {
|
||||
// 颜色 4 代表高阻态
|
||||
// 7 代表 unknown,比如 b1xx0xx0xx1xx000xxxx0 这种,一部分高阻的就是
|
||||
let color = val ? 7 : 4;
|
||||
|
||||
// 不定态
|
||||
return { y: -1, color: 4 };
|
||||
return { y: -1, color };
|
||||
}
|
||||
|
||||
// 根据当前格式进行转换
|
||||
@ -667,11 +709,8 @@ export function renderAsLineAnalog(lookup, link, wave, time) {
|
||||
const y = coordinateTransform(numVal);
|
||||
const colorParam = { y, color: 5 };
|
||||
|
||||
if (renderOptions.has(link)) {
|
||||
const option = renderOptions.get(link);
|
||||
if (typeof option.color === 'number') {
|
||||
colorParam.color = option.color;
|
||||
}
|
||||
if (userDefineCommonColor !== undefined) {
|
||||
colorParam.color = userDefineCommonColor;
|
||||
}
|
||||
|
||||
return colorParam;
|
||||
|
Loading…
x
Reference in New Issue
Block a user