From 837e8d0c34e09a615e4512d9c11c276e4c15a39a Mon Sep 17 00:00:00 2001 From: Igor Olewicz <94185939+CZIWELLO@users.noreply.github.com> Date: Fri, 8 May 2026 23:12:09 +0200 Subject: [PATCH 1/2] Add Contact element with NO/NC type Add Contact.h and Contact.cpp introducing a Contact element. Defines ContactType enum (NO/NC) and a Contact class inheriting from VirtualElement with an explicit constructor that accepts an address and contact type. Stores address and type members and adds evaluate(MemoryMap&) as a stub (currently returns false/0). TODO: implement evaluate logic to consult MemoryMap and handle NO/NC behavior. (opis przez copilota) --- include/core/elements/Contact.h | 22 ++++++++++++++++++++++ src/core/elements/Contact.cpp | 12 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 include/core/elements/Contact.h create mode 100644 src/core/elements/Contact.cpp diff --git a/include/core/elements/Contact.h b/include/core/elements/Contact.h new file mode 100644 index 0000000..3ba6083 --- /dev/null +++ b/include/core/elements/Contact.h @@ -0,0 +1,22 @@ +#pragma once + +#include "core/VirtualElement.h" + +#include + +enum class ContactType : int +{ + NO, + NC +}; + +class Contact : public VirtualElement +{ +public: + explicit Contact(std::string a, ContactType t); // jawny konstruktor przyjmujący typ styku - deklarować np. "Contact styk(NO);" + bool evaluate(bool powerFlow, MemoryMap& memory) override; + +private: + std::string address; // zmienna oznaczajaca adres styku + ContactType type; // zmienna oznaczajaca typ styku (NO lub NC) +}; \ No newline at end of file diff --git a/src/core/elements/Contact.cpp b/src/core/elements/Contact.cpp new file mode 100644 index 0000000..875580a --- /dev/null +++ b/src/core/elements/Contact.cpp @@ -0,0 +1,12 @@ +#include "core/elements/Contact.h" + +Contact::Contact(std::string a, ContactType t) + : address(std::move(a)), type(t) +{ + +} + +bool Contact::evaluate(bool powerFlow, MemoryMap& memory) +{ + return 0; +} From e71c47714ec9bd08d0652058dc7da06a6cc8a57f Mon Sep 17 00:00:00 2001 From: Igor Olewicz <94185939+CZIWELLO@users.noreply.github.com> Date: Fri, 8 May 2026 23:27:54 +0200 Subject: [PATCH 2/2] Implement Contact::evaluate, rename params Include MemoryMap, rename constructor parameters from generic names to address and type, and implement Contact::evaluate. The function now returns true only when powerFlow is true and the contact state matches its type (NO reads true from memory, NC reads false). Keeps existing comment explaining behavior. --- include/core/elements/Contact.h | 3 ++- src/core/elements/Contact.cpp | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/core/elements/Contact.h b/include/core/elements/Contact.h index 3ba6083..52dc4b4 100644 --- a/include/core/elements/Contact.h +++ b/include/core/elements/Contact.h @@ -1,6 +1,7 @@ #pragma once #include "core/VirtualElement.h" +#include "core/engine/MemoryMap.h" #include @@ -13,7 +14,7 @@ enum class ContactType : int class Contact : public VirtualElement { public: - explicit Contact(std::string a, ContactType t); // jawny konstruktor przyjmujący typ styku - deklarować np. "Contact styk(NO);" + explicit Contact(std::string address, ContactType type); // jawny konstruktor przyjmujący typ styku - deklarować np. "Contact styk(NO);" bool evaluate(bool powerFlow, MemoryMap& memory) override; private: diff --git a/src/core/elements/Contact.cpp b/src/core/elements/Contact.cpp index 875580a..765209a 100644 --- a/src/core/elements/Contact.cpp +++ b/src/core/elements/Contact.cpp @@ -3,10 +3,9 @@ Contact::Contact(std::string a, ContactType t) : address(std::move(a)), type(t) { - } bool Contact::evaluate(bool powerFlow, MemoryMap& memory) { - return 0; + return powerFlow && (type == ContactType::NO ? memory.getBool(address) : !memory.getBool(address)); // zwraca true jeśli przepływ jest możliwy i styk jest zgodny z jego typem (NO - musi być true, NC - musi być false) }