예제 #1
0
 def __init__(self):
     CompositeNode.__init__(self)
     AutoDiscoveredNode.__init__(self)
     self.running = 0
     self.discover_mode = 'never'
     self._been_discovered = 0
     self.source = 'broadway' #or 'bacnet'
예제 #2
0
파일: host.py 프로젝트: mcruse/monotone
 def __init__(self):
     CompositeNode.__init__(self)
     self.coprocessor = None
     self.port_map = None
     self.eth_map = None
     self.modem_map = None
     return
예제 #3
0
 def configure(self, config):
     CompositeNode.configure(self, config)
     set_attribute(self, 'url', '', config, str)
     set_attribute(self, 'user', '', config, str)
     set_attribute(self, 'password', '', config, str)
     set_attribute(self, 'spreadsheet', self.name, config, str) #spreadsheet name
     set_attribute(self, 'worksheet', '', config, str)
예제 #4
0
 def start(self):
     CompositeNode.start(self)
     next_position = 0
     timestamp = PeriodicColumn()
     timestamp.configure({'parent':self.get_child('recorders'),
                          'name':'timestamp',
                          'position':next_position,
                          'sort_order':'ascending',
                          'args':(),
                          'function':self.scheduled_time})
     timestamp.sequence = 0
     sequences = []
     for child in self.get_child('recorders').children_nodes():
         if child.__class__ == Recorder:
             if child.sequence in sequences:
                 raise EConfiguration(
                     'Conflicting RecorderSet sequence %s on %r' %
                     (child.sequence, child.name))
         sequences.append(child.sequence)
     # Force Timestamp as column '0'.
     self.collector.add_column(timestamp)
     children = self.get_child('recorders').children_nodes()
     children.sort(_sort)
     for child in children:
         if child.__class__ == Recorder:
             for channel in child.channels():
                 next_position += 1
                 channel.position = next_position
                 self.collector.add_column(channel)
     cc = ColumnConfiguration()
     cc.configure(timestamp.configuration())
     self.log.configure([cc]+self.collector.columns[1:],
                        self.minimum_size,self.maximum_size)
     self.collector.start()
예제 #5
0
 def start(self):
     self.port = self.parent
     if not self.port.is_open():
         self.port.open()
     self.line_handler = cat_lib.CCMLineHandler(self.port)
     self.line_handler.start(self.password)
     CompositeNode.start(self)
 def test_configure_sequence_get(self):
     p = PeriodicLog()
     p.configure({'name':'log','parent':None, 'period':1})
     h = CompositeNode()
     h.configure({'name':'columns','parent':p})
     c = PeriodicDeltaColumn()
     c.configure({'position':0, 'name':'2', 'parent':h,
                  'function':self._next})
     p.start()
     try:
         l = []
         if c.get() != None:
             raise 'Get didn\'t return None on first get'
         if c.get() != None:
             raise 'Get didn\'t return None on second get'
         self.seq.value = 0
         c.function()
         self._next()
         self._next()
         self._next()
         if c.get() != self.seq.value - 1:
             raise 'Got incorrect value after incrementing'
     finally:
         p.stop()
     return
예제 #7
0
 def start(self):
     CompositeNode.start(self)
     self.local_context = {}
     try:
         self.compiled_statement = compile(self.statement, '', 'eval')
         #examine each variable and decide what to do with it
         for variable in self.variables:
             name = variable['vn']
             definition = variable['node_reference']
             if self.local_context.has_key(name):
                 raise EInvalidValue('variable',name,
                                     'Variable name duplicated')
             exceptions = []
             conversions = self._conversions[:]
             while conversions:
                 conversion = conversions.pop(0)
                 try:
                     reference = conversion(definition)
                     break
                 except Exception,e:
                     exceptions.append(e)
             else:
                 self.local_context = {}
                 raise EInvalidValue('variable',name,
                                     ('Conversions %s Gave Errors %s.' %
                                      (self._conversions,exceptions)))
             self.local_context[name] = reference
         self.started = 1
