Fixed two small bugs in the two Delegating...Handlers:
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 25 Sep 2019 16:42:18 +0000 (18:42 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 25 Sep 2019 17:00:18 +0000 (19:00 +0200)
1. DelegatingSubcomponentHighLevelStateHandler#getParamsForSerializing
now throws a meaningful exception when the delegate target was destroyed
2. Both now support serializing delegating to the parent

plugins/net.mograsim.logic.model.am2900/components/net/mograsim/logic/model/am2900/components/Am2900.json
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/atomic/DelegatingAtomicHighLevelStateHandler.java
plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/subcomponent/DelegatingSubcomponentHighLevelStateHandler.java

index 8b2c9cf..74c0beb 100644 (file)
         "id": "Clock",
         "name": "Clock#0",
         "pos": {
-          "x": 75.0,
+          "x": 70.0,
           "y": 365.0
         },
         "params": {
         "id": "ManualSwitch",
         "name": "ManualSwitch#0",
         "pos": {
-          "x": 75.0,
+          "x": 70.0,
           "y": 347.5
         },
         "params": 1
         "id": "ManualSwitch",
         "name": "ManualSwitch#1",
         "pos": {
-          "x": 75.0,
+          "x": 70.0,
           "y": 387.5
         },
         "params": 1
         "id": "NandGate",
         "name": "NandGate#5",
         "pos": {
-          "x": 60.0,
+          "x": 105.0,
           "y": 235.0
         },
         "params": 1
         "id": "NandGate",
         "name": "NandGate#6",
         "pos": {
-          "x": 150.0,
+          "x": 145.0,
           "y": 375.0
         },
         "params": 1
         "id": "NandGate",
         "name": "NandGate#7",
         "pos": {
-          "x": 65.0,
+          "x": 110.0,
           "y": 270.0
         },
         "params": 1
         "id": "WireCrossPoint",
         "name": "WireCrossPoint#38",
         "pos": {
-          "x": 174.0,
+          "x": 169.0,
           "y": 384.0
         },
         "params": 1
         "id": "WireCrossPoint",
         "name": "WireCrossPoint#39",
         "pos": {
-          "x": 179.0,
+          "x": 174.0,
           "y": 364.0
         },
         "params": 1
         "id": "WireCrossPoint",
         "name": "WireCrossPoint#40",
         "pos": {
-          "x": 144.0,
+          "x": 139.0,
           "y": 364.0
         },
         "params": 1
         "id": "WireCrossPoint",
         "name": "WireCrossPoint#41",
         "pos": {
-          "x": 144.0,
+          "x": 139.0,
           "y": 379.0
         },
         "params": 1
         "name": "WireCrossPoint#42",
         "pos": {
           "x": 364.0,
-          "y": 289.0
+          "y": 314.0
         },
         "params": 1
       },
         "name": "WireCrossPoint#44",
         "pos": {
           "x": 174.0,
-          "y": 289.0
+          "y": 254.0
         },
         "params": 1
       },
         "id": "WireCrossPoint",
         "name": "WireCrossPoint#45",
         "pos": {
-          "x": 129.0,
+          "x": 174.0,
           "y": 304.0
         },
         "params": 1
         "id": "WireCrossPoint",
         "name": "WireCrossPoint#46",
         "pos": {
-          "x": 129.0,
+          "x": 174.0,
           "y": 279.0
         },
         "params": 1
         "id": "WireCrossPoint",
         "name": "WireCrossPoint#47",
         "pos": {
-          "x": 59.0,
+          "x": 104.0,
           "y": 294.0
         },
         "params": 1
         "id": "WireCrossPoint",
         "name": "WireCrossPoint#48",
         "pos": {
-          "x": 84.0,
+          "x": 129.0,
           "y": 244.0
         },
         "params": 1
         "id": "WireCrossPoint",
         "name": "WireCrossPoint#49",
         "pos": {
-          "x": 59.0,
+          "x": 104.0,
           "y": 274.0
         },
         "params": 1
         "id": "WireCrossPoint",
         "name": "WireCrossPoint#52",
         "pos": {
-          "x": 59.0,
+          "x": 104.0,
           "y": 284.0
         },
         "params": 1
       },
-      {
-        "id": "WireCrossPoint",
-        "name": "WireCrossPoint#53",
-        "pos": {
-          "x": 174.0,
-          "y": 314.0
-        },
-        "params": 1
-      },
       {
         "id": "and",
         "name": "and#0",
         "id": "and",
         "name": "and#3",
         "pos": {
-          "x": 90.0,
+          "x": 135.0,
           "y": 240.0
         }
       },
         "id": "and",
         "name": "and#4",
         "pos": {
-          "x": 90.0,
+          "x": 135.0,
           "y": 265.0
         }
       },
