Exemplo n.º 1
0
    def test_nextion_selection(self):
        selectionvalue = 100
        objname_length = self.bc.NEXTION_OBJNAME_LEN
        status_selected = self.bc.NEXTION_COMPONENTSTATUS_SELECTED
        decay_ticks = self.bc.NEXTION_SELECT_DECAY_TICKS

        name = self.ffi.new('const char[' + str(objname_length) + ']', b'tst')
        component = self.ffi.new("NEXTION_Component*")
        component.value_selected = selectionvalue
        component.name = name
        component.highlighttype = self.bc.NEXTION_HIGHLIGHTTYPE_IMAGE
        component = self.ffi.cast("void*", component)
        self.bc.NEXTION_set_componentstatus(component, status_selected)
        self.bc.USART_flush()

        parse_nextion(self.bc, read_usart(self.bc), nextion_data)
        self.assertEqual(int(nextion_data['pic']['tst']), selectionvalue)
Exemplo n.º 2
0
    def test_EGT(self):
        packets = [{
            "test": 0xffff,
            "result": self.bc.SENSORSFEED_EGT_STATUS_UNKN,
            "display": "----"
        }, {
            "test": 0xfffd,
            "result": self.bc.SENSORSFEED_EGT_STATUS_OPEN,
            "display": "open"
        }, {
            "test": 0x7720,
            "result": self.bc.SENSORSFEED_EGT_STATUS_VALUE,
            "display": " 953"
        }]
        for test_packet in packets:
            response = max6675_response(self.bc, test_packet["test"])
            self.bc.SYSTEM_event_timer = 5
            next(response)
            self.assertEqual(self.bc.SENSORSFEED_EGT_transmission_status,
                             self.bc.SENSORSFEED_EGT_TRANSMISSION_HALF)
            next(response)
            self.assertEqual(self.bc.SENSORSFEED_EGT_transmission_status,
                             self.bc.SENSORSFEED_EGT_TRANSMISSION_READY)
            self.bc.SENSORSFEED_update_EGT()
            self.assertEqual(self.bc.SENSORSFEED_EGT_status,
                             test_packet["result"])
            self.bc.UIBOARD_update_EGT()
            self.bc.USART_flush()
            parse_nextion(self.bc, read_usart(self.bc), nextion_data)
            self.assertEqual(nextion_data["txt"]["egt"],
                             test_packet["display"])

        # Last test should bring value to sensors feed (bits 14 to 5 inclusive)
        self.assertEqual(
            self.bc.SENSORSFEED_feed[self.bc.SENSORSFEED_FEEDID_EGT], 0x3b9)

        self.bc.SYSTEM_event_timer = 0
