/// <summary> /// Create the adapter /// </summary> /// <param name="pcb">PCB to use for the generation</param> public PogoPinAdapter(PCB pcb) { this.pcb = pcb; circuit_bounds = pcb.Bounds; }
/// <summary> /// Create PCB file for the bottom layer if configured /// </summary> private PCB CreatePCBBottom(BottomMode bottom_mode) { PCB out_pcb = new PCB(); float left = pcb.Bounds.Left - 10; float top = pcb.Bounds.Top - 10; float right = pcb.Bounds.Right + 10; float bottom = pcb.Bounds.Bottom + 10; out_pcb.Edge.AddLine(left + 5, top, right - 5, top); out_pcb.Edge.AddArc(new PointF(right - 5, top + 5), new PointF(right - 5, top), 90); out_pcb.Edge.AddLine(right, top + 5, right, bottom - 5); out_pcb.Edge.AddArc(new PointF(right - 5, bottom - 5), new PointF(right, bottom - 5), 90); out_pcb.Edge.AddLine(right - 5, bottom, left + 5, bottom); out_pcb.Edge.AddArc(new PointF(left + 5, bottom - 5), new PointF(left + 5, bottom), 90); out_pcb.Edge.AddLine(left, bottom - 5, left, top + 5); out_pcb.Edge.AddArc(new PointF(left + 5, top + 5), new PointF(left, top + 5), 90); out_pcb.Edge.AddCircle(new PointF(left + 5, top + 5), 2.05); out_pcb.Edge.AddCircle(new PointF(left + 5, bottom - 5), 2.05); out_pcb.Edge.AddCircle(new PointF(right - 5, top + 5), 2.05); out_pcb.Edge.AddCircle(new PointF(right - 5, bottom - 5), 2.05); Dictionary <Net, Net> nets = new Dictionary <Net, Net>(); List <Components.Component> testPoints = new List <Component>(); foreach (var pad in pads) { nets[pad.Net] = out_pcb.Nets.AddNet(pad.Net.Number, pad.Net.Name); var testpoint = out_pcb.Components.AddComponent("TestPoint", "TestPoint_Pad_D1.5mm", pad.Net.Name, pad.Location, pad.Owner.Angle, false); testpoint.Pads[1].Net = nets[pad.Net]; testPoints.Add(testpoint); } var connector = out_pcb.Components.AddComponent("Connector_PinSocket_2.54mm", "PinSocket_1x" + pads.Count.ToString().PadLeft(2, '0') + "_P2.54mm_Horizontal", "OUT_CONN_1", (right + left) / 2 + 1.27 * (pads.Count - 1), bottom - 10.15, 270, false ); pads.Sort((b, a) => (a.Location.X.CompareTo(b.Location.X) != 0 ? a.Location.X.CompareTo(b.Location.X) : b.Location.Y.CompareTo(a.Location.Y))); for (int i = 0; i < pads.Count; i++) { connector.Pads[i + 1].Net = nets[pads[i].Net]; out_pcb.FSilk.AddText(connector.Pads[i + 1].Net.Name, connector.Pads[i + 1].Location + new SizeF(0, 5.65f), 90, 1, 1, 0.2); out_pcb.BSilk.AddText(connector.Pads[i + 1].Net.Name, connector.Pads[i + 1].Location + new SizeF(0, 5.65f), 90, 1, 1, 0.2); } switch (bottom_mode) { case BottomMode.PCB_no_connect: out_pcb.FSilk.AddText("This PCB is NOT ready!\nConnect test points to something,\n preferably the connector at the bottom\n autorouter should do well", pcb.Bounds.Center(), 0, 4.5, 4.5, 0.9); break; case BottomMode.PCB_connect_direct: for (int i = 0; i < pads.Count; i++) { out_pcb.Traces.SetTraceStart(testPoints[i].Pads[1], 0.6); out_pcb.Traces.ContinueTrace(connector.Pads[pads.Count - i]); } out_pcb.FSilk.AddText("This PCB is NOT ready!\nVerify all connections are good", pcb.Bounds.Center(), 0, 4.5, 4.5, 0.9); break; case BottomMode.PCB_connect_via_grid: for (int i = 0; i < pads.Count; i++) { out_pcb.Traces.SetTraceStart(testPoints[i].Pads[1], 0.6); out_pcb.Traces.ContinueTrace(new PointF(connector.Pads[pads.Count - i].Location.X, testPoints[i].Pads[1].Location.Y)); out_pcb.Traces.ContinueWithVia(0.7, 0.6); out_pcb.Traces.ContinueTrace(connector.Pads[pads.Count - i]); } out_pcb.FSilk.AddText("This PCB is NOT ready!\nVerify all connections are good", pcb.Bounds.Center(), 0, 4.5, 4.5, 0.9); break; default: throw new NotImplementedException(); } out_pcb.MoveAll(new SizeF(100, 100)); return(out_pcb); }