/src/opendnp3/cpp/lib/src/master/EmptyResponseTask.cpp
Line | Count | Source |
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 "master/EmptyResponseTask.h" |
21 | | |
22 | | #include "master/TaskPriority.h" |
23 | | |
24 | | #include <utility> |
25 | | |
26 | | namespace opendnp3 |
27 | | { |
28 | | |
29 | | EmptyResponseTask::EmptyResponseTask(const std::shared_ptr<TaskContext>& context, |
30 | | IMasterApplication& app, |
31 | | std::string name, |
32 | | FunctionCode func, |
33 | | std::function<bool(HeaderWriter&)> format, |
34 | | Timestamp startExpiration, |
35 | | const Logger& logger, |
36 | | const TaskConfig& config) |
37 | 0 | : IMasterTask(context, app, TaskBehavior::SingleExecutionNoRetry(startExpiration), logger, config), |
38 | 0 | name(std::move(name)), |
39 | 0 | func(func), |
40 | 0 | format(std::move(format)) |
41 | 0 | { |
42 | 0 | } |
43 | | |
44 | | bool EmptyResponseTask::EmptyResponseTask::BuildRequest(APDURequest& request, uint8_t seq) |
45 | 0 | { |
46 | 0 | request.SetControl(AppControlField(true, true, false, false, seq)); |
47 | 0 | request.SetFunction(this->func); |
48 | 0 | auto writer = request.GetWriter(); |
49 | 0 | return format(writer); |
50 | 0 | } |
51 | | |
52 | | /*func, priority::USER_REQUEST, format*/ |
53 | | |
54 | | IMasterTask::ResponseResult EmptyResponseTask::ProcessResponse(const APDUResponseHeader& header, |
55 | | const ser4cpp::rseq_t& objects) |
56 | 0 | { |
57 | 0 | return ValidateNullResponse(header, objects) ? ResponseResult::OK_FINAL : ResponseResult::ERROR_BAD_RESPONSE; |
58 | 0 | } |
59 | | |
60 | | } // namespace opendnp3 |