예제 #8
0
파일: server.py 프로젝트: mcruse/monotone
 def __init__(self):
     CompositeNode.__init__(self)
     ProxyAbstractClass.__init__(self)
     self.debug = 0
     self.value = None
     self.buffer = None
     self.last_set_exception = None
예제 #9
0
 def __init__(self):
     CompositeNode.__init__(self)
     self._threads = set()
     self.started = 0
     self._failed = {}
     self._exception = None
     return
예제 #10
0
 def configure(self, config_dict):
     CompositeNode.configure(self, config_dict)
     set_attribute(self, "debug", 0, config_dict, int)
     # Default the period (between tickling our children) to 15
     # seconds.  Note:  This may be overriden for specific
     # applications.
     set_attribute(self, "period", 15, config_dict, int)
예제 #11
0
 def configure(self,config):
     CompositeNode.configure(self,config)
     set_attribute(self, 'port', 502, config, int)
     set_attribute(self, 'debug', 0, config, int)
     self.udp_port = self.port
     self.port = self #intercept any calls to the port
     return
예제 #12
0
 def configure(self, config):
     CompositeNode.configure(self, config)
     set_attribute(self, "debug", 0, config, as_boolean)
     set_attribute(self, "discover", "never", config, str)
     set_attribute(self, "discover_start", 0, config, int)
     set_attribute(self, "discover_stop", 255, config, int)
     debug = self.debug
예제 #13
0
파일: __init__.py 프로젝트: mcruse/monotone
 def configure(self, config):
     CompositeNode.configure(self,config)
     set_attribute(self, 'id', 0, config, str)
     set_attribute(self,'cache_life',30,config,float)
     set_attribute(self,'timeout',10,config,float)
     set_attribute(self,'patience',1,config,float)
     self.port = self.parent
예제 #14
0
파일: tsws.py 프로젝트: mcruse/monotone
 def stop(self):
     try:
         self._interface_node.stop()
     except:
         msglog.log('tsws',msglog.types.ERR,'tsws failed to stop interface node')
     self._interface_node = None
     CompositeNode.stop(self)
예제 #15
0
파일: device.py 프로젝트: mcruse/monotone
 def configure(self, config):
     CompositeNode.configure(self, config)
     set_attribute(self,'debug', debug, config, as_boolean)
     set_attribute(self,'post',REQUIRED,config, str)
     set_attribute(self,'server',REQUIRED, config, str)
     set_attribute(self,'action',REQUIRED, config, str)
     set_attribute(self,'ttl',1.0, config, float)
예제 #16
0
 def __init__(self):
     CompositeNode.__init__(self)
     self._pdo_lock = Lock()
     self._pdo = None
     self.__running = False
     self.debug = 0
     return
예제 #17
0
파일: __init__.py 프로젝트: mcruse/monotone
 def start( self ):
     CompositeNode.start( self )
     if not self.isStarted:
         self.isStarted = 1
         self._schedule(.15)
     else:
         raise EAlreadyRunning
예제 #18
0
 def configure(self,config):
     if self.debug:
         msglog.log('EnergywiseManager:', msglog.types.INFO,
                    'Inside configure' )
     CompositeNode.configure(self, config)
     set_attribute(self, 'debug', 0, config, int)
     return
예제 #19
0
 def configure(self, config):
     CompositeNode.configure(self, config)
     set_attribute(self, "timeout", 1.0, config, float)
     set_attribute(self, "debug", 0, config, int)
     self.port = self.parent
     if not self.port.is_open():
         self.port.open()
