当前位置: 首页>>代码示例>>Python>>正文


Python utils.load_config函数代码示例

本文整理汇总了Python中volttron.platform.agent.utils.load_config函数的典型用法代码示例。如果您正苦于以下问题:Python load_config函数的具体用法?Python load_config怎么用?Python load_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了load_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, **kwargs):
     '''
         Initialize class from config file
     '''
     super(CEA2045RelayAgent, self).__init__(**kwargs)
     self.config = utils.load_config(config_path)
     self.volttime = None
     self.mode_CEA2045_array = ['emergency','shed','normal']
     # possible states of the appliance
     self.cea_rate = {
             'Running Normal' : 2,
             'Running Curtailed Grid' : 1,
             'Idle Grid' : 0,
             'Idle Normal': 0,
             'SGD Error Condition':0,
             'Running Heightened Grid':3
             }
     self.device1_mode = {'cea2045state' : 'Idle Normal'}
     self.device2_mode = None
     self.task = 0
     # points of interest for demo
     self.point_name_map = {
         'cea2045state': 'cea2045state'
     }
     self.writable_points = {'cea2045state'}
开发者ID:FraunhoferCSE,项目名称:volttron,代码行数:25,代码来源:agent.py

示例2: __init__

    def __init__(self, config_path, **kwargs):
        super(PGnEAgent, self).__init__(**kwargs)
        self.config = utils.load_config(config_path)
        self.site = self.config.get('campus')
        self.building = self.config.get('building')
        self.out_temp_unit = self.config.get('out_temp_unit')
        self.out_temp_name = self.config.get('out_temp_name')
        self.power_unit = self.config.get('power_unit')
        self.power_name = self.config.get('power_name')
        self.aggregate_in_min = self.config.get('aggregate_in_min')
        self.aggregate_freq = str(self.aggregate_in_min) + 'Min'
        self.ts_name = self.config.get('ts_name')
        self.calc_mode = self.config.get('calculation_mode', 0)
        self.manual_set_adj_value = self.config.get('manual_set_adj_value', False)
        self.fix_adj_value = self.config.get('fix_adj_value', 1.26)

        self.tz = self.config.get('tz')
        self.local_tz = pytz.timezone(self.tz)
        self.one_day = timedelta(days=1)

        self.min_adj = 1
        self.max_adj = 1.4

        #Debug
        self.debug_folder = self.config.get('debug_folder') + '/'
        self.debug_folder = self.debug_folder.replace('//', '/')
        self.wbe_csv = self.config.get('wbe_file')

        #
        self.bday_us = CustomBusinessDay(calendar=USFederalHolidayCalendar())
开发者ID:hlngo,项目名称:volttron-applications,代码行数:30,代码来源:agent.py

示例3: __init__

 def __init__(self, config_path, **kwargs):
     super(PublisherAgent2, self).__init__(**kwargs)
     self._config = load_config(config_path)
     
     self._src_file_handle = open(settings.source_file)
     header_line = self._src_file_handle.readline().strip()
     self._headers = header_line.split(',')
开发者ID:StephenCzarnecki,项目名称:volttron,代码行数:7,代码来源:publisheragent2.py

示例4: ahu_agent

def ahu_agent(config_path, **kwargs):
    """Parses the Electric Meter Agent configuration and returns an instance of
    the agent created using that configuation.

    :param config_path: Path to a configuation file.

    :type config_path: str
    :returns: Market Service Agent
    :rtype: MarketServiceAgent
    """   
    try:
        config = utils.load_config(config_path)
    except StandardError:
        config = {}

    if not config:
        _log.info("Using defaults for starting configuration.")
    air_market_name = config.get('market_name1', 'air')
    electric_market_name = config.get('market_name2', 'electric')
    agent_name= config.get('agent_name')
    subscribing_topic= config.get('subscribing_topic')
    c0= config.get('c0')
    c1= config.get('c1')
    c2= config.get('c2')
    c3= config.get('c3')
    COP= config.get('COP')	
    verbose_logging= config.get('verbose_logging', True)
    return AHUAgent(air_market_name,electric_market_name,agent_name,subscribing_topic,c0,c1,c2,c3,COP,verbose_logging, **kwargs)
开发者ID:Kisensum,项目名称:volttron,代码行数:28,代码来源:agent.py

示例5: historian

def historian(config_path, **kwargs):
    """
    This method is called by the :py:func:`crate_historian.historian.main` to parse
    the passed config file or configuration dictionary object, validate the
    configuration entries, and create an instance of MongodbHistorian

    :param config_path: could be a path to a configuration file or can be a
                        dictionary object
    :param kwargs: additional keyword arguments if any
    :return: an instance of :py:class:`CrateHistorian`
    """
    if isinstance(config_path, dict):
        config_dict = config_path
    else:
        config_dict = utils.load_config(config_path)
    connection = config_dict.get('connection', None)
    assert connection is not None

    database_type = connection.get('type', None)
    assert database_type is not None

    params = connection.get('params', None)
    assert params is not None

    topic_replacements = config_dict.get('topic_replace_list', None)
    _log.debug('topic_replacements are: {}'.format(topic_replacements))

    CrateHistorian.__name__ = 'CrateHistorian'
    return CrateHistorian(config_dict, topic_replace_list=topic_replacements,
                          **kwargs)
开发者ID:schandrika,项目名称:volttron,代码行数:30,代码来源:historian.py

示例6: __init__

    def __init__(self, config_path, **kwargs):
        super(SmartStrip, self).__init__(**kwargs)
        _log.debug("vip_identity: " + self.core.identity)

        self.config = utils.load_config(config_path)
        self._configGetPoints()
        self._configGetInitValues()
开发者ID:cbs-iiith,项目名称:volttron,代码行数:7,代码来源:agent.py

示例7: sep2_agent

def sep2_agent(config_path, **kwargs):
    """Parses the SEP2 Agent configuration and returns an instance of
    the agent created using that configuation.

    :param config_path: Path to a configuation file.

    :type config_path: str
    :returns: SEP2 Agent
    :rtype: SEP2Agent
    """
    try:
        config = utils.load_config(config_path)
    except StandardError:
        config = {}

    if not config:
        _log.info("Using SEP2 Agent defaults for starting configuration.")

    devices = config.get('devices', [])  # To add devices, include them in a config file
    sep2_server_sfdi = config.get('sep2_server_sfdi', 'foo')  # This default should be overridden in config file
    sep2_server_lfdi = config.get('sep2_server_lfdi', 'bar')  # This defauly should be overridden in config file
    load_shed_device_category = config.get('load_shed_device_category', '0020')
    timezone = config.get('timezone', 'America/Los_Angeles')

    return SEP2Agent(devices,
                     sep2_server_sfdi,
                     sep2_server_lfdi,
                     load_shed_device_category,
                     timezone,
                     **kwargs)
开发者ID:Kisensum,项目名称:volttron,代码行数:30,代码来源:agent.py

示例8: kafka_agent

def kafka_agent(config_path, **kwargs):
    '''
        Function: Return KafkaAgent object with configuration information

        Args: Same with Class Args

        Returns: KafkaAgent object

        Note: None

        Created: SungonLee, 2017-10-20
        Deleted: .
    '''
    # get config information
    config = utils.load_config(config_path)
    services_topic_list = config.get('services_topic_list')
    kafka_broker_ip = config.get('kafka_broker_ip')
    kafka_broker_port = config.get('kafka_broker_port')
    kafka_producer_topic = config.get('kafka_producer_topic')
    kafka_consumer_topic = config.get('kafka_consumer_topic')

    if 'all' in services_topic_list:
        services_topic_list = [topics.DRIVER_TOPIC_BASE, topics.LOGGER_BASE,
                            topics.ACTUATOR, topics.ANALYSIS_TOPIC_BASE]

    return KafkaAgent(services_topic_list,
                      kafka_broker_ip,
                      kafka_broker_port,
                      kafka_producer_topic,
                      kafka_consumer_topic,
                      **kwargs)
开发者ID:Kisensum,项目名称:volttron,代码行数:31,代码来源:agent.py

