예제 #1
0
    def test_str(self):
        article = Article()
        article.entry_number = '7399422'
        article.author = 'R. Atia and N. Yamada'
        article.journal = 'IEEE Transactions on Smart Grid'
        article.title = 'Sizing and Analysis of Renewable Energy and Battery Systems in Residential Microgrids'
        article.year = '2016'
        article.volume = '7'
        article.number = '3'
        article.pages = '1204-1213'
        article.abstract = 'Accelerated development of eco-friendly technologies such as renewable energy smart grids and electric transportation will shape the future of electric power generation and supply. Accordingly the power consumption characteristics of modern power systems are designed to be more flexible which impact the system sizing. However integrating these considerations into the design stage can be complex. Under these terms this paper presents a novel model based on mixed integer linear programming for the optimization of a hybrid renewable energy system with a battery energy storage system in residential microgrids in which the demand response of available controllable appliances is coherently considered in the proposed optimization problem with reduced calculation burdens. The model takes into account the intrinsic stochastic behavior of renewable energy and the uncertainty involving electric load prediction and thus proper stochastic models are considered. This paper investigates the effect of load flexibility on the component sizing of the system for a residential microgrid in Okinawa. Also under consideration are different operation scenarios emulating technical limitations and several uncertainty levels.'
        article.keyword = 'battery storage plants;demand side management;distributed power generation;hybrid power systems;integer programming;linear programming;load forecasting;renewable energy sources;smart power grids;Okinawa;battery energy storage system;battery systems;demand response;eco-friendly technologies;electric load prediction;electric power generation;electric transportation;hybrid renewable energy system;load flexibility;mixed integer linear programming;power systems;residential microgrids;smart grids;Batteries;Home appliances;Load modeling;Microgrids;Optimization;Renewable energy sources;Stochastic processes;Design optimization;demand response;hybrid power systems;microgrids;performance analysis'
        article.doi = '10.1109/TSG.2016.2519541'
        article.issn = '1949-3053'

        benchmark = '@article{7399422,\n' \
                    ' abstract = {Accelerated development of eco-friendly technologies such as renewable energy smart grids and electric transportation will shape the future of electric power generation and supply. Accordingly the power consumption characteristics of modern power systems are designed to be more flexible which impact the system sizing. However integrating these considerations into the design stage can be complex. Under these terms this paper presents a novel model based on mixed integer linear programming for the optimization of a hybrid renewable energy system with a battery energy storage system in residential microgrids in which the demand response of available controllable appliances is coherently considered in the proposed optimization problem with reduced calculation burdens. The model takes into account the intrinsic stochastic behavior of renewable energy and the uncertainty involving electric load prediction and thus proper stochastic models are considered. This paper investigates the effect of load flexibility on the component sizing of the system for a residential microgrid in Okinawa. Also under consideration are different operation scenarios emulating technical limitations and several uncertainty levels.},\n' \
                    ' author = {R. Atia and N. Yamada},\n' \
                    ' doi = {10.1109/TSG.2016.2519541},\n' \
                    ' issn = {1949-3053},\n' \
                    ' journal = {IEEE Transactions on Smart Grid},\n' \
                    ' keyword = {battery storage plants;demand side management;distributed power generation;hybrid power systems;integer programming;linear programming;load forecasting;renewable energy sources;smart power grids;Okinawa;battery energy storage system;battery systems;demand response;eco-friendly technologies;electric load prediction;electric power generation;electric transportation;hybrid renewable energy system;load flexibility;mixed integer linear programming;power systems;residential microgrids;smart grids;Batteries;Home appliances;Load modeling;Microgrids;Optimization;Renewable energy sources;Stochastic processes;Design optimization;demand response;hybrid power systems;microgrids;performance analysis},\n' \
                    ' number = {3},\n' \
                    ' pages = {1204-1213},\n' \
                    ' title = {Sizing and Analysis of Renewable Energy and Battery Systems in Residential Microgrids},\n' \
                    ' volume = {7},\n' \
                    ' year = {2016}\n' \
                    '}\n\n'

        self.assertEqual(str(article), benchmark)
