예제 #1
0
파일: bacnet.py 프로젝트: zbeech/volttron
    def setup_device(self,
                     address,
                     max_apdu_len=1024,
                     seg_supported='segmentedBoth',
                     obj_id=599,
                     obj_name='sMap BACnet driver',
                     ven_id=15):

        global this_application

        #We use a singleton device
        if this_application is not None:
            return

        print 'seg_supported', seg_supported
        print 'max_apdu_len', max_apdu_len
        print 'obj_id', obj_id
        print 'obj_name', obj_name
        print 'ven_id', ven_id

        #Check to see if they gave a valid apdu length.
        if encode_max_apdu_response(max_apdu_len) is None:
            raise ValueError(
                'Invalid max_apdu_len: Valid options are 50, 128, 206, 480, 1024, and 1476'
            )

        this_device = LocalDeviceObject(
            objectName=obj_name,
            objectIdentifier=obj_id,
            maxApduLengthAccepted=max_apdu_len,
            segmentationSupported=seg_supported,
            vendorIdentifier=ven_id,
        )

        # build a bit string that knows about the bit names and leave it empty. We respond to NOTHING.
        pss = ServicesSupported()

        # set the property value to be just the bits
        this_device.protocolServicesSupported = pss.value

        this_application = BACnet_application(this_device, address)

        #We must use traditional python threads, otherwise the driver will
        # hang during startup while trying to scrape actuator values.
        # I think this is because the reactor hasn't started before we start trying
        # to use the other threads.
        #reactor.callInThread(bacpypes.core.run)
        #reactor.addSystemEventTrigger("before", "shutdown", bacpypes.core.stop)

        server_thread = threading.Thread(target=bacpypes.core.run)

        # exit the BACnet App thread when the main thread terminates
        server_thread.daemon = True
        server_thread.start()
예제 #2
0
    def setup_device(self,
                     async_call,
                     address,
                     max_apdu_len=1024,
                     seg_supported='segmentedBoth',
                     obj_id=599,
                     obj_name='sMap BACnet driver',
                     ven_id=15):

        _log.info('seg_supported ' + str(seg_supported))
        _log.info('max_apdu_len ' + str(max_apdu_len))
        _log.info('obj_id ' + str(obj_id))
        _log.info('obj_name ' + str(obj_name))
        _log.info('ven_id ' + str(ven_id))

        #Check to see if they gave a valid apdu length.
        if encode_max_apdu_response(max_apdu_len) is None:
            raise ValueError(
                'Invalid max_apdu_len: {} Valid options are 50, 128, 206, 480, 1024, and 1476'
                .format(max_apdu_len))

        this_device = LocalDeviceObject(
            objectName=obj_name,
            objectIdentifier=obj_id,
            maxApduLengthAccepted=max_apdu_len,
            segmentationSupported=seg_supported,
            vendorIdentifier=ven_id,
        )

        # build a bit string that knows about the bit names.
        pss = ServicesSupported()
        pss['whoIs'] = 1
        pss['iAm'] = 1

        # set the property value to be just the bits
        this_device.protocolServicesSupported = pss.value

        def i_am_callback(address, device_id, max_apdu_len, seg_supported,
                          vendor_id):
            async_call.send(None, self.i_am, address, device_id, max_apdu_len,
                            seg_supported, vendor_id)

        #i_am_callback('foo', 'bar', 'baz', 'foobar', 'foobaz')

        self.this_application = BACnet_application(i_am_callback, this_device,
                                                   address)

        server_thread = threading.Thread(target=bacpypes.core.run)

        # exit the BACnet App thread when the main thread terminates
        server_thread.daemon = True
        server_thread.start()
예제 #3
0
파일: bacnet.py 프로젝트: NREL/volttron
 def setup_device(self, address, 
                  max_apdu_len=1024, seg_supported='segmentedBoth', 
                  obj_id=599, obj_name='sMap BACnet driver', 
                  ven_id=15): 
     
     global this_application 
     
     #We use a singleton device
     if this_application is not None:
         return
     
     print 'seg_supported', seg_supported
     print 'max_apdu_len', max_apdu_len
     print 'obj_id', obj_id
     print 'obj_name', obj_name
     print 'ven_id', ven_id
     
     #Check to see if they gave a valid apdu length.
     if encode_max_apdu_response(max_apdu_len) is None:
         raise ValueError('Invalid max_apdu_len: Valid options are 50, 128, 206, 480, 1024, and 1476')
     
     this_device = LocalDeviceObject(
         objectName=obj_name,
         objectIdentifier=obj_id,
         maxApduLengthAccepted=max_apdu_len,
         segmentationSupported=seg_supported,
         vendorIdentifier=ven_id,
         )
     
     # build a bit string that knows about the bit names and leave it empty. We respond to NOTHING.
     pss = ServicesSupported()
 
     # set the property value to be just the bits
     this_device.protocolServicesSupported = pss.value
     
     this_application = BACnet_application(this_device, address)
     
     #We must use traditional python threads, otherwise the driver will
     # hang during startup while trying to scrape actuator values.
     # I think this is because the reactor hasn't started before we start trying
     # to use the other threads.
     #reactor.callInThread(bacpypes.core.run)
     #reactor.addSystemEventTrigger("before", "shutdown", bacpypes.core.stop)
     
     server_thread = threading.Thread(target=bacpypes.core.run)
 
     # exit the BACnet App thread when the main thread terminates
     server_thread.daemon = True
     server_thread.start()