-      {
-        "id": "and",
-        "name": "and#5",
-        "pos": {
-          "x": 185.0,
-          "y": 240.0
-        }
-      },
       {
         "id": "dff16",
         "name": "dff16#0",
         "id": "dff",
         "name": "dff#0",
         "pos": {
-          "x": 135.0,
+          "x": 180.0,
           "y": 265.0
         }
       },
         "id": "dff",
         "name": "dff#1",
         "pos": {
-          "x": 135.0,
+          "x": 180.0,
           "y": 240.0
         }
       },
         "id": "dff",
         "name": "dff#2",
         "pos": {
-          "x": 135.0,
+          "x": 180.0,
           "y": 290.0
         }
       },
         "id": "mux1",
         "name": "mux1#0",
         "pos": {
-          "x": 105.0,
+          "x": 100.0,
           "y": 360.0
         }
       },
         "name": "unnamedWire#96",
         "path": [
           {
-            "x": 145.0,
+            "x": 140.0,
             "y": 390.0
           }
         ]
         "name": "unnamedWire#99",
         "path": [
           {
-            "x": 175.0,
+            "x": 170.0,
             "y": 485.0
           },
           {
         "name": "unnamedWire#102",
         "path": [
           {
-            "x": 180.0,
+            "x": 175.0,
             "y": 480.0
           },
           {
             "y": 325.0
           },
           {
-            "x": 55.0,
+            "x": 100.0,
             "y": 325.0
           },
           {
-            "x": 55.0,
+            "x": 100.0,
             "y": 250.0
           }
         ]
             "y": 320.0
           },
           {
-            "x": 60.0,
+            "x": 105.0,
             "y": 320.0
           }
         ]
         "name": "unnamedWire#335",
         "path": [
           {
-            "x": 55.0,
+            "x": 100.0,
             "y": 230.0
           },
           {
-            "x": 55.0,
+            "x": 100.0,
             "y": 240.0
           }
         ]
           "pinName": ""
         },
         "pin2": {
-          "compName": "WireCrossPoint#53",
+          "compName": "WireCrossPoint#42",
           "pinName": ""
         },
         "name": "unnamedWire#346",
