Ejemplo n.º 1
0
 def from_frame(cls, f, devicetype=0):
     if f[8]:
         return
     addr = address.from_frame(f)
     if addr is None:
         return
     return cls(addr, f[7:0])
Ejemplo n.º 2
0
    def from_frame(cls, frame):
        if cls == _StandardCommand:
            return
        if len(frame) != 16:
            return
        if not frame[8]:
            # It's a direct arc power control command
            return
        b = frame[7:0]

        if cls._hasparam:
            if b & 0xf0 != cls._cmdval:
                return
        else:
            if b != cls._cmdval:
                return

        addr = address.from_frame(frame)

        if addr is None:
            return

        if cls._hasparam:
            return cls(addr, b & 0x0f)

        return cls(addr)
Ejemplo n.º 3
0
    def from_frame(cls, frame):
        if cls == _StandardCommand:
            return
        if len(frame) != 16:
            return
        if not frame[8]:
            # It's a direct arc power control command
            return
        b = frame[7:0]

        if cls._hasparam:
            if b & 0xf0 != cls._cmdval:
                return
        else:
            if b != cls._cmdval:
                return

        addr = address.from_frame(frame)

        if addr is None:
            return

        if cls._hasparam:
            return cls(addr, b & 0x0f)

        return cls(addr)
Ejemplo n.º 4
0
 def from_frame(cls, f):
     if len(f) != 16:
         return
     if f[8]:
         return
     addr = address.from_frame(f)
     if addr is None:
         return
     return cls(addr, f[7:0])
Ejemplo n.º 5
0
 def from_frame(cls, f):
     if len(f) != 16:
         return
     if f[8]:
         return
     addr = address.from_frame(f)
     if addr is None:
         return
     return cls(addr, f[7:0])
Ejemplo n.º 6
0
    def from_frame(cls, frame):
        if not frame[16]:
            return
        addr = address.from_frame(frame)
        instance = address.instance_from_frame(frame)

        if addr is None or instance is None:
            return

        cc = cls._opcodes.get(frame[7:0])
        if not cc:
            return UnknownDeviceCommand(frame)

        return cc(addr, instance)
Ejemplo n.º 7
0
    def from_frame(cls, frame):
        if frame[16:8] != 0x1fe:
            return

        addr = address.from_frame(frame)

        if addr is None:
            return

        cc = cls._opcodes.get(frame[7:0])
        if not cc:
            return UnknownDeviceCommand(frame)

        return cc(addr)
Ejemplo n.º 8
0
    def from_frame(cls, frame):
        if cls == _StandardDeviceCommand:
            return
        if len(frame) != 24:
            return
        if frame[16:8] != 0x1fe:
            return
        if frame[7:0] != cls._opcode:
            return

        addr = address.from_frame(frame)

        if addr is None:
            return

        return cls(addr)
Ejemplo n.º 9
0
    def from_frame(cls, frame):
        if cls == _StandardDeviceCommand:
            return
        if len(frame) != 24:
            return
        if frame[16:8] != 0x1fe:
            return
        if frame[7:0] != cls._opcode:
            return

        addr = address.from_frame(frame)

        if addr is None:
            return

        return cls(addr)
Ejemplo n.º 10
0
    def from_frame(cls, frame):
        if cls == _StandardDeviceCommand:
            return
        if len(frame) != 24:
            return
        if not frame[16]:
            return
        if frame[7:0] != cls._opcode:
            return

        addr = address.from_frame(frame)
        instance = address.instance_from_frame(frame)

        if addr is None or instance is None:
            return

        return cls(addr, instance)
Ejemplo n.º 11
0
    def from_frame(cls, frame):
        if cls == _StandardDeviceCommand:
            return
        if len(frame) != 24:
            return
        if not frame[16]:
            return
        if frame[7:0] != cls._opcode:
            return

        addr = address.from_frame(frame)
        instance = address.instance_from_frame(frame)

        if addr is None or instance is None:
            return

        return cls(addr, instance)
Ejemplo n.º 12
0
    def from_frame(cls, frame, devicetype=0):
        if not frame[8]:
            # It's a direct arc power control command
            return

        addr = address.from_frame(frame)

        if addr is None:
            # It's probably a _SpecialCommand
            return

        opcode = frame[7:0]

        cc = cls._opcodes.get((devicetype, opcode))
        if not cc:
            return UnknownGearCommand(frame)

        if cc._hasparam:
            return cc(addr, opcode & 0x0f)

        return cc(addr)