Esempio n. 1
0
        public bool GetDI(int port)
        {
            Func <short, int> getDI = ty =>
            {
                int s;
                N.GT_GetDi(card, ty, out s).Verify();
                return(s);
            };

            var p = port;

            if (p < 0)
            {
                return(false);
            }

            if (p < 16)
            {
                return(CheckBit(getDI(Api.MC_GPI), p));
            }
            p -= 16;

            if (p < 8)
            {
                return(CheckBit(getDI(Api.MC_LIMIT_POSITIVE), p));
            }
            p -= 8;

            if (p < 8)
            {
                return(CheckBit(getDI(Api.MC_LIMIT_NEGATIVE), p));
            }
            p -= 8;

            if (p < 8)
            {
                return(CheckBit(getDI(Api.MC_ALARM), p));
            }
            p -= 8;

            if (p < 8)
            {
                return(CheckBit(getDI(Api.MC_HOME), p));
            }
            p -= 8;

            if (p < 8)
            {
                return(CheckBit(getDI(Api.MC_ARRIVE), p));
            }

            return(false);
        }