/src/opendnp3/cpp/lib/src/app/ControlRelayOutputBlock.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2013-2022 Step Function I/O, LLC |
3 | | * |
4 | | * Licensed to Green Energy Corp (www.greenenergycorp.com) and Step Function I/O |
5 | | * LLC (https://stepfunc.io) under one or more contributor license agreements. |
6 | | * See the NOTICE file distributed with this work for additional information |
7 | | * regarding copyright ownership. Green Energy Corp and Step Function I/O LLC license |
8 | | * this file to you under the Apache License, Version 2.0 (the "License"); you |
9 | | * may not use this file except in compliance with the License. You may obtain |
10 | | * a copy of the License at: |
11 | | * |
12 | | * http://www.apache.org/licenses/LICENSE-2.0 |
13 | | * |
14 | | * Unless required by applicable law or agreed to in writing, software |
15 | | * distributed under the License is distributed on an "AS IS" BASIS, |
16 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17 | | * See the License for the specific language governing permissions and |
18 | | * limitations under the License. |
19 | | */ |
20 | | #include "opendnp3/app/ControlRelayOutputBlock.h" |
21 | | |
22 | | namespace opendnp3 |
23 | | { |
24 | | |
25 | | ControlRelayOutputBlock::ControlRelayOutputBlock(OperationType opType_, |
26 | | TripCloseCode tcc_, |
27 | | bool clear_, |
28 | | uint8_t count_, |
29 | | uint32_t onTime_, |
30 | | uint32_t offTime_, |
31 | | CommandStatus status_) |
32 | 0 | : opType(opType_), |
33 | 0 | tcc(tcc_), |
34 | 0 | clear(clear_), |
35 | 0 | count(count_), |
36 | 0 | onTimeMS(onTime_), |
37 | 0 | offTimeMS(offTime_), |
38 | 0 | status(status_), |
39 | 0 | rawCode(((TripCloseCodeSpec::to_type(tcc) << 6) & 0xC0) | ((static_cast<uint8_t>(clear) << 5) & 0x20) |
40 | 0 | | (OperationTypeSpec::to_type(opType) & 0x0F)) |
41 | 0 | { |
42 | 0 | } |
43 | | |
44 | | ControlRelayOutputBlock::ControlRelayOutputBlock( |
45 | | uint8_t rawCode_, uint8_t count_, uint32_t onTime_, uint32_t offTime_, CommandStatus status_) |
46 | 0 | : opType(OperationTypeSpec::from_type(rawCode_ & 0x0F)), |
47 | 0 | tcc(TripCloseCodeSpec::from_type((rawCode_ >> 6) & 0x3)), |
48 | 0 | clear(rawCode_ & 0x20), |
49 | 0 | count(count_), |
50 | 0 | onTimeMS(onTime_), |
51 | 0 | offTimeMS(offTime_), |
52 | 0 | status(status_), |
53 | 0 | rawCode(rawCode_) |
54 | 0 | { |
55 | 0 | } |
56 | | |
57 | | } // namespace opendnp3 |