From 54a7ea32d4c79b5ca56b66a5dac28690e928740e Mon Sep 17 00:00:00 2001 From: masterm Date: Tue, 13 Feb 2007 14:40:04 +0000 Subject: +++ added parent object to io_modules +++ added speed and enabling value stores for engines --- source/Concept/Framework/Concept.vcproj | 18 ++++++++++++++++++ source/Concept/Framework/defines.h | 2 +- source/Concept/Framework/engine.h | 29 +++++++++++++++++++++++++++++ source/Concept/Framework/io_module.h | 22 ++++++++++++++++++---- source/Concept/Framework/robot.cpp | 2 ++ source/Concept/Framework/sensor.h | 2 ++ source/Concept/Framework/stdafx.h | 2 +- source/Concept/Framework/tools.cpp | 4 ++++ source/Concept/Framework/tools.h | 6 ++++-- 9 files changed, 79 insertions(+), 8 deletions(-) (limited to 'source') diff --git a/source/Concept/Framework/Concept.vcproj b/source/Concept/Framework/Concept.vcproj index 1559721..fd22f8d 100644 --- a/source/Concept/Framework/Concept.vcproj +++ b/source/Concept/Framework/Concept.vcproj @@ -220,6 +220,24 @@ + + + + + + + + + + diff --git a/source/Concept/Framework/defines.h b/source/Concept/Framework/defines.h index fd07125..9eac05d 100644 --- a/source/Concept/Framework/defines.h +++ b/source/Concept/Framework/defines.h @@ -18,7 +18,7 @@ #ifdef __int16 #define int16 __int16 #else - #define int16 int + #define int16 short #endif #endif diff --git a/source/Concept/Framework/engine.h b/source/Concept/Framework/engine.h index 0b8bfac..2736a7a 100644 --- a/source/Concept/Framework/engine.h +++ b/source/Concept/Framework/engine.h @@ -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 diff --git a/source/Concept/Framework/io_module.h b/source/Concept/Framework/io_module.h index 271f7a7..af5d611 100644 --- a/source/Concept/Framework/io_module.h +++ b/source/Concept/Framework/io_module.h @@ -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 diff --git a/source/Concept/Framework/robot.cpp b/source/Concept/Framework/robot.cpp index 24038d3..f982be6 100644 --- a/source/Concept/Framework/robot.cpp +++ b/source/Concept/Framework/robot.cpp @@ -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; diff --git a/source/Concept/Framework/sensor.h b/source/Concept/Framework/sensor.h index 15dcdc0..117f446 100644 --- a/source/Concept/Framework/sensor.h +++ b/source/Concept/Framework/sensor.h @@ -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; } diff --git a/source/Concept/Framework/stdafx.h b/source/Concept/Framework/stdafx.h index db15d17..5a50add 100644 --- a/source/Concept/Framework/stdafx.h +++ b/source/Concept/Framework/stdafx.h @@ -1,6 +1,6 @@ #include -#ifdef _WIN32 +#ifdef _MSC_VER // MS VC++ #include #endif diff --git a/source/Concept/Framework/tools.cpp b/source/Concept/Framework/tools.cpp index 93766f1..625ef20 100644 --- a/source/Concept/Framework/tools.cpp +++ b/source/Concept/Framework/tools.cpp @@ -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 \ No newline at end of file diff --git a/source/Concept/Framework/tools.h b/source/Concept/Framework/tools.h index a3c12de..9cd38f2 100644 --- a/source/Concept/Framework/tools.h +++ b/source/Concept/Framework/tools.h @@ -1,7 +1,9 @@ #ifndef _TOOLS_H #define _TOOLS_H -void* operator new(size_t sz); -void operator delete(void* p); +#ifndef __cplusplus + void* operator new(size_t sz); + void operator delete(void* p); +#endif #endif -- cgit v1.2.3