Commit 6183e08f authored by Locatelli's avatar Locatelli
Browse files

remove file_text widget:

use text widget
check directory if existed, or create it
parent c8337b55
......@@ -18,6 +18,7 @@
#include "controllers/common/family/Families.h"
#include "CyclopsDataPath.h"
#include <boost/filesystem/operations.hpp>
namespace cyclops {
......@@ -58,18 +59,64 @@ void CyclopsDataPath::postConfiguration() {
* start
*/
void CyclopsDataPath::start() {
m_CamDriver->fileDirectory = datapath();
m_CamDriver->fileName = dataname();
cout << "Dir -> " << datapath() << endl;
cout << "Name -> " << dataname() << endl;
commandProgression = 0;
commandStatus.setRunning();
// Create path in /users/data if not existed
boost::filesystem::path path = "/users/data";
path /= datapath();
if (boost::filesystem::is_regular_file(path)) {
log(Level::s_Error) << "error path name existed as regular file " << path.string() << endlog;
commandStatus.setError();
}
else {
if (boost::filesystem::is_directory(path) == false) {
boost::filesystem::create_directory(path);
log(Level::s_Info) << "create local data path " << path.string() << endlog;
}
m_CamDriver->fileDirectory = datapath();
m_CamDriver->fileName = dataname();
log(Level::s_Info) << "set data path " << datapath() << " and name " << dataname() << endlog;
commandStatus.setIdle();
}
commandProgression = 0;
}
/*
* updateNumor
*/
void CyclopsDataPath::updateNumor() {
cout << "Numor -> " << m_Title->numor() << endl;
m_CamDriver->numor = m_Title->numor();
}
/*
* test
*/
void CyclopsDataPath::test() {
using namespace utilities;
UnitTest test(this);
boost::filesystem::path tmp = "/users/data/CyclopsDataPathTest";
ofstream ofs;
ofs.open(tmp.string().c_str());
if (ofs.is_open()) {
ofs << "TEST" << endl;
ofs.close();
}
datapath = "CyclopsDataPathTest";
dataname = "nomad";
this->startCommand();
test.checkTrue(commandStatus.isError());
boost::filesystem::remove(tmp);
this->startCommand();
test.checkTrue(commandStatus.isIdle());
test.checkTrue(boost::filesystem::is_directory(tmp));
this->startCommand();
test.checkTrue(commandStatus.isIdle());
boost::filesystem::remove(tmp);
}
}
......@@ -78,6 +78,11 @@ private:
DriverPtr<psl::PslDriver> m_CamDriver;
ControllerPtr<acquisition::ExperimentData> m_Title;
/*!
* \brief implement unitary test
*/
virtual void test();
};
}
......
......@@ -64,6 +64,9 @@ void CyclopsFileCmd::parse(Items& items) throw (CannotSetValue, CommonCmdDef::Ba
controller->dataname = *items;
}
}
vector<CommandLineCommand> controllersToStart;
controllersToStart.push_back(CommandLineCommand(controller));
CommandLineManager::getInstance()->startControllers(START_COMMAND, controllersToStart, m_Parser->isSynchronized());
}
ostringstream buf1;
buf1 << "Cyclops data directory : " << controller->datapath();
......
cyclops_datapath.filePrefix=Tif
cyclops_datapath.datapathPrefix=Path
cyclops_datapath.datanamePrefix=Name
\ No newline at end of file
cyclops_datapath.datanamePrefix=Name
cyclops_datapath.fileWarningPrefix=Nothing called theta or gamma!
\ No newline at end of file
<plugin>
<controller type="cyclops_datapath" role="cyclops_datapath1"/>
<number_of_lines nb_lines="1"/>
<number_of_lines nb_lines="2"/>
<simple_label prefix="cyclops_datapath.filePrefix"/>
<file_text role="cyclops_datapath1" property="datapath" prefix="cyclops_datapath.datapathPrefix"/>
<text role="cyclops_datapath1" property="datapath" prefix="cyclops_datapath.datapathPrefix"/>
<text role="cyclops_datapath1" property="dataname" prefix="cyclops_datapath.datanamePrefix"/>
<newLine/>
<simple_label prefix="cyclops_datapath.fileWarningPrefix"/>
</plugin>
......@@ -2,7 +2,9 @@
<controller type="cyclops_datapath" role="cyclops_datapath1"/>
<simple_label prefix="cyclops_datapath.filePrefix"/>
<file_text role="cyclops_datapath1" property="datapath" prefix="cyclops_datapath.datapathPrefix"/>
<text role="cyclops_datapath1" property="datapath" prefix="cyclops_datapath.datapathPrefix"/>
<text role="cyclops_datapath1" property="dataname" prefix="cyclops_datapath.datanamePrefix"/>
<newLine/>
<simple_label prefix="cyclops_datapath.fileWarningPrefix"/>
</plugin>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment