ViewLogicModelAdapter now supports directly connected interface pins
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / modeladapter / ViewLogicModelAdapter.java
index 8c478ae..193e240 100644 (file)
@@ -72,9 +72,9 @@ public class ViewLogicModelAdapter
                        if (guiComp instanceof SubmodelComponent)
                        {
                                SubmodelComponent guiCompCasted = (SubmodelComponent) guiComp;
-                               Map<Pin, Pin> supermodelPinsPerSubmodelPin = guiCompCasted.getSupermodelPinsPerSubmodelPin();
-                               Map<Pin, Wire> externalWiresForSubmodel = supermodelPinsPerSubmodelPin.entrySet().stream()
-                                               .collect(Collectors.toMap(Entry::getKey, e -> logicWiresPerPin.get(e.getValue())));
+                               Map<String, Pin> supermodelPins = guiCompCasted.getSupermodelPins();
+                               Map<Pin, Wire> externalWiresForSubmodel = supermodelPins.entrySet().stream()
+                                               .collect(Collectors.toMap(e -> guiCompCasted.getSubmodelPin(e.getKey()), e -> logicWiresPerPin.get(e.getValue())));
                                convert(guiCompCasted.submodel, params, timeline, externalWiresForSubmodel);
                        } else if (guiComp instanceof WireCrossPoint)
                        {
@@ -114,8 +114,11 @@ public class ViewLogicModelAdapter
                                        if (externalWireCandidate != null)
                                                if (externalWire == null)
                                                        externalWire = externalWireCandidate;
+                                               else if (externalWire.length == externalWireCandidate.length)
+                                                       Wire.fuse(externalWire, externalWireCandidate);
                                                else
-                                                       throw new IllegalArgumentException("Two pins to external wires can't be connected directly");
+                                                       throw new IllegalArgumentException(
+                                                                       "Two pins to external wires with different logicWidths can't be connected directly");
                                }
                                return externalWire == null ? new Wire(timeline, e.getKey().logicWidth, params.wireTravelTime) : externalWire;
                        }));