GMLC-TDC / HELICS

@@ -125,9 +125,21 @@
Loading
125 125
126 126
void ValueFederateManager::addTarget(const Input& inp, const std::string& target)
127 127
{
128 +
    {
129 +
        auto iTHandle = inputTargets.lock();
130 +
        auto rng = iTHandle->equal_range(inp.handle);
131 +
        for (auto el = rng.first; el != rng.second; ++el) {
132 +
            if (el->second == target) {
133 +
                fed->logWarningMessage(std::string("Duplicate input targets detected for ") +
134 +
                                       inp.actualName + "::" + target);
135 +
                return;
136 +
            }
137 +
        }
138 +
    }
139 +
128 140
    coreObject->addSourceTarget(inp.handle, target);
141 +
    auto it = inputTargets.lock()->emplace(inp.handle, target);
129 142
    targetIDs.lock()->emplace(target, inp.handle);
130 -
    inputTargets.lock()->emplace(inp.handle, target);
131 143
}
132 144
133 145
void ValueFederateManager::removeTarget(const Publication& pub, const std::string& target)

@@ -251,8 +251,9 @@
Loading
251 251
                auto units = getOrDefault(sub, "unit", emptyStr);
252 252
                replaceIfMember(sub, "units", units);
253 253
                subAct = &registerInput(emptyStr, type, units);
254 +
                subAct->addTarget(key);
254 255
            }
255 -
            subAct->addTarget(key);
256 +
256 257
            loadOptions(this, sub, *subAct);
257 258
        }
258 259
    }

@@ -1147,18 +1147,20 @@
Loading
1147 1147
        case CMD_ADD_PUBLISHER: {
1148 1148
            auto* subI = interfaceInformation.getInput(cmd.dest_handle);
1149 1149
            if (subI != nullptr) {
1150 -
                subI->addSource(cmd.getSource(),
1151 -
                                cmd.name,
1152 -
                                cmd.getString(typeStringLoc),
1153 -
                                cmd.getString(unitStringLoc));
1154 -
                addDependency(cmd.source_id);
1150 +
                if (subI->addSource(cmd.getSource(),
1151 +
                                    cmd.name,
1152 +
                                    cmd.getString(typeStringLoc),
1153 +
                                    cmd.getString(unitStringLoc))) {
1154 +
                    addDependency(cmd.source_id);
1155 +
                }
1155 1156
            }
1156 1157
        } break;
1157 1158
        case CMD_ADD_SUBSCRIBER: {
1158 1159
            auto* pubI = interfaceInformation.getPublication(cmd.dest_handle);
1159 1160
            if (pubI != nullptr) {
1160 -
                pubI->subscribers.emplace_back(cmd.source_id, cmd.source_handle);
1161 -
                addDependent(cmd.source_id);
1161 +
                if (pubI->addSubscriber(cmd.getSource())) {
1162 +
                    addDependent(cmd.source_id);
1163 +
                }
1162 1164
            }
1163 1165
        } break;
1164 1166
        case CMD_ADD_DEPENDENCY:

@@ -38,6 +38,11 @@
Loading
38 38
    int32_t required_connections{0};  //!< the number of required connections 0 is no requirement
39 39
    /** check the value if it is the same as the most recent data and if changed, store it*/
40 40
    bool CheckSetValue(const char* dataToCheck, uint64_t len);
41 +
    /** add a new subscriber to the publication
42 +
   @return true if the subscriber was added false if duplicate
43 +
   */
44 +
    bool addSubscriber(global_handle newSubscriber);
45 +
41 46
    /** remove a subscriber*/
42 47
    void removeSubscriber(global_handle subscriberToRemove);
43 48
};

@@ -17,6 +17,17 @@
Loading
17 17
    return false;
18 18
}
19 19
20 +
bool PublicationInfo::addSubscriber(global_handle newSubscriber)
21 +
{
22 +
    for (const auto& sub : subscribers) {
23 +
        if (sub == newSubscriber) {
24 +
            return false;
25 +
        }
26 +
    }
27 +
    subscribers.push_back(newSubscriber);
28 +
    return true;
29 +
}
30 +
20 31
void PublicationInfo::removeSubscriber(global_handle subscriberToRemove)
21 32
{
22 33
    subscribers.erase(std::remove(subscribers.begin(), subscribers.end(), subscriberToRemove),

@@ -119,8 +119,10 @@
Loading
119 119
    bool updateTimeNextIteration(Time newTime);
120 120
    /** get the event based on the event queue*/
121 121
    Time nextValueTime() const;
122 -
    /** add a new source target to the input*/
123 -
    void addSource(global_handle newSource,
122 +
    /** add a new source target to the input
123 +
    @return true if the source was added false if duplicate
124 +
    */
125 +
    bool addSource(global_handle newSource,
124 126
                   const std::string& sourceName,
125 127
                   const std::string& stype,
126 128
                   const std::string& sunits);

@@ -110,13 +110,20 @@
Loading
110 110
    }
111 111
}
112 112
113 -
void InputInfo::addSource(global_handle newSource,
113 +
bool InputInfo::addSource(global_handle newSource,
114 114
                          const std::string& sourceName,
115 115
                          const std::string& stype,
116 116
                          const std::string& sunits)
117 117
{
118 +
    for (const auto& is : input_sources) {
119 +
        if (is == newSource) {
120 +
            return false;
121 +
        }
122 +
    }
123 +
    // clear this since it isn't well defined what the units are once a new source is added
118 124
    inputUnits.clear();
119 125
    inputType.clear();
126 +
120 127
    input_sources.push_back(newSource);
121 128
    source_info.emplace_back(sourceName, stype, sunits);
122 129
    data_queues.resize(input_sources.size());
@@ -124,10 +131,12 @@
Loading
124 131
    current_data_time.resize(input_sources.size(), {Time::minVal(), 0});
125 132
    deactivated.push_back(Time::maxVal());
126 133
    has_target = true;
134 +
    return true;
127 135
}
128 136
129 137
void InputInfo::removeSource(global_handle sourceToRemove, Time minTime)
130 138
{
139 +
    // the inputUnits and type are not determined anymore since the source list has changed
131 140
    inputUnits.clear();
132 141
    inputType.clear();
133 142
    for (size_t ii = 0; ii < input_sources.size(); ++ii) {
Files Coverage
src/helics 52.42%
Project Totals (210 files) 52.42%
12949.9
TRAVIS_OS_NAME=linux
1
codecov:
2
  notify:
3
    require_ci_to_pass: no
4
  branch: develop
5

6
coverage:
7
  precision: 2
8
  round: down
9
  range: '50...95'
10
  status:
11
    project: yes
12
    patch: yes
13
    changes: no
14

15
parsers:
16
  gcov:
17
    branch_detection:
18
      conditional: yes
19
      loop: yes
20
      method: no
21
      macro: no
22

23
comment:
24
  layout: 'header, diff'
25
  behavior: default
26
  require_changes: no
27

28
ignore:
29
  - 'ThirdParty'
30
  - 'examples'
31
  - 'tests'
32
  - 'interfaces'
33
  - 'src/helics/core/mpi'
34
  - '**/logger.*'
35
  - '**/loggerCore.*'
36
  - '**/zmqHelper.*'
37
  - 'src/helics/shared_api_library/internal/api_objects.h'
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading