Пример #1
0
    def __init__(self, localIPAddr='127.0.0.1',
                 localObjName='BAC0', DeviceId=None,
                 maxAPDULengthAccepted='1024', maxSegmentsAccepted='1024',
                 segmentationSupported='segmentedBoth',
                 bbmdAddress=None, bbmdTTL=0):

        self._log.debug("Configurating app")

        self.response = None
        self._initialized = False
        self._started = False
        self._stopped = False

        self.localIPAddr = localIPAddr
        
        self.Boid = int(DeviceId) if DeviceId else (
            3056177 + int(random.uniform(0, 1000)))

        self.segmentationSupported = segmentationSupported
        self.maxSegmentsAccepted = maxSegmentsAccepted
        self.localObjName = localObjName

        self.maxAPDULengthAccepted = maxAPDULengthAccepted
        self.vendorId = 842
        self.vendorName = CharacterString('SERVISYS inc.')
        self.modelName = CharacterString('BAC0 Scripting Tool')

        self.discoveredDevices = None
        self.systemStatus = DeviceStatus(1)

        self.bbmdAddress = bbmdAddress
        self.bbmdTTL = bbmdTTL

        self.startApp()
Пример #2
0
    def __init__(self, localIPAddr=None, localObjName='BAC0', Boid=None,
                 maxAPDULengthAccepted='1024', segmentationSupported='segmentedBoth'):
        """
        Initialization requires information about the local device
        Default values are localObjName = 'name', Boid = '2015',maxAPDULengthAccepted = '1024',segmentationSupported = 'segmentedBoth', vendorId = '842' )
        Local IP address must be given in a string.
        Normally, the address must be in the same subnet than the bacnet network (if no BBMD or Foreign device is used)
        Script doesn't support BBMD actually
        """
        log_debug("Configurating app")

        self.response = None
        self._initialized = False
        self._started = False
        self._stopped = False
        if localIPAddr:
            self.localIPAddr = localIPAddr
        else:
            self.localIPAddr = '127.0.0.1'
        self.segmentationSupported = segmentationSupported
        self.localObjName = localObjName
        if Boid:
            self.Boid = int(Boid)
        else:
            self.Boid = int('3056177') + int(random.uniform(0, 1000))
        self.maxAPDULengthAccepted = maxAPDULengthAccepted
        self.vendorId = '842'
        self.vendorName = CharacterString('SERVISYS inc.')
        self.modelName = CharacterString('BAC0 Scripting Tool')
        self.discoveredDevices = None
        self.ResponseQueue = Queue()
        self.systemStatus = DeviceStatus(1)

        self.startApp()
Пример #3
0
    def __init__(self,
                 local_ip,
                 local_object_name='PyScada',
                 device_id=None,
                 max_APDU_length_accepted='1024',
                 max_segments_accepted='1024',
                 segmentation_supported='segmentedBoth',
                 bbmd_address=None,
                 bbmd_TTL=0,
                 *args):

        if _debug: logger.debug("__init__ %r", args)
        self.this_device = None
        self.this_application = None

        self.local_ip = local_ip
        self.local_object_name = local_object_name
        self.boid = int(device_id) if device_id else (
            3056177 + int(random.uniform(0, 1000)))
        self.vendor_id = 0
        self.vendor_name = CharacterString('PyScada')
        self.model_name = CharacterString('BACnet DAQ Service')
        self.system_status = DeviceStatus(1)
        self.max_APDU_length_accepted = max_APDU_length_accepted
        self.max_segments_accepted = max_segments_accepted
        self.segmentation_supported = segmentation_supported
        self.bbmd_address = bbmd_address
        self.bbmd_TTL = bbmd_TTL
        self.t = None
Пример #4
0
    def __init__(
        self,
        localIPAddr="127.0.0.1",
        localObjName="BAC0",
        DeviceId=None,
        maxAPDULengthAccepted="1024",
        maxSegmentsAccepted="1024",
        segmentationSupported="segmentedBoth",
        bbmdAddress=None,
        bbmdTTL=0,
    ):

        self._log.debug("Configurating app")

        self.response = None
        self._initialized = False
        self._started = False
        self._stopped = False

        if localIPAddr in Base._used_ips:
            raise InitializationError(
                "IP Address provided ({}) already used.".format(localIPAddr))

        if validate_ip_address(localIPAddr):
            self.localIPAddr = localIPAddr
        else:
            raise InitializationError(
                "IP Address provided ({}) invalid.".format(localIPAddr))

        self.Boid = (int(DeviceId) if DeviceId else
                     (3056177 + int(random.uniform(0, 1000))))

        self.segmentationSupported = segmentationSupported
        self.maxSegmentsAccepted = maxSegmentsAccepted
        self.localObjName = localObjName

        self.maxAPDULengthAccepted = maxAPDULengthAccepted
        self.vendorId = 842
        self.vendorName = CharacterString("SERVISYS inc.")
        self.modelName = CharacterString("BAC0 Scripting Tool")

        self.discoveredDevices = None
        self.systemStatus = DeviceStatus(1)

        self.bbmdAddress = bbmdAddress
        self.bbmdTTL = bbmdTTL

        try:
            self.startApp()
        except InitializationError as error:
            raise InitializationError("Gros probleme : {}".format(error))
