Commits

Peter Polidoro committed b828153

Modified python files to handle multiple arrays.

  • Participants
  • Parent commits e66b97c

Comments (0)

Files changed (3)

File brd_tools.py

+"""
+Copyright 2010  IO Rodeo Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+from __future__ import division
+import sys
 
 class ComponentPlacer(object):
 
         self.filename = filename
         self.lines = self.readFile()
         self.moduleDict = self.getModuleDict()
-        
+
     def readFile(self):
         """
-        Read the file and return a list of all lines. 
+        Read the file and return a list of all lines.
         """
         with open(self.filename,'r') as fid:
             lines = fid.readlines()
         moduleLines = self.moduleDict[name]
         posFound = False
         for moduleIndex, lineData in enumerate(moduleLines):
-            linesIndex, line = lineData 
+            linesIndex, line = lineData
             splitLine = line.split()
             if splitLine[0] == 'Po' and len(splitLine) > 3:
                 splitLine[1] = '%d'%(round(10000*x),)
 
     def write(self,filename=None):
         """
-        Write new .brd file. If filename argument is not specified the 
+        Write new .brd file. If filename argument is not specified the
         same name as the original file will be used.
         """
         if filename is None:
                 fid.write(line)
 
     def printLines(self):
-        """ 
+        """
         Prints all lines in the file.
         """
         for i, line in enumerate(self.lines):
             print i, line
-                
+
 
 # -----------------------------------------------------------------------------
 if __name__ == '__main__':
+    # xNum = 11
+    # yNum = 15
+    # xStart = 1.0
+    # yStart = 1.0
+    # xStep = 0.3691
+    # yStep = 0.3691
 
-    xNum = 11 
-    yNum = 15 
-    xStart = 1.0
-    yStart = 1.0
-    xStep = 0.3
-    yStep = 0.3
+    # placer = ComponentPlacer('ledarray.brd')
+    # for i in range(0,xNum):
+    #     for j in range(0,yNum):
+    #         name = 'D%d,%d'%(j,i)
+    #         x = xStart + i*xStep
+    #         y = yStart + j*yStep
+    #         ang = 0
+    #         placer.setModulePos(name,x,y,ang)
+    # placer.write()
 
-    placer = ComponentPlacer('ledarray.brd')
-    for i in range(0,xNum):
-        for j in range(0,yNum):
-            name = 'D%d,%d'%(j,i)
-            x = xStart + i*xStep
-            y = yStart + j*yStep
-            ang = 0
-            placer.setModulePos(name,x,y,ang)
+
+    board_filename = sys.argv[1]
+    print "Placing components in %s" % (board_filename,)
+
+    xNum_input = 6
+    yNum_input = 96
+    xNum_output = 24
+    yNum_output = 24
+    xStep = 0.3691
+    yStep = 0.3691
+    xCenter = (xNum_output - 1)/2 * xStep
+    yCenter = (yNum_output - 1)/2 * yStep
+    xStart = int(10.0 + xCenter) - xCenter
+    yStart = int(10.0 + yCenter) - yCenter
+
+    placer = ComponentPlacer(board_filename)
+    for h in range(0,int(xNum_output/xNum_input)):
+        xLow = h*xNum_input
+        xHigh = xLow + xNum_input
+        for i in range(xLow,xHigh):
+            for j in range(0,yNum_output):
+                name0 = j + h*yNum_output
+                name1 = i - h*xNum_input
+                name = 'D%d,%d'%(name0,name1)
+                x = xStart + i*xStep
+                y = yStart + j*yStep
+                ang = 0
+                placer.setModulePos(name,x,y,ang)
     placer.write()
-
-

File led_schem_array.py

+"""
+Copyright 2010  IO Rodeo Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+from __future__ import division
 import os.path
 import time
 

File led_schem_multi_array.py

+"""
+Copyright 2010  IO Rodeo Inc.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+from __future__ import division
 import os.path
 import time
 
     def writeSchFile(self):
         with open(self.schFileName,'w') as self.schFid:
             self.writeHeader()
+            self.writeLabels()
             self.writeArrayWires()
             self.writeLEDArray()
             self.writeFooter()
     def writeFooter(self):
         self.schFid.write('$EndSCHEMATC\n')
 
+    def writeLabels(self):
+        pass
+
     def writeArrayWires(self):
         for arrayNum in range(self.numArrays):
             ledPos = self.getLEDPos(arrayNum)
 
     def writeLEDArray(self):
         for arrayNum in range(self.numArrays):
