diff options
-rw-r--r-- | LightInstallation.py | 11 | ||||
-rw-r--r-- | Util.py | 13 | ||||
-rw-r--r-- | behaviors/DebugBehavior.py (renamed from DebugBehavior.py) | 2 | ||||
-rw-r--r-- | behaviors/EchoBehavior.py (renamed from EchoBehavior.py) | 2 | ||||
-rw-r--r-- | behaviors/__init__.py | 0 | ||||
-rw-r--r-- | config/.LightInstallationConfig.xml.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | config/Behavior.params | 1 | ||||
-rw-r--r-- | config/DecayEvent.params | 3 | ||||
-rw-r--r-- | config/Input.params | 2 | ||||
-rw-r--r-- | config/LayoutEngine.params | 6 | ||||
-rw-r--r-- | config/LightInstallationConfig.xml | 94 | ||||
-rw-r--r-- | config/PixelEvent.params | 1 | ||||
-rw-r--r-- | config/RendererConfig.xml | 14 | ||||
-rw-r--r-- | config/StepEvent.params | 1 | ||||
-rw-r--r-- | config/TestXML.xml | 23 | ||||
-rw-r--r-- | config/UDPTestConfig.xml | 24 | ||||
-rw-r--r-- | docs/designDocs.pdf | bin | 0 -> 129631 bytes | |||
-rw-r--r-- | docs/designDocs.tex | 178 | ||||
-rw-r--r-- | inputs/PygameInput.py (renamed from PygameInput.py) | 2 | ||||
-rw-r--r-- | inputs/TCPInput.py (renamed from TCPInput.py) | 3 | ||||
-rw-r--r-- | inputs/UDPInput.py (renamed from UDPInput.py) | 5 | ||||
-rw-r--r-- | layouts/LineLayout.py (renamed from LineLayout.py) | 2 | ||||
-rw-r--r-- | layouts/ZigzagLayout.py (renamed from ZigzagLayout.py) | 2 | ||||
-rw-r--r-- | layouts/__init__.py | 0 | ||||
-rw-r--r-- | operationscore/Behavior.py (renamed from Behavior.py) | 2 | ||||
-rw-r--r-- | operationscore/Input.py (renamed from Input.py) | 0 | ||||
-rw-r--r-- | operationscore/LayoutEngine.py (renamed from LayoutEngine.py) | 2 | ||||
-rw-r--r-- | operationscore/PixelEvent.py (renamed from PixelEvent.py) | 2 | ||||
-rw-r--r-- | operationscore/Renderer.py (renamed from Renderer.py) | 2 | ||||
-rw-r--r-- | operationscore/SmootCoreObject.py (renamed from SmootCoreObject.py) | 2 | ||||
-rw-r--r-- | operationscore/__init__.py | 0 | ||||
-rw-r--r-- | pixelcore/Pixel.py (renamed from Pixel.py) | 2 | ||||
-rw-r--r-- | pixelcore/PixelStrip.py (renamed from PixelStrip.py) | 4 | ||||
-rw-r--r-- | pixelcore/Screen.py (renamed from Screen.py) | 4 | ||||
-rw-r--r-- | pixelcore/__init__.py | 0 | ||||
-rw-r--r-- | pixelevents/DecayEvent.py (renamed from DecayEvent.py) | 2 | ||||
-rw-r--r-- | pixelevents/StepEvent.py (renamed from StepEvent.py) | 2 | ||||
-rw-r--r-- | pixelevents/__init__.py | 0 | ||||
-rw-r--r-- | renderers/IndoorRenderer.py (renamed from IndoorRenderer.py) | 2 | ||||
-rw-r--r-- | renderers/PygameRenderer.py (renamed from PygameRenderer.py) | 2 | ||||
-rw-r--r-- | renderers/__init__.py | 0 |
41 files changed, 387 insertions, 30 deletions
diff --git a/LightInstallation.py b/LightInstallation.py index 0c24981..3fcdcd5 100644 --- a/LightInstallation.py +++ b/LightInstallation.py @@ -1,6 +1,6 @@ from xml.etree.ElementTree import ElementTree -from Screen import Screen -from PixelStrip import PixelStrip +from pixelcore.Screen import * +from pixelcore.PixelStrip import * import pdb, sys, time, Util from pygame.locals import * #Python class to instantiate and drive a Screen through different patterns, @@ -9,9 +9,8 @@ class LightInstallation: def __init__(self, configFileName): self.inputs = {} #dict of inputs and their bound behaviors, keyed by InputId self.behaviors = {} - config = ElementTree() - config.parse(configFileName) self.screen = Screen() + config = Util.loadConfigFile(configFileName) rendererConfig = config.find('RendererConfiguration') layoutConfig = config.find('LayoutConfiguration') inputConfig = config.find('InputConfiguration') @@ -40,8 +39,8 @@ class LightInstallation: components = [] if config != None: for configItem in config.getchildren(): - className = configItem.find('Class').text - exec('from ' + className + ' import ' + className) + [module,className] = configItem.find('Class').text.split('.') + exec('from ' + module+'.'+className + ' import *') args = Util.generateArgDict(configItem.find('Args')) args['parentScope'] = self components.append(eval(className+'(args)')) #TODO: doesn't error @@ -12,11 +12,22 @@ KINET_DEEPMAGIC = 0xc001d00d KINET_MAGICHASH = 0x69000420 KINET_PORTOUT = 0x0108 KINET_UNI = 0 +CONFIG_PATH = 'config/' kinetDict = {'flags': 0, 'startcode': 0, 'pad':0} def dist(l1, l2): return math.sqrt(sum([(l1[i]-l2[i])**2 for i in range(len(l1))])) def time(): return clock.time()*1000 +def loadParamRequirementDict(className): + return fileToDict(CONFIG_PATH + className) +def loadConfigFile(fileName): + fileName = CONFIG_PATH + fileName + if '.params' in fileName: + return fileToDict(fileName) + if '.xml' in fileName: + config = ElementTree() + config.parse(fileName) + return config def fileToDict(fileName): fileText = '' with open(fileName) as f: @@ -25,7 +36,6 @@ def fileToDict(fileName): if fileText == '': return {} return eval(fileText) -print fileToDict('LayoutEngine.params') def combineColors(c1,c2): return [c1[i]+c2[i] for i in range(min(len(c1),len(c2)))] def multiplyColor(color, percent): @@ -110,7 +120,6 @@ def testXMLParse(fileName): config.parse(fileName) print generateArgDict(config.find('ChildElement')) print generateArgDict(config.find('Renderer')) -testXMLParse('TestXML.xml') ##CONSTANTS## location = 'Location' diff --git a/DebugBehavior.py b/behaviors/DebugBehavior.py index f0758be..4c8550a 100644 --- a/DebugBehavior.py +++ b/behaviors/DebugBehavior.py @@ -1,4 +1,4 @@ -from Behavior import Behavior +from operationscore.Behavior import * import Util import pdb class DebugBehavior(Behavior): diff --git a/EchoBehavior.py b/behaviors/EchoBehavior.py index 6d0a79b..a11558a 100644 --- a/EchoBehavior.py +++ b/behaviors/EchoBehavior.py @@ -1,4 +1,4 @@ -from Behavior import Behavior +from operationscore.Behavior import * import Util import pdb class EchoBehavior(Behavior): diff --git a/behaviors/__init__.py b/behaviors/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/behaviors/__init__.py diff --git a/config/.LightInstallationConfig.xml.swp b/config/.LightInstallationConfig.xml.swp Binary files differnew file mode 100644 index 0000000..cfcec1b --- /dev/null +++ b/config/.LightInstallationConfig.xml.swp diff --git a/config/Behavior.params b/config/Behavior.params new file mode 100644 index 0000000..532fa03 --- /dev/null +++ b/config/Behavior.params @@ -0,0 +1 @@ +{'Inputs':'Inputs must be defined!'} diff --git a/config/DecayEvent.params b/config/DecayEvent.params new file mode 100644 index 0000000..67b7dcf --- /dev/null +++ b/config/DecayEvent.params @@ -0,0 +1,3 @@ +{'DecayType': 'Decay type missing. Specify Exponential or Proportional.', + 'Coefficient':'Coeffienct missing. Coefficient for decay type. E^(-ct) if + exponential, c/t if proportional.'} diff --git a/config/Input.params b/config/Input.params new file mode 100644 index 0000000..f051cb3 --- /dev/null +++ b/config/Input.params @@ -0,0 +1,2 @@ +{'InputId': 'InputId must be defined in config XML', 'RefreshInterval': +'RefreshInterval must be defined in config XML'} diff --git a/config/LayoutEngine.params b/config/LayoutEngine.params new file mode 100644 index 0000000..1b1dee5 --- /dev/null +++ b/config/LayoutEngine.params @@ -0,0 +1,6 @@ +{'pixelToPixelSpacing':'pixelToPixel spacing not defined in argDict. This is the +length of wire between 2 adjacent LEDs. Common values are 4 or 12. +Specified in config XML.', 'numPixels': 'numPixels not defined in +argDict. Common value: 50.', 'originLocation':'originLocation not +defined in argDict. Values should be a string in the form (x,y). This +should be specified in the config XML.'} diff --git a/config/LightInstallationConfig.xml b/config/LightInstallationConfig.xml new file mode 100644 index 0000000..a5f4a08 --- /dev/null +++ b/config/LightInstallationConfig.xml @@ -0,0 +1,94 @@ +<!---All configuration items contain a "Class" tag specifying the python class they represent, and an "Args" tag specifying the args to be passed in.--> +<LightInstallation> + <LayoutConfiguration> + + <PixelStrip> + <Class>layouts.ZigzagLayout</Class><!--Name of Layout Class, + imported dynamically via a eval('import ' + name)--> + <Args><!--Any args the layout class needs. This go as + elements of a dictionary that gets passed to the Layout machinery--> + <Id>strip1</Id> + <zigLength>25</zigLength> + <zigAxis>X</zigAxis> + <yDirection>-1</yDirection> + <pixelToPixelSpacing>12</pixelToPixelSpacing> + <spacing>12</spacing> <!--we can space at any value less the + l2lspacing--> + <numPixels>50</numPixels> + <originLocation>(10,10)</originLocation> + </Args> + </PixelStrip> + <PixelStrip> + <Class>layouts.ZigzagLayout</Class><!--Name of Layout Class, + imported dynamically via a eval('import ' + name)--> + <Args><!--Any args the layout class needs. This go as + elements of a dictionary that gets passed to the Layout machinery--> + <Id>strip2</Id> + <zigLength>25</zigLength> + <zigAxis>X</zigAxis> + <yDirection>1</yDirection> + <pixelToPixelSpacing>12</pixelToPixelSpacing> + <spacing>12</spacing> <!--we can space at any value less the + l2lspacing--> + <numPixels>50</numPixels> + <originLocation>(10,30)</originLocation> + </Args> + </PixelStrip> + </LayoutConfiguration> + <RendererConfiguration> + <Renderer> + <Class>renderers.PygameRenderer</Class> + <Args> + <displaySize>(1300,50)</displaySize> + </Args> + </Renderer> + <Renderer> + <Class>renderers.IndoorRenderer</Class> + <Args> + <PowerSupply> + <IP>10.1.218.72</IP> + <PortMapping>{'strip1':1, 'strip2':2}</PortMapping> + </PowerSupply> + </Args> + </Renderer> + </RendererConfiguration> + <InputConfiguration> + <InputElement> + <Class>inputs.PygameInput</Class> + <Args><!--Passed as a dictionary--> + <InputId>pygame</InputId> + <RefreshInterval>100</RefreshInterval> + </Args> + </InputElement> + <InputElement> + <Class>inputs.UDPInput</Class> + <Args> + <InputId>UDP</InputId> + <Port>6038</Port> + <RefreshInterval>100</RefreshInterval> + </Args> + </InputElement> + </InputConfiguration> + <BehaviorConfiguration> + <Behavior> + <Class>behaviors.EchoBehavior</Class> + <Args> + <behaviorId>echo</behaviorId> + <z-index>0</z-index> + <Inputs> + <InputId>pygame</InputId> + </Inputs> + </Args> + </Behavior> + <Behavior> + <Class>behaviors.DebugBehavior</Class> + <Args> + <behaviorId>debug</behaviorId> + <z-index>0</z-index> + <Inputs> + <InputId>UDP</InputId> + </Inputs> + </Args> + </Behavior> + </BehaviorConfiguration> +</LightInstallation> diff --git a/config/PixelEvent.params b/config/PixelEvent.params new file mode 100644 index 0000000..bc5dd82 --- /dev/null +++ b/config/PixelEvent.params @@ -0,0 +1 @@ +{'Color':'Color must be defined in argDict'} diff --git a/config/RendererConfig.xml b/config/RendererConfig.xml new file mode 100644 index 0000000..27fb98b --- /dev/null +++ b/config/RendererConfig.xml @@ -0,0 +1,14 @@ +<!---All configuration items contain a "Class" tag specifying the python class they represent, and an "Args" tag specifying the args to be passed in.--> +<LightSystem> + <RendererConfiguration> + <Renderer> + <Class>IndoorRenderer</Class> + <Args> + <PowerSupply> + <IP>10.1.218.72</IP> + <PortMapping>{'strip1':1}</PortMapping> + </PowerSupply> + </Args> + </Renderer> + </RendererConfiguration> +</LightSystem> diff --git a/config/StepEvent.params b/config/StepEvent.params new file mode 100644 index 0000000..64d4365 --- /dev/null +++ b/config/StepEvent.params @@ -0,0 +1 @@ +{'LightTime': 'You must define LightTime (ms) in argDict.'} diff --git a/config/TestXML.xml b/config/TestXML.xml new file mode 100644 index 0000000..20d7f6f --- /dev/null +++ b/config/TestXML.xml @@ -0,0 +1,23 @@ +<RootElement> + <ChildElement> + <setOfElements> + <a>1</a> + <a>2</a> + <a>3</a> + </setOfElements> + <normalElement>normal</normalElement> + </ChildElement> + <Renderer> + <Class>IndoorRenderer</Class> + <Args> + <PowerSupply> + <IP>192.168.1.0</IP> + <PortMapping>{'strip1':1,'strip2':2}</PortMapping> + </PowerSupply> + <PowerSupply> + <IP>192.168.1.1</IP> + <PortMapping>{'strip3':1, 'strip4':2}</PortMapping> + </PowerSupply> + </Args> + </Renderer> +</RootElement> diff --git a/config/UDPTestConfig.xml b/config/UDPTestConfig.xml new file mode 100644 index 0000000..8483833 --- /dev/null +++ b/config/UDPTestConfig.xml @@ -0,0 +1,24 @@ +<!---All configuration items contain a "Class" tag specifying the python class they represent, and an "Args" tag specifying the args to be passed in.--> +<LightSystem> + <InputConfiguration> + <InputElement> + <Class>UDPInput</Class> + <Args> + <InputId>UDP</InputId> + <Port>6038</Port> + </Args> + </InputElement> + </InputConfiguration> + <BehaviorConfiguration> + <Behavior> + <Class>DebugBehavior</Class> + <Args> + <behaviorId>debug</behaviorId> + <z-index>0</z-index> + <Inputs> + <InputId>UDP</InputId> + </Inputs> + </Args> + </Behavior> + </BehaviorConfiguration> +</LightSystem> diff --git a/docs/designDocs.pdf b/docs/designDocs.pdf Binary files differnew file mode 100644 index 0000000..78eb646 --- /dev/null +++ b/docs/designDocs.pdf diff --git a/docs/designDocs.tex b/docs/designDocs.tex new file mode 100644 index 0000000..2a9fd97 --- /dev/null +++ b/docs/designDocs.tex @@ -0,0 +1,178 @@ +\documentclass{article} +\usepackage{fullpage} +\begin{document} + \title{150 Smoots Lighting Installation Design Document} + \author{Russell Cohen} + \date{\today} + \maketitle + \newcommand{\classDoc}[5]{ + \subsection{#1} + \begin{itemize} + \item \textbf{Inherits from: } #2 + \item \textbf{Inherited by: } #3 + \item \textbf{Brief Description: } #4 + \item \textbf{Argument Requirements: } #5 + \end{itemize} + } + \section{Intro} + \textbf{NB: These docs give an overview of the classes and methods but + may lag behind the code for certain in-flux functionality. For + up-to-the minute docs, please use pydoc.} \\ + The system, which we will describe henceforth as SmootLight is a + modular system designed with the following goals in mind: + \begin{itemize} + \item The system must abstract away from all components while + remaining useful (\verb=Renderer=, \verb=Input=, \verb=Behavior=) + \item The system must be modular and be easy to write new code for. + \item More goals as I think of them + \end{itemize} + We accomplish this in the following manner: + \begin{itemize} + \item The system is configured by an XML file which specifies its + components. + \item All classes are initialized with a dictionary as an argument + containing anything a class may need. All objects are passed + between members as python dictionaries because their easy + serialization. + \end{itemize} + \section{Operations Class Patterns} + \classDoc{SmootCoreObject}{None}{All 2nd level classes (PixelAssembler, Renderer, + Input, Behavior)} + {SmootCoreObject is essentially a super-object + that makes things easy for us. It does the following actions: + \begin{itemize} + \item Defines a constructor that sets argDict + \item Defines a \texttt{\_\_getitem\_\_} , which lets us acces items in + argDict as if the class was a dictionary. + (\texttt{self['itemName']}) + \item Defines validateArgs and validateArgDict which + validate the incoming arguments against a dictionary + containing argument names as keys and an error message to + display if they are missing as a values. This file should + be named classname.params and look like a python dict + (\texttt{\{'key':value, 'key2':value2\}} ) + \end{itemize} + Note that at this point, the only class using this functionality + is the PixelEvent class.} + {No required parameters in argDict} + \classDoc{PixelAssembler}{SmootCoreObject}{LineLayout, ZigzagLayout}{ + PixelAssembler is a class that defines the positions of lights. It + provides a method \texttt{getLightLocations} which give a list of + all light locations for a given strip. Inheriting classes must + define \texttt{layoutFunc} which returns the next location given the + previous location. (They may simply override + \texttt{getLightLocations} + instead, if they wish, but be careful when doing so). In + heriting classes may defint \texttt{initLayout} which is called at + initialization.}{\begin{itemize} + \item \texttt{lightToLightSpacing}: this is the length of wire + between 2 adjacent LEDs. Common values are 4 or 12. + \item \texttt{numLights}: Number of lights in a strip. + \item \texttt{originLocation}: Location of the first light. + \end{itemize}} + \classDoc{Renderer}{SmootCoreObject}{PygameRenderer, IndoorRenderer}{ + Renderer is a class that serves as an abstract class for renderers + interacting with the system. Inheriting classes must define + render, which is passed a \texttt{lightSystem} object. Inheriting + classes may define initRenderer which is called on initiation. + }{No required arguments} + \classDoc{Input}{SmootCoreObject, threading.Thread}{PygameInput, + TCPInput,UDPInput}{Input is a abstract class which facilitates Inputs. + It does this by providing a method that is polled at a periodic + interval within which the inheriting class can raise an event. + Inheriting classes must define \texttt{sensingLoop} which is + called at the interval specified in the config. Inheriting + classes should call respond with an dictionary as an argument + to raise an event. Classes using (not + inheriting) input must pass a scope into + the argDict which offers a \texttt{processInput} + method. Inputs are marked as Daemon threads, and + are therefore killed when their parent is + killed.}{\begin{itemize} + \item \texttt{InputId}: The string id of a given input. Must be + unique. + \item Optional:\texttt{RefreshInterval}: The interval in + seconds (will soon be changed to milliseconds) between + sucessive calls to the sensingLoop method. TODO: make + timeout. + \end{itemize}} + \classDoc{Behavior}{SmootCoreObject}{EchoBehavior, DebugBehavior}{ +Abstract class for a behavior. On every time step, the behavior is passed the +inputs from all sensors it is bound to as well as any recursive inputs that it +spawned during the last time step. Inheriting classes MUST define +\texttt{processBehavior}. \texttt{processBehavior} should return a list of dictionaries which +define the properties of the light response. The must return a location +\texttt{PixelEvent} class. Soon be be deprecated:\textit{They must give a location and +color. They may define a function pointer which defines a custom mapping. +[More on this later. Bug Russell if you want to do it].} +Call \texttt{recursiveResponse} to queue a input on the next iteration with a dictionary +argument. This will be passed in via recursive inputs.} +{\begin{itemize} + \item \texttt{Inputs}: A list of input Ids specifying input to the + behavior. In the future, this may also contain behavior ids. +\end{itemize}} +\classDoc{PixelEvent}{SmootCoreObject}{StepResponse}{ + Abstract class defining the behavior of a light after it has been turned on. + Inheriting classes should defint \texttt{lightState} which is passed a + timeDelay in ms as an argument. \texttt{lightState} should return a + color or None if the response is complete.}{\begin{itemize} + \item \texttt{Color}: The color of response. \textit{This is may be + removed in the future} + \end{itemize} + } +\section{The Screen Class and Its Relatives} +\classDoc{Screen}{None}{None} +{The \texttt{Screen} class is a representation of an entire system of pixels, + distributed over space. The Screen class and its relatives process + responses (mapped to pixels via a LayoutEngine), and add PixelEvents + to the individual pixels. The Screen provides an instance that + renderers can call to determine the color of all the individual pixels. It contains a list of PixelStrips, which each + address the individual pixels. \texttt{Screen} offers a + \texttt{respond} method which takes a dictionary containing information + about a response. TODO: detail the contents of this dictionary (maybe + somewhere else). Note: \texttt{Screen} will not process its + responses until \texttt{timeStep} is called which processes all responses that + have been queued since the last time that \texttt{timeStep} was + called. Screen also offers an iterator over \textit{all} lights, + accesible by using an expression like: \texttt{for light in screen:}. For + addressing of specific \texttt{PixelStrips} , \texttt{self.pixelStrips} + is exposed.}{No required parameters} +\classDoc{PixelStrip}{None}{None} +{The \texttt{PixelStrip} class is a representation of a string of Pixels that are + connected in physical space (eg. a strip of lights). A \texttt{PixelStrip} takes a + \texttt{LayoutBuilder} (\textit{Name up for debate, currently known as layout + engine}) as an argument. The \texttt{argDict} of the + \texttt{LayoutBuilder} is + passed becomes the \texttt{argDict} of the \texttt{PixelStrip}. + \texttt{PixelStrip} generally shouldn't be + adressed directly unless you need Strip-Identification for rendering + purposes. You should never, for example, call \texttt{respond} on a + \texttt{PixelStrip} + directly, unless you really know what you're doing. Well, actually you + should never need to do that. + never. Don't do it.}{Takes a \texttt{LayoutBuilder} as an argument.} + \section{Best Practices} + \subsection{Variable and function naming} + I'm pretty bad about being consistent. However, in all future + code, please adhere to the following: + \begin{itemize} + \item Classes: \texttt{FirstLetterCaps} + \item Functions: \texttt{camelCase} + \item Property Names: \texttt{FirstLetterCaps} + \item Constants: \texttt{ALL\_CAPS\_WITH\_UNDERSCORES} + \end{itemize} + \subsection{Time} + For time, use the \texttt{Util.time()} method to return the current + time in ms. + \subsection{Acessing Pixels} + The ideal method for acessing Pixels in a screen is to use its + iterator. Iterating over the individual PixelStrips is also an + acceptable method. + \subsection{Determining the state of a \texttt{Pixel}} + The best practice for determining the color of a \texttt{Pixel} is to call + \texttt{lightState} (may be renamed to State TODO). This ensures + all current active responses running on the Pixel contribute correctly. + \subsection{Color} + For color, use a tuple of (R,G,B) 0-255 for each. Colors can be + easily manipulated with members of the Util class. + \end{document} diff --git a/PygameInput.py b/inputs/PygameInput.py index 12ae7f6..6c84664 100644 --- a/PygameInput.py +++ b/inputs/PygameInput.py @@ -1,5 +1,5 @@ import time, Util -from Input import Input +from operationscore.Input import * import pygame from pygame.locals import * #This class processes input from an already running pygame instance and passes diff --git a/TCPInput.py b/inputs/TCPInput.py index 903b6f0..72d8742 100644 --- a/TCPInput.py +++ b/inputs/TCPInput.py @@ -1,5 +1,6 @@ import SocketServer -import Util, Input +import Util +from operationscore.Input import * """ A rough sketch about how a TCP socket server receives data from the phone (or other stuff). diff --git a/UDPInput.py b/inputs/UDPInput.py index f0af2b0..b0d6c93 100644 --- a/UDPInput.py +++ b/inputs/UDPInput.py @@ -1,6 +1,7 @@ -import Util, Input +import Util +from operationscore.Input import * import socket -class UDPInput(Input.Input): +class UDPInput(Input): def inputInit(self): HOST = '' # Symbolic name meaning all available interfaces PORT = self.argDict['Port'] # Arbitrary non-privileged port diff --git a/LineLayout.py b/layouts/LineLayout.py index f5cb5ce..3a8b747 100644 --- a/LineLayout.py +++ b/layouts/LineLayout.py @@ -1,4 +1,4 @@ -from LayoutEngine import LayoutEngine +from operationscore.LayoutEngine import * #Simple layout class that simply makes a line of LEDs class LineLayout(LayoutEngine): def layoutFunc(self, lastLocation): diff --git a/ZigzagLayout.py b/layouts/ZigzagLayout.py index 66d27ec..26b27d8 100644 --- a/ZigzagLayout.py +++ b/layouts/ZigzagLayout.py @@ -1,4 +1,4 @@ -from LayoutEngine import LayoutEngine +from operationscore.LayoutEngine import * import pdb #Slightly more complex layout class that makes a zig-Zag Led Pattern #Inheriting classes must specify zigLength, the length in lights of a of a zig diff --git a/layouts/__init__.py b/layouts/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/layouts/__init__.py diff --git a/Behavior.py b/operationscore/Behavior.py index e25f7be..f29430f 100644 --- a/Behavior.py +++ b/operationscore/Behavior.py @@ -8,7 +8,7 @@ #recursiveResponse to queue a input on the next iteration with a dictionary #argument. This will be passed in via recursive inputs. import pdb -from SmootCoreObject import SmootCoreObject +from operationscore.SmootCoreObject import * #timeStep is called on every iteration of the LightInstallation #addInput is called on each individual input received, and the inputs queue class Behavior(SmootCoreObject): diff --git a/Input.py b/operationscore/Input.py index 1ba4528..1ba4528 100644 --- a/Input.py +++ b/operationscore/Input.py diff --git a/LayoutEngine.py b/operationscore/LayoutEngine.py index 153167e..700b554 100644 --- a/LayoutEngine.py +++ b/operationscore/LayoutEngine.py @@ -1,4 +1,4 @@ -from SmootCoreObject import SmootCoreObject +from operationscore.SmootCoreObject import * import Util import pdb class LayoutEngine(SmootCoreObject): diff --git a/PixelEvent.py b/operationscore/PixelEvent.py index a932e23..07669cd 100644 --- a/PixelEvent.py +++ b/operationscore/PixelEvent.py @@ -1,7 +1,7 @@ #Class defining a light response. Inheriting classes should define lightState, #which should return a color, or None if the response is complete. Consider #requiring a generate event. -from SmootCoreObject import SmootCoreObject +from operationscore.SmootCoreObject import * class PixelEvent(SmootCoreObject): def init(self): self.validateArgs('PixelEvent.params') diff --git a/Renderer.py b/operationscore/Renderer.py index 2297f1f..11fd8ca 100644 --- a/Renderer.py +++ b/operationscore/Renderer.py @@ -2,7 +2,7 @@ #Inheriting classes MUST define render which takes a light system and renders it. #Inheriting classes may define initRenderer which is called after the dictionary #is pulled from config. -from SmootCoreObject import SmootCoreObject +from operationscore.SmootCoreObject import * class Renderer(SmootCoreObject): def init(self): self.initRenderer() diff --git a/SmootCoreObject.py b/operationscore/SmootCoreObject.py index 74e1a9a..2901ef6 100644 --- a/SmootCoreObject.py +++ b/operationscore/SmootCoreObject.py @@ -16,7 +16,7 @@ class SmootCoreObject: def __getiter__(self): return self.argDict.__getiter__() def validateArgs(self, argFileName): - self.validateArgDict(Util.fileToDict(argFileName)) + self.validateArgDict(Util.loadParamRequirementDict(argFileName)) def validateArgDict(self, validationDict): for item in validationDict: if not item in self.argDict: diff --git a/operationscore/__init__.py b/operationscore/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/operationscore/__init__.py diff --git a/Pixel.py b/pixelcore/Pixel.py index 71e77ed..6784c63 100644 --- a/Pixel.py +++ b/pixelcore/Pixel.py @@ -1,6 +1,6 @@ import Util import pdb -from StepEvent import StepEvent +from pixelevents.StepEvent import * #Pixel keeps a queue of events (PixelEvent objects) (actually a dictionary #keyed by event time). Every time is state is #requested, it processes all the members of its cue. If a member returns none, diff --git a/PixelStrip.py b/pixelcore/PixelStrip.py index 7be9528..14c87d9 100644 --- a/PixelStrip.py +++ b/pixelcore/PixelStrip.py @@ -1,5 +1,5 @@ -from Pixel import Pixel -from StepEvent import StepEvent +from pixelcore.Pixel import * +from pixelevents.StepEvent import * import pygame import math import Util diff --git a/Screen.py b/pixelcore/Screen.py index fe9abc7..9806daa 100644 --- a/Screen.py +++ b/pixelcore/Screen.py @@ -1,5 +1,5 @@ -from Pixel import Pixel -from PixelStrip import PixelStrip +from pixelcore.Pixel import * +from pixelcore.PixelStrip import * import itertools class Screen: def __init__(self): diff --git a/pixelcore/__init__.py b/pixelcore/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/pixelcore/__init__.py diff --git a/DecayEvent.py b/pixelevents/DecayEvent.py index 4dbe3cd..c9fc226 100644 --- a/DecayEvent.py +++ b/pixelevents/DecayEvent.py @@ -1,4 +1,4 @@ -from PixelEvent import PixelEvent +from pixelcore import PixelEvent import Util, math class DecayEvent(PixelEvent): def initEvent(self): diff --git a/StepEvent.py b/pixelevents/StepEvent.py index aca933b..d95271e 100644 --- a/StepEvent.py +++ b/pixelevents/StepEvent.py @@ -1,4 +1,4 @@ -from PixelEvent import PixelEvent +from operationscore.PixelEvent import * class StepEvent(PixelEvent): def initEvent(self): self.validateArgs('StepEvent.params') diff --git a/pixelevents/__init__.py b/pixelevents/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/pixelevents/__init__.py diff --git a/IndoorRenderer.py b/renderers/IndoorRenderer.py index b42c337..efe2b3a 100644 --- a/IndoorRenderer.py +++ b/renderers/IndoorRenderer.py @@ -1,4 +1,4 @@ -from Renderer import Renderer +from operationscore.Renderer import * import socket, Util import pdb kinetPort = 6038 diff --git a/PygameRenderer.py b/renderers/PygameRenderer.py index 81740c7..6f7f65b 100644 --- a/PygameRenderer.py +++ b/renderers/PygameRenderer.py @@ -1,4 +1,4 @@ -from Renderer import Renderer +from operationscore.Renderer import * import pygame from pygame.locals import * import pdb diff --git a/renderers/__init__.py b/renderers/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/renderers/__init__.py |