本文整理汇总了Python中Controller.Controller类的典型用法代码示例。如果您正苦于以下问题:Python Controller类的具体用法?Python Controller怎么用?Python Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, ser, default = RGBState.STATE_OFF):
Controller.__init__(self)
self.ser = ser
self.default = default
self.keepalive = False
self.state = self.default
self.lock = threading.Lock()
示例2: test_TextSave_03
def test_TextSave_03(self, mock_isfile, mock_open):
"""
Add 2 Records, then expect the text save to produce 2 text lines
"""
def doText():
doText.theText = theTextStream.getvalue()
theTextStream = StringIO()
theTextStream.close = Mock(side_effect=doText)
mock_isfile.return_value = False
mock_open.return_value = theTextStream
theController = Controller(TestView.TestView(), None)
self._addSomeRecordsViaController(theController, 2)
TestView.clearLog()
theController.do_text_save("")
# Part 1: Text data
expectedData = "A000 M 0 0 Normal 0\nA001 M 0 0 Normal 0"
actualData = doText.theText
self.assertEqual(expectedData, actualData)
# Part 2: Show
expectedShow = "Saved As Text"
actualShow = TestView.theLog[0]
self.assertEqual(expectedShow, actualShow)
示例3: test_SerialSave_01
def test_SerialSave_01(self, mock_isfile, mock_open):
"""
Saving a RecordCollection with 10 Records
"""
def doDump():
doDump.theDump = theDumpStream.getvalue()
theDumpStream = BytesIO()
theDumpStream.close = Mock(side_effect=doDump)
# So that it is know that file does not exist
mock_isfile.return_value = False
mock_open.return_value = theDumpStream
theController = Controller(TestView.TestView(), None)
# add 10 Records, reset view log, then serial save
self._addSomeRecordsViaController(theController, 10)
TestView.clearLog()
theController.do_serial_save("")
# Part 1: Check contents of theDumpStream
# theDump = theDumpStream.getvalue()
expectedRecords = 10
fromDump = pickle.load(BytesIO(doDump.theDump))
actualRecords = len(fromDump.getAllRecords())
self.assertEqual(expectedRecords, actualRecords)
# Part 2: Check no show() messages on theLog
expectedLog = 0
actualLog = len(TestView.theLog)
self.assertEqual(expectedLog, actualLog)
示例4: test_TextLoad_01
def test_TextLoad_01(self, mockMeth):
"""
Load a record from text, test for correct attribute parsing
- This test does not add coverage if test_TextLoad_02 is exercised
- Asserted by expecting TestView().show() to get a message,
representing the record in the same string format
"""
expID = "A001"
expGender = "F"
expAge = 36
expSales = 92
expBMI = "Normal"
expIncome = 700
theData = "{} {} {} {} {} {}".format(expID, expGender, expAge,
expSales, expBMI, expIncome)
mockMeth.return_value = StringIO(theData)
theController = Controller(TestView.TestView(), None)
theController.do_text_load("")
TestView.clearLog()
expectedMessage = theData + "\n"
theController.do_view_records("")
actualMessage = TestView.theLog[0]
self.assertEqual(expectedMessage, actualMessage)
示例5: __init__
def __init__(self, speed, min_altitude, max_altitudeGoal, height_diff, \
timeout, bbx, bby, pid_x, pid_y, pid_z, pid_theta, bounding_box=True):
# Initialize the node and rate
Mode.__init__(self, 'land_mode')
Controller.__init__(self, pid_x, pid_y, pid_z, pid_theta, bounding_box)
# Subscribers
# self.sub_navdata = rospy.Subscriber('/ardrone/navdata', Navdata, self.navdata_cb)
##self.sub_state = rospy.Subscriber('/smach/state', String, self.state_cb)
self.sub_state = rospy.Subscriber('/smach/state',String, self.handle_timer_cb)
# Publishers
self.pub_altitude = rospy.Publisher('/cmd_vel', Twist, queue_size=1)
self.pub_land = rospy.Publisher('/ardrone/land', Empty, queue_size=100) #this turns off the motors
# NOTE changed to passing transition and state info along
# /smach/transition and /smach/state topics, respectively
# self.pub_return_to_state = rospy.Publisher('qc_smach/transitions', String, queue_size=1)
self.pub_transition = rospy.Publisher('smach/transition', String, queue_size=1)
# Initialize member variables
self.transition = String()
self.state = 'nada'
self.timer = rospy.Timer(rospy.Duration(timeout), self.goto_reacquisition)
self.altitude_command = Twist()
self.altitude_command.linear.z = speed
self.min_altitude = min_altitude
self.speed = speed
self.max_altitudeGoal = max_altitudeGoal
self.height_diff = height_diff
示例6: __init__
def __init__(self, model, view):
Controller.__init__(self, model, view)
self.choices = {
1: self._choice_insert_stop,
2: self._choice_insert_time,
3: self._choice_insert_local,
"sair": self.finish}
示例7: ControllerThread
class ControllerThread(threading.Thread):
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, verbose=None):
'''
Initialize class attributes.
'''
threading.Thread.__init__(self, group=group, target=target, name=name, verbose=verbose)
self.controller = Controller()
self.state = True
def stop_communication(self):
'''
Change the state to False, this will finish the communication
cylce.
'''
self.state = False
self.controller.quit_commands()
def run(self):
'''
Perform the joystick connection and get the bluetooth list.
'''
try:
while self.state:
self.controller.send_commands()
except:
print str(traceback.format_exc())
示例8: test_delimiter
def test_delimiter(self):
"""
testet ob der richtige delimiter benutzt wird
"""
c = Controller()
c.delimiter = ';'
self.assertEqual(c.delimiter, ';')
示例9: test_update_temperature_range
def test_update_temperature_range(self):
t_lower = 15
t_upper = 18
c = Controller(t_lower, t_upper)
c.update_temperature_range(16,17)
assert c.set_point_lower == 16
assert c.set_point_upper == 17
示例10: test_SelectedRecord_EditIncome
def test_SelectedRecord_EditIncome(self):
"""
A RecordCollection with one Record will be provided to Controller
- Random ID, male, default attributes
- Randomise an income
- Methodology for picking a new income will be
(original sales + 1) % 1000
"""
theRC = self._getRecordColl_OneMaleRecord_RandomID()
theRecord = theRC.getAllRecords()[0]
theID = theRecord.getID()
theRecord.setIncome(random.randrange(1000))
originalIncome = theRecord.getIncome()
newIncome = (originalIncome + 1) % 1000 # 1000 is income limit
theController = Controller(TestView.TestView(), theRC)
# From here the record will be manipulated via theController
# Successful calls will represent the record via show message
expected_1 = self._getRecordStateMessage(theID, income=originalIncome)
expected_2 = self._getRecordStateMessage(theID, income=newIncome)
# Call 1, selecting the record. 3 show messages
expectedList = [TestObjectSelectionClass._expRecordHeader, expected_1,
TestObjectSelectionClass._expRecordFunctions]
TestView.clearLog()
theController.do_select_rec(theID)
self.assertEqual(expectedList, TestView.theLog)
# Call 2, editing the income. 3 show messages
expectedList[1] = expected_2
TestView.clearLog()
theController.do_edit_income(newIncome)
self.assertEqual(expectedList, TestView.theLog)
示例11: test_SelectedRecord_EditBMI
def test_SelectedRecord_EditBMI(self):
"""
A RecordCollection with one Record will be provided to Controller
- Random ID, male, default attributes
- New BMI will be Overweight
"""
theRC = self._getRecordColl_OneMaleRecord_RandomID()
theRecord = theRC.getAllRecords()[0]
theID = theRecord.getID()
newBMI = "Overweight"
theController = Controller(TestView.TestView(), theRC)
# From here the record will be manipulated via theController
# Successful calls will represent the record via show message
expected_1 = self._getRecordStateMessage(theID)
expected_2 = self._getRecordStateMessage(theID, bmi=newBMI)
# Call 1, selecting the record. 3 show messages
expectedList = [TestObjectSelectionClass._expRecordHeader, expected_1,
TestObjectSelectionClass._expRecordFunctions]
TestView.clearLog()
theController.do_select_rec(theID)
self.assertEqual(expectedList, TestView.theLog)
# Call 2, editing the BMI. 3 show messages
expectedList[1] = expected_2
TestView.clearLog()
theController.do_edit_bmi(newBMI)
self.assertEqual(expectedList, TestView.theLog)
示例12: __init__
def __init__(self, enemy, player, director):
Controller.__init__(self, enemy, director)
self.player = player
self.enemy_speed = 0.10
self.ttl = 0
self.lastSpeedX = 0
self.lastSpeedY = 0
示例13: ControllerTest
class ControllerTest(unittest.TestCase):
def setUp(self):
self.clerk = MockClerk()
self.clerk.store(Goal(name="Test Goal 1"))
self.clerk.store(Goal(name="Test Goal 2"))
self.clerk.store(Task(name="Test Task 1"))
self.clerk.store(Task(name="Test Task 2"))
self.clerk.store(User(name="Durran"))
self.clerk.store(User(name="Michal"))
self.clerk.store(Plan())
self.controller = Controller(self.clerk)
# Test the listing of goals
def testListGoals(self):
g = self.controller.list_goal()
assert len(g) == 2
# Test the listing of tasks
def testListTasks(self):
t = self.controller.list_task()
assert len(t) == 2
# Test the user list
def testListUsers(self):
u = self.controller.list_user()
assert len(u) == 2
# test the plan list
def testListPlan(self):
p = self.controller.list_plan()
assert len(p) == 1
示例14: __init__
def __init__(self, prefs):
'''
Constructor
'''
Controller.__init__(self)
self.shared_prefs = prefs
示例15: test_wrong_delimiter2
def test_wrong_delimiter2(self):
"""
testet ob ein falscher delimiter verwendet wird
"""
c = Controller()
c.delimiter = ','
self.assertEqual(c.delimiter, ',')