Skip to content

Commit

Permalink
Merge pull request #6 from lukasc-ubc/lyrdb
Browse files Browse the repository at this point in the history
Show DRC Results Database (.lyrdb) file in KLayout
  • Loading branch information
sebastian-goeldi committed Nov 20, 2023
2 parents 1e82067 + ee7777f commit 5033d66
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions klayout/python/klive_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class ServerInstance(pya.QTcpServer):
"""
Implements a TCP server listening on port 8082.
You can use it to instantly load a GDS file, programmatically, from Python.
You can use it to instantly load a GDS or lyrdb (Results Database) file, programmatically, from Python.
Just send a JSON-formatted command to localhost:8082.
See README for more details.
"""
Expand Down Expand Up @@ -52,8 +52,11 @@ def new_connection(self):
if connection.canReadLine():
line = connection.readLine()
data = json.loads(line)

# Interpret the data
gds_path = data["gds"]
if "lyrdb" in data:
lyrdb_path = data["lyrdb"]

# Store the current view
window = pya.Application.instance().main_window()
Expand Down Expand Up @@ -87,7 +90,7 @@ def load_existing_layout():
json.dumps(send_data).encode("utf-8")
)
connection.flush()
return
return view
else:
# Load the new layout
new_cview = window.load_layout(gds_path, 1)
Expand All @@ -98,9 +101,9 @@ def load_existing_layout():
send_data["file"] = gds_path
connection.write(json.dumps(send_data).encode("utf-8"))
connection.flush()

return new_view
if window.views() > 0:
load_existing_layout()
view = load_existing_layout()
else:
# Load the new layout
window.load_layout(gds_path, 1)
Expand All @@ -117,6 +120,11 @@ def load_existing_layout():
send_data["file"] = gds_path
connection.write(json.dumps(send_data).encode("utf-8"))
connection.flush()
if "lyrdb" in data:
lyrdb_path = data["lyrdb"]
rdb = pya.ReportDatabase().load(lyrdb_path)
rdb_i = view.add_rdb(rdb)
view.show_rdb(rdb_i, view.active_cellview().cell_index)
else:
connection.waitForReadyRead(100)

Expand Down

0 comments on commit 5033d66

Please sign in to comment.