예제 #20
0
파일: __init__.py 프로젝트: mcruse/monotone
    def children_nodes(self):
        children = CompositeNode.children_nodes(self)

        stats = get_c_stat_names()

        # remove all nodes that do not have a stat
        nodeNameList = []
        for c in children:
            if c.name not in stats:
                c.prune()
            else:
                nodeNameList.append( c.name)
        
        # add all stats to node tree (unless already there)
        for stat in stats:
            if stat not in nodeNameList:
                n = CStatNode(stat)
                cd = { 'name'   : stat,
                       'parent' : self,
                       'log_on_change': -1,
                       'time_last_changed': ''}
                
                n.configure( cd)

        return CompositeNode.children_nodes(self)
예제 #21
0
파일: device.py 프로젝트: mcruse/monotone
 def configure(self, config):
     CompositeNode.configure(self, config)
     set_attribute(self, 'debug', debug, config, as_boolean)
     set_attribute(self,'device_name',REQUIRED,config, str)
     set_attribute(self,'unit_number',REQUIRED, config, int)
     set_attribute(self,'controller_type',None, config, str)
     set_attribute(self,'controller_version',None, config, str)
예제 #22
0
 def configure(self, cd):
     CompositeNode.configure(self, cd)
     set_attribute(self, 'source',self.source, cd, str)
     set_attribute(self, 'device_link', None, cd, str) #url of Devices node
     set_attribute(self, 'discover_mode', self.discover_mode, cd, str)
     set_attribute(self, '__node_id__',self._node_id, cd, str)
     set_attribute(self, 'bacnet_datatype', 'real', cd, str)
예제 #23
0
파일: node.py 프로젝트: mcruse/monotone
 def configure(self, config):
     CompositeNode.configure(self, config)
     # get handle to ARM in arm.py.  
     # self.coprocessor is the surrogate parent this child.
     # 
     set_attributes(self, (('id',REQUIRED),('coprocessor',REQUIRED)), config)
     self._coprocessor = self.coprocessor._coprocessor # the moab megatron ARM object
 def test_configure_sequence(self):
     p = PeriodicLog()
     p.configure({'name':'log','parent':None, 'period':1})
     h = CompositeNode()
     h.configure({'name':'columns','parent':p})
     c = PeriodicAverageColumn()
     c.configure({'position':0, 'name':'2', 'parent':h,
                  'function':self._next})
     p.start()
     try:
         l = []
         v = []
         for i in range(0,100):
             l.append(c._evaluate())
             v.append(i-0.5)
         if l.pop(0) != None:
             raise 'First delta not None.'
         v.pop(0)
         for i in l:
             j = v.pop(0)
             if i != j:
                 raise 'Incorrect average of %s should be %s.' % (i, j)
     finally:
         p.stop()
     return
예제 #25
0
파일: usap.py 프로젝트: mcruse/monotone
    def start(self):
        if self.parent.room == 1:
            msglog.log('USAP', INFO, 'Object:start() - %s --> %s --> %s' % (self.parent.parent.name, self.parent.name, self.name))
            self.path = string.join([self.parent.name, self.name], '.')
            self.lh = self.parent.parent.lh
            self.request_obj = self.parent.parent.request_obj
            self.response_obj = self.parent.parent.response_obj
            self.unison_v1_9_0_or_prior = self.parent.parent.unison_v1_9_0_or_prior
        else:
            msglog.log('USAP', INFO, 'Object:start() - %s --> %s --> %s --> %s' % (self.parent.parent.parent.name, self.parent.parent.name, self.parent.name, self.name))
            self.path = string.join([self.parent.parent.name, \
                                     self.parent.name, self.name], '.')
            self.lh = self.parent.parent.parent.lh
            self.request_obj = self.parent.parent.parent.request_obj
            self.response_obj = self.parent.parent.parent.response_obj
            self.unison_v1_9_0_or_prior = self.parent.parent.parent.unison_v1_9_0_or_prior

        # Find the relevant protocol child objects ahead of time to
        # be more efficient.
        self.req_startCode_obj = self.request_obj.findChildByName("startCode")
        self.req_vData_obj = self.request_obj.findChildByName("vData")
        self.req_crc_obj = self.request_obj.findChildByName("crc")
        #
        self.resp_startCode_obj = self.response_obj.findChildByName("startCode")
        self.resp_vData_obj = self.response_obj.findChildByName("vData")
        self.resp_crc_obj = self.response_obj.findChildByName("crc")
        #
        CompositeNode.start(self)
