Location: PHPKode > projects > OpenCabling > opencabling/docs/creating_new_objects.html
<html>
<body>
<h1>CREATING NEW OBJECTS</h1>
<p>Opencabling is usefull only if the correct object is choosen. For this, the correct object have to be present in the
database. At the time of this writing, there are over 70 different objects and 40 type of connections. I hope
these numbers will be every day larger through user contribute.</p>
<p>For adding objects I use phpmyadmin for db insertions and GIMP for the drawings.</p>
<p>Objects definitions are stored in one mysql database table, objtypes. Following the field meaning:</p>
<table border=1><tr><th>Field</th><th>Type</th><th>Meaning</th></tr>
<tr><td>id_obj_type</td><td>int(11)</td><td>This is an autoincrement field used to reference at the object from other tables. Let mysql administer it. If you plan to create a new object, ask me for a number and I reserve it for you.</td></tr>
<tr><td>brand</td><td>varchar(255)<td>This is the alphanumeric description of the brand. Why am I not using a decoding table for these data? Because I am lazy. Yes, I know what is database normalization.</td></tr>
<tr><td>category</td><td>varchar(255)</td><td>This is the alphanumeric description of the category where the object has to be put. Idem as above for the a-normalization of the db.</td></tr>
<tr><td>type</td><td>varchar(255)</td><td>This is the alphanumeric description of the type of the object. This is the last element to differentiate an object.</td></tr>
<tr><td>html</td><td>longtext</td><td>This is where the front object layout is defined in html. More information will follow.</td></tr>
<tr><td>html_small</td><td>longtext</td><td>This is where the front object layout is defined in html when the object is displayed inside another object, like a server in a rack.</td></tr>
<tr><td>html_back</td><td>longtext</td><td>This is where the back object layout is defined in html. More information will follow.</td></tr>
<tr><td>html_back_small</td><td>longtext</td><td>This is where the back object layout is defined in html when the object is displayed inside another object, like a server in a rack.</td></tr>
<tr><td>void_item</td><td>varchar(255)</td><td>When an object can have other object inside, like a server can have some network card inside, this is the definition of a null (or void) element to put inside when no network cards are present.</td></tr>
<tr><td>void_item_back</td><td>varchar(255)</td><td>As above, but for the back of the void element.</td></tr>
<tr><td>hpos_available</td><td>int(11)</td><td>An object can have rooms for other object inside. This is how many horizontal buckets are present. The total amount of buckets are hpos_available x vpos_available.</td></tr>
<tr><td>vpos_available</td><td>int(11)</td><td>Read above, this time for vertical count of buckets.</td><tr>
<tr><td>pos_ordering</td><td>varchar(10)</td><td>This is the ordering of the objects inside the object. Take for example a rack. The U ordering is from bottom (U number 1), instead in a modular switch is from top to bottom. You can choose from ascending order, starting from 1, the default, or the descending order with the sql word "desc". This value is postoned at the ordering sql command.</td></tr>
<tr><td>out_available</td><td>int(11)</td><td>This is the number of ports inside the object.</td></tr>
<tr><td>out_names</td><td>text</td><td>This is a list of the port names, generally like 1;2;3 ... 1b;2b;3b ... For ports like Fibre ST or fibre SC where the ports are two, use a bis suffix, like 1;1bis ... </td></tr>
<tr><td>hpos_used</td><td>int(11)</td><td>This is the amout of horizontal position used by the object when inserted in another object.</td></tr>
<tr><td>vpos_used</td><td>int(11)</td><td>This is the amout of vertical position used by the object when inserted in another object</td></tr>
<tr><td>display_detail</td><td>int(11)</td><td>This is the number of the schema used to display the object coded in displays table</td></tr>
<tr><td>options</td><td>varchar(255)</td><td>A list separated by ; of different options regarding the object:<br>
vlan - The object has vlan capabilities, so show the vlan table<br>
nospan - The spanning of inside object is not honored<br>
frontbackconnection - Each port on the front is connected to the port on the back like in a patch panel<br>
fullconnection - Every port is connected to the others like in a switch<br></td></tr>
</table>
<p>
The main difficulty is to write the "html" code describing the object, front and back if any. About writing the code, I suggest you to start looking to already made objects and if possibile to start modifing similar ones to make new one. Inside the html code you can use some "macro" as following:<p>
<table><tr><td>@@ITEMn@@</td><td>Where 'n' is a number. This macro is replaced by the html_small of the inserted element or the void element of the object. This is used for example in the definition of the generic rack object, one ITEM each 1U</td></tr>
<tr><td>@@IFCONN@@n;conn;noconn@@</td><td>Where 'n' is the number of a port, 'conn' and 'noconn' are html data. If there is a connection from such port, the macro is replaced by 'conn', else by 'noconn'</td></tr>
</table>
</body>
</html>
Return current item: OpenCabling