コード例 #1
0
ファイル: test_abstractui.py プロジェクト: fkivela/TurboCtl
    def test_on_off_and_status(self):

        # Make sure the status signal is correct, and the pump is
        # initially not turning.
        q, r = self.ui.status()
        status_bits = [
            2, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 20
        ]
        status_query = Query(status_bits)
        self.assertEqual(q, status_query)
        self.assertFalse(StatusBits.TURNING in r.control_or_status_set)

        # Make sure the on_off signal is correct.
        q, r = self.ui.on_off()
        onoff_bits = [
            2, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 17
        ]
        onoff_query = Query(onoff_bits)
        self.assertEqual(q, onoff_query)

        # Wait for the pump to start.
        time.sleep(0.1)

        # Make sure the pump starts turning.
        q, r = self.ui.status()
        self.assertTrue(StatusBits.TURNING in r.control_or_status_set)
コード例 #2
0
 def setUp(self):
     self.q = Query(parameter_number=1, parameter_value=123)
     self.q_Hz = Query(parameter_number=3, parameter_value=123)
     self.qi = Query(parameter_number=29,
                     parameter_value=123,
                     parameter_index=1)
     self.r = Reply(parameter_number=1, parameter_value=123)
     self.r_Hz = Reply(parameter_number=3, parameter_value=123)
     self.ri = Reply(parameter_number=29,
                     parameter_value=123,
                     parameter_index=1)
コード例 #3
0
 def setUpClass(cls):
     cls.q = Query(control_or_status_set={ControlBits.START_STOP, 
                   ControlBits.COMMAND}, frequency=0, temperature=40, 
                   current=10, voltage=20)
     cls.r = Reply(cls.q.data)
     cls.r.control_or_status_set={StatusBits.OPERATION, 
                                  StatusBits.ACCELERATION}
コード例 #4
0
    def test_none(self):
        q = Query()
        r = Reply()

        string = 'No parameter access'
        self.assertEqual(parameter_output(q), string)
        self.assertEqual(parameter_output(r), string)
        self.assertEqual(parameter_output(q, verbose=False), '')
        self.assertEqual(parameter_output(r, verbose=False), '')
コード例 #5
0
    def test_setpoint(self):
        q = Query(
            frequency=1000,
            temperature=30,
            current=100,
            voltage=120,
            control_or_status_set={ControlBits.COMMAND, ControlBits.SETPOINT})

        string = ('Stator frequency setpoint: 1000 Hz')

        self.assertEqual(hardware_output(q), string)
        self.assertEqual(hardware_output(q, verbose=False), '')
コード例 #6
0
    def test_normal(self):
        q = Query(frequency=1000, temperature=30, current=100, voltage=120)
        r = Reply(frequency=1000, temperature=30, current=100, voltage=120)

        long_string = ('Stator frequency: 1000 Hz\n'
                       'Frequency converter temperature: 30 °C\n'
                       'Motor current: 100×0.1 A\n'
                       'Intermediate circuit voltage: 120×0.1 V')

        short_string = ('f=1000 Hz\n'
                        'T=30 °C\n'
                        'I=100×0.1 A\n'
                        'U=120×0.1 V')

        self.assertEqual(hardware_output(r), long_string)
        self.assertEqual(hardware_output(r, verbose=False), short_string)
        self.assertEqual(hardware_output(q), '')
        self.assertEqual(hardware_output(q, verbose=False), '')
コード例 #7
0
    def test_normal(self):

        self.q = Query(
            control_or_status_set={ControlBits.ON, ControlBits.COMMAND})
        self.r = Reply(control_or_status_set={
            StatusBits.TURNING, StatusBits.ACCELERATION
        })

        control_string = ('Active control bits:\n'
                          '    Start/Stop\n'
                          '    Enable control bits')
        status_string = ('Present status conditions:\n'
                         '    Accelerating\n'
                         '    Pump is turning')

        self.assertEqual(out(self.q), control_string)
        self.assertEqual(out(self.r), status_string)
        self.assertEqual(out(self.q, verbose=False), '')
        self.assertEqual(out(self.r, verbose=False), '')
コード例 #8
0
    def test_full_output(self):

        q = Query(parameter_number=1,
                  parameter_value=123,
                  parameter_mode='write',
                  control_or_status_set={
                      ControlBits.COMMAND, ControlBits.ON,
                      ControlBits.FREQ_SETPOINT
                  },
                  frequency=1000)

        r = Reply(parameter_number=1,
                  parameter_value=123,
                  parameter_mode='response',
                  control_or_status_set={
                      StatusBits.TURNING, StatusBits.ACCELERATION
                  },
                  frequency=1000,
                  temperature=30,
                  current=100,
                  voltage=120)

        string = ("""
Sent a telegram with the following contents:
    Write the value 123 to parameter 1
    Active control bits:
        Start/Stop
        Set frequency setpoint
        Enable control bits 0, 5, 6, 7, 8, 13, 14, 15
    Stator frequency setpoint: 1000 Hz

Received a telegram with the following contents:
    The value of parameter 1 is 123
    Present status conditions:
        Accelerating
        Pump is turning
    Stator frequency: 1000 Hz
    Frequency converter temperature: 30 °C
    Motor current: 100×0.1 A
    Intermediate circuit voltage: 120×0.1 V
""".strip())
        self.assertEqual(full_output(q, r), string)
コード例 #9
0
 def setUpClass(cls):
     cls.q = Query(parameter_number=1, parameter_mode='read')
     cls.r = Reply(parameter_number=1, parameter_mode='response',
                   parameter_value=180, 
                   control_or_status_set={StatusBits.READY})
コード例 #10
0
 def setUpClass(cls):
     cls.q = Query()
     cls.r = Reply(control_or_status_set={StatusBits.READY})