Directory: | ./ |
---|---|
File: | pdcom5/src/msrproto/Variable.cpp |
Date: | 2024-12-15 04:08:34 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 8 | 11 | 72.7% |
Branches: | 8 | 20 | 40.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /***************************************************************************** | ||
2 | * | ||
3 | * Copyright (C) 2021 Richard Hacker (lerichi at gmx dot net), | ||
4 | * Florian Pose (fp at igh dot de), | ||
5 | * Bjarne von Horn (vh at igh dot de). | ||
6 | * | ||
7 | * This file is part of the PdCom library. | ||
8 | * | ||
9 | * The PdCom library is free software: you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU Lesser General Public License as published by | ||
11 | * the Free Software Foundation, either version 3 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | * | ||
14 | * The PdCom library is distributed in the hope that it will be useful, but | ||
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
16 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | ||
17 | * License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public License | ||
20 | * along with the PdCom library. If not, see <http://www.gnu.org/licenses/>. | ||
21 | * | ||
22 | *****************************************************************************/ | ||
23 | |||
24 | #include "Variable.h" | ||
25 | |||
26 | #include "Channel.h" | ||
27 | #include "Parameter.h" | ||
28 | #include "ProtocolHandler.h" | ||
29 | |||
30 | #include <cstring> | ||
31 | #include <pdcom5/Exception.h> | ||
32 | #include <sstream> | ||
33 | |||
34 | using PdCom::impl::MsrProto::Channel; | ||
35 | using PdCom::impl::MsrProto::Parameter; | ||
36 | using PdCom::impl::MsrProto::Variable; | ||
37 | |||
38 | |||
39 | 377 | Variable::Variable( | |
40 | PdCom::SizeInfo size_info, | ||
41 | const PdCom::TypeInfo *type_info, | ||
42 | std::weak_ptr<PdCom::impl::Process> process, | ||
43 | unsigned int index, | ||
44 | unsigned taskId, | ||
45 | bool writeable, | ||
46 | double sampleTime, | ||
47 | const char *alias, | ||
48 | bool isDir, | ||
49 | 377 | bool is_parameter) : | |
50 | PdCom::impl::Variable(size_info, type_info, process), | ||
51 | DirNode(isDir), | ||
52 | is_parameter_(is_parameter), | ||
53 | index_(index), | ||
54 | sample_time_(sampleTime), | ||
55 | task_id_(taskId), | ||
56 | writeable_(writeable), | ||
57 |
3/6✓ Branch 5 taken 377 times.
✗ Branch 6 not taken.
✓ Branch 14 taken 377 times.
✗ Branch 15 not taken.
✓ Branch 36 taken 377 times.
✗ Branch 37 not taken.
|
377 | alias_(alias) |
58 | 377 | {} | |
59 | |||
60 | 43 | PdCom::Variable::SetValueFuture Parameter::setValue( | |
61 | const void *src, | ||
62 | PdCom::TypeInfo::DataType t, | ||
63 | size_t idx, | ||
64 | size_t n) const | ||
65 | { | ||
66 |
2/4✓ Branch 3 taken 43 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 43 times.
|
43 | if (const auto p = process.lock()) { |
67 |
1/2✓ Branch 5 taken 43 times.
✗ Branch 6 not taken.
|
43 | auto &h = p->protocolHandler<ProtocolHandler>(); |
68 |
2/4✓ Branch 3 taken 43 times.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 43 times.
|
86 | return h.writeParameter(*this, src, t, idx, n); |
69 | } | ||
70 | ✗ | throw PdCom::ProcessGoneAway(); | |
71 | } | ||
72 | |||
73 | |||
74 | ✗ | PdCom::Variable::SetValueFuture Channel::setValue( | |
75 | const void * /* data */, | ||
76 | PdCom::TypeInfo::DataType /* t */, | ||
77 | size_t /* idx */, | ||
78 | size_t /* n */) const | ||
79 | { | ||
80 | ✗ | throw PdCom::InvalidArgument("Signals are read-only"); | |
81 | } | ||
82 |