1 package net.mograsim.logic.model.examples;
3 import java.io.IOException;
4 import java.util.function.Function;
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.serializing.SubmodelComponentSerializer;
40 import net.mograsim.logic.model.util.JsonHandler;
42 public class ComponenetSerializer
44 public static void main(String[] args) throws IOException
46 // we know we only use components where this works
47 Function<GUIComponent, String> getIdentifier = c -> c.getClass().getSimpleName();
49 ViewModelModifiable model = new ViewModelModifiable();
50 SubmodelComponent[] components = { new GUIAm2901(model), new GUIAm2901ALUFuncDecode(model), new GUIAm2901ALUInclDecode(model),
51 new GUIAm2901ALUInclSourceDecodeInclFunctionDecode(model), new GUIAm2901ALUOneBit(model), new GUIAm2901DestDecode(model),
52 new GUIAm2901QReg(model), new GUIAm2901SourceDecode(model), new GUI_rsLatch(model), new GUIand(model), new GUIand41(model),
53 new GUIandor414(model), new GUIdemux2(model), new GUIdff(model), new GUIdlatch(model), new GUIdlatch4(model),
54 new GUIfulladder(model), new GUIhalfadder(model), new GUImux1(model), new GUImux1_4(model), new GUInand3(model),
55 new GUInot4(model), new GUIor4(model), new GUIor_4(model), new GUIram2(model), new GUIram4(model), new GUIsel2_4(model),
56 new GUIsel3_4(model), new GUIxor(model) };
58 for (SubmodelComponent comp : components)
60 SubmodelComponentParams params = SubmodelComponentSerializer.serialize(comp, getIdentifier);
64 + comp.getClass().getName()
65 .substring("net.mograsim.logic.model.model.components.mi.nandbased.".length()).replace('.', '/')