Esempio n. 1
0
        /// <summary>
        /// 参数:[0板卡,1扩展模块],[板卡号0-2],[模块号0-3],[输出端口号0-15]
        /// </summary>
        /// <param name="CardType"></param>
        /// <param name="CardNum"></param>
        /// <param name="Mdl"></param>
        /// <param name="Index"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static bool NSetDO(int CardType, int CardNum, int Mdl, int Index)
        {
            try
            {
                switch (CardType)
                {
                case 0:
                    if (Gg.GetDo((short)CardNum, (short)Index) == 1)
                    {
                        Gg.SetDo((short)CardNum, (short)Index, (short)0);
                    }
                    else
                    {
                        Gg.SetDo((short)CardNum, (short)Index, (short)1);
                    }
                    break;

                case 1:
                    if (Gg.GetExDo((short)Mdl, (short)Index) == 1)
                    {
                        Gg.SetExDo(0, (short)Mdl, (short)Index, (short)0);
                    }
                    else
                    {
                        Gg.SetExDo(0, (short)Mdl, (short)Index, (short)1);
                    }
                    break;
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        public static short mGetDO(int CardTag, int index)
        {
            //      CardIndex              CardInfo
            //控件  TabIndex  代表卡类型, Tag(A,B) A代表卡号,B代表模块序号(0-15);
            //CardType=0 固高卡自带IO,CardType=1 固高卡扩展IO。
            int    CardType  = 0;
            string CardInfo  = "0,0";
            int    CardIndex = 0;
            int    CardNum   = 0;
            int    ReturnStr = 0;

            switch (CardTag)
            {
            case 0:     //0号输入单元
                CardType = 0;
                CardInfo = "0,0";
                break;

            case 1:     //1号输入单元
                CardType = 1;
                CardInfo = "0,0";
                break;

            case 2:     //3号输入单元
                CardType = 1;
                CardInfo = "0,1";
                break;

            case 3:     //3号输入单元
                CardType = 1;
                CardInfo = "0,2";
                break;
            }
            CardNum   = System.Convert.ToInt32(CardInfo.Substring(0, 1));
            CardIndex = System.Convert.ToInt32(CardInfo.Substring(CardInfo.Length - 1, 1));
            try
            {
                switch (CardType)
                {
                case 0:
                    ReturnStr = Math.Abs(Gg.GetDo((short)CardNum, (short)index));
                    break;

                case 1:
                    ReturnStr = Math.Abs(Gg.GetExDo((short)CardIndex, (short)index));
                    break;
                }
            }
            catch (Exception)
            {
                ReturnStr = 0;
            }
            return((short)ReturnStr);
        }
Esempio n. 3
0
        /// <summary>
        /// 参数:[0板卡,1扩展模块],[板卡号0-2],[模块号0-3],[输出端口号0-15]
        /// </summary>
        /// <param name="CardType"></param>
        /// <param name="CardNum"></param>
        /// <param name="Mdl"></param>
        /// <param name="Index"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static int NGetDO(int CardType, int CardNum, int Mdl, int Index)
        {
            int st = 0;

            try
            {
                switch (CardType)
                {
                case 0:
                    if (Gg.GetDo((short)CardNum, (short)Index) == 1)
                    {
                        st = 1;
                    }
                    else
                    {
                        st = 0;
                    }
                    break;

                case 1:
                    if (Gg.GetExDo((short)Mdl, (short)Index) == 1)
                    {
                        st = 1;
                    }
                    else
                    {
                        st = 0;
                    }
                    break;
                }
            }
            catch (Exception)
            {
                return(st);
            }
            return(st);
        }