int IsmrmrdDumpGadget::process_config(ACE_Message_Block* mb)
    {
        file_prefix_ = file_prefix.value();
        if ( file_prefix_.empty() )
        {
            file_prefix_ = "ISMRMRD_DUMP";
        }

        append_timestamp_ = append_timestamp.value();

        //Generate filename
        if (append_timestamp_)
        {
            ismrmrd_file_name_ = file_prefix_ + std::string("_") + get_date_time_string() + std::string(".h5");
        }
        else
        {
            ismrmrd_file_name_ = file_prefix_ + std::string(".h5");
        }

        ismrmrd_dataset_ = boost::shared_ptr<ISMRMRD::Dataset>(new ISMRMRD::Dataset(ismrmrd_file_name_.c_str(), "dataset"));

        std::string xml_config(mb->rd_ptr());

        try {
            ismrmrd_dataset_->writeHeader(xml_config);
        }
        catch (...)
        {
            GDEBUG("Failed to write XML header to HDF file\n");
            return GADGET_FAIL;
        }

        return GADGET_OK;
    }
void CTeleSerialConsoleOverTcp::OnAccept()
{
    time_t timep;
    struct tm *p;
    time (&timep);
    p=localtime(&timep);

    char strDT[GET_DATE_TIME_STRING_DEFAULT_STR_LEN];

    Send(" hostname : " + Utility::GetLocalHostname() + "\n");
    Send(" address  : " + Utility::GetLocalAddress() + "\n");
    //tprintf(" datetime : %s\n", asctime(gmtime(&timep)));

    tprintf(" datetime : %s\n", get_date_time_string(strDT, NULL));

    Send("Number of sockets in list : " + Utility::l2string(Handler().GetCount()) + "\n");

    tprintf("\n(none) login:"******"CTeleSerialConsoleOverTcp::OnAccept:" << GetRemoteAddress() << ":" << GetRemotePort());
}
    int IsmrmrdDumpGadget::process_config(ACE_Message_Block* mb)
    {
        
        ISMRMRD::IsmrmrdHeader ismrmrd_header;
        ISMRMRD::deserialize(mb->rd_ptr(), ismrmrd_header);

        std::string measurement_id = "";
        std::string ismrmrd_filename = "";
        
        if ( ismrmrd_header.measurementInformation ) {
            if ( ismrmrd_header.measurementInformation->measurementID ) {
                measurement_id = *ismrmrd_header.measurementInformation->measurementID;
            }
        }

        GDEBUG("Measurement ID: %s\n", measurement_id.c_str());
        
        bf::path p(folder.value());

        if (!exists(p)) {
            try {
                bf::create_directory(p);
            } catch(...) {
                GERROR("Error caught trying to create folder %s\n", folder.value().c_str());
                return GADGET_FAIL;
            }
        } else {
            if (!is_directory(p)) {
                GERROR("Specified path is not a directory\n");
                return GADGET_FAIL;
            }
        }
        
        if ( file_prefix.value().empty() )
        {
            ismrmrd_filename = "ISMRMRD_DUMP";
        } else {
            ismrmrd_filename = file_prefix.value();
        }

        if (append_id.value() && measurement_id.size()) {
            ismrmrd_filename.append("_");
            ismrmrd_filename.append(measurement_id);
        }
        
        //Generate filename
        if (append_timestamp.value())
        {
            ismrmrd_filename.append("_");
            ismrmrd_filename.append(get_date_time_string());
        }

        ismrmrd_filename.append(".h5");

        p /= ismrmrd_filename;

        ismrmrd_filename = p.string();
        ismrmrd_dataset_ = boost::shared_ptr<ISMRMRD::Dataset>(new ISMRMRD::Dataset(ismrmrd_filename.c_str(), "dataset"));

        std::string xml_config(mb->rd_ptr());

        try {
            ismrmrd_dataset_->writeHeader(xml_config);
        }
        catch (...)
        {
            GDEBUG("Failed to write XML header to HDF file\n");
            return GADGET_FAIL;
        }

        return GADGET_OK;
    }