示例9: tagging_service

def tagging_service(config_path, **kwargs):
    """
    This method is called by the :py:func:`service.tagging.main` to
    parse the passed config file or configuration dictionary object, validate
    the configuration entries, and create an instance of SQLTaggingService

    :param config_path: could be a path to a configuration file or can be a
                        dictionary object
    :param kwargs: additional keyword arguments if any
    :return: an instance of :py:class:`service.tagging.SQLTaggingService`
    """
    _log.debug("kwargs before init: {}".format(kwargs))
    if isinstance(config_path, dict):
        config_dict = config_path
    else:
        config_dict = utils.load_config(config_path)

    _log.debug("config_dict before init: {}".format(config_dict))

    if not config_dict.get('connection') or \
            not config_dict.get('connection').get('params') or \
            not config_dict.get('connection').get('params').get('database'):
        raise ValueError("Missing database connection parameters. Agent "
                         "configuration should contain database connection "
                         "parameters with the details about type of database"
                         "and name of database. Please refer to sample "
                         "configuration file in Agent's source directory.")

    utils.update_kwargs_with_config(kwargs,config_dict)
    return SQLiteTaggingService(**kwargs)
开发者ID:Kisensum,项目名称:volttron,代码行数:30,代码来源:tagging.py

示例10: light_agent

def light_agent(config_path, **kwargs):
    """Parses the Electric Meter Agent configuration and returns an instance of
    the agent created using that configuation.

    :param config_path: Path to a configuation file.

    :type config_path: str
    :returns: Market Service Agent
    :rtype: MarketServiceAgent
    """   
    try:
        config = utils.load_config(config_path)
    except StandardError:
        config = {}

    if not config:
        _log.info("Using defaults for starting configuration.")

    market_name = config.get('market_name')
    k= config.get('k', 0)
    qmax= float(config.get('Pmax', 0))
    Pabsnom= float(config.get('Pabsnom', 0))        
    nonResponsive= config.get('nonResponsive', False)    
    agent_name= config.get('agent_name')
    subscribing_topic= config.get('subscribing_topic', '')
    verbose_logging= config.get('verbose_logging', True)
    return LightAgent(market_name,agent_name,k,qmax,Pabsnom,nonResponsive,verbose_logging,subscribing_topic, **kwargs)
开发者ID:Kisensum,项目名称:volttron,代码行数:27,代码来源:agent.py

示例11: fncs_example

def fncs_example(config_path, **kwargs):
    """Parses the Agent configuration and returns an instance of
    the agent created using that configuration.

    :param config_path: Path to a configuration file.

    :type config_path: str
    :returns: FncsExample
    :rtype: FncsExample
    """
    try:
        config = utils.load_config(config_path)
    except StandardError:
        config = {}

    if not config:
        _log.info("Using Agent defaults for starting configuration.")

    if not config.get("topic_mapping"):
        raise ValueError("Configuration must have a topic_mapping entry.")

    topic_mapping = config.get("topic_mapping")
    federate = config.get("federate_name")
    broker_location = config.get("broker_location", "tcp://localhost:5570")
    time_delta = config.get("time_delta", "1s")
    sim_length = config.get("sim_length", "60s")
    stop_agent_when_sim_complete = config.get("stop_agent_when_sim_complete", False)
    subscription_topic = config.get("subscription_topic", None)
    return FncsExample(topic_mapping=topic_mapping, federate_name=federate, broker_location=broker_location,
                       time_delta=time_delta,subscription_topic=subscription_topic, sim_length=sim_length,
                       stop_agent_when_sim_complete=stop_agent_when_sim_complete, **kwargs)
开发者ID:Kisensum,项目名称:volttron,代码行数:31,代码来源:agent.py

示例12: hello_agent

def hello_agent(config_path, **kwargs):

