Exemple #1
0
        private void SendDataThread()
        {
            try
            {
                while (true)
                {
                    if (!GlobalDataInterface.CommportConnectFlag)
                    {
                        Thread.Sleep(10);
                        continue;
                    }
                    if (GlobalDataInterface.SendMsgData.Count == 0)
                    {
                        Thread.Sleep(10);
                        continue;
                    }
                    byte[] bytes;
                    if (GlobalDataInterface.SendMsgData.TryDequeue(out bytes))
                    {
                        tcpClient.Send(bytes, 0, bytes.Length);
                    }
                    Thread.Sleep(10);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ProjectSetForm中函数SendDataThread出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ProjectSetForm中函数SendDataThread出错" + ex);
#endif
            }
        }
Exemple #2
0
        private void AllcheckBox_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                CheckBox checkbox = (CheckBox)sender;
                if (checkbox.Checked)
                {
                    for (int i = 0; i < this.IPMcustomCheckedListBox.Items.Count; i++)
                    {
                        this.IPMcustomCheckedListBox.SetItemChecked(i, true);
                    }
                }
                else
                {
                    for (int i = 0; i < this.IPMcustomCheckedListBox.Items.Count; i++)
                    {
                        this.IPMcustomCheckedListBox.SetItemChecked(i, false);
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ProjectSetForm-SystemSruct中函数WeighcheckBox_CheckedChanged出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ProjectSetForm-SystemSruct中函数WeighcheckBox_CheckedChanged出错" + ex);
#endif
            }
        }
Exemple #3
0
        private void FruitTypedataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)  //Add by ChengSk - 20180507
                {
                    return;
                }

                if (IsCellValidate)
                {
                    IsCellValidate = false;
                    if (e.ColumnIndex == 0)
                    {
                        this.FruitTypedataGridView[e.ColumnIndex, e.RowIndex].Value = GlobalDataInterface.globalOut_AnalogDensity.uAnalogDensity[e.RowIndex].ToString("#0.00");
                    }
                }
                if ((this.FruitTypedataGridView[e.ColumnIndex, e.RowIndex].Value == null) && e.ColumnIndex > 0)
                {
                    this.FruitTypedataGridView[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.White;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ProjectSetForm-FruitSet中函数FruitTypedataGridView_CellValidating出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ProjectSetForm-FruitSet中函数FruitTypedataGridView_CellValidating出错" + ex);
#endif
            }
        }
