-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathEaglepy.py
2215 lines (1858 loc) · 89.7 KB
/
Eaglepy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
(C) Copyright 2013 Rob Watson rmawatson [at] hotmail.com and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the GNU Lesser General Public License
(LGPL) version 2.1 which accompanies this distribution, and is available at
http://www.gnu.org/licenses/lgpl-2.1.html
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
Contributors:
Rob Watson ( rmawatson [at] hotmail )
"""
import os,sys,time,json,re,platform
import weakref
from types import ListType
from urlparse import urlparse
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from threading import Thread,Condition,Timer,Lock
from uuid import uuid4
from types import ListType
from xml.dom.minidom import parseString
if platform.system() == "Windows" and "pythonw.exe" in sys.executable.lower():
class NullOutput(object):
def write(self, text): pass
sys.stdout = NullOutput()
sys.stderr = NullOutput()
""" REMOTE MESSAGE TYPES """
POLLING_TYPE_NAME = "polling"
EXECREPLY_TYPE_NAME = "execreply"
""" LOCAL MESSAGE TYPES """
POLLING_TYPE_CODE = 0
EXEC_TYPE_CODE = 1
""" POLLING MESSAGE RESPONSE TYPES """
POLLING_REPONSE_NOP = 0
POLLING_REPONSE_EXIT = 1
""" EXECUTION ERROR VALUES """
ERROR_VALUES = [
"ERROR_INVALID_CONTEXT",
"ERROR_WIRE_HANDLER",
"ERROR_GRID_HANDLER",
"ERROR_AREA_HANDLER",
"ERROR_ARC_HANDLER",
"ERROR_ATTRIBUTE_HANDLER",
"ERROR_CIRCLE_HANDLER",
"ERROR_CLASS_HANDLER",
"ERROR_DIMENSION_HANDLER",
"ERROR_ELEMENT_HANDLER",
"ERROR_PACKAGE_HANDLER",
"ERROR_TEXT_HANDLER",
"ERROR_CONTACT_HANDLER",
"ERROR_POLYGON_HANDLER",
"ERROR_FRAME_HANDLER",
"ERROR_RECTANGLE_HANDLER",
"ERROR_HOLE_HANDLER",
"ERROR_LAYER_HANDLER",
"ERROR_LIBRARY_HANDLER",
"ERROR_DEVICE_HANDLER",
"ERROR_DEVICESET_HANDLER",
"ERROR_SYMBOL_HANDLER",
"ERROR_GATE_HANDLER",
"ERROR_PIN_HANDLER",
"ERROR_PAD_HANDLER",
"ERROR_PINREF_HANDLER",
"ERROR_SIGNAL_HANDLER",
"ERROR_VIA_HANDLER",
"ERROR_VARIANTDEF_HANDLER",
"ERROR_VARIANT_HANDLER",
"ERROR_PART_HANDLER",
"ERROR_INSTANCE_HANDLER",
"ERROR_JUNCTION_HANDLER",
"ERROR_SEGMENT_HANDLER",
"ERROR_LABEL_HANDLER",
"ERROR_NET_HANDLER",
"ERROR_BUS_HANDLER",
"ERROR_CONTACTREF_HANDLER",
"ERROR_BOARD_HANDLER",
"ERROR_SCHEMATIC_HANDLER",
"ERROR_SHEET_HANDLER",
"ERROR_MAX_DEPTH",
"ERROR_BASE_HANDLER"]
class EaglepyException(Exception):pass
class EagleRemoteHandler(BaseHTTPRequestHandler):
def __init__(self,request,client_address,server):
BaseHTTPRequestHandler.__init__(self,request,client_address,server)
def log_message(self, format, *args):
return
def do_POST(self):
print "POST"
params = urlparse(self.path)
requestType = params.path[1:].split("?")[0] if len(params.path) > 0 else None
requestData = params.path[1:].split("?")[0] if len(params.path) > 1 else None
length = int(self.headers['Content-Length'])
postData = self.rfile.read(length)
if requestType == POLLING_TYPE_NAME:
self.pollingHandler(requestData)
if requestType == EXECREPLY_TYPE_NAME:
self.execReplyHandler(postData)
def execReplyHandler(self,postData):
splitReplies = [item for item in postData.split(";") if item != ""]
self.server.commandQueueLock.acquire()
commandConditions = dict(self.server.commandCondition)
for reply in splitReplies:
splitReplyItem = reply.split("|")
cmdid = str(splitReplyItem[0])
cmddata = None
if len(splitReplyItem) > 1:
cmddata = str(splitReplyItem[1])
commandConditions[cmdid][0].acquire()
commandConditions[cmdid][1] = cmddata
commandConditions[cmdid][0].notifyAll()
commandConditions[cmdid][0].release()
cond = commandConditions[cmdid][0]
cond.acquire()
del commandConditions[cmdid]
cond.release()
self.server.commandQueueLock.release()
self.postResponse({str(POLLING_TYPE_CODE):str(POLLING_REPONSE_NOP)})
def pollingHandler(self,data):
time.sleep(0.005)
self.server.commandQueueLock.acquire()
if self.server.shuttingDown:
self.postResponse({str(POLLING_TYPE_CODE):str(POLLING_REPONSE_EXIT)})
self.server.shutdownCondition.acquire()
self.server.shutdownCondition.notifyAll()
self.server.shutdownCondition.release()
if len(self.server.commandQueue):
commandItem = self.server.commandQueue.pop()
commandData = str(commandItem[0]) + "|" + str(commandItem[1]) + "|" + "?".join(str(item) for item in commandItem[2])
self.postResponse({str(EXEC_TYPE_CODE):commandData})
else:
self.postResponse({str(POLLING_TYPE_CODE):str(POLLING_REPONSE_NOP)})
self.server.commandQueueLock.release()
def postResponse(self,keyvalues):
self.send_response(200)
self.send_header("Content-type", "application/json")
self.send_header("Access-Control-Allow-Origin", "*")
self.end_headers()
self.wfile.write(json.dumps(keyvalues))
class EagleRemoteServer(HTTPServer):
TIMEOUT = 3.0
def __init__(self):
self.connectData = None
self.queuedRequests = []
self.sessionID = None
self.serverThread = None
self.commandQueueLock = Lock()
self.commandQueue = []
self.shuttingDown = False
self.shutdownCondition = Condition()
self.commandCondition = {}
HTTPServer.__init__(self,("127.0.0.1",7697),EagleRemoteHandler )
def startup(self):
self.serverThread= Thread(target=self.serve_forever)
self.serverThread.start()
def shutdown(self):
self.shuttingDown = True
self.shutdownCondition.acquire()
self.shutdownCondition.wait()
self.shutdownCondition.release()
HTTPServer.shutdown(self)
self.serverThread.join()
def executeCommand(self,cmdtype,args=[]):
cmdid = str(uuid4().hex)
self.commandQueueLock.acquire()
self.commandCondition[cmdid] = [Condition(),None]
self.commandQueue.append([cmdid,cmdtype,args])
self.commandCondition[cmdid][0].acquire()
self.commandQueueLock.release()
self.commandCondition[cmdid][0].wait()
condition = self.commandCondition[cmdid][0]
result = self.commandCondition[cmdid][1]
condition.release()
return result;
global EALGE_SERVER_INSTANCE
EALGE_SERVER_INSTANCE = None
def initialize():
global EALGE_SERVER_INSTANCE
EALGE_SERVER_INSTANCE = EagleRemoteServer()
EALGE_SERVER_INSTANCE.startup()
def shutdown():
instance().shutdown()
def instance():
global EALGE_SERVER_INSTANCE
return EALGE_SERVER_INSTANCE
""" EAGLE OBJECTS """
from types import *
import weakref
def splitEscapedString(unescaped,splitchar):
skipNext = False
currentString = ""
result = []
for index,char in enumerate(unescaped):
if skipNext:
skipNext = False
continue
if char == "\\":
if index+1 < len(unescaped) and unescaped[index+1] == splitchar:
currentString += splitchar
skipNext = True
continue
else:
currentString += "\\"
continue
if char == splitchar:
result.append(currentString)
currentString = ""
continue
currentString += char
result.append(currentString)
return result
class ULBaseAttribute(object):
def __init__(self,owner,ul_name,datatype):
self.parent = owner
self.ul_name = ul_name
self.datatype = datatype
def cleanString(self,string):
return string.replace("uF","")
class ULMethodAttribute(ULBaseAttribute):
def __init__(self,owner,ul_name,datatype):
ULBaseAttribute.__init__(self,owner,ul_name,datatype)
def __call__(self,cacheAhead=True):
result = []
path = self.parent.path() + "@" + self.ul_name
resultString = instance().executeCommand(COMMAND_getattribute,[path,int(cacheAhead)])
if not resultString:
return result
handleReplyError(resultString)
if cacheAhead:
splitResult = splitEscapedString(resultString[1:],":")
for index,cachedItem in enumerate(splitResult):
result.append(self.datatype(self).setIndex(index))
cachedItem = cachedItem[:-1]
splitCached = splitEscapedString(cachedItem,"?")
for attrIndex,value in enumerate(splitCached):
try:
result[-1].simplePropertyList[attrIndex].cachedValue = result[-1].simplePropertyList[attrIndex].datatype(self.cleanString(value))
except:
#print "ERROR: Unable to convert value to native type with value='%s' and type=%s" % (value,result[-1].simplePropertyList[attrIndex].datatype.__name__)
result[-1].simplePropertyList[attrIndex].cachedValue = result[-1].simplePropertyList[attrIndex].datatype()
return result
else:
return [self.datatype(self).setIndex(index) for index in range(int(resultString))]
class ULPropertyAttribute(ULBaseAttribute):
def __init__(self,owner,ul_name,datatype):
ULBaseAttribute.__init__(self,owner,ul_name,datatype)
self.cachedValue = None
def __call__(self,cached=True):
return self.get(cached)
def get(self,cached=True):
if self.parent and self not in self.parent.simplePropertyList:
return self
if not cached or not self.cachedValue:
path = self.path()
self.cachedValue = self.datatype(instance().executeCommand(COMMAND_getattribute,[path]))
return self.cachedValue
def set(self,value):
pass
#path = self.path()
#return self.datatype(instance().executeCommand(COMMAND_setattribute,[path + "?" + str(value)]))
def __getattr__(self,attr):
if attr == "value":
if issubclass(self.__dict__["datatype"],ULObject):
return self.__dict__["datatype"](self)
else:
return self.__dict__["datatype"]()
elif attr == "__dict__":
return self.__dict__
elif attr == "path":
if not issubclass(self.__dict__["datatype"],ULObject):
def simplePropertyPath():
parent = self.__dict__["parent"];
pathList = parent.path()
pathList += "@" + self.__dict__["ul_name"] + "@" + str(self.__dict__["datatype"].__name__)
return pathList
return simplePropertyPath
return getattr(self.value,attr)
elif attr == "index":
return getattr(self.value,attr)
return getattr(self.value,attr)
class ULObject(object):
def __init__(self,parent=None):
self.ul_name = str(self.__class__.__name__)
self.parent = parent
self.simplePropertyList = []
self.index = -1
self.args = None
def createAttribute(self,ul_name,datatype,writeable=False,readable=True,args=None):
self.args = args
if isinstance(datatype,ListType):
self.__dict__[ul_name] = ULMethodAttribute(self,ul_name,datatype[0])
else:
self.__dict__[ul_name] = ULPropertyAttribute(self,ul_name,datatype)
if issubclass(datatype,(str,int,float)) and not self.args:
self.simplePropertyList.append(self.__dict__[ul_name])
if ul_name == "name" and datatype == str:
def rename_func(newname):
globals()["rename"](self.name(),newname)
self.rename = rename_func
elif ul_name == "x":
def move_func(unitx,unity,currentUnits=None):
eaglex = configuredToEagle(unitx,currentUnits)
eagley = configuredToEagle(unity,currentUnits)
self.x.__dict__["cachedValue"] = eaglex
self.y.__dict__["cachedValue"] = eagley
globals()["move"](self.name(),unitx,unity)
self.move = move_func
def setIndex(self,index):
self.__dict__["index"] = index
return self
def path(self):
pathList = []
parent = self
while parent:
if hasattr(parent,"index") and parent.index >= 0:
pathList.append(str(parent.index))
pathList.append("^")
pathList.append(parent.ul_name)
pathList.append("@")
parent = parent.parent
pathList.reverse()
return "".join(pathList)
class ULClass(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("clearance",int,args=[(None),(int)])
self.createAttribute("drill",int)
self.createAttribute("name",str)
self.createAttribute("number",int)
self.createAttribute("width",int)
class ULGate(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("addlevel",int)
self.createAttribute("name",str)
self.createAttribute("swaplevel",int)
self.createAttribute("symbol",ULSymbol)
self.createAttribute("x",int)
self.createAttribute("y",int)
class ULPinRef(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("contact",ULPart)
self.createAttribute("direction",ULPin)
class ULPin(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("angle",float)
self.createAttribute("direction",int)
self.createAttribute("function",int)
self.createAttribute("length",int)
self.createAttribute("name",str)
self.createAttribute("net",str)
self.createAttribute("route",int)
self.createAttribute("swaplevel",int)
self.createAttribute("visible",int)
self.createAttribute("x",int)
self.createAttribute("y",int)
self.createAttribute("circles",[ULCircle])
self.createAttribute("contacts",[ULContact])
self.createAttribute("texts",[ULText])
self.createAttribute("wires",[ULWire])
class ULNet(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("class",ULClass)
self.createAttribute("column",str)
self.createAttribute("name",str)
self.createAttribute("row",str)
self.createAttribute("pinrefs",[ULPinRef])
self.createAttribute("segments",[ULSegment])
class ULLabel(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("angle",float)
self.createAttribute("layer",int)
self.createAttribute("mirror",int)
self.createAttribute("spin",int)
self.createAttribute("text",ULText)
self.createAttribute("x",int)
self.createAttribute("y",int)
self.createAttribute("xref",int)
self.createAttribute("wires",[ULWire])
class ULSegment(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("junctions",[ULJunction])
self.createAttribute("labels",[ULLabel])
self.createAttribute("pinrefs",[ULPinRef])
self.createAttribute("texts",[ULText])
self.createAttribute("wires",[ULWire])
class ULPart(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("attribute",str,args=[(int)])
self.createAttribute("device",ULDevice)
self.createAttribute("deviceset",[ULDeviceSet])
self.createAttribute("name",str)
self.createAttribute("populate",int)
self.createAttribute("value",str)
self.createAttribute("attributes",[ULAttribute])
self.createAttribute("variants",[ULVariant])
self.createAttribute("instances",[ULInstance])
class ULSignal(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("airwireshidden",int)
self.createAttribute("class",ULClass)
self.createAttribute("name",str)
self.createAttribute("contactrefs",[ULContactRef])
self.createAttribute("polygons",[ULPolygon])
self.createAttribute("vias",[ULVia])
self.createAttribute("wires",[ULWire])
class ULSymbol(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("area",[ULArea])
self.createAttribute("description",str)
self.createAttribute("headline",str)
self.createAttribute("library",str)
self.createAttribute("name",str)
self.createAttribute("circles",[ULCircle])
self.createAttribute("dimensions",[ULDimension])
self.createAttribute("frames",[ULFrame])
self.createAttribute("rectangles",[ULRectangle])
self.createAttribute("pins",[ULPin])
self.createAttribute("polygons",[ULPolygon])
self.createAttribute("texts",[ULText])
self.createAttribute("wires",[ULWire])
class ULDeviceSet(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("activedevice",ULDevice)
self.createAttribute("area",ULArea)
self.createAttribute("description",str)
self.createAttribute("headline",str)
self.createAttribute("library",str)
self.createAttribute("name",str)
self.createAttribute("prefix",str)
self.createAttribute("value",str)
self.createAttribute("devices",[ULDevice])
self.createAttribute("gates",[ULGate])
class ULDevice(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("activetechnology",str)
self.createAttribute("area",ULArea)
self.createAttribute("description",str)
self.createAttribute("headline",str)
self.createAttribute("library",str)
self.createAttribute("name",str)
self.createAttribute("package",ULPackage)
self.createAttribute("prefix",str)
self.createAttribute("technologies",str)
self.createAttribute("value",str)
self.createAttribute("attributes",[ULAttribute])
self.createAttribute("gates",[ULGate])
class ULLibrary(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("description",str)
self.createAttribute("grid",ULGrid)
self.createAttribute("headline",str)
self.createAttribute("name",str)
self.createAttribute("devices",[ULDevice])
self.createAttribute("devicesets",[ULDeviceSet])
self.createAttribute("layers",[ULLayer])
self.createAttribute("packages",[ULPackage])
self.createAttribute("symbols",[ULSymbol])
class ULPackage(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("area",ULArea)
self.createAttribute("description",str)
self.createAttribute("headline",str)
self.createAttribute("library",str)
self.createAttribute("name",str)
self.createAttribute("circles",[ULCircle])
self.createAttribute("contacts",[ULContact])
self.createAttribute("dimensions",[ULDimension])
self.createAttribute("frames",[ULFrame])
self.createAttribute("holes",[ULHole])
self.createAttribute("rectangles",[ULRectangle])
self.createAttribute("texts",[ULText])
self.createAttribute("wires",[ULWire])
class ULContactRef(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("contact",ULContact)
self.createAttribute("element",ULElement)
self.createAttribute("route",int)
self.createAttribute("routetag",str)
class ULVia(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("drill",int)
self.createAttribute("drillsymbol",int)
self.createAttribute("end",int)
self.createAttribute("flags",int)
self.createAttribute("shape",int,args=[(int)])
self.createAttribute("start",int)
self.createAttribute("x",int)
self.createAttribute("y",int)
class ULBus(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("name",str)
self.createAttribute("segments",[ULSegment])
class ULJunction(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("diameter",int)
self.createAttribute("x",int)
self.createAttribute("y",int)
class ULVariantDef(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("name",str)
class ULVariant(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("populate",int)
self.createAttribute("value",str)
self.createAttribute("technology",str)
self.createAttribute("variantdef",str)
class ULRectangle(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("angle",float)
self.createAttribute("layer",int)
self.createAttribute("x1",int)
self.createAttribute("x2",int)
self.createAttribute("y1",int)
self.createAttribute("y2",int)
class ULHole(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("diameter",int,args=[(int)])
self.createAttribute("drill",int)
self.createAttribute("drillsymbol",int)
self.createAttribute("x",int)
self.createAttribute("y",int)
class ULFrame(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("columns",int)
self.createAttribute("rows",int)
self.createAttribute("border",int)
self.createAttribute("x1",int)
self.createAttribute("x2",int)
self.createAttribute("y1",int)
self.createAttribute("y2",int)
self.createAttribute("texts",[ULText])
self.createAttribute("fillings",[ULWire])
class ULPolygon(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("isolate",int)
self.createAttribute("layer",int)
self.createAttribute("orphans",int)
self.createAttribute("pour",int)
self.createAttribute("rank",int)
self.createAttribute("spacing",int)
self.createAttribute("thermals",int)
self.createAttribute("width",int)
self.createAttribute("contours",[ULWire])
self.createAttribute("fillings",[ULWire])
self.createAttribute("wires",[ULWire])
class ULContact(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("name",str)
self.createAttribute("pad",ULPad)
self.createAttribute("signal",str)
self.createAttribute("smd",ULSmd)
self.createAttribute("x",int)
self.createAttribute("y",int)
self.createAttribute("polygons",[ULPolygon])
self.createAttribute("wires",[ULWire])
class ULSmd(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("angle",float)
self.createAttribute("dx",float,args=[(int)])
self.createAttribute("dy",float,args=[(int)])
self.createAttribute("flags",int)
self.createAttribute("layer",int)
self.createAttribute("name",str)
self.createAttribute("roundness",str)
self.createAttribute("signal",str)
self.createAttribute("x",int)
self.createAttribute("y",int)
class ULPad(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("angle",float)
self.createAttribute("diameter",int,args=[(int)])
self.createAttribute("drill",int)
self.createAttribute("drillsymbol",int)
self.createAttribute("elongation",int)
self.createAttribute("flags",int)
self.createAttribute("name",str)
self.createAttribute("shape",int,args=[(int)])
self.createAttribute("signal",int)
self.createAttribute("x",int)
self.createAttribute("y",int)
class ULArc(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("angle1",float)
self.createAttribute("angle2",float)
self.createAttribute("cap",int)
self.createAttribute("layer",int)
self.createAttribute("radius",int)
self.createAttribute("width",int)
self.createAttribute("x1",int)
self.createAttribute("x2",int)
self.createAttribute("xc",int)
self.createAttribute("y1",int)
self.createAttribute("y2",int)
self.createAttribute("yc",int)
class ULWire(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("arc",ULArc)
self.createAttribute("cap",int)
self.createAttribute("curve",float)
self.createAttribute("layer",int)
self.createAttribute("style",int)
self.createAttribute("width",int)
self.createAttribute("x1",int)
self.createAttribute("x2",int)
self.createAttribute("y1",int)
self.createAttribute("y2",int)
self.createAttribute("pieces",[ULWire])
class ULText(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("align",int)
self.createAttribute("angle",float)
self.createAttribute("font",int)
self.createAttribute("layer",int)
self.createAttribute("mirror",int)
self.createAttribute("ratio",int)
self.createAttribute("size",int)
self.createAttribute("spin",int)
self.createAttribute("value",str)
self.createAttribute("x",int)
self.createAttribute("y",int)
self.createAttribute("wires",[ULWire])
class ULPackage(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("area",ULArea)
self.createAttribute("description",str)
self.createAttribute("headline",str)
self.createAttribute("library",str)
self.createAttribute("name",str)
self.createAttribute("circles",[ULCircle])
self.createAttribute("contacts",[ULContact])
self.createAttribute("dimensions",[ULDimension])
self.createAttribute("frames",[ULFrame])
self.createAttribute("holes",[ULHole])
self.createAttribute("polygons",[ULPolygon])
self.createAttribute("rectangles",[ULRectangle])
self.createAttribute("texts",[ULText])
self.createAttribute("wires",[ULWire])
def grid(self):
return ULLibrary().grid
def groups(self):
if ULContext() != ULPackage:
return []
return ULGroupSet(ULPackage)
class ULElement(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("angle",float)
self.createAttribute("attribute",str,args=[(str)])
self.createAttribute("column",str)
self.createAttribute("locked",int)
self.createAttribute("mirror",int)
self.createAttribute("name",str)
self.createAttribute("package",ULPackage)
self.createAttribute("populate",int)
self.createAttribute("row",str)
self.createAttribute("smashed",int)
self.createAttribute("spin",int)
self.createAttribute("value",int)
self.createAttribute("x",int)
self.createAttribute("y",int)
self.createAttribute("attributes",[ULAttribute])
self.createAttribute("texts",[ULText])
self.createAttribute("variants",[ULVariant])
class ULDimension(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("dtype",int)
self.createAttribute("layer",int)
self.createAttribute("x1",int)
self.createAttribute("x2",int)
self.createAttribute("x3",int)
self.createAttribute("y1",int)
self.createAttribute("y2",int)
self.createAttribute("y3",int)
self.createAttribute("texts",[ULText])
self.createAttribute("wires",[ULWires])
class ULLayer(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("color",int)
self.createAttribute("fill",int)
self.createAttribute("name",str)
self.createAttribute("number",int)
self.createAttribute("used",int)
self.createAttribute("visible",int)
class ULCircle(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("layer",int)
self.createAttribute("radius",int)
self.createAttribute("width",int)
self.createAttribute("x",int)
self.createAttribute("y",int)
class ULAttribute(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("constant",int)
self.createAttribute("defaultvalue",str)
self.createAttribute("display",int)
self.createAttribute("name",str)
self.createAttribute("text",ULText)
self.createAttribute("value",str)
class ULArea(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("x1",int)
self.createAttribute("x2",int)
self.createAttribute("y1",int)
self.createAttribute("y2",int)
class ULGrid(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("distance",float)
self.createAttribute("dots",int)
self.createAttribute("multiple",int)
self.createAttribute("on",int)
self.createAttribute("unit",int)
self.createAttribute("unitdist",int)
class ULInstance(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("angle",float)
self.createAttribute("column",str)
self.createAttribute("gate",ULGate)
self.createAttribute("mirror",int)
self.createAttribute("name",str)
#self.createAttribute("part",ULPart)
self.createAttribute("row",str)
self.createAttribute("sheet",int)
self.createAttribute("smashed",int)
self.createAttribute("value",str)
self.createAttribute("x",int)
self.createAttribute("y",int)
self.createAttribute("attributes",[ULAttribute])
self.createAttribute("texts",[ULText])
self.createAttribute("xrefs",[ULGate])
class ULBoard(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("area",ULArea)
self.createAttribute("description",str)
self.createAttribute("grid",ULGrid)
self.createAttribute("headline",str)
self.createAttribute("name",str)
self.createAttribute("attributes",[ULAttribute])
self.createAttribute("circles",[ULCircle])
self.createAttribute("classes",[ULClass])
self.createAttribute("dimensions",[ULDimension])
self.createAttribute("elements",[ULElement])
self.createAttribute("frames",[ULFrame])
self.createAttribute("holes",[ULHole])
self.createAttribute("layers",[ULLayer])
self.createAttribute("libraries",[ULLibrary])
self.createAttribute("polygons",[ULPolygon])
self.createAttribute("rectangles",[ULRectangle])
self.createAttribute("signals",[ULSignal])
self.createAttribute("texts",[ULText])
self.createAttribute("variantdefs",[ULVariantDef])
self.createAttribute("wires",[ULWire])
def groups(self):
return ULGroupSet(ULBoard)
class ULSchematic(ULObject):
def __init__(self,parent=None):
ULObject.__init__(self,parent)
self.createAttribute("alwaysvectorfont",int)
self.createAttribute("description",str)
self.createAttribute("grid",ULGrid)
self.createAttribute("headline",str)
self.createAttribute("name",str)
self.createAttribute("verticaltext",int)
self.createAttribute("xreflabel",str)
self.createAttribute("attributes",[ULAttribute])
self.createAttribute("classes",[ULClass])
self.createAttribute("layers",[ULLayer])
self.createAttribute("libraries",[ULLibrary])
self.createAttribute("nets",[ULNet])
self.createAttribute("parts",[ULPart])
self.createAttribute("sheets",[ULSheet])
self.createAttribute("instances",[ULInstance])
self.createAttribute("variantdefs",[ULVariantDef])