コード例 #1
0
ファイル: sid.py プロジェクト: gbdu/project_sid
except ImportError as e:
    print "Could not import from sid ... "
    exit(1)

try:
    from component import component
    from helpers import getmylogger

except ImportError as e:    
    print "could not import internal from sid"
    print e
    exit(1)
last_component_number = 0

log = getmylogger.loud_logger("sid")
qlog = getmylogger.silent_logger("sid_silent")

class Sid:
    '''create 256 components, then hang and print a message every 1 sec as
    the components run'''
    
    # locks, myname
    mystate = Value("d", 0) # 0 for dead, 1 for alive, set by creator
    components = [] # alist of tuples of form  (c, s, a, b, h, l)
    processes = []

    def add_component(self, component_hints):
        '''add a tuple of the form (component, state, parent_pipe, child_pipe,
        hints) and append it to list components
        
        state is an integer, 0 for dead, 1 for alive
コード例 #2
0
ファイル: component.py プロジェクト: gbdu/project_sid
__status__ = "dev"

import random
from multiprocessing import Process, Value, Lock
from time import sleep

try :
    from neuron import Neuron
    from helpers.getmylogger import loud_logger,silent_logger

except ImportError as e:
    print "Could not import from component"
    print e
    raise e

log = silent_logger("component")

def error(n):
    log.exception(RuntimeError(n))
    raise(BadValue(n))

DEFAULT_NEURONS_PER_LAYER = 8
DEFAULT_LAYERS_FOR_EACH_TYPE = 8

class component:
    ''' an octo is an 8 channel parallel (list of 8 floats from numpy)
            perform thread synch when playing with it
    '''

    octo_layer_average = []
    mystate = None # You get this from parent
コード例 #3
0
ファイル: ut.py プロジェクト: gbdu/project_sid
''' ut: universal tweener with asynch locks for python ~ gbdu'''

try:
    from helpers.getmylogger import silent_logger,loud_logger
    from multiprocessing import Lock
    import exceptions
except Exception as e:
    print "Could not load ut dependencies: "
    print e
    exit(1)
    
logger = loud_logger("gui_helpers")
    
llog = silent_logger("tweener")
DEFAULT_TWEEN_TO = 0
DEFAULT_TWEEN_MIN = 0
DEFAULT_TWEEN_VALUE = 0

class Ut:
    '''universal tweener for python -- with locks'''
    _itl = []

    def find_tweener(self, name):
        '''returns an internal dict if a tweener exists in internal list'''
        if len(self._itl) == 0:
            llog.warning("list not initd eyet and youre trying to find %s ", name)
            return False
        
        for i in self._itl :
            if i['name'] == name:
                llog.info("returning %s as found ", name)