Пример #1
0
        /// <summary>
        /// 在收到总控的K令数据包时,根据K令号获得K令实际内容
        /// </summary>
        /// <param name="j"></param>
        /// <param name="ch"></param>
        /// <returns></returns>
        public static string Get_KcmdText(int j, ref byte[] ch)
        {
            byte[] temp = new byte[5];
            try
            {
                temp[0] = Data.KcmdText[4 * (j - 1)];
                temp[1] = Data.KcmdText[4 * (j - 1) + 1];
                temp[2] = Data.KcmdText[4 * (j - 1) + 2];
                temp[3] = Data.KcmdText[4 * (j - 1) + 3];
            }
            catch (Exception ex)
            {
                MyLog.Error("执行本地发送K令失败,未加载K令码表" + ex.Message);
                return("Error");
            }
            ch[0] = temp[0];
            ch[1] = (byte)((temp[1] & 0xf0) + ((temp[2] & 0xf0) >> 4));
            ch[2] = (byte)(((temp[2] & 0x0f) << 4) + ((temp[3] & 0xf0) >> 4));
            ch[3] = ch[0];
            ch[4] = ch[1];
            ch[5] = ch[2];
            ch[6] = ch[0];
            ch[7] = ch[1];
            ch[8] = ch[2];

            string KcmdStr = null;

            for (int i = 0; i < 9; i++)
            {
                KcmdStr += ch[i].ToString("x2");
            }
            return(KcmdStr);
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            ListViewItem item;

            ListViewItem.ListViewSubItem subitem1;
            ListViewItem.ListViewSubItem subitem2;

            listView1.Items.Clear();
            string        path   = Program.GetStartupPath() + comboBox1.Text + "\\" + comboBox2.Text + '\\';
            DirectoryInfo folder = new DirectoryInfo(path);

            try
            {
                foreach (FileInfo file in folder.GetFiles("*.*"))
                {
                    item          = new ListViewItem();
                    item.Text     = file.Name;
                    subitem1      = new ListViewItem.ListViewSubItem();
                    subitem1.Text = file.FullName;
                    item.SubItems.Add(subitem1);
                    subitem2      = new ListViewItem.ListViewSubItem();
                    subitem2.Text = file.Length.ToString();
                    item.SubItems.Add(subitem2);
                    listView1.Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                MyLog.Error(ex.Message);
            }
        }
Пример #3
0
        public void ServerStart2()
        {
            Trace.WriteLine("------------------------进入ServerStart2");
            ClientAPP.ClientZK1_YC.ClientIP = ConfigurationManager.AppSettings["ZK1IP"];
            ServerOn_YC = true;
            ClientAPP.ClientZK1_YC.IsConnected = false;

            ServerPort2   = int.Parse(ConfigurationManager.AppSettings["LocalPort1_YC"]);
            ServerSocket2 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPAddress address2 = IPAddress.Parse(ConfigurationManager.AppSettings["LocalIP1"]);

            try
            {
                ServerSocket2.Bind(new IPEndPoint(address2, ServerPort2));
                ServerSocket2.Listen(10);
                ServerSocket2.BeginAccept(new AsyncCallback(onCall_GT), ServerSocket2);
            }
            catch (Exception ex)
            {
                MyLog.Error("启动<--遥测<--服务器监听总控线程失败,检查IP设置和网络连接");
                Trace.WriteLine(ex.Message);
                ServerOn_YC = false;
            }
            Trace.WriteLine("------------------------退出ServerStart2");
        }
Пример #4
0
        public void ServerStart()
        {
            Trace.WriteLine("------------------------进入ServerStart");
            ClientAPP.ClientZK1.ClientIP = ConfigurationManager.AppSettings["ZK1IP"];
            ServerOn = true;
            ClientAPP.ClientZK1.IsConnected = false;

            //     new Thread(() => { WhichZKOn(); }).Start();

            ServerPort   = int.Parse(ConfigurationManager.AppSettings["LocalPort1_YK"]);
            ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            IPAddress address = IPAddress.Parse(ConfigurationManager.AppSettings["LocalIP1"]);

            try
            {
                ServerSocket.Bind(new IPEndPoint(address, ServerPort));
                //  ServerSocket.Bind(new IPEndPoint(IPAddress.Any, ServerPort));
                ServerSocket.Listen(10);
                ServerSocket.BeginAccept(new AsyncCallback(onCall), ServerSocket);//继续接受其他客户端的连接
            }
            catch (Exception ex)
            {
                MyLog.Error("启动-->遥测-->服务器监听总控线程失败,检查IP设置和网络连接");
                Trace.WriteLine(ex.Message);
                ServerOn = false;
            }
            Trace.WriteLine("------------------------退出ServerStart");
        }
Пример #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "805H07_YKYC")
     {
         if (textBox2.Text == "123456")
         {
             MyLog.Info("用户名密码通过校验,解锁成功");
             mform.TagLock       = 0;
             mform.Logform_state = true;
             this.Close();
         }
         else
         {
             MyLog.Error("密码校验失败,解锁失败");
             this.label3.Text    = "密码错误";
             this.label3.Visible = true;
         }
     }
     else
     {
         MyLog.Error("用户名校验失败,解锁失败");
         this.label4.Text    = "用户名错误";
         this.label4.Visible = true;
     }
 }
