Commit b45e99ba authored by Franck Cecillon's avatar Franck Cecillon

after test

parent 55e754ee
......@@ -36,13 +36,13 @@ const string OpeningV2::TYPE = "openingV2";
* constructor
*/
OpeningV2::OpeningV2(const string& name) :
ExperimentController(name), controller::Stoppable(this), controller::Read(this) {
ExperimentController(name), controller::Stoppable(this), controller::Read(this) {
setFamily(family::BEAM_PARAMETERS, family::CHOPPER);
// Init property
opening.init(this, SAVE| SCAN | SPY, "actual_opening", "wanted_opening", "OpeningV2");
opening.init(this, SAVE | SCAN | SPY, "actual_opening", "wanted_opening", "Opening");
ratio.init(this, SAVE, "ratio_speed");
speed.init(this, SAVE | SPY, "actual_speed", "wanted_speed", "Speed");
speedChopper1.init(this, NOSAVE, "actual_speed1", "wanted_speed1", "Speed1");
......@@ -56,13 +56,19 @@ OpeningV2::OpeningV2(const string& name) :
offsetOppening.init(this, SAVE, "offset_oppening");
indiceChopperMaster.init(this,SAVE, "indiceChopperMaster");
indiceChopperMaster.init(this, SAVE, "indiceChopperMaster");
indChopperActive.init(this, SAVE, "indChopperActive");
useSingleChopper.init(this, SAVE, "useSingleChopper");
indiceSingleChopper.init(this, SAVE, "indiceSingleChopper");
speedSingle.init(this, SAVE, "speedSingle");
phaseSingle.init(this, SAVE, "phaseSingle");
// Init drivers
m_NCSDriver.init(this, "ncs_driver");
m_NCSDriver.init(this, "ncs_driver");
registerFunction(TYPE);
useSingleChopper = false;
}
/*
......@@ -82,11 +88,9 @@ void OpeningV2::postConfiguration() {
registerRefresher(opening.setpoint, &OpeningV2::refreshWantedOpeningV2, this);
// Link with controller update
registerUpdater(m_NCSDriver->currentSpeed , &OpeningV2::updateSpeed, this);
registerUpdater(m_NCSDriver->currentPhase , &OpeningV2::updatePhase, this);
registerUpdater(m_NCSDriver->chopperStatus ,&OpeningV2::updateActualStatus, this);
registerUpdater(m_NCSDriver->currentSpeed, &OpeningV2::updateSpeed, this);
registerUpdater(m_NCSDriver->currentPhase, &OpeningV2::updatePhase, this);
registerUpdater(m_NCSDriver->chopperStatus, &OpeningV2::updateActualStatus, this);
// Progression
registerProgression(m_NCSDriver, &OpeningV2::updateProgression, this);
......@@ -106,26 +110,25 @@ void OpeningV2::refreshWantedOpeningV2(float64 value) throw (CannotSetValue) {
calculate_before(value);
}
// Chopper 1
void OpeningV2::updateSpeed(int32 ki){
if (ki == 1 ) {
speedChopper1 = m_NCSDriver->currentSpeed.get(ki);
speed = m_NCSDriver->currentSpeed.get(ki);
void OpeningV2::updateSpeed(int32 ki) {
if (ki == 0) {
speedChopper1 = m_NCSDriver->currentSpeed.get(ki);
speed = m_NCSDriver->currentSpeed.get(ki);
}else {
} else {
speedChopper2 = m_NCSDriver->currentSpeed.get(ki);
}
}
void OpeningV2::updatePhase(int32 ki) {
if (ki == 1 ) {
if (ki == 0) {
phaseChopper1 = m_NCSDriver->currentPhase.get(ki);
}else {
} else {
phaseChopper2 = m_NCSDriver->currentPhase.get(ki);
}
ComputeActualOpeningV2();
}
void OpeningV2::ComputeActualOpeningV2() {
float64 newopen = refForPickup() + phaseChopper1() - phaseChopper2() - (offsetOppening());
opening.update(newopen);
......@@ -143,7 +146,7 @@ void OpeningV2::updateProgression() {
commandProgression = lProgression;
}
void OpeningV2::calculate_before( float64 value) {
void OpeningV2::calculate_before(float64 value) {
if (ratio() == 0) {
ratio = 1;
}
......@@ -151,11 +154,10 @@ void OpeningV2::calculate_before( float64 value) {
speedChopper1.setpoint = speed.setpoint();
speedChopper2.setpoint = speed.setpoint() / ratio();
phaseChopper1.setpoint = refForOpeningV2();
phaseChopper2.setpoint = (-1 * value ) + refForPickup() + phaseChopper1.setpoint() - (offsetOppening() );
phaseChopper2.setpoint = (-1 * value) + refForPickup() + phaseChopper1.setpoint() - (offsetOppening());
}
void OpeningV2::calculate() {
if (ratio() == 0) {
ratio = 1;
......@@ -164,16 +166,15 @@ void OpeningV2::calculate() {
speedChopper1.setpoint = speed.setpoint();
speedChopper2.setpoint = speed.setpoint() / ratio();
phaseChopper1.setpoint = refForOpeningV2();
phaseChopper2.setpoint = (-1 * opening.setpoint()) + refForPickup() + phaseChopper1.setpoint() - (offsetOppening() );
phaseChopper2.setpoint = (-1 * opening.setpoint()) + refForPickup() + phaseChopper1.setpoint() - (offsetOppening());
}
void OpeningV2::setNewOffsetOppening(float64 value){
void OpeningV2::setNewOffsetOppening(float64 value) {
offsetOppening = value;
ComputeActualOpeningV2();
}
/*
* start
*/
......@@ -181,36 +182,51 @@ void OpeningV2::start() {
commandProgression = 0; // Set progression to 0
commandStatus.setRunning();
calculate();
if (useSingleChopper() == false) {
try {
indiceChopperMaster = chopper_ncs::IND_CH1 ;
m_NCSDriver->isSync = 1;
m_NCSDriver->isMaster = 1;
calculate();
m_NCSDriver->indChopperActive = chopper_ncs::IND_CH1 ;
m_NCSDriver->speed.setpoint = speedChopper1.setpoint();
m_NCSDriver->phase.setpoint = phaseChopper1.setpoint();
try {
indiceChopperMaster = chopper_ncs::IND_CH1;
m_NCSDriver->isSync = 1;
m_NCSDriver->isMaster = 1;
m_NCSDriver.execute(driver::START_COMMAND, true);
m_NCSDriver->indChopperActive = chopper_ncs::IND_CH1;
m_NCSDriver->speed.setpoint = speedChopper1.setpoint();
m_NCSDriver->phase.setpoint = phaseChopper1.setpoint();
m_NCSDriver->indChopperActive = chopper_ncs::IND_CH2 ;
m_NCSDriver->speed.setpoint = speedChopper2.setpoint();
m_NCSDriver->phase.setpoint = phaseChopper2.setpoint();
m_NCSDriver.execute(driver::START_COMMAND, true);
m_NCSDriver->indChopperActive = chopper_ncs::IND_CH2;
m_NCSDriver->speed.setpoint = speedChopper2.setpoint();
m_NCSDriver->phase.setpoint = phaseChopper2.setpoint();
/* Parallel::begin();
chopper1->startParallel(false);
chopper2->startParallel(false);
Parallel::end();*/
/* Parallel::begin();
chopper1->startParallel(false);
chopper2->startParallel(false);
Parallel::end();*/
} catch (CannotSetValue &e) {
cerr << " Chopper OpeningV2 Over limits" << endl;
}
} catch (CannotSetValue &e) {
cerr << " Chopper OpeningV2 Over limits" << endl;
}
log(Level::s_Info) << opening << endlog;
commandStatus.setIdle();
commandProgression = 100;
} else { // useSingeChopper true
log(Level::s_Info) << opening << endlog;
commandStatus.setIdle();
commandProgression = 100;
indiceChopperMaster = indiceSingleChopper();
m_NCSDriver->isSync = 0;
m_NCSDriver->isMaster = 1;
m_NCSDriver->indChopperActive = indiceSingleChopper();
m_NCSDriver->speed.setpoint = speedChopper1.setpoint();
m_NCSDriver->phase.setpoint = phaseChopper1.setpoint();
m_NCSDriver.execute(driver::START_COMMAND, true);
m_NCSDriver->isSync = 1;
}
}
/*
......@@ -229,7 +245,7 @@ void OpeningV2::stop() {
log(Level::s_Info) << "Stopped" << endlog;
}
void OpeningV2::updateActualStatus(int32 ki){
void OpeningV2::updateActualStatus(int32 ki) {
}
......
......@@ -26,7 +26,6 @@
namespace d17 {
/*!
* \class OpeningV2
* \brief lss instrument
......@@ -48,7 +47,6 @@ public:
*/
OpeningV2(const std::string& name);
/*!
* \brief Destructor
*/
......@@ -57,9 +55,9 @@ public:
/*!
* Properties
*/
Property<float64, SETPOINT> opening; //! config a integer to store the resolution config
Property<int32> ratio;
Property<int32, SETPOINT> speed;
Property<float64, SETPOINT> opening; //! config a integer to store the resolution config
Property<int32> ratio;
Property<int32, SETPOINT> speed;
Property<int32, SETPOINT> speedChopper1;
Property<int32, SETPOINT> speedChopper2;
Property<float64, SETPOINT> phaseChopper1;
......@@ -68,12 +66,16 @@ public:
Property<float64> refForPickup;
Property<std::string> chopper1Name;
Property<std::string> chopper2Name;
Property<float64 > offsetOppening;
Property<float64> offsetOppening;
Property<int32> indiceChopperMaster;
Property<int32> indChopperActive; //! speed property
Property<bool> useSingleChopper;
Property<int32> indiceSingleChopper;
Property<int32> speedSingle; //! speed property
Property<float64> phaseSingle; //! speed property
// ControllerPtr<chopper::ChopperController> chopper1; //! chopper CH1 link
// ControllerPtr<chopper::ChopperController> chopper2; //! chopper CH2 link
......@@ -113,14 +115,10 @@ protected:
*/
virtual void refreshWantedOpeningV2(float64 value) throw (CannotSetValue);
virtual void updateSpeed(int32 ki);
virtual void updatePhase(int32 ki);
virtual void updateActualStatus(int32 ki);
/*!
* \brief update the progression property from driver one
*/
......@@ -129,8 +127,7 @@ protected:
* \brief calculate : choice or calculate the good choppers parameters related to the resolution
*/
virtual void calculate();
virtual void calculate_before( float64 value);
virtual void calculate_before(float64 value);
virtual void ComputeActualOpeningV2();
};
......
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