/src/opendnp3/cpp/lib/src/app/AppControlField.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 "AppControlField.h"  | 
21  |  |  | 
22  |  | namespace opendnp3  | 
23  |  | { | 
24  |  |  | 
25  |  | const AppControlField AppControlField::DEFAULT(true, true, false, false, 0);  | 
26  |  |  | 
27  |  | AppControlField::AppControlField(uint8_t byte)  | 
28  |  |     : FIR((byte & FIR_MASK) != 0),  | 
29  |  |       FIN((byte & FIN_MASK) != 0),  | 
30  |  |       CON((byte & CON_MASK) != 0),  | 
31  |  |       UNS((byte & UNS_MASK) != 0),  | 
32  |  |       SEQ(byte & SEQ_MASK)  | 
33  | 41.8k  | { | 
34  | 41.8k  | }  | 
35  |  |  | 
36  |  | AppControlField AppControlField::Request(uint8_t seq)  | 
37  | 0  | { | 
38  | 0  |     return AppControlField(true, true, false, false, seq);  | 
39  | 0  | }  | 
40  |  |  | 
41  |  | AppControlField::AppControlField(bool fir, bool fin, bool con, bool uns, uint8_t seq)  | 
42  |  |     : FIR(fir), FIN(fin), CON(con), UNS(uns), SEQ(seq)  | 
43  | 2  | { | 
44  | 2  | }  | 
45  |  |  | 
46  |  | uint8_t AppControlField::ToByte() const  | 
47  | 0  | { | 
48  | 0  |     uint8_t ret = 0;  | 
49  |  | 
  | 
50  | 0  |     if (FIR)  | 
51  | 0  |     { | 
52  | 0  |         ret |= FIR_MASK;  | 
53  | 0  |     }  | 
54  | 0  |     if (FIN)  | 
55  | 0  |     { | 
56  | 0  |         ret |= FIN_MASK;  | 
57  | 0  |     }  | 
58  | 0  |     if (CON)  | 
59  | 0  |     { | 
60  | 0  |         ret |= CON_MASK;  | 
61  | 0  |     }  | 
62  | 0  |     if (UNS)  | 
63  | 0  |     { | 
64  | 0  |         ret |= UNS_MASK;  | 
65  | 0  |     }  | 
66  |  | 
  | 
67  | 0  |     uint8_t seq = SEQ % 16;  | 
68  |  | 
  | 
69  | 0  |     return ret | seq;  | 
70  | 0  | }  | 
71  |  |  | 
72  |  | } // namespace opendnp3  |