Commits

dirtycold committed f4a46d8

refactored DeviceController related classes

AbstractDeviceController base class
BasicDeviceController basic implementation using Motioner and Scanner
DeviceParameter basic DeviceParameter focusing on convenience
of reading device realted parameters.
a BasicDeviceController can dynamically create
Devices according to it.
DeviceControllerManipulator a command player wrapper of DeviceController

Comments (0)

Files changed (9)

platform/DeviceController/DeviceController.pro

 
 SOURCES += \
     abstractdevicecontroller.cpp \
-    deviceparameter.cpp
+    deviceparameter.cpp \
+    basicdevicecontroller.cpp \
+    devicecontrollermanipulator.cpp
 
 HEADERS += \
     devicecontrollerglobal.h \
     abstractdevicecontroller.h \
-    deviceparameter.h
+    deviceparameter.h \
+    basicdevicecontroller.h \
+    devicecontrollermanipulator.h
 
 CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../Build -lInterpreter
 else:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../Build -lInterpreter

platform/DeviceController/abstractdevicecontroller.cpp

 	init();
 }
 
-AbstractDeviceController::AbstractDeviceController(const std::string name) :AbstractDevice(name)
+AbstractDeviceController::AbstractDeviceController(const std::string name):AbstractDevice(name)
 {
 	init();
 }
 
 short AbstractDeviceController::mount()
 {
-	motionerlist::const_iterator mit;
-	short status = OK;
-	for (mit = mlist.begin(); mit != mlist.end() && status == OK; mit++)
-	{
-		status = (*mit)->mount();
-	}
-	scannerlist::const_iterator sit;
-	for (sit = slist.begin(); sit != slist.end() && status == OK; sit++)
-	{
-		status = (*sit)->mount();
-	}
-	return status;
+	return OK;
 }
 
 short AbstractDeviceController::umount()
 {
-	motionerlist::const_iterator mit;
-	short status = OK;
-	for (mit = mlist.begin(); mit != mlist.end() && status == OK; mit++)
-	{
-		status = (*mit)->umount();
-	}
-	scannerlist::const_iterator sit;
-	for (sit = slist.begin(); sit != slist.end() && status == OK; sit++)
-	{
-		status = (*sit)->umount();
-	}
-	return status;
-}
-
-bool AbstractDeviceController::play(BaseCommand *c)
-{
-	switch (c->type())
-	{
-	case MovingCommand:
-		{
-			MoveCommand *t = dynamic_cast<MoveCommand *>(c);
-			uint id = t->motionerID;
-			if (id < mlist.size())
-			{
-				if (!t->hasExtent())
-					return mlist.at(id)->move(t->axis,t->delta);
-				else
-					return mlist.at(id)->move(t->axis,t->delta,t->isRelative,t->speed,t->startupSpeed,t->startupTime);
-			}
-			debug << "motionerID exceeds when moving." << endl;
-			return false;
-		}
-	case MarkingCommand:
-		{
-			MarkCommand *t = dynamic_cast<MarkCommand *>(c);
-			uint id = t->scannerID;
-			if (id < slist.size())
-			{
-				if (!c->hasExtent())
-					return slist.at(id)->mark(t->delta);
-				else
-					return slist.at(id)->mark(t->delta,t->isRelative,t->speed,t->depth);
-			}
-			debug << "scannerID exceeds when marking." << endl;
-			return false;
-		}
-	case JumpingCommand:
-		{
-			JumpCommand *t = dynamic_cast<JumpCommand *>(c);
-			uint id = t->scannerID;
-			if (id < slist.size())
-			{
-				if (!c->hasExtent())
-					return slist.at(id)->jump(t->delta);
-				else
-					return slist.at(id)->jump(t->delta,t->isRelative,t->speed,t->depth);
-			}
-			debug << "scannerID exceeds when jumping." << endl;
-			return false;
-		}
-	case StoppingCommand:
-		{
-			StopCommand *t = dynamic_cast<StopCommand *>(c);
-			switch (t->target)
-			{
-			case ControllerTarget:
-				return stopAll();
-				break;
-			case MotionerTarget:
-				{
-					uint id = t->targetID;
-					if (id < mlist.size())
-					{
-						return mlist.at(id)->stop(t->axis);
-					}
-					debug << "motionerID exceeds when stopping." << endl;
-					return false;
-				}
-			case ScannerTarget:
-				{
-					uint id = t->targetID;
-					if (id < slist.size())
-					{
-						return slist.at(id)->stop();
-					}
-					debug << "scannerID exceeds when stopping." << endl;
-					return false;
-				}
-			default:
-				break;
-			}
-		}
-	case LaseringCommand:
-		{
-			LaserCommand *t = dynamic_cast<LaserCommand *>(c);
-			uint id = t->scannerID;
-			if (id < slist.size())
-			{
-				return slist.at(id)->laser(t->state);
-			}
-			debug << "scannerID exceeds when toggling laser state." << endl;
-			return false;
-		}
-	case QueryingCommand:
-	case NullCommand:
-	default:
-		debug << "failed to play a command." << endl;
-		return false;
-		break;
-	}
-}
-
-bool AbstractDeviceController::stopAll()
-{
-	motionerlist::iterator mit;
-	scannerlist::iterator sit;
-	bool status = true;
-	for (mit = mlist.begin(); mit != mlist.end() && status == OK; mit++)
-	{
-		status = (*mit)->stopAll();
-	}
-	for (sit = slist.begin(); sit != slist.end() && status == OK; sit++)
-	{
-		status = (*sit)->stop();
-	}
-	return status;
+	return OK;
 }
 
 void AbstractDeviceController::init()
 {
-	/*
-	 * theoretically as many Motioners and Scanner can be new'd here
-	 * either manually or refering some rules eg. config file
-	 * do it as you wish.
-	 *
-	 * don't forget to delete them in exit()
-	 */
-	Motioner *m1 = new Motioner("vM0");
-	Motioner *m2 = new Motioner("vM1");
-	Motioner *m3 = new Motioner("vM2");
-	Scanner *s1 = new Scanner("vS0");
-	Scanner *s2 = new Scanner("vS1");
-	mlist.push_back(m1);
-	mlist.push_back(m2);
-	mlist.push_back(m3);
-	slist.push_back(s1);
-	slist.push_back(s2);
 }
 
 void AbstractDeviceController::exit()
 {
-	motionerlist::iterator mit;
-	for (mit = mlist.begin(); mit != mlist.end(); mit++)
-	{
-		delete (*mit);
-	}
-	scannerlist::iterator sit;
-	for (sit = slist.begin(); sit != slist.end(); sit++)
-	{
-		delete (*sit);
-	}
 }
 
 }

