add missing file
This commit is contained in:
28
src/items/signal.cpp
Normal file
28
src/items/signal.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include "signal.h"
|
||||||
|
|
||||||
|
Microcontroller *Signal::micro = nullptr;
|
||||||
|
|
||||||
|
Signal::Signal(uint8_t id, uint8_t address, uint8_t subaddress, uint8_t type, int8_t initalValue)
|
||||||
|
: Item(address | (subaddress << 8), QString("Turnout ")+QString::number(id), initalValue),
|
||||||
|
subaddress_(subaddress), signalId_(id), type_(type)
|
||||||
|
{
|
||||||
|
itemId_ = address | (subaddress << 8);
|
||||||
|
name_ = QString("Signal ")+QString::number(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Signal::setValue(int8_t value)
|
||||||
|
{
|
||||||
|
Item::setValue(value);
|
||||||
|
if(micro)
|
||||||
|
micro->signalSetValue(signalId_, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Signal::hasSlow()
|
||||||
|
{
|
||||||
|
return type_ & TYPE_HAS_SLOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Signal::hasExpect()
|
||||||
|
{
|
||||||
|
return type_ & TYPE_HAS_EXPECT;
|
||||||
|
}
|
38
src/items/signal.h
Normal file
38
src/items/signal.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#ifndef SIGNAL_H
|
||||||
|
#define SIGNAL_H
|
||||||
|
|
||||||
|
#include "item.h"
|
||||||
|
#include "../microcontroller.h"
|
||||||
|
|
||||||
|
class Signal : public Item
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr int GO = 0;
|
||||||
|
static constexpr int STOP = 1;
|
||||||
|
static constexpr int SLOW = 2;
|
||||||
|
static constexpr int EXPECT_GO = 1 << 3;
|
||||||
|
static constexpr int EXPECT_STOP = 2 << 3;
|
||||||
|
static constexpr int EXPECT_SLOW = 3 << 3;
|
||||||
|
|
||||||
|
static constexpr uint8_t TYPE_NORMAL = 0;
|
||||||
|
static constexpr uint8_t TYPE_RELAY = 1;
|
||||||
|
static constexpr uint8_t TYPE_HAS_SLOW = 1 << 1;
|
||||||
|
static constexpr uint8_t TYPE_HAS_EXPECT = 1 << 2;
|
||||||
|
private:
|
||||||
|
uint8_t subaddress_;
|
||||||
|
uint8_t signalId_;
|
||||||
|
uint8_t type_;
|
||||||
|
public:
|
||||||
|
static Microcontroller *micro;
|
||||||
|
|
||||||
|
explicit Signal(uint8_t id = 0, uint8_t address = 0, uint8_t subaddress = 0, uint8_t type = 0, int8_t initalValue = 0);
|
||||||
|
virtual void setValue(int8_t value);
|
||||||
|
bool hasSlow();
|
||||||
|
bool hasExpect();
|
||||||
|
uint8_t getSignalId()
|
||||||
|
{
|
||||||
|
return signalId_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SIGNAL_H
|
Reference in New Issue
Block a user