+            self.writeLEDConn(arrayNum)
             ledPos = self.getLEDPos(arrayNum)
             for k,v in ledPos.iteritems():
                 i,j = k
                 x,y = v
                 self.writeLED(i,j,x,y,arrayNum)
 
+    def writeLEDConn(self,arrayNum=0):
+        self.schFid.write('$Comp\n')
+
+        refStr = 'P' + str(arrayNum)
+        self.schFid.write('L CONN_2 %s\n'%(refStr,))
+
+        timeStamp = hex(int(time.time()))[2:]
+        timeStamp = timeStamp.upper()
+        self.schFid.write('U 1 1 %s\n'%(timeStamp,))
+
+        x = self.upperLeft[0] - 1000
+        y = self.upperLeft[1] + 1000*arrayNum
+
+        self.schFid.write('P %d %d\n'%(x,y))
+
+        annotationX = x - 50
+        annotationY = y
+        self.schFid.write('F 0 "%s" V %d %d  40 0000 C CNN\n'%(refStr,annotationX, annotationY))
+
+        valueStr = 'LED_CONN'
+        valueX = x + 50
+        valueY = y
+        self.schFid.write('F 1 "%s" V %d %d  40 0000 C CNN\n'%(valueStr,valueX, valueY))
+        self.schFid.write('\t1    %d %d\n'%(x,y))
+        self.schFid.write('\t1    0    0    -1\n')
+
+        self.schFid.write('$EndComp\n')
+
     def writeLED(self,i,j,x,y,arrayNum=0):
         self.schFid.write('$Comp\n')
 
         self.schFid.write('$EndComp\n')
 
         # Save info for writing .cmp file
-        self.ledData[(i,j)] = {
+        self.ledData[(i,j,arrayNum)] = {
                 'reference' : refStr,
                 'timeStamp' : timeStamp,
                 'value'     : valueStr,
         with open(self.cmpFileName,'w') as cmpFid:
             # Write header - need to modify so that the date string is correct
             cmpFid.write('Cmp-Mod V01 Created by CVpcb (20090216-final) date = Thu 14 Jul 2011 05:35:17 PM PDT\n\n')
-            for i in range(self.numParallel):
-                for j in range(self.numSeries):
-                    data = self.ledData[(i,j)]
-                    cmpFid.write('BeginCmp\n')
-                    cmpFid.write('TimeStamp = /%s;\n'%(data['timeStamp'],))
-                    cmpFid.write('Reference = %s;\n'%(data['reference'],))
-                    cmpFid.write('ValuerCmp = %s;\n'%(data['value'],))
-                    cmpFid.write('IdModule  = %s;\n'%(data['module'],))
-                    cmpFid.write('EndCmp\n\n')
+            for arrayNum in range(self.numArrays):
+                data = self.ledData[(0,0,0)]
+                cmpFid.write('BeginCmp\n')
+                cmpFid.write('TimeStamp = /%s;\n'%(data['timeStamp'],))
+                cmpFid.write('Reference = %s;\n'%('P'+str(arrayNum),))
+                cmpFid.write('ValuerCmp = %s;\n'%('LED_CONN',))
+                cmpFid.write('IdModule  = %s;\n'%('DCJACK_2PIN_HIGHCURRENT',))
+                cmpFid.write('EndCmp\n\n')
+                for i in range(self.numParallel):
+                    for j in range(self.numSeries):
+                        data = self.ledData[(i,j,arrayNum)]
+                        cmpFid.write('BeginCmp\n')
+                        cmpFid.write('TimeStamp = /%s;\n'%(data['timeStamp'],))
+                        cmpFid.write('Reference = %s;\n'%(data['reference'],))
+                        cmpFid.write('ValuerCmp = %s;\n'%(data['value'],))
+                        cmpFid.write('IdModule  = %s;\n'%(data['module'],))
+                        cmpFid.write('EndCmp\n\n')
             cmpFid.write('EndListe\n')
 
 
 LIBS:power,device,transistors,conn,linear,regul,74xx,cmos4000,adc-dac,memory,xilinx,special,microcontrollers,dsp,microchip,analog_switches,motorola,texas,intel,audio,interface,digital-audio,philips,display,cypress,siliconi,opto,atmel,contrib,valves,./CACHEFILE_MARKER
 EELAYER 24  0
 EELAYER END
-$Descr A4 11700 8267
+$Descr E 44000 34000
 Sheet 1 1
 Title ""
 Date "14 jul 2011"