diff --git a/README.md b/README.md index 3435e6cb56aebb9b9e102744880f044c96be9992..6a716d8e2b79d9951907848fe1616f062553fc4f 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,24 @@ ## ENGINEERING JOURNAL ### Jingyan Ling -### 08/04/2019 +### 08/06/2019 + +- Successfully parse the wiring information from `ses` file to array + - A little "hacky" way, not using any parsing package + - Stands for `ses` file only +- +### 08/05/2019 - Working on parsing routed (wiring section) text information. - Ref: [pyparsing](https://scipy-cookbook.readthedocs.io/items/Reading_Custom_Text_Files_with_Pyparsing.html) - Parsing generated `dsn` file back to `DSN` class - Fail - Parsing generated `kicad_pcb` file back to `pykicad` package - `pcb` class + - Success +- Working on: + - debug dsn library so it can read file. + - `pykicad` uses `pyparsing` internally + - Rebuild `ses` file schema. Not working well ### 08/01/2019 diff --git a/dsn_python/__pycache__/dsnwritier.cpython-36.pyc b/dsn_python/__pycache__/dsnwritier.cpython-36.pyc index 1feefcb9130856e37c619d19224dc7a7e0542c83..1890aaefc90ef62e7e8c6e165b1935bcab1c8419 100644 Binary files a/dsn_python/__pycache__/dsnwritier.cpython-36.pyc and b/dsn_python/__pycache__/dsnwritier.cpython-36.pyc differ diff --git a/dsn_python/__pycache__/sesreader.cpython-36.pyc b/dsn_python/__pycache__/sesreader.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..71d45142e76f54b36b1ce3a7827144e0f106ac08 Binary files /dev/null and b/dsn_python/__pycache__/sesreader.cpython-36.pyc differ diff --git a/dsn_python/dsnwritier.py b/dsn_python/dsnwritier.py index 5823467df1a005dc384e65af9d6175e62717360e..08c1a8e423650a78c73be53cbcec21e03c31a80b 100644 --- a/dsn_python/dsnwritier.py +++ b/dsn_python/dsnwritier.py @@ -213,3 +213,6 @@ class Dsn(AST): with open(path, 'w', encoding='utf-8') as f: f.write(self.to_string()) + @classmethod + def from_file(cls, path): + return cls.parse(open(path, encoding='utf-8').read()) \ No newline at end of file diff --git a/dsn_python/sesreader.py b/dsn_python/sesreader.py new file mode 100644 index 0000000000000000000000000000000000000000..8f6d581cd649f5bc1fad7a92a63e8b9caa4de102 --- /dev/null +++ b/dsn_python/sesreader.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +def find_wire(file_path): + ses=open(file_path,'r').read().splitlines() + pathsec_list=[] + for i in range(len(ses)): + if 'path' in ses[i]: + for j in range(i,len(ses)): + if ')' in ses[j]: + pathsec=[i,j] + pathsec_list.append(pathsec) + break + path_list=[] + for sec_bry in pathsec_list: + onepath=[] + for j in range(sec_bry[0]+1,sec_bry[1]): + pts_str=ses[j].split() + ptstart=int(pts_str[0]) + ptend=int(pts_str[1]) + pts=[ptstart,ptend] + onepath.append(pts) + path_list.append(onepath) + return path_list \ No newline at end of file diff --git a/paperbot_ee_autoroute/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/paperbot_ee_autoroute/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..84f772e39761715aa1757149128ff66c3b068d0d --- /dev/null +++ b/paperbot_ee_autoroute/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,67 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [], + "source": [ + "ses=open('paperbot_ee.ses','r').read().splitlines()" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "25\n", + "31\n", + "36\n", + "43\n" + ] + } + ], + "source": [ + "pathsec_list=[]\n", + "for i in range(len(ses)):\n", + " if 'path' in ses[i]:\n", + " for j in range(i,len(ses)):\n", + " if ')' in ses[j]:\n", + " pathsec=[i,j]\n", + " break" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.5" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/paperbot_ee_autoroute/__pycache__/paperbot_dsn.cpython-36.pyc b/paperbot_ee_autoroute/__pycache__/paperbot_dsn.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..24e94e2b1393100979a854eb60a572a64f23f8b5 Binary files /dev/null and b/paperbot_ee_autoroute/__pycache__/paperbot_dsn.cpython-36.pyc differ diff --git a/paperbot_ee_autoroute/auto_route_dsn.py b/paperbot_ee_autoroute/auto_route_dsn.py index 719625ff873ac3c46f241fc9cf8ebdb7e0359675..3669656a21eee0694218059f9817fe3491bbcf64 100644 --- a/paperbot_ee_autoroute/auto_route_dsn.py +++ b/paperbot_ee_autoroute/auto_route_dsn.py @@ -5,4 +5,7 @@ import subprocess unrouted_dsn_file='paperbot_ee.dsn' -subprocess.call(['java','-jar','freeRouting.jar','-de',unrouted_dsn_file,'-white','-s']) \ No newline at end of file +subprocess.call(['java','-jar','freeRouting.jar','-de',unrouted_dsn_file,'-white','-s']) + + +import re \ No newline at end of file diff --git a/paperbot_ee_autoroute/fab_drawing.py b/paperbot_ee_autoroute/fab_drawing.py new file mode 100644 index 0000000000000000000000000000000000000000..37d20bd4693c5a3545c4aebeee92a1c02bbafa26 --- /dev/null +++ b/paperbot_ee_autoroute/fab_drawing.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +""" +This module call script 'paperbot_dsn.py' to generate a DSN file +for auto_router. An interface will pop up for the user to confirm wiring design, +if a user does not want to change anything, one can just simply close the window. +Routing information will be stored automatically in the same directory. +The routing information will be read and draw the corresponding line on the dxf file + +path information needed: + +- dsnwritier(sesreader) dir +- modules library dir +- mechanical design drawing file +- dsn/ses file name and (optional:dir) +""" + +dsnwritier_dir='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/dsn_python' +module_libpath='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/libraries/kicad-ESP8266/ESP8266.pretty/' +dwg_path='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/dsn_line_test.dxf' +dsn_name='paperbot_ee' + +import sys +sys.path.insert(1,dsnwritier_dir) + +import paperbot_dsn +paperbot_dsn.brd_design(dwg_path,0,module_libpath,dsn_name) diff --git a/paperbot_ee_autoroute/paperbot_dsn.py b/paperbot_ee_autoroute/paperbot_dsn.py index befdd0c76f0cf7e920a825c61cb4249d719d1c8c..7f5d8fa54306a4474b3fe137896a66ce2b453b76 100644 --- a/paperbot_ee_autoroute/paperbot_dsn.py +++ b/paperbot_ee_autoroute/paperbot_dsn.py @@ -1,24 +1,27 @@ #!/usr/bin/env python3 -import sys -sys.path.insert(1,'/home/jingyan/Documents/summer_intern_lemur/roco_electrical/dsn_python') +# import sys +# sys.path.insert(1,'/home/jingyan/Documents/summer_intern_lemur/roco_electrical/dsn_python') import dsnwritier class brd_design(): - def __init__(self,dwgfile,boundary_inx,libpath): + def __init__(self,dwgfile,boundary_inx,libpath,savename): self.dwgfile=dwgfile self.boundary_inx=boundary_inx self.libpath=libpath + self.savename=savename + self.module_list=[ ['mpu-9250.kicad_mod','J1',[103000,88000],270], ['ESP12F-Devkit-V3.kicad_mod','U1',[103000,48000],90], ] self.netlist=[ ['3v3',['U1-3','J1-1']], - ['VIN',['U1-1']] + ['VIN',['U1-1']], + ['NET1',['U1-2','J1-5']] ] self.netclass_list=[ - ['default',['3v3','VIN'],'',1000,200] + ['default',['3v3','VIN','NET1'],'',1000,200] ] self.brd_general() @@ -108,12 +111,12 @@ class brd_design(): self.brd.net=self.net self.brd.netclass=self.netclass - self.brd.to_file('paperbot_ee.dsn') + self.brd.to_file(self.savename) -libpath='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/libraries/kicad-ESP8266/ESP8266.pretty/' -dwgfile='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/dsn_line_test.dxf' -a= brd_design(dwgfile,0,libpath) +# libpath='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/libraries/kicad-ESP8266/ESP8266.pretty/' +# dwgfile='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/dsn_line_test.dxf' +# a= brd_design(dwgfile,0,libpath,'paperbot_ee') diff --git a/paperbot_ee_autoroute/paperbot_ee.dsn b/paperbot_ee_autoroute/paperbot_ee.dsn index 71baeeec0e6f92e076248d1898b5b69821c5acd5..114568bb2fe746c2406bfc81f72379acc4e5d0fa 100644 --- a/paperbot_ee_autoroute/paperbot_ee.dsn +++ b/paperbot_ee_autoroute/paperbot_ee.dsn @@ -394,7 +394,9 @@ (pins U1-3 J1-1)) (net VIN (pins U1-1)) -(class default 3v3 VIN +(net NET1 + (pins U1-2 J1-5)) +(class default 3v3 VIN NET1 (circuit (use_via "")) (rule diff --git a/paperbot_ee_autoroute/paperbot_ee.rules b/paperbot_ee_autoroute/paperbot_ee.rules index d015151f812ee06cfc3e572636d9d09e027836f7..8c5bd423f01e5516957f1ba9e657b78b7d27a772 100644 --- a/paperbot_ee_autoroute/paperbot_ee.rules +++ b/paperbot_ee_autoroute/paperbot_ee.rules @@ -11,7 +11,7 @@ (via_costs 50) (plane_via_costs 5) (start_ripup_costs 100) - (start_pass_no 4) + (start_pass_no 20) (layer_rule F.Cu (active on) (preferred_direction vertical) @@ -48,7 +48,7 @@ default ) (class default - 3v3 VIN + 3v3 VIN NET1 (clearance_class default) (via_rule default) (rule diff --git a/paperbot_ee_autoroute/paperbot_ee.ses b/paperbot_ee_autoroute/paperbot_ee.ses index 515be5e9f096dc4e8664ec912883cab3a27a8a43..a371161400248f1b1b3cd36298e47245faa777c1 100644 --- a/paperbot_ee_autoroute/paperbot_ee.ses +++ b/paperbot_ee_autoroute/paperbot_ee.ses @@ -23,7 +23,7 @@ (network_out (net 3v3 (wire - (path B.Cu 10000 + (path F.Mask 10000 890300 -600650 918654 -629004 1049358 -629004 @@ -32,6 +32,18 @@ ) ) ) + (net NET1 + (wire + (path B.Cu 10000 + 864900 -600650 + 916308 -652058 + 1072390 -652058 + 1086143 -665811 + 1086143 -760357 + 1030000 -816500 + ) + ) + ) ) ) ) \ No newline at end of file diff --git a/test_history/__pycache__/pcb_dxf_importer.cpython-36.pyc b/test_history/__pycache__/pcb_dxf_importer.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1ddecbb7f7c41efebe2fb7e7d43c63695171e1e0 Binary files /dev/null and b/test_history/__pycache__/pcb_dxf_importer.cpython-36.pyc differ diff --git a/test_history/kicad_python.py b/test_history/kicad_python.py index 5b08dfeca64fc0d6d433f5ee5c7e99931281f8d1..56927b62496bc2941548768975c80af9cc017bcf 100644 --- a/test_history/kicad_python.py +++ b/test_history/kicad_python.py @@ -115,7 +115,7 @@ class pcb_editor(): -lib_path='libraries/kicad-ESP8266' +lib_path='/home/jingyan/Documents/summer_intern_lemur/roco_electrical/libraries/kicad-ESP8266' # net_generator=schematic(lib_path) pcb_generator=pcb_editor(lib_path) diff --git a/pcb_dxf_importer.py b/test_history/pcb_dxf_importer.py similarity index 100% rename from pcb_dxf_importer.py rename to test_history/pcb_dxf_importer.py