本文整理匯總了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)