Exemple #1
0
import sys
import logging
import datetime

from volttron.lite.agent import BaseAgent, periodic, PublishMixin
from volttron.lite.agent.utils import jsonapi
from volttron.lite.agent import utils
from volttron.lite.agent.matching import match_glob, match_headers, match_exact, match_start
from volttron.lite.messaging import headers as headers_mod, topics

from xlrd import open_workbook
from ahp import calc_column_sums, validate_input, demo_ahp

import time

utils.setup_logging()
_log = logging.getLogger(__name__)

# Variables that are only used for output to file for demo period
criteria_labels = ['NO_curtailing', 'deltaT_zone_delta', 'Room_rtu', 'Power_rtu', 'deltaT_zone_sp']
matrix_rowstring = "%20s\t%15.2f%19.2f%10.2f%11.2f%16.2f"
criteria_labelstring = "\t\t\t%15s%19s%10s%11s%16s"


class LoggerWriter:
    def __init__(self, logger, level):
        self.logger = logger
        self.level = level

    def write(self, message):
        if message != '\n':
Exemple #2
0
# under Contract DE-AC05-76RL01830

#}}}

from datetime import datetime
import logging
import sys
import uuid

from volttron.lite.agent import BaseAgent, PublishMixin, periodic
from volttron.lite.agent import utils, matching
from volttron.lite.messaging import topics, headers as headers_mod

import settings

utils.setup_logging()
_log = logging.getLogger(__name__)


def DatetimeFromValue(ts):
    if isinstance(ts, (int, long)):
        return datetime.utcfromtimestamp(ts)
    elif isinstance(ts, float):
        return datetime.utcfromtimestamp(ts)
    elif not isinstance(ts, datetime):
        raise ValueError('Unknown timestamp value')
    return ts


class ScheduleExampleAgent(PublishMixin, BaseAgent):
    '''Listens to everything and publishes a heartbeat according to the
Exemple #3
0
import psycopg2  #PostgresQL database adapter
import sys
import json
import datetime
import time
import logging
import os
import re
from volttron.lite.agent import BaseAgent, PublishMixin, periodic
from volttron.lite.agent import utils, matching
from volttron.lite.messaging import headers as headers_mod
from urlparse import urlparse
import settings
import random

utils.setup_logging()  # setup logger for debugging
_log = logging.getLogger(__name__)


#Step1: Agent Initialization
def DeviceDiscoveryAgent(config_path, **kwargs):
    config = utils.load_config(
        config_path
    )  # load the config_path from devicediscoveryagent.launch.json

    def get_config(name):
        try:
            value = kwargs.pop(
                name)  # from the **kwargs when call this function
        except KeyError:
            return config.get(name, '')