Пример #5
0
    def connect(self, bacnet_server):
        address = self._ip_address(bacnet_server)
        version = get_version()
        description = "nube-io bacnet server"
        self.ldo = LocalDeviceObject(
            objectName=bacnet_server.local_obj_name,
            objectIdentifier=int(bacnet_server.device_id),
            maxApduLengthAccepted=1024,
            segmentationSupported="segmentedBoth",
            vendorIdentifier=bacnet_server.vendor_id,
            firmwareRevision=CharacterString(version),
            modelName=CharacterString(bacnet_server.model_name),
            vendorName=CharacterString(bacnet_server.vendor_name),
            description=CharacterString(description),
            systemStatus=DeviceStatus(1),
            applicationSoftwareVersion=CharacterString(version),
            databaseRevision=0)

        self.__bacnet = BIPSimpleApplication(self.ldo, address)
        self.__bacnet.add_capability(ReadWritePropertyMultipleServices)
        self.sync_stack()
        FlaskThread(target=bacnet_run).start()  # start bacpypes thread
Пример #6
0
    def __init__(
        self,
        localIPAddr="127.0.0.1",
        localObjName="BAC0",
        deviceId=None,
        firmwareRevision="".join(sys.version.split("|")[:2]),
        maxAPDULengthAccepted="1024",
        maxSegmentsAccepted="1024",
        segmentationSupported="segmentedBoth",
        bbmdAddress=None,
        bbmdTTL=0,
        bdtable=None,
        modelName=CharacterString("BAC0 Scripting Tool"),
        vendorId=842,
        vendorName=CharacterString("SERVISYS inc."),
        description=CharacterString(
            "http://christiantremblay.github.io/BAC0/"),
    ):

        self._log.debug("Configurating app")

        if not _COMPLETE:
            self._log.debug(
                "To be able to run the web server, you must install pandas, bokeh, flask and flask_bootstrap"
            )
            self._log.debug(
                "Those are not all installed so BAC0 will work in Lite mode only."
            )

        self.response = None
        self._initialized = False
        self._started = False
        self._stopped = False

        if localIPAddr in Base._used_ips:
            raise InitializationError(
                "IP Address provided ({}) already used by BAC0. Check if another software is using port 47808 on this network interface. If so, you can define multiple IP per interface. Or specify another IP using BAC0.lite(ip='IP/mask')"
                .format(localIPAddr))

        if validate_ip_address(localIPAddr):
            self.localIPAddr = localIPAddr
        else:
            raise InitializationError(
                "IP Address provided ({}) invalid. Check if another software is using port 47808 on this network interface. If so, you can define multiple IP per interface. Or specify another IP using BAC0.lite(ip='IP/mask')"
                .format(localIPAddr))

        self.Boid = (int(deviceId) if deviceId else
                     (3056177 + int(random.uniform(0, 1000))))

        self.segmentationSupported = segmentationSupported
        self.maxSegmentsAccepted = maxSegmentsAccepted
        self.localObjName = localObjName
        self.local_objects = LocalObjects(device=self)

        self.maxAPDULengthAccepted = maxAPDULengthAccepted
        self.vendorId = vendorId
        self.vendorName = vendorName
        self.modelName = modelName
        self.description = description

        self.discoveredDevices = None
        self.systemStatus = DeviceStatus(1)

        self.bbmdAddress = bbmdAddress
        self.bbmdTTL = bbmdTTL
        self.bdtable = bdtable

        self.firmwareRevision = firmwareRevision
        self._ric = {}
        self.subscription_contexts = {}

        try:
            self.startApp()
        except InitializationError as error:
            raise InitializationError(
                "Gros probleme : {}. Address requested : {}".format(
                    error, localIPAddr))
Пример #7
0
    def __init__(
            self,
            localIPAddr="127.0.0.1",
            localObjName="BAC0",
            deviceId=None,
            firmwareRevision="".join(sys.version.split("|")[:2]),
            maxAPDULengthAccepted="1024",
            maxSegmentsAccepted="1024",
            segmentationSupported="segmentedBoth",
            bbmdAddress=None,
            bbmdTTL=0,
            modelName=CharacterString("BAC0 Scripting Tool"),
            vendorId=842,
            vendorName=CharacterString("SERVISYS inc."),
    ):

        self._log.debug("Configurating app")

        if not _COMPLETE:
            self._log.debug(
                "To be able to run the web server, you must install pandas, bokeh, flask and flask_bootstrap"
            )
            self._log.debug(
                "Those are not all installed so BAC0 will work in Lite mode only."
            )

        self.response = None
        self._initialized = False
        self._started = False
        self._stopped = False

        if localIPAddr in Base._used_ips:
            raise InitializationError(
                "IP Address provided ({}) already used.".format(localIPAddr))

        if validate_ip_address(localIPAddr):
            self.localIPAddr = localIPAddr
        else:
            raise InitializationError(
                "IP Address provided ({}) invalid.".format(localIPAddr))

        self.Boid = (int(deviceId) if deviceId else
                     (3056177 + int(random.uniform(0, 1000))))

        self.segmentationSupported = segmentationSupported
        self.maxSegmentsAccepted = maxSegmentsAccepted
        self.localObjName = localObjName

        self.maxAPDULengthAccepted = maxAPDULengthAccepted
        self.vendorId = vendorId
        self.vendorName = vendorName
        self.modelName = modelName

        self.discoveredDevices = None
        self.systemStatus = DeviceStatus(1)

        self.bbmdAddress = bbmdAddress
        self.bbmdTTL = bbmdTTL

        self.firmwareRevision = firmwareRevision

        try:
            self.startApp()
        except InitializationError as error:
            raise InitializationError("Gros probleme : {}".format(error))