예제 #26
0
 def __init__(self):
     CompositeNode.__init__(self)
     self.running = 0
     self.line_handler = None
     self._pnts_map = {}
     self.debug_lvl = 0 # should be valid immediately after ctor, NOT just after configure()
     self.__status = None
예제 #27
0
    def start(self):
        if self.__running:
            return
        if self.debug:
            msglog.log('EnergywiseManager :', msglog.types.INFO, 'Inside start' )
        CompositeNode.start(self)
#        start_node = as_node('/services/EnergywiseManager/')
#        self.configure_trend_in_switches(start_node, 60)
        self.__running = True
        self._pdo_lock.acquire()
        self._pdo = PersistentDataObject(self, dmtype=GC_NEVER)
        self._pdo.trends = {}
        self._pdo.load()
        self._pdo_lock.release()
        if self.has_child('trends'):
            self.trends = self.get_child('trends')
        else:
            self.trends = CompositeNode()
            self.trends.configure({'parent':self, 'name':'trends'})
            self.trends.start()
        # start trending for saved domains
        for domain,freq in self._pdo.trends.items():
            try:
                start_node = as_node(domain)
               # self.configure_trend_in_switches( start_node,freq )
                start_node.new_trend(freq)
            except:
                self.delete_trend_configuration(domain)
        return
예제 #28
0
파일: tsws.py 프로젝트: mcruse/monotone
 def start(self):
     CompositeNode.start(self)
     self._set_zip_file()
     tread = Thread(name="AutoDiscovery",target=self.kick_start_discovery)
     scheduler.after(2, tread.start)
     self.ad = AutoDiscovery()
     self.ad.configure({"parent":self,"name":"AutoDiscover"})
예제 #29
0
 def start(self):
     self.device_map = {}
     if self.debug: print 'Start modbus serial slave node'
     CompositeNode.start(self)
     self.subnet.start()
     if self.debug: print 'modbus serial slave node started'
     return
예제 #30
0
파일: aerocomm.py 프로젝트: mcruse/monotone
 def __init__(self):
     self._running = 0
     self.driver = None
     self.mac_address = None
     self.discovery_mode = 'None'
     CompositeNode.__init__(self)
     AutoDiscoveredNode.__init__(self)
     EventProducerMixin.__init__(self)
     self.device_map = {} #keyed by mac address of clients; value=Child node
     self._out_q = [] #request queue
     self._out_q_cv = threading.Condition()
     self._mutex = threading.Lock() #prevent multiple access to outbound commands
     self._registered_clients = {}
     self.transceiver_state = TransceiverState[0]
     self.cov = ChangeOfValueEvent(self, None, self.transceiver_state)
     self.debug = debug
     self.timeout = 10 #seconds
     self.who_is_interval = 10 #seconds
     self.default_discovered_protocol_module = None
     # @todo
     # initailize this through configuration
     self.default_discovered_protocol_module = feu
     self.transceiver_state = 0
     self.relay_node = '/interfaces/relay1'  #this is temporary, should be None
     self.active_devices = {}
     self.status = None
예제 #31
0
 def __init__(self):
     CompositeNode.__init__(self)
     EventConsumerMixin.__init__(self, self._cov_event_handler)
     self._smid = None
     self._last_value = None
     self.link = None  #url of bacnet schedule object
     self.source = 'broadway'  #or 'bacnet'
     self._bacnet_datatype = 'auto'
     pass
예제 #32
0
 def configure(self, config):
     CompositeNode.configure(self, config)
     set_attribute(self, 'enabled', 1, config, int)
     set_attribute(self, 'bbmd_table', [], config)
     set_attribute(self, 'allow_external_table_editor', 1, config, int)
     self.debug = 0
     if self.debug:
         print 'configure bbmd'
         print str(config)