Exemplo n.º 3
0
    def test_uiboard_maindisplay(self):
        # Cuz of chain of events, test needs to dive into countersfeed
        #Needs rework
        firstcomponent = self.bc.UIBOARD_maindisplay_components[0]
        TANK_ID = self.bc.SENSORSFEED_FEEDID_TANK
        SPEED_ID = self.bc.COUNTERSFEED_FEEDID_SPEED
        FUEL_ID = self.bc.COUNTERSFEED_FEEDID_FUELPS
        SPEED_AVG_ID = self.bc.SENSORSFEED_FEEDID_SPEED_AVG
        LP100_AVG_ID = self.bc.SENSORSFEED_FEEDID_LP100_AVG
        INJT_ID = self.bc.COUNTERSFEED_FEEDID_INJT
        ticks_100m = 540
        speed_modifier = ticks_100m / 360

        def execute_activecomponent():
            active_component = self.bc.UIBOARD_maindisplay_activecomponent
            active_component.executable_component.execute()

        self.bc.UIBOARD_maindisplay_activecomponent = self.ffi.addressof(
            firstcomponent)
        # Fuelps is raw tickcount per injection, however speed is in kph.
        packets = [
            {
                "fuelps": 2700,
                "ccm": 700,
                "speed": 0,
                "assert": " 0.9"
            },
            {
                "fuelps": 4400,
                "ccm": 1000,
                "speed": 1,
                "assert": " 2.0"
            },
            #Speed added, should switch to liters per 100/km
            {
                "fuelps": 5000,
                "ccm": 1000,
                "speed": 100,
                "assert": " 2.3"
            },
            #Speed 0 should trigger zero div checkup and wont update value.
            {
                "fuelps": 5000,
                "ccm": 1000,
                "speed": 0,
                "assert": " 2.3"
            },
            #It should lead to lph mode as a result
            {
                "fuelps": 4400,
                "ccm": 1000,
                "speed": 0,
                "assert": " 2.0"
            },
            {
                "fuelps": 0,
                "ccm": 1,
                "speed": 0,
                "assert": " 0.0"
            },
            {
                "fuelps": 20000,
                "ccm": 1500,
                "speed": 0,
                "assert": "14.3"
            },
            # Hit limiter
            {
                "fuelps": 0xffff,
                "ccm": 14000,
                "speed": 0,
                "assert": "99.9"
            }
        ]
        # At Speed 0 there are liters per hour as current consumption
        for packet in packets:
            self.bc.SENSORSFEED_injector_ccm = packet["ccm"]
            self.bc.SENSORSFEED_speed_ticks_100m = ticks_100m
            self.bc.SENSORSFEED_initialize()  # recalc
            self.bc.COUNTERSFEED_feed[FUEL_ID][0] = packet["fuelps"]
            raw_speed = packet["speed"] * speed_modifier
            self.bc.COUNTERSFEED_feed[SPEED_ID][0] = int(raw_speed)
            self.bc.SENSORSFEED_update_fuel()
            self.bc.SENSORSFEED_update_speed()
            execute_activecomponent()
            self.bc.USART_flush()
            self.bc.AVERAGE_clear(self.bc.AVERAGE_BUFFER_LP100)
            self.bc.AVERAGE_clear(self.bc.AVERAGE_BUFFER_SPEED)
            parse_nextion(self.bc, read_usart(self.bc), nextion_data)
            self.assertEqual(nextion_data['txt']['mdv'], packet["assert"])

        # Fast checkup of averages, only format is tested
        # Average itself is tested in prerun
        # LP100_AVG
        self.bc.UIBOARD_switch_maindisplay()
        read_usart(self.bc)
        self.bc.SENSORSFEED_feed[LP100_AVG_ID] = 12 << 8
        execute_activecomponent()
        self.bc.USART_flush()
        parse_nextion(self.bc, read_usart(self.bc), nextion_data)
        self.assertEqual(nextion_data['txt']['mdv'], "12.0")
        # SPEED_AVG
        self.bc.UIBOARD_switch_maindisplay()
        read_usart(self.bc)
        self.bc.SENSORSFEED_feed[SPEED_AVG_ID] = (90 << 8)
        execute_activecomponent()
        self.bc.USART_flush()
        parse_nextion(self.bc, read_usart(self.bc), nextion_data)
        self.assertEqual(nextion_data['txt']['mdv'], " 90")
        self.bc.SENSORSFEED_feed[SPEED_AVG_ID] = 0
        # INJ_T
        self.bc.UIBOARD_switch_maindisplay()
        read_usart(self.bc)
        self.bc.COUNTERSFEED_feed[INJT_ID][0] = 150
        self.bc.UIBOARD_maindisplay_activecomponent.executable_component.execute(
        )
        self.bc.USART_flush()
        parse_nextion(self.bc, read_usart(self.bc), nextion_data)
        self.assertEqual(nextion_data['txt']['mdv'], " 1.1")
        # RANGE
        self.bc.UIBOARD_switch_maindisplay()
        read_usart(self.bc)
        self.bc.SENSORSFEED_feed[TANK_ID] = 70
        self.bc.SENSORSFEED_feed[LP100_AVG_ID] = 12 << 8
        execute_activecomponent()
        self.bc.USART_flush()
        parse_nextion(self.bc, read_usart(self.bc), nextion_data)
        self.assertEqual(nextion_data['txt']['mdv'], " 583")
Exemplo n.º 4
0
 def setUp(self):
     exec_cycle(self.bc)
     self.bc.NEXTION_switch_page(self.bc.NEXTION_PAGEID_BOARD, 0)
     parse_nextion(self.bc, read_usart(self.bc), nextion_data)
     return super().setUp()