本文整理汇总了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)
示例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)