Skip to content

Commit c717ea9

Browse files
author
Cécile
committed
[FIX] - Fix inhibit
1 parent d1b7fd6 commit c717ea9

1 file changed

Lines changed: 23 additions & 24 deletions

File tree

Src/Components/C4514.cpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,21 @@ Component::MyComponent(nts::C4514)
2020
_inputs[22] = {22, nts::UNDEFINED, nullptr, -1};
2121
_inputs[23] = {23, nts::UNDEFINED, nullptr, -1};
2222

23-
_outputs[11] = {0, nts::UNDEFINED, nullptr, -1};
24-
_outputs[9] = {1, nts::UNDEFINED, nullptr, -1};
25-
_outputs[10] = {2, nts::UNDEFINED, nullptr, -1};
26-
_outputs[8] = {3, nts::UNDEFINED, nullptr, -1};
27-
_outputs[7] = {4, nts::UNDEFINED, nullptr, -1};
28-
_outputs[6] = {5, nts::UNDEFINED, nullptr, -1};
29-
_outputs[5] = {6, nts::UNDEFINED, nullptr, -1};
23+
_outputs[0] = {11, nts::UNDEFINED, nullptr, -1};
24+
_outputs[1] = {9, nts::UNDEFINED, nullptr, -1};
25+
_outputs[2] = {10, nts::UNDEFINED, nullptr, -1};
26+
_outputs[3] = {8, nts::UNDEFINED, nullptr, -1};
3027
_outputs[4] = {7, nts::UNDEFINED, nullptr, -1};
31-
_outputs[18] = {8, nts::UNDEFINED, nullptr, -1};
32-
_outputs[17] = {9, nts::UNDEFINED, nullptr, -1};
33-
_outputs[20] = {10, nts::UNDEFINED, nullptr, -1};
34-
_outputs[19] = {11, nts::UNDEFINED, nullptr, -1};
35-
_outputs[14] = {12, nts::UNDEFINED, nullptr, -1};
36-
_outputs[13] = {13, nts::UNDEFINED, nullptr, -1};
28+
_outputs[5] = {6, nts::UNDEFINED, nullptr, -1};
29+
_outputs[6] = {5, nts::UNDEFINED, nullptr, -1};
30+
_outputs[7] = {4, nts::UNDEFINED, nullptr, -1};
31+
_outputs[8] = {18, nts::UNDEFINED, nullptr, -1};
32+
_outputs[9] = {17, nts::UNDEFINED, nullptr, -1};
33+
_outputs[10] = {20, nts::UNDEFINED, nullptr, -1};
34+
_outputs[11] = {19, nts::UNDEFINED, nullptr, -1};
35+
_outputs[12] = {14, nts::UNDEFINED, nullptr, -1};
3736
_outputs[13] = {13, nts::UNDEFINED, nullptr, -1};
38-
_outputs[16] = {14, nts::UNDEFINED, nullptr, -1};
37+
_outputs[14] = {16, nts::UNDEFINED, nullptr, -1};
3938
_outputs[15] = {15, nts::UNDEFINED, nullptr, -1};
4039
}
4140

@@ -76,7 +75,9 @@ nts::Tristate C4514::computeOutput(nts::Pin &pin)
7675
for (auto it = _inputs.begin(); it != _inputs.end(); ++it)
7776
computeInput(it->second);
7877
conv = tranfsormBinaryToDecimal(_inputs[2].state, _inputs[3].state, _inputs[21].state, _inputs[22].state);
79-
if (conv == pin.pin)
78+
if (_inputs[23].state == nts::TRUE)
79+
pin.state = nts::FALSE;
80+
else if (conv == pin.pin)
8081
pin.state = nts::TRUE;
8182
else
8283
pin.state = nts::FALSE;
@@ -85,10 +86,8 @@ nts::Tristate C4514::computeOutput(nts::Pin &pin)
8586

8687
nts::Tristate C4514::compute(std::size_t pin)
8788
{
88-
if (_inputs[23].state == nts::TRUE)
89-
_outputs[pin].state = nts::FALSE;
9089
for (auto it = _outputs.begin(); it != _outputs.end(); ++it) {
91-
if (pin == it->first) {
90+
if (pin == it->second.pin) {
9291
return computeOutput(it->second);
9392
}
9493
}
@@ -101,11 +100,11 @@ void C4514::checkSelfLink(std::size_t pin1, std::size_t pin2)
101100
bool output = false;
102101

103102
for (auto it = _inputs.begin(); it != _inputs.end(); ++it) {
104-
if (it->first == pin1 || it->first == pin2)
103+
if (it->second.pin == pin1 || it->second.pin == pin2)
105104
input = true;
106105
}
107106
for (auto it = _outputs.begin(); it != _outputs.end(); ++it) {
108-
if (it->first == pin1 || it->first == pin2)
107+
if (it->second.pin == pin1 || it->second.pin == pin2)
109108
output = true;
110109
}
111110
if (!(input == true && output == true))
@@ -119,7 +118,7 @@ void C4514::setLink(std::size_t pin , nts::IComponent &other, std::size_t otherP
119118
if (this == &other)
120119
checkSelfLink(pin, otherPin);
121120
for (auto it = _inputs.begin(); it != _inputs.end() && find == false; ++it) {
122-
if (it->first == pin) {
121+
if (it->second.pin == pin) {
123122
it ->second.destinationName = &other;
124123
it->second.destinationPin = otherPin;
125124
try {
@@ -132,7 +131,7 @@ void C4514::setLink(std::size_t pin , nts::IComponent &other, std::size_t otherP
132131
}
133132
}
134133
for (auto it = _outputs.begin(); it != _outputs.end() && find == false; ++it) {
135-
if (it->first == pin) {
134+
if (it->second.pin == pin) {
136135
it ->second.destinationName = &other;
137136
it->second.destinationPin = otherPin;
138137
try {
@@ -153,7 +152,7 @@ void C4514::setInput(std::size_t pin, nts::IComponent &other, std::size_t otherP
153152
bool find = false;
154153

155154
for (auto it = _inputs.begin(); it != _inputs.end() && find == false; ++it) {
156-
if (it->first == pin) {
155+
if (it->second.pin == pin) {
157156
if (it->second.destinationName != nullptr)
158157
throw Error::Component::LinkError("Pin already linked", "C4514::setInput");
159158
it->second.destinationName = &other;
@@ -170,7 +169,7 @@ void C4514::setOutput(std::size_t pin, nts::IComponent &other, std::size_t other
170169
bool find = false;
171170

172171
for (auto it = _outputs.begin(); it != _outputs.end() && find == false; ++it) {
173-
if (it->first == pin) {
172+
if (it->second.pin == pin) {
174173
it->second.destinationName = &other;
175174
it->second.destinationPin = otherPin;
176175
find = true;

0 commit comments

Comments
 (0)