Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                WFHttpWebResponse WebResponse = new WFHttpWebResponse();
                string            url;
                byte[]            ss = StringsFunction.strToHexByte(textBox1.Text, " ");
                url = "http://www.mercedes-tool.com:9999/" + "AdminAPI/RegTE.aspx?ID=" + StringsFunction.byteToHexStr(ss, "");
                url = url + "&HexVer=" + textBox2.Text;

                HttpWebResponse hr  = WebResponse.CreateGetHttpResponse(url);
                string          ret = WebResponse.Content;
                if (ret == "ok")
                {
                    TextLog.AddTextLog(StringsFunction.byteToHexStr(ss, ""), System.Windows.Forms.Application.StartupPath + "\\regLog.txt", false);
                    MessageBox.Show("注册成功");
                }
                else if (ret == "reged")
                {
                    MessageBox.Show("已经注册");
                }
                else
                {
                    MessageBox.Show("注册失败:" + ret);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #2
0
 public static void ClearHPassLogThread()
 {
     while (Global.bRun)
     {
         try
         {
             WFHttpWebResponse web = new WFHttpWebResponse();
             web.CreateGetHttpResponse(@"http://192.168.0.158/");
             web.CreatePostHttpResponse(@"http://192.168.0.158/login", "username=root&password=root");
             HttpWebResponse hr  = web.CreateGetHttpResponse(@"http://192.168.0.158/m1_user_search_get_status");
             m1_Status[]     ret = WFJSON.JsonDeserializeBySingleData <m1_Status[]>(web.Content);
             foreach (m1_Status m1 in ret)
             {
                 m1.updatedAt = m1.updatedAt.Replace('T', ' ');
                 m1.updatedAt = m1.updatedAt.Replace("Z", "");
                 DateTime dt = Convert.ToDateTime(m1.updatedAt);
                 if (m1.progress == 100 && dt.AddMinutes(30) < DateTime.Now)
                 {
                     web.CreateGetHttpResponse(@"http://192.168.0.158/m1_search_user_remove?request_id=" + m1.id);
                 }
                 //http://192.168.0.158/m1_search_user_remove?request_id=484
             }
             Thread.Sleep(30 * 60 * 1000);
         }
         catch (System.Exception ex)
         {
             TextLog.AddTextLog("Unkown:" + ex.Message, Global.txtLogFolder + "ClearHPassLog.txt", true);
         }
     }
 }
Пример #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            CP1616_NoAddr_Packet.bVerify = false;
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);
            if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
            {
                MessageBox.Show("输入的端口号格式有问题!!");
                return;
            }
            toolStripButton1.Text = "停止";
            mcuClientContext      = null;
            tcpAsyncServer.Start();
            NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
            NetLog("服务器启动\r\n");
            NetLog("\r\n");
            timer1.Enabled = true;
            DateTime dt = DateTime.Now;

            fileHY = System.Windows.Forms.Application.StartupPath + "\\TextLog\\HY" + String.Format("{0:D4}{1:D2}{2:D2}{3:D2}{4:D2}{5:D2}", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileHY, false);
        }
Пример #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            tcpAsyncServer = new TCPAsyncServer();
            tcpAsyncServer.SaveDataProcessCallback = new SaveDataProcessCallbackDelegate(CP1616_NoAddr_Packet.SaveDataProcessCallbackProc);
            tcpAsyncServer.ErrorServerEvent       += new TCPErrorEvent(tcpAsyncServer_ErrorServer);
            tcpAsyncServer.AcceptServerEvent      += new TCPAcceptEvent(tcpAsyncServer_AcceptServer);
            tcpAsyncServer.DisconnectServerEvent  += new TCPDisconnectEvent(tcpAsyncServer_DisconnectServer);
            tcpAsyncServer.ReceiveServerEvent     += new TCPReceiveEvent(tcpAsyncServer_ReceiveServerEvent);


            mcuClientContext = null;
            if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
            {
                MessageBox.Show("输入的端口号格式有问题!!");
                return;
            }
            toolStripButton1.Text = "停止";
            tcpAsyncServer.Start();
            NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
            NetLog("服务器启动\r\n");
            NetLog("\r\n");
            listView1_Resize(null, null);
            timer1.Enabled = true;
            DateTime dt = DateTime.Now;
            string   filePT, fileMS, fileTC, fileLA;

            filePT = System.Windows.Forms.Application.StartupPath + "\\TextLog\\PT" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), filePT, false);
            fileMS = System.Windows.Forms.Application.StartupPath + "\\TextLog\\MS" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileMS, false);
            fileTC = System.Windows.Forms.Application.StartupPath + "\\TextLog\\TC" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileTC, false);
            fileLA = System.Windows.Forms.Application.StartupPath + "\\TextLog\\LA" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
            TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileLA, false);
        }
Пример #5
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (toolStripButton1.Text == "开始")
     {
         if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
         {
             MessageBox.Show("输入的端口号格式有问题!!");
             return;
         }
         toolStripButton1.Text = "停止";
         tcpAsyncServer.Start();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器启动\r\n");
         NetLog("\r\n");
         timer1.Enabled = true;
         DateTime dt = DateTime.Now;
         fileHY = System.Windows.Forms.Application.StartupPath + "\\TextLog\\HY" + String.Format("{0:D4}{1:D2}{2:D2}{3:D2}{4:D2}{5:D2}", dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second) + ".txt";
         TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileHY, false);
         //this.Text = tcpAsyncServer.TCPServerName + ":" + tcpAsyncServer.TCPServerPort;
     }
     else
     {
         toolStripButton1.Text = "开始";
         tcpAsyncServer.Stop();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器停止\r\n");
         NetLog("\r\n");
         mcuClientContext = null;
         timer1.Enabled   = false;
     }
 }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string queueID;
            string ret = "-2000";

            try
            {
                queueID = Request.QueryString["queueID"];
                //信息|用户id|实验id,实验名,实验室;
                if (string.IsNullOrEmpty(queueID))//没有这两个变量
                {
                    ret = "-1";
                    Response.Write(ret);
                    return;
                }
                KeyDataQueueData kd = new KeyDataQueueData();
                kd.ID = int.Parse(queueID);
                KeyDataQueueDataDBOption.delete(kd);
                ret = "1";
                Response.Write(ret);
                return;
            }
            catch (System.Exception ex)
            {
                ret = "-100," + ex.Message;
                TextLog.AddTextLog("Cancel_Unkown:" + ex.Message, Global.txtLogFolder + "KeyData.txt", true);
            }
            Response.Write(ret);
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string queueID;
            string ret = webAPIFunc.GetRetString(ErrType.UnkownErr);

            try
            {
                queueID = Request.QueryString["queueID"];
                //信息|用户id|实验id,实验名,实验室;
                if (string.IsNullOrEmpty(queueID))//没有这两个变量
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissParam);
                    Response.Write(ret);
                    return;
                }
                KeyDataWorkLogData kdl = KeyDataWorkLogDataDBOption.Get(int.Parse(queueID));
                if (kdl != null)//已完成
                {
                    if (kdl.bOK)
                    {
                        ret = webAPIFunc.GetRetString(ErrType.retOK);
                        Response.Write(ret);
                        return;
                    }
                    else
                    {
                        ret = "4,";
                        Response.Write(ret);
                        return;
                    }
                }
                int index = KeyDataQueueDataDBOption.GetIndex(queueID);
                if (index == -1)//申请的数据无效
                {
                    ret = "3,";
                    Response.Write(ret);
                    return;
                }
                else
                {
                    ret = "2," + index.ToString();
                    Response.Write(ret);
                    return;
                }
            }
            catch (System.Exception ex)
            {
                ret = webAPIFunc.GetRetString(ErrType.UnkownErr);
                TextLog.AddTextLog("Status_Unkown:" + ex.Message, Global.txtLogFolder + "KeyData.txt", true);
            }
            Response.Write(ret);
        }
Пример #8
0
 private void ShowTextLogProc(string str, bool newSection)
 {
     if (textBox1.Text.Length > 20000)
     {
         textBox1.Clear();
     }
     if (newSection)
     {
         textBox1.AppendText("---------------------" + DateTime.Now.ToString("yy年MM月dd日 hh:mm:ss") + "-------------------\r\n");
     }
     textBox1.AppendText(str + "\r\n");
     TextLog.AddTextLog(str, newSection);
 }
Пример #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         double v1, v2;
         v1 = UpdateDataDBOption.GetSoftVer();
         v2 = UpdateDataDBOption.GetHexVer();
         Response.Write(((int)ErrType.retOK).ToString() + "," + v1.ToString("f2") + "|" + v2.ToString("f2"));
     }
     catch (System.Exception ex)
     {
         Response.Write("-100," + ex.Message);
         TextLog.AddTextLog("GetVer_Unkown:" + ex.Message, Global.txtLogFolder + "Update.txt", true);
     }
 }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string ret = webAPIFunc.GetRetString(ErrType.UnkownErr);

            try
            {
                string post = WFHttpWebResponse.PostInput(Request.InputStream);
                if (string.IsNullOrEmpty(post))//没有这两个变量
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissParam);
                    Response.Write(ret);
                    return;
                }
                post = post.Substring(0, post.Length - 1);
                byte[]           rx = StringsFunction.strToHexByte(post, "");
                KeyDataQueueData kd = new KeyDataQueueData();
                kd.DeviceID  = StringsFunction.byteToHexStr(rx, 0, 4, "");
                kd.KeyOption = BytesOP.MakeShort(rx[4], rx[5]);
                kd.format    = rx[6];
                kd.IP        = aspNetFunc.getIp();
                kd.SSID      = StringsFunction.byteToHexStr(rx, 7, 4, "");
                kd.BIN       = StringsFunction.byteToHexStr(rx, 7, 1024, "");
                if (DeviceInfoDataDBOption.Get(kd.DeviceID) == null)
                {
                    ret = webAPIFunc.GetRetString(ErrType.NoRegDevice);
                    Response.Write(ret);
                    return;
                }
                int queueID = KeyDataQueueDataDBOption.Insert(kd);
                if (KeyDataWork.bCalc == false)
                {
                    KeyDataWork.autoResetEvent.Set();
                }
                ret = webAPIFunc.GetRetString(ErrType.retOK, queueID.ToString());
                Response.Write(ret);
                return;
            }
            catch (System.Exception ex)
            {
                ret = webAPIFunc.GetRetString(ErrType.UnkownErr);
                TextLog.AddTextLog("Add_Unkown:" + ex.Message, Global.txtLogFolder + "KayData.txt", true);
            }
            Response.Write(ret);
        }
Пример #11
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     MessageBox.Show("请转入暗场,点击确定继续");
     chart1.Series[0].Points.Clear();
     chart1.Series[1].Points.Clear();
     chart1.ChartAreas[0].AxisY.Title = "暗场均值";
     chart1.ChartAreas[1].AxisY.Title = "暗场方差";
     toolStrip1.Enabled = false;
     try
     {
         MaxTime = int.Parse(toolStripTextBox1.Text);
         PhotoNs = int.Parse(toolStripTextBox2.Text);
         PicN    = int.Parse(toolStripTextBox3.Text);
         iniFileOP.Write("System Run", "MaxTime", toolStripTextBox1.Text);
         iniFileOP.Write("System Run", "PhotoNs", toolStripTextBox2.Text);
         iniFileOP.Write("System Run", "PicN", toolStripTextBox3.Text);
     }
     catch //(System.Exception ex)
     {
         return;
     }
     dtStart  = DateTime.Now;
     fileName = SystemParam.TxtCustomDarkDataPath + dtStart.ToString("yyyyMMdd_HHmmss") + "\\数据" + ".txt";
     TextLog.AddTextLog("--------------" + dtStart.ToString() + "----------------", fileName, false);
     TextLog.AddTextLog(String.Format(SystemParam.TxtCustomDarkDataTitleFormat, "曝光时间(ms)", "暗场均值", "暗场方差"), fileName, false);
     //第一步、采集图像
     InitCam(PicN + 1);
     StatusLabelInfoTrash.Text = "";
     m_Xfer.Grab();
     waitProc             = new CMOSTestLib.WaitingProc();
     waitProc.MaxProgress = PhotoNs;
     CMOSTestLib.WaitingProcFunc wpf = new CMOSTestLib.WaitingProcFunc(暗场采集);
     if (!waitProc.Execute(wpf, "自定义暗场测试", CMOSTestLib.WaitingType.None, ""))
     {
         MessageBox.Show("用户终止自定义暗场测试");
         toolStrip1.Enabled = true;
         return;
     }
     MessageBox.Show("自定义暗场测试完成");
     toolStrip1.Enabled = true;
 }
Пример #12
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (toolStripButton1.Text == "开始")
     {
         if (!int.TryParse(tbPort.Text, out tcpAsyncServer.TCPServerPort))
         {
             MessageBox.Show("输入的端口号格式有问题!!");
             return;
         }
         toolStripButton1.Text = "停止";
         tcpAsyncServer.Start();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器启动\r\n");
         NetLog("\r\n");
         timer1.Enabled = true;
         DateTime dt = DateTime.Now;
         string   filePT, fileMS, fileTC, fileLA;
         filePT = System.Windows.Forms.Application.StartupPath + "\\TextLog\\PT" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
         TextLog.AddTextLog("实验开始时间:" + dt.ToString(), filePT, false);
         fileMS = System.Windows.Forms.Application.StartupPath + "\\TextLog\\MS" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
         TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileMS, false);
         fileTC = System.Windows.Forms.Application.StartupPath + "\\TextLog\\TC" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
         TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileTC, false);
         fileLA = System.Windows.Forms.Application.StartupPath + "\\TextLog\\LA" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
         TextLog.AddTextLog("实验开始时间:" + dt.ToString(), fileLA, false);
     }
     else
     {
         toolStripButton1.Text = "开始";
         tcpAsyncServer.Stop();
         NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
         NetLog("服务器停止\r\n");
         NetLog("\r\n");
         //bPic = false;
         timer1.Enabled   = false;
         mcuClientContext = null;
     }
 }
Пример #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string queueID, keyIndex, format;
            string ret = webAPIFunc.GetRetString(ErrType.UnkownErr);

            try
            {
                queueID  = Request.QueryString["queueID"];
                keyIndex = Request.QueryString["keyIndex"];
                format   = Request.QueryString["format"];
                //信息|用户id|实验id,实验名,实验室;
                if (string.IsNullOrEmpty(queueID) || string.IsNullOrEmpty(keyIndex) || string.IsNullOrEmpty(format))//没有这两个变量
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissParam);
                    Response.Write(ret);
                    return;
                }
                string bin = KeyDataWorkLogDataDBOption.GetFile(queueID, keyIndex, format);
                if (bin == null || bin == "")
                {
                    ret = webAPIFunc.GetRetString(ErrType.NoHexBin);
                    Response.Write(ret);
                    return;
                }
                else
                {
                    ret = "1," + bin;
                    Response.Write(ret);
                    return;
                }
            }
            catch (System.Exception ex)
            {
                ret = webAPIFunc.GetRetString(ErrType.UnkownErr);
                TextLog.AddTextLog("Get_Unkown:" + ex.Message, Global.txtLogFolder + "KeyData.txt", true);
            }
            Response.Write(ret);
        }
Пример #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string DeviceID, PocketIndex;
            string ret = "";

            try
            {
                DeviceID    = Request.QueryString["DeviceID"];
                PocketIndex = Request.QueryString["PocketIndex"];
                //信息|用户id|实验id,实验名,实验室;
                if (string.IsNullOrEmpty(DeviceID) || string.IsNullOrEmpty(PocketIndex))//没有这两个变量
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissParam);
                    Response.Write(ret);
                    return;
                }
                int index;
                if (!int.TryParse(PocketIndex, out index))
                {
                    ret = webAPIFunc.GetRetString(ErrType.ErrParam);
                    Response.Write(ret);
                    return;
                }
                if (index == 1)
                {
                    DeviceInfoData did = DeviceInfoDataDBOption.Get(DeviceID);
                    if (did == null)
                    {
                        ret = webAPIFunc.GetRetString(ErrType.NoRegDevice);
                        Response.Write(ret);
                        return;
                    }
                }
                string fileName = Global.hexBINFolder + DeviceID + ".bin";
                if (!FileOP.IsExist(fileName, FileOPMethod.File))
                {
                    ret = webAPIFunc.GetRetString(ErrType.NoHexBin);
                    Response.Write(ret);
                    return;
                }
                FileInfo f;
                f = new FileInfo(fileName);
                Stream stream = File.OpenRead(f.FullName);
                byte[] pBuf   = new byte[stream.Length];
                stream.Read(pBuf, 0, (int)stream.Length);
                stream.Close();
                if (index == 0)
                {
                    ret = webAPIFunc.GetRetString(ErrType.retOK, pBuf.Length.ToString());
                    Response.Write(ret);
                    return;
                }
                else
                {
                    int    size  = 1024 * 5; // 0480;
                    int    count = pBuf.Length / size;
                    int    left  = pBuf.Length % size;
                    int    x     = size * (index - 1);
                    string str;
                    if (index > count)//最后一包
                    {
                        //ret = ((int)ErrType.retOK).ToString() + ",";
                        str = StringsFunction.byteToHexStr(pBuf, x, left, "");
                        Response.Write(webAPIFunc.GetRetString(ErrType.retOK, str));
                        return;
                    }
                    else
                    {
                        //ret = ((int)ErrType.retOK).ToString() + ",";
                        str = StringsFunction.byteToHexStr(pBuf, x, size, "");
                        ret = ret + str;
                        //Debug.WriteLine(ret);
                        Response.Write(webAPIFunc.GetRetString(ErrType.retOK, str));
                        return;
                    }
                }
            }
            catch (System.Exception ex)
            {
                ret = webAPIFunc.GetRetString(ErrType.UnkownErr);
                TextLog.AddTextLog("GetHexData_Unkown:" + ex.Message, Global.txtLogFolder + "Update.txt", true);
            }
            Response.Write(ret);
        }
Пример #15
0
        public static void ESLPass()
        {
            UInt32 numBytesRead = 0;
            int    retryMax     = 10;
            int    retry        = retryMax;

            while (Global.bRun)
            {
                bCalc = false;
                autoResetEvent.WaitOne();
                bCalc = true;
                while (true)
                {
                    bool         bOK = false;
                    ESLQueueData eq  = ESLQueueDataDBOption.GetFirst();
                    if (eq == null)
                    {
                        break;
                    }
                    ESLWorkLogData elog = new ESLWorkLogData();
                    elog.Pass     = eq.Pass;
                    elog.IP       = eq.IP;
                    elog.sTime    = eq.sTime;
                    elog.DeviceID = eq.DeviceID;
                    try
                    {
                        byte[] bPass = WFNetLib.StringFunc.StringsFunction.strToHexByte(eq.Pass, "");
                        byte[] rxbuf = new byte[100];
                        retry = retryMax;
                        while (retry != 0)
                        {
                            retry--;
                            try
                            {
                                UInt32         ftdiDeviceCount = 0;
                                FTDI.FT_STATUS ftStatus        = FTDI.FT_STATUS.FT_OK;
                                FTDI           myFtdiDevice    = new FTDI();
//                                 ftStatus = myFtdiDevice.GetNumberOfDevices(ref ftdiDeviceCount);
//                                 if (ftStatus != FTDI.FT_STATUS.FT_OK)
//                                 {
//                                     continue;
//                                 }
//                                 if (ftdiDeviceCount == 0)
//                                 {
//                                     continue;
//                                 }
//                                 FTDI.FT_DEVICE_INFO_NODE[] ftdiDeviceList = new FTDI.FT_DEVICE_INFO_NODE[ftdiDeviceCount];
//                                 ftStatus = myFtdiDevice.GetDeviceList(ftdiDeviceList);
//                                 if (ftStatus == FTDI.FT_STATUS.FT_OK)
//                                 {
//                                     bool bFind = false;
//                                     for (int i = 0; i < ftdiDeviceCount;i++ )
//                                     {
//                                         if (ftdiDeviceList[i].SerialNumber.ToString() == "001054")
//                                         {
//                                             ftStatus = myFtdiDevice.OpenBySerialNumber(ftdiDeviceList[i].SerialNumber.ToString());
//                                             if (ftStatus != FTDI.FT_STATUS.FT_OK)
//                                             {
//                                                 //continue;
//                                                 break;
//                                             }
//                                             bFind = true;
//                                             break;
//                                         }
//                                     }
//                                     if(!bFind)
//                                         continue;
//                                 }
//                                 else
//                                 {
//                                     continue;
//                                 }
                                ftStatus = myFtdiDevice.OpenBySerialNumber("DA00UTH1");
                                if (ftStatus != FTDI.FT_STATUS.FT_OK)
                                {
                                    continue;
                                }
                                ftStatus = myFtdiDevice.ResetDevice();
                                if (ftStatus != FTDI.FT_STATUS.FT_OK)
                                {
                                    continue;
                                }
                                ftStatus = myFtdiDevice.SetBaudRate(300);
                                if (ftStatus != FTDI.FT_STATUS.FT_OK)
                                {
                                    continue;
                                }
                                ftStatus = myFtdiDevice.SetTimeouts(30000, 30000);
                                if (ftStatus != FTDI.FT_STATUS.FT_OK)
                                {
                                    continue;
                                }
                                byte[] txbuf = new byte[100];
                                txbuf[0] = 0xf0;
                                ftStatus = myFtdiDevice.Write(txbuf, 1, ref numBytesRead);
                                if (ftStatus != FTDI.FT_STATUS.FT_OK)
                                {
                                    continue;
                                }
                                Thread.Sleep(200);
                                txbuf[0] = 0x30;
                                txbuf[1] = 0x00;
                                for (int i = 0; i < 8; i++)
                                {
                                    txbuf[2 + i] = bPass[i];
                                }
                                txbuf[10] = WFNetLib.Verify.GetVerify_byteSum(txbuf, 10);
                                ftStatus  = myFtdiDevice.Write(txbuf, 11, ref numBytesRead);
                                if (ftStatus != FTDI.FT_STATUS.FT_OK)
                                {
                                    continue;
                                }
                                ftStatus = myFtdiDevice.Read(rxbuf, 11, ref numBytesRead);
                                if (ftStatus != FTDI.FT_STATUS.FT_OK)
                                {
                                    continue;
                                }
                                ftStatus = myFtdiDevice.Close();
                                if (ftStatus != FTDI.FT_STATUS.FT_OK)
                                {
                                    continue;
                                }
                                if (rxbuf[2] == 0x80 &&
                                    rxbuf[3] == 0x00 &&
                                    rxbuf[4] == 0x00 &&
                                    rxbuf[5] == 0x00 &&
                                    rxbuf[6] == 0x00 &&
                                    rxbuf[7] == 0x00 &&
                                    rxbuf[8] == 0x00 &&
                                    rxbuf[9] == 0x00)
                                {
                                    Thread.Sleep(5000);
                                    continue;
                                }
                                if (rxbuf[2] == 0x00 &&
                                    rxbuf[3] == 0x00 &&
                                    rxbuf[4] == 0x00 &&
                                    rxbuf[5] == 0x00 &&
                                    rxbuf[6] == 0x00 &&
                                    rxbuf[7] == 0x00 &&
                                    rxbuf[8] == 0x00 &&
                                    rxbuf[9] == 0x00)
                                {
                                    Thread.Sleep(5000);
                                    continue;
                                }
                                bOK = true;
                                break;
                            }
                            catch
                            {
                            }
                        }
                        if (bOK)
                        {
                            ESLRecodeData esl = new ESLRecodeData();
                            esl.Pass = eq.Pass;
                            esl.Ret  = WFNetLib.StringFunc.StringsFunction.byteToHexStr(rxbuf, 2, 8, "");
                            ESLRecodeDataDBOption.Insert(esl);
                            elog.Ret = esl.Ret;
                        }
                        else
                        {
                            elog.Ret = "err";
                        }
                        ESLWorkLogDataDBOption.Insert(elog);
                        ESLQueueDataDBOption.delete(eq.Pass, eq.IP, eq.DeviceID, eq.sTime.ToString());
                    }
                    catch (System.Exception ex)
                    {
                        elog.Ret = "err";
                        ESLWorkLogDataDBOption.Insert(elog);
                        ESLQueueDataDBOption.delete(eq.Pass, eq.IP, eq.DeviceID, eq.sTime.ToString());
                        TextLog.AddTextLog("Thread_Unkown:" + ex.Message, Global.txtLogFolder + "ESLPass.txt", true);
                    }
                }
            }
        }
Пример #16
0
        private void tcpAsyncServer_ReceiveServerEvent(object sender, ReceiveServerEventArgs e)
        {
            IPEndPoint ip = (IPEndPoint)e.Client.ClientSocket.RemoteEndPoint;

            //if (ip.Address.Equals(mcuSocketIP.Address))

            if (mcuClientContext != null && e.Client == mcuClientContext)
            {
                this.Invoke((EventHandler)(delegate
                {
                    CP1616_NoAddr_Packet rx = (CP1616_NoAddr_Packet)e.netPacket;
                    if (rx.Header.Command == 0x01)
                    {
                        textBox1.AppendText(DateTime.Now.ToLongTimeString() + "   :   ");
                        textBox1.AppendText("收到水听器采集板数据" + e.Client.clientEndPoint.ToString());
                        textBox1.AppendText("\r\n");
                        int max = 102400;
                        if (chart1.Series[0].Points.Count > max)
                        {
                            chart1.Series[0].Points.Clear();
                        }
                        StringBuilder sb = new StringBuilder();
                        for (int i = 0; i < (rx.Data.Length - 2); i += 2)
                        {
                            ushort ad = BytesOP.MakeShort(rx.Data[i], rx.Data[i + 1]);
                            double v = (double)ad;
                            v = v * 0.000078125;
                            v = v - 2.56;
                            //chart1.Series[0].Points.Clear();
                            chart1.Series[0].Points.AddY(v);
                            sb.AppendLine(v.ToString("F6"));
//                           int max = 1024000;
//                           if (chart1.Series[0].Points.Count > max)
//                           {
//                               while (chart1.Series[0].Points.Count > (max - 1024))
//                               {
//                                   chart1.Series[0].Points.RemoveAt(0);
//                               }
//                           }
                        }
                        TextLog.AddTextLog(sb.ToString(), fileHY, false);
                    }
                }));
            }
            else
            {
                this.Invoke((EventHandler)(delegate
                {
                    textBox1.AppendText(DateTime.Now.ToLongTimeString() + "   :   ");
                    textBox1.AppendText("收到未知IP数据" + e.Client.clientEndPoint.ToString() + ":");
                    textBox1.AppendText("\r\n");
                    CP1616_NoAddr_Packet rx = (CP1616_NoAddr_Packet)e.netPacket;
                    if (rx.Header.Command == 0xf0)
                    {
                        if (rx.Data[0] == 0x02)                         //矢量水听器采集板接入
                        {
                            mcuClientContext = e.Client;
                            //mcuSocketIP.Port = ip.Port;
                            this.Invoke((EventHandler)(delegate
                            {
                                NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
                                NetLog("水听器采集板接入");
                                NetLog("\r\n");
                            }));
                        }
                    }
                }));
            }
        }
Пример #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string ret         = webAPIFunc.GetRetString(ErrType.UnkownErr);
            string LinuxServer = ConfigurationManager.AppSettings["LinuxServer"];

            try
            {
                string post = WFHttpWebResponse.PostInput(Request.InputStream);
                if (string.IsNullOrEmpty(post))//没有这两个变量
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissParam);
                    Response.Write(ret);
                    return;
                }
                post = post.Substring(0, post.Length - 1);
                byte[] rx       = StringsFunction.strToHexByte(post, "");
                byte[] DeviceID = new byte[4];
                byte[] SSID     = new byte[4];
                byte[] data     = null;
                if (rx.Length == (0x401 * 0x08))
                {
                    for (int i = 0; i < 4; i++)
                    {
                        DeviceID[i] = rx[i];
                        SSID[i]     = rx[4 + i];
                    }
                    data = new byte[(0x400 * 0x08)];
                    for (int i = 0; i < (0x400 * 0x08); i++)
                    {
                        data[i] = rx[8 + i];
                    }
                }
                else if (rx.Length == (0x801 * 0x08))
                {
                    for (int i = 0; i < 4; i++)
                    {
                        DeviceID[i] = rx[i];
                        SSID[i]     = rx[4 + i];
                    }
                    data = new byte[(0x800 * 0x08)];
                    for (int i = 0; i < (0x800 * 0x08); i++)
                    {
                        data[i] = rx[8 + i];
                    }
                }
                else
                {
                    webAPIFunc.GetRetString(ErrType.ErrFileLen);
                    Response.Write(ret);
                    return;
                }
                byte[]         txData      = GlobalFunc.Encrypt(data, DeviceID, SSID);
                string         strDeviceID = StringsFunction.byteToHexStr(DeviceID, "");
                string         strSSID     = StringsFunction.byteToHexStr(SSID, "");
                DeviceInfoData did         = DeviceInfoDataDBOption.Get(strDeviceID);
                if (did == null)
                {
                    ret = webAPIFunc.GetRetString(ErrType.NoRegDevice);
                    Response.Write(ret);
                    return;
                }
                else
                {
                    int ut = HPassWorkLogDataDBOption.GetUseTimes(strDeviceID);
                    if (ut > did.HPassTimes)
                    {
                        ret = webAPIFunc.GetRetString(ErrType.MaxUseTimes);
                        Response.Write(ret);
                        return;
                    }
                }
                int index = HPassWorkLogDataDBOption.GetIndex(strDeviceID, strSSID);
                index++;
                string            fileName = strDeviceID + strSSID + "_" + index.ToString() + ".txt";
                WFHttpWebResponse web      = new WFHttpWebResponse();
                HttpWebResponse   webRet   = web.CreateGetHttpResponse(LinuxServer);
                if (webRet == null)
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissServer);
                    Response.Write(ret);
                    return;
                }
                webRet = web.CreatePostHttpResponse(LinuxServer + @"/login", "username=root&password=root");
                if (webRet == null)
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissServer);
                    Response.Write(ret);
                    return;
                }
                webRet = web.CreateGetHttpResponse(LinuxServer + @"/search_m1_user");
                if (webRet == null)
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissServer);
                    Response.Write(ret);
                    return;
                }
                HttpWebRequest request = null;
                request        = WebRequest.Create(LinuxServer + @"/m1_user_search_add") as HttpWebRequest;
                request.Method = "POST";
                string boundary = DateTime.Now.Ticks.ToString("x");
                //请求
                request.ContentType = "multipart/form-data; boundary=---------------------------" + boundary;

                request.CookieContainer = new CookieContainer();
                if (web.Cookies != null && web.Cookies.Count != 0)
                {
                    foreach (Cookie c in web.Cookies)
                    {
                        request.CookieContainer.Add(c);
                    }
                }

                //组织表单数据
                StringBuilder sb = new StringBuilder();
                sb.Append("-----------------------------" + boundary);
                sb.Append("\r\n");
                sb.Append("Content-Disposition: form-data; name=\"search_source\"; filename=\"" + fileName + "\"");
                sb.Append("\r\n");
                sb.Append("Content-Type: text/plain");
                sb.Append("\r\n\r\n");
                string head      = sb.ToString();
                byte[] form_data = Encoding.ASCII.GetBytes(head);
                //结尾
                byte[] foot_data = Encoding.ASCII.GetBytes("\r\n-----------------------------" + boundary + "--\r\n");
                //数据
                StringBuilder sb1 = new StringBuilder();
                if (rx.Length == (0x401 * 0x08))
                {
                    for (int i = 0; i < 0x400; i++)
                    {
                        sb1.Append(StringsFunction.byteToHexStr(txData, i * 8, 8, " "));
                        sb1.Append("\r\n");
                    }
                }
                else
                {
                    for (int i = 0; i < 0x800; i++)
                    {
                        sb1.Append(StringsFunction.byteToHexStr(txData, i * 8, 8, " "));
                        sb1.Append("\r\n");
                    }
                }
                sb1.Remove(sb1.Length - 2, 2);
                TextLog.AddTextLog(sb1.ToString(), Global.txtLogFolder + "HPassLog\\" + fileName, false);
                byte[] pBuf = Encoding.ASCII.GetBytes(sb1.ToString());
                //post总长度
                long length = form_data.Length + pBuf.Length + foot_data.Length;
                request.ContentLength = length;
                using (Stream requestStream = request.GetRequestStream())
                {
                    requestStream.Write(form_data, 0, form_data.Length);
                    //文件内容
                    requestStream.Write(pBuf, 0, pBuf.Length);
                    //结尾
                    requestStream.Write(foot_data, 0, foot_data.Length);
                }
                try
                {
                    HttpWebResponse fileResponse = request.GetResponse() as HttpWebResponse;
                    string          Content;
                    if (fileResponse.Headers["ContentEncoding"] != null)
                    {
                        Stream       receiveStream = fileResponse.GetResponseStream();
                        StreamReader sr            = new StreamReader(receiveStream, Encoding.GetEncoding(fileResponse.Headers["ContentEncoding"].ToString()));
                        Content = sr.ReadToEnd();
                    }
                    else
                    {
                        try
                        {
                            Stream       receiveStream = fileResponse.GetResponseStream();
                            StreamReader sr            = new StreamReader(receiveStream);
                            Content = sr.ReadToEnd();
                        }
                        catch
                        {
                        }
                    }
                    if (fileResponse.StatusCode == HttpStatusCode.OK)
                    {
                        ret = webAPIFunc.GetRetString(ErrType.retOK, fileName);
                        HPassWorkLogData hl = new HPassWorkLogData();
                        hl.DeviceID = strDeviceID;
                        hl.SSID     = strSSID;
                        hl.FileName = fileName;
                        hl.IP       = aspNetFunc.getIp();
                        HPassWorkLogDataDBOption.Insert(hl);
                        Response.Write(ret);
                        return;
                    }
                }
                catch (System.Exception ex)
                {
                    ret = webAPIFunc.GetRetString(ErrType.UnkownErr);
                    Response.Write(ret);
                    TextLog.AddTextLog("Add_updatafile:" + ex.Message, Global.txtLogFolder + "HPass.txt", true);
                    return;
                }
            }
            catch (System.Exception ex)
            {
                ret = webAPIFunc.GetRetString(ErrType.UnkownErr);
                TextLog.AddTextLog("Add_Unkown:" + ex.Message, Global.txtLogFolder + "HPass.txt", true);
            }
            Response.Write(ret);
        }
Пример #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string FileName;
            string ret         = webAPIFunc.GetRetString(ErrType.UnkownErr);
            string LinuxServer = ConfigurationManager.AppSettings["LinuxServer"];

            try
            {
                FileName = Request.QueryString["FileName"];
                //信息|用户id|实验id,实验名,实验室;
                if (string.IsNullOrEmpty(FileName))//没有这两个变量
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissParam);
                    Response.Write(ret);
                    return;
                }
                HPassWorkLogData hl = HPassWorkLogDataDBOption.GetByFileName(FileName);
                if (hl == null)
                {
                    ret = webAPIFunc.GetRetString(ErrType.ErrParam);
                    Response.Write(ret);
                    return;
                }
                WFHttpWebResponse web    = new WFHttpWebResponse();
                HttpWebResponse   webRet = web.CreateGetHttpResponse(LinuxServer);
                if (webRet == null)
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissServer);
                    Response.Write(ret);
                    return;
                }
                webRet = web.CreatePostHttpResponse(LinuxServer + @"/login", "username=root&password=root");
                if (webRet == null)
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissServer);
                    Response.Write(ret);
                    return;
                }
                webRet = web.CreateGetHttpResponse(LinuxServer + @"/m1_user_search_get_status");
                if (webRet == null)
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissServer);
                    Response.Write(ret);
                    return;
                }
                m1_Status[] results = WFJSON.JsonDeserializeBySingleData <m1_Status[]>(web.Content);
                FileName = FileName + "_0";
                foreach (m1_Status m1 in results)
                {
                    if (m1.search_id == FileName)
                    {
                        if (m1.status == "inprogress")
                        {
                            if (m1.progress == 100)
                            {
                                string strResult = "";
                                if (m1.results != null)
                                {
                                    foreach (m1_result result in m1.results)
                                    {
                                        byte[] q  = StringsFunction.strToHexByte(result.query, " ");
                                        byte[] a  = StringsFunction.strToHexByte(result.answer, " ");
                                        string sq = StringsFunction.byteToHexStr(q, "");
                                        string sa = StringsFunction.byteToHexStr(a, "");
                                        strResult += sq + "-" + sa + "|";
                                    }
                                }
                                hl.eTime = DateTime.Now;
                                hl.Ret   = strResult;
                                HPassWorkLogDataDBOption.Update(hl);
                                ret = webAPIFunc.GetRetString(ErrType.retOK, strResult);
                                //ret = "1,100,"+strResult;
                                Response.Write(ret);
                                return;
                            }
                            else
                            {
                                ret = "2," + m1.progress.ToString();
                                Response.Write(ret);
                                return;
                            }
                        }
                        else if (m1.status == "pendding")
                        {
                            ret = "2,-1";
                            Response.Write(ret);
                            return;
                        }
                        else
                        {
                            ret = webAPIFunc.GetRetString(ErrType.ErrServerRet);
                            Response.Write(ret);
                            return;
                        }
                    }
                }
                ret = "3,";
                Response.Write(ret);
                return;
            }
            catch (System.Exception ex)
            {
                ret = webAPIFunc.GetRetString(ErrType.UnkownErr);
                TextLog.AddTextLog("Satus_Unkown:" + ex.Message, Global.txtLogFolder + "HPass.txt", true);
            }
            Response.Write(ret);
        }
Пример #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string DeviceID, PocketIndex;
            string ret = webAPIFunc.GetRetString(ErrType.UnkownErr);

            try
            {
                DeviceID    = Request.QueryString["DeviceID"];
                PocketIndex = Request.QueryString["PocketIndex"];
                //信息|用户id|实验id,实验名,实验室;
                if (string.IsNullOrEmpty(DeviceID) || string.IsNullOrEmpty(PocketIndex))//没有这两个变量
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissParam);
                    Response.Write(ret);
                    return;
                }
                int index;
                if (!int.TryParse(PocketIndex, out index))
                {
                    ret = webAPIFunc.GetRetString(ErrType.ErrParam);
                    Response.Write(ret);
                    return;
                }
                if (index == 1)
                {
                    DeviceInfoData did = DeviceInfoDataDBOption.Get(DeviceID);
                    if (did == null)
                    {
                        ret = webAPIFunc.GetRetString(ErrType.NoRegDevice);
                        Response.Write(ret);
                        return;
                    }
                }
                DataTable dt   = UpdateDataDBOption.SoftDataTableSelect();
                byte[]    data = (byte [])dt.Rows[0][1];
                if (index == 0)
                {
                    ret = "1," + data.Length.ToString();
                    Response.Write(ret);
                    return;
                }
                else
                {
                    int    size  = 2048 * 5; // 0480;
                    int    count = data.Length / size;
                    int    left  = data.Length % size;
                    int    x     = size * (index - 1);
                    string str;
                    if (index > count)//最后一包
                    {
                        ret = "1,";
                        str = StringsFunction.byteToHexStr(data, x, left, "");
                        Response.Write(ret + str);
                        return;
                    }
                    else
                    {
                        ret = "1,";
                        str = StringsFunction.byteToHexStr(data, x, size, "");
                        ret = ret + str;
                        Debug.WriteLine(ret);
                        Response.Write(ret);
                        return;
                    }
                }
            }
            catch (System.Exception ex)
            {
                ret = webAPIFunc.GetRetString(ErrType.UnkownErr);
                TextLog.AddTextLog("GetSoftData_Unkown:" + ex.Message, Global.txtLogFolder + "Update.txt", true);
            }
            Response.Write(ret);
        }
Пример #20
0
        private void tcpAsyncServer_ReceiveServerEvent(object sender, ReceiveServerEventArgs e)
        {
            IPEndPoint ip = (IPEndPoint)e.Client.ClientSocket.RemoteEndPoint;

            //if (ip.Address.Equals(mcuSocketIP.Address))

            if (mcuClientContext != null && e.Client == mcuClientContext)
            {
                this.Invoke((EventHandler)(delegate
                {
                    CP1616_NoAddr_Packet rx = (CP1616_NoAddr_Packet)e.netPacket;
                    if (rx.Header.Command == 0x01)
                    {
                        double f;
                        byte[] fb = new byte[4];
                        int fbIndex;
                        string str;
                        bool bSave = false;
                        DateTime dt = DateTime.Now;
                        //温度
                        f = BytesOP.MakeShort(rx.Data[0], rx.Data[1]);
                        f = f / 100;
                        listView1.Items[0].SubItems[1].Text = f.ToString("F2");
                        string filePT;
                        filePT = System.Windows.Forms.Application.StartupPath + "\\TextLog\\PT" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
                        TextLog.AddTextLog(dt.ToString() + "      " + listView1.Items[0].SubItems[1].Text, filePT, false);
                        //电子罗盘
                        fbIndex = 2;
                        for (int i = 0; i < 4; i++)
                        {
                            fb[i] = rx.Data[fbIndex + 3 - i];
                        }
                        f = BitConverter.ToSingle(fb, 0);
                        listView1.Items[1].SubItems[1].Text = f.ToString("F2");

                        fbIndex = 6;
                        for (int i = 0; i < 4; i++)
                        {
                            fb[i] = rx.Data[fbIndex + 3 - i];
                        }
                        f = BitConverter.ToSingle(fb, 0);
                        listView1.Items[2].SubItems[1].Text = f.ToString("F2");

                        fbIndex = 10;
                        for (int i = 0; i < 4; i++)
                        {
                            fb[i] = rx.Data[fbIndex + 3 - i];
                        }
                        f = BitConverter.ToSingle(fb, 0);
                        listView1.Items[3].SubItems[1].Text = f.ToString("F2");
                        string fileTC;
                        fileTC = System.Windows.Forms.Application.StartupPath + "\\TextLog\\TC" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
                        TextLog.AddTextLog(dt.ToString() + "      " + listView1.Items[1].SubItems[1].Text
                                           + "      " + listView1.Items[2].SubItems[1].Text
                                           + "      " + listView1.Items[3].SubItems[1].Text, fileTC, false);
                        //授时
                        str = Encoding.UTF8.GetString(rx.Data, 14, 10);
                        listView1.Items[4].SubItems[1].Text = str;

                        str = Encoding.UTF8.GetString(rx.Data, 24, 6);
                        listView1.Items[5].SubItems[1].Text = str;

                        //MS8607
                        f = BitConverter.ToSingle(rx.Data, 30);
                        listView1.Items[6].SubItems[1].Text = f.ToString("F2");

                        f = BitConverter.ToSingle(rx.Data, 34);
                        listView1.Items[7].SubItems[1].Text = f.ToString("F2");

                        f = BitConverter.ToSingle(rx.Data, 38);
                        listView1.Items[8].SubItems[1].Text = f.ToString("F2");
                        string fileMS;
                        fileMS = System.Windows.Forms.Application.StartupPath + "\\TextLog\\MS" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
                        TextLog.AddTextLog(dt.ToString() + "      " + listView1.Items[6].SubItems[1].Text
                                           + "      " + listView1.Items[7].SubItems[1].Text
                                           + "      " + listView1.Items[8].SubItems[1].Text, fileMS, false);
                        //光源
                        f = BytesOP.MakeShort(rx.Data[44], rx.Data[45]);
                        f = f / 10;
                        rioCur = f;
                        listView1.Items[14].SubItems[1].Text = f.ToString("F1");
                        ushort rioStatus = BytesOP.MakeShort(rx.Data[42], rx.Data[43]);
                        listView1.Items[15].SubItems[1].Text = rioStatus.ToString("X04");
                        if (BytesOP.GetBit(rioStatus, 0))
                        {
                            listView1.Items[16].SubItems[1].Text = "是";
                            listView1.Items[16].BackColor = Color.Lime;
                        }
                        else
                        {
                            listView1.Items[16].SubItems[1].Text = "否";
                            listView1.Items[16].BackColor = Color.Red;
                        }
                        if (BytesOP.GetBit(rioStatus, 6))
                        {
                            listView1.Items[17].SubItems[1].Text = "是";
                            listView1.Items[17].BackColor = Color.Red;
                        }
                        else
                        {
                            listView1.Items[17].SubItems[1].Text = "否";
                            listView1.Items[17].BackColor = Color.Lime;
                        }
                        if (BytesOP.GetBit(rioStatus, 7))
                        {
                            listView1.Items[18].SubItems[1].Text = "是";
                            listView1.Items[18].BackColor = Color.Red;
                        }
                        else
                        {
                            listView1.Items[18].SubItems[1].Text = "否";
                            listView1.Items[18].BackColor = Color.Lime;
                        }
                        if (BytesOP.GetBit(rioStatus, 11))//当前为新数据,需要存储
                        {
                            string fileLA;
                            fileLA = System.Windows.Forms.Application.StartupPath + "\\TextLog\\LA" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
                            TextLog.AddTextLog(dt.ToString() + "      " + listView1.Items[14].SubItems[1].Text
                                               + "      " + listView1.Items[15].SubItems[1].Text, fileLA, false);
                        }
                        //通信错误帧统计
                        listView1.Items[9].SubItems[1].Text = rx.Data[46].ToString();
                        if (rx.Data[46] > 5)
                        {
                            bSave = true;
                            listView1.Items[9].BackColor = Color.Red;
                        }
                        else
                        {
                            listView1.Items[9].BackColor = SystemColors.Window;
                        }

                        listView1.Items[10].SubItems[1].Text = rx.Data[47].ToString();
                        if (rx.Data[47] > 5)
                        {
                            bSave = true;
                            listView1.Items[10].BackColor = Color.Red;
                        }
                        else
                        {
                            listView1.Items[10].BackColor = SystemColors.Window;
                        }

                        listView1.Items[11].SubItems[1].Text = rx.Data[48].ToString();
                        if (rx.Data[48] > 5)
                        {
                            bSave = true;
                            listView1.Items[11].BackColor = Color.Red;
                        }
                        else
                        {
                            listView1.Items[11].BackColor = SystemColors.Window;
                        }

                        listView1.Items[12].SubItems[1].Text = rx.Data[49].ToString();
                        if (rx.Data[49] > 5)
                        {
                            bSave = true;
                            listView1.Items[12].BackColor = Color.Red;
                        }
                        else
                        {
                            listView1.Items[12].BackColor = SystemColors.Window;
                        }

                        listView1.Items[13].SubItems[1].Text = rx.Data[50].ToString();
                        if (rx.Data[50] > 5)
                        {
                            bSave = true;
                            listView1.Items[13].BackColor = Color.Red;
                        }
                        else
                        {
                            listView1.Items[13].BackColor = SystemColors.Window;
                        }

                        listView1.Items[19].SubItems[1].Text = rx.Data[51].ToString(); //漏水1
                        listView1.Items[20].SubItems[1].Text = rx.Data[52].ToString(); //漏水2
                        listView1.Items[21].SubItems[1].Text = rx.Data[53].ToString(); //备用IO1
                        listView1.Items[22].SubItems[1].Text = rx.Data[54].ToString(); //备用IO1
                        listView1.Items[23].SubItems[1].Text = rx.Data[55].ToString(); //备用IO1
                        listView1.Items[24].SubItems[1].Text = rx.Data[56].ToString(); //备用IO1
                        listView1.Items[25].SubItems[1].Text = rx.Data[57].ToString(); //备用IO1
                        listView1.Items[26].SubItems[1].Text = rx.Data[58].ToString(); //备用IO1

                        for (int i = 0; i < 6; i++)
                        {
                            bIO[i] = rx.Data[53 + i];
                        }

                        if (rx.Data[59] == 0)
                        {
                            listView1.Items[27].SubItems[1].Text = "打开";
                            bPower1 = true;
                        }
                        else
                        {
                            listView1.Items[27].SubItems[1].Text = "关闭";
                            bPower1 = false;
                        }

                        if (rx.Data[60] == 0)
                        {
                            listView1.Items[28].SubItems[1].Text = "打开";
                            bPower2 = true;
                        }
                        else
                        {
                            listView1.Items[28].SubItems[1].Text = "关闭";
                            bPower2 = false;
                        }

                        if (bSave)
                        {
                            NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
                            NetLog("收到单片机采集板数据" + e.Client.clientEndPoint.ToString() + ":");
                            NetLog(WFNetLib.StringFunc.StringsFunction.byteToHexStr(rx.Data, " "));
                            NetLog("\r\n");
                        }
                        else
                        {
                            textBox1.AppendText(DateTime.Now.ToLongTimeString() + "   :   ");
                            textBox1.AppendText("收到单片机采集板数据" + e.Client.clientEndPoint.ToString() + ":");
                            textBox1.AppendText(WFNetLib.StringFunc.StringsFunction.byteToHexStr(rx.Data, " "));
                            textBox1.AppendText("\r\n");
                        }
                    }
                    else if (rx.Header.Command == 0x08)//读取光源状态
                    {
                        timer2.Enabled = false;
                        toolStrip1.Enabled = true;
                        timer1.Enabled = true;
                        textBox1.AppendText(DateTime.Now.ToLongTimeString() + "   :   ");
                        textBox1.AppendText("收到手动读取光源数据" + e.Client.clientEndPoint.ToString() + ":");
                        textBox1.AppendText(WFNetLib.StringFunc.StringsFunction.byteToHexStr(rx.Data, " "));
                        textBox1.AppendText("\r\n");
                        if (rx.Header.Len == 0)//读取失败
                        {
                            MessageBox.Show("读取光源状态失败,请稍后重试!!");
                        }
                        else
                        {
                            //光源
                            double f;
                            f = BytesOP.MakeShort(rx.Data[2], rx.Data[3]);
                            f = f / 10;
                            rioCur = f;
                            listView1.Items[14].SubItems[1].Text = f.ToString("F1");
                            ushort rioStatus = BytesOP.MakeShort(rx.Data[0], rx.Data[1]);
                            listView1.Items[15].SubItems[1].Text = rioStatus.ToString("X04");
                            if (BytesOP.GetBit(rioStatus, 0))
                            {
                                listView1.Items[16].SubItems[1].Text = "是";
                                listView1.Items[16].BackColor = Color.Lime;
                            }
                            else
                            {
                                listView1.Items[16].SubItems[1].Text = "否";
                                listView1.Items[16].BackColor = Color.Red;
                            }
                            if (BytesOP.GetBit(rioStatus, 6))
                            {
                                listView1.Items[17].SubItems[1].Text = "是";
                                listView1.Items[17].BackColor = Color.Red;
                            }
                            else
                            {
                                listView1.Items[17].SubItems[1].Text = "否";
                                listView1.Items[17].BackColor = Color.Lime;
                            }
                            if (BytesOP.GetBit(rioStatus, 7))
                            {
                                listView1.Items[18].SubItems[1].Text = "是";
                                listView1.Items[18].BackColor = Color.Red;
                            }
                            else
                            {
                                listView1.Items[18].SubItems[1].Text = "否";
                                listView1.Items[18].BackColor = Color.Lime;
                            }
                            DateTime dt = DateTime.Now;
                            string fileLA;
                            fileLA = System.Windows.Forms.Application.StartupPath + "\\TextLog\\LA" + String.Format("{0:D4}{1:D2}{2:D2}", dt.Year, dt.Month, dt.Day) + ".txt";
                            TextLog.AddTextLog(dt.ToString() + "      " + listView1.Items[14].SubItems[1].Text
                                               + "      " + listView1.Items[15].SubItems[1].Text, fileLA, false);
                        }
                    }
                    else
                    {
                        textBox1.AppendText(DateTime.Now.ToLongTimeString() + "   :   ");
                        textBox1.AppendText("收到单片机采集板数据" + e.Client.clientEndPoint.ToString() + ":");
                        textBox1.AppendText(WFNetLib.StringFunc.StringsFunction.byteToHexStr(rx.Data, " "));
                        textBox1.AppendText("\r\n");
                    }
                }));
            }
            else
            {
                this.Invoke((EventHandler)(delegate
                {
                    textBox1.AppendText(DateTime.Now.ToLongTimeString() + "   :   ");
                    textBox1.AppendText("收到未知IP数据" + e.Client.clientEndPoint.ToString() + ":");
                    textBox1.AppendText("\r\n");
                    CP1616_NoAddr_Packet rx = (CP1616_NoAddr_Packet)e.netPacket;
                    if (rx.Header.Command == 0xf0)
                    {
                        if (rx.Data[0] == 0x01)                        //传感器采集板接入
                        {
                            toolStripButton2.Enabled = true;
                            toolStripButton3.Enabled = true;
                            mcuClientContext = e.Client;
                            //mcuSocketIP.Port = ip.Port;
                            this.Invoke((EventHandler)(delegate
                            {
                                NetLog(DateTime.Now.ToLongTimeString() + "   :   ");
                                NetLog("单片机采集板接入");
                                NetLog("\r\n");
                            }));
                        }
                    }
                }));
            }
        }
Пример #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string DeviceID, pass, sTime;
            string ret = webAPIFunc.GetRetString(ErrType.UnkownErr);

            try
            {
                DeviceID = Request.QueryString["DeviceID"];
                pass     = Request.QueryString["pass"];
                sTime    = Request.QueryString["sTime"];
                //信息|用户id|实验id,实验名,实验室;
                if (string.IsNullOrEmpty(DeviceID) || string.IsNullOrEmpty(pass))//没有这两个变量
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissParam);
                    Response.Write(ret);
                    return;
                }
                if (DeviceInfoDataDBOption.Get(DeviceID) == null)
                {
                    ret = webAPIFunc.GetRetString(ErrType.NoRegDevice);
                    Response.Write(ret);
                    return;
                }
                DataTable dt = ESLRecodeDataDBOption.DataTableSelect(pass);
                if (dt.Rows.Count == 0)
                {
                    if (sTime == "-1")//新的查询
                    {
                        int que = ESLQueueDataDBOption.GetIndex(pass);
                        if (que == -1)//新的查询
                        {
                            ESLQueueData d = new ESLQueueData();
                            d.Pass     = pass;
                            d.DeviceID = DeviceID;
                            d.IP       = WFNetLib.aspNetFunc.getIp();
                            ESLQueueDataDBOption.Insert(d);
                            que = ESLQueueDataDBOption.GetIndex(pass);
                            ret = webAPIFunc.GetRetString(2, que.ToString() + "|" + d.sTime.ToString());
//                             ret = "2," + que.ToString();
//                             ret += "," + d.sTime.ToString();
                            if (ESLWork.bCalc == false)
                            {
                                ESLWork.autoResetEvent.Set();
                            }
                        }
                        else
                        {
                            ret = "3," + que.ToString();
                        }
                    }
                    else
                    {
                        dt = ESLWorkLogDataDBOption.DataTableSelect(pass, WFNetLib.aspNetFunc.getIp(), DeviceID, sTime);
                        if (dt.Rows.Count != 0)
                        {
                            ret = "-4,";
                        }
                        else
                        {
                            int que = ESLQueueDataDBOption.GetIndex(pass);
                            if (que == -1)//新的查询
                            {
                                ESLQueueData d = new ESLQueueData();
                                d.Pass     = pass;
                                d.DeviceID = DeviceID;
                                d.IP       = WFNetLib.aspNetFunc.getIp();
                                ESLQueueDataDBOption.Insert(d);
                                que = ESLQueueDataDBOption.GetIndex(pass);
                                ret = webAPIFunc.GetRetString(2, que.ToString() + "|" + d.sTime.ToString());
//                                 ret = "2," + que.ToString();
//                                 ret += "," + d.sTime.ToString();
                                if (ESLWork.bCalc == false)
                                {
                                    ESLWork.autoResetEvent.Set();
                                }
                            }
                            else
                            {
                                ret = "3," + que.ToString();
                            }
                        }
                    }
                }
                else
                {
                    ret = "1,";
//                     for (int i = 0; i < dt.Rows.Count; i++)
//                     {
                    ret += dt.Rows[0]["Ret"];// +",";
//                     }
                }
            }
            catch (System.Exception ex)
            {
                ret = webAPIFunc.GetRetString(ErrType.UnkownErr);//"-100," + ex.Message;
                TextLog.AddTextLog("Unkown:" + ex.Message, Global.txtLogFolder + "ESLPass.txt", true);
            }
            Response.Write(ret);
        }
Пример #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string DeviceID, serverid, SSID;
            string ret = "";

            try
            {
                DeviceID = Request.QueryString["DeviceID"];
                serverid = Request.QueryString["serverid"];
                SSID     = Request.QueryString["SSID"];
                //信息|用户id|实验id,实验名,实验室;
                if (string.IsNullOrEmpty(DeviceID) || string.IsNullOrEmpty(serverid) || string.IsNullOrEmpty(SSID))//没有这两个变量
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissParam);
                    Response.Write(ret);
                    return;
                }
                string    LinuxServer = ConfigurationManager.AppSettings["LinuxServer"];
                Linux_101 WebResponse = new Linux_101();
                string    xml         = string.Format("<?xml version=\"1.0\"?><query><client>{0}</client><id>{1}</id></query>", DeviceID, serverid);
                int       retry       = 10;
                string    status;
                string    progress;
                int       x;
                while (retry != 0)
                {
                    HttpWebResponse response = WebResponse.CreatePostHttpResponse(LinuxServer + "/cgi-device/device.cgi?command=status101", xml);
                    if (response == null)
                    {
                        //textBox1.AppendText("连接服务器失败\r\n");
                        retry--;
                        continue;
                    }
                    x = WebResponse.Content.IndexOf("no such request");
                    if (x != -1)
                    {
                        ret = webAPIFunc.GetRetString(ErrType.ErrServerRet);
                        Response.Write(ret);
                        return;
                    }
                    x = WebResponse.Content.IndexOf("<status>");
                    if (x == -1)
                    {
                        //textBox1.AppendText("未查询到status数据\r\n");
                        retry--;
                        continue;
                    }
                    status = WebResponse.Content.Substring(x + "<status>".Length, WebResponse.Content.IndexOf("</status>") - x - "<status>".Length);
                    if (status == "finished")
                    {
                        x = WebResponse.Content.IndexOf("<result>");
                        if (x == -1)
                        {
                            ret = webAPIFunc.GetRetString(ErrType.retOK);
                            Response.Write(ret);
                            return;
                        }
                        else
                        {
                            x = WebResponse.Content.IndexOf("<query>");
                            string query, answer;
                            if (x == -1)
                            {
                                ret = webAPIFunc.GetRetString(ErrType.retOK);
                                Response.Write(ret);
                                return;
                            }
                            else
                            {
                                query = WebResponse.Content.Substring(x + "<query>".Length, WebResponse.Content.IndexOf("</query>") - x - "<query>".Length);
                            }
                            x = WebResponse.Content.IndexOf("<answer>");
                            if (x == -1)
                            {
                                ret = webAPIFunc.GetRetString(ErrType.retOK);
                                Response.Write(ret);
                                return;
                            }
                            else
                            {
                                answer = WebResponse.Content.Substring(x + "<answer>".Length, WebResponse.Content.IndexOf("</answer>") - x - "<answer>".Length);
                            }
                            byte[]          ss1 = WFNetLib.StringFunc.StringsFunction.strToHexByte(query, " ");
                            byte[]          ss2 = WFNetLib.StringFunc.StringsFunction.strToHexByte(answer, " ");
                            DPassRecodeData dr  = new DPassRecodeData();
                            dr.Dealer = WFNetLib.StringFunc.StringsFunction.byteToHexStr(ss1, "");
                            dr.DPass  = WFNetLib.StringFunc.StringsFunction.byteToHexStr(ss2, "");
                            DPassRecodeDataDBOption.Insert(dr);
                            DPassWorkLogData dl = new DPassWorkLogData();
                            dl.DeviceID = DeviceID;
                            dl.IP       = WFNetLib.aspNetFunc.getIp();
                            dl.Pass     = dr.Dealer;
                            dl.Ret      = dr.DPass;
                            dl.SSID     = SSID;
                            DPassWorkLogDataDBOption.Insert(dl);
                            byte[] dID    = WFNetLib.StringFunc.StringsFunction.strToHexByte(DeviceID, "");
                            byte[] sID    = WFNetLib.StringFunc.StringsFunction.strToHexByte(SSID, "");
                            byte[] DPass  = WFNetLib.StringFunc.StringsFunction.strToHexByte(dr.DPass, "");
                            byte[] DDPass = GlobalFunc.Encrypt(DPass, dID, sID);
                            ret = "1," + dr.Dealer + "-" + WFNetLib.StringFunc.StringsFunction.byteToHexStr(DDPass, "");
                            Response.Write(ret);
                            return;
                        }
                    }
                    else if (status == "rejected")
                    {
                        ret = "4,";
                        Response.Write(ret);
                        return;
                    }
                    else if (status == "queued")
                    {
                        x = WebResponse.Content.IndexOf("<queue>");
                        if (x != -1)
                        {
                            progress = WebResponse.Content.Substring(x + "<queue>".Length, WebResponse.Content.IndexOf("</queue>") - x - "<queue>".Length);
                            ret      = "3," + progress;
                            Response.Write(ret);
                            return;
                        }
                        else
                        {
                            ret = "3,-1";
                            Response.Write(ret);
                            return;
                        }
                    }
                    else if (status == "inprogress")
                    {
                        x = WebResponse.Content.IndexOf("<progress>");
                        if (x != -1)
                        {
                            progress = WebResponse.Content.Substring(x + "<progress>".Length, WebResponse.Content.IndexOf("</progress>") - x - "<progress>".Length);
                            ret      = "2," + progress;
                            Response.Write(ret);
                            return;
                        }
                        else
                        {
                            ret = "2,-1";
                            Response.Write(ret);
                            return;
                        }
                    }
                }
                if (retry == 0)
                {
                    ret = "-99,";
                    Response.Write(ret);
                    return;
                }
            }
            catch (System.Exception ex)
            {
                ret = webAPIFunc.GetRetString(ErrType.UnkownErr);
                TextLog.AddTextLog("Status_Unkown:" + ex.Message, Global.txtLogFolder + "DPass.txt", true);
            }
            Response.Write(ret);
        }
        void FPNTest_ProcData(object LockWatingThread)
        {
            string strName = FPNFile_Path + "FPN_L" + FPN_L.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bin";

            /************************************************************************/
            /* FPN_y                                                                */
            /************************************************************************/
            miu_y = new List <double>();
            for (int i = 0; i < FPN_L; i++)
            {
                FPN_y = new ushort[m_Buffers.Height, m_Buffers.Width];
                ysave = new byte[SystemParam.ByteLen4Pic];
                for (int j = 0; j < FPN_Ns; j++)
                {
                    byte[] p = SystemParam.ReadTempFile(SystemParam.ByteLen4Pic, j, FPNFile_Path + "TempData\\Light\\" + (i + 1).ToString() + "bin");
                    ushort[,] pic = wfSapGUI.TransPicDatas(p, m_Buffers.Height, m_Buffers.Width, m_Buffers.PixelDepth);
                    for (int m = 0; m < m_Buffers.Height; m++)
                    {
                        for (int n = 0; n < m_Buffers.Width; n++)
                        {
                            FPN_y[m, n] += pic[m, n];
                        }
                    }
                    if (waitProc.HasBeenCancelled())
                    {
                        return;
                    }
                    waitProc.SetProcessBarPerformStep();
                }
                double miu = 0;
                for (int m = 0; m < m_Buffers.Height; m++)
                {
                    for (int n = 0; n < m_Buffers.Width; n++)
                    {
                        FPN_y[m, n] = (ushort)(FPN_y[m, n] / FPN_Ns);
                        miu        += FPN_y[m, n];
                    }
                }
                ysave = wfSapGUI.ReTransPicDatas(FPN_y, m_Buffers.Height, m_Buffers.Width);
                SystemParam.WriteTempFile(ysave, i, strName);
                miu = miu / m_Buffers.Height / m_Buffers.Width;
                miu_y.Add(miu);
            }

            this.Invoke((EventHandler)(delegate
            {
                textBox1.AppendText("FPN明场数据处理完成\r\n");
            }));

            strName = FPNFile_Path + "FPN_D" + FPN_L.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bin";
            /************************************************************************/
            /* FPN_y                                                                */
            /************************************************************************/
            miu_ydark = new List <double>();
            for (int i = 0; i < FPN_L; i++)
            {
                FPN_y = new ushort[m_Buffers.Height, m_Buffers.Width];
                ysave = new byte[SystemParam.ByteLen4Pic];
                for (int j = 0; j < FPN_Ns; j++)
                {
                    byte[] p = SystemParam.ReadTempFile(SystemParam.ByteLen4Pic, j, FPNFile_Path + "TempData\\Dark\\" + (i + 1).ToString() + "bin");
                    ushort[,] pic = wfSapGUI.TransPicDatas(p, m_Buffers.Height, m_Buffers.Width, m_Buffers.PixelDepth);
                    for (int m = 0; m < m_Buffers.Height; m++)
                    {
                        for (int n = 0; n < m_Buffers.Width; n++)
                        {
                            FPN_y[m, n] += pic[m, n];
                        }
                    }
                    if (waitProc.HasBeenCancelled())
                    {
                        return;
                    }
                    waitProc.SetProcessBarPerformStep();
                }
                double miu = 0;
                for (int m = 0; m < m_Buffers.Height; m++)
                {
                    for (int n = 0; n < m_Buffers.Width; n++)
                    {
                        FPN_y[m, n] = (ushort)(FPN_y[m, n] / FPN_Ns);
                        miu        += FPN_y[m, n];
                    }
                }
                ysave = wfSapGUI.ReTransPicDatas(FPN_y, m_Buffers.Height, m_Buffers.Width);
                SystemParam.WriteTempFile(ysave, i, strName);
                miu = miu / m_Buffers.Height / m_Buffers.Width;
                miu_ydark.Add(miu);
            }

            this.Invoke((EventHandler)(delegate
            {
                textBox1.AppendText("FPN暗场数据处理完成\r\n");
            }));

            TextLog.AddTextLog("--------------" + DateTime.Now.ToString() + "----------------", FPNFile_Path + "FPN" + FPN_L.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt", false);
            TextLog.AddTextLog(String.Format("{0,-11}{1,-11}{2,-11}", "曝光时间", "明场均值", "暗场均值"), FPNFile_Path + "FPN" + FPN_L.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt", false);
            uint lsup = SystemParam.eStart + (uint)(Calc1.saturation * FPN_Per / 100) * SystemParam.eStep;

            for (int i = 0; i < FPN_L; i++)
            {
                uint   ls = (uint)(lsup / FPN_L * (i + 1));
                double t  = ((double)(ls)) * SystemParam.Ts;
                TextLog.AddTextLog(String.Format("{0,-15}{1,-15}{2,-15}", t.ToString("F3"), miu_y[i].ToString("F6"), miu_ydark[i].ToString("F6")), FPNFile_Path + "FPN" + FPN_L.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt", false);
            }
        }
Пример #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string DeviceID, Dealer, SSID;
            string ret = "";

            try
            {
                DeviceID = Request.QueryString["DeviceID"];
                Dealer   = Request.QueryString["pass"];
                SSID     = Request.QueryString["SSID"];
                //信息|用户id|实验id,实验名,实验室;
                if (string.IsNullOrEmpty(DeviceID) || string.IsNullOrEmpty(Dealer) || string.IsNullOrEmpty(SSID))//没有这两个变量
                {
                    ret = webAPIFunc.GetRetString(ErrType.MissParam);
                    Response.Write(ret);
                    return;
                }
                DeviceInfoData did = DeviceInfoDataDBOption.Get(DeviceID);
                if (did == null)
                {
                    ret = webAPIFunc.GetRetString(ErrType.NoRegDevice);
                    Response.Write(ret);
                    return;
                }
                else
                {
                    int ut = DPassWorkLogDataDBOption.GetUseTimes(DeviceID);
                    if (ut > did.DPassTimes)
                    {
                        ret = webAPIFunc.GetRetString(ErrType.MaxUseTimes);
                        Response.Write(ret);
                        return;
                    }
                }
                DataTable dt = DPassRecodeDataDBOption.DataTableSelect(Dealer);
                if (dt.Rows.Count != 0)
                {
                    byte[]           dID    = WFNetLib.StringFunc.StringsFunction.strToHexByte(DeviceID, "");
                    byte[]           sID    = WFNetLib.StringFunc.StringsFunction.strToHexByte(SSID, "");
                    byte[]           DPass  = WFNetLib.StringFunc.StringsFunction.strToHexByte(dt.Rows[0]["DPass"].ToString(), "");
                    byte[]           DDPass = GlobalFunc.Encrypt(DPass, dID, sID);
                    DPassWorkLogData dl     = new DPassWorkLogData();
                    dl.DeviceID = DeviceID;
                    dl.IP       = WFNetLib.aspNetFunc.getIp();
                    dl.Pass     = dt.Rows[0]["Dealer"].ToString();
                    dl.Ret      = dt.Rows[0]["DPass"].ToString();
                    dl.SSID     = SSID;
                    DPassWorkLogDataDBOption.Insert(dl);
                    ret = "2," + dt.Rows[0]["Dealer"] + "-" + WFNetLib.StringFunc.StringsFunction.byteToHexStr(DDPass, "");
                    Response.Write(ret);
                    return;
                }
                else
                {
                    string          LinuxServer = ConfigurationManager.AppSettings["LinuxServer"];
                    Linux_101       WebResponse = new Linux_101();
                    byte[]          bD          = WFNetLib.StringFunc.StringsFunction.strToHexByte(Dealer, "");
                    string          Dealer1     = WFNetLib.StringFunc.StringsFunction.byteToHexStr(bD, " ");
                    string          xml         = string.Format("<?xml version=\"1.0\"?><query><client>{0}</client><data>{1}</data></query>", DeviceID, Dealer1);
                    HttpWebResponse response    = WebResponse.CreatePostHttpResponse(LinuxServer + "/cgi-device/device.cgi?command=search101", xml);
                    if (response == null)
                    {
                        ret = webAPIFunc.GetRetString(ErrType.MissServer);
                        Response.Write(ret);
                        return;
                    }
                    string id = "";
                    int    x;
                    x = WebResponse.Content.IndexOf("<id>");
                    if (x == -1)
                    {
                        ret = webAPIFunc.GetRetString(ErrType.ErrServerRet);
                        Response.Write(ret);
                        return;
                    }
                    id  = WebResponse.Content.Substring(x + "<id>".Length, WebResponse.Content.IndexOf("</id>") - x - "<id>".Length);
                    ret = webAPIFunc.GetRetString(ErrType.retOK, id);
                }
            }
            catch (System.Exception ex)
            {
                ret = webAPIFunc.GetRetString(ErrType.UnkownErr);
                TextLog.AddTextLog("Add_Unkown:" + ex.Message, Global.txtLogFolder + "DPass.txt", true);
            }
            Response.Write(ret);
        }
Пример #25
0
        void 暗场采集(object LockWatingThread)
        {
            double y, d;
            double t;

            Calc1.miu_y_dark   = new List <double>();
            Calc1.delta_y_dark = new List <double>();
            this.Invoke((EventHandler)(delegate
            {
                chart1.Series[0].Points.Clear();
                chart1.Series[1].Points.Clear();
                chart1.ChartAreas[0].AxisY.Title = "暗场均值";
                chart1.ChartAreas[1].AxisY.Title = "暗场方差";
            }));
            NopCam((ushort)(PicN + 1), SystemParam.eStart);
            int saveindex = 0;
            int step      = (int)(MaxTime / SystemParam.Ts / PhotoNs);

            for (uint i = 0; i < PhotoNs; i++)
            {
                uint ls = SystemParam.eStart + (uint)(i * step);
                this.Invoke((EventHandler)(delegate
                {
                    toolStripLabel3.Text = SystemParam.GetTime((int)i).ToString("F2") + " ms";
                }));
                if (waitProc.HasBeenCancelled())
                {
                    return;
                }
                SerialFunc.SerialCommand3((ushort)(PicN + 1), ls);
                if (!WaitCam((ushort)(PicN + 1)))
                {
                    i--;
                    continue;
                }
                for (int j = 1; j < PicN + 1; j++)
                {
                    saveindex++;
                    m_Buffers.Save(Calc1.TempPicPath_Dark + saveindex.ToString() + ".bmp", "-format bmp", j, 0);
                    Thread.Sleep(SystemParam.PicDelay);
                }
                byte[] yByteArray;
                t = ls * SystemParam.Ts;
                for (int j = 1; j < PicN + 1; j++)
                {
                    yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j);
                    SystemParam.CreateBINFile(yByteArray, SystemParam.TxtCustomDarkDataPath + dtStart.ToString("yyyyMMdd_HHmmss") + "\\" + t.ToString("F3") + "_" + j.ToString() + ".bin");
                }
//                 yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, 1);
//                 SystemParam.CreateBINFile(yByteArray, SystemParam.TxtCustomDarkDataPath + dtStart.ToString("yyyyMMdd_HHmmss") + "\\" + t.ToString("F3") + "_1.bin");
//                 yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, 2);
//                 SystemParam.CreateBINFile(yByteArray, SystemParam.TxtCustomDarkDataPath + dtStart.ToString("yyyyMMdd_HHmmss") + "\\" + t.ToString("F3") + "_2.bin");
                ya = wfSapGUI.ReadPicDatas(m_Buffers, PicN);
                //yb = wfSapGUI.ReadPicDatas(m_Buffers, 2);
                Calc1.TestExposureTime1(ya, m_Buffers.Height, m_Buffers.Width, SystemParam.cmosInfo.PixelDepth, out y, out d);
                this.Invoke((EventHandler)(delegate
                {
                    chart1.Series[0].Points.AddXY(t, y);
                    chart1.Series[1].Points.AddXY(t, d);
                    waitProc.SetProcessBar((int)(i + 1));
                }));
                TextLog.AddTextLog(String.Format(SystemParam.TxtCustomDarkDataFormat, t.ToString("F3"), y.ToString("F6"), d.ToString("F6")), fileName, false);
            }
        }
Пример #26
0
        public static void KeyDataWorkThread()
        {
            int retryMax = 10;
            int retry    = retryMax;

            iniFileOP.iniFilePath = "c:\\LCY.ini";
            while (Global.bRun)
            {
                bCalc = false;
                autoResetEvent.WaitOne();
                bCalc = true;
                while (true)
                {
                    bool             bOK = false;
                    KeyDataQueueData eq  = KeyDataQueueDataDBOption.GetFirst();
                    if (eq == null)
                    {
                        break;
                    }
                    KeyDataWorkLogData kl = new KeyDataWorkLogData();
                    kl.IP       = eq.IP;
                    kl.DeviceID = eq.DeviceID;
                    kl.sTime    = eq.sTime;
                    kl.SSID     = eq.SSID;
                    kl.QueueID  = eq.ID;
                    try
                    {
                        byte[] data   = WFNetLib.StringFunc.StringsFunction.strToHexByte(eq.BIN, "");
                        string folder = workPath + eq.SSID;
                        if (WFNetLib.FileOP.IsExist(folder, FileOPMethod.Folder))
                        {
                            WFNetLib.FileOP.Delete(folder, FileOPMethod.Folder);
                        }
                        GetST12(data);
                        uint keyoption = (uint)eq.KeyOption;
                        for (int i = 0; i < 8; i++)
                        {
                            if (BytesOP.GetBit(keyoption, i))
                            {
                                iniFileOP.Write("DuoXuan", i.ToString(), "1");
                            }
                            else
                            {
                                iniFileOP.Write("DuoXuan", i.ToString(), "0");
                            }
                        }
                        if (BytesOP.GetBit(keyoption, 8))
                        {
                            iniFileOP.Write("DuoXuan", "all", "1");
                        }
                        else
                        {
                            iniFileOP.Write("DuoXuan", "all".ToString(), "0");
                        }
                        iniFileOP.Write("KaiGuan", "KG", "1");
                        retry = 60;
                        bool bStart = false;
                        while (retry != 0)
                        {
                            Thread.Sleep(1000);
                            retry--;
                            try
                            {
                                int kg = int.Parse(iniFileOP.Read("KaiGuan", "KG"));
                                if (kg == 2)
                                {
                                    bStart = true;
                                    break;
                                }
                            }
                            catch
                            {
                            }
                        }
                        if (bStart)
                        {
                            retry = 10 * 60;
                            bool bFinish = false;
                            while (retry != 0)
                            {
                                Thread.Sleep(1000);
                                retry--;
                                try
                                {
                                    int kg = int.Parse(iniFileOP.Read("KaiGuan", "KG"));
                                    if (kg == 3)
                                    {
                                        bFinish = true;
                                        break;
                                    }
                                }
                                catch
                                {
                                }
                            }
                            if (bFinish)
                            {
                                if (WFNetLib.FileOP.IsExist(folder, FileOPMethod.Folder))
                                {
                                    byte   format = (byte)eq.format;
                                    string filename;
                                    if (BytesOP.GetBit(format, 0))//11格式
                                    {
                                        if (BytesOP.GetBit(keyoption, 0))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_0_" + eq.SSID + "_11.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key0_11 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 1))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_1_" + eq.SSID + "_11.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key1_11 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 2))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_2_" + eq.SSID + "_11.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key2_11 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 3))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_3_" + eq.SSID + "_11.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key3_11 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 4))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_4_" + eq.SSID + "_11.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key4_11 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 5))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_5_" + eq.SSID + "_11.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key5_11 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 6))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_6_" + eq.SSID + "_11.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key6_11 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 7))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_7_" + eq.SSID + "_11.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key7_11 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                    }
                                    if (BytesOP.GetBit(format, 1))//41格式
                                    {
                                        if (BytesOP.GetBit(keyoption, 0))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_0_" + eq.SSID + "_41.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key0_41 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 1))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_1_" + eq.SSID + "_41.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key1_41 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 2))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_2_" + eq.SSID + "_41.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key2_41 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 3))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_3_" + eq.SSID + "_41.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key3_41 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 4))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_4_" + eq.SSID + "_41.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key4_41 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 5))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_5_" + eq.SSID + "_41.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key5_41 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 6))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_6_" + eq.SSID + "_41.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key6_41 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 7))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_7_" + eq.SSID + "_41.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key7_41 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                    }
                                    if (BytesOP.GetBit(format, 2))//51格式
                                    {
                                        if (BytesOP.GetBit(keyoption, 0))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_0_" + eq.SSID + "_51.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key0_51 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 1))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_1_" + eq.SSID + "_51.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key1_51 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 2))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_2_" + eq.SSID + "_51.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key2_51 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 3))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_3_" + eq.SSID + "_51.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key3_51 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 4))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_4_" + eq.SSID + "_51.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key4_51 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 5))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_5_" + eq.SSID + "_51.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key5_51 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 6))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_6_" + eq.SSID + "_51.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key6_51 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                        if (BytesOP.GetBit(keyoption, 7))
                                        {
                                            FileInfo f;
                                            filename = folder + "\\key_7_" + eq.SSID + "_51.bin";
                                            if (WFNetLib.FileOP.IsExist(filename, FileOPMethod.File))
                                            {
                                                f = new FileInfo(filename);
                                                Stream stream = File.OpenRead(f.FullName);
                                                byte[] bin    = new byte[stream.Length];
                                                stream.Read(bin, 0, (int)stream.Length);
                                                stream.Close();
                                                kl.Key7_51 = StringsFunction.byteToHexStr(bin, "");
                                            }
                                        }
                                    }
                                    kl.bOK = true;
                                    KeyDataWorkLogDataDBOption.Insert(kl);
                                    //WFNetLib.FileOP.Delete(folder, FileOPMethod.Folder);
                                }
                                else
                                {
                                    kl.bOK = false;
                                    KeyDataWorkLogDataDBOption.Insert(kl);
                                }
                            }
                            else
                            {
                                kl.bOK = false;
                                KeyDataWorkLogDataDBOption.Insert(kl);
                            }
                        }
                        else
                        {
                            kl.bOK = false;
                            KeyDataWorkLogDataDBOption.Insert(kl);
                        }
                        KeyDataQueueDataDBOption.delete(eq);
                    }
                    catch (System.Exception ex)
                    {
                        TextLog.AddTextLog("Thread_Unkown:" + ex.Message, Global.txtLogFolder + "KeyData.txt", true);
                        kl.bOK = false;
                        KeyDataWorkLogDataDBOption.Insert(kl);
                        KeyDataQueueDataDBOption.delete(eq);
                    }
                }
            }
        }