...
 
Commits (2)
<module name="pfc200">
<driver class="pfc200::Pfc200Driver"/>
<driver class="pfc200::TcpPfc200Driver"/>
</module>
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "PerfectPfc200Driver.h"
namespace pfc200 {
PerfectPfc200Driver::PerfectPfc200Driver(Pfc200Driver* owner) : Pfc200State(owner) {
}
PerfectPfc200Driver::~PerfectPfc200Driver() {
}
void PerfectPfc200Driver::init() {
//owner()->status =0;
}
void PerfectPfc200Driver::read() {
}
void PerfectPfc200Driver::start() {
owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
}
void PerfectPfc200Driver::stop() {
//Note: there is not a stop
owner()->commandStatus.setIdle();
owner()->commandProgression = 100;
}
/*
* moveSinu
*/
void PerfectPfc200Driver::squareMove() {
}
/*
* speedMove
*/
void PerfectPfc200Driver::pulseMove() {
}
/*
* PositionMove
*/
void PerfectPfc200Driver::continuMove() {
}
void PerfectPfc200Driver::readStatus() {
owner()->startActivated = false;
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef PERFECTPFC200DRIVER_H
#define PERFECTPFC200DRIVER_H
#include "Pfc200State.h"
namespace pfc200 {
/**
* Perfect Implementation part of the Pfc200.
*/
class PerfectPfc200Driver : public Pfc200State {
public:
/**
* Constructor.
*
* @param Link to the class which used the state
*/
PerfectPfc200Driver(Pfc200Driver* owner);
/**
* Destructor.
*/
virtual ~PerfectPfc200Driver();
/**
* Initialization of the device.
*/
virtual void init();
/**
* Read values
*/
virtual void read();
/**
* Starts the device.
*/
virtual void start();
/**
* Stop the execution.
*/
virtual void stop();
/*!
* \brief Speed move command implementation
*/
virtual void squareMove();
/*!
* \brief Implement sinusoidal move command implementation
*/
virtual void pulseMove();
/*
* Position move command implementation
*/
virtual void continuMove();
/**
* Read status
*/
virtual void readStatus();
private:
};
}
#endif
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef PFC200DEF_H
#define PFC200DEF_H
namespace pfc200 {
static const int32 STATUS_REGISTER = 0x0000;
static const int32 ACTUAL_POSITION_REGISTER = 0x0001;
static const int32 LOC_ERROR_REGISTER = 0x0002;
static const int32 ID_ERROR_REGISTER = 0x0003;
static const int32 ACTUAL_SQUARE_SEQ_LSB_REGISTER = 0x0004;
static const int32 ACTUAL_SQUARE_SEQ_MSB_REGISTER = 0x0005;
static const int32 ACTUAL_PULSE_SEQ_LSB_REGISTER = 0x0006;
static const int32 ACTUAL_PULSE_SEQ_MSB_REGISTER = 0x0007;
static const int32 ACTUAL_CONTINU_SEQ_REGISTER = 0x0008;
static const int32 REMAINING_TIME_SQUARE_LSB_REGISTER = 0x0009;
static const int32 REMAINING_TIME_SQUARE_MSB_REGISTER = 0x000A;
static const int32 REMAINING_TIME_PULSE_LSB_REGISTER = 0x000B;
static const int32 REMAINING_TIME_PULSE_MSB_REGISTER = 0x000C;
static const int32 REMAINING_TIME_CONTINU_LSB_REGISTER = 0x000D;
static const int32 REMAINING_TIME_CONTINU_MSB_REGISTER = 0x000E;
static const int32 COMMAND_REGISTER = 0x00032;
static const int32 WANTED_SQUARE_SEQ_LSB_REGISTER = 0x0033;
static const int32 WANTED_SQUARE_SEQ_MSB_REGISTER = 0x0034;
static const int32 WANTED_SQUARE_ANGLE1_REGISTER = 0x0035;
static const int32 WANTED_SQUARE_SPEED1_REGISTER = 0x0036;
static const int32 WANTED_SQUARE_TIME1_LSB_REGISTER = 0x0037;
static const int32 WANTED_SQUARE_TIME1_MSB_REGISTER = 0x0038;
static const int32 WANTED_SQUARE_ANGLE2_REGISTER = 0x0039;
static const int32 WANTED_SQUARE_SPEED2_REGISTER = 0x003A;
static const int32 WANTED_SQUARE_TIME2_LSB_REGISTER = 0x003B;
static const int32 WANTED_SQUARE_TIME2_MSB_REGISTER = 0x003C;
static const int32 WANTED_PULSE_SEQ_LSB_REGISTER = 0x003D;
static const int32 WANTED_PULSE_SEQ_MSB_REGISTER = 0x003E;
static const int32 WANTED_PULSE_ANGLE_REGISTER = 0x003F;
static const int32 WANTED_PULSE_SPEED_REGISTER = 0x0040;
static const int32 WANTED_PULSE_TIME_LSB_REGISTER = 0x0041;
static const int32 WANTED_PULSE_TIME_MSB_REGISTER = 0x0042;
static const int32 WANTED_CONTINU_SEQ_REGISTER = 0x0043;
static const int32 WANTED_CONTINU_PARAM_REGISTER = 0x0044;
static const int32 WANTED_CONTINU_OFFSET_REGISTER = 0x0003;
static const int32 WANTED_CONTINU_TIME_LSB_OFFSET_REGISTER = 0x0001;
static const int32 WANTED_CONTINU_TIME_MSB_OFFSET_REGISTER = 0x0002;
}
#endif //PFC200DEF_H
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "Pfc200Driver.h"
#include <math.h>
#include "Pfc200State.h"
#include "PerfectPfc200Driver.h"
#include "RealPfc200Driver.h"
#include "SimulatedPfc200Driver.h"
#include "DeviceContainer/Def/CommandDef.h"
#include "drivers/legacy/def/FunctionDef.h"
#include "drivers/global/DriversCommands.h"
#include "controllers/common/axis/AxisCommon.h"
using namespace boost;
namespace pfc200 {
const std::string Pfc200Driver::TYPE = "pfc200";
const int32 Pfc200Driver::STOP_MODE = 0;
const int32 Pfc200Driver::SQUARE_MODE = 1;
const int32 Pfc200Driver::PULSE_MODE = 2;
const int32 Pfc200Driver::CONTINU_MODE = 3;
const int32 Pfc200Driver::MOVE_MODE = 4;
Pfc200Driver::Pfc200Driver(const string& name) :
DeviceDriver(name) {
registerStates(new RealPfc200Driver(this), new PerfectPfc200Driver(this), new SimulatedPfc200Driver(this));
SpeedCommon::SpeedCommon::init(name);
squareSpeed1.init(this, SAVE, "actual_squareSpeed1", "wanted_squareSpeed1", "squareSpeed1");
squareAngle1.init(this, SAVE, "actual_squareAngle1", "wanted_squareAngle1", "squareAngle1");
squareTimems1.init(this, SAVE, "actual_squareTimems1", "wanted_squareTimems1", "squareTimems1");
squareSpeed2.init(this, SAVE, "actual_squareSpeed2", "wanted_squareSpeed2", "squareSpeed2");
squareAngle2.init(this, SAVE, "actual_squareAngle2", "wanted_squareAngle2", "squareAngle2");
squareTimems2.init(this, SAVE, "actual_squareTimems2", "wanted_squareTimems2", "squareTimems2");
pulseSpeed.init(this, SAVE, "actual_pulseSpeed", "wanted_pulseSpeed", "pulseSpeed");
pulseAngle.init(this, SAVE, "actual_pulseAngle", "wanted_pulseAngle", "pulseAngle");
pulseTimems.init(this, SAVE, "actual_pulseTimems", "wanted_pulseTimems", "pulseTimems");
continuSpeed.init(this, NOSAVE, "continuSpeed");
continuTimems.init(this, NOSAVE, "continuTimems");
idStatus.init(this, NOSAVE, "idStatus");
locStatus.init(this, NOSAVE, "locStatus");
actualSquareSeqNb.init(this, NOSAVE, "actualSquareSeqNb");
actualPulseSeqNb.init(this, NOSAVE, "actualPulseSeqNb");
actualContinuSeqNb.init(this, NOSAVE, "actualContinuSeqNb");
remainingTimeSquareSeq.init(this, NOSAVE, "remainingTimeSquareSeq");
remainingTimePulseSeq.init(this, NOSAVE, "remainingTimePulseSeq");
remainingTimeContinuSeq.init(this, NOSAVE, "remainingTimeContinuSeq");
status.init(this, NOSAVE, "status");
wantedSquareSeqNb.init(this, NOSAVE, "wantedSquareSeqNb");
wantedPulseSeqNb.init(this, NOSAVE, "wantedPulseSeqNb");
wantedContinuSeqNb.init(this, NOSAVE, "wantedContinuSeqNb");
seqNb.init(this, SAVE, "seqNb");
execMode.init(this, SAVE, "exec_mode");
ratio.init(this, SAVE, "ratio");
statusFunction.init(this, NOSAVE, "status_function");
registerRefresher(wantedContinuSeqNb, &Pfc200Driver::refreshwantedContinuSeqNb, this);
initCommand(COMMAND_READ_DEVICE_CONTAINER);
initCommand(COMMAND_STATUS_DEVICE_CONTAINER);
initCommand(COMMAND_START_DEVICE_CONTAINER);
initCommand(COMMAND_STOP_DEVICE_CONTAINER);
registerFunction(NONE_FUNCTION);
updateValue(DEVICE_TYPE_DEVICE_CONTAINER, string(LEAF_DEVICE_TYPE_DEVICE_CONTAINER));
registerSpyCommand(COMMAND_READ_DEVICE_CONTAINER, 2);
registerSpyCommand(COMMAND_STATUS_DEVICE_CONTAINER, 2);
registerObserverCommand(COMMAND_READ_DEVICE_CONTAINER, 1);
registerObserverCommand(COMMAND_STATUS_DEVICE_CONTAINER, 1);
}
Pfc200Driver::~Pfc200Driver() {
}
void Pfc200Driver::execute(const string& aCommand) {
if ((aCommand != COMMAND_STATUS_DEVICE_CONTAINER) && (aCommand != COMMAND_READ_DEVICE_CONTAINER)) {
commandProgression = PROGRESSION_UNKNOWNSTATE_DEVICE_CONTAINER;
}
Pfc200State * currentState = static_cast<Pfc200State *>(getCurrentState());
// Check command
if (aCommand == COMMAND_INIT_DEVICE_CONTAINER) {
currentState->init();
} else if (aCommand == COMMAND_READ_DEVICE_CONTAINER) {
currentState->read();
} else if (aCommand == COMMAND_STATUS_DEVICE_CONTAINER) {
currentState->readStatus();
} else if (aCommand == COMMAND_START_DEVICE_CONTAINER) {
startActivated = true;
currentState->start();
} else if (aCommand == COMMAND_STOP_DEVICE_CONTAINER) {
currentState->stop();
} else {
//Error bad command
}
}
void Pfc200Driver::refreshwantedContinuSeqNb(int32 number) throw (CannotSetValue) {
continuSpeed.resize(int32(number));
continuTimems.resize(int32(number)); //one per diaphragm
}
void Pfc200Driver::calculateProgression() {
}
/*
* openModbus
*/
void Pfc200Driver::openModbus() {
}
/*
* writeModbus
*/
void Pfc200Driver::writeModbus(int32 reg, int32 value) {
}
/*
* readModbus
*/
int32 Pfc200Driver::readModbus(int32 reg) {
return 0;
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef PFC200DRIVER_H
#define PFC200DRIVER_H
#include <Driver.h>
#include "controllers/common/axis/SpeedCommon.h"
#include "controllers/common/axis/AxisCommon.h"
#include "drivers/legacy/other/modbus/Modbus.h"
namespace pfc200 {
class Pfc200Driver : public axis::SpeedCommon {
friend class RealPfc200Driver;
friend class PerfectPfc200Driver;
public:
//! Driver type value
static const std::string TYPE;
/**
* Constructor.
*
* @param the name of device driver
*/
Pfc200Driver(const string& aName);
/**
* Destructor.
*/
virtual ~Pfc200Driver();
/**
* Execute the command on the device.
* The DeviceActionDriver class gives the command to the DeviceDriver.
* Each type of device have to interpret its command and call
* the write method.
*
* @param the command to apply on the device
*/
virtual void execute(const string& aCommand);
/**
* Calculate the progression state.
*/
void calculateProgression();
/**
* Properties
*/
Property<int32, SETPOINT> squareSpeed1;
Property<int32, SETPOINT> squareAngle1;
Property<int32, SETPOINT> squareTimems1;
Property<int32, SETPOINT> squareSpeed2;
Property<int32, SETPOINT> squareAngle2;
Property<int32, SETPOINT> squareTimems2;
Property<int32, SETPOINT> pulseSpeed;
Property<int32, SETPOINT> pulseAngle;
Property<int32, SETPOINT> pulseTimems;
DynamicProperty<int32> continuSpeed;
DynamicProperty<int32> continuTimems;
Property<int32> idStatus;
Property<int32> locStatus;
Property<int32> actualSquareSeqNb;
Property<int32> actualPulseSeqNb;
Property<int32> actualContinuSeqNb;
Property<int32> remainingTimeSquareSeq;
Property<int32> remainingTimePulseSeq;
Property<int32> remainingTimeContinuSeq;
Property<int32> status;
Property<int32> wantedSquareSeqNb;
Property<int32> wantedPulseSeqNb;
Property<int32> wantedContinuSeqNb;
Property<int32> seqNb;
Property<int32> execMode;
Property<int32> ratio;
Property<int32> statusFunction;
virtual void openModbus();
virtual void writeModbus(int32 reg, int32 value);
virtual int32 readModbus(int32 reg);
void refreshwantedContinuSeqNb(int32 number) throw (CannotSetValue);
static const int32 STOP_MODE;
static const int32 SQUARE_MODE;
static const int32 PULSE_MODE;
static const int32 CONTINU_MODE;
static const int32 MOVE_MODE;
private:
// void refreshWantedAmplitude(float64 value);
// void refreshWantedFrequency(float64 value);
};
}
#endif
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef PFC200STATE_H
#define PFC200STATE_H
#include "Pfc200Driver.h"
#include <Driver.h>
namespace pfc200 {
/**
* The class is the interface class describes in the pattern state implemented the Pfc200 Modbus device.
*/
class Pfc200State : public DriverState<Pfc200Driver> {
public:
/**
* Constructor
*
* @param the class which used the state
*/
Pfc200State(Pfc200Driver* owner) : DriverState<Pfc200Driver>(owner) {}
/**
* Destructor
*/
virtual ~Pfc200State() {}
/**
* Read the value.
*/
virtual void read() = 0;
/**
* Start the execution.
*/
virtual void start() = 0;
/**
* Stop the execution.
*/
virtual void stop() = 0;
/*!
* \brief Speed move command implementation
*/
virtual void squareMove()=0;
/*!
* \brief Implement sinusoidal move command implementation
*/
virtual void pulseMove()=0;
/*
* Position move command implementation
*/
virtual void continuMove()=0;
/**
* Read status.
*/
virtual void readStatus() = 0;
};
}
#endif
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "RealPfc200Driver.h"
#include "Pfc200Driver.h"
#include "Pfc200Def.h"
#include "drivers/legacy/other/modbus/Modbus.h"
#include "drivers/legacy/def/ModbusDef.h"
#include "Utilities/Calculations.h"
#include <cmath>
using namespace boost;
namespace pfc200 {
RealPfc200Driver::RealPfc200Driver(Pfc200Driver * owner) :
Pfc200State(owner) {
}
RealPfc200Driver::~RealPfc200Driver() {
}
void RealPfc200Driver::init() {
owner()->openModbus();
}
void RealPfc200Driver::read() {
// Read actual angle
int32 value = static_cast<int32>(owner()->readModbus(ACTUAL_POSITION_REGISTER));
owner()->actualPosition = value ;
usleep(10000);
owner()->status = static_cast<int32>(owner()->readModbus(STATUS_REGISTER));
usleep(10000);
// Read actual amplitude
owner()->locStatus = static_cast<int32>(owner()->readModbus(LOC_ERROR_REGISTER));
owner()->idStatus = static_cast<int32>(owner()->readModbus(ID_ERROR_REGISTER));
usleep(10000);
owner()->actualSquareSeqNb= (static_cast<int32>(owner()->readModbus(ACTUAL_SQUARE_SEQ_MSB_REGISTER))<< 16) + static_cast<int32>(owner()->readModbus(ACTUAL_SQUARE_SEQ_LSB_REGISTER));
usleep(10000);
owner()->actualPulseSeqNb= (static_cast<int32>(owner()->readModbus(ACTUAL_PULSE_SEQ_MSB_REGISTER))<< 16) + static_cast<int32>(owner()->readModbus(ACTUAL_PULSE_SEQ_LSB_REGISTER));
usleep(10000);
owner()->actualContinuSeqNb= static_cast<int32>(owner()->readModbus(ACTUAL_SQUARE_SEQ_MSB_REGISTER));
usleep(10000);
owner()->remainingTimeSquareSeq= (static_cast<int32>(owner()->readModbus(REMAINING_TIME_SQUARE_MSB_REGISTER))<< 16) + static_cast<int32>(owner()->readModbus(REMAINING_TIME_SQUARE_LSB_REGISTER));
usleep(10000);
owner()->remainingTimePulseSeq= (static_cast<int32>(owner()->readModbus(REMAINING_TIME_PULSE_MSB_REGISTER))<< 16) + static_cast<int32>(owner()->readModbus(REMAINING_TIME_PULSE_LSB_REGISTER));
usleep(10000);
owner()->remainingTimeContinuSeq= (static_cast<int32>(owner()->readModbus(REMAINING_TIME_CONTINU_MSB_REGISTER))<< 16) + static_cast<int32>(owner()->readModbus(REMAINING_TIME_CONTINU_LSB_REGISTER));
usleep(10000);
}
void RealPfc200Driver::start() {
owner()->commandStatus.setRunning();
owner()->commandProgression = 10;
cout << "RealPfc200Driver::start() " << endl;
if (owner()->execMode() == Pfc200Driver::SQUARE_MODE) {
squareMove();
} else if (owner()->execMode() == Pfc200Driver::PULSE_MODE) {
pulseMove();
} else if (owner()->execMode() == Pfc200Driver::CONTINU_MODE) {
continuMove();
}else {
cerr << "execution mode for PFC200 driver does not exist" << endl;
owner()->commandStatus.setError();
owner()->commandProgression = 100;
}
// //Note: there is not a stop
//owner()->commandStatus.setIdle();
// owner()->commandProgression = 100;
}
void RealPfc200Driver::stop() {
cout << "executing stop command" << endl;
if (owner()->execMode() == Pfc200Driver::SQUARE_MODE) {
owner()->writeModbus(COMMAND_REGISTER, STOP_SQUARE);
} else if (owner()->execMode() == Pfc200Driver::PULSE_MODE) {
owner()->writeModbus(COMMAND_REGISTER, STOP_PULSE);
} else if (owner()->execMode() == Pfc200Driver::CONTINU_MODE) {
owner()->writeModbus(COMMAND_REGISTER, STOP_CONTINU);
}
owner()->commandStatus.setIdle();
owner()->commandProgression = 100;
}
/*
* moveSinu
*/
void RealPfc200Driver::pulseMove() {
//Split
int32 vallsb = owner()->wantedPulseSeqNb() >> 16;
int32 valmsb = owner()->wantedPulseSeqNb() & 0x0000FFFF;
// Write registers
owner()->writeModbus(WANTED_PULSE_SEQ_LSB_REGISTER, vallsb);
usleep(10000);
owner()->writeModbus(WANTED_PULSE_SEQ_MSB_REGISTER, vallsb);
usleep(10000);
owner()->writeModbus(WANTED_PULSE_ANGLE_REGISTER, owner()->pulseAngle.setpoint());
usleep(10000);
owner()->writeModbus(WANTED_PULSE_SPEED_REGISTER, owner()->pulseSpeed.setpoint());
usleep(10000);
vallsb = owner()->pulseTimems() >> 16;
valmsb = owner()->pulseTimems() & 0x0000FFFF;
// Write registers
owner()->writeModbus(WANTED_PULSE_TIME_LSB_REGISTER, vallsb);
usleep(10000);
owner()->writeModbus(WANTED_PULSE_TIME_MSB_REGISTER, valmsb);
usleep(10000);
owner()->writeModbus(COMMAND_REGISTER, RUN_PULSE);
}
/*
* speedMove
*/
void RealPfc200Driver::squareMove() {
//Split
int32 vallsb = owner()->wantedSquareSeqNb() >> 16;
int32 valmsb = owner()->wantedSquareSeqNb() & 0x0000FFFF;
// Write registers
owner()->writeModbus(WANTED_SQUARE_SEQ_LSB_REGISTER, vallsb);
usleep(10000);
owner()->writeModbus(WANTED_SQUARE_SEQ_MSB_REGISTER, valmsb);
usleep(10000);
owner()->writeModbus(WANTED_SQUARE_ANGLE1_REGISTER, owner()->squareAngle1.setpoint());
usleep(10000);
owner()->writeModbus(WANTED_SQUARE_SPEED1_REGISTER, owner()->squareSpeed1.setpoint());
usleep(10000);
vallsb = owner()->squareTimems1() >> 16;
valmsb = owner()->squareTimems1() & 0x0000FFFF;
// Write registers
owner()->writeModbus(WANTED_SQUARE_TIME1_LSB_REGISTER, vallsb);
usleep(10000);
owner()->writeModbus(WANTED_SQUARE_TIME1_MSB_REGISTER, valmsb);
usleep(10000);
owner()->writeModbus(WANTED_SQUARE_ANGLE2_REGISTER, owner()->squareAngle2.setpoint());
usleep(10000);
owner()->writeModbus(WANTED_SQUARE_SPEED2_REGISTER, owner()->squareSpeed2.setpoint());
usleep(10000);
vallsb = owner()->squareTimems2() >> 16;
valmsb = owner()->squareTimems2() & 0x0000FFFF;
// Write registers
owner()->writeModbus(WANTED_SQUARE_TIME2_LSB_REGISTER, vallsb);
usleep(10000);
owner()->writeModbus(WANTED_SQUARE_TIME2_MSB_REGISTER, valmsb);
usleep(10000);
owner()->writeModbus(COMMAND_REGISTER, RUN_SQUARE);
}
/*
* Position move
*/
void RealPfc200Driver::continuMove() {
// Write registers
owner()->writeModbus(WANTED_CONTINU_SEQ_REGISTER, owner()->wantedContinuSeqNb());
usleep(10000);
for (int32 i = 0; i < owner()->wantedContinuSeqNb(); i++) {
owner()->writeModbus(WANTED_CONTINU_PARAM_REGISTER + i *WANTED_CONTINU_OFFSET_REGISTER , owner()->continuSpeed.get(i));
int32 vallsb = owner()->continuTimems.get(i) >> 16;
int32 valmsb = owner()->continuTimems.get(i) & 0x0000FFFF;
// Write registers
owner()->writeModbus(WANTED_CONTINU_PARAM_REGISTER + i *WANTED_CONTINU_OFFSET_REGISTER+WANTED_CONTINU_TIME_LSB_OFFSET_REGISTER, vallsb);
usleep(10000);
owner()->writeModbus(WANTED_CONTINU_PARAM_REGISTER + i *WANTED_CONTINU_OFFSET_REGISTER+WANTED_CONTINU_TIME_LSB_OFFSET_REGISTER, valmsb);
usleep(10000);
}
owner()->writeModbus(COMMAND_REGISTER, RUN_CONTINU);
}
void RealPfc200Driver::readStatus() {
// get status
int32 status = owner()->readModbus(STATUS_REGISTER);
int32 valueout = 0;
if (status & MOVING) {
valueout |= axis::AxisCommon::MOVING;
} else if (status & STOPPED) {
valueout |= axis::AxisCommon::BRAKE_ACTIVATED;
}
owner()->status.update(status);
owner()->axisStatus.update(valueout);
owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
stop();
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef REALPFC200DRIVER_H
#define REALPFC200DRIVER_H
#include "controllers/common/axis/AxisCommon.h"
#include "Pfc200State.h"
class Modbus;
namespace pfc200 {
/**
* Real Implementation part of the Pfc200.
*/
class RealPfc200Driver : public Pfc200State {
public:
/**
* Constructor.
*
* @param Link to the class which used the state
*/
RealPfc200Driver(Pfc200Driver* owner);
/**
* Destructor.
*/
virtual ~RealPfc200Driver();
/**
* Initialization of the device.
*/
virtual void init();
/**
* Read values
*/
virtual void read();
/**
* Start the execution.
*/
virtual void start();
/**
* Stop the execution.
*/
virtual void stop();
/*!
* \brief Speed move command implementation
*/
virtual void squareMove();
/*!
* \brief Implement sinusoidal move command implementation
*/
virtual void pulseMove();
/*
* Position move command implementation
*/
virtual void continuMove();
/**
* Read status
*/
virtual void readStatus();
private:
// System state regiters
// State
typedef enum {REG_ACTIVE, VAR_READY,VAR_ERROR,COM_OK,MOVING,STOPPED,SQUARE_READY,PULSE_READY,
CONTINU_READY,SQUARE_RUNNING,PULSE_RUNNING,CONTINU_RUNNING,SPARE1,SPARE2,
SPARE3,CONNECT_OK} State;
typedef enum {DISABLE_VAR,RESET_DEFAULT,RUN_SQUARE,RUN_PULSE,RUN_CONTINU,STOP_SQUARE,STOP_PULSE,STOP_CONTINU,ZERO,A,B,C,D,E,F,G} VarState;
};
}
#endif
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "SimulatedPfc200Driver.h"
#include <cmath>
using namespace boost;
using namespace common;
namespace pfc200 {
SimulatedPfc200Driver::SimulatedPfc200Driver(Pfc200Driver* owner) :
Pfc200State(owner) {
}
SimulatedPfc200Driver::~SimulatedPfc200Driver() {
}
void SimulatedPfc200Driver::init() {
}
void SimulatedPfc200Driver::read() {
}
void SimulatedPfc200Driver::start() {
owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
}
void SimulatedPfc200Driver::stop() {
//Note: there is not a stop
owner()->commandStatus.setIdle();
owner()->commandProgression = 100;
}
/*
* moveSinu
*/
void SimulatedPfc200Driver::squareMove() {
}
/*
* speedMove
*/
void SimulatedPfc200Driver::pulseMove() {
}
/*
* PositionMove
*/
void SimulatedPfc200Driver::continuMove() {
}
void SimulatedPfc200Driver::readStatus() {
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef SIMULATEDPFC200DRIVER_H
#define SIMULATEDPFC200DRIVER_H
#include <common/base/Date.h>
#include "Pfc200State.h"
namespace pfc200 {
/**
* Simulated Implementation part of the Pfc200.
*/
class SimulatedPfc200Driver : public Pfc200State {
public:
/**
* Constructor.
*
* @param Link to the class which used the state
*/
SimulatedPfc200Driver(Pfc200Driver* owner);
/**
* Destructor.
*/
virtual ~SimulatedPfc200Driver();
/**
* Initialization of the device.
*/
virtual void init();
/**
* Read values
*/
virtual void read();
/**
* Starts the device.
*/
virtual void start();
/**
* Stop the execution.
*/
virtual void stop();
/*!
* \brief Speed move command implementation
*/
virtual void squareMove();
/*!
* \brief Implement sinusoidal move command implementation
*/
virtual void pulseMove();
/*
* Position move command implementation
*/
virtual void continuMove();
/**
* Read status
*/
virtual void readStatus();
};
}
#endif
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "TcpPfc200Driver.h"
#include "Utilities/Calculations.h"
namespace pfc200 {
const std::string TcpPfc200Driver::TYPE = "TcpPfc200";
/*
* Constructor
*/
TcpPfc200Driver::TcpPfc200Driver(const std::string& name) :
Pfc200Driver(name) {
ModBusTCP::init(name);
registerParentFunction(TCP_FUNCTION);
}
/*
* Destructor
*/
TcpPfc200Driver::~TcpPfc200Driver() {
}
/*
* openModbus
*/
void TcpPfc200Driver::openModbus() {
openModBus(leafChannel());
}
/*
* writeModbus
*/
void TcpPfc200Driver::writeModbus(int32 reg, int32 value) {
writeMultipleRegister(reg, value, true);
}
/*
* readModbus
*/
int32 TcpPfc200Driver::readModbus(int32 reg) {
int32 i32;
i32 = readInt32HoldingRegister(reg, true);
i32 = Calculations::swapD32ByD16(i32);
usleep(10000);
return i32;
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef TCPPFC200DRIVER_H
#define TCPPFC200DRIVER_H
#include "Pfc200Driver.h"
#include "drivers/global/modbus/ModBusTCP.h"
namespace pfc200 {
/**
* Global Implementation of the vme card called StartStop made in Ill. It needs a board called Men A201.
*/
class TcpPfc200Driver: public Pfc200Driver, public driver::ModBusTCP {
friend class RealPfc200Driver;
friend class PerfectPfc200Driver;
public:
//! Driver type value
static const std::string TYPE;
/*!
* \brief Constructor
* \param[in] name the name of the device driver
*/
TcpPfc200Driver(const std::string& name);
/*!
* \brief Destructor
*/
virtual ~TcpPfc200Driver();
private:
virtual void openModbus();
virtual void writeModbus(int32 reg, int32 value);
virtual int32 readModbus(int32 reg);
};
}
#endif //TCPPFC200DRIVER_H
TcpPfc200.statusPrefix=Actual status:
TcpPfc200.actual_amplitudePrefix=actual amplitude
TcpPfc200.actual_offsetPrefix= actual offset
TcpPfc200.wanted_amplitudePrefix=wanted amplitude
TcpPfc200.wanted_speedPrefix=wanted speed
TcpPfc200.actual_speedPrefix=actual speed
TcpPfc200.actual_anglePrefix=actual angle
TcpPfc200.wanted_anglePrefix=wanted angle
TcpPfc200.actual_timePrefix=actual time(ms)
TcpPfc200.wanted_timePrefix=wanted time(ms)
TcpPfc200.actual_time1Prefix=actual time1(ms)
TcpPfc200.wanted_time1Prefix=wanted time1(ms)
TcpPfc200.actual_time2Prefix=actual tim2e(ms)
TcpPfc200.wanted_time2Prefix=wanted time2(ms)
TcpPfc200.wanted_speed1Prefix=wanted speed1
TcpPfc200.actual_speed1Prefix=actual speed1
TcpPfc200.wanted_speed2Prefix=wanted speed2
TcpPfc200.actual_speed2Prefix=actual speed2
TcpPfc200.wanted_offsetPrefix=wanted offset
TcpPfc200.wanted_frequencyPrefix=wanted frequency
TcpPfc200.actual_frequencyPrefix=actual frequency
TcpPfc200.actual_anglePrefix=actual angle
TcpPfc200.wanted_anglePrefix=wanted angle
TcpPfc200.actual_angle1Prefix=actual angle1
TcpPfc200.wanted_angle1Prefix=wanted angle1
TcpPfc200.actual_angle2Prefix=actual angle2
TcpPfc200.wanted_angle2Prefix=wanted angle2
TcpPfc200.pulse_onePrefix=pulse 1
TcpPfc200.pulse_twoPrefix=pulse 2
TcpPfc200.set_positionPrefix=position feedback
TcpPfc200.ratioPrefix=Ratio: 1 /
TcpPfc200.statusFunctionPrefix=Function status:
TcpPfc200.wanted_continuTimePrefix=Time
TcpPfc200.wanted_continuSpeedPrefix=Speed
TcpPfc200.actual_continuSeqPrefix=Actual Nb Seq
TcpPfc200.wanted_continuSeqPrefix=Wanted Nb Seq
#Combo mode
TcpPfc200.modeSquareValue=1
TcpPfc200.modeSquareLabel=Square mode
TcpPfc200.modePulseValue=2
TcpPfc200.modePulseLabel=Pulse mode
TcpPfc200.modeContinuValue=3
TcpPfc200.modeContinuLabel=Continu mode
#Values & Labels of Status
TcpPfc200.statusInitValue=0
TcpPfc200.statusInitLabel=Init
TcpPfc200.statusAttenteValue=10
TcpPfc200.statusAttenteLabel=Idle
TcpPfc200.statusSinusValue=20
TcpPfc200.statusSinusLabel=Sinus
TcpPfc200.statusSpeedValue=30
TcpPfc200.statusSpeedLabel=Speed
TcpPfc200.statusErrorValue=40
TcpPfc200.statusErrorLabel=Error
TcpPfc200.statusPositionValue=50
TcpPfc200.statusPositionLabel=Position
#Values & Labels of FunctionStatus
TcpPfc200.functionStatusIdleValue=0
TcpPfc200.functionStatusIdleLabel=Idle
TcpPfc200.functionStatusRunValue=1
TcpPfc200.functionStatusRunLabel=Run
#Groups
TcpPfc200.squareGroup=Square
TcpPfc200.pulseGroup=Pulse
TcpPfc200.statusGroup=Status
TcpPfc200.continuGroup=Continu
#Units
TcpPfc200.frequencyUnit=Hz
TcpPfc200.speedUnit=m/s
TcpPfc200.degreeUnit=~degree
TcpPfc200.timeUnit=ms
<controller_plugin_config type="TcpPfc200">
<image key="DOPPLER"/>
<settings view="TcpPfc200View.xml"/>
</controller_plugin_config>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<controller type="TcpPfc200">
<property name="actual_squareSpeed1" type="long" max_length="12">
<decimal_format nb_decimal_places="3"/>
</property>
<property name="wanted_squareSpeed1" type="long" max_length="12">
<decimal_format nb_decimal_places="3"/>
</property>
<property name="actual_squareAngle1" type="long" max_length="12">
<decimal_format nb_decimal_places="3"/>
</property>
<property name="wanted_squareAngle1" type="long" max_length="12">
<decimal_format nb_decimal_places="3"/>
</property>
<property name="actual_squareTimems1" type="long" max_length="12">
</property>
<property name="wanted_squareTimems1" type="long" max_length="12">
</property>
<property name="actual_squareSpeed2" type="long" max_length="12">
</property>
<property name="wanted_squareSpeed2" type="long" max_length="12">
</property>
<property name="actual_squareAngle2" type="long" max_length="12">
</property>
<property name="wanted_squareAngle2" type="long" max_length="12">
</property>
<property name="actual_squareTimems2" type="long" max_length="12">
</property>
<property name="wanted_squareTimems2" type="long" max_length="12">
</property>
<property name="actual_pulseSpeed" type="long" max_length="12">
</property>
<property name="wanted_pulseSpeed" type="long" max_length="12">
</property>
<property name="actual_pulseAngle" type="long" max_length="12">
</property>
<property name="wanted_pulseAngle" type="long" max_length="12">
</property>
<property name="actual_pulseTimems" type="long" max_length="12">
</property>
<property name="wanted_pulseTimems" type="long" max_length="12">
</property>
<dynamic_property name="continuSpeed" type="long" max_length="12">
</dynamic_property>
<dynamic_property name="continuTimems" type="long" max_length="12">
</dynamic_property>
<property name="idStatus" type="long" max_length="12">
</property>
<property name="locStatus" type="long" max_length="12">
</property>
<property name="actualSquareSeqNb" type="long" max_length="12">
</property>
<property name="actualPulseSeqNb" type="long" max_length="12">
</property>
<property name="actualContinuSeqNb" type="long" max_length="12">
</property>
<property name="wantedSquareSeqNb" type="long" max_length="12">
</property>
<property name="wantedPulseSeqNb" type="long" max_length="12">
</property>
<property name="wantedContinuSeqNb" type="long" max_length="12">
</property>
<property name="remainingTimeSquareSeq" type="long" max_length="12">
</property>
<property name="remainingTimePulseSeq" type="long" max_length="12">
</property>
<property name="remainingTimeContinuSeq" type="long" max_length="12">
</property>
<property name="status" type="long" max_length="12">
</property>
<property name="seqNb" type="long" max_length="12">
</property>
<property name="exec_mode" type="long" max_length="12">
</property>
</controller>
<plugin>
<controller type="TcpPfc200" role="TcpPfc2001" />
<group title="TcpPfc200.statusGroup">
<label role="TcpPfc2001" property="status" prefix="TcpPfc200.statusPrefix" valuesAndLabels="TcpPfc200.statusInit,TcpPfc200.statusAttente,TcpPfc200.statusSinus,TcpPfc200.statusSpeed,TcpPfc200.statusError,TcpPfc200.statusPosition"/>
</group>
<newLine />
<combo role="TcpPfc2001" property="exec_mode" valuesAndLabels="TcpPfc200.modeSquare,TcpPfc200.modePulse,TcpPfc200.modeContinu" />
<newLine />
<group title="TcpPfc200.squareGroup">
<label role="TcpPfc2001" property="actualSquareSeqNb" prefix="TcpPfc200.actual_continuSeqPrefix" />
<text role="TcpPfc2001" property="wantedSquareSeqNb" prefix="TcpPfc200.wanted_continuSeqPrefix" />
<newLine />
<label role="TcpPfc2001" property="actual_squareSpeed1" prefix="TcpPfc200.actual_speed1Prefix" suffix="TcpPfc200.speedUnit"/>
<text role="TcpPfc2001" property="wanted_squareSpeed1" prefix="TcpPfc200.wanted_speed1Prefix" suffix="TcpPfc200.speedUnit"/>
<newLine />
<label role="TcpPfc2001" property="actual_squareSpeed2" prefix="TcpPfc200.actual_speed2Prefix" suffix="TcpPfc200.speedUnit"/>
<text role="TcpPfc2001" property="wanted_squareSpeed2" prefix="TcpPfc200.wanted_speed2Prefix" suffix="TcpPfc200.speedUnit"/>
<newLine />
<label role="TcpPfc2001" property="actual_squareAngle1" prefix="TcpPfc200.actual_angle1Prefix" suffix="TcpPfc200.degreeUnit"/>
<text role="TcpPfc2001" property="wanted_squareAngle1" prefix="TcpPfc200.wanted_angle1Prefix" suffix="TcpPfc200.degreeUnit"/>
<newLine />
<label role="TcpPfc2001" property="actual_squareAngle2" prefix="TcpPfc200.actual_angl2ePrefix" suffix="TcpPfc200.degreeUnit"/>
<text role="TcpPfc2001" property="wanted_squareAngle2" prefix="TcpPfc200.wanted_angle2Prefix" suffix="TcpPfc200.degreeUnit"/>
<newLine />
<label role="TcpPfc2001" property="actual_squareTimems1" prefix="TcpPfc200.actual_time1Prefix" suffix="TcpPfc200.timeUnit"/>
<text role="TcpPfc2001" property="wanted_squareTimems1" prefix="TcpPfc200.wanted_time1Prefix" suffix="TcpPfc200.timeUnit"/>
<newLine />
<label role="TcpPfc2001" property="actual_squareTimems2" prefix="TcpPfc200.actual_time2Prefix" suffix="TcpPfc200.timeUnit"/>
<text role="TcpPfc2001" property="wanted_squareTimems2" prefix="TcpPfc200.wanted_time2Prefix" suffix="TcpPfc200.timeUnit"/>
</group>
<newLine />
<group title="TcpPfc200.pulseGroup">
<label role="TcpPfc2001" property="actualPulseSeqNb" prefix="TcpPfc200.actual_continuSeqPrefix" />
<text role="TcpPfc2001" property="wantedPulseSeqNb" prefix="TcpPfc200.wanted_continuSeqPrefix" />
<newLine />
<label role="TcpPfc2001" property="actual_pulseSpeed" prefix="TcpPfc200.actual_speedPrefix" suffix="TcpPfc200.speedUnit"/>
<text role="TcpPfc2001" property="wanted_pulseSpeed" prefix="TcpPfc200.wanted_speedPrefix" suffix="TcpPfc200.speedUnit"/>
<newLine />
<label role="TcpPfc2001" property="actual_pulseAngle" prefix="TcpPfc200.actual_anglePrefix" suffix="TcpPfc200.degreeUnit"/>
<text role="TcpPfc2001" property="wanted_pulseAngle" prefix="TcpPfc200.wanted_anglePrefix" suffix="TcpPfc200.degreeUnit"/>
<newLine />
<label role="TcpPfc2001" property="actual_pulseTimems" prefix="TcpPfc200.actual_timePrefix" suffix="TcpPfc200.timeUnit"/>
<text role="TcpPfc2001" property="wanted_pulseTimems" prefix="TcpPfc200.wanted_timePrefix" suffix="TcpPfc200.timeUnit"/>
</group>
<newLine />
<group title="TcpPfc200.continuGroup">
<label role="TcpPfc2001" property="actualContinuSeqNb" prefix="TcpPfc200.actual_continuSeqPrefix" />
<text role="TcpPfc2001" property="wantedContinuSeqNb" prefix="TcpPfc200.wanted_continuSeqPrefix" />
<newLine />
<dynamic_composite role="TcpPfc2001" properties="continuSpeed">
<text role="TcpPfc2001" property="continuSpeed" prefix="TcpPfc200.wanted_continuSpeedPrefix" />
</dynamic_composite>
<newLine />
<dynamic_composite role="TcpPfc2001" properties="continuTimems">
<text role="TcpPfc2001" property="continuTimems" prefix="TcpPfc200.wanted_continuTimePrefix" />
</dynamic_composite>
</group>
</plugin>