Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions include/core/elements/Contact.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include "core/VirtualElement.h"
#include "core/engine/MemoryMap.h"

#include <string>

enum class ContactType : int
{
NO,
NC
};

class Contact : public VirtualElement
{
public:
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:
std::string address; // zmienna oznaczajaca adres styku
ContactType type; // zmienna oznaczajaca typ styku (NO lub NC)
};
11 changes: 11 additions & 0 deletions src/core/elements/Contact.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#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 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)
}