Пример #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            byte[] VCDU = new byte[1018];

            byte b1 = byte.Parse((string)Data.dtVCDU.Rows[0]["版本号"], System.Globalization.NumberStyles.HexNumber);
            byte b2 = byte.Parse((string)Data.dtVCDU.Rows[0]["SCID"], System.Globalization.NumberStyles.HexNumber);
            byte b3 = byte.Parse((string)Data.dtVCDU.Rows[0]["VCID"], System.Globalization.NumberStyles.HexNumber);

            VCDU[0] = (byte)((byte)(b1 << 6) + (byte)(b2 >> 2));
            VCDU[1] = (byte)((byte)(b2 << 6) + b3);
            string temp = ((string)Data.dtVCDU.Rows[0]["虚拟信道帧计数"]).PadLeft(6, '0');

            VCDU[2] = byte.Parse(temp.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
            VCDU[3] = byte.Parse(temp.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
            VCDU[4] = byte.Parse(temp.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
            byte b4 = byte.Parse((string)Data.dtVCDU.Rows[0]["回放"], System.Globalization.NumberStyles.HexNumber);
            byte b5 = byte.Parse((string)Data.dtVCDU.Rows[0]["保留"], System.Globalization.NumberStyles.HexNumber);

            VCDU[5] = (byte)((byte)(b4 << 7) + b5);

            byte[] time_login = new byte[6];
            time_login = Function.Get_Time();
            time_login.CopyTo(VCDU, 6);//时间

            Data.dtVCDU.Rows[0]["插入域"] = time_login[0].ToString("x2") + time_login[1].ToString("x2")
                                         + time_login[2].ToString("x2") + time_login[3].ToString("x2")
                                         + time_login[4].ToString("x2") + time_login[5].ToString("x2");

            for (int i = 12; i < 1018; i++)
            {
                VCDU[i] = 0xff;
            }


            byte[] temp2 = Function.StrToHexByte(textBox2.Text);
            Array.Copy(temp2, 0, VCDU, 12, temp2.Length);


            byte[] Return_Send = Function.Make_tozk_YC_frame(Data.Data_Flag_Real, Data.InfoFlag_DMTC, VCDU);
            if (myServer.ServerOn_YC)
            {
                Data.DataQueue_GT.Enqueue(Return_Send);
                MyLog.Info("手动发送一次遥测数据--成功");
            }
            else
            {
                Data.dtYC.Rows[4]["数量"] = (int)Data.dtYC.Rows[4]["数量"] + 1;
                MyLog.Error("手动发送一次遥测数据--失败");
            }
        }
Пример #7
0
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            System.Windows.Forms.ListView lw = (System.Windows.Forms.ListView)sender;

            try
            {
                string filename = lw.FocusedItem.SubItems[1].Text;
                System.Diagnostics.Process.Start(filename);
            }
            catch
            {
                MyLog.Error("openfile err");
                //textBox.Text += "openfile err\r\n";
                return;
            }
        }
Пример #8
0
        //----------设置系统时间----------
        public static void Set_Time(byte[] data)
        {
            try
            {
                byte[] gettime = new byte[23];
                for (int datai = 0; datai < data.Length; datai++)
                {
                    gettime[datai] = byte.Parse(data[datai].ToString());
                }
                string dt_str = Encoding.ASCII.GetString(gettime);

                string     str     = dt_str.Substring(0, 4);
                SystemTime systime = new SystemTime();
                systime.vYear = ushort.Parse(str);

                str            = dt_str.Substring(5, 2);
                systime.vMonth = ushort.Parse(str);

                str          = dt_str.Substring(8, 2);
                systime.vDay = ushort.Parse(str);

                str           = dt_str.Substring(11, 2);
                systime.vHour = ushort.Parse(str);

                str             = dt_str.Substring(14, 2);
                systime.vMinute = ushort.Parse(str);

                str             = dt_str.Substring(17, 2);
                systime.vSecond = ushort.Parse(str);

                str = dt_str.Substring(20, 3);
                systime.vMilliseconds = ushort.Parse(str);
                //--------更改系统时间--------
                SetLocalTime(ref systime);
            }
            catch
            {
                MyLog.Error("设置系统时间失败!");
            }
        }
Пример #9
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox2.Enabled = true;
            switch (comboBox1.Text)
            {
            case "接收":
                comboBox2.Items.Clear();
                comboBox2.Items.Add("总控设备(主)");
                comboBox2.Items.Add("总控设备(备)");
                comboBox2.Items.Add("外系统接口计算机");
                comboBox2.SelectedIndex = 0;
                break;

            case "发送":
                comboBox2.Items.Clear();
                comboBox2.Items.Add("应答机a");
                comboBox2.Items.Add("应答机b");
                comboBox2.Items.Add("窄波束SSA");
                comboBox2.Items.Add("宽波束SSA");
                comboBox2.Items.Add("中继KSA");
                comboBox2.Items.Add("空空");
                comboBox2.Items.Add("其它舱(总控)");
                comboBox2.SelectedIndex = 0;
                break;

            case "小回路闭环":
                comboBox2.Items.Clear();
                comboBox2.Items.Add("应答机a");
                comboBox2.Items.Add("应答机b");
                comboBox2.Items.Add("窄波束SSA");
                comboBox2.Items.Add("宽波束SSA");
                comboBox2.SelectedIndex = 0;
                break;

            default:
                MyLog.Error("查询条件无效,无法查询文件");
                break;
            }
        }
Пример #10
0
 public void ServerStop()
 {
     Trace.WriteLine("------------------------进入ServerStop");
     ServerOn = false;
     ClientAPP.ClientZK1.IsConnected = false;
     Data.ServerConnectEvent.Set();
     try
     {
         ServerSocket.Close();
         foreach (var sock in ClientSocketList)
         {
             if (sock.Connected)
             {
                 sock.Shutdown(SocketShutdown.Both);
                 sock.Close();
             }
         }
     }
     catch (Exception ex)
     {
         MyLog.Error("ServerStop无法关闭,错误原因:" + ex.Message);
     }
     Trace.WriteLine("------------------------退出ServerStop");
 }