3d568e36d513acf3b696f81dd1bac70ae163eb7a
[Mograsim.git] / net.mograsim.logic.model.am2900 / src / net / mograsim / logic / model / examples / ComponenetSerializer.java
1 package net.mograsim.logic.model.examples;
2
3 import java.io.IOException;
4 import java.util.function.Function;
5
6 import net.mograsim.logic.model.model.ViewModelModifiable;
7 import net.mograsim.logic.model.model.components.GUIComponent;
8 import net.mograsim.logic.model.model.components.mi.nandbased.GUI_rsLatch;
9 import net.mograsim.logic.model.model.components.mi.nandbased.GUIand;
10 import net.mograsim.logic.model.model.components.mi.nandbased.GUIand41;
11 import net.mograsim.logic.model.model.components.mi.nandbased.GUIandor414;
12 import net.mograsim.logic.model.model.components.mi.nandbased.GUIdemux2;
13 import net.mograsim.logic.model.model.components.mi.nandbased.GUIdff;
14 import net.mograsim.logic.model.model.components.mi.nandbased.GUIdlatch;
15 import net.mograsim.logic.model.model.components.mi.nandbased.GUIdlatch4;
16 import net.mograsim.logic.model.model.components.mi.nandbased.GUIfulladder;
17 import net.mograsim.logic.model.model.components.mi.nandbased.GUIhalfadder;
18 import net.mograsim.logic.model.model.components.mi.nandbased.GUImux1;
19 import net.mograsim.logic.model.model.components.mi.nandbased.GUImux1_4;
20 import net.mograsim.logic.model.model.components.mi.nandbased.GUInand3;
21 import net.mograsim.logic.model.model.components.mi.nandbased.GUInot4;
22 import net.mograsim.logic.model.model.components.mi.nandbased.GUIor4;
23 import net.mograsim.logic.model.model.components.mi.nandbased.GUIor_4;
24 import net.mograsim.logic.model.model.components.mi.nandbased.GUIram2;
25 import net.mograsim.logic.model.model.components.mi.nandbased.GUIram4;
26 import net.mograsim.logic.model.model.components.mi.nandbased.GUIsel2_4;
27 import net.mograsim.logic.model.model.components.mi.nandbased.GUIsel3_4;
28 import net.mograsim.logic.model.model.components.mi.nandbased.GUIxor;
29 import net.mograsim.logic.model.model.components.mi.nandbased.am2901.GUIAm2901;
30 import net.mograsim.logic.model.model.components.mi.nandbased.am2901.GUIAm2901ALUFuncDecode;
31 import net.mograsim.logic.model.model.components.mi.nandbased.am2901.GUIAm2901ALUInclDecode;
32 import net.mograsim.logic.model.model.components.mi.nandbased.am2901.GUIAm2901ALUInclSourceDecodeInclFunctionDecode;
33 import net.mograsim.logic.model.model.components.mi.nandbased.am2901.GUIAm2901ALUOneBit;
34 import net.mograsim.logic.model.model.components.mi.nandbased.am2901.GUIAm2901DestDecode;
35 import net.mograsim.logic.model.model.components.mi.nandbased.am2901.GUIAm2901QReg;
36 import net.mograsim.logic.model.model.components.mi.nandbased.am2901.GUIAm2901SourceDecode;
37 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
38 import net.mograsim.logic.model.serializing.SubmodelComponentParams;
39 import net.mograsim.logic.model.util.JsonHandler;
40
41 public class ComponenetSerializer
42 {
43         public static void main(String[] args) throws IOException
44         {
45                 // we know we only use components where this works
46                 Function<GUIComponent, String> getIdentifier = c -> c.getClass().getSimpleName();
47
48                 ViewModelModifiable model = new ViewModelModifiable();
49                 SubmodelComponent[] components = { new GUIAm2901(model), new GUIAm2901ALUFuncDecode(model), new GUIAm2901ALUInclDecode(model),
50                                 new GUIAm2901ALUInclSourceDecodeInclFunctionDecode(model), new GUIAm2901ALUOneBit(model), new GUIAm2901DestDecode(model),
51                                 new GUIAm2901QReg(model), new GUIAm2901SourceDecode(model), new GUI_rsLatch(model), new GUIand(model), new GUIand41(model),
52                                 new GUIandor414(model), new GUIdemux2(model), new GUIdff(model), new GUIdlatch(model), new GUIdlatch4(model),
53                                 new GUIfulladder(model), new GUIhalfadder(model), new GUImux1(model), new GUImux1_4(model), new GUInand3(model),
54                                 new GUInot4(model), new GUIor4(model), new GUIor_4(model), new GUIram2(model), new GUIram4(model), new GUIsel2_4(model),
55                                 new GUIsel3_4(model), new GUIxor(model) };
56
57                 for (SubmodelComponent comp : components)
58                 {
59                         SubmodelComponentParams params = comp.calculateParams(getIdentifier);
60                         JsonHandler.writeJson(params, "components/"
61                                         + comp.getClass().getName().substring("net.mograsim.logic.ui.model.components.mi.nandbased.".length()).replace('.', '/')
62                                         + ".json");
63                 }
64         }
65 }