예제 #33
0
파일: ppp.py 프로젝트: ed-aicradle/monotone
 def __init__(self, log_id):
     CompositeNode.__init__(self)
     ConnectionMixin.__init__(self)
     EventProducerMixin.__init__(self)
     self.critical_data = self._CriticalData()
     self._log_id = log_id
     self._service_name = None
     self._device = None
     self._port = None
예제 #34
0
 def configure(self, config):
     self._pdo = PersistentDataObject(self)
     self._pdo.stats_dict = {
     }  #used to detect changes to xml files based on timestamp. Tuple (modify time, pickle string)
     self._pdo.load()
     # write_priority can be set for the entire control service, though
     # it may be specialized at the individual application node level.
     set_attribute(self, 'write_priority', 9, config, int)
     CompositeNode.configure(self, config)
예제 #35
0
 def start(self):
     if self._running == 0:
         self._running = 1
         for event_class in self._event_handlers.keys():
             self.parent.event_subscribe(self, event_class)
     else:
         msglog.log('broadway', msglog.types.WARN, \
                    'Instance of %s is already running.' % str(self.__class__))
     CompositeNode.start(self)
예제 #36
0
 def __init__(self, cache, name, rgvm, args):
     CompositeNode.__init__(self)
     self.parent = cache.ion()
     self.name = name
     self._cache = cache
     file = 'mpx.ion.capstone.micro_turbine.personality.RO_CommandCache.CommandION.__init__'
     self._compiled_reference = compile(rgvm, file, 'eval')
     self._rgvm_args = args
     self.parent._add_child(self)
예제 #37
0
 def __init__(self):
     CompositeNode.__init__(self)
     self.running = 0
     self.discover = 0
     self.line_handler = None
     self._pnts_map = {}
     self.debug_lvl = 0  #16383 # should be valid immediately after ctor, NOT just after configure()
     self.__status = None
     self.connection_type = 'rs-485'
예제 #38
0
    def configure(self, config):
        CompositeNode.configure(self, config)
        set_attribute(self, 'dev', REQUIRED, config)
        set_attribute(self, 'parity', parity_to_int('none'), config,
                      parity_to_int)
        set_attribute(self, 'baud', 9600, config, str)
        if self.baud == 'Custom':
            self.baud = -1  # flag for later processing of custom_baud
        else:
            self.baud = int(self.baud)  # normal path
        set_attributes(self, (('bits', 8), ('stop_bits', 1), ('debug', 0),
                              ('dump_cpl', 16)), config, int)
        set_attribute(self, 'custom_baud', 76800, config, int)
        set_attribute(self, 'flow_control', flowctl_to_int('none'), config,
                      flowctl_to_int)
        set_attribute(self, 'lock_directory', properties.get('VAR_LOCK'),
                      config, str)

        set_attribute(self, 'VINTR', '\x03', config, str)
        set_attribute(self, 'VQUIT', '\x1c', config, str)
        set_attribute(self, 'VERASE', '\x7f', config, str)
        set_attribute(self, 'VKILL', '\x15', config, str)
        set_attribute(self, 'VEOF', '\x04', config, str)
        set_attribute(self, 'VTIME', 0, config, int)
        set_attribute(self, 'VMIN', 1, config, int)
        set_attribute(self, 'VSWTC', '\x00', config, str)
        set_attribute(self, 'VSTART', '\x11', config, str)
        set_attribute(self, 'VSTOP', '\x13', config, str)
        set_attribute(self, 'VSUSP', '\x1a', config, str)
        set_attribute(self, 'VEOL', '\x00', config, str)
        set_attribute(self, 'VREPRINT', '\x12', config, str)
        set_attribute(self, 'VDISCARD', '\x0f', config, str)
        set_attribute(self, 'VWERASE', '\x17', config, str)
        set_attribute(self, 'VLNEXT', '\x16', config, str)
        set_attribute(self, 'VEOL2', '\x00', config, str)
        set_attribute(self, 'cc17', '\x00', config, str)
        set_attribute(self, 'cc18', '/', config, str)
        set_attribute(self, 'cc19', '\x00', config, str)
        set_attribute(self, 'cc20', '\x00', config, str)
        set_attribute(self, 'cc21', '\x00', config, str)
        set_attribute(self, 'cc22', '\x00', config, str)
        set_attribute(self, 'cc23', '\x00', config, str)
        set_attribute(self, 'cc24', '\x00', config, str)
        set_attribute(self, 'cc25', '\x00', config, str)
        set_attribute(self, 'cc26', '\x00', config, str)
        set_attribute(self, 'cc27', '\x00', config, str)
        set_attribute(self, 'cc28', '\x00', config, str)
        set_attribute(self, 'cc29', '\x00', config, str)
        set_attribute(self, 'cc30', '\x00', config, str)
        set_attribute(self, 'cc31', '\x00', config, str)

        self._devlock = DeviceLock(self.dev, self.lock_directory)

        if self.is_open():
            self._set_serial()
        return
