<?php

// builder
// ================================================================================================

// library   
// - pad
// - via
// - text
// - pattern
// - component

// netlist
// - component
// - net

// pcb design
// - pcbDesignHeader
// - layerDef
// - multiLayer
//   - via
//   - pattern

// - layerContents 1 - top
//   - line
//   - text
// - layerContents 2 - bottom
//   - line
//   - text
// - layerContents 3 - board
//   - line
//   - polygon

// - layersStackup



// create header
// ================================================================================================
$out_file = "p/" . $proj[$PROJ_ID]['dir'] . "/sprint05_pcad.pcb";
$ascii = "SPRINT05_PCAD.PCB";
$ts = date("Y m d H i s");
$cr = "Copyright © 2009-".date("Y")." Sprinter Reverse Team";

$hdr = "ACCEL_ASCII \"$ascii\"\r\n";
$hdr .= "\r\n";
$hdr .= "(asciiHeader\r\n";
$hdr .= "  (asciiVersion 3 0)\r\n";
$hdr .= "  (timeStamp $ts)\r\n";
$hdr .= "  (program \"Sprinter php parser\" \"01.00.1234\")\r\n";
$hdr .= "  (copyright \"$cr\")\r\n";
$hdr .= "  (fileAuthor \"RomanRom2\")\r\n";
$hdr .= "  (headerString \"\")\r\n";
$hdr .= "  (fileUnits Mil)\r\n";
$hdr .= "  (guidString \"\")\r\n";
$hdr .= ")\r\n";

file_put_contents($out_file, $hdr, LOCK_EX);



// create library
// ================================================================================================

// lib begin
$pcad_lib  = "(library \"Library_1\"\r\n";
file_put_contents($out_file, $pcad_lib, FILE_APPEND | LOCK_EX);

include("p/" . $proj[$PROJ_ID]['dir'] . "/lib_via.php");
include("p/" . $proj[$PROJ_ID]['dir'] . "/lib_text.php");
include("p/" . $proj[$PROJ_ID]['dir'] . "/lib_pad.php");
include("p/" . $proj[$PROJ_ID]['dir'] . "/lib_pattern.php");
include("p/" . $proj[$PROJ_ID]['dir'] . "/lib_component.php");

// lib end
$pcad_lib = ")\r\n";
file_put_contents($out_file, $pcad_lib, FILE_APPEND | LOCK_EX);



// create netlist
// ================================================================================================

// netlist begin
$pcad_net  = "(netlist \"Netlist_1\"\r\n";
file_put_contents($out_file, $pcad_net, FILE_APPEND | LOCK_EX);

include("p/" . $proj[$PROJ_ID]['dir'] . "/net.php");

// netlist end
$pcad_net = ")\r\n";
file_put_contents($out_file, $pcad_net, FILE_APPEND | LOCK_EX);



// create pcb design
// ================================================================================================

// pcb begin
$pcad_pcb  = "(pcbDesign \"PcbDesign_1\"\r\n";
file_put_contents($out_file, $pcad_pcb, FILE_APPEND | LOCK_EX);

include("p/" . $proj[$PROJ_ID]['dir'] . "/pcb_header.php");
include("p/" . $proj[$PROJ_ID]['dir'] . "/pcb_layerdef.php");
include("p/" . $proj[$PROJ_ID]['dir'] . "/pcb_multilayer.php");
include("p/" . $proj[$PROJ_ID]['dir'] . "/pcb_layers.php");
include("p/" . $proj[$PROJ_ID]['dir'] . "/pcb_stackup.php");

// pcb end
$pcad_pcb = ")\r\n";
file_put_contents($out_file, $pcad_pcb, FILE_APPEND | LOCK_EX);


