Coverage for d7a/alp/indirect_forward_action.py: 67%
18 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-05-24 08:03 +0200
« prev ^ index » next coverage.py v7.5.0, created at 2024-05-24 08:03 +0200
1#
2# Copyright (c) 2015-2021 University of Antwerp, Aloxy NV.
3#
4# This file is part of pyd7a.
5# See https://github.com/Sub-IoT/pyd7a for further info.
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19from d7a.alp.action import Action
20from d7a.alp.operands.indirect_interface_operand import IndirectInterfaceOperand
21from d7a.alp.operations.indirect_forward import IndirectForward
22from d7a.alp.operations.nop import NoOperation
23from d7a.support.schema import Types
26class IndirectForwardAction(Action):
27 SCHEMA = [{
28 "overload" : Types.BOOLEAN(),
29 "resp" : Types.BOOLEAN(),
30 "op" : Types.BITS(6),
31 "operation": Types.OBJECT(IndirectForward),
32 "operand" : Types.OBJECT(IndirectInterfaceOperand) # TODO for now only D7 interface is supported
33 }]
35 def __init__(self, overload=False, resp=False, operation=NoOperation()):
36 self.overload = overload
37 self.resp = resp
38 super(IndirectForwardAction, self).__init__(operation)
40 def __iter__(self):
41 byte = 0
42 if self.overload: byte |= 1 << 7
43 if self.resp: byte |= 1 << 6
44 byte += self.op
45 yield byte
47 for byte in self.operation: yield byte