This repository has been archived by the owner on Sep 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #323 from dnp3/feature/unsol-num-retries
Add support for configurable unsolicited response retries
- Loading branch information
Showing
30 changed files
with
708 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2013-2019 Automatak, LLC | ||
* | ||
* Licensed to Green Energy Corp (www.greenenergycorp.com) and Automatak | ||
* LLC (www.automatak.com) under one or more contributor license agreements. | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. Green Energy Corp and Automatak LLC license | ||
* this file to you under the Apache License, Version 2.0 (the "License"); you | ||
* may not use this file except in compliance with the License. You may obtain | ||
* a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef OPENDNP3_NUMRETRIES_H | ||
#define OPENDNP3_NUMRETRIES_H | ||
|
||
#include <cstddef> | ||
|
||
namespace opendnp3 | ||
{ | ||
|
||
/** | ||
* Unsolicited response number of retries | ||
*/ | ||
class NumRetries final | ||
{ | ||
public: | ||
static NumRetries Fixed(std::size_t maxNumRetries); | ||
static NumRetries Infinite(); | ||
|
||
bool Retry(); | ||
void Reset(); | ||
|
||
private: | ||
NumRetries(std::size_t maxNumRetries, bool isInfinite); | ||
|
||
std::size_t numRetries; | ||
std::size_t maxNumRetries; | ||
bool isInfinite; | ||
}; | ||
|
||
} // namespace opendnp3 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2013-2019 Automatak, LLC | ||
* | ||
* Licensed to Green Energy Corp (www.greenenergycorp.com) and Automatak | ||
* LLC (www.automatak.com) under one or more contributor license agreements. | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. Green Energy Corp and Automatak LLC license | ||
* this file to you under the Apache License, Version 2.0 (the "License"); you | ||
* may not use this file except in compliance with the License. You may obtain | ||
* a copy of the License at: | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "opendnp3/outstation/NumRetries.h" | ||
|
||
namespace opendnp3 | ||
{ | ||
|
||
NumRetries::NumRetries(std::size_t maxNumRetries, bool isInfinite) | ||
: numRetries(0), | ||
maxNumRetries(maxNumRetries), | ||
isInfinite(isInfinite) | ||
{ | ||
|
||
} | ||
|
||
NumRetries NumRetries::Fixed(std::size_t maxNumRetries) | ||
{ | ||
return NumRetries(maxNumRetries, false); | ||
} | ||
|
||
NumRetries NumRetries::Infinite() | ||
{ | ||
return NumRetries(0, true); | ||
} | ||
|
||
bool NumRetries::Retry() | ||
{ | ||
this->numRetries++; | ||
|
||
return this->isInfinite || this->numRetries <= this->maxNumRetries; | ||
} | ||
|
||
void NumRetries::Reset() | ||
{ | ||
this->numRetries = 0; | ||
} | ||
|
||
}; // namespace opendnp3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.