radec/src/wire.cpp

40 lines
613 B
C++
Raw Normal View History

2017-04-23 19:13:23 -04:00
#include "Wire.h"
2017-04-23 19:13:23 -04:00
Wire::Wire(int number, bool io, string inName)
{
2017-04-23 19:13:23 -04:00
WireNumber = number;
isPrint = io;
name = inName;
value = -1;
lastEvent = 0;
history.insert(history.begin(), 60, -1);
}
int wire::getValue(int time) const
{
for (auto i = history.begin() + time; i != history.begin(); i--) {
if (i[0] != -1) {
return i[0];
}
}
return -1;
}
void wire::setValue(int newValue, int setTime)
{
history[setTime] = newValue;
if (lastEvent < setTime) {
lastEvent = setTime;
}
}
int wire::getNumber() const
{
return wireNumber;
}
void wire::addGate(gate * newGate)
{
gates.push_back(newGate);
}