Exemple #1
0
    def setUp(self):
        logging.basicConfig(format='%(levelname)s:%(message)s',
                            level=logging.DEBUG)  # configure logging

        self.gp = gridpi_core.System()

        # configure asset models
        parser = ConfigParser()
        parser.read_dict({
            'FEEDER': {
                'class_name': 'VirtualFeeder',
                'name': 'feeder'
            },
            'ENERGY_STORAGE': {
                'class_name': 'VirtualEnergyStorage',
                'name': 'inverter'
            },
            'GRID_INTERTIE': {
                'class_name': 'VirtualGridIntertie',
                'name': 'grid'
            }
        })

        asset_factory = model_core.AssetFactory(
        )  # Create Asset Factory object
        for cfg in parser.sections(
        ):  # Add models to System, The asset factory acts on a configuration
            self.gp.add_asset(asset_factory.factory(parser[cfg]))
        del asset_factory

        self.db = SQLAlchemyGP.SQLAlchemyGP()
Exemple #2
0
    def setUp(self):
        self.test_system = gridpi_core.System(
        )  # Create System container object

        # configure processes
        parser = ConfigParser()
        parser.read_dict({
            'process_1': {
                'class_name': 'EssUpdateStatus'
            },
            'process_2': {
                'class_name': 'GridUpdateStatus'
            },
            'process_3': {
                'class_name': 'EssSocPowerController',
                'inverter_target_soc': 0.6
            },
            'process_4': {
                'class_name': 'EssDemandLimitPowerController',
                'grid_kw_import_limit': 20,
                'grid_kw_export_limit': 20
            },
            'process_5': {
                'class_name': 'EssWriteControl'
            }
        })
        process_factory = process_core.ProcessFactory()
        for cfg in parser.sections():
            self.test_system.add_process(process_factory.factory(parser[cfg]))
        del process_factory
Exemple #3
0
    def setUp(self):
        logging.basicConfig(format='%(levelname)s:%(message)s',
                            level=logging.DEBUG)  # configure logging

        self.gp = gridpi_core.System()

        # configure asset models
        parser = ConfigParser()
        parser.read_dict({
            'FEEDER': {
                'class_name': 'VirtualFeeder',
                'name': 'feeder'
            },
            'ENERGY_STORAGE': {
                'class_name': 'VirtualEnergyStorage',
                'name': 'inverter'
            },
            'GRID_INTERTIE': {
                'class_name': 'VirtualGridIntertie',
                'name': 'grid'
            }
        })

        asset_factory = model_core.AssetFactory(
        )  # Create Asset Factory object
        for cfg in parser.sections(
        ):  # Add models to System, The asset factory acts on a configuration
            self.gp.add_asset(asset_factory.factory(parser[cfg]))
        del asset_factory

        # configure persistence model
        parser.clear()
        parser.read_dict({
            'PERSISTENCE': {
                'class_name': 'DBSQLite3',
                'local_path': '/database/GridPi.sqlite',
                'empty_database_on_start': 1
            }
        })
        persistence_factory = persistence_core.PersistenceFactory()
        for cfg in parser.sections():
            self.db = persistence_factory.factory(parser[cfg])
        del persistence_factory

        asset_refs = [x for x in self.gp.assets]

        for asset in asset_refs:
            params = [p for p in asset.status.keys()]
            self.db.addGroup(asset.config['name'], *params)
Exemple #4
0
def main(*args, **kwargs):
    """ Initalize System object.
        Create the system object. Load system assets, modules, and tagbus. Register the parameters of each asset with the
        tagbus object.
    """
    gp = gridpi_core.System()  # Create System container object
    vs = virtual_system.Virtual_System(
        gp.state_machine, gp.asset_container)  # virtual system for testing

    # read asset config.ini
    bootstrap_parser = kwargs['bootstrap']
    parser = ConfigParser()
    parser.read(bootstrap_parser['BOOTSTRAP']['asset_cfg_local_path'])
    asset_factory = model_core.AssetFactory()  # Create Asset Factory object
    for cfg in parser.sections():
        gp.add_asset(asset_factory.factory(parser[cfg], virtual_system=vs))
    del asset_factory

    # read process config.ini
    parser.clear()
    parser.read(bootstrap_parser['BOOTSTRAP']['process_cfg_local_path'])
    process_factory = process_core.ProcessFactory()
    for cfg in parser.sections():
        gp.add_process(process_factory.factory(parser[cfg]))
    del process_factory

    # read persistent storage config.ini
    parser.clear()
    parser.read(bootstrap_parser['BOOTSTRAP']['persistence_cfg_local_path'])
    persistence_factory = persistence_core.PersistenceFactory()
    for cfg in parser.sections():
        db = persistence_factory.factory(parser[cfg])
    del persistence_factory
    del bootstrap_parser
    del parser

    gp.process_container.sort()  # Sort the process tags by dependency

    loop = asyncio.get_event_loop()  # Get event loop
    loop.create_task(update_assets_loop(gp, poll_rate=.1))
    loop.create_task(update_persistent_storage(gp, db, .2))
    loop.create_task(update_virtual_system(vs))

    try:
        loop.run_forever()
    except:
        loop.close()
