+++ 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>
|
||||
</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>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifdef __int16
|
||||
#define int16 __int16
|
||||
#else
|
||||
#define int16 int
|
||||
#define int16 short
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -8,12 +8,41 @@ class Engine : public IO_Module
|
|||
public:
|
||||
Engine()
|
||||
{
|
||||
this->enabled = false;
|
||||
this->parent = NULL;
|
||||
}
|
||||
|
||||
Engine(uint32 engineId)
|
||||
{
|
||||
this->enabled = false;
|
||||
this->parent = NULL;
|
||||
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
|
||||
|
|
|
@ -3,27 +3,41 @@
|
|||
|
||||
#include "defines.h"
|
||||
|
||||
class Robot;
|
||||
|
||||
class IO_Module
|
||||
{
|
||||
public:
|
||||
IO_Module()
|
||||
{
|
||||
this->parent = NULL;
|
||||
}
|
||||
|
||||
IO_Module(uint32 moduleId)
|
||||
{
|
||||
this->parent = NULL;
|
||||
this->moduleId = moduleId;
|
||||
}
|
||||
|
||||
IO_Module(){}
|
||||
|
||||
protected:
|
||||
Robot* parent;
|
||||
uint32 moduleId;
|
||||
|
||||
public:
|
||||
Robot* GetParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
void SetParent(Robot* newParent)
|
||||
{
|
||||
parent = newParent;
|
||||
}
|
||||
|
||||
uint32 GetId()
|
||||
{
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,6 +24,8 @@ bool Robot::AddModule(IO_Module* newModule)
|
|||
if(modules[newModule->GetId()])
|
||||
return false;
|
||||
|
||||
newModule->SetParent(this);
|
||||
|
||||
modules[newModule->GetId()] = newModule;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -8,10 +8,12 @@ class Sensor : public IO_Module
|
|||
public:
|
||||
Sensor()
|
||||
{
|
||||
this->parent = NULL;
|
||||
}
|
||||
|
||||
Sensor(uint32 sensorId, SensorTypes sensorType)
|
||||
{
|
||||
this->parent = NULL;
|
||||
this->moduleId = sensorId;
|
||||
this->sensorType = sensorType;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef _MSC_VER // MS VC++
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "tools.h"
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void* operator new(size_t sz)
|
||||
{
|
||||
|
@ -11,3 +13,5 @@ void operator delete(void* p)
|
|||
{
|
||||
free(p);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,7 +1,9 @@
|
|||
#ifndef _TOOLS_H
|
||||
#define _TOOLS_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
void* operator new(size_t sz);
|
||||
void operator delete(void* p);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Reference in a new issue