Commit e1436d9c authored by legoc's avatar legoc
Browse files

Removed calculate loop in VEXPController, using the calca1, calca2, ...

from IncidentBeam and TasScatteredBeam.
parent 9214b370
......@@ -25,9 +25,6 @@ namespace vexp {
const string VEXPController::TYPE = "vexp_controller";
const int32 VEXPController::PARAMETERS_OK = 1;
const int32 VEXPController::BAD_PARAMETERS = 2;
VEXPController::VEXPController(const string& name) :
ExperimentController(name), m_running(true), m_errorDuringCalculation(false) {
......@@ -66,7 +63,7 @@ VEXPController::VEXPController(const string& name) :
a5.init(this, NOSAVE, "a5");
a6.init(this, NOSAVE, "a6");
state.init(this, NOSAVE, "state");
calculationStatus.init(this, NOSAVE, "calculation_status");
errorMessage.init(this, NOSAVE, "error_message");
tasSettings.init(this, "tas_settings");
......@@ -97,7 +94,7 @@ VEXPController::~VEXPController() {
m_waitCondition.notify_one();
}
if (m_loopThread.get() != NULL) {
if (m_loopThread.get() != 0) {
m_loopThread->join();
}}
......@@ -113,6 +110,30 @@ void VEXPController::updateBMatrix() {
b.sendEvent();
}
void VEXPController::refreshKi(float64 value) {
// calca1, calca2, calcStatus are calculated by refresh.
incidentBeam->calcki = value;
a1 = incidentBeam->calca1();
a2 = incidentBeam->calca2();
// Copy the status.
calculationStatus.set(incidentBeam->calcStatus);
}
void VEXPController::refreshKf(float64 value) {
// calca1, calca2, calcStatus are calculated by refresh.
scatteredBeam->calckf = value;
a5 = scatteredBeam->calca5();
a6 = scatteredBeam->calca6();
// Copy the status.
calculationStatus.set(scatteredBeam->calcStatus);
}
void VEXPController::refreshFloat64Property(SimpleProperty<float64>& property, float64 value) {
// Update the value.
......@@ -144,67 +165,74 @@ void VEXPController::postConfiguration() {
updateUMatrix();
updateBMatrix();
qh.update(scattering->qh.setpoint());
qk.update(scattering->qk.setpoint());
ql.update(scattering->ql.setpoint());
en.update(scattering->en.setpoint());
qm.update(scattering->qm.setpoint());
ki.update(incidentBeam->ki.setpoint());
kf.update(scatteredBeam->kf.setpoint());
a1.update(a1Controller->position.setpoint());
a2.update(a2Controller->position.setpoint());
a3.update(a3Controller->position.setpoint());
a4.update(a4Controller->position.setpoint());
a5.update(a5Controller->position.setpoint());
a6.update(a6Controller->position.setpoint());
// Register the property updaters.
registerPropertyCopierByUpdate(tasSettings->as, as);
registerPropertyCopierByUpdate(tasSettings->bs, bs);
registerPropertyCopierByUpdate(tasSettings->cs, cs);
registerPropertyCopierByUpdate(tasSettings->aa, aa);
registerPropertyCopierByUpdate(tasSettings->bb, bb);
registerPropertyCopierByUpdate(tasSettings->cc, cc);
registerPropertyCopierByUpdate(tasSettings->ax, ax);
registerPropertyCopierByUpdate(tasSettings->ay, ay);
registerPropertyCopierByUpdate(tasSettings->az, az);
registerPropertyCopierByUpdate(tasSettings->bx, bx);
registerPropertyCopierByUpdate(tasSettings->by, by);
registerPropertyCopierByUpdate(tasSettings->bz, bz);
// Not used anymore
// qh.update(scattering->qh.setpoint());
// qk.update(scattering->qk.setpoint());
// ql.update(scattering->ql.setpoint());
// en.update(scattering->en.setpoint());
// qm.update(scattering->qm.setpoint());
//
// ki.update(incidentBeam->ki.setpoint());
// kf.update(scatteredBeam->kf.setpoint());
//
// a1.update(a1Controller->position.setpoint());
// a2.update(a2Controller->position.setpoint());
// a3.update(a3Controller->position.setpoint());
// a4.update(a4Controller->position.setpoint());
// a5.update(a5Controller->position.setpoint());
// a6.update(a6Controller->position.setpoint());
//
// // Register the property updaters.
// registerPropertyCopierByUpdate(tasSettings->as, as);
// registerPropertyCopierByUpdate(tasSettings->bs, bs);
// registerPropertyCopierByUpdate(tasSettings->cs, cs);
// registerPropertyCopierByUpdate(tasSettings->aa, aa);
// registerPropertyCopierByUpdate(tasSettings->bb, bb);
// registerPropertyCopierByUpdate(tasSettings->cc, cc);
// registerPropertyCopierByUpdate(tasSettings->ax, ax);
// registerPropertyCopierByUpdate(tasSettings->ay, ay);
// registerPropertyCopierByUpdate(tasSettings->az, az);
// registerPropertyCopierByUpdate(tasSettings->bx, bx);
// registerPropertyCopierByUpdate(tasSettings->by, by);
// registerPropertyCopierByUpdate(tasSettings->bz, bz);
registerUpdater(sample->uRef, &VEXPController::updateUMatrix, this);
registerUpdater(sample->b, &VEXPController::updateBMatrix, this);
registerPropertyCopierByUpdate(scattering->qh.setpoint, qh);
registerPropertyCopierByUpdate(scattering->qk.setpoint, qk);
registerPropertyCopierByUpdate(scattering->ql.setpoint, ql);
registerPropertyCopierByUpdate(scattering->en.setpoint, en);
registerPropertyCopierByUpdate(scattering->qm.setpoint, qm);
registerPropertyCopierByUpdate(incidentBeam->ki.setpoint, ki);
registerPropertyCopierByUpdate(scatteredBeam->kf.setpoint, kf);
registerPropertyCopierByUpdate(a1Controller->position.setpoint, a1);
registerPropertyCopierByUpdate(a2Controller->position.setpoint, a2);
registerPropertyCopierByUpdate(a3Controller->position.setpoint, a3);
registerPropertyCopierByUpdate(a4Controller->position.setpoint, a4);
registerPropertyCopierByUpdate(a5Controller->position.setpoint, a5);
registerPropertyCopierByUpdate(a6Controller->position.setpoint, a6);
// Register the refreshers.
registerRefresher(qh, &VEXPController::refreshFloat64Property, this, scattering->qh.setpoint);
registerRefresher(qk, &VEXPController::refreshFloat64Property, this, scattering->qk.setpoint);
registerRefresher(ql, &VEXPController::refreshFloat64Property, this, scattering->ql.setpoint);
registerRefresher(en, &VEXPController::refreshFloat64Property, this, scattering->en.setpoint);
registerRefresher(qm, &VEXPController::refreshFloat64Property, this, scattering->qm.setpoint);
registerRefresher(ki, &VEXPController::refreshFloat64Property, this, incidentBeam->ki.setpoint);
registerRefresher(kf, &VEXPController::refreshFloat64Property, this, scatteredBeam->kf.setpoint);
// Start the thread.
m_loopThread.reset(new thread(bind(&VEXPController::loop, this)));
// Not used anymore
// registerPropertyCopierByUpdate(scattering->qh.setpoint, qh);
// registerPropertyCopierByUpdate(scattering->qk.setpoint, qk);
// registerPropertyCopierByUpdate(scattering->ql.setpoint, ql);
// registerPropertyCopierByUpdate(scattering->en.setpoint, en);
// registerPropertyCopierByUpdate(scattering->qm.setpoint, qm);
//
// registerPropertyCopierByUpdate(incidentBeam->ki.setpoint, ki);
// registerPropertyCopierByUpdate(scatteredBeam->kf.setpoint, kf);
//
// registerPropertyCopierByUpdate(a1Controller->position.setpoint, a1);
// registerPropertyCopierByUpdate(a2Controller->position.setpoint, a2);
// registerPropertyCopierByUpdate(a3Controller->position.setpoint, a3);
// registerPropertyCopierByUpdate(a4Controller->position.setpoint, a4);
// registerPropertyCopierByUpdate(a5Controller->position.setpoint, a5);
// registerPropertyCopierByUpdate(a6Controller->position.setpoint, a6);
//
// // Register the refreshers.
// registerRefresher(qh, &VEXPController::refreshFloat64Property, this, scattering->qh.setpoint);
// registerRefresher(qk, &VEXPController::refreshFloat64Property, this, scattering->qk.setpoint);
// registerRefresher(ql, &VEXPController::refreshFloat64Property, this, scattering->ql.setpoint);
// registerRefresher(en, &VEXPController::refreshFloat64Property, this, scattering->en.setpoint);
// registerRefresher(qm, &VEXPController::refreshFloat64Property, this, scattering->qm.setpoint);
//
// registerRefresher(ki, &VEXPController::refreshFloat64Property, this, incidentBeam->ki.setpoint);
// registerRefresher(kf, &VEXPController::refreshFloat64Property, this, scatteredBeam->kf.setpoint);
registerRefresher(ki, &VEXPController::refreshKi, this);
registerRefresher(kf, &VEXPController::refreshKf, this);
// // Start the thread.
// m_loopThread.reset(new thread(bind(&VEXPController::loop, this)));
}
void VEXPController::loop() {
......@@ -238,10 +266,10 @@ void VEXPController::calculate() {
// Check if an error occurred.
if (m_errorDuringCalculation) {
state = BAD_PARAMETERS;
//state = BAD_PARAMETERS;
}
else {
state = PARAMETERS_OK;
//state = PARAMETERS_OK;
}
cout << "Calculate in " << (common::Date() - begin).getMilliseconds() << "ms" << endl;
......
......@@ -44,6 +44,11 @@ public:
void updateUMatrix();
void updateBMatrix();
void refreshKi(float64 value);
void refreshKf(float64 value);
// Not used anymore.
void refreshFloat64Property(SimpleProperty<float64>& property, float64 value);
virtual void postConfiguration();
......@@ -80,7 +85,7 @@ public:
Property<float64> a5;
Property<float64> a6;
Property<int32> state;
StatusProperty calculationStatus;
Property<std::string> errorMessage;
ControllerPtr<tas::TasSettings> tasSettings;
......@@ -102,14 +107,11 @@ protected:
virtual void updateError(ChangeAspect* aspect);
std::auto_ptr<boost::thread> m_loopThread;
std::auto_ptr<boost::thread> m_loopThread; // Not used
boost::mutex m_mutex;
boost::condition m_waitCondition;
bool m_running;
bool m_errorDuringCalculation;
static const int32 PARAMETERS_OK;
static const int32 BAD_PARAMETERS;
};
}
......
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