예제 #4
0
파일: agent.py 프로젝트: carlatpnl/volttron
    def setup_device(self, async_call, address,
                     max_apdu_len=1024, 
                     seg_supported='segmentedBoth', 
                     obj_id=599, 
                     obj_name='sMap BACnet driver', 
                     ven_id=15): 
                    
        _log.info('seg_supported '+str(seg_supported))
        _log.info('max_apdu_len '+str(max_apdu_len))
        _log.info('obj_id '+str(obj_id))
        _log.info('obj_name '+str(obj_name))
        _log.info('ven_id '+str(ven_id))


        
        #Check to see if they gave a valid apdu length.
        if encode_max_apdu_response(max_apdu_len) is None:
            raise ValueError('Invalid max_apdu_len: {} Valid options are 50, 128, 206, 480, 1024, and 1476'.format(max_apdu_len))
        
        this_device = LocalDeviceObject(
            objectName=obj_name,
            objectIdentifier=obj_id,
            maxApduLengthAccepted=max_apdu_len,
            segmentationSupported=seg_supported,
            vendorIdentifier=ven_id,
            )
        
        # build a bit string that knows about the bit names.
        pss = ServicesSupported()
        pss['whoIs'] = 1
        pss['iAm'] = 1
    
        # set the property value to be just the bits
        this_device.protocolServicesSupported = pss.value

        def i_am_callback(address, device_id, max_apdu_len, seg_supported, vendor_id):
            async_call.send(None, self.i_am, address, device_id, max_apdu_len, seg_supported, vendor_id)

        #i_am_callback('foo', 'bar', 'baz', 'foobar', 'foobaz')
        
        self.this_application = BACnet_application(i_am_callback, this_device, address)
      
        server_thread = threading.Thread(target=bacpypes.core.run)
    
        # exit the BACnet App thread when the main thread terminates
        server_thread.daemon = True
        server_thread.start()
예제 #5
0
파일: rough.py 프로젝트: miraabid/bemoss
    def setup_device(self,
                     address,
                     max_apdu_len=1024,
                     seg_supported='segmentedBoth',
                     obj_id=599,
                     obj_name='sMap BACnet driver',
                     ven_id=15):

        _log.info('seg_supported ' + str(seg_supported))
        _log.info('max_apdu_len ' + str(max_apdu_len))
        _log.info('obj_id ' + str(obj_id))
        _log.info('obj_name ' + str(obj_name))
        _log.info('ven_id ' + str(ven_id))

        # Check to see if they gave a valid apdu length.
        if encode_max_apdu_response(max_apdu_len) is None:
            raise ValueError(
                'Invalid max_apdu_len: {} Valid options are 50, 128, 206, 480, 1024, and 1476'
                .format(max_apdu_len))

        this_device = LocalDeviceObject(
            objectName=obj_name,
            objectIdentifier=obj_id,
            maxApduLengthAccepted=max_apdu_len,
            segmentationSupported=seg_supported,
            vendorIdentifier=ven_id,
        )

        # build a bit string that knows about the bit names and leave it empty. We respond to NOTHING.
        pss = ServicesSupported()

        # set the property value to be just the bits
        this_device.protocolServicesSupported = pss.value

        self.this_application = BACnet_application(this_device, address)

        server_thread = threading.Thread(target=bacpypes.core.run)

        # exit the BACnet App thread when the main thread terminates
        server_thread.daemon = True
        request = WhoIsRequest()
        request.pduDestination = GlobalBroadcast()
        server_thread.start()
예제 #6
0
 def setup_device(self, address, 
                  max_apdu_len=1024, 
                  seg_supported='segmentedBoth', 
                  obj_id=599, 
                  obj_name='sMap BACnet driver', 
                  ven_id=15): 
                 
     print 'seg_supported', seg_supported
     print 'max_apdu_len', max_apdu_len
     print 'obj_id', obj_id
     print 'obj_name', obj_name
     print 'ven_id', ven_id
     
     #Check to see if they gave a valid apdu length.
     if encode_max_apdu_response(max_apdu_len) is None:
         raise ValueError('Invalid max_apdu_len: Valid options are 50, 128, 206, 480, 1024, and 1476')
     
     this_device = LocalDeviceObject(
         objectName=obj_name,
         objectIdentifier=obj_id,
         maxApduLengthAccepted=max_apdu_len,
         segmentationSupported=seg_supported,
         vendorIdentifier=ven_id,
         )
     
     # build a bit string that knows about the bit names and leave it empty. We respond to NOTHING.
     pss = ServicesSupported()
 
     # set the property value to be just the bits
     this_device.protocolServicesSupported = pss.value
     
     self.this_application = BACnet_application(this_device, address)
   
     server_thread = threading.Thread(target=bacpypes.core.run)
 
     # exit the BACnet App thread when the main thread terminates
     server_thread.daemon = True
     server_thread.start()