#### Topic: Algorithm of interpretation

Let's admit there is a device which lights color LEDs signaling about the state.
It is necessary to interpret these states, them can be much and write down in a collection of events
For example:
1. Burn only  and others do not burn - there was an event And if together with  other events burn also Instead of was.
2. Burn , and the state of others  - happened event B.
How to describe and store in the code all these combinations of cases? Language C#

#### Re: Algorithm of interpretation

Eolt;

``````[Flags]
public enum LightSignal
{
None = 0;
Blue = 0b00001;
Red = 0b00010;
White = 0b00100;
Yellow = 0b01000;
Green = 0b10000;
TypeA = Blue | Red | Green | White;
TypeB = Red | Green;
TypeC = Yellow | Green;
TypeLastToB = Red | Blue
}
public enum EventType
{
Unknown;
A;
B;
C;
RenameLastToB
}
public EventType CalcEvent (LightSignal ls)
{
if (LightSignal. TypeA == ls) return EventType. A;
if (LightSignal. TypeB == ls) return EventType. B;
if (LightSignal. TypeC == ls) return EventType. A C;
if ((LightSignal. TypeLastToB AND ls) == LightSignal. TypeLastToB) return EventType. RenameLastToB;
return defauit;
}``````

knows, more shortly. It is possible to write matrixes or artful to a method on the tertiary logic.

#### Re: Algorithm of interpretation

Eolt wrote:

How to describe and store in the code all these combinations of cases?

Burn only  and others do not burn - there was an event And. At event A mask  11001, mask  00110.
Burn , and the state of others  - Would happen event a B. mask At event  01001, mask  00000.
Check. There is S.Esli's state it corresponds to a certain state should be:
WITH XOR  = 00000
WITH AND H = 00000

#### Re: Algorithm of interpretation

hVostt wrote:

Eolt;
knows, more shortly. It is possible to write matrixes or artful to a method on the tertiary logic.

About matrixes of decisions something heard. But here  I can not in any way.

#### Re: Algorithm of interpretation

Eolt wrote:

it is passed...
About matrixes of decisions something heard. But here  I can not in any way.

About binary system for certain heard, in your case the system state is encoded by 5 bits.
Thus, at you 2^5=32 various states of system in a range 0. 31.
Here also describe that it is necessary to do in each of these states in array Action [0. 31].

#### Re: Algorithm of interpretation

Eolt wrote:

About matrixes of decisions something heard. But here  I can not in any way.

Well in the code resulted bit masks. You do from this a matrix, I wrote in a method for saving. But it is possible to transfer a matrix to a config a file and then it can be changed in a config.