Coverage Report

Created: 2025-08-29 06:15

/src/opendnp3/cpp/lib/src/master/AssignClassTask.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 "AssignClassTask.h"
21
22
#include "app/HeaderWriter.h"
23
24
#include "opendnp3/master/IMasterApplication.h"
25
26
namespace opendnp3
27
{
28
29
AssignClassTask::AssignClassTask(const std::shared_ptr<TaskContext>& context,
30
                                 IMasterApplication& application,
31
                                 const TaskBehavior& behavior,
32
                                 const Logger& logger)
33
6.81k
    : IMasterTask(context, application, behavior, logger, TaskConfig::Default())
34
6.81k
{
35
6.81k
}
36
37
bool AssignClassTask::BuildRequest(APDURequest& request, uint8_t seq)
38
0
{
39
0
    request.SetControl(AppControlField(true, true, false, false, seq));
40
0
    request.SetFunction(FunctionCode::ASSIGN_CLASS);
41
0
    auto writer = request.GetWriter();
42
43
0
    bool success = true;
44
0
    auto writeFun = [&](const Header& header) { success &= header.WriteTo(writer); };
45
46
0
    this->application->ConfigureAssignClassRequest(writeFun);
47
0
    return success;
48
0
}
49
50
bool AssignClassTask::IsEnabled() const
51
20.4k
{
52
20.4k
    return this->application->AssignClassDuringStartup();
53
20.4k
}
54
55
IMasterTask::ResponseResult AssignClassTask::ProcessResponse(const APDUResponseHeader& header,
56
                                                             const ser4cpp::rseq_t& objects)
57
0
{
58
0
    return ValidateNullResponse(header, objects) ? ResponseResult::OK_FINAL : ResponseResult::ERROR_BAD_RESPONSE;
59
0
}
60
61
} // namespace opendnp3