コード例 #1
0
class Device(D.BCU1):
    """Jung 2138 (8out) device"""

    ### default values for standard fields
    manufacturer = 0x0004
    deviceType = 0x2060
    version = 1

    class Output(D.Channel):
        """Fields for the output configuration"""

        delay_base = TBF(0x1F9, bit_field_kind="iduo")
        on_delay_factor = TFF(0x1DA, 0xFF, offset="i", base="delay_base")
        off_delay_factor = TFF(0x1E2, 0xFF, offset="i", base="delay_base")
        timed_fct_active = INF(0x1EA, bit_field_kind="bit")
        reaction_to_off   = D.Choice_Field \
            ( 0x1EB, bit_field_kind = "bit"
            , Choices = { "ignore" : 0, "switch off" : 1}
            )
        lock_polarity     = D.Choice_Field \
            ( 0x1F1, bit_field_kind = "bit"
            , Choices = { "lock=1" : 0, "lock=0" : 1}
            )
        output_polarity   = D.Choice_Field \
            ( 0x1F2, bit_field_kind = "bit"
            , Choices = { "normally open" : 0, "normally closed" : 1}
            )
        feedback_polarity = D.Choice_Field \
            ( 0x1F3, bit_field_kind = "bit"
            , Choices = { "normal" : 0, "inverted" : 1}
            )
        bus_return_action = D.Choice_Field \
            ( 0x1F4, bit_field_kind = "quad"
            , Choices = { "no reaction"   : 0
                        , "open contact"  : 1
                        , "close contact" : 2
                        }
            )

    # end class Output

    class Special_Function(D.Channel):
        """The special function channel"""

        lock_on_action       = D.Choice_Field \
            ( 0x1EF
            , bit_field_kind = "duo_quad_l"
            , Choices        = {"no action" : 0, "close" : 1, "open" : 2}
            )
        lock_off_action      = D.Choice_Field  \
            ( 0x1EF
            , bit_field_kind = "duo_quad_h"
            , Choices        = {"no action" : 0, "close" : 1, "open" : 2}
            )
        output               = D.Choice_Field \
            ( 0x1D8
            , bit_field_kind = "duo"
            , Choices        = { "disabled"  : 0
                               , "channel 1" : 1
                               , "channel 2" : 2
                               , "channel 3" : 3
                               , "channel 4" : 4
                               , "channel 5" : 5
                               , "channel 6" : 6
                               , "channel 7" : 7
                               , "channel 8" : 8
                               }
            )
        kind                 = D.Choice_Field \
            ( 0x1ED
            , bit_field_kind = "quad"
            , Choices        = {"logic" : 0, "lock" : 1, "force" : 2}
            )
        operator             = D.Choice_Field \
            ( 0x1EE
            , bit_field_kind = "quad"
            , Choices        = { "undefined"              : 0
                               , "or"                     : 1
                               , "and"                    : 2
                               , "and with recirculation" : 3
                               }
            )

    # end class Special_Function

    channel = D.Channels_Definition(Output, 8)
    special = D.Channels_Definition(Special_Function, 4)

    Com_Objects = [  ( ( "output %d" % (i + 1, ), )
                     , dict (write = True)
                     )
                   for i in range (8)
                  ] + \
                  [  ( ( "special %d" % (i - 7, ), )
                     , dict ()
                     )
                   for i in range (8, 12)
                  ] + \
                  [  ( ( "feedback %d" % (i - 11, ), )
                     , dict (read = False, transmit = True)
                     )
                   for i in range (12, 20)
                  ]