#     home = os.path.expanduser(os.path.expandvars(
#                  os.environ.get('VOLTTRON_HOME', '~/.volttron')))
#     vip_address = 'ipc://@{}/run/vip.socket'.format(home)

    config = utils.load_config(config_path)

    def get_config(name, default=None):
        try:
            return kwargs.pop(name)
        except KeyError:
            return config.get(name, default)

    agentid = get_config('agentid')
    vip_identity = get_config('vip_identity')
    if not vip_identity:
        vip_identity = os.environ.get('AGENT_UUID')

    class Agent(BaseAgent):

        def __init__(self, **kwargs):
            super(Agent, self).__init__(vip_identity=vip_identity, **kwargs)

        @export()
        def sayHello(self, payload="'name': 'juniper'"):
            return "Hello, {them} from {me}".format(them=payload['name'], me=agentid)

    Agent.__name__ = 'HelloAgent'
    return Agent(**kwargs)
开发者ID:pelamlio,项目名称:volttron,代码行数:30,代码来源:agent.py

示例13: historian

def historian(config_path, **kwargs):

    config = utils.load_config(config_path)
            
    class NullHistorian(BaseHistorian):
        '''This historian forwards data to another platform.
        '''

        @Core.receiver("onstart")
        def starting(self, sender, **kwargs):
            
            _log.debug('Null historian started.')

        def publish_to_historian(self, to_publish_list):
            _log.debug("recieved {} items to publish"
                       .format(len(to_publish_list)))

            self.report_all_handled()

        def query_historian(self, topic, start=None, end=None, agg_type=None,
              agg_period=None, skip=0, count=None, order="FIRST_TO_LAST"):
            """Not implemented
            """
            raise NotImplemented("query_historian not implimented for null historian")

    return NullHistorian(**kwargs)
开发者ID:carlatpnl,项目名称:volttron,代码行数:26,代码来源:agent.py

示例14: __init__

    def __init__(self, config_path, **kwargs):
        config = utils.load_config(config_path)


        # We pass every optional parameter to the MQTT library functions so they
        # default to the same values that paho uses as defaults.
        self.mqtt_qos = config.get('mqtt_qos', 0)
        self.mqtt_retain = config.get('mqtt_retain', False)

        self.mqtt_hostname = config.get('mqtt_hostname', 'localhost')
        self.mqtt_port = config.get('mqtt_port', 1883)
        self.mqtt_client_id = config.get('mqtt_client_id', '')
        self.mqtt_keepalive = config.get('mqtt_keepalive', 60)
        self.mqtt_will = config.get('mqtt_will', None)
        self.mqtt_auth = config.get('mqtt_auth', None)
        self.mqtt_tls = config.get('mqtt_tls', None)

        protocol = config.get('mqtt_protocol', MQTTv311)
        if protocol == "MQTTv311":
            protocol = MQTTv311
        elif protocol == "MQTTv31":
            protocol = MQTTv31

        if protocol not in (MQTTv311, MQTTv31):
            raise ValueError("Unknown MQTT protocol: {}".format(protocol))

        self.mqtt_protocol = protocol

        # will be available in both threads.
        self._last_error = 0

        super(MQTTHistorian, self).__init__(**kwargs)
开发者ID:Kisensum,项目名称:volttron,代码行数:32,代码来源:agent.py

示例15: market_service_agent

def market_service_agent(config_path, **kwargs):
    """Parses the Market Service Agent configuration and returns an instance of
    the agent created using that configuation.

    :param config_path: Path to a configuation file.

    :type config_path: str
    :returns: Market Service Agent
    :rtype: MarketServiceAgent
    """
    _log.debug("Starting MarketServiceAgent")
    try:
        config = utils.load_config(config_path)
    except StandardError:
        config = {}

    if not config:
        _log.info("Using Market Service Agent defaults for starting configuration.")

    market_period = int(config.get('market_period', 300))
    reservation_delay = int(config.get('reservation_delay', 0))
    offer_delay = int(config.get('offer_delay', 120))
    verbose_logging = int(config.get('verbose_logging', True))

    return MarketServiceAgent(market_period, reservation_delay, offer_delay, verbose_logging, **kwargs)
开发者ID:Kisensum,项目名称:volttron,代码行数:25,代码来源:agent.py


注:本文中的volttron.platform.agent.utils.load_config函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。