예제 #39
0
 def configure( self, config_dict ):     
     CompositeNode.configure( self, config_dict )
     set_attribute( self, 'enabled', 0, config_dict, int )
     set_attribute( self, 'debug', self.debug, config_dict, int )
     set_attribute( self, 'period', self.period, config_dict, int )
     set_attribute( self, 'fast_adjust_threshold', self.fast_adjust_threshold, config_dict, int )
     set_attribute( self, 'adjust_threshold', self.adjust_threshold, config_dict, int )
     set_attribute( self, 'nudge_amount', self.nudge_amount, config_dict, int )
     set_attribute( self, 'bcu_date', REQUIRED, config_dict )
     set_attribute( self, 'bcu_time', REQUIRED, config_dict )
예제 #40
0
 def start(self):
     # all known relevant calculators are presently imported to this name space from xconvert.
     # NameError raised if there's issue.
     self.group_id = _get_group_id(self)
     self.addr = _get_addr(self)
     self.timeout = _get_timeout(self)
     self.cache = _get_cache(self)
     self.ion = self.parent
     self.translator = ConversionFactory(self.cls_name, self)
     CompositeNode.start(self)
예제 #41
0
 def configure(self, config):
     #
     # log_error_value and log_error_type are used by logs that invoke
     # functions to there value and may throw an exception.  This provides
     # a default for all columns.
     #
     set_attribute(self, 'log_error_value', 'None', config)
     set_attribute(self, 'log_error_type', 'eval', config)
     CompositeNode.configure(self, config)
     return
예제 #42
0
 def configure(self, cd):
     CompositeNode.configure(self, cd)
     self.line_handler = self.parent
     set_attribute(self, 'turbine', REQUIRED, cd, int)
     set_attribute(self, 'password', None, cd)
     if not self._configured_caches:
         self._create_alldat_cache()
         self._create_single_children()
         self._create_lmdata_cache()
         self._configured_caches = 1
예제 #43
0
 def start(self):
     if self.is_remote():
         e_prop = EntityProp(name='Entity',
                             type='Entity',
                             label='',
                             description='',
                             url=self.display,
                             entity=as_entity_url(self))
         self._properties = [e_prop.as_dict()]
     CompositeNode.start(self)
예제 #44
0
 def __init__(self, dev_node, ckt_svc_nodes=None):
     CompositeNode.__init__(self)
     if ckt_svc_nodes is None:
         ckt_svc_nodes = []
     self._ckt_svc_nodes = ckt_svc_nodes
     self._status_nodes = []
     self.running = 0
     self._dev_node = dev_node
     self._reqs = []
     return
