diff --git a/LocalParticipant.cpp b/LocalParticipant.cpp index 94044f0..6def52e 100644 --- a/LocalParticipant.cpp +++ b/LocalParticipant.cpp @@ -3,14 +3,15 @@ #include "Thing.h" #include "Arduino/ArduinoParticipant.h" -#include "Posix/PosixParticipant.h" -#include "Windows/WindowsParticipant.h" #if defined(_WIN32) || defined(_WIN64) +#include "Windows/WindowsParticipant.h" #include #include #pragma comment(lib, "ws2_32.lib") + #elif defined(__unix__) || defined(__APPLE__) +#include "Posix/PosixParticipant.h" #include #include // For fcntl #include @@ -26,15 +27,31 @@ namespace RoboidControl { LocalParticipant::LocalParticipant(int port) { this->ipAddress = "0.0.0.0"; this->port = port; + if (this->port == 0) + this->isIsolated = true; } LocalParticipant::LocalParticipant(const char* ipAddress, int port) { - this->ipAddress = ipAddress; // maybe this is not needed anymore, keeping it to "0.0.0.0" + this->ipAddress = "0.0.0.0"; // ipAddress; // maybe this is not needed anymore, keeping it to "0.0.0.0" this->port = port; - this->site = new Participant(ipAddress, port); + if (this->port == 0) + this->isIsolated = true; + else + this->remoteSite = new Participant(ipAddress, port); +} + +static LocalParticipant* isolatedParticipant = nullptr; + +LocalParticipant* LocalParticipant::Isolated() { + if (isolatedParticipant == nullptr) + isolatedParticipant = new LocalParticipant(0); + return isolatedParticipant; } void LocalParticipant::begin() { + if (this->isIsolated) + return; + SetupUDP(this->port, this->ipAddress, this->port); } @@ -63,28 +80,32 @@ void LocalParticipant::Update(unsigned long currentTimeMs) { #endif } - if (this->connected == false) - begin(); + if (this->isIsolated == false) { + if (this->connected == false) + begin(); - if (this->publishInterval > 0 && currentTimeMs > this->nextPublishMe) { - ParticipantMsg* msg = new ParticipantMsg(this->networkId); - if (this->site == nullptr) - this->Publish(msg); - else - this->Send(this->site, msg); - delete msg; + if (this->publishInterval > 0 && currentTimeMs > this->nextPublishMe) { + ParticipantMsg* msg = new ParticipantMsg(this->networkId); + if (this->remoteSite == nullptr) + this->Publish(msg); + else + this->Send(this->remoteSite, msg); + delete msg; - this->nextPublishMe = currentTimeMs + this->publishInterval; + this->nextPublishMe = currentTimeMs + this->publishInterval; + } + this->ReceiveUDP(); } - this->ReceiveUDP(); for (Thing* thing : this->things) { if (thing != nullptr) { thing->Update(currentTimeMs); - PoseMsg* poseMsg = new PoseMsg(this->networkId, thing); - for (Participant* sender : this->senders) - this->Send(sender, poseMsg); - delete poseMsg; + if (this->isIsolated == false) { + PoseMsg* poseMsg = new PoseMsg(this->networkId, thing); + for (Participant* sender : this->senders) + this->Send(sender, poseMsg); + delete poseMsg; + } } } } @@ -273,8 +294,13 @@ void LocalParticipant::Process(Participant* sender, NameMsg* msg) { int nameLength = msg->nameLength; int stringLen = nameLength + 1; char* thingName = new char[stringLen]; +#if defined(_WIN32) || defined(_WIN64) + strncpy_s(thingName, stringLen, msg->name, stringLen - 1); // Leave space for null terminator +#else // Use strncpy with bounds checking for other platforms (Arduino, POSIX, ESP-IDF) strncpy(thingName, msg->name, stringLen - 1); // Leave space for null terminator + thingName[stringLen - 1] = '\0'; // Ensure null termination +#endif thingName[nameLength] = '\0'; thing->name = thingName; std::cout << "thing name = " << thing->name << " length = " << nameLength << "\n"; diff --git a/LocalParticipant.h b/LocalParticipant.h index 0d70be5..8d479b3 100644 --- a/LocalParticipant.h +++ b/LocalParticipant.h @@ -25,16 +25,45 @@ namespace RoboidControl { -/// @brief A participant is device which can communicate with other participants +/// @brief A local participant is the local device which can communicate with other participants +/// It manages all local things and communcation with other participants. +/// Each application has a local participant which is usually explicit in the code. +/// An participant can be isolated. In that case it is standalong and does not communicate with other participants. +/// +/// It is possible to work with an hidden participant by creating things without specifying a participant in the +/// constructor (@sa RoboidControl::Thing::Thing()). In that case an hidden isolated participant is created which can be +/// obtained using RoboidControl::LocalParticipant::Isolated(). class LocalParticipant : public Participant { public: - char buffer[1024]; + /// @brief Create a participant without connecting to a site + /// @param port The port on which the participant communicates + /// These participant typically broadcast Participant messages to let site servers on the local network know their presence. + /// Alternatively they can broadcast information which can be used directly by other participants. + LocalParticipant(int port = 7681); + /// @brief Create a participant which will try to connect to a site. + /// @param ipAddress The IP address of the site + /// @param port The port used by the site + LocalParticipant(const char* ipAddress, int port = 7681); + // Note to self: one cannot specify the port used by the local participant now!! + + /// @brief Isolated participant is used when the application is run without networking + /// @return A participant without networking support + static LocalParticipant* Isolated(); + + /// @brief True if the participant is running isolated. + /// Isolated participants do not communicate with other participants + bool isIsolated = false; + + /// The interval in milliseconds for publishing (broadcasting) data on the local network long publishInterval = 3000; // 3 seconds + /// @brief The name of the participant const char* name = "LocalParticipant"; // int localPort = 0; - Participant* site = nullptr; + + /// @brief The remote site when this participant is connected to a site + Participant* remoteSite = nullptr; #if defined(ARDUINO) const char* remoteIpAddress = nullptr; @@ -44,9 +73,7 @@ class LocalParticipant : public Participant { WiFiUDP udp; #else -#if defined(_WIN32) || defined(_WIN64) - SOCKET sock; -#elif defined(__unix__) || defined(__APPLE__) +#if defined(__unix__) || defined(__APPLE__) int sock; #endif sockaddr_in remote_addr; @@ -55,9 +82,6 @@ class LocalParticipant : public Participant { #endif - LocalParticipant(int port = 7681); - LocalParticipant(const char* ipAddress, int port = 7681); - void begin(); bool connected = false; @@ -77,6 +101,8 @@ class LocalParticipant : public Participant { protected: unsigned long nextPublishMe = 0; + char buffer[1024]; + void SetupUDP(int localPort, const char* remoteIpAddress, int remotePort); Participant* GetParticipant(const char* ipAddress, int port); diff --git a/Participant.cpp b/Participant.cpp index fbcc64e..4e7e69e 100644 --- a/Participant.cpp +++ b/Participant.cpp @@ -11,7 +11,11 @@ Participant::Participant(const char* ipAddress, int port) { int addressLength = strlen(ipAddress); int stringLength = addressLength + 1; char* addressString = new char[stringLength]; +#if defined(_WIN32) || defined(_WIN64) + strncpy_s(addressString, stringLength, ipAddress, addressLength); // Leave space for null terminator +#else strncpy(addressString, ipAddress, addressLength); +#endif addressString[addressLength] = '\0'; this->ipAddress = addressString; @@ -24,21 +28,22 @@ Participant::~Participant() { Thing* Participant::Get(unsigned char networkId, unsigned char thingId) { for (Thing* thing : this->things) { - //if (thing->networkId == networkId && thing->id == thingId) + // if (thing->networkId == networkId && thing->id == thingId) if (thing->id == thingId) return thing; } - // std::cout << "Could not find thing " << this->ipAddress << ":" << this->port - // << "[" << (int)networkId << "/" << (int)thingId << "]\n"; + // std::cout << "Could not find thing " << this->ipAddress << ":" << this->port + // << "[" << (int)networkId << "/" << (int)thingId << "]\n"; return nullptr; } void Participant::Add(Thing* thing, bool checkId) { if (checkId && thing->id == 0) { // allocate a new thing ID - thing->id = this->things.size() + 1; + thing->id = (unsigned char)this->things.size() + 1; this->things.push_back(thing); - // std::cout << "Add thing with generated ID " << this->ipAddress << ":" << this->port << "[" << (int)thing->networkId << "/" + // std::cout << "Add thing with generated ID " << this->ipAddress << ":" << this->port << "[" << + // (int)thing->networkId << "/" // << (int)thing->id << "]\n"; } else { Thing* foundThing = Get(thing->networkId, thing->id); @@ -46,7 +51,7 @@ void Participant::Add(Thing* thing, bool checkId) { this->things.push_back(thing); // std::cout << "Add thing " << this->ipAddress << ":" << this->port << "[" << (int)thing->networkId << "/" // << (int)thing->id << "]\n"; - } + } // else // std::cout << "Did not add, existing thing " << this->ipAddress << ":" << this->port << "[" // << (int)thing->networkId << "/" << (int)thing->id << "]\n"; @@ -58,16 +63,16 @@ void Participant::Remove(Thing* thing) { std::cout << "Removing " << thing->networkId << "/" << thing->id << " list size = " << this->things.size() << "\n"; } -void Participant::UpdateAll(unsigned long currentTimeMs) { - // Not very efficient, but it works for now. +// void Participant::UpdateAll(unsigned long currentTimeMs) { +// // Not very efficient, but it works for now. - for (Thing* thing : this->things) { - if (thing != nullptr && thing->GetParent() == nullptr) { // update all root things - // std::cout << " update " << (int)ix << " thingid " << (int)thing->id - // << "\n"; - thing->Update(currentTimeMs); - } - } -} +// for (Thing* thing : this->things) { +// if (thing != nullptr && thing->GetParent() == nullptr) { // update all root things +// // std::cout << " update " << (int)ix << " thingid " << (int)thing->id +// // << "\n"; +// thing->Update(currentTimeMs); +// } +// } +// } } // namespace RoboidControl diff --git a/Participant.h b/Participant.h index e834c81..bf1c18d 100644 --- a/Participant.h +++ b/Participant.h @@ -3,25 +3,50 @@ namespace RoboidControl { +/// @brief A participant is a device which manages things. +/// It can communicate with other participant to synchronise the state of things. +/// This class is used to register the things the participant is managing. +/// It also maintains the communcation information to contact the participant. +/// It is used as a basis for the local participant, but also as a reference to remote participants. class Participant { public: + /// @brief The Ip Address of a participant. When the participant is local, this contains 0.0.0.0 const char *ipAddress = "0.0.0.0"; + /// @brief The port number for UDP communication with the participant. This is 0 for isolated participants. int port = 0; + /// @brief The network Id to identify the participant. + /// @note This field is likely to disappear in future versions unsigned char networkId = 0; + /// @brief Default constructor Participant(); + /// @brief Create a new participant with the given communcation info + /// @param ipAddress The IP address of the participant + /// @param port The port of the participant Participant(const char *ipAddress, int port); + /// @brief Destructor for the participant ~Participant(); protected: + /// @brief The list of things managed by this participant std::list things; public: + /// @brief Find a thing managed by this participant + /// @param networkId The network ID for the thing + /// @param thingId The ID of the thing + /// @return The thing if found or nullptr when no thing has been found + /// @note The use of the network ID is likely to disappear in future versions. Thing *Get(unsigned char networkId, unsigned char thingId); + /// @brief Add a new thing for this participant. + /// @param thing The thing to add + /// @param checkId Checks the thing ID of the thing. If it is 0, a new thing Id will be assigned. void Add(Thing *thing, bool checkId = true); + /// @brief Remove a thing for this participant + /// @param thing The thing to remove void Remove(Thing *thing); - void UpdateAll(unsigned long currentTimeMs); + }; } // namespace Control diff --git a/README.md b/README.md index c9b893e..f01cb53 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,10 @@ Supporting: - Windows - MacOS - Linux -- Arduino (using PlatformIO) +- Arduino (using PlatformIO). The following microcontrollers are tested and supported: + - ESP8266 + - ESP32 + - UNO R4 WiFi - ESP8266 - ESP32 - UNO R4 WiFi @@ -13,5 +16,5 @@ Supporting: # Basic components - RoboidControl::Thing -- RoboidControl::Participant +- RoboidControl::LocalParticipant - RoboidControl::SiteServer \ No newline at end of file diff --git a/Thing.cpp b/Thing.cpp index d13f580..23bf269 100644 --- a/Thing.cpp +++ b/Thing.cpp @@ -4,14 +4,26 @@ #include #include #include +#include + #include "LocalParticipant.h" namespace RoboidControl { + +// LocalParticipant* Thing::CheckHiddenParticipant() { +// if (isolatedParticipant == nullptr) +// isolatedParticipant = new LocalParticipant(0); +// return isolatedParticipant; +// } + +Thing::Thing(int thingType) : Thing(LocalParticipant::Isolated(), thingType) { +} + Thing::Thing(Participant* owner, Type thingType) : Thing(owner, (unsigned char)thingType) {} -Thing::Thing(Participant* owner, unsigned char thingType) { - this->participant = owner; +Thing::Thing(Participant* owner, int thingType) { + this->owner = owner; this->id = 0; this->type = thingType; this->networkId = 0; @@ -28,7 +40,7 @@ Thing::Thing(Participant* owner, unsigned char thingType) { Thing::Thing(Participant* owner, unsigned char networkId, unsigned char thingId, Type thingType) { // no participant reference yet.. - this->participant = owner; + this->owner = owner; this->networkId = networkId; this->id = thingId; this->type = (unsigned char)thingType; @@ -153,11 +165,20 @@ void Thing::SetModel(const char* url) { this->modelUrl = url; } -#if defined(ARDUINO) -void Thing::Update() { - Update(millis()); +unsigned long Thing::GetTimeMs() { + auto now = std::chrono::steady_clock::now(); + auto ms = std::chrono::duration_cast( + now.time_since_epoch()); + return static_cast(ms.count()); +} + +void Thing::Update() { + #if defined(ARDUINO) + Update(millis()); + #else + Update(GetTimeMs()); + #endif } -#endif void Thing::Update(unsigned long currentTimeMs) { (void)currentTimeMs; @@ -168,6 +189,10 @@ void Thing::Update(unsigned long currentTimeMs) { } +void Thing::UpdateThings(unsigned long currentTimeMs) { + LocalParticipant::Isolated()->Update(currentTimeMs); +} + void Thing::GenerateBinary(char* buffer, unsigned char* ix) { (void)buffer; (void)ix; diff --git a/Thing.h b/Thing.h index 02fbcea..0cf14b4 100644 --- a/Thing.h +++ b/Thing.h @@ -7,6 +7,7 @@ namespace RoboidControl { class Participant; +class LocalParticipant; #define THING_STORE_SIZE 256 // IMPORTANT: values higher than 256 will need to change the Thing::id type @@ -15,13 +16,8 @@ class Participant; /// @brief A thing is the primitive building block class Thing { public: - Participant* participant; // -> owner - unsigned char networkId = 0; - /// @brief The ID of the thing - unsigned char id = 0; - /// @brief Predefined thing types - enum class Type { + enum Type { Undetermined, // Sensor, Switch, @@ -38,24 +34,34 @@ class Thing { Humanoid, ExternalSensor, }; - /// @brief The type of Thing - unsigned char type = 0; + /// @brief Create a new thing using an implicit local participant + /// @param thingType The type of thing + Thing(int thingType = Type::Undetermined); /// @brief Create a new thing of the given type /// @param thingType The predefined type of thing Thing(Participant* participant, Type thingType = Type::Undetermined); /// @brief Create a new thing of the give type /// @param thingType The custom type of the thing - Thing(Participant* participant, unsigned char thingType); + Thing(Participant* participant, int thingType); /// @brief Create a new thing for the given participant /// @param participant The participant for which this thing is created /// @param networkId The network ID of the thing /// @param thingId The ID of the thing /// @param thingType The type of thing - Thing(Participant* participant, - unsigned char networkId, - unsigned char thingId, - Type thingType = Type::Undetermined); + Thing(Participant* participant, unsigned char networkId, unsigned char thingId, Type thingType = Type::Undetermined); + + /// @brief The participant managing this thing + Participant* owner; + /// @brief The network ID of this thing + /// @note This field will likely disappear in future versions + unsigned char networkId = 0; + /// @brief The ID of the thing + unsigned char id = 0; + + /// @brief The type of Thing + /// This can be either a Thing::Type of a byte value for custom types + unsigned char type = 0; /// @brief Find a thing by name /// @param name Rhe name of the thing @@ -117,7 +123,7 @@ class Thing { /// @return The orienation in local space SwingTwist16 GetOrientation(); /// @brief The scale of the thing (deprecated I think) - float scale = 1; // assuming uniform scale + //float scale = 1; // assuming uniform scale /// @brief boolean indicating if the position was updated bool positionUpdated = false; @@ -126,7 +132,7 @@ class Thing { /// @brief Set the linear velocity of the thing /// @param linearVelocity The new linear velocity in local space, in meters per second - virtual void SetLinearVelocity(Spherical16 linearVelocity); + void SetLinearVelocity(Spherical16 linearVelocity); /// @brief Get the linear velocity of the thing /// @return The linear velocity in local space, in meters per second virtual Spherical16 GetLinearVelocity(); @@ -165,13 +171,15 @@ class Thing { /// the only official supported model format is .obj void SetModel(const char* url); -#if defined(ARDUINO) + static unsigned long GetTimeMs(); + void Update(); -#endif /// @brief Updates the state of the thing /// @param currentTimeMs The current clock time in milliseconds - virtual void Update(unsigned long currentTimeMs); // { (void)currentTimeMs; }; + virtual void Update(unsigned long currentTimeMs); // { (void)currentTimeMs; }; + + static void UpdateThings(unsigned long currentTimeMs); /// @brief Function used to generate binary data for this thing /// @param buffer The byte array for thw binary data diff --git a/Windows/WindowsParticipant.cpp b/Windows/WindowsParticipant.cpp index 955a23c..9b5a8b3 100644 --- a/Windows/WindowsParticipant.cpp +++ b/Windows/WindowsParticipant.cpp @@ -4,6 +4,7 @@ #include #include #pragma comment(lib, "ws2_32.lib") + #elif defined(__unix__) || defined(__APPLE__) #include #include // For fcntl diff --git a/Windows/WindowsParticipant.h b/Windows/WindowsParticipant.h index d5c0679..c0ec0ed 100644 --- a/Windows/WindowsParticipant.h +++ b/Windows/WindowsParticipant.h @@ -11,6 +11,11 @@ class LocalParticipant : public RoboidControl::LocalParticipant { void Receive(); bool Send(Participant* remoteParticipant, int bufferSize); bool Publish(IMessage* msg); + + protected: + #if defined(_WIN32) || defined(_WIN64) + SOCKET sock; + #endif }; } // namespace Windows diff --git a/test/participant_test.cc b/test/participant_test.cc new file mode 100644 index 0000000..70a5e09 --- /dev/null +++ b/test/participant_test.cc @@ -0,0 +1,114 @@ +#if GTEST + +// #include +// not supported using Visual Studio 2022 compiler... +#include + +#include +#include +// #include + +#include "Participant.h" +#include "SiteServer.h" +#include "Thing.h" + +using namespace RoboidControl; + +// Function to get the current time in milliseconds as unsigned long +unsigned long get_time_ms() { + auto now = std::chrono::steady_clock::now(); + auto ms = std::chrono::duration_cast( + now.time_since_epoch()); + return static_cast(ms.count()); +} + +// class RoboidControlSuite : public ::testing::test { +// TEST_F(RoboidControlSuite, HiddenParticipant) { +// Thing thing = Thing(); + +// unsigned long milliseconds = get_time_ms(); +// unsigned long startTime = milliseconds; +// while (milliseconds < startTime + 1000) { +// Thing.Update(milliseconds); + +// milliseconds = get_time_ms(); +// } +// ASSERT_EQ(1, 1); +// } +// } + +class ParticipantSuite : public ::testing::Test { +protected: + // SetUp and TearDown can be used to set up and clean up before/after each + // test + void SetUp() override { + // Initialize test data here + } + + void TearDown() override { + // Clean up test data here + } +}; + + + +// TEST_F(ParticipantSuite, LocalParticipant) { +// LocalParticipant* participant = new LocalParticipant("127.0.0.1", 7681); + +// unsigned long milliseconds = get_time_ms(); +// unsigned long startTime = milliseconds; +// while (milliseconds < startTime + 1000) { +// participant->Update(milliseconds); + +// milliseconds = get_time_ms(); +// } +// ASSERT_EQ(1, 1); +// } + +// TEST_F(ParticipantSuite, SiteServer) { +// SiteServer site = SiteServer(7681); + +// unsigned long milliseconds = get_time_ms(); +// unsigned long startTime = milliseconds; +// while (milliseconds < startTime + 1000) { +// site.Update(milliseconds); + +// milliseconds = get_time_ms(); +// } +// ASSERT_EQ(1, 1); +// } + +// TEST_F(ParticipantSuite, SiteParticipant) { +// SiteServer site = SiteServer(7681); +// LocalParticipant participant = LocalParticipant("127.0.0.1", 7681); + +// unsigned long milliseconds = get_time_ms(); +// unsigned long startTime = milliseconds; +// while (milliseconds < startTime + 1000) { +// site.Update(milliseconds); +// participant.Update(milliseconds); + +// std::this_thread::sleep_for(std::chrono::milliseconds(100)); +// milliseconds = get_time_ms(); +// } +// ASSERT_EQ(1, 1); +// } + +// TEST_F(ParticipantSuite, Thing) { +// SiteServer site = SiteServer(7681); +// LocalParticipant participant = LocalParticipant("127.0.0.1", 7681); +// Thing thing = Thing(&participant); + +// unsigned long milliseconds = get_time_ms(); +// unsigned long startTime = milliseconds; +// while (milliseconds < startTime + 1000) { +// site.Update(milliseconds); +// participant.Update(milliseconds); + +// std::this_thread::sleep_for(std::chrono::milliseconds(100)); +// milliseconds = get_time_ms(); +// } +// ASSERT_EQ(1, 1); +// } + +#endif diff --git a/test/second_test.cc b/test/second_test.cc deleted file mode 100644 index 150a841..0000000 --- a/test/second_test.cc +++ /dev/null @@ -1,43 +0,0 @@ -#if GTEST - -// #include -// not supported using Visual Studio 2022 compiler... -#include - -#include - -#include "Participant.h" -#include "Thing.h" - -using namespace RoboidControl; - -class ControlCoreSuite2 : public ::testing::Test { -protected: - // SetUp and TearDown can be used to set up and clean up before/after each - // test - void SetUp() override { - // Initialize test data here - } - - void TearDown() override { - // Clean up test data here - } -}; - -TEST_F(ControlCoreSuite2, Dummytest2) { - LocalParticipant participant = LocalParticipant("127.0.0.1", 7681); - ASSERT_EQ(1, 1); -} - -TEST_F(ControlCoreSuite2, Basic2) { - // Thing t = Thing(); - - // unsigned long milliseconds = (unsigned long)std::chrono::steady_clock::now() - // .time_since_epoch() - // .count(); - - // // Thing::UpdateAll(milliseconds); - // t.Update(milliseconds); -} - -#endif diff --git a/test/thing_test.cc b/test/thing_test.cc index 914c4fc..bc613a8 100644 --- a/test/thing_test.cc +++ b/test/thing_test.cc @@ -4,94 +4,36 @@ // not supported using Visual Studio 2022 compiler... #include -#include -#include -// #include - -#include "Participant.h" -#include "SiteServer.h" +#include "LocalParticipant.h" #include "Thing.h" using namespace RoboidControl; -// Function to get the current time in milliseconds as unsigned long -unsigned long get_time_ms() { - auto now = std::chrono::steady_clock::now(); - auto ms = std::chrono::duration_cast( - now.time_since_epoch()); - return static_cast(ms.count()); -} +TEST(RoboidControlSuite, HiddenParticipant) { + Thing* thing = new Thing(); -class ControlCoreSuite : public ::testing::Test { -protected: - // SetUp and TearDown can be used to set up and clean up before/after each - // test - void SetUp() override { - // Initialize test data here - } - - void TearDown() override { - // Clean up test data here - } -}; - -TEST_F(ControlCoreSuite, LocalParticipant) { - LocalParticipant participant = LocalParticipant("127.0.0.1", 7681); - - unsigned long milliseconds = get_time_ms(); + unsigned long milliseconds = Thing::GetTimeMs(); unsigned long startTime = milliseconds; while (milliseconds < startTime + 1000) { - participant.Update(milliseconds); + Thing::UpdateThings(milliseconds); - milliseconds = get_time_ms(); + milliseconds = Thing::GetTimeMs(); } - ASSERT_EQ(1, 1); + SUCCEED(); } -TEST_F(ControlCoreSuite, SiteServer) { - SiteServer site = SiteServer(7681); +TEST(RoboidControlSuite, IsolatedParticipant) { + LocalParticipant* participant = LocalParticipant::Isolated(); + Thing* thing = new Thing(participant); - unsigned long milliseconds = get_time_ms(); + unsigned long milliseconds = Thing::GetTimeMs(); unsigned long startTime = milliseconds; while (milliseconds < startTime + 1000) { - site.Update(milliseconds); + participant->Update(milliseconds); - milliseconds = get_time_ms(); + milliseconds = Thing::GetTimeMs(); } - ASSERT_EQ(1, 1); -} - -TEST_F(ControlCoreSuite, SiteParticipant) { - SiteServer site = SiteServer(7681); - LocalParticipant participant = LocalParticipant("127.0.0.1", 7681); - - unsigned long milliseconds = get_time_ms(); - unsigned long startTime = milliseconds; - while (milliseconds < startTime + 1000) { - site.Update(milliseconds); - participant.Update(milliseconds); - - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - milliseconds = get_time_ms(); - } - ASSERT_EQ(1, 1); -} - -TEST_F(ControlCoreSuite, Thing) { - SiteServer site = SiteServer(7681); - LocalParticipant participant = LocalParticipant("127.0.0.1", 7681); - Thing thing = Thing(&participant); - - unsigned long milliseconds = get_time_ms(); - unsigned long startTime = milliseconds; - while (milliseconds < startTime + 1000) { - site.Update(milliseconds); - participant.Update(milliseconds); - - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - milliseconds = get_time_ms(); - } - ASSERT_EQ(1, 1); + SUCCEED(); } #endif