radec/src/wire.cpp
2017-04-23 19:13:23 -04:00

40 lines
613 B
C++

#include "Wire.h"
Wire::Wire(int number, bool io, string inName)
{
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);
}