예제 #45
0
 def __init__(self):
     CompositeNode.__init__(self)
     self._cpc_uhp_node = None
     self._cases = []
     self._racks = []
     self.running = 0
     self._start_thread_inst = None
     self._ready = 0
     self.debug_lvl = 1
     return
예제 #46
0
 def __init__(self, ckt_dev_node):
     CompositeNode.__init__(self)
     self._alm_status_nodes = []
     self._defr_status_nodes = []
     self.running = 0
     self._ckt_dev_node = ckt_dev_node
     self._alarms = []
     self._alm_reqs = []
     self._defr_reqs = []
     return
예제 #47
0
 def start(self):
     self.device_map = {}
     if self.debug: print 'Start modbus tcpip server node'
     if self.parent.__class__ == IP:  #then must be an 'internet_protocol' node (1.3)
         self.ip = self.parent.address
     else:  #must be directly under the eth# port (1.4)
         self.ip = ip_address(self.parent.name)
     self.server = TcpServerConnection(self.ip, self.udp_port, self)
     CompositeNode.start(self)
     if self.debug: print 'modbus tcpip server node started'
예제 #48
0
 def __init__( self ):
     CompositeNode.__init__( self )
     EventProducerMixin.__init__( self )
     #
     self.mount_point = None
     self.debug = None
     #
     # Set old value to something which will never be valid so that
     # we always generate an event on startup.
     self.old_value = -99
예제 #49
0
 def __init__(self):
     self._last_rcvd = 0
     self._subscribers = 0
     self._scheduled = None
     self._skip_cache = False
     self._cached_result = None
     self._exec_delay = _Buffer(5)
     self._subscription_lock = Lock()
     CompositeNode.__init__(self)
     EventProducerMixin.__init__(self)
예제 #50
0
 def configure(self, config):
     CompositeNode.configure(self, config)
     set_attribute(self, 'debug', debug, config, int)
     #
     #
     if debug: self.debug = debug
     #
     #
     self.port = self  #intercept any calls to the port
     return
예제 #51
0
 def start(self):
     if not self._threadpool:
         port_name = self.parent.name
         self._threadpool = thread_pool.ThreadPool(
             1, name='Sensorsoft ThreadPool-' + port_name)
     if not self._port or not self._port.is_open():
         self._port = self.parent
         self._port.open()
         self._port.drain()
     CompositeNode.start(self)
예제 #52
0
 def __init__(self, lib_device=None, discovered=None):
     CompositeNode.__init__(self)
     self.__node_id__ = '1254'
     self.running = 0
     self.device_name = None
     self.discovered = discovered
     self.tcstype = None
     if lib_device:
         if debug: print 'TCS device type= ', str(lib_device.type)
         self.tcstype = str(lib_device.type)
예제 #53
0
 def configure(self, cd):
     CompositeNode.configure(self, cd)
     try:
         log_on_change = get_c_stat_log_on_change(self.c_stat_name)
     except:
         # If this happens, it is probably because the stat disappeared
         self.log_stat_disappeared()
         return None
     set_attribute(self, 'log_on_change', log_on_change, cd, int)
     set_attribute(self, 'time_last_changed', ctime(0), cd, str)
예제 #54
0
 def configure(self, config):
     if self.debug: print 'Configure modbus point'
     CompositeNode.configure(self, config)
     set_attribute(self, 'register', REQUIRED, config, int)
     self.offset = self.register - self.base_register()
     set_attribute(self, 'read_only', 1, config, int)
     set_attribute(self, 'debug', 1, config, int)
     set_attribute(self, 'length', 1, config, int)
     ProxyAbstractClass.configure(self, config)
     if self.debug: print 'Configured modbus point', self
예제 #55
0
 def stop(self):
     self._running = 0
     ##
     # @todo Remove auto-created nodes (eg logger, aeroserver, etc.),
     # to prevent "Already Exists" errors at next call on start(). OR
     # simply check for node pre-existence during start. Reconfig if
     # nodes already exist.
     #
     CompositeNode.stop(self)
     return
