Commit 32ffaa18 authored by Cristina Cocho's avatar Cristina Cocho
Browse files
parents 2e02ba8b d85bf203
<module name="nomad3d">
<controller class="nomad3d::Nomad3DController"/>
<include path="$(NOMAD_HOME)/../NomadModules/src"/>
</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 "controllers/common/family/Families.h"
#include "contrib/rapidjson/document.h"
#include "contrib/rapidjson/reader.h"
#include "contrib/rapidjson/writer.h"
#include "contrib/rapidjson/prettywriter.h"
#include "Nomad3DController.h"
#include "InstrumentManager/InstrumentManager.h"
using namespace boost;
using namespace std;
using namespace rapidjson;
namespace nomad3d {
const string Nomad3DController::TYPE = "nomad3d_controller";
Nomad3DController::Nomad3DController(const string& name) :
ExperimentController(name), controller::Init(this) {
setFamily(family::HIDDEN);
axisPositions.init(this, NOSAVE, "axis_positions");
}
Nomad3DController::Nomad3DController(const Nomad3DController& controller) :
ExperimentController(controller) {
}
Nomad3DController::~Nomad3DController() {
}
void Nomad3DController::postConfiguration() {
}
void Nomad3DController::init() {
map<string, ExperimentController*> experimentControllersMap = InstrumentManager::getInstance()->getAllInstalledExperimentControllersMap();
map<string, ExperimentController*>::iterator it;
int i = 0;
for (it = experimentControllersMap.begin(); it != experimentControllersMap.end(); it++) {
if (dynamic_cast<axis::AxisController*>(it->second) != 0) {
axis::AxisController* controller = dynamic_cast<axis::AxisController*>(it->second);
controller->attach(this); //Attach it to in order to be able to receive propertyChanged events.
m_axisControllers.push_back(controller);
registerUpdater(controller->position, &Nomad3DController::updateActualPosition, this, i);
++i;
}
}
updateActualPosition(0);
}
void Nomad3DController::updateActualPosition(int32 i) {
PrettyWriter<StringBuffer> writer(s);
s.Clear();
writer.StartObject();
for (auto controller : m_axisControllers) {
writer.Key(controller->getName().c_str());
writer.Double(controller->position() - controller->position.offset());
}
writer.EndObject();
axisPositions = s.GetString();
}
}
/*
* 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 NOMAD3D_NOMAD3DCONTROLLER_H
#define NOMAD3D_NOMAD3DCONTROLLER_H
#include "controllers/common/axis/AxisController.h"
#include "contrib/rapidjson/stringbuffer.h"
#include <memory>
namespace nomad3d {
/**
* Class defining a controller for Nomad3D. The positions passed to the client integrate the offset.
*/
class Nomad3DController : public ExperimentController, public controller::Init {
public:
//! Type of controller
static const std::string TYPE;
Nomad3DController(const std::string& name);
Nomad3DController(const Nomad3DController& controller);
virtual ~Nomad3DController();
virtual void postConfiguration();
virtual void init();
void updateActualPosition(int32 i);
private:
std::vector<axis::AxisController*> m_axisControllers;
Property<std::string> axisPositions;
rapidjson::StringBuffer s;
};
}
#endif
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