lundi 28 octobre 2019

Is there any algorithmic approach for this problem

I have set of opcodes to carryout a specific function but the tricky part is here: for example in the posted code below, channelABC is the input, which means: if in my product side has channel A, or channel b, or channel c is selected, it should match,OR, if in my product side . if channel b and c are selected it should match, basically if one or more of the Channels match (with input side or product side),- Led has to glow .

i tried to map it, but i am not sure of the right way to do it

typedef enum{
    ZoneA  = 0x01,
    ZoneB  = 0x02,
    ZoneC  = 0x04,
    ZoneD  = 0x08,
    zoneE  = 0x10,
    ZoneF  = 0x20,
    ZoneG  = 0x40,
    ZoneH  = 0x80,
    ZoneABCD = 0x0f,
    ZoneAB = 0x03,
    ZoneAC = 0x05,
    ZoneAD = 0x09,
    ZoneBC = 0x06,
    ZoneBD = 0x0A,
    ZoneCD = 0x0C,
    ZoneABC = 0x07 ,
    ZoneABD = 0x0B,
    ZoneBCD = 0x0E,
    NOZONE  = 0x00

}zone;


railzone =buffers[0];  //rail zone read the value , which is  the first element in the buffer when the packet info is transformed to buffer
            //railzone will have the input here
            if(railzone ==ZoneABCD || railzone == ZoneA  || railzone == ZoneB || railzone == ZoneC || railzone == ZoneD  || railzone == ZoneAB
                    || railzone == ZoneAC || railzone == ZoneAD || railzone == ZoneBC || railzone == ZoneBD || railzone == ZoneCD || railzone == ZoneABC ||
                    railzone == ZoneABD || railzone == ZoneBCD   )      
            {


            }

I am giving input as ZONEABC, AND I am having the zoneAB in my product and since two of the zoneA and b are present, it should glow the LED

Aucun commentaire:

Enregistrer un commentaire