PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
ups_watch_scu.h
Go to the documentation of this file.
1
15#ifndef PACS_SERVICES_UPS_WATCH_SCU_HPP
16#define PACS_SERVICES_UPS_WATCH_SCU_HPP
17
18#include "ups_push_scu.h"
19#include "ups_watch_scp.h"
20
25
26#include <atomic>
27#include <chrono>
28#include <functional>
29#include <memory>
30#include <string>
31
32namespace kcenon::pacs::services {
33
34// =============================================================================
35// UPS Watch SCU Data Structures
36// =============================================================================
37
45 std::string workitem_uid;
46
48 bool deletion_lock{false};
49};
50
56 std::string workitem_uid;
57};
58
66 uint16_t event_type_id{0};
67
69 std::string workitem_uid;
70
73
75 std::string progress;
76
79
82
84 std::chrono::system_clock::time_point timestamp;
85};
86
92 std::chrono::milliseconds timeout{30000};
93};
94
95// =============================================================================
96// UPS Watch SCU Class
97// =============================================================================
98
132public:
133 // =========================================================================
134 // Construction
135 // =========================================================================
136
142 explicit ups_watch_scu(std::shared_ptr<di::ILogger> logger = nullptr);
143
150 explicit ups_watch_scu(const ups_watch_scu_config& config,
151 std::shared_ptr<di::ILogger> logger = nullptr);
152
153 ~ups_watch_scu() = default;
154
155 // Non-copyable, non-movable (due to atomic members)
156 ups_watch_scu(const ups_watch_scu&) = delete;
160
161 // =========================================================================
162 // Callback Configuration
163 // =========================================================================
164
170 using event_received_callback = std::function<void(
171 const ups_watch_event& event)>;
172
178
179 // =========================================================================
180 // N-ACTION Operations
181 // =========================================================================
182
195 const ups_subscribe_data& data);
196
206 const ups_unsubscribe_data& data);
207
215 network::association& assoc);
216
217 // =========================================================================
218 // N-EVENT-REPORT Handler
219 // =========================================================================
220
230 const network::dimse::dimse_message& event_rq);
231
232 // =========================================================================
233 // Statistics
234 // =========================================================================
235
236 [[nodiscard]] size_t subscribes_performed() const noexcept;
237 [[nodiscard]] size_t unsubscribes_performed() const noexcept;
238 [[nodiscard]] size_t events_received() const noexcept;
239
240 void reset_statistics() noexcept;
241
242private:
243 // =========================================================================
244 // Private Implementation
245 // =========================================================================
246
247 [[nodiscard]] network::Result<ups_result> send_watch_action(
248 network::association& assoc,
249 const std::string& sop_instance_uid,
250 uint16_t action_type_id);
251
252 [[nodiscard]] static ups_watch_event parse_event_dataset(
253 uint16_t event_type_id,
254 const std::string& workitem_uid,
255 const core::dicom_dataset& dataset);
256
257 [[nodiscard]] uint16_t next_message_id() noexcept;
258
259 // =========================================================================
260 // Private Members
261 // =========================================================================
262
263 std::shared_ptr<di::ILogger> logger_;
266 std::atomic<uint16_t> message_id_counter_{1};
267 std::atomic<size_t> subscribes_performed_{0};
268 std::atomic<size_t> unsubscribes_performed_{0};
269 std::atomic<size_t> events_received_{0};
270};
271
272} // namespace kcenon::pacs::services
273
274#endif // PACS_SERVICES_UPS_WATCH_SCU_HPP
DICOM Association management per PS3.8.
UPS Watch SCU service for subscribing to events on remote systems.
event_received_callback event_callback_
network::Result< ups_result > send_watch_action(network::association &assoc, const std::string &sop_instance_uid, uint16_t action_type_id)
size_t unsubscribes_performed() const noexcept
network::Result< ups_result > subscribe(network::association &assoc, const ups_subscribe_data &data)
Subscribe to UPS workitem events (N-ACTION Type 3)
std::atomic< size_t > unsubscribes_performed_
std::function< void( const ups_watch_event &event)> event_received_callback
Callback type for received event notifications.
size_t subscribes_performed() const noexcept
std::shared_ptr< di::ILogger > logger_
void set_event_received_callback(event_received_callback cb)
Set callback for received event notifications.
ups_watch_scu & operator=(const ups_watch_scu &)=delete
ups_watch_scu(ups_watch_scu &&)=delete
ups_watch_scu(const ups_watch_scu &)=delete
network::Result< ups_result > suspend_global(network::association &assoc)
Suspend global subscription (N-ACTION Type 5)
ups_watch_scu(std::shared_ptr< di::ILogger > logger=nullptr)
Construct UPS Watch SCU with default configuration.
std::atomic< size_t > subscribes_performed_
size_t events_received() const noexcept
std::atomic< uint16_t > message_id_counter_
network::Result< ups_result > unsubscribe(network::association &assoc, const ups_unsubscribe_data &data)
Unsubscribe from UPS workitem events (N-ACTION Type 4)
ups_watch_scu & operator=(ups_watch_scu &&)=delete
network::Result< ups_watch_event > handle_event_report(const network::dimse::dimse_message &event_rq)
Handle an N-EVENT-REPORT-RQ received from the SCP.
static ups_watch_event parse_event_dataset(uint16_t event_type_id, const std::string &workitem_uid, const core::dicom_dataset &dataset)
DICOM Dataset - ordered collection of Data Elements.
DIMSE message encoding and decoding.
Logger interface for dependency injection.
Result of a UPS SCU operation.
Data for N-ACTION subscribe request.
bool deletion_lock
Whether to request a deletion lock.
std::string workitem_uid
Workitem SOP Instance UID (empty for global subscription)
Data for N-ACTION unsubscribe request.
std::string workitem_uid
Workitem SOP Instance UID (empty for global unsubscription)
Parsed UPS event notification received from SCP.
uint16_t event_type_id
Event type ID (ups_event_state_report, ups_event_cancel_requested, etc.)
std::string workitem_uid
Workitem SOP Instance UID that triggered the event.
std::string procedure_step_state
New procedure step state (for state report events)
core::dicom_dataset event_info
Full event dataset (for custom processing)
std::string progress
Progress percentage (for progress report events)
std::chrono::system_clock::time_point timestamp
Timestamp when the event was received.
std::string cancellation_reason
Cancellation reason (for cancel requested events)
Configuration for UPS Watch SCU service.
std::chrono::milliseconds timeout
Timeout for receiving DIMSE response.
DICOM UPS (Unified Procedure Step) Push SCU service.
DICOM UPS Watch SCP service (subscription and event notification)