+++ added parent object to io_modules
+++ added speed and enabling value stores for engines
This commit is contained in:
parent
05c8b0af60
commit
54a7ea32d4
9 changed files with 79 additions and 8 deletions
|
@ -220,6 +220,24 @@
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Tools"
|
||||||
|
Filter="">
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath=".\tools.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath=".\tools.h">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#ifdef __int16
|
#ifdef __int16
|
||||||
#define int16 __int16
|
#define int16 __int16
|
||||||
#else
|
#else
|
||||||
#define int16 int
|
#define int16 short
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,41 @@ class Engine : public IO_Module
|
||||||
public:
|
public:
|
||||||
Engine()
|
Engine()
|
||||||
{
|
{
|
||||||
|
this->enabled = false;
|
||||||
|
this->parent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine(uint32 engineId)
|
Engine(uint32 engineId)
|
||||||
{
|
{
|
||||||
|
this->enabled = false;
|
||||||
|
this->parent = NULL;
|
||||||
this->moduleId = engineId;
|
this->moduleId = engineId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool enabled;
|
||||||
|
float curSpeed;
|
||||||
|
|
||||||
|
public:
|
||||||
|
float GetSpeed()
|
||||||
|
{
|
||||||
|
return curSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetSpeed(float newSpeed)
|
||||||
|
{
|
||||||
|
curSpeed = newSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetEnabled(bool newStatus)
|
||||||
|
{
|
||||||
|
enabled = newStatus;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,27 +3,41 @@
|
||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
|
class Robot;
|
||||||
|
|
||||||
class IO_Module
|
class IO_Module
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
IO_Module()
|
||||||
|
{
|
||||||
|
this->parent = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
IO_Module(uint32 moduleId)
|
IO_Module(uint32 moduleId)
|
||||||
{
|
{
|
||||||
|
this->parent = NULL;
|
||||||
this->moduleId = moduleId;
|
this->moduleId = moduleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
IO_Module(){}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Robot* parent;
|
||||||
uint32 moduleId;
|
uint32 moduleId;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Robot* GetParent()
|
||||||
|
{
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetParent(Robot* newParent)
|
||||||
|
{
|
||||||
|
parent = newParent;
|
||||||
|
}
|
||||||
|
|
||||||
uint32 GetId()
|
uint32 GetId()
|
||||||
{
|
{
|
||||||
return moduleId;
|
return moduleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,6 +24,8 @@ bool Robot::AddModule(IO_Module* newModule)
|
||||||
if(modules[newModule->GetId()])
|
if(modules[newModule->GetId()])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
newModule->SetParent(this);
|
||||||
|
|
||||||
modules[newModule->GetId()] = newModule;
|
modules[newModule->GetId()] = newModule;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -8,10 +8,12 @@ class Sensor : public IO_Module
|
||||||
public:
|
public:
|
||||||
Sensor()
|
Sensor()
|
||||||
{
|
{
|
||||||
|
this->parent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sensor(uint32 sensorId, SensorTypes sensorType)
|
Sensor(uint32 sensorId, SensorTypes sensorType)
|
||||||
{
|
{
|
||||||
|
this->parent = NULL;
|
||||||
this->moduleId = sensorId;
|
this->moduleId = sensorId;
|
||||||
this->sensorType = sensorType;
|
this->sensorType = sensorType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _MSC_VER // MS VC++
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void* operator new(size_t sz)
|
void* operator new(size_t sz)
|
||||||
{
|
{
|
||||||
|
@ -11,3 +13,5 @@ void operator delete(void* p)
|
||||||
{
|
{
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,7 +1,9 @@
|
||||||
#ifndef _TOOLS_H
|
#ifndef _TOOLS_H
|
||||||
#define _TOOLS_H
|
#define _TOOLS_H
|
||||||
|
|
||||||
void* operator new(size_t sz);
|
#ifndef __cplusplus
|
||||||
void operator delete(void* p);
|
void* operator new(size_t sz);
|
||||||
|
void operator delete(void* p);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Reference in a new issue