gaoyakang / online_logisim

仿制 logisim 的在线网站版本
https://mrx.wiki/
MIT License
6 stars 0 forks source link

rs的状态弄反了 #5

Closed gaoyakang closed 3 days ago

gaoyakang commented 3 days ago

online_logisim/src/core/nodes/flipFlop/rsFlipFlop

下列代码将rs的状态弄反了:

// ....
node.anchors.forEach((anchor) => {
    const { id } = anchor;
    // 找到对应的锚点
    if (id === 'rsFlipFlop-lefttop-input') {
      // S输入
      lf.graphModel.edges.forEach((edge) => {
        if (edge.targetAnchorId === id) {
          const sourceNode = activeNodes.value[edge.sourceNodeId] || false ;
          S = sourceNode.active ? '1' : '0';
        }
      });
    } else if (id === 'rsFlipFlop-leftbottom-input') {
      // R输入
      lf.graphModel.edges.forEach((edge) => {
        if (edge.targetAnchorId === id) {
          const sourceNode = activeNodes.value[edge.sourceNodeId] || false;
          R = sourceNode.active ? '1' : '0';
        }
      });
    } else if (id === 'rsFlipFlop-leftmiddle-input') {
      // C输入
      lf.graphModel.edges.forEach((edge) => {
        if (edge.targetAnchorId === id) {
          const sourceNode = activeNodes.value[edge.sourceNodeId] || false;
          C = sourceNode.active ? '1' : '0';
        }
      });
    }
  });

// ...
gaoyakang commented 3 days ago

已修复:https://github.com/gaoyakang/online_logisim/commit/08986a49aed4cb184430b45acd02aa57d9f9e333