|
|
/*------------------------------------------------------------------------------
|
|
|
-- This file is a part of the QLop Software
|
|
|
-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
|
|
|
--
|
|
|
-- This program is free software; you can redistribute it and/or modify
|
|
|
-- it under the terms of the GNU General Public License as published by
|
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
|
|
-- (at your option) any later version.
|
|
|
--
|
|
|
-- This program is distributed in the hope that it will be useful,
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
-- GNU General Public License for more details.
|
|
|
--
|
|
|
-- You should have received a copy of the GNU General Public License
|
|
|
-- along with this program; if not, write to the Free Software
|
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
-------------------------------------------------------------------------------*/
|
|
|
/*-- Author : Alexis Jeandet
|
|
|
-- Mail : alexis.jeandet@member.fsf.org
|
|
|
----------------------------------------------------------------------------*/
|
|
|
|
|
|
#include "cassinidatadownloader.h"
|
|
|
#include "ui_cassinidatadownloader.h"
|
|
|
#include <filedownloader.h>
|
|
|
#include <QDir>
|
|
|
#include <QFileDialog>
|
|
|
#include <QFile>
|
|
|
|
|
|
CassiniDataDownloader::CassiniDataDownloader(QWidget *parent) :
|
|
|
QWidget(parent),
|
|
|
ui(new Ui::CassiniDataDownloader)
|
|
|
{
|
|
|
ui->setupUi(this);
|
|
|
m_xmlLoader = new ExpXmlDownLoader();
|
|
|
connect(this->ui->calendar,SIGNAL(activated(QDate)),this,SLOT(downloadData(QDate)));
|
|
|
connect(this->ui->LoadXmlFileQpb,SIGNAL(clicked()),this,SLOT(loadXmlFile()));
|
|
|
}
|
|
|
|
|
|
CassiniDataDownloader::~CassiniDataDownloader()
|
|
|
{
|
|
|
delete ui;
|
|
|
delete m_xmlLoader;
|
|
|
}
|
|
|
|
|
|
void CassiniDataDownloader::changeEvent(QEvent *e)
|
|
|
{
|
|
|
QWidget::changeEvent(e);
|
|
|
switch (e->type()) {
|
|
|
case QEvent::LanguageChange:
|
|
|
ui->retranslateUi(this);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void CassiniDataDownloader::downloadData(const QDate &date)
|
|
|
{
|
|
|
QDate tmpDate;
|
|
|
QStringList months=QStringList()<< "JAN" << "FEB" << "MAR" << "APR" << "MAY" << "JUN" << "JUI" << "AUG" << "SEP" << "OCT" << "NOV" << "DEC";
|
|
|
tmpDate.setDate(date.year(),date.month(),1);
|
|
|
int firstDayOfMonth=tmpDate.dayOfYear();
|
|
|
tmpDate.setDate(tmpDate.year(),tmpDate.month(),tmpDate.daysInMonth());
|
|
|
int lastDayOfMonth=tmpDate.dayOfYear();
|
|
|
QString link="http://ppi.pds.nasa.gov/ditdos/download?id=pds://PPI/CO-E_SW_J_S-MAG-3-RDR-FULL-RES-V1.0/DATA/" \
|
|
|
+ QString("%1").arg(date.year()) +"/" + QString("%1_%2_").arg(firstDayOfMonth,3).arg(lastDayOfMonth,3).replace(' ','0') \
|
|
|
+ months.at(date.month()-1) + "/" ;
|
|
|
qDebug()<<link;
|
|
|
QString dataFileName= QString("%1%2").arg(date.year()-2000,2).arg(date.dayOfYear(),3).replace(' ','0') + "_FGM_KRTP.TAB";
|
|
|
QString headerFileName= QString("%1%2").arg(date.year()-2000,2).arg(date.dayOfYear(),3).replace(' ','0') + "_FGM_KRTP.LBL";
|
|
|
// "_FGM_KRTP.TAB"
|
|
|
FileDownloader::downloadFile(link+dataFileName,QDir::homePath() +"/Téléchargements/"+dataFileName);
|
|
|
FileDownloader::downloadFile(link+headerFileName,QDir::homePath() +"/Téléchargements/"+headerFileName);
|
|
|
}
|
|
|
|
|
|
void CassiniDataDownloader::loadXmlFile()
|
|
|
{
|
|
|
QString file=QFileDialog::getOpenFileName();
|
|
|
if(QFile::exists(file))
|
|
|
{
|
|
|
if(m_xmlLoader->parseXml(file))
|
|
|
{
|
|
|
QList<QDate> daysToDl = m_xmlLoader->daysToDownload();
|
|
|
for(int i=0;i<daysToDl.count();i++)
|
|
|
{
|
|
|
downloadData(daysToDl.at(i));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|