| 148 | } |
| 149 | |
| 150 | void notify() { |
| 151 | |
| 152 | vsomeip::byte_t its_data[10]; |
| 153 | uint32_t its_size = 1; |
| 154 | |
| 155 | while (running_) { |
| 156 | std::unique_lock its_lock(notify_mutex_); |
| 157 | notify_condition_.wait(its_lock, [this] { return is_offered_ || !running_; }); |
| 158 | |
| 159 | while (is_offered_ && running_) { |
| 160 | if (its_size == sizeof(its_data)) |
| 161 | its_size = 1; |
| 162 | |
| 163 | for (uint32_t i = 0; i < its_size; ++i) |
| 164 | its_data[i] = static_cast<uint8_t>(i); |
| 165 | |
| 166 | { |
| 167 | std::scoped_lock its_lock(payload_mutex_); |
| 168 | payload_->set_data(its_data, its_size); |
| 169 | |
| 170 | std::cout << "Setting event (Length=" << std::dec << its_size << ")." << std::endl; |
| 171 | app_->notify(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, SAMPLE_EVENT_ID, payload_); |
| 172 | } |
| 173 | |
| 174 | its_size++; |
| 175 | |
| 176 | std::this_thread::sleep_for(std::chrono::milliseconds(cycle_)); |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | private: |
| 182 | std::shared_ptr<vsomeip::application> app_; |