示例#1
0
        /// <summary>
        /// Calculates a start channel number.
        /// </summary>
        private bool CalcStartCnlNum(IBaseTable cnlTable, int cnlCnt, out int startCnlNum)
        {
            ChannelOptions channelOptions = appSettings.ChannelOptions;
            int            cnlMult        = channelOptions.CnlMult;
            int            cnlGap         = channelOptions.CnlGap;

            startCnlNum = cnlMult + channelOptions.CnlShift;
            int prevCnlNum = 0;

            foreach (int cnlNum in cnlTable.EnumerateKeys())
            {
                if (prevCnlNum < startCnlNum && startCnlNum <= cnlNum)
                {
                    if (startCnlNum + cnlCnt + cnlGap <= cnlNum)
                    {
                        return(true);
                    }
                    else
                    {
                        startCnlNum += cnlMult;
                    }
                }

                prevCnlNum = cnlNum;
            }

            return(startCnlNum <= ushort.MaxValue);
        }