Exemplo n.º 1
0
        /// <summary>
        /// 将回复数据放入队列
        /// </summary>
        /// <param name="GS">GSM服务</param>
        /// <param name="STCD">测站编号</param>
        /// <param name="bt">数据</param>
        public static void WriteGsdQ(GsmServer GS, string STCD, byte[] bt)
        {
            ConcurrentQueue <GsmSendData> Qgsd = GS.GQ.Qgsd;

            GsmSendData gsd = new GsmSendData();

            gsd.Data = bt;
            gsd.STCD = STCD;
            lock (Qgsd)
            {
                Qgsd.Enqueue(gsd);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 从回复队列中回复数据(未使用)
        /// </summary>
        /// <param name="GS">GSM服务</param>
        public static void SendData(GsmServer GS)
        {
            string ServiceId = GS.ServiceID;
            ConcurrentQueue <GsmSendData> Qgsd = GS.GQ.Qgsd;
            List <GsmMobile> Gs = GS.Gs;

            GSMMODEM.GsmModem gm = GS.gm;

            lock (Qgsd)
            {
                int k = Qgsd.Count;
                while (Qgsd.Count > 0)
                {
                    GsmSendData gs = null;
                    Qgsd.TryDequeue(out gs);
                    if (gs != null)
                    {
                        lock (Gs)
                        {
                            var temp = from g in Gs where gs.STCD == g.STCD select g;
                            List <GsmMobile> TEMP = temp.ToList <GsmMobile>();
                            if (TEMP.Count() > 0)
                            {
                                try
                                {
                                    gm.SendMsg(TEMP.First().MOBILE, gs.Data);
                                }
                                catch (Exception ex)
                                {
                                    ServiceControl.log.Error(DateTime.Now + ex.ToString());
                                }
                                //ServiceBussiness.WriteQUIM("GSM", ServiceId, temp.First().STCD, "回复数据", gs.Data, Service.ServiceEnum.EnCoderType.HEX, Service.ServiceEnum.DataType.Text);
                            }
                            else
                            {
                                Qgsd.Enqueue(gs);
                            }
                        }
                        k--;
                        if (k <= 0)
                        {
                            return;
                        }
                    }

                    System.Threading.Thread.Sleep(800);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 移除召测命令集中的命令
        /// </summary>
        /// <param name="GS">gsm服务</param>
        /// <param name="STCD">站号</param>
        /// <param name="CommandCode">命令码</param>
        public static void RemoveGsdQ(GsmServer GS, string STCD, string CommandCode)
        {
            ConcurrentQueue <GsmSendData> Qgsd = GS.GQ.Qgsd;

            lock (Qgsd)
            {
                for (int i = 0; i < GS.GQ.Qgsd.Count; i++)
                {
                    GsmSendData gsd = null;
                    if (Qgsd.TryDequeue(out gsd))
                    {
                        if (gsd.STCD != STCD || gsd.COMMANDCODE != CommandCode)
                        {
                            Qgsd.Enqueue(gsd);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 将回复数据放入队列
        /// </summary>
        /// <param name="GS">GSM服务</param>
        /// <param name="STCD">测站编号</param>
        /// <param name="bt">数据</param>
        /// <param name="CommandCode">命令码</param>
        public static void WriteGsdQ(GsmServer GS, string STCD, byte[] bt, string CommandCode)
        {
            ConcurrentQueue <GsmSendData> Qgsd = GS.GQ.Qgsd;

            var qgsd = from g in Qgsd where g.STCD == STCD && g.COMMANDCODE == CommandCode select g;
            List <GsmSendData> QGSD = qgsd.ToList <GsmSendData>();

            lock (Qgsd)
                if (QGSD.Count() > 0)
                {
                    QGSD.First().Data = bt;
                }
                else
                {
                    GsmSendData gsd = new GsmSendData();
                    gsd.Data        = bt;
                    gsd.STCD        = STCD;
                    gsd.COMMANDCODE = CommandCode;
                    Qgsd.Enqueue(gsd);
                }
        }