public void SaveSubGate(ObjectOutputStream s) throws IOException {
        s.writeInt(mySignals.size());
        for (int a = 0; a < mySignals.size(); a++) {
            Signal sig = mySignals.elementAt(a);
            s.writeBoolean(sig.Get());
            s.writeBoolean(sig.working);
        }

        for (int a = 0; a < 8; a++) {
            s.writeInt(mySignals.indexOf(portSignals[a].internalSignal));
            s.writeInt(portSignals[a].type);
        }

        s.writeInt(myGates.size());
        for (int a = 0; a < myGates.size(); a++) {
            Gate gate = myGates.elementAt(a);
            s.writeObject(gate.type);
            s.writeBoolean(gate.state);
            for (int b = 0; b < 8; b++) {
                s.writeInt(mySignals.indexOf(gate.portSignals[b].externalSignal));
            }
            if (gate.type.equalsIgnoreCase("Chip")) {
                gate.SaveSubGate(s);
            }
        }
        s.writeInt(speed);
    }