Exemple #4
0
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WaveCaptureOKbutton_Click(object sender, EventArgs e)
        {
            try
            {
                m_EndInterval.CopyTo(m_waveInterval, 0);
                if (m_waveInterval[0] > m_waveInterval[1])
                {
                    byte temp = m_waveInterval[0];
                    m_waveInterval[0] = m_waveInterval[1];
                    m_waveInterval[1] = temp;
                }
                int WeightSubsysindex        = Commonfunction.GetSubsysIndex(m_nChannelID);
                int WeightSubsysChannelIndex = Commonfunction.GetChannelIndex(m_nChannelID);

                GlobalDataInterface.globalOut_WeightBaseInfo[WeightSubsysindex * ConstPreDefine.MAX_CHANNEL_NUM + WeightSubsysChannelIndex].waveinterval[0] = m_waveInterval[0];
                GlobalDataInterface.globalOut_WeightBaseInfo[WeightSubsysindex * ConstPreDefine.MAX_CHANNEL_NUM + WeightSubsysChannelIndex].waveinterval[1] = m_waveInterval[1];
                if (GlobalDataInterface.global_IsTestMode)
                {
                    GlobalDataInterface.TransmitParam(m_nChannelID, (int)HC_FSM_COMMAND_TYPE.HC_CMD_WEIGHT_INFO, null);
                    GlobalDataInterface.TransmitParam(m_nChannelID, (int)HC_FSM_COMMAND_TYPE.HC_CMD_WAVE_FORM_OFF, null);//开启波形捕捉
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("WaveCaptureForm中函数WaveCaptureOKbutton_Click出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("WaveCaptureForm中函数WaveCaptureOKbutton_Click出错" + ex);
#endif
            }
        }
        /// <summary>
        /// 开始烧写
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Startbutton_Click(object sender, EventArgs e)
        {
            try
            {
                byte[] data       = new byte[m_file.Length + sizeof(int)];//下传参数
                byte[] datalength = new byte[sizeof(int)];
                if (this.DataLenghthnumericUpDown.Text == "0")
                {
                    //MessageBox.Show("0x30001032 Please input the data length!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageBox.Show("0x30001032 " + LanguageContainer.BootFlashBurnFormMessagebox1Text[GlobalDataInterface.selectLanguageIndex],
                                    LanguageContainer.BootFlashBurnFormMessageboxInformationCaption[GlobalDataInterface.selectLanguageIndex],
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                datalength = BitConverter.GetBytes(int.Parse(this.DataLenghthnumericUpDown.Text));
                Array.Copy(datalength, 0, data, 0, datalength.Length);
                Array.Copy(m_FileData, 0, data, datalength.Length - 1, m_FileData.Length);
                if (GlobalDataInterface.global_IsTestMode)
                {
                    GlobalDataInterface.TransmitParam(Common.Commonfunction.EncodeSubsys(0), (int)HC_FSM_COMMAND_TYPE.HC_CMD_BOOT_FLASH_BURN, data);//只给16发送
                }
                this.Startbutton.Enabled = false;
            }
            catch (Exception ex)
            {
                Trace.WriteLine("BootFlashBurnForm中函数Startbutton_Click出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("BootFlashBurnForm中函数Startbutton_Click出错" + ex);
#endif
            }
        }
Exemple #6
0
        private void ExitlistViewEx_SubItemEndEditing(object sender, ListViewEx.SubItemEndEditingEventArgs e)
        {
            try
            {
                ListViewEx.ListViewEx listviewex = (ListViewEx.ListViewEx)sender;

                switch (e.SubItem)
                {
                case 1:
                    if (e.Item.Index >= 0)
                    {
                        tempGlobalExitInfo[m_ExitSubsysindex * ConstPreDefine.MAX_CHANNEL_NUM + m_ExitSubsysChannelIndex].Delay_time[e.Item.Index] = float.Parse(e.DisplayText);
                    }
                    break;

                case 2:
                    if (e.Item.Index >= 0)
                    {
                        tempGlobalExitInfo[m_ExitSubsysindex * ConstPreDefine.MAX_CHANNEL_NUM + m_ExitSubsysChannelIndex].Hold_time[e.Item.Index] = float.Parse(e.DisplayText);
                    }
                    //tempExitInfo[m_ExitSubsysindex * ConstPreDefine.MAX_CHANNEL_NUM + m_ExitSubsysChannelIndex].exits[e.Item.Index].nDis = (short)int.Parse(e.DisplayText);
                    break;

                default: break;
                }
                //tempGlobalExitInfo.CopyTo(GlobalDataInterface.globalOut_GlobalExitInfo, 0);//add by xcw -20191209
            }
            catch (Exception ex)
            {
                Trace.WriteLine("VolveTestForm中函数ExitlistViewEx_SubItemEndEditing出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("VolveTestForm中函数ExitlistViewEx_SubItemEndEditing出错" + ex);
#endif
            }
        }
Exemple #7
0
        /// <summary>
        /// 开始/停止捕捉按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Capturedbutton_Click(object sender, EventArgs e)
        {
            try
            {
                m_IsWaveCapturing = !m_IsWaveCapturing;
                if (m_IsWaveCapturing)
                {
                    this.Capturedbutton.Text           = m_resourceManager.GetString("Capturedbutton.Text");
                    this.WaveCapturehScrollBar.Enabled = false;
                    this.WaveCapturehScrollBar.Value   = this.WaveCapturehScrollBar.Maximum;
                    if (GlobalDataInterface.global_IsTestMode)
                    {
                        GlobalDataInterface.TransmitParam(m_nChannelID, (int)HC_FSM_COMMAND_TYPE.HC_CMD_WAVE_FORM_ON, null);//关闭波形捕捉
                    }
                }
                else
                {
                    this.Capturedbutton.Text           = m_resourceManager.GetString("StartCapturedlabel.Text");
                    this.WaveCapturehScrollBar.Enabled = true;
                    if (GlobalDataInterface.global_IsTestMode)
                    {
                        GlobalDataInterface.TransmitParam(m_nChannelID, (int)HC_FSM_COMMAND_TYPE.HC_CMD_WAVE_FORM_OFF, null);//关闭波形捕捉
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("WaveCaptureForm中函数Capturedbutton_Click出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("WaveCaptureForm中函数Capturedbutton_Click出错" + ex);
#endif
            }
        }
Exemple #8
0
        /// <summary>
        /// 数据库删除操作
        /// </summary>
        /// <param name="strSQL">SQL删除语句</param>
        /// <returns>删除是否成功</returns>
        public Boolean DeleteData(string strSQL)
        {
            SqlConnection conn = new SqlConnection(strConn);
            SqlCommand    comm = new SqlCommand(strSQL, conn);

            comm.CommandType = CommandType.Text;
            try
            {
                conn.Open();
                int i = comm.ExecuteNonQuery();
                conn.Close();
                conn.Dispose();
                if (i > 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("DeleteData Error: " + ex.ToString());
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("DeleteData Error: " + ex.ToString());
                GlobalDataInterface.WriteErrorInfo("DeleteData Error SQL: " + strSQL); //打印执行错误的SQL语句 Add by ChengSk - 20180919
#endif
            }
            return(false);
        }
Exemple #9
0
//        private void ConnecttoServerTimeOut(object sender)
//        {

//            ConnectServerParam param = (ConnectServerParam)sender;

//            try
//            {
//                //lock (this)
//                //{

//                    if (!param.socket.Connected)
//                    {
//                        param.socket.Connect(param.IPaddress, param.PortNum);//连接服务器
//                        //IsConnected = true;
//                        param.IsConnected = true;
//                    }
//                //}
//            }
//            catch (Exception e)
//            {
//                Trace.WriteLine(string.Format("网络连接出错,IP{0},PortNum{1}", param.IPaddress, param.PortNum) + e);
//#if REALEASE
//                GlobalDataInterface.WriteErrorInfo(string.Format("网络连接出错,IP{0},PortNum{1}", param.IPaddress, param.PortNum) + e);
//#endif
//            }

//        }
        /// <summary>
        /// 断开服务器
        /// </summary>
        private void DestroySocket(Socket socket, bool sign)
        {
            if (socket != null)
            {
                //lock (this)
                //{
                if (sign)
                {
                    socket.Shutdown(SocketShutdown.Send);
                    WaitSocketClose(socket);
                    Trace.WriteLine("Socket正常等待服务器通知关闭");
#if REALEASE
                    GlobalDataInterface.WriteErrorInfo("Socket正常等待服务器通知关闭");
#endif
                }
                else
                {
                    socket.Close();
                    Trace.WriteLine("Socket不正常关闭");
#if REALEASE
                    GlobalDataInterface.WriteErrorInfo("Socket不正常关闭");
#endif
                }
                //}
            }
        }
        //参数信息 - 生效(所有通道均生效)
        private void ButtonSetupSetAll_Click(object sender, EventArgs e)
        {
            try
            {
                bool resFlag = SetupParameterCheckProcess1();
                if (!resFlag)
                {
                    return;
                }

                if (MessageBox.Show("将内部品质信息参数更新到所有通道设备." +
                                    System.Environment.NewLine + System.Environment.NewLine + "是否继续?"
                                    , "警告信息", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }

                //将“所有通道”的内部品质参数下发到设备
                if (m_ChanelIDList.Count > 0 && GlobalDataInterface.InternalAvailable == true)
                {
                    SendDevParaData(m_ChanelIDList.Count);  //仅在通道不为零的情况下才发送内部品质基础信息
                }

                GlobalDataInterface.globalOut_SysDevParaData.ToCopy(temp_SysDevParaData); //局部变量赋值到全局变量
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ProjectSetForm-InnerQuality中函数ButtonSetupSetAll_Click出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ProjectSetForm-InnerQuality中函数ButtonSetupSetAll_Click出错" + ex);
#endif
            }
        }
Exemple #11
0
        /// <summary>
        /// 数据库查询操作(返回结果数据集)
        /// </summary>
        /// <param name="strSQL">SQL查询语句</param>
        /// <returns>查询结果数据集</returns>
        public DataSet SelectData(string strSQL)
        {
            SqlConnection conn = new SqlConnection(strConn);
            SqlCommand    comm = new SqlCommand(strSQL, conn);

            comm.CommandType = CommandType.Text;
            SqlDataAdapter da  = new SqlDataAdapter(comm);
            DataSet        dst = new DataSet();

            try
            {
                conn.Open();
                comm.ExecuteNonQuery();
                da.Fill(dst);
                conn.Close();
                conn.Dispose();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("SelectData Error: " + ex.ToString());
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("SelectData Error:" + ex.ToString());
                GlobalDataInterface.WriteErrorInfo("SelectData Error SQL:" + strSQL); //打印执行错误的SQL语句 Add by ChengSk - 20180919
#endif
            }

            return(dst);
        }
        //光谱仪信息 - 生效(仅当前通道的光谱仪信息生效,其它通道不变)
        private void ButtonSetSpectrum_Click(object sender, EventArgs e)
        {
            try
            {
                bool resFlag = SetupParameterCheckProcess2();
                if (!resFlag)
                {
                    return;
                }

                if (MessageBox.Show("将光谱信息参数更新到通道" + (m_InnerQualitySelectIndex + 1).ToString() + "设备." +
                                    System.Environment.NewLine + System.Environment.NewLine + "是否继续?"
                                    , "警告信息", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }

                this.LabelWaitCount.Text = "光谱仪信息发送中...";
                //将“当前通道”的光谱信息参数下发到设备
                SendSpectrumInfoData(m_InnerQualitySelectIndex);

                int SelId = m_ChanelIDList[m_InnerQualitySelectIndex];
                int m_InnerQualitySubsysindex  = Commonfunction.GetSubsysIndex(SelId);                          //子系统索引
                int m_InnerQualityChannelIndex = Commonfunction.GetChannelIndex(SelId);                         //子系统通道
                int dataIndex = m_InnerQualitySubsysindex * ConstPreDefine.MAX_CHANNEL_NUM + m_InnerQualityChannelIndex;
                GlobalDataInterface.globalOut_SysDevInfoData[dataIndex].ToCopy(temp_SysDevInfoData[dataIndex]); //局部变量赋值到全局变量
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ProjectSetForm-InnerQuality中函数ButtonSetSpectrum_Click出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ProjectSetForm-InnerQuality中函数ButtonSetSpectrum_Click出错" + ex);
#endif
            }
        }
        //光谱仪信息
        private void SetFormInfoDisplay()
        {
            try
            {
                //加载通道零
                if (this.ComboBoxChannel.Items.Count == 0)
                {
                    return;
                }
                int SelId = m_ChanelIDList[m_InnerQualitySelectIndex];
                int m_InnerQualitySubsysindex  = Commonfunction.GetSubsysIndex(SelId);  //子系统索引
                int m_InnerQualityChannelIndex = Commonfunction.GetChannelIndex(SelId); //子系统通道
                int dataIndex = m_InnerQualitySubsysindex * ConstPreDefine.MAX_CHANNEL_NUM + m_InnerQualityChannelIndex;
                this.EditInfoProductID.Text      = Commonfunction.ByteArrayToString(temp_SysDevInfoData[dataIndex].ProductID.buf);
                this.EditInfoProductSerial.Text  = Commonfunction.ByteArrayToString(temp_SysDevInfoData[dataIndex].ProductSerial.buf);
                this.EditInfoSpectoroSerial.Text = System.Text.Encoding.Default.GetString(temp_SysDevInfoData[dataIndex].SpectraSerial.buf);
                this.EditCcdInfoCoeffA0.Text     = string.Format("{0:0.0000000E+00}", temp_SysDevInfoData[dataIndex].unitDblAr.DblArray[0]);
                this.EditCcdInfoCoeffA1.Text     = string.Format("{0:0.0000000E+00}", temp_SysDevInfoData[dataIndex].unitDblAr.DblArray[1]);
                this.EditCcdInfoCoeffA2.Text     = string.Format("{0:0.0000000E+00}", temp_SysDevInfoData[dataIndex].unitDblAr.DblArray[2]);
                this.EditCcdInfoCoeffA3.Text     = string.Format("{0:0.0000000E+00}", temp_SysDevInfoData[dataIndex].unitDblAr.DblArray[3]);
                this.EditCcdInfoCoeffA4.Text     = string.Format("{0:0.0000000E+00}", temp_SysDevInfoData[dataIndex].unitDblAr.DblArray[4]);
                this.EditCcdInfoCoeffA5.Text     = string.Format("{0:0.0000000E+00}", temp_SysDevInfoData[dataIndex].unitDblAr.DblArray[5]);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ProjectSetForm-InnerQuality中函数SetFormInfoDisplay出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ProjectSetForm-InnerQuality中函数SetFormInfoDisplay出错" + ex);
#endif
            }
        }
        private void RegisterEventThread(object arg)
        {
            try
            {
                DeviceInfo deviceInfo = new DeviceInfo();
                deviceInfo = (DeviceInfo)arg;

                string  strData      = Commonfunction.getJsonByObject(deviceInfo);
                string  strUrl       = GlobalDataInterface.ServerURL + "UpLoadDeviceRegisterInfo?data=";
                string  result       = HttpHelper.OpenReadWithHttps(strUrl, strData, 10000, new IPEndPoint(IPAddress.Parse(GlobalDataInterface.ServerBindLocalIP), 0));
                JObject jo           = (JObject)JsonConvert.DeserializeObject(result);
                string  reMessage    = jo["message"].ToString();
                string  reResult     = jo["result"].ToString();
                string  reStatus     = jo["status"].ToString();
                string  reStatusCode = jo["statusCode"].ToString();
                if ((reMessage.Contains("注册成功") || reMessage.Contains("更新成功")) && reMessage.Contains(GlobalDataInterface.DeviceNumber))
                {
                    MessageBox.Show(reMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(reMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("DataDownloadForm中函数RegisterEventThread出错" + ex);
#endif
                MessageBox.Show("注册失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #15
0
        /// <summary>
        /// 设置腐烂列表参数
        /// </summary>
        private void SetRotListView()
        {
            try
            {
                this.RotlistViewEx.Items.Clear();
                ListViewItem item;
                for (int i = 0; i < this.RotcomboBox.SelectedIndex + 1; i++)
                {
                    byte[] temp = new byte[ConstPreDefine.MAX_TEXT_LENGTH];
                    Array.Copy(m_RotGradeName, i * ConstPreDefine.MAX_TEXT_LENGTH, temp, 0, ConstPreDefine.MAX_TEXT_LENGTH);

                    item = new ListViewItem(Encoding.Default.GetString(temp).TrimEnd('\0'));
                    if (i == this.RotcomboBox.SelectedIndex)
                    {
                        m_RotFactor[2 * i]     = 0;
                        m_RotFactor[2 * i + 1] = 0;
                    }
                    item.SubItems.Add(m_RotFactor[2 * i].ToString());
                    item.SubItems.Add(m_RotFactor[2 * i + 1].ToString());
                    this.RotlistViewEx.Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("QualityParamSetForm-RotSetFormt中函数SetRotListView出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("QualityParamSetForm-RotSetFormt中函数SetRotListView出错" + ex);
#endif
            }
        }
Exemple #16
0
        /// <summary>
        /// 关闭Socket线程
        /// </summary>
        private void WaitSocketCloseThread()
        {
            try
            {
                while (SocketList.Count > 0)
                {
                    byte[] temp = new byte[1];

                    Socket iter    = (Socket)SocketList[SocketList.Count - 1];
                    int    iResult = iter.Receive(temp);
                    while (iResult > 0)
                    {
                        iResult = iter.Receive(temp);
                    }
                    Thread.Sleep(1);
                    iter.Close();
                    SocketList.Remove(iter);
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine("CTcpClient类中函数WaitSocketCloseThread出错" + e);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("CTcpClient类中函数WaitSocketCloseThread出错" + e);
#endif
            }
        }
Exemple #17
0
        /// <summary>
        /// 通道出口初始化
        /// </summary>
        private void SetExitlistViewEx()
        {
            try
            {
                this.ExitlistViewEx.Items.Clear();
                int SelId = m_ChanelIDList[0];
                m_ExitSubsysindex        = Commonfunction.GetSubsysIndex(SelId);
                m_ExitSubsysChannelIndex = Commonfunction.GetChannelIndex(SelId);


                ListViewItem lvi;
                for (int i = 0; i < GlobalDataInterface.globalOut_SysConfig.nExitNum; i++)
                {
                    lvi = new ListViewItem(m_resourceManager.GetString("Outletlabel.Text") + string.Format(" {0}", i + 1));
                    //lvi.SubItems.Add(string.Format("{0}", tempExitInfo[m_ExitSubsysindex * ConstPreDefine.MAX_CHANNEL_NUM + m_ExitSubsysChannelIndex].exits[i].nOffset));
                    //lvi.SubItems.Add(string.Format("{0}", tempExitInfo[m_ExitSubsysindex * ConstPreDefine.MAX_CHANNEL_NUM + m_ExitSubsysChannelIndex].exits[i].nDis));
                    lvi.SubItems.Add(tempGlobalExitInfo[m_ExitSubsysindex].Delay_time[i].ToString());
                    lvi.SubItems.Add(tempGlobalExitInfo[m_ExitSubsysindex].Hold_time[i].ToString());
                    //lvi.SubItems.Add(string.Format("{0}", tempExitInfo[m_ExitSubsysindex * ConstPreDefine.MAX_CHANNEL_NUM + m_ExitSubsysChannelIndex].exits[i].nDriverPin));  //Note by ChengSk - 20180402
                    this.ExitlistViewEx.Items.Add(lvi);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("VolveTestForm中函数ChannelExitIntial出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("VolveTestForm中函数ChannelExitIntial出错" + ex);
#endif
            }
        }
Exemple #18
0
        /// <summary>
        /// 接受命令头
        /// </summary>
        /// <param name="clientSocket"></param>
        /// <param name="nCmdId">命令ID</param>
        /// <param name="nSrcId">发送源ID</param>
        /// <returns></returns>
        private bool RecvCommand(Socket clientSocket, ref int nCmdId, ref int nSrcId)
        {
            /*接收同步头*/
            if (!RecvSync(clientSocket))
            {
                return(false);
            }

            nSrcId = -1;
            int nDstId = -1;

            nCmdId = -1;

            try
            {
                IntPtr pData = Marshal.AllocHGlobal(sizeof(byte) * 4 * 3);
                if (pData == null)
                {
                    return(false);
                }

                /*接收命令头*/
                if (!RecvData(clientSocket, ref pData, 12))
                {
                    return(false);
                }
                else
                {
                    nSrcId = Marshal.ReadInt32(pData, 0); //接收发送源Id
                    nDstId = Marshal.ReadInt32(pData, 4); //接收发送目标Id
                    if (nDstId != ConstPreDefine.HC_ID)
                    {
                        return(false);
                    }
                    nCmdId = Marshal.ReadInt32(pData, 8);//接受命令
                    Marshal.FreeHGlobal(pData);
                }
            }
            catch (AccessViolationException e)
            {
                Trace.WriteLine("TcpServer中RecvCommand函数开辟非托管内存失败:" + e);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("TcpServer中RecvCommand函数开辟非托管内存失败:" + e);
#endif
            }
            catch (Exception e)
            {
                Trace.WriteLine("TcpServer中RecvCommand函数错误:" + e);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("TcpServer中RecvCommand函数错误:" + e);
#endif
            }

            if (nCmdId == -1 || nSrcId == -1)
            {
                return(false);
            }

            return(true);
        }
Exemple #19
0
        /// <summary>
        /// 鼠标放开事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WeightWavepictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                PictureBox pictureBox = (PictureBox)sender;
                Graphics   graphics   = pictureBox.CreateGraphics();//创建画板

                if (m_IntervalCatched)
                {
                    if (m_IntervalCatchedType == 1)
                    {
                        m_waveInterval[0] = (byte)m_tempInterval;
                    }
                    else
                    {
                        m_waveInterval[1] = (byte)m_tempInterval;
                    }
                    pictureBox.Invalidate();
                    m_IntervalCatched = false;
                }
                m_MouseDown = false;
            }
            catch (Exception ex)
            {
                Trace.WriteLine("WaveCaptureForm中函数WeightWavepictureBox_MouseUp出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("WaveCaptureForm中函数WeightWavepictureBox_MouseUp出错" + ex);
#endif
            }
        }
Exemple #20
0
        /// <summary>
        /// 保存配置界面初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveConfigForm_Load(object sender, EventArgs e)
        {
            try
            {
                List <string> configList = new List <string>();
                if (m_IsProjectConfig)
                {
                    this.Text = m_resourceManager.GetString("SaveProjectConfiglabel.Text");
                    Commonfunction.GetAllProjectSettingFileName(ref configList);
                }
                else
                {
                    this.Text = m_resourceManager.GetString("SaveUserConfiglabel.Text");
                    Commonfunction.GetAllCommonSettingFileName(ref configList);
                }
                if (configList.Count > 0)
                {
                    for (int i = 0; i < configList.Count; i++)
                    {
                        this.ConfiglistBox.Items.Add(configList[i]);
                    }
                    this.ConfiglistBox.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("SaveConfigForm中函数SaveConfigForm_Load出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("SaveConfigForm中函数SaveConfigForm_Load出错" + ex);
#endif
            }
        }
Exemple #21
0
        private void WaveCaptureForm_Load(object sender, EventArgs e)
        {
            try
            {
                this.WaveCapturehScrollBar.Enabled = false;//波形捕捉时不许查看之前数据

                m_fTransRatio = (float)this.WeightWavepictureBox.Height / (4096.0f * 2.0f);

                this.WaveCapturehScrollBar.Value = this.WaveCapturehScrollBar.Maximum;
                lock (this)
                {
                    GlobalDataInterface.globalIn_wavelist.Clear();
                }

                if (GlobalDataInterface.global_IsTestMode)
                {
                    GlobalDataInterface.TransmitParam(m_nChannelID, (int)HC_FSM_COMMAND_TYPE.HC_CMD_WAVE_FORM_ON, null);//开启波形捕捉
                }
                this.IntervaltextBox1.Text = m_waveInterval[0].ToString();
                this.IntervaltextBox2.Text = m_waveInterval[1].ToString();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("WaveCaptureForm中函数WaveCaptureForm_Load出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("WaveCaptureForm中函数WaveCaptureForm_Load出错" + ex);
#endif
            }
        }
Exemple #22
0
        /// <summary>
        /// 体积
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void VolumecheckBox_Click(object sender, EventArgs e)
        {
            try
            {
                CheckBox checkBox = (CheckBox)sender;
                if (checkBox.Checked)
                {
                    m_bSwitchNumber                  = false;
                    m_bSwitchWeight                  = false;
                    m_bSwitchVolume                  = true;
                    this.NumcheckBox.Checked         = false;
                    this.WeightcheckBox.Checked      = false;
                    this.NumnumericUpDown.Enabled    = m_bSwitchNumber;
                    this.WeightnumericUpDown.Enabled = m_bSwitchWeight;
                    this.VolumenumericUpDown.Enabled = m_bSwitchVolume;
                    this.VolumenumericUpDown.Focus();
                    this.VolumenumericUpDown.Text = "0";
                }
                else
                {
                    m_bSwitchVolume = false;
                    this.VolumenumericUpDown.Enabled = m_bSwitchVolume;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ExitSwitchForm中函数VolumecheckBox_Click出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ExitSwitchForm中函数VolumecheckBox_Click出错" + ex);
#endif
            }
        }
Exemple #23
0
        /// <summary>
        /// 浏览按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Scanbutton_Click(object sender, EventArgs e)
        {
            try
            {
                string         fileName       = "";
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.InitialDirectory = System.Environment.CurrentDirectory;
                openFileDialog.Filter           = "bin files(*.bin)|*.bin|All files(*.*)|*.*";
                openFileDialog.FilterIndex      = 1;
                openFileDialog.RestoreDirectory = true;
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    fileName   = openFileDialog.FileName;
                    m_file     = new FileInfo(openFileDialog.FileName);
                    m_FileData = new byte[m_file.Length];
                    FileStream   fs     = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                    BinaryReader reader = new BinaryReader(fs);
                    m_FileData = reader.ReadBytes((int)m_file.Length);
                    reader.Close();
                    fs.Close();
                    this.FileRoottextBox.Text = openFileDialog.FileName;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("BootFlashBurnForm中函数Scanbutton_Click出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("BootFlashBurnForm中函数Scanbutton_Click出错" + ex);
#endif
            }
        }
Exemple #24
0
        /// <summary>
        /// 贴标4
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LabelcheckBox4_Click(object sender, EventArgs e)
        {
            try
            {
                CheckBox checkBox = (CheckBox)sender;
                if (checkBox.Checked)
                {
                    m_nLabel = 4;
                    this.LabelcheckBox1.Checked = false;
                    this.LabelcheckBox2.Checked = false;
                    this.LabelcheckBox3.Checked = false;
                }
                else
                {
                    m_nLabel = 0;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ExitSwitchForm中函数LabelcheckBox4_Click出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ExitSwitchForm中函数LabelcheckBox4_Click出错" + ex);
#endif
            }
        }
Exemple #25
0
        /// <summary>
        /// 浮皮列表编辑完事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SkinlistViewEx_SubItemEndEditing(object sender, ListViewEx.SubItemEndEditingEventArgs e)
        {
            try
            {
                byte[] temp = new byte[ConstPreDefine.MAX_TEXT_LENGTH];
                switch (e.SubItem)
                {
                case 0:
                    Array.Copy(temp, 0, m_SkinGradeName, e.Item.Index * ConstPreDefine.MAX_TEXT_LENGTH, temp.Length);
                    temp = Encoding.Default.GetBytes(e.DisplayText);
                    Array.Copy(temp, 0, m_SkinGradeName, e.Item.Index * ConstPreDefine.MAX_TEXT_LENGTH, temp.Length);
                    break;

                case 1:
                    m_fSkinFactor[e.Item.Index] = float.Parse(e.DisplayText);
                    break;

                default: break;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("QualityParamSetForm-SkinSetForm中函数SkinlistViewEx_SubItemEndEditing出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("QualityParamSetForm-SkinSetForm中函数SkinlistViewEx_SubItemEndEditing出错" + ex);
#endif
            }
        }
Exemple #26
0
        private void ReplaceSelectcheckBox_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                string strexitDisplayTypeConfig = "出口显示名称类型";
                long   exitDisplayType          = long.Parse(Commonfunction.GetAppSetting(strexitDisplayTypeConfig));

                if (this.ReplaceSelectcheckBox.Checked == true) //0
                {
                    this.DisplayNametextBox.ReadOnly = true;
                    exitDisplayType &= ~((long)1 << m_nCurrentExitIndex);
                }
                else //1
                {
                    this.DisplayNametextBox.ReadOnly = false;
                    exitDisplayType |= ((long)1 << m_nCurrentExitIndex);
                }

                Commonfunction.SetAppSetting(strexitDisplayTypeConfig, exitDisplayType.ToString());
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ExitSwitchForm中函数ReplaceSelectcheckBox_CheckedChanged出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ExitSwitchForm中函数ReplaceSelectcheckBox_CheckedChanged出错" + ex);
#endif
            }
        }
Exemple #27
0
        /// <summary>
        /// 果杯测试按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Testbutton_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.Testbutton.Text == m_resourceManager.GetString("Testbutton.Text"))
                {
                    this.Testbutton.Text = m_resourceManager.GetString("StopTestlabel.Text");
                    this.Infolabel.Text  = m_resourceManager.GetString("TestInfolabel.Text");
                    if (GlobalDataInterface.global_IsTestMode)
                    {
                        GlobalDataInterface.TransmitParam(-1, (int)HC_FSM_COMMAND_TYPE.HC_CMD_TEST_CUP_ON, null);
                    }
                }
                else
                {
                    this.Testbutton.Text = m_resourceManager.GetString("Testbutton.Text");
                    this.Infolabel.Text  = m_resourceManager.GetString("PrepareInfolabel.Text");
                    if (GlobalDataInterface.global_IsTestMode)
                    {
                        GlobalDataInterface.TransmitParam(-1, (int)HC_FSM_COMMAND_TYPE.HC_CMD_TEST_CUP_OFF, null);
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("TestCupForm中函数Testbutton_Click出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("TestCupForm中函数Testbutton_Click出错" + ex);
#endif
            }
        }
Exemple #28
0
        private void RotpictureBox_Paint(object sender, PaintEventArgs e)
        {
            try
            {
                Graphics graphics = e.Graphics;//创建画板
                GCHandle handle;
                IntPtr   scan;

                if (m_RotDrawImage)
                {
                    int   stride = m_rotWidth * 4;
                    float radio  = (float)this.RotpictureBox.Width / m_rotWidth;

                    //画图片
                    handle     = GCHandle.Alloc(m_rotimageRGB, GCHandleType.Pinned);
                    scan       = handle.AddrOfPinnedObject();
                    m_RotImage = new Bitmap(m_rotWidth, m_rotHeight, stride, System.Drawing.Imaging.PixelFormat.Format32bppRgb, scan);

                    graphics.DrawImage(m_RotImage, 0, 0, this.RotpictureBox.Width, radio * m_rotHeight);
                    handle.Free();

                    m_RotDrawImage = false;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("QualityParamSetForm-RotSetFormt中函数RotpictureBox_Paint出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("QualityParamSetForm-RotSetFormt中函数RotpictureBox_Paint出错" + ex);
#endif
            }
        }
Exemple #29
0
        private void DownLoadDataThread()
        {
            try
            {
                bool         bDownLoaded;
                WaitHandle[] waitEvent = new WaitHandle[2];
                waitEvent[0] = new EventWaitHandle(false, EventResetMode.AutoReset, "DownLoad", out bDownLoaded);
                waitEvent[1] = ThreadAbortEventDone;

                while (true)
                {
                    //waitEvent.WaitOne();
                    int result1 = WaitHandle.WaitAny(waitEvent, -1);
                    if (result1 == 1)
                    {
                        break;
                    }
                    else
                    {
                        bool bContinue = true;
                        int  ErrorNum  = 0;
                        while (bContinue)
                        {
                            int bFlag = OnDownLoadDataEvent();
                            switch (bFlag)
                            {
                            case 0:
                                break;

                            case 1:
                                break;

                            case 2:
                                bContinue = false;
                                break;

                            case 3:
                                ErrorNum++;
                                break;

                            default:
                                break;
                            }
                            if (ErrorNum >= 5)
                            {
                                bContinue = false;
                            }
                            Thread.Sleep(500);
                        }
                    }
                    Thread.Sleep(500);
                }
            }
            catch (Exception ex)
            {
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("DataDownloadForm中函数DownLoadDataThread出错" + ex);
#endif
            }
        }
Exemple #30
0
        public void MessageDataSend(byte MsgType, byte[] MsgData = null)
        {
            try
            {
                if (!GlobalDataInterface.CommportConnectFlag)
                {
                    return;
                }
                int MsgLength = 0;
                if (MsgData != null)
                {
                    MsgLength = MsgData.Length;
                }
                byte[] buff = new byte[(4 + MsgLength)];
                buff[0] = ConstPreDefine.STX;
                buff[1] = MsgType;
                buff[2] = Convert.ToByte(MsgLength & 0xff);
                buff[3] = Convert.ToByte((MsgLength >> 8) & 0xff);
                if (MsgData != null && MsgLength > 0)
                {
                    Array.Copy(MsgData, 0, buff, 4, MsgLength);
                }
                GlobalDataInterface.SendMsgData.Enqueue(buff);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ProjectSetForm中函数MessageDataSend出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ProjectSetForm中函数MessageDataSend出错" + ex);
#endif
            }
        }