public static boolean checkScheme(Library library, Scheme scheme) throws ModelingException {
        // checking elements
        for(String elementName : scheme.elements.keySet()) {
            String elementType = scheme.elements.get(elementName);
            Element element = library.library.get(elementType);
            if(element == null) {
                throw new ModelingException(0x20, "'" + elementName + "' [" + elementType + "]");
            }
        }
        
        // checking circuits
        for(String circuitName : scheme.circuits.keySet()) {
            Circuit circuit = scheme.circuits.get(circuitName);
            int outputs = 0;
            for(Contact contact : circuit.contacts) {
                Element element = library.library.get(scheme.elements.get(contact.element));
                if(element == null) {
                    if(scheme.inputs.contains(contact.element)) {
                        outputs++;
                    } else if(!scheme.outputs.contains(contact.element)) {
                        throw new ModelingException(0x32, "Контакт " + contact.toString() + " в цепи " + circuitName);
                    }
                } else {
                    if(element.isOutput(contact.cnumber)) {
                        outputs++;
                    } else if(element.isInternal(contact.cnumber)) {
                        throw new ModelingException(0x31, "Контакт " + contact.toString() + " в цепи " + circuitName);
                    } else if(contact.cnumber >= element.icnt + element.ocnt + element.ecnt) {
                        throw new ModelingException(0x32, "Контакт " + contact.toString() + " в цепи " + circuitName);
                    }
                }
            }
            if(outputs > 1) {
                throw new ModelingException(0x30, circuitName + ": " + circuit.contacts.toString());
            } else if(outputs == 0) {
                throw new ModelingException(0x33, circuitName + ": " + circuit.contacts.toString());
            }
        }
        return true;
    }