88import java .util .Collections ;
99import java .util .List ;
1010
11+ import javax .swing .JOptionPane ;
12+
1113import com .modsim .modules .ports .BidirPort ;
14+ import com .modsim .Main ;
1215import com .modsim .modules .parts .Port ;
16+ import com .modsim .modules .parts .SSText ;
1317import com .modsim .res .Colors ;
1418import com .modsim .simulator .PickableEntity ;
1519import com .modsim .util .BezierCurve ;
@@ -74,6 +78,14 @@ public SplitMerge() {
7478 cs [8 ] = new BezierCurve (new Vec2 (B + b1 , 23 ), new Vec2 (d - b0 , -23 ), // B1-d0
7579 new Vec2 (B + b1 , -15 ), new Vec2 (d - b0 , 15 ));
7680 curves = Collections .unmodifiableList (Arrays .asList (cs ));
81+
82+ parts .add (new SSText (A -10 , 24 , "DCBA" , 7 , Colors .labelText ));
83+ parts .add (new SSText (B -10 , 24 , "XXDC" , 7 , Colors .labelText ));
84+ parts .add (new SSText (a +10 , -24 , "ABXX" , -7 , Colors .labelText ));
85+ parts .add (new SSText (b +10 , -24 , "BXXX" , -7 , Colors .labelText ));
86+ parts .add (new SSText (c +10 , -24 , "CDXX" , -7 , Colors .labelText ));
87+ parts .add (new SSText (d +10 , -24 , "DXXX" , -7 , Colors .labelText ));
88+
7789 }
7890
7991 @ Override
@@ -133,12 +145,22 @@ public void propagate() {
133145
134146 // Switch based on propagation direction
135147 if (portA0 .wasUpdated () || portA1 .wasUpdated ()) {
148+ if (portA0 .isConnected () && portA1 .isConnected ())
149+ {
150+ JOptionPane .showMessageDialog (Main .ui .pane , "Error: There must only be one connection to that size of split/merge." );
151+ Port port = portA0 .wasUpdated ()?portA0 :portA1 ;
152+ synchronized (Main .sim )
153+ {
154+ Main .sim .removeLink (port .link );
155+ }
156+ return ;
157+ }
136158 b0_val .setBit (0 , a0_val .getBit (0 )); // A0-a0
137159 b1_val .setBit (0 , a0_val .getBit (1 )); // A1-b1
138160 b0_val .setBit (1 , a0_val .getBit (1 )); // A1-a1
139161
140162 // Resolution of 3-state logic for merges
141- b3_val .setBit (0 , a0_val .getBit (3 )); // A3-d0
163+ b3_val .setBit (0 , a0_val .getBit (3 )); // A3-d0
142164 b3_val .resolveBit (0 , a1_val .getBit (1 )); // B1-d0
143165
144166 b2_val .setBit (0 , a0_val .getBit (2 )); // A2-c0
@@ -151,15 +173,15 @@ else if ( portB0.wasUpdated() || portB1.wasUpdated() ||
151173 portB2 .wasUpdated () || portB3 .wasUpdated ()) {
152174 a0_val .setBit (0 , b0_val .getBit (0 )); // a0-A0
153175 a0_val .setBit (2 , b2_val .getBit (0 )); // c0-A2
154- a0_val .setBit (3 , b2_val .getBit (1 )); // c1-A3
155176 a1_val .setBit (0 , b2_val .getBit (0 )); // c0-B0
156177
157178 // Resolution of 3-state logic for merges
158- a1_val .setBit (1 , b2_val .getBit (1 )); // c1-B1
159- a1_val .resolveBit (1 , b3_val .getBit (0 )); // d0-B1
160-
161- a0_val .setBit (1 , b0_val .getBit (1 )); // a1-A1
162- a0_val .resolveBit (1 , b1_val .getBit (0 )); // b0-A1
179+ int val = b2_val .getBit (1 ) | b3_val .getBit (0 );
180+ a1_val .setBit (1 , val );
181+ a0_val .setBit (3 , val );
182+
183+ val = b0_val .getBit (1 ) | b1_val .getBit (0 );
184+ a0_val .setBit (1 , val );
163185 }
164186
165187 // Set the values
0 commit comments