コード例 #1
0
        public int SoftTrigge(int[] trigChns)
        {
            if (!IsOpen)
            {
                return((int)ErrorDef.NotOpen);
            }
            List <int> swDev = new List <int>();

            if (null != trigChns)
            {
                if (0 == trigChns.Length)
                {
                    return((int)ErrorDef.Success);
                }
                for (int i = 0; i < trigChns.Length; i++)
                {
                    if (trigChns[i] < 0 || trigChns[i] >= EncoderChannels)
                    {
                        throw new ArgumentOutOfRangeException(string.Format("SoftTrigge(trigChns[]) fialed By:trigChns[{0}] = {1} is outof range:0~{2}", i, trigChns[i], TrigChannels - 1));
                    }
                    if (!swDev.Contains(devIndexes[trigChns[i]]))
                    {
                        swDev.Add(devIndexes[trigChns[i]]);
                    }
                }
            }
            else
            {
                swDev.AddRange(devIndexes);
            }

            if (swDev.Count == 0)
            {
                return((int)ErrorDef.Success);
            }
            foreach (int devIdx in swDev)
            {
                if (0 != HTM.SWPosTrig(devIdx))
                {
                    return((int)ErrorDef.InvokeFailed);
                }
            }

            return((int)ErrorDef.Success);
        }