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