예제 #2
0
def add_article(current_user):
    try:
        data = request.form
        files = request.files
        article = Article()
        article.title = data['title']
        article.category = data['category']
        article.author = data['author']
        article.author_desc = data['author_desc']
        article.date = datetime.strptime(str(data['date']),'%Y-%m-%d')
        article.image = files['image'].read()
        article.caption = data['caption']
        article.text = data['text']
        if 'chart1' in files:
            article.chart1 = files['chart1'].read()
        article.chart1_caption = data.get('chart1','')
        if 'chart2' in files:
            article.chart2 = files['chart2'].read()
        article.chart2_caption = data.get('chart2','')
        db.session.add(article)
        db.session.commit()
        return jsonify({
            'status': 'SUCCESS',
            'data': {},
        })
    except Exception as e:
        print(e)
        return jsonify({
            'status': 'ERROR',
            'data': str(e),
        })
예제 #3
0
 def get(self):
     user = User(username='******', email='*****@*****.**')
     article = Article(title='邪神', content='威武雄壮')
     article.author = user
     tag1 = Tag(name='Java')
     tag2 = Tag(name='Python')
     article.tags.append(tag1)
     article.tags.append(tag2)
     db.session.add(article)
     return render_template('home/index.html')
예제 #4
0
    def post(self, request):

        jsonData = json.loads(request.body)
        article = Article()
        article.title = jsonData['title']
        article.author = jsonData['author']
        article.date = jsonData['date']
        article.articleJson = jsonData['post']
        article.save()

        return HttpResponse("OK")
예제 #5
0
def readarticle(articleid):
    if request.method == 'GET':
        return u'this is article'
    else:
        title = request.get_json().get('title')
        content = request.get_json().get('content')
        article = Article(title=title, content=content)
        user_id = session.get('user_id')
        user = User.query.filter_by(id=user_id).first()
        article.author = user
        db.session.add(article)
        db.session.commit()
        return jsonify({"title": article.title}), 200
예제 #6
0
def post():
    if request.method == 'GET':
        return render_template('main/post.html')
    else:
        author_id = session.get('logined_id')
        title = request.form.get('title')
        content = request.form.get('content')
        tags_content = request.form.get('tag')
        article = Article(title=title, content=content)
        tags = Tag(content=tags_content)
        article.author = User.query.filter_by(id=author_id).first()
        db.session.add(tags)
        db.session.add(article)
        db.session.commit()

        return redirect(url_for('main.index'))
예제 #7
0
def write(request):
    if request.session.get('username') != 'admin':
        info = "你不是小张!不过可以<a href='../about/'>查看小张</a>"
        return HttpResponse(info)
    if request.method == 'POST':
        title = request.POST['title']
        body = request.POST['body']
        author = request.POST['author']

        article = Article()
        article.title = title
        article.body = body
        article.author = author
        article.create_time = datetime.now()
        article.save()
        return render(request, 'index.html', context_instance=RequestContext(request))
    return render(request, 'write.html', context_instance=RequestContext(request))
예제 #8
0
def new_article():
    form = ArticleForm()

    if form.validate_on_submit():
        print("ZZZ")
        title = form.title.data
        time_now = datetime.now()
        folder_name = form.identifier.data

        new_object = Article()
        new_object.title = title
        new_object.created = time_now
        new_object.updated = time_now
        new_object.folder = folder_name
        new_object.author = g.user

        db.session.add(new_object)
        db.session.commit()

        return redirect(url_for('admin.index'))

    return render_template('admin/article.html', form=form)
예제 #9
0
def create_article():

    user = users.get_current_user()

    context = {
        'logout_url': logout_url(),
    }

    form = CreateArticleLoginForm()

    if form.validate_on_submit():

        new_article = Article()

        new_article.title1 = form.title1.data
        new_article.title2 = form.title2.data
        new_article.seo_title = form.seo_title.data
        new_article.seo_description = form.seo_description.data
        new_article.author = blog_config['EDITOR_ACCESS_LIST'][user.email()]
        new_article.slug = slugify(form.title1.data)
        new_article.content = form.content.data
        tags = form.tags.data
        tags = tags.lower()
        tags = tags.split()
        new_article.tags = tags
        new_article.published = True if form.status.data == 'published' else False
        new_article.put()

        return redirect(url_for('editor.home'))

    else:
        pass

    return render_template('editor/create_article_page.html',
                           context=context,
                           form=form,
                           blog_config=blog_config)
