Exemplo n.º 1
0
    def _create_block_from_channel(self, channel):
        """
        Create a single block from a channel object.

        Args:
            channel: the channel.

        Returns:

        """
        name = shorten_title(channel["Channel"])
        connected = channel["Connected"]
        current_value = channel["Current Value"]
        if connected:
            units = current_value.get("Units", "")

            precision = unicode(current_value.get("Precision", ""))

            value = unicode(current_value["Value"])

            replaced = True
            while replaced:
                value, replaced = self._replace_fake_unicode(value)
            alarm = current_value["Alarm"]
        else:
            value = "null"
            alarm = ""
            units = ""
            precision = 0
        status = Block.CONNECTED if connected else Block.DISCONNECTED

        return Block(name, status, value, alarm, True, precision, units)
Exemplo n.º 2
0
    def test_shorten_title_larmor_block_low_rc(self):
        # Arrange
        test_pv = "IN:LARMOR:CS:SB:Chi:RC:LOW.VAL"

        # Act
        shortened_title = shorten_title(test_pv)

        # Assert
        self.assertEquals(shortened_title, "Chi:RC:LOW.VAL")
Exemplo n.º 3
0
    def test_shorten_title_larmor_block_high_rc(self):
        # Arrange
        test_pv = "IN:LARMOR:CS:SB:CJHCent:RC:HIGH.VAL"

        # Act
        shortened_title = shorten_title(test_pv)

        # Assert
        self.assertEquals(shortened_title, "CJHCent:RC:HIGH.VAL")
Exemplo n.º 4
0
    def test_shorten_title_rc_in_pv_doesnt_count(self):
        # Arrange
        test_pv = "TE:NDLT910:RC.VAL"

        # Act
        shortened_title = shorten_title(test_pv)

        # Assert
        self.assertEquals(shortened_title, "RC.VAL")
Exemplo n.º 5
0
    def test_shorten_title_with_malformed_input_rc_value(self):
        # Arrange
        test_pv = "RC:INRANGE.VAL"

        # Act
        shortened_title = shorten_title(test_pv)

        # Assert
        self.assertEquals(shortened_title, "RC:INRANGE.VAL")
Exemplo n.º 6
0
    def test_shorten_title_with_bad_rc_value(self):
        # Arrange
        test_pv = "OLD_BLOCK:RC:OUTRANGE.VAL"

        # Act
        shortened_title = shorten_title(test_pv)

        # Assert
        self.assertEquals(shortened_title, "OUTRANGE.VAL")
Exemplo n.º 7
0
    def test_shorten_title_with_empty_string(self):
        # Arrange
        test_pv = ""

        # Act
        shortened_title = shorten_title(test_pv)

        # Assert
        self.assertEquals(shortened_title, "")
Exemplo n.º 8
0
    def test_shorten_title_with_rc_in_range(self):
        # Arrange
        test_pv = "TE:NDLT910:CS:SB:OLD_BLOCK:RC:INRANGE.VAL"

        # Act
        shortened_title = shorten_title(test_pv)

        # Assert
        self.assertEquals(shortened_title, "OLD_BLOCK:RC:INRANGE.VAL")
Exemplo n.º 9
0
    def test_shorten_title_with_rc_enabled(self):
        # Arrange
        test_pv = "TE:NDLT910:CS:SB:NEW_BLOCK:RC:ENABLE.VAL"

        # Act
        shortened_title = shorten_title(test_pv)

        # Assert
        self.assertEquals(shortened_title, "NEW_BLOCK:RC:ENABLE.VAL")
Exemplo n.º 10
0
    def test_shorten_title_for_default_case(self):
        #Arrange
        test_pv = "TE:NDLT910:DAE:COUNTRATE.VAL"

        #Act
        shortened_title = shorten_title(test_pv)

        #Assert
        self.assertEquals(shortened_title, "COUNTRATE.VAL")