Пример #1
0
void 
FindSCU
::find(DcmDataset const * query, Callback callback) const
{
    CFindRequest request(
        this->_association->get_association()->nextMsgID++,
        this->_affected_sop_class, DIMSE_PRIORITY_MEDIUM, query);
    this->_send(request, this->_affected_sop_class);
    
    // Receive the responses
    bool done = false;
    while(!done)
    {
        // FIXME: include progress callback
        auto response = this->_receive<CFindResponse>();

        if(response.get_message_id_being_responded_to() != request.get_message_id())
        {
            std::ostringstream message;
            message << "DIMSE: Unexpected Response MsgId: "
                    << response.get_message_id_being_responded_to()
                    << "(expected: " << request.get_message_id() << ")";
            throw Exception(message.str());
        }
        if(response.has_affected_sop_class_uid() &&
           response.get_affected_sop_class_uid() != request.get_affected_sop_class_uid())
        {
            std::ostringstream message;
            message << "DIMSE: Unexpected Response Affected SOP Class UID: "
                    << response.get_affected_sop_class_uid()
                    << " (expected: " << request.get_affected_sop_class_uid() << ")";
            throw Exception(message.str());
        }

        done = !DICOM_PENDING_STATUS(response.get_status());
        if(!done)
        {
            callback(response.get_data_set());
            // Response dataset is allocated in this->_receive,
            // free it now.
            response.delete_data_set();
        }
    }
}
Пример #2
0
void 
NSetSCU
::set(std::shared_ptr<DataSet> dataset) const
{
    auto request = std::make_shared<message::NSetRequest const>(
        this->_association.next_message_id(),
        this->_affected_sop_class,
        dataset->as_string(registry::RequestedSOPInstanceUID, 0),
        dataset);

    this->_association.send_message(request, this->_affected_sop_class);
    
    auto response = std::make_shared<message::NSetResponse const>(
        this->_association.receive_message());

    if(response->get_message_id_being_responded_to() != request->get_message_id())
    {
        std::ostringstream message;
        message << "DIMSE: Unexpected Response MsgId: "
                << response->get_message_id_being_responded_to()
                << "(expected: " << request->get_message_id() << ")";
        throw Exception(message.str());
    }
}