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


Python Motor.turn方法代码示例

本文整理汇总了Python中motor.Motor.turn方法的典型用法代码示例。如果您正苦于以下问题:Python Motor.turn方法的具体用法?Python Motor.turn怎么用?Python Motor.turn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在motor.Motor的用法示例。


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

示例1: Configuration

# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import turn [as 别名]
from motor import Motor
from configuration import Configuration
import logging

LOG_FORMAT = '%(levelname) -10s %(asctime)s %(name) -30s %(funcName) -35s %(lineno) -5d: %(message)s'
LOGGER = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)

log_file_handler = logging.FileHandler('slotobahn.log')
#app.logger.addHandler(log_file_handler)

configuration = Configuration()

motor = Motor(configuration)

try:
    motor.turn(15, 50)
except KeyboardInterrupt:
    print 'Stopped by the user'
    GPIO.cleanup()
    sys.exit(0)
开发者ID:gregmajor,项目名称:slotobahn,代码行数:23,代码来源:motor_test.py

示例2: Clock

# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import turn [as 别名]
class Clock(object):
    """This is the clock aggregate root.
    """

    def __init__(self, configuration):
        """Create a new instance of the clock class.
        """
        self._configuration = configuration
        self._logger = logging.getLogger(__name__)

        self._motor = Motor(self._configuration)
        self._blinker = Blinker(self._configuration)
        self._display = Display(self._configuration)
        self._database = Database(self._configuration)
        self._consumer = Consumer(self._configuration, self.on_message)

    @property
    def blinker(self):
        """The blinker.
        """
        return self._blinker

    @property
    def consumer(self):
        """The RabbitMQ consumer.
        """
        return self._consumer

    @property
    def database(self):
        """The database.
        """
        return self._database

    @property
    def display(self):
        """The display.
        """
        return self._display

    @property
    def ip_address(self):
        """The IP address.
        """
        return socket.gethostbyname(socket.gethostname())

    @property
    def motor(self):
        """The clock motor.
        """
        return self._motor

    def on_message(self, unused_channel, basic_deliver, properties, body):
        """Invoked when a message is delivered from RabbitMQ. The channel is passed for your convenience. The
        basic_deliver object that is passed in carries the exchange, routing key, delivery tag and a redelivered flag
        for the message. The properties passed in is an instance of BasicProperties with the message properties and the
        body is the message that was sent.

        :param pika.channel.Channel unused_channel: The channel object
        :param pika.Spec.Basic.Deliver: basic_deliver method
        :param pika.Spec.BasicProperties: properties
        :param str|unicode body: The message body
        """
        self._logger.info('Received message # %s from %s: %s', basic_deliver.delivery_tag, properties.app_id, body)

        #if body is not None:
        #    payload = json.loads(body)

        #    if payload['Order'] is not None:
        #        order = payload['Order']

        #        if order is not None:

        #            order_date = date_parser.parse(order['OrderDate'])

        #            self._logger.info('Order date is %s', order_date.strftime("%Y-%m-%d %H:%M:%S"))

        #            order_year = int(order_date.year)

        #            self._logger.info('Order year is %i', order_year)

        #            order_month = int(order_date.month)

        #            self._logger.info('Order month is %i', order_month)

        #self._blinker.blink()
        
        self._motor.turn(15, 50)
        
        self._logger.info('Current order count is %i', self._database.order_count)

        order_year = datetime.today().year
        order_month = datetime.today().month
        self._database.record_order(order_year, order_month)

        self._display.write("%i orders" % self._database.order_count)
开发者ID:gregmajor,项目名称:slotobahn,代码行数:98,代码来源:clock.py


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