Exemple #5
0
    def setUp(self):
        "Setup for process Module Testing"
        self.test_system = gridpi_core.System(
        )  # Create System container object

        # configure asset models
        self.parser = ConfigParser()
        self.parser.read_dict({
            'FEEDER': {
                'class_name': 'VirtualFeeder',
                'name': 'feeder'
            },
            'ENERGY_STORAGE': {
                'class_name': 'VirtualEnergyStorage',
                'name': 'inverter'
            },
            'GRID_INTERTIE': {
                'class_name': 'VirtualGridIntertie',
                'name': 'grid'
            }
        })

        asset_factory = model_core.AssetFactory(
        )  # Create Asset Factory object
        for cfg in self.parser.sections(
        ):  # Add models to System, The asset factory acts on a configuration
            self.test_system.add_asset(asset_factory.factory(self.parser[cfg]))
        del asset_factory

        # configure processes
        self.parser.clear()
        self.parser.read_dict({
            'process_1': {
                'class_name': 'EssUpdateStatus'
            },
            'process_2': {
                'class_name': 'GridUpdateStatus'
            },
            'process_3': {
                'class_name': 'EssSocPowerController',
                'inverter_target_soc': 0.6
            },
            'process_4': {
                'class_name': 'EssDemandLimitPowerController',
                'grid_kw_import_limit': 20,
                'grid_kw_export_limit': 20
            },
            'process_5': {
                'class_name': 'EssWriteControl'
            }
        })
        process_factory = process_core.ProcessFactory()
        for cfg in self.parser.sections():
            self.test_system.add_process(
                process_factory.factory(self.parser[cfg]))
        del process_factory

        self.test_system.process.sort()

        # Get an asyncio event loop so that we can run updateStatus() and updateCtrl() on assets.
        self.loop = asyncio.get_event_loop()
Exemple #6
0
    def setUp(self):
        logging.basicConfig(format='%(levelname)s:%(message)s',
                            level=logging.DEBUG)  # configure logging
        self.gp = gridpi_core.System()

        # configure asset models
        parser = ConfigParser()
        parser.read_dict({
            'FEEDER': {
                'class_name': 'VirtualFeeder',
                'class_type': 'feeder',
                'name': 'feeder'
            },
            'ENERGY_STORAGE': {
                'class_name': 'VirtualEnergyStorage',
                'class_type': 'ess',
                'name': 'inverter'
            },
            'GRID_INTERTIE': {
                'class_name': 'VirtualGridIntertie',
                'class_type': 'grid',
                'name': 'grid'
            }
        })

        asset_factory = model_core.AssetFactory(
        )  # Create Asset Factory object
        for cfg in parser.sections(
        ):  # Add models to System, The asset factory acts on a configuration
            self.gp.add_asset(asset_factory.factory(parser[cfg]))
        del asset_factory

        # configure processes
        parser.clear()
        parser.read_dict({
            'process_1': {
                'class_name': 'EssUpdateStatus'
            },
            'process_2': {
                'class_name': 'GridUpdateStatus'
            },
            'process_3': {
                'class_name': 'EssSocPowerController',
                'inverter_target_soc': 0.6
            },
            'process_4': {
                'class_name': 'EssDemandLimitPowerController',
                'grid_kw_import_limit': 20,
                'grid_kw_export_limit': 20
            },
            'process_5': {
                'class_name': 'EssWriteControl'
            }
        })
        process_factory = process_core.ProcessFactory()
        for cfg in parser.sections():
            self.gp.add_process(process_factory.factory(parser[cfg]))
        del process_factory

        parser.clear()
        """
Exemple #7
0
    def setUp(self):

        self.test_system = gridpi_core.System()