Ejemplo n.º 1
0
        public static void GetComTimeFor4()
        {
            foreach (ComServer item in Service.ServiceControl.com)
            {
                if (item.sp.IsOpen)
                {
                    lock (item.sp)
                    {
                        long   satellite = 0;
                        string Satellite = "000000";
                        if (long.TryParse(item.Satellite, out satellite))
                        {
                            Satellite = satellite.ToString("X").PadLeft(6, '0');
                        }

                        byte[] a       = EnCoder.HexStrToByteArray("24534A5343000D" + Satellite + "0000");
                        byte   b       = xor(a);         //异或校验
                        byte[] vBuffer = copybyte(a, b); //追加异或校验

                        //ComBussiness.XorSAT(ref vBuffer);
                        item.sp.Write(vBuffer, 0, vBuffer.Length);


                        Service.ServiceControl.LogInfoToTxt(Service.ServiceEnum.NFOINDEX.COM, "", vBuffer, "ASC");
                        Service.ServiceControl.LogInfoToTxt(Service.ServiceEnum.NFOINDEX.COM, "", vBuffer);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 信道启动时将命令读取到命令列表
        /// </summary>
        public static void ToQcsd()
        {
            var cmds = from cmd in ServiceControl.LC where cmd.SERVICETYPE == "COM" select cmd;

            foreach (var c in ServiceControl.com)
            {
                foreach (var item in cmds)
                {
                    if (c != null)
                    {
                        ComService.ComBussiness.WriteCsdQ(c, item.STCD, EnCoder.HexStrToByteArray(item.Data), item.CommandID);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 信道启动时将命令读取到命令列表
        /// </summary>
        public static void ToQtsd()
        {
            //命令本地列表中删除超时记录
            var cmds = from c in ServiceControl.LC where c.SERVICETYPE == ServiceEnum.NFOINDEX.TCP.ToString() && c.STATE == -1 && c.DATETIME < DateTime.Now.AddSeconds(-30) select c;

            foreach (var items in cmds)
            {
                List <Command> lc = ServiceBussiness.RemoveListCommand(items.STCD, Service.ServiceEnum.NFOINDEX.TCP, items.CommandID, -1);
                foreach (var item in lc)
                {
                    PublicBD.db.AddDataCommand(item.STCD, item.CommandID, item.DATETIME, DateTime.Now, item.Data, (int)Service.ServiceEnum.NFOINDEX.TCP, -1);
                }
            }

            cmds = from c in ServiceControl.LC where c.SERVICETYPE == ServiceEnum.NFOINDEX.TCP.ToString() && c.STATE == -2 && c.DATETIME < DateTime.Now.AddSeconds(-30) select c;
            foreach (var items in cmds)
            {
                List <Command> lc = ServiceBussiness.RemoveListCommand(items.STCD, Service.ServiceEnum.NFOINDEX.TCP, items.CommandID, -2);
                foreach (var item in lc)
                {
                    PublicBD.db.AddDataCommand(item.STCD, item.CommandID, item.DATETIME, DateTime.Now, item.Data, (int)Service.ServiceEnum.NFOINDEX.TCP, -2);
                }
            }

            cmds = from cmd in ServiceControl.LC where cmd.SERVICETYPE == "TCP" select cmd;
            foreach (var t in ServiceControl.tcp)
            {
                foreach (var item in cmds)
                {
                    if (t != null)
                    {
                        #region 编码
                        byte[] EncoderData = null;
                        if (ServiceControl.wrx.XMLObj.HEXOrASC == "HEX")
                        {
                            EncoderData = EnCoder.HexStrToByteArray(item.Data);
                        }
                        if (ServiceControl.wrx.XMLObj.HEXOrASC == "ASC")
                        {
                            EncoderData = Encoding.ASCII.GetBytes(item.Data);
                        }
                        #endregion

                        TcpService.TcpBussiness.WriteTsdQ(t, item.STCD, EncoderData, item.CommandID);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 信道启动时将命令读取到命令列表
        /// </summary>
        public static void ToQusd()
        {
            //命令本地列表中删除超时记录
            var            cmds = from c in ServiceControl.LC where c.SERVICETYPE == ServiceEnum.NFOINDEX.UDP.ToString() && c.STATE == -1 && c.DATETIME < DateTime.Now.AddSeconds(-30) select c;
            List <Command> CMDS = cmds.ToList <Command>();

            foreach (var items in CMDS)
            {
                var            lc = ServiceBussiness.RemoveListCommand(items.STCD, Service.ServiceEnum.NFOINDEX.UDP, items.CommandID, -1);
                List <Command> LC = lc.ToList <Command>();
                foreach (var item in LC)
                {
                    PublicBD.db.AddDataCommand(item.STCD, item.CommandID, item.DATETIME, DateTime.Now, item.Data, (int)Service.ServiceEnum.NFOINDEX.UDP, -1);
                }
            }

            cmds = from c in ServiceControl.LC where c.SERVICETYPE == ServiceEnum.NFOINDEX.UDP.ToString() && c.STATE == -2 && c.DATETIME < DateTime.Now.AddSeconds(-30) select c;
            CMDS = cmds.ToList <Command>();
            foreach (var items in CMDS)
            {
                List <Command> lc = ServiceBussiness.RemoveListCommand(items.STCD, Service.ServiceEnum.NFOINDEX.UDP, items.CommandID, -2);
                List <Command> LC = lc.ToList <Command>();
                foreach (var item in LC)
                {
                    PublicBD.db.AddDataCommand(item.STCD, item.CommandID, item.DATETIME, DateTime.Now, item.Data, (int)Service.ServiceEnum.NFOINDEX.UDP, -2);
                }
            }

            cmds = from cmd in ServiceControl.LC where cmd.SERVICETYPE == "UDP" select cmd;
            CMDS = cmds.ToList <Command>();
            foreach (var u in ServiceControl.udp)
            {
                foreach (var item in CMDS)
                {
                    if (u != null)
                    {
                        UdpService.UdpBussiness.WriteUsdQ(u, item.STCD, EnCoder.HexStrToByteArray(item.Data), item.CommandID);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public static void GetComStateFor4()
        {
            foreach (ComServer item in Service.ServiceControl.com)
            {
                if (item.sp.IsOpen)
                {
                    lock (item.sp)
                    {
                        long   satellite = 0;
                        string Satellite = "000000";
                        if (long.TryParse(item.Satellite, out satellite))
                        {
                            Satellite = satellite.ToString("X").PadLeft(6, '0');
                        }



                        //XTZJ
                        byte[] a       = EnCoder.HexStrToByteArray("2458545A4A000D" + Satellite + "0000");
                        byte   b       = xor(a);         //异或校验
                        byte[] vBuffer = copybyte(a, b); //追加异或校验

                        //byte[] enter = ASCIIEncoding.ASCII.GetBytes(item.sp.NewLine); //加回车
                        //Array.Resize(ref vBuffer, vBuffer.Length + enter.Length);
                        //Array.Copy(enter, 0, vBuffer, vBuffer.Length - enter.Length, enter.Length);

                        //ComBussiness.XorSAT(ref vBuffer);
                        item.sp.Write(vBuffer, 0, vBuffer.Length);


                        Service.ServiceControl.LogInfoToTxt(Service.ServiceEnum.NFOINDEX.COM, "", vBuffer, "ASC");
                        Service.ServiceControl.LogInfoToTxt(Service.ServiceEnum.NFOINDEX.COM, "", vBuffer);
                    }
                }
            }
        }