platform/DeviceController/abstractdevicecontroller.h

 	virtual short mount();
 	virtual short umount();
 
-	virtual bool play(BaseCommand *c);
-
-	virtual bool stopAll();
-
 protected:
 	/**
 	 * @brief init is for device construction before they are sent to m_deviceList
 	 * here you can also overload it, you can destroy every device in m_deviceList
 	 */
 	virtual void exit();
-	motionerlist mlist; // motioner list
-	scannerlist slist; // scanner list
-
-
-
 };
 
 }

platform/DeviceController/basicdevicecontroller.cpp

+#include "basicdevicecontroller.h"
+
+namespace RP {
+
+BasicDeviceController::BasicDeviceController()
+{
+	init();
+}
+
+BasicDeviceController::BasicDeviceController(const std::string name):AbstractDeviceController(name)
+{
+	init();
+}
+
+BasicDeviceController::~BasicDeviceController()
+{
+	exit();
+}
+
+short BasicDeviceController::mount()
+{
+	if (!isMounted)
+	{
+		motionerlist::const_iterator mit;
+		short status = OK;
+		for (mit = mlist.begin(); mit != mlist.end() && status == OK; mit++)
+		{
+			status = (*mit)->mount();
+		}
+		scannerlist::const_iterator sit;
+		for (sit = slist.begin(); sit != slist.end() && status == OK; sit++)
+		{
+			status = (*sit)->mount();
+		}
+		if (status == OK)
+			isMounted = true;
+		return status;
+	}
+	else
+	{
+		debug << "base device controller: "<< name << " mounted already." << endl;
+		return MountedAlready;
+	}
+
+}
+
+short BasicDeviceController::umount()
+{
+	if (isMounted)
+	{
+		motionerlist::const_iterator mit;
+		short status = OK;
+		for (mit = mlist.begin(); mit != mlist.end() && status == OK; mit++)
+		{
+			status = (*mit)->umount();
+		}
+		scannerlist::const_iterator sit;
+		for (sit = slist.begin(); sit != slist.end() && status == OK; sit++)
+		{
+			status = (*sit)->umount();
+		}
+		if (status == OK)
+			isMounted = false;
+		return status;
+	}
+	else
+	{
+		debug << "device controller: "<< name << " unmounted already." << endl;
+		return NotMounted;
+	}
+}
+
+bool BasicDeviceController::move(uint motionerID, uint axis, double delta)
+{
+	if (isMounted)
+	{
+		if (motionerID < mlist.size())
+		{
+			return mlist.at(motionerID)->move(axis,delta);
+		}
+		else
+		{
+			debug << "motionerID exceeds when moving." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+
+}
+
+bool BasicDeviceController::move(uint motionerID, uint axis, double delta, bool isRelative, double speed, double startupSpeed, double startupTime)
+{
+	if (isMounted)
+	{
+		if (motionerID < mlist.size())
+		{
+			return mlist.at(motionerID)->move(axis,delta,isRelative,speed,startupSpeed,startupTime);
+		}
+		else
+		{
+			debug << "motionerID exceeds when moving." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+bool BasicDeviceController::move(uint motionerID, std::vector<uint>& axises, std::vector<double>& deltas)
+{
+	if (isMounted)
+	{
+		if (motionerID < mlist.size())
+		{
+			return mlist.at(motionerID)->move(axises,deltas);
+		}
+		else
+		{
+			debug << "motionerID exceeds when moving." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+bool BasicDeviceController::stopMove(uint motionerID, uint axis)
+{
+	if (isMounted)
+	{
+		if (motionerID < mlist.size())
+		{
+			return mlist.at(motionerID)->stop(axis);
+		}
+		else
+		{
+			debug << "motionerID exceeds when stopping." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+bool BasicDeviceController::stopMove(uint motionerID)
+{
+	if (isMounted)
+	{
+		if (motionerID < mlist.size())
+		{
+			return mlist.at(motionerID)->stopAll();
+		}
+		else
+		{
+			debug << "motionerID exceeds when stopping." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+double BasicDeviceController::currentPosition(uint motionerID, uint axis)
+{
+	if (isMounted)
+	{
+		if (motionerID < mlist.size())
+		{
+			return mlist.at(motionerID)->currentPosition(axis);
+		}
+		else
+		{
+			debug << "motionerID exceeds when getting motioner position." << endl;
+			return NaN;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return NaN;
+	}
+}
+
+bool BasicDeviceController::laser(uint scannerID, bool state)
+{
+	if (isMounted)
+	{
+		if (scannerID < slist.size())
+		{
+			return slist.at(scannerID)->laser(state);
+		}
+		else
+		{
+			debug << "scannerID exceeds when toggling laser state." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+bool BasicDeviceController::jump(uint scannerID, const Point& p)
+{
+	if (isMounted)
+	{
+		if (scannerID < slist.size())
+		{
+			return slist.at(scannerID)->jump(p);
+		}
+		else
+		{
+			debug << "scannerID exceeds when jumpping." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+bool BasicDeviceController::jump(uint scannerID, const Point& p, bool isRelative, double speed, double depth)
+{
+	if (isMounted)
+	{
+		if (scannerID < slist.size())
+		{
+			return slist.at(scannerID)->jump(p,isRelative,speed,depth);
+		}
+		else
+		{
+			debug << "scannerID exceeds when jumpping." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+bool BasicDeviceController::jump(uint scannerID, const Contour& c)
+{
+	if (isMounted)
+	{
+		if (scannerID < slist.size())
+		{
+			return slist.at(scannerID)->jump(c);
+		}
+		else
+		{
+			debug << "scannerID exceeds when jumpping." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+bool BasicDeviceController::jumpZ(uint scannerID, const double z)
+{
+	if (isMounted)
+	{
+		if (scannerID < slist.size())
+		{
+			return slist.at(scannerID)->jumpZ(z);
+		}
+		else
+		{
+			debug << "scannerID exceeds when jumpping." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+bool BasicDeviceController::mark(uint scannerID, const Point& p)
+{
+	if (isMounted)
+	{
+		if (scannerID < slist.size())
+		{
+			return slist.at(scannerID)->mark(p);
+		}
+		else
+		{
+			debug << "scannerID exceeds when marking." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+bool BasicDeviceController::mark(uint scannerID, const Point& p, bool isRelative, double speed, double depth)
+{
+	if (isMounted)
+	{
+		if (scannerID < slist.size())
+		{
+			return slist.at(scannerID)->mark(p,isRelative,speed,depth);
+		}
+		else
+		{
+			debug << "scannerID exceeds when marking." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+bool BasicDeviceController::mark(uint scannerID, const Contour& c)
+{
+	if (isMounted)
+	{
+		if (scannerID < slist.size())
+		{
+			return slist.at(scannerID)->mark(c);
+		}
+		else
+		{
+			debug << "scannerID exceeds when marking." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+bool BasicDeviceController::stopScan(uint scannerID)
+{
+	if (isMounted)
+	{
+		if (scannerID < slist.size())
+		{
+			return slist.at(scannerID)->stop();
+		}
+		else
+		{
+			debug << "scannerID exceeds when stopping." << endl;
+			return false;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return false;
+	}
+}
+
+Point BasicDeviceController::currentPosition(uint scannerID) const
+{
+	if (isMounted)
+	{
+		if (scannerID < slist.size())
+		{
+			return slist.at(scannerID)->currentPosition();
+		}
+		else
+		{
+			debug << "scannerID exceeds when getting scanner position." << endl;
+			return Point(NaN,NaN);
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return Point(NaN,NaN);
+	}
+}
+
+double BasicDeviceController::currentDepth(uint scannerID) const
+{
+	if (isMounted)
+	{
+		if (scannerID < slist.size())
+		{
+			return slist.at(scannerID)->currentDepth();
+		}
+		else
+		{
+			debug << "scannerID exceeds when getting scanner depth." << endl;
+			return NaN;
+		}
+	}
+	else
+	{
+		debug << "device controller:" << name << " not mounted, command not functional." << endl;
+		return NaN;
+	}
+}
+
+bool BasicDeviceController::stopAll()
+{
+	motionerlist::iterator mit;
+	scannerlist::iterator sit;
+	bool status = true;
+	for (mit = mlist.begin(); mit != mlist.end() && status == OK; mit++)
+	{
+		status = (*mit)->stopAll();
+	}
+	for (sit = slist.begin(); sit != slist.end() && status == OK; sit++)
+	{
+		status = (*sit)->stop();
+	}
+	return status;
+}
+
+void BasicDeviceController::init()
+{
+	/*
+	 * theoretically as many Motioners and Scanner can be new'd here
+	 * either manually or refering some rules eg. config file
+	 * do it as you wish.
+	 *
+	 * don't forget to delete them in exit()
+	 */
+
+	devicecontrollerSetting = new DeviceParameter("device.cfg");
+	devicecontrollerSetting->read();
+
+	uint mCount = devicecontrollerSetting->getIntValue("motioner_count");
+	uint sCount = devicecontrollerSetting->getIntValue("scanner_count");
+	if (mCount)
+	{
+		for (uint i = 0; i<mCount; i++)
+		{
+			std::string name = devicecontrollerSetting->getDeviceValue(MotionerTarget,i,"name");
+			Motioner *m = new Motioner(name);
+			mlist.push_back(m);
+		}
+	}
+	if (sCount)
+	{
+		for (uint i = 0; i<mCount; i++)
+		{
+			std::string name = devicecontrollerSetting->getDeviceValue(ScannerTarget,i,"name");
+			Scanner *m = new Scanner(name);
+			slist.push_back(m);
+		}
+	}
+}
+
+void BasicDeviceController::exit()
+{
+	motionerlist::iterator mit;
+	for (mit = mlist.begin(); mit != mlist.end(); mit++)
+	{
+		delete (*mit);
+	}
+	scannerlist::iterator sit;
+	for (sit = slist.begin(); sit != slist.end(); sit++)
+	{
+		delete (*sit);
+	}
+}
+
+}

platform/DeviceController/basicdevicecontroller.h

+#ifndef BASICDEVICECONTROLLER_H
+#define BASICDEVICECONTROLLER_H
+
+#include "abstractdevicecontroller.h"
+#include "deviceparameter.h"
+
+namespace RP {
+
+class BasicDeviceController : public AbstractDeviceController
+{
+public:
+	BasicDeviceController();
+	BasicDeviceController(const std::string name);
+	virtual ~BasicDeviceController();
+	
+	virtual short mount();
+	virtual short umount();
+	
+	//wrapper methods
+	//motioner
+	virtual bool move(uint motionerID, uint axis, double delta);
+	virtual bool move(uint motionerID, uint axis, double delta, bool isRelative, double speed, double startupSpeed, double startupTime);
+	virtual bool move(uint motionerID, std::vector<uint> &axises,std::vector<double> &deltas);
+    virtual bool stopMove(uint motionerID, uint axis);
+    virtual bool stopMove(uint motionerID);
+    virtual double currentPosition(uint motionerID, uint axis);
+	//scanner
+	virtual bool laser(uint scannerID, bool state);
+	virtual bool jump(uint scannerID, const Point &p);
+	virtual bool jump(uint scannerID, const Point &p, bool isRelative, double speed, double depth);
+    virtual bool jump(uint scannerID, const Contour &c);
+	virtual bool jumpZ(uint scannerID, const double z);
+    virtual bool mark(uint scannerID, const Point &p);
+	virtual bool mark(uint scannerID, const Point &p, bool isRelative, double speed, double depth);
+    virtual bool mark(uint scannerID, const Contour &c);
+	virtual bool stopScan(uint scannerID);
+	
+	virtual Point currentPosition(uint scannerID) const;
+    virtual double currentDepth(uint scannerID) const;
+	
+	//integration
+	virtual bool stopAll();
+	
+	//initialization
+	virtual void init();
+	virtual void exit();
+	//no need to re-declare mlist and slist they're protected.
+	
+	//
+protected:
+	DeviceParameter *devicecontrollerSetting;
+
+	motionerlist mlist; // motioner list
+	scannerlist slist; // scanner list
+	
+	
+};
+
+}
+
+#endif // BASICDEVICECONTROLLER_H

platform/DeviceController/devicecontrollermanipulator.cpp

+#include "devicecontrollermanipulator.h"
+
+namespace RP {
+
+DeviceControllerManipulator::DeviceControllerManipulator()
+{
+}
+
+DeviceControllerManipulator::DeviceControllerManipulator(const std::string name):AbstractDevice(name)
+{
+
+}
+
+DeviceControllerManipulator::~DeviceControllerManipulator()
+{
+}
+
+short DeviceControllerManipulator::mount()
+{
+	setting = new Setting("device.cfg");
+	setting->read();
+	if (setting->getValue("controller_model") == "basic")
+	{
+		controller = new BasicDeviceController("vDC");
+		interpreter = new Interpreter;
+		queue = new CommandQueue;
+		interpreter->setQueue(*queue);
+		short status = controller->mount();
+		if (status == OK)
+			isMounted = true;
+		return status;
+	}
+	else
+	{
+		debug << "manipulator: " << name << ": controller model not recognized." << endl;
+		return MountFailed;
+	}
+}
+
+short DeviceControllerManipulator::umount()
+{
+	delete setting;
+	if (isMounted)
+	{
+		short status = controller->umount();
+		if (status == OK)
+			isMounted = false;
+		delete controller;
+		delete queue;
+		delete interpreter;
+		return status;
+	}
+	else
+	{
+		debug << "manipulator: " << name << ": not mounted." << endl;
+		return NotMounted;
+	}
+}
+
+bool DeviceControllerManipulator::play(const std::string& s,bool doClean)
+{
+	BaseCommand *c = interpreter->readLine(s);
+	if (c != 0)
+	{
+		bool status = play(c);
+		if (doClean)
+			delete c;
+		return status;
+	}
+	else
+	{
+		debug << "manipulator: " << name << " playing null command." << endl;
+		return false;
+	}
+}
+
+bool DeviceControllerManipulator::play(BaseCommand* c)
+{
+	switch (c->type())
+	{
+	case MovingCommand:
+		{
+			MoveCommand *t = dynamic_cast<MoveCommand *>(c);
+			if (!t->hasExtent())
+				return controller->move(t->motionerID,t->axis,t->delta);
+			else
+				return controller->move(t->motionerID,t->axis,t->delta,t->isRelative,t->speed,t->startupSpeed,t->startupTime);
+		}
+	case MarkingCommand:
+		{
+			MarkCommand *t = dynamic_cast<MarkCommand *>(c);
+			if (!c->hasExtent())
+				return controller->mark(t->scannerID,t->delta);
+			else
+				return controller->mark(t->scannerID,t->delta,t->isRelative,t->speed,t->depth);
+		}
+	case JumpingCommand:
+		{
+			JumpCommand *t = dynamic_cast<JumpCommand *>(c);
+			if (!c->hasExtent())
+				return controller->jump(t->scannerID,t->delta);
+			else
+				return controller->jump(t->scannerID,t->delta,t->isRelative,t->speed,t->depth);
+		}
+	case StoppingCommand:
+		{
+			StopCommand *t = dynamic_cast<StopCommand *>(c);
+			switch (t->target)
+			{
+			case ControllerTarget:
+				return controller->stopAll();
+				break;
+			case MotionerTarget:
+				{
+					return controller->stopMove(t->targetID,t->axis);
+				}
+			case ScannerTarget:
+				{
+					return controller->stopScan(t->targetID);
+				}
+			default:
+				break;
+			}
+		}
+	case LaseringCommand:
+		{
+			LaserCommand *t = dynamic_cast<LaserCommand *>(c);
+			return controller->laser(t->scannerID,t->state);
+		}
+	case QueryingCommand:
+	case NullCommand:
+	default:
+		debug << "failed to play a command." << endl;
+		return false;
+		break;
+	}
+}
+
+
+
+}

platform/DeviceController/devicecontrollermanipulator.h

+#ifndef DEVICECONTROLLERMANIPULATOR_H
+#define DEVICECONTROLLERMANIPULATOR_H
+
+#include "basicdevicecontroller.h"
+#include "interpreter.h"
+
+namespace RP {
+
+class DeviceControllerManipulator : public AbstractDevice
+{
+public:
+	DeviceControllerManipulator();
+	DeviceControllerManipulator(const std::string name);
+	virtual ~DeviceControllerManipulator();
+
+	virtual short mount();
+	virtual short umount();
+
+	virtual bool play(const std::string &s, bool doClean = true);
+	virtual bool play(BaseCommand *c);
+
+protected:
+	BasicDeviceController *controller;
+	Interpreter *interpreter;
+	CommandQueue *queue;
+	Setting *setting;
+};
+
+}
+
+#endif // DEVICECONTROLLERMANIPULATOR_H

platform/DeviceController/deviceparameter.cpp

 namespace RP {
 
 DeviceParameter::DeviceParameter(const std::string filepath,
-													 EncryptionInterface::Method m,
-													 DigestInterface::Method d)
-	:DigestSetting(filepath,m,d)
+								EncryptionInterface::Method m,
+								 std::string seed)
+	:Setting(filepath,m,seed)
 {
 
 }
 
+std::string DeviceParameter::getDeviceValue(CommandTarget target, uint id, const std::string& key)
+{
+	return Setting::getValue(getKey(target,id,key));
+}
+
+bool DeviceParameter::getDeviceBoolValue(CommandTarget target, uint id, const std::string& key)
+{
+	return Setting::getBoolValue(getKey(target,id,key));
+}
+
+int DeviceParameter::getDeviceIntValue(CommandTarget target, uint id, const std::string& key)
+{
+	return Setting::getIntValue(getKey(target,id,key));
+}
+
+double DeviceParameter::getDeviceDoubleValue(CommandTarget target, uint id, const std::string &key)
+{
+	return Setting::getDoubleValue(getKey(target,id,key));
+}
+
+std::string DeviceParameter::getKey(CommandTarget target, uint id, const std::string& key)
+{
+	std::string targetstr;
+	switch (target) {
+	case MotionerTarget:
+		targetstr = "motioner";
+		break;
+	case ScannerTarget:
+		targetstr = "scanner";
+		break;
+	case ControllerTarget:
+		targetstr = "controller";
+		break;
+	default:
+		break;
+	}
+	const std::string splitter = "_";
+
+	std::string query = targetstr + splitter + toString(id) + splitter + key;
+	return query;
+}
+
 }

platform/DeviceController/deviceparameter.h

 #define DEVICEPARAMETER_H
 
 #include "digestsetting.h"
+#include "interpreterglobal.h"
 
 namespace RP {
 
 /**
  * @brief The DeviceParameter class is just a renaming inherit of @class DigestSetting.
  */
-class DeviceParameter : public DigestSetting
+class DeviceParameter : public Setting
 {
 public:
 	DeviceParameter(const std::string filepath,
-							  EncryptionInterface::Method m,
-							  DigestInterface::Method d);
+					EncryptionInterface::Method m = EncryptionInterface::None,
+					std::string seed = std::string());
+	virtual std::string getDeviceValue(CommandTarget target, uint id, const std::string &key);
+	virtual bool getDeviceBoolValue(CommandTarget target, uint id, const std::string &key);
+	virtual int getDeviceIntValue(CommandTarget target, uint id, const std::string &key);
+	virtual double getDeviceDoubleValue(CommandTarget target, uint id, const std::string &key);
+private:
+	virtual std::string getKey(CommandTarget target, uint id, const std::string &key);
 };
 
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.