本文整理汇总了Python中controller.Controller方法的典型用法代码示例。如果您正苦于以下问题:Python controller.Controller方法的具体用法?Python controller.Controller怎么用?Python controller.Controller使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类controller
的用法示例。
在下文中一共展示了controller.Controller方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stop_daemon
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def stop_daemon(process, project, collector_id=None, network=None):
"""
Calls a Controller to stop a daemonized STACK process
"""
if process == 'collect':
c = Controller(
process=process,
project=project,
collector_id=collector_id
)
else:
c = Controller(
process=process,
project=project,
network=network
)
t = threading.Thread(name='test-thread', target=c.process_command, args=('stop',))
t.start()
t.join()
# c.process_command('stop')
示例2: get_controller
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def get_controller(self):
"""Get controller."""
cls = controller.Controller
return cls(self.env, self.env_spec, self.internal_dim,
use_online_batch=self.use_online_batch,
batch_by_steps=self.batch_by_steps,
unify_episodes=self.unify_episodes,
replay_batch_size=self.replay_batch_size,
max_step=self.max_step,
cutoff_agent=self.cutoff_agent,
save_trajectories_file=self.save_trajectories_file,
use_trust_region=self.trust_region_p,
use_value_opt=self.value_opt is not None,
update_eps_lambda=self.update_eps_lambda,
prioritize_by=self.prioritize_by,
get_model=self.get_model,
get_replay_buffer=self.get_replay_buffer,
get_buffer_seeds=self.get_buffer_seeds)
示例3: prepare_spi
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def prepare_spi(self, spi):
if spi:
new_spi = Controller.Mock()
def transfer(pin_ss, address, value = 0x00):
response = bytearray(1)
pin_ss.low()
response.append(spi.xfer2([address, value])[1])
pin_ss.high()
return response
new_spi.transfer = transfer
new_spi.close = spi.close
return new_spi
示例4: prepare_spi
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def prepare_spi(self, spi):
if spi:
new_spi = Controller.Mock()
def transfer(pin_ss, address, value = 0x00):
response = bytearray(1)
pin_ss.low()
spi.write(bytes([address]))
spi.write_readinto(bytes([value]), response)
pin_ss.high()
return response
new_spi.transfer = transfer
new_spi.close = spi.deinit
return new_spi
示例5: prepare_spi
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def prepare_spi(self, spi):
if spi:
new_spi = Controller.Mock()
def transfer(pin_ss, address, value = 0x00):
response = bytearray(1)
pin_ss.low()
spi.write(bytes([address]))
spi.write_readinto(bytes([value]), response)
pin_ss.high()
return response
new_spi.transfer = transfer
new_spi.close = spi.deinit
return new_spi
示例6: start_daemon
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def start_daemon(process, project, collector_id=None, network=None):
"""
Calls a Controller to daemonize and start a STACK process
"""
if process == 'collect':
c = Controller(
process=process,
project=project,
collector_id=collector_id
)
else:
c = Controller(
process=process,
project=project,
network=network
)
t = threading.Thread(name='test-thread', target=c.process_command, args=('start',))
t.start()
# c.process_command('start')
示例7: restart_daemon
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def restart_daemon(process, project, collector_id=None, network=None):
"""
Calls a Controller to restart a daemonized STACK process
"""
if process == 'collect':
c = Controller(
process=process,
project=project,
collector_id=collector_id
)
else:
c = Controller(
process=process,
project=project,
network=network
)
t = threading.Thread(name='test-thread', target=c.process_command, args=('restart',))
t.start()
# c.process_command('restart')
示例8: get_controller
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def get_controller(self, env):
"""Get controller."""
cls = controller.Controller
return cls(env, self.env_spec, self.internal_dim,
use_online_batch=self.use_online_batch,
batch_by_steps=self.batch_by_steps,
unify_episodes=self.unify_episodes,
replay_batch_size=self.replay_batch_size,
max_step=self.max_step,
cutoff_agent=self.cutoff_agent,
save_trajectories_file=self.save_trajectories_file,
use_trust_region=self.trust_region_p,
use_value_opt=self.value_opt not in [None, 'None'],
update_eps_lambda=self.update_eps_lambda,
prioritize_by=self.prioritize_by,
get_model=self.get_model,
get_replay_buffer=self.get_replay_buffer,
get_buffer_seeds=self.get_buffer_seeds)
示例9: load_controllers
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def load_controllers():
controllers = []
path = os.path.join(config.get_runtime_path(),"platformcode", "controllers")
for fname in os.listdir(path):
mod, ext = os.path.splitext(fname)
fname = os.path.join(path, fname)
if os.path.isfile(fname) and ext == '.py' and not mod.startswith('_'):
try:
exec "import " + mod + " as controller"
except:
import traceback
logger.error(traceback.format_exc())
for c in dir(controller):
cls = getattr(controller, c)
if not c.startswith('_') and isclass(cls) and issubclass(cls, Controller) and Controller != cls:
controllers.append(cls)
return controllers
示例10: render
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def render(self, request, doneCallback=None):
if not getattr(request, 'currentId', 0):
request.currentId = 0
request.currentPage = self
if self.controller is None:
self.controller = controller.Controller(self.model)
if doneCallback is not None:
self.doneCallback = doneCallback
else:
self.doneCallback = doSendPage
self.setupAllStacks()
template = self.getTemplate(request)
if template:
self.d = microdom.parseString(template, caseInsensitive=0, preserveCase=0)
else:
if not self.templateFile:
raise AttributeError, "%s does not define self.templateFile to operate on" % self.__class__
self.d = self.lookupTemplate(request)
request.d = self.d
self.handleDocument(request, self.d)
return NOT_DONE_YET
示例11: __init__
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def __init__(self,
controller: Controller,
button_gpio: int = 26,
led_gpio: int = 21) -> None:
self.button_gpio = button_gpio
self.controller = controller
GPIO.setmode(GPIO.BCM)
GPIO.setup(button_gpio, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(led_gpio, GPIO.OUT)
self.led_gpio = led_gpio
def call_back(channel: int) -> None:
def new_thread():
self.controller.update_and_redraw()
logger.info('Update of the screen due to button event')
thread = threading.Thread(target=new_thread)
thread.start()
GPIO.add_event_detect(button_gpio,
GPIO.FALLING,
callback=call_back,
bouncetime=500)
self.led_off()
示例12: load_controllers
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def load_controllers():
controllers=[]
path=os.path.split(__file__)[0]
for fname in os.listdir(path):
mod,ext=os.path.splitext(fname)
fname=os.path.join(path,fname)
if os.path.isfile(fname) and ext=='.py' and not mod.startswith('_'):
try:
exec "import "+ mod + " as controller"
except:
import traceback
logger.error(traceback.format_exc())
for c in dir(controller):
cls=getattr(controller, c);
if not c.startswith('_') and isclass(cls) and issubclass(cls, Controller) and Controller != cls:
controllers.append(cls)
return controllers
示例13: prepare_pin
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def prepare_pin(self, pin_id, in_out = GPIO.OUT):
if pin_id is not None:
GPIO.setup(pin_id, in_out)
new_pin = Controller.Mock()
new_pin.pin_id = pin_id
if in_out == GPIO.OUT:
new_pin.low = lambda : GPIO.output(pin_id, GPIO.LOW)
new_pin.high = lambda : GPIO.output(pin_id, GPIO.HIGH)
else:
new_pin.value = lambda : GPIO.input(pin_id)
return new_pin
示例14: prepare_pin
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def prepare_pin(self, pin_id, in_out = Pin.OUT):
if pin_id is not None:
pin = Pin(pin_id, in_out)
new_pin = Controller.Mock()
new_pin.pin_id = pin_id
new_pin.value = pin.value
if in_out == Pin.OUT:
new_pin.low = lambda : pin.value(0)
new_pin.high = lambda : pin.value(1)
else:
new_pin.irq = pin.irq
return new_pin
示例15: prepare_pin
# 需要导入模块: import controller [as 别名]
# 或者: from controller import Controller [as 别名]
def prepare_pin(self, pin_id, in_out = GPIO.OUT):
if pin_id is not None:
GPIO.setup(pin_id, in_out)
new_pin = Controller.Mock()
new_pin.pin_id = pin_id
if in_out == GPIO.OUT:
new_pin.low = lambda: GPIO.output(pin_id, GPIO.LOW)
new_pin.high = lambda: GPIO.output(pin_id, GPIO.HIGH)
else:
new_pin.value = lambda: GPIO.input(pin_id)
return new_pin