This site uses cookies. By using this site, you agree to our use of cookies. Learn more

Implementations

Implementations allow components to define which real life component they represent. This allows many people to create their own version of a component while enabling them all to be compatible when saving and opening circuit documents.

Introduction

The main reason for implementations is the CDDX file format. A *.cddx file contains the following information:

Some programs may be designed simply for simulating a circuit, and are only interested in the connection information. Implementations allow them to understand how to simulate that component and how to interpret its connections, since the connections will be named in the same way for all resistors, capacitors etc.

This also means that if a circuit document is opened and one of the components it uses is not installed, a replacement can be used if a component which implements the same real life component can be found.

Sources

Implementations are made up of two parts - the collection and the item itself. The collection defines which list of components is being used, and the item defines which component from that list is being used.

The collection is a uri, which uniquely identifies the list being used. The collection containing most of the standard components is:

http://schemas.circuit-diagram.org/circuitDiagramDocument/2012/components/common

If you visit that link, you can see which components it defines and the connections and properties they are expected to have.

Example

In this example, we will implement the "resistor" component from the common components list. If you are not familiar with how the xml component format works, please read this tutorial first.

Implementations can be made either using configurations or without them. If you are only implementing one component, you do not need to use configurations, but if you wanted to implement ldr, thermistor and variableresistor all in the same component xml file, you would need to use them.

Without Configurations

By looking at this section of the document, we can see that our component must have the following:

The first step is to add a meta property stating which component we are implementing. This is done by placing the following tags in the <declaration> section of the component file:

<meta name="implementset" value="http://schemas.circuit-diagram.org/circuitdiagramdocument/2012/components/common" />
<meta name="implementitem" value="resistor" />

Please note that there should be '''no forward slash''' at the end of the common components uri.

Now simply make sure that you have a property which serializes as resistance (the property name does not have to be resistance), and two connections called a and b.

<property name="Resistance" type="double" default="4700" serialize="resistance" display="Resistance">
    <formatting>
        <format conditions="$Resistance(lt_1000)" value="$Resistance \u2126"/>
        <format conditions="$Resistance(lt_1000000)" value="$Resistance(div_1000_)(round_1) k\u2126"/>
        <format value="$Resistance(div_1000000)(round_1) M\u2126"/>
    </formatting>
</property>
<connections>
    <group conditions="_Horizontal">
        <connection name="a" start="_Start" end="_Middle-21x" edge="start"/>
        <connection name="b" start="_Middle+21x" end="_End" edge="end"/>
    </group>
    <group conditions="!_Horizontal">
        <connection name="a" start="_Start" end="_Middle-21y" edge="start"/>
        <connection name="b" start="_Middle+21y" end="_End" edge="end"/>
    </group>
</connections>

With Configurations

By using configurations, a single component can take advantage of multiple implementations. For this method, the set being used needs to be defined within the <declaration> section:

<meta name="implementset" value="http://schemas.circuit-diagram.org/circuitdiagramdocument/2012/components/common" />

Each item from that set that will be implemented can be assigned to a specific configuration as follows:

<configurations>
    <configuration name="Resistor" value="Type:Standard" implements="resistor" />
    <configuration name="Variable Resistor" value="Type:Variable" implements="variableresistor" />
    <configuration name="Potentiometer" value="Type:Potentiometer" implements="potentiometer" />
    <configuration name="Thermistor" value="Type:Thermistor" implements="thermistor" />
    <configuration name="LDR" value="Type:LDR" implements="ldr" />
</configurations>

Note that the connections required for each item only need to be enabled when the specific configuration that requires them is in use.