mirror of
https://github.com/worldforge/cyphesis
synced 2026-08-13 12:26:04 -04:00
Use task for longer running usages.
This commit is contained in:
parent
cd6510d475
commit
2ed0437035
12 changed files with 129 additions and 51 deletions
|
|
@ -16,6 +16,8 @@
|
|||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <rulesets/PythonWrapper.h>
|
||||
#include <rulesets/PythonEntityScript.h>
|
||||
#include "CyPy_Task.h"
|
||||
#include "CyPy_Operation.h"
|
||||
#include "CyPy_LocatedEntity.h"
|
||||
|
|
@ -29,6 +31,7 @@ CyPy_Task::CyPy_Task(Py::PythonClassInstance* self, Py::Tuple& args, Py::Dict& k
|
|||
m_value = CyPy_Task::value(arg);
|
||||
} else if (CyPy_LocatedEntity::check(arg)) {
|
||||
m_value = new Task(CyPy_LocatedEntity::value(arg));
|
||||
m_value->setScript(new PythonEntityScript(this->self()));
|
||||
} else {
|
||||
throw Py::TypeError("Task requires a Task, or Entity");
|
||||
}
|
||||
|
|
@ -103,6 +106,12 @@ Py::Object CyPy_Task::getattro(const Py::String& name)
|
|||
if (nameStr == "rate") {
|
||||
return Py::Float(m_value->rate());
|
||||
}
|
||||
if (nameStr == "tick_interval") {
|
||||
return Py::Float(m_value->m_tick_interval);
|
||||
}
|
||||
if (nameStr == "name") {
|
||||
return Py::String(m_value->name());
|
||||
}
|
||||
Atlas::Message::Element val;
|
||||
if (m_value->getAttr(name, val) == 0) {
|
||||
if (val.isNone()) {
|
||||
|
|
@ -127,6 +136,14 @@ int CyPy_Task::setattro(const Py::String& name, const Py::Object& attr)
|
|||
m_value->rate() = verifyNumeric(attr);
|
||||
return 0;
|
||||
}
|
||||
if (nameStr == "tick_interval") {
|
||||
m_value->m_tick_interval = verifyNumeric(attr);
|
||||
return 0;
|
||||
}
|
||||
if (nameStr == "name") {
|
||||
m_value->name() = verifyString(attr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto element = CyPy_Element::asElement(attr);
|
||||
m_value->setAttr(nameStr, element);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue