コード例 #1
0
    def price_callback(self, timestamp, market_name, buyer_seller, price,
                       quantity):
        if self.bldg_power:
            _log.debug("Price is {} at {}".format(price,
                                                  self.bldg_power[-1][0]))
            dt = self.bldg_power[-1][0]
            occupied = check_schedule(dt, self.occupancy_schedule)
        if price is None and self.price is not None:
            _log.debug(
                "Using stored price information! - market price: %x -- price: %s",
                price, self.current_price)
            price = self.current_price

        if self.demand_curve is not None and price is not None and occupied:
            demand_goal = self.demand_curve.x(price)
            self.publish_demand_limit(demand_goal, str(uuid.uuid1()))
        elif not occupied:
            demand_goal = None
            self.publish_demand_limit(demand_goal, str(uuid.uuid1()))
        else:
            _log.debug(
                "Possible market problem price: {} - quantity: {}".format(
                    price, quantity))
            demand_goal = None

        if price is None:
            price = "None"
            demand_goal = "None"
        message = {
            "Price": price,
            "Quantity": demand_goal,
            "Commodity": "Electricity"
        }
        topic_suffix = "/".join([self.logging_topic, "MarketClear"])
        self.publish_record(topic_suffix, message)
コード例 #2
0
    def error_callback(self, timestamp, market_name, buyer_seller, error_code,
                       error_message, aux):
        # figure out what to send if the market is not formed or curves don't intersect.
        _log.debug("AUX: {}".format(aux))
        if market_name == "electric":
            if self.bldg_power:
                dt = self.bldg_power[-1][0]
                occupied = check_schedule(dt, self.occupancy_schedule)

            _log.debug("AUX: {}".format(aux))
            if not occupied:
                demand_goal = None
                self.publish_demand_limit(demand_goal, str(uuid.uuid1()))
            else:
                if aux.get('SQn,DQn', 0) == -1 and aux.get('SQx,DQx', 0) == -1:
                    demand_goal = self.demand_curve.min_x()
                    self.publish_demand_limit(demand_goal, str(uuid.uuid1()))
                elif aux.get('SPn,DPn', 0) == 1 and aux.get('SPx,DPx', 0) == 1:
                    demand_goal = self.demand_curve.min_x()
                    self.publish_demand_limit(demand_goal, str(uuid.uuid1()))
                elif aux.get('SPn,DPn', 0) == -1 and aux.get('SPx,DPx',
                                                             0) == -1:
                    demand_goal = self.demand_curve.max_x()
                    self.publish_demand_limit(demand_goal, str(uuid.uuid1()))
                else:
                    demand_goal = None
                    self.publish_demand_limit(demand_goal, str(uuid.uuid1()))
        return
コード例 #3
0
    def price_callback(self, timestamp, market_name, buyer_seller, price,
                       quantity):
        if self.bldg_power:
            _log.debug("Price is {} at {}".format(price,
                                                  self.bldg_power[-1][0]))
            dt = self.bldg_power[-1][0]
            occupied = check_schedule(dt, self.occupancy_schedule)

        if self.demand_curve is not None and price is not None and occupied:
            demand_goal = self.demand_curve.x(price)
            self.publish_demand_limit(demand_goal, str(uuid.uuid1()))
        elif not occupied:
            demand_goal = None
            self.publish_demand_limit(demand_goal, str(uuid.uuid1()))