예제 #56
0
 def __init__(self):
     self._threadpool = None
     self._init_complete = False
     self._port = None
     self._request = {}  # k:(rqst_type, addr,) v: request object
     self.__update_freqs = {}
     self.__callbacks = {}
     self.__callback_lock = threading.Lock()
     self.__port_lock = threading.Lock()
     CompositeNode.__init__(self)
예제 #57
0
파일: avr.py 프로젝트: ed-aicradle/monotone
    def configure(self, config):
        CompositeNode.configure(self, config)
        set_attribute(self, 'ncounters', REQUIRED, config, int)
        set_attribute(self, 'nDIs', REQUIRED, config, int)
        set_attribute(self, 'nrelays', REQUIRED, config, int)
        set_attribute(self, 'ndallas_busses', REQUIRED, config, int)
        set_attribute(self, 'nGPIOs', REQUIRED, config, int)

        # Open the avr devices.
        self.avr = None
        self.avroob = None
        try:
            self.avr = open("/dev/avr", "r+")
            self.avroob = open("/dev/avroob", "r")
            self.p = select.poll()
            self.p.register(self.avroob, select.POLLIN)
            avr_maj_ver = ord(self.invoke_message('\x17\x00\x00')[0])
            if (avr_maj_ver < 2) and (self.nGPIOs > 0):
                self.nGPIOs = 0
                msglog.log('mpx',msglog.types.ERR,'No GPIOs created; AVR version is %s; should be 2.x or greater.' \
                           % self.version())
            # Attach the counters, relays and dallas busses to the AVR.
            config_list = (('mpx.ion.host.avr.counter', 'counter',
                            self.ncounters), ('mpx.ion.host.avr.di', 'DI',
                                              self.nDIs),
                           ('mpx.ion.host.avr.relay', 'relay', self.nrelays),
                           ('mpx.ion.host.avr.dallasbus', 'dallas',
                            self.ndallas_busses), ('mpx.ion.host.avr.gpio',
                                                   'gpio', self.nGPIOs))
            for module, prefix, count in config_list:
                for i in range(1, count + 1):
                    name = prefix + str(i)
                    config = {
                        'name': name,
                        'id': i,
                        'avr': self,
                        'parent': self
                    }
                    ion = mpx.lib.factory(module)
                    ion.configure(config)
        except:
            msglog.log('broadway', msglog.types.ERR,
                       "Failed to open avr device.")
            msglog.exception()
            self.p = select.poll()
            if self.avr:
                self.avr.close()
                self.avr = None
            if self.avroob:
                self.avroob.close()
                self.avroob = None
            pass

        return
예제 #58
0
 def start(self):
     CompositeNode.start(self)
     for i in range(0,4):
         label = getattr(self,'label%s' % (i+1,))
         point = getattr(self,'point%s' % (i+1,))
         if point:
             node = as_node(point)
         else:
             node = None
         self._channels.append(_Channel(i,self.id,label,node))
     return
예제 #59
0
 def configure(self,config):
     self.timeout = 1.0
     CompositeNode.configure(self,config)
     set_attribute(self, 'ip', REQUIRED, config)
     set_attribute(self, 'port', 502, config, int)
     self.udp_port = int(self.port)
     set_attribute(self, 'debug', 0, config, int)
     set_attribute(self, 'retries', 3, config, int)
     set_attribute(self, 'report_timeouts', 1, config, int)
     self.port = self #intercept any calls to the port
     return
예제 #60
0
 def start(self):
     if self.interval_calculation == self.CHARACTER_TIME:
         self.__silent_interval = (self.silent_interval_characters *
                                   self.port.seconds_per_character())
     elif self.interval_calculation == self.ABSOLUTE:
         self.__silent_interval = self.silent_interval_absolute
     else:
         raise EInvalidValue('interval_calculation',
                             self.interval_calculation)
     CompositeNode.start(self)
     return