-        "path": []
+        "path": [
+          {
+            "x": 170.0,
+            "y": 315.0
+          }
+        ]
       },
       {
         "pin1": {
         "path": [
           {
             "x": 480.0,
-            "y": 290.0
+            "y": 315.0
           },
           {
             "x": 480.0,
       },
       {
         "pin1": {
-          "compName": "WireCrossPoint#44",
+          "compName": "WireCrossPoint#46",
           "pinName": ""
         },
         "pin2": {
-          "compName": "WireCrossPoint#42",
+          "compName": "WireCrossPoint#44",
           "pinName": ""
         },
         "name": "unnamedWire#352",
       },
       {
         "pin1": {
-          "compName": "WireCrossPoint#53",
+          "compName": "WireCrossPoint#39",
           "pinName": ""
         },
         "pin2": {
-          "compName": "WireCrossPoint#44",
+          "compName": "WireCrossPoint#45",
           "pinName": ""
         },
         "name": "unnamedWire#353",
       },
       {
         "pin1": {
-          "compName": "WireCrossPoint#53",
+          "compName": "WireCrossPoint#44",
           "pinName": ""
         },
         "pin2": {
-          "compName": "WireCrossPoint#45",
-          "pinName": ""
+          "compName": "dff16#1",
+          "pinName": "C"
         },
         "name": "unnamedWire#354",
         "path": [
           {
-            "x": 130.0,
-            "y": 315.0
+            "x": 175.0,
+            "y": 70.0
           }
         ]
       },
           "pinName": ""
         },
         "pin2": {
-          "compName": "dff16#1",
+          "compName": "dff#1",
           "pinName": "C"
         },
         "name": "unnamedWire#355",
-        "path": [
-          {
-            "x": 175.0,
-            "y": 70.0
-          }
-        ]
+        "path": []
       },
       {
         "pin1": {
       },
       {
         "pin1": {
-          "compName": "and#5",
-          "pinName": "Y"
+          "compName": "dff#1",
+          "pinName": "Q"
         },
         "pin2": {
           "compName": "TriStateBuffer#4",
         "name": "unnamedWire#358",
         "path": [
           {
-            "x": 225.0,
+            "x": 220.0,
             "y": 245.0
           },
           {
-            "x": 225.0,
+            "x": 220.0,
             "y": 200.0
           },
           {
         "name": "unnamedWire#359",
         "path": [
           {
-            "x": 230.0,
+            "x": 225.0,
             "y": 270.0
           },
           {
-            "x": 230.0,
+            "x": 225.0,
             "y": 170.0
           },
           {
         "name": "unnamedWire#364",
         "path": [
           {
-            "x": 60.0,
+            "x": 105.0,
             "y": 260.0
           },
           {
-            "x": 80.0,
+            "x": 125.0,
             "y": 260.0
           },
           {
-            "x": 80.0,
+            "x": 125.0,
             "y": 255.0
           }
         ]
         "name": "unnamedWire#365",
         "path": [
           {
-            "x": 85.0,
+            "x": 130.0,
             "y": 270.0
           }
         ]
         "name": "unnamedWire#375",
         "path": []
       },
-      {
-        "pin1": {
-          "compName": "WireCrossPoint#46",
-          "pinName": ""
-        },
-        "pin2": {
-          "compName": "dff#1",
-          "pinName": "C"
-        },
-        "name": "unnamedWire#376",
-        "path": [
-          {
-            "x": 130.0,
-            "y": 255.0
-          }
-        ]
-      },
       {
         "pin1": {
           "compName": "dff#2",
           "compName": "Am2900MainMemory#0",
           "pinName": "RW"
         },
-        "name": "unnamedWire#377",
+        "name": "unnamedWire#376",
         "path": [
           {
-            "x": 235.0,
+            "x": 230.0,
             "y": 295.0
           },
           {
-            "x": 235.0,
+            "x": 230.0,
             "y": 210.0
           },
           {
           }
         ]
       },
-      {
-        "pin1": {
-          "compName": "dff#1",
-          "pinName": "Q"
-        },
-        "pin2": {
-          "compName": "and#5",
-          "pinName": "A"
-        },
-        "name": "unnamedWire#378",
-        "path": []
-      },
-      {
-        "pin1": {
-          "compName": "WireCrossPoint#39",
-          "pinName": ""
-        },
-        "pin2": {
-          "compName": "and#5",
-          "pinName": "B"
-        },
-        "name": "unnamedWire#379",
-        "path": [
-          {
-            "x": 180.0,
-            "y": 255.0
-          }
-        ]
-      },
       {
         "pin1": {
           "compName": "ManualSwitch#0",
           "compName": "mux1#0",
           "pinName": "S0"
         },
-        "name": "unnamedWire#380",
+        "name": "unnamedWire#377",
         "path": [
           {
-            "x": 100.0,
+            "x": 95.0,
             "y": 355.0
           },
           {
-            "x": 100.0,
+            "x": 95.0,
             "y": 365.0
           }
         ]
           "compName": "mux1#0",
           "pinName": "I1"
         },
-        "name": "unnamedWire#381",
+        "name": "unnamedWire#378",
         "path": [
           {
-            "x": 100.0,
+            "x": 95.0,
             "y": 395.0
           },
           {
-            "x": 100.0,
+            "x": 95.0,
             "y": 385.0
           }
         ]
           "compName": "mux1#0",
           "pinName": "I0"
         },
-        "name": "unnamedWire#382",
+        "name": "unnamedWire#379",
         "path": []
       }
     ],
index 9d2645d..cdc7e4a 100644 (file)
@@ -100,7 +100,7 @@ public class DelegatingAtomicHighLevelStateHandler implements AtomicHighLevelSta
                if (delegateTarget == null)
                        throw new IllegalStateException("Delegating to a component that was destroyed");
                DelegatingAtomicHighLevelStateHandlerParams params = new DelegatingAtomicHighLevelStateHandlerParams();
-               params.delegateTarget = delegateTarget.getName();
+               params.delegateTarget = delegateTarget == parentComponent ? null : delegateTarget.getName();
                params.subStateID = subStateID;
                return params;
        }
index 12a9888..104cb14 100644 (file)
@@ -103,8 +103,10 @@ public class DelegatingSubcomponentHighLevelStateHandler implements Subcomponent
        @Override
        public DelegatingSubcomponentHighLevelStateHandlerParams getParamsForSerializing(IdentifyParams idParams)
        {
+               if (delegateTarget == null)
+                       throw new IllegalStateException("Delegating to a component that was destroyed");
                DelegatingSubcomponentHighLevelStateHandlerParams params = new DelegatingSubcomponentHighLevelStateHandlerParams();
-               params.delegateTarget = delegateTarget.getName();
+               params.delegateTarget = delegateTarget == parentComponent ? null : delegateTarget.getName();
                params.prefix = prefix;
                return params;
        }