예제 #10
0
def create_app(config, blog_config):
    """This initiates the Flask app and starts your app engine instance.
    Startup Steps:
    1. Instantiate the Flask app with the config settings.
    2. Register bluprints.
    3. Create the Contact and About Pages in the datastore if they don't exist yet.
    4. Load the blog_config settings from the datatstore. Or add them if they don't exist yet.
    """

    logging.info('STARTUP: Getting ready to launch the Flask App')

    app = Flask(__name__)
    app.config.update(config)

    # Register blueprints

    logging.info('STARTUP: Register Blueprints')

    from .main import app as main_blueprint
    app.register_blueprint(main_blueprint, url_prefix='/')

    from .editor import app as editor_blueprint
    app.register_blueprint(editor_blueprint, url_prefix='/editor')

    # Add Contact and About pages to the datastore when first launching the blog

    logging.info('STARTUP: Set up Contact and About pages')

    # Contact page creation
    query = Article.query(Article.slug == 'contact-page')
    result = query.fetch(1)

    if result:
        logging.info('STARTUP: Contact page exists')
    else:
        logging.info('STARTUP: Creating a contact page')
        contact_page = Article()
        contact_page.title1 = 'Contact Me'
        contact_page.title2 = 'Have questions? I have answers (maybe).'
        contact_page.slug = 'contact-page'
        contact_page.author = ''
        contact_page.content = 'Want to get in touch with me? Fill out the form below to send me a message and I ' \
                               'will try to get back to you within 24 hours! '
        contact_page.published = False
        contact_page.put()

    # About page creation
    query = Article.query(Article.slug == 'about-page')
    result = query.fetch(1)

    if result:
        logging.info('STARTUP: About page exists')
    else:
        logging.info('STARTUP: Creating an about page')
        about_page = Article()
        about_page.title1 = 'About Me'
        about_page.title2 = 'This is what I do.'
        about_page.slug = 'about-page'
        about_page.author = ''
        about_page.content = ''
        about_page.published = False
        about_page.put()

    # Register blog configurations
    # The Blog is initially configured with blog_conf settings
    # The settings are added to the datastore and will take precedence from now on
    # You can change the settings in the datastore.
    # The settings are only updated on Startup, so you need to restart the instances to apply changes.

    logging.info('STARTUP: Register Blog Configurations')

    query = Feature.query()

    for feature in blog_config:

        # TODO: Add the accesslist to the datastore. The access list is still read only from the config file.
        if feature == 'EDITOR_ACCESS_LIST':
            pass

        # TODO: The posts limit is an int and needs to be converted. Find a better way of doing this.
        elif feature == 'POSTS_LIST_LIMIT':
            result = query.filter(Feature.title == feature).fetch()
            if result:

                logging.info('STARTUP: Loading {}'.format(result[0].title))

                blog_config['POSTS_LIST_LIMIT'] = int(result[0].value)

            else:

                logging.info('STARTUP: Adding to datastore: {}'.format(feature))

                f = Feature()
                f.title = feature
                f.value = str(blog_config[feature])
                f.put()

        # Load the configs or add them to the datastore if they don't exist yet
        else:
            result = query.filter(Feature.title == feature).fetch()
            if result:

                logging.info('STARTUP: Loading {}'.format(result[0].title))

                blog_config[result[0].title] = result[0].value

            else:

                logging.info('STARTUP: Adding to datastore: {}'.format(feature))

                f = Feature()
                f.title = feature
                f.value = blog_config[feature]
                f.put()

    # Startup complete
    logging.info('STARTUP: READY TO ROCK!!!')

    return app