示例#1
0
        private bool DataFrmToCls(out cBarSet barSet)
        {
            bool    returnValue = false;
            cBarSet mBarSet     = new cBarSet();

            try
            {
                mBarSet.mIsWinCeBar  = rbtWince.Checked ? true : false;
                mBarSet.mIsAutoStart = chkAutoStart.Checked ? true : false;

                for (int i = 0; i < 10; i++)
                {
                    mBarSet.mIsUse[i]        = Num.BoolParse(BarCodeSet.Rows[i].Cells[0].Value);
                    mBarSet.mIntBarLength[i] = Num.IntParse(BarCodeSet.Rows[i].Cells[1].Value);
                    mBarSet.mIntBarStart[i]  = Num.IntParse(BarCodeSet.Rows[i].Cells[2].Value);
                    mBarSet.mIntBarCount[i]  = Num.IntParse(BarCodeSet.Rows[i].Cells[3].Value);
                }
                returnValue = true;
            }
            catch (Exception exc)
            {
                cMain.WriteErrorToLog("frmBarSet DataFrmToCls is Error " + exc.Message);
            }
            barSet = mBarSet;
            return(returnValue);
        }
        public static cSnSet DataStrToClass(string data)
        {
            if (data.IndexOf("C~") == 0)
            {
                data = data.Substring(2);
            }
            cSnSet mSnSet = new cSnSet();

            try
            {
                string[] tempStr = data.Split('~');
                int      index   = 0;
                mSnSet.id           = tempStr[index++];
                mSnSet.MachineIndex = Num.IntParse(tempStr[index++]);
                for (int i = 0; i < mSnSet.SnCodeSet.Length; i++)
                {
                    mSnSet.SnCodeSet[i].FengSu     = Num.IntParse(tempStr[index++]);
                    mSnSet.SnCodeSet[i].IsDanLen   = Num.BoolParse(tempStr[index++]);
                    mSnSet.SnCodeSet[i].IsKuaiJian = Num.BoolParse(tempStr[index++]);
                    mSnSet.SnCodeSet[i].MoShi      = Num.IntParse(tempStr[index++]);
                    mSnSet.SnCodeSet[i].NeiJiNeng  = Num.IntParse(tempStr[index++]);
                    mSnSet.SnCodeSet[i].NengLi     = Num.IntParse(tempStr[index++]);
                    mSnSet.SnCodeSet[i].PinLv      = Num.IntParse(tempStr[index++]);
                }
            }
            catch
            { }
            return(mSnSet);
        }
示例#3
0
 void setShowColumns()
 {
     for (int i = 0; i < dataGridShow.ColumnCount; i++)
     {
         if (dataGridShow.Rows[0].Cells[i].Value != null)
         {
             dataGridSet.Columns[13 + i * 2].Visible = Num.BoolParse(dataGridShow.Rows[0].Cells[i].Value);
             dataGridSet.Columns[14 + i * 2].Visible = Num.BoolParse(dataGridShow.Rows[0].Cells[i].Value);
         }
     }
 }
        private void timer1_Tick(object sender, EventArgs e)
        {
            int SumRows = 0;

            for (int i = 0; i < cMain.DataShow; i++)
            {
                MaxValue[i] = -65535;//初始化一个默认值
                MinValue[i] = 65535;
                SumValue[i] = 0;
            }
            for (int i = 2; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Cells[0].Value != null && Num.BoolParse(dataGridView1.Rows[i].Cells[0].Value))
                {
                    for (int j = 0; j < cMain.DataShow; j++)
                    {
                        double tmpValue = Num.DoubleParse(dataGridView1.Rows[i].Cells[1 + j].Value);
                        SumValue[j] = SumValue[j] + tmpValue;
                        MaxValue[j] = Num.DoubleMax(MaxValue[j], tmpValue);
                        MinValue[j] = Num.DoubleMin(MinValue[j], tmpValue);
                    }
                    SumRows++;
                }
            }
            if (SumRows >= 3)//最少要3行,(最高值,最低值,中间值)最少3行
            {
                for (int i = 0; i < cMain.DataShow; i++)
                {
                    double tmpValue = Num.DoubleParse(txtData.Text);
                    SumValue[i] = SumValue[i] - MaxValue[i] - MinValue[i];
                    if (chkData[i].Checked)
                    {
                        dataGridView1.Rows[0].Cells[i + 1].Value = (1 - tmpValue * 0.010) * SumValue[i] / (SumRows - 2.000);
                        dataGridView1.Rows[1].Cells[i + 1].Value = (1 + tmpValue * 0.010) * SumValue[i] / (SumRows - 2.000);
                    }
                    else
                    {
                        dataGridView1.Rows[0].Cells[i + 1].Value = 0;
                        dataGridView1.Rows[1].Cells[i + 1].Value = 0;
                    }
                }
            }
            else
            {
                if (dataGridView1.Rows.Count >= 2)
                {
                    for (int i = 0; i < cMain.DataShow; i++)
                    {
                        dataGridView1.Rows[0].Cells[i + 1].Value = 0;
                        dataGridView1.Rows[1].Cells[i + 1].Value = 0;
                    }
                }
            }
        }
示例#5
0
        private cModeSet FrmToClass()
        {
            cModeSet result = new cModeSet();

            result.mId         = txtID.Text;
            result.mMode       = txtMode.Text;
            result.mDescript   = txtDescribe.Text;
            result.mElect      = cbbVol.SelectedIndex;
            result.mBiaoZhunJi = cbbBzz.SelectedIndex;
            result.m24V        = cbb24V.SelectedIndex;
            result.mJiQi       = cbbJiQi.SelectedIndex;

            for (int i = 0; i < cMain.DataProtect / 2; i++)
            {
                result.mProtect[i] = Num.SingleParse(Grid1.Rows[i].Cells[1].Value);
                result.mProtect[cMain.DataProtect / 2 + i] = Num.SingleParse(Grid1.Rows[i].Cells[3].Value);
            }

            for (int i = 0; i < result.mStepId.Length && i < Grid2.Rows.Count; i++)
            {
                result.mStepId[i]  = Grid2.Rows[i].Cells["RunMode"].Value.ToString();
                result.mSetTime[i] = Num.IntParse(Grid2.Rows[i].Cells["Times"].Value);
                result.mSendStr[i] = Grid2.Rows[i].Cells["Code"].Value.ToString();
                for (int j = 0; j < cMain.DataKaiGuang; j++)
                {
                    result.mKaiGuan[i, j] = Num.BoolParse(Grid2.Rows[i].Cells[string.Format("KaiGuan{0}", j + 1)].Value);
                }
                for (int j = 0; j < cMain.DataShow; j++)
                {
                    result.mLowData[i, j]  = Num.SingleParse(Grid2.Rows[i].Cells[string.Format("Data{0}", j * 2 + 1)].Value);
                    result.mHighData[i, j] = Num.SingleParse(Grid2.Rows[i].Cells[string.Format("Data{0}", j * 2 + 2)].Value);
                }
            }
            for (int i = 0; i < cMain.DataShow; i++)
            {
                result.mShow[i] = Num.BoolParse(Grid3.Rows[0].Cells[i].Value);
            }

            return(result);
        }
示例#6
0
        public static bool DataFileToClass(string FileStr, out cModeSet ModeSet, bool isPath)
        {
            cModeSet mModeset = new cModeSet();
            string   readStr;

            if (isPath)
            {
                readStr = cMain.ReadFile(FileStr);
            }
            else
            {
                readStr = FileStr;
            }
            try
            {
                string[] tempStr;
                tempStr = readStr.Split('~');
                int i, j, index = 0;
                mModeset.mId          = tempStr[index++];
                mModeset.mMode        = tempStr[index++];
                mModeset.mElect       = Num.IntParse(tempStr[index++]);
                mModeset.mBiaoZhunJi  = Num.IntParse(tempStr[index++]);
                mModeset.mBiaoZhunJi1 = Num.BoolParse(tempStr[index++]);
                mModeset.mBiaoZhunJi2 = Num.BoolParse(tempStr[index++]);
                mModeset.mBiaoZhunJi3 = Num.BoolParse(tempStr[index++]);
                mModeset.mBiaoZhunJi4 = Num.BoolParse(tempStr[index++]);
                mModeset.mBiaoZhunJi5 = Num.BoolParse(tempStr[index++]);
                mModeset.mBiaoZhunJi6 = Num.BoolParse(tempStr[index++]);
                mModeset.m24V         = Num.IntParse(tempStr[index++]);
                mModeset.mJiQi        = Num.IntParse(tempStr[index++]);
                for (i = 0; i < cMain.DataProtect; i++)
                {
                    mModeset.mProtect[i] = Num.SingleParse(tempStr[index++]);
                }

                for (i = 0; i < cModeSet.StepCount; i++)
                {
                    mModeset.mStepId[i] = tempStr[index++];
                }
                for (i = 0; i < cModeSet.StepCount; i++)
                {
                    mModeset.mSetTime[i] = Num.IntParse(tempStr[index++]);
                }
                for (i = 0; i < cModeSet.StepCount; i++)
                {
                    mModeset.mSendStr[i] = tempStr[index++];
                }
                for (i = 0; i < cMain.DataKaiGuang; i++)
                {
                    for (j = 0; j < cModeSet.StepCount; j++)
                    {
                        if (tempStr[index++] == "√")
                        {
                            mModeset.mKaiGuan[j, i] = true;
                        }
                        else
                        {
                            mModeset.mKaiGuan[j, i] = false;
                        }
                    }
                }
                for (i = 0; i < cMain.DataShow * 2; i++)
                {
                    for (j = 0; j < cModeSet.StepCount; j++)
                    {
                        if (i % 2 == 0)
                        {
                            mModeset.mLowData[j, i / 2] = Num.SingleParse(tempStr[index++]);
                        }
                        else
                        {
                            mModeset.mHighData[j, i / 2] = Num.SingleParse(tempStr[index++]);
                        }
                    }
                }
                for (i = 0; i < cMain.DataShow; i++)
                {
                    mModeset.mShow[i] = Num.BoolParse(tempStr[index++]);
                }
            }
            catch
            {
            }
            ModeSet = mModeset;
            return(true);
        }
示例#7
0
        private void FrmAutoTest_mDataReciveString(object o, RecieveStringArgs e)
        {
            string[] tempStr   = e.RemostHost.Split('.');
            int      RemoteNum = Num.IntParse(tempStr[3]) - 101;

            cMain.isUdpInitError[RemoteNum] = true;
            string readStr = e.ReadStr;

            if (readStr.IndexOf("A~OK") >= 0)
            {
                string[] tempstr   = readStr.Split('~');
                int      remoteNum = Num.IntParse(tempstr[3]);
                switch (tempstr[2])
                {
                case "OVER":
                    McgsUdp[remoteNum - 1].fUdpSend("A~OK~OVER");
                    cMain.isAccessDiQi = cMain.isAccessDiQi.Replace("," + string.Format("{0:D2},", remoteNum), ",");
                    break;

                case "HOLD":
                    //McgsUdp[remoteNum - 1].fUdpSend("A~OK~HOLD");
                    if (cMain.isAccessDiQi.IndexOf(string.Format(",{0:D2},", remoteNum)) < 0)
                    {
                        cMain.isAccessDiQi = cMain.isAccessDiQi + string.Format("{0:D2},", remoteNum);
                    }
                    break;

                case "ACCESS":
                    return;
                }
                tempstr = null;
                tempstr = cMain.isAccessDiQi.Split(',');
                if (tempstr.Length >= 3)
                {
                    McgsUdp[Num.IntParse(tempstr[1]) - 1].fUdpSend("A~OK~ACCESS");
                }
            }
            if (readStr.IndexOf("E~OK") >= 0)//关机返回
            {
                is_E_Ok = true;
            }
            if (readStr.IndexOf("B~OK") >= 0)//条码
            {
                is_B_OK[RemoteNum] = true;
            }
            if (readStr.IndexOf("S~OK") >= 0)//系统设置
            {
                is_S_OK = true;
            }
            if (readStr.IndexOf("T~OK") >= 0)//停机
            {
                is_T_OK = true;
            }
            if (readStr.IndexOf("N~OK") >= 0)//下一步
            {
                is_N_OK = true;
            }
            if (readStr.IndexOf("K~OK") >= 0)//开始
            {
                is_K_OK = true;
            }
            if (readStr.IndexOf("U~OK") >= 0)//更新
            {
                is_U_OK = true;
            }
            if (readStr.IndexOf("D~OK") >= 0)//当前实时数据
            {
                is_D_OK    = true;
                mNetResult = GetNetResult(readStr);
                cMain.mCurrentData[mNetResult.RunResult.mTestNo - 1] = mNetResult;
                lastGetDataTime[mNetResult.RunResult.mTestNo - 1]    = Environment.TickCount;
            }
            if (readStr.IndexOf("J~OK") >= 0)
            {
                is_J_OK          = true;
                cMain.mNetResult = GetNetResult(readStr);
                cData.SaveJianCeData(cMain.mNetResult);
                cMain.mTempNetResult[cMain.mNetResult.RunResult.mTestNo - 1].RunResult[cMain.mNetResult.RunResult.mStepId]  = cMain.mNetResult.RunResult;
                cMain.mTempNetResult[cMain.mNetResult.RunResult.mTestNo - 1].StepResult[cMain.mNetResult.RunResult.mStepId] = cMain.mNetResult.StepResult;
                McgsUdp[cMain.mNetResult.RunResult.mTestNo - 1].fUdpSend("J~OK");
                //if ((cMain.isPrint) && (cMain.mNetResult.RunResult.mId != "") && (cMain.mNetResult.StepResult.mIsStepPass == 0))
                //{
                //    DataTable tmpDt = cData.GetErrorReport(cMain.mNetResult);
                //    frmPrint fp = new frmPrint(tmpDt);
                //    fp.Show();
                //    if (!fp.IsDisposed)
                //    {
                //        fp.Close();
                //        fp.Dispose();
                //    }
                //}
            }
            if (readStr.IndexOf("R~OK") >= 0)//此处已实现条码读取上来,并发送成功标志,但上位机这头暂时未处理.(防止和232串口读条码不兼容)
            {
                is_R_OK = true;
                string[] tempstr = readStr.Split('~');
                indexAtBar = Num.IntParse(tempstr[2]) - 1;
                McgsUdp[indexAtBar].fUdpSend("R~OK");
                if (isSetSendBarFrm)
                {
                    sendBarFrm.SendBarMethod(tempstr[3]);
                }
            }
            if (readStr.IndexOf("X~OK") >= 0)
            {
                string[] tempstr = readStr.Split('~');
                indexAtBar = Num.IntParse(tempstr[2]) - 1;
            }
            if (readStr.IndexOf("O~OK") >= 0)
            {
                string[] tempstr = readStr.Split('~');
                cMain.mTodayData.TestCount[0]++;
                if (Num.BoolParse(tempstr[3]))
                {
                    cMain.mTodayData.TestCount[1]++;
                }
                else
                {
                    cMain.mTodayData.TestCount[2]++;
                }
                for (int i = 0; i < cMain.mTodayData.TestCount.Length; i++)
                {
                    cTodayData.WriteToday("TestCount" + i.ToString(), cMain.mTodayData.TestCount[i].ToString());
                }
            }
        }
示例#8
0
        private void initSystem()
        {
            if (!cTodayData.ReadToday(ref cMain.mTodayData.TodayTime, ref cMain.mTodayData.TestCount))
            {
                cMain.WriteErrorToLog("读取当日测量数据失败");
            }
            else
            {
                DateTime todayStart = new DateTime(cMain.mTodayData.TodayTime.Year, cMain.mTodayData.TodayTime.Month, cMain.mTodayData.TodayTime.Day);
                cTodayData.WriteToday("TodayTime", todayStart.ToString());
                TimeSpan ts = DateTime.Now - todayStart;
                if (ts.Days >= 1)
                {
                    cTodayData.WriteToday("TodayTime", DateTime.Now.ToString());
                    for (int i = 0; i < cMain.mTodayData.TestCount.Length; i++)
                    {
                        cMain.mTodayData.TestCount[i] = 0;
                        cTodayData.WriteToday("TestCount" + i.ToString(), "0");
                    }
                }
            }
            cMain.isDebug        = bool.Parse(cMain.ReadIni("System", "IsDebug", "false"));
            cMain.comICCard      = cMain.ReadIni("System", "ComICCard", "COM1");
            cMain.comBar         = cMain.ReadIni("System", "comBar", "COM2");
            cMain.ReadAnGuiDelay = Num.IntParse(cMain.ReadIni("System", "ReadAnGuiDelay", "6000"));
            cMain._Modeuser      = cMain.ReadIni("System", "UserName", "Admin");
            cMain.isAutoSn       = Num.BoolParse(cMain.ReadIni("System", "isAutoSn", "true"));
            cData.GetICCard(out cMain.TestIcCardNum);
            if (!cMain.isDebug)
            {
                if (cPingMcgs.localHostIp() != "192.168.1.100")
                {
                    MessageBox.Show("本机IP地址错误,请将本机IP地址修改为192.168.1.100", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            for (int i = 0; i < cMain.AllCount; i++)
            {
                cMain.mTempNetResult[i] = new cTempResult();
            }
            for (int i = 0; i < cMain.AllCount; i++)
            {
                cMain.mCurrentData[i] = new cNetResult();
            }

            cMain.DataAllTitle  = cMain.DataAllTitleStr.Split(',');
            cMain.DataShowTitle = cMain.DataShowTitleStr.Split(',');
            foreach (Process p in Process.GetProcesses())
            {
                if (p.ProcessName == "ftpserver")
                {
                    p.Kill();
                }
            }
            if (System.IO.File.Exists(cMain.path + "\\exe\\ftpserver.exe"))
            {
                pp = new Process();
                pp.StartInfo.FileName       = cMain.path + "\\Exe\\ftpserver.exe";
                pp.StartInfo.WindowStyle    = ProcessWindowStyle.Minimized;
                pp.StartInfo.CreateNoWindow = true;
                pp.Start();
            }
        }