Exemplo n.º 1
0
        /// <summary>
        /// 远程开机
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenIPMbutton_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (string item in this.IPMcustomCheckedListBox.CheckedItems)
                {
                    string[] sArray = item.Split('-');
                    string   IP     = ConstPreDefine.LC_IP_ADDR_TEMPLATE + (int.Parse(sArray[sArray.Length - 1]) + 16).ToString();
                    string   IPName = "IPM-" + IP;
                    //string strMAC = getMacAddr_Remote(IP);            //Note by ChengSk - 2017/09/26
                    string strMAC = Commonfunction.GetAppSetting(IPName); //~Note by ChengSk - 2017/09/26
                    if (strMAC != "")
                    {
                        string[] sArray1 = strMAC.Split('-');
                        //if (sArray1.Length != 6)
                        //{
                        //    MessageBox.Show(item + "'s MAC is wrong!");
                        //    continue;
                        //}

                        byte[] mac = new byte[strMAC.Length];
                        for (int i = 0; i < sArray1.Length; i++)
                        {
                            mac[i] = (byte)(int.Parse(sArray1[i], System.Globalization.NumberStyles.HexNumber));
                        }
                        WakeUp(mac);
                    }
                }
            }
            catch (Exception ex)
            { }
        }
Exemplo n.º 2
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
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 用户手册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 用户手册ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string strManualName = Commonfunction.GetAppSetting("用户手册");
                string fileNewPat    = Application.StartupPath;
                if (!Directory.Exists(fileNewPat + "\\handbook\\"))
                {
                    Directory.CreateDirectory(fileNewPat + "\\handbook\\");
                }
                strManualName = strManualName.Replace("**", GlobalDataInterface.selectLanguage);//Add by xcw - 20191031
                string fileName = fileNewPat + "\\handbook\\" + strManualName;
                //MessageBox.Show("**" + fileName + "**");
                if (File.Exists(fileName))
                {
                    Process process1 = new Process();
                    process1.StartInfo.FileName    = fileName;
                    process1.StartInfo.Arguments   = "";
                    process1.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
                    process1.Start();
                }
                else
                {
                    MessageBox.Show("File does not exist!");
                }
            }
            catch (Exception ex)
            {
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("MainForm中函数用户手册ToolStripMenuItem_Click出错" + ex);
#endif
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 更新IPM列表状态
        /// </summary>
        private void RefreshIPMList()
        {
            try
            {
                Ping m_ping = new Ping();
                this.IPMcustomCheckedListBox.Items.Clear();
                this.IPMMACAddrlistViewEx.Items.Clear();
                lstIPMIP.Clear();
                //统计每个子系统的通道数
                int          k = 0;
                ListViewItem lvi;
                for (int i = 0; i < ConstPreDefine.MAX_SUBSYS_NUM; i++)
                {
                    for (int j = 0; j < ConstPreDefine.MAX_CHANNEL_NUM; j++)
                    {
                        //if (GlobalDataInterface.globalOut_SysConfig.nChannelInfo[i * ConstPreDefine.MAX_CHANNEL_NUM + j] == 1)
                        if (GlobalDataInterface.globalOut_SysConfig.nChannelInfo[i] > j)  //Modify by ChengSk - 20190521
                        {
                            //nDstId = Commonfunction.EncodeIPM(i, j);
                            //GlobalDataInterface.TransmitParam(nDstId, (int)HC_IPM_COMMAND_TYPE.HC_CMD_SHUTDOWN, null);
                            int    nDstId    = Commonfunction.EncodeIPM(i, j);
                            int    nSubsysId = Commonfunction.GetIPMID(nDstId);
                            string strTemp   = ConstPreDefine.LC_IP_ADDR_TEMPLATE;
                            string strIP     = strTemp + nSubsysId;//得到IPM的IP地址
                            string strIPName = (nSubsysId - 16).ToString();
                            this.IPMcustomCheckedListBox.Items.Add("IPM-" + strIPName);
                            //this.IPMcustomCheckedListBox.Items.Add("IPM-" + strIP);

                            lstIPMIP.Add(strIP);
                            lvi = new ListViewItem((k + 1).ToString());
                            string strMACAddr = Commonfunction.GetAppSetting("IPM-" + strIP);
                            lvi.SubItems.Add(strMACAddr);
                            this.IPMMACAddrlistViewEx.Items.Add(lvi);//Add by ChengSk - 20190829

                            PingReply pingReply = m_ping.Send(strIP, 500);
                            if (pingReply.Status == IPStatus.Success)
                            {
                                //lvi.SubItems[k].ForeColor= Color.Green;
                                IPMMACAddrlistViewEx.Items[k].BackColor = System.Drawing.Color.Green;
                                //itemColor[k] = Color.Green;
                            }
                            else
                            {
                                //itemColor[k] = Color.White;
                                IPMMACAddrlistViewEx.Items[k].BackColor = System.Drawing.Color.White;//add by xcw 20200226
                                //lvi.SubItems[k].ForeColor = Color.White;
                            }
                            k++;
                        }
                    }
                }

                this.IPMcustomCheckedListBox.Refresh();
            }
            catch (Exception ex)
            { }
        }
Exemplo n.º 5
0
        private void FruitSetInitial()
        {
            try
            {
                this.FruitTypedataGridView.Font = new Font("微软雅黑", 9, FontStyle.Regular);
                this.FruitTypedataGridView.AllowUserToAddRows = false;
                this.FruitTypedataGridView.Rows.Clear();
                this.FruitTypedataGridView.ReadOnly                = false;
                this.FruitTypedataGridView.RowHeadersWidth         = 190;//行表头宽度
                this.FruitTypedataGridView.TopLeftHeaderCell.Value = m_resourceManager.GetString("FruitTypeGridViewTopLeftHeadCelllabel.Text");
                DataGridViewRow row;
                // m_FruitType.iCurrentFruitNumber = int.Parse(Commonfunction.GetAppSetting("已选水果数量"));
                fruittypeconfig   = Commonfunction.GetAppSetting("水果种类大类");
                sFruitMajortArray = fruittypeconfig.Split(';'); //分割具体水果种类
                if (GlobalDataInterface.selectLanguage == "en")
                {
                    fruittypeconfig     = Commonfunction.GetAppSetting("水果种类大类en");
                    sFruitMajortArrayEn = fruittypeconfig.Split(';');//分割具体水果种类
                }
                if (GlobalDataInterface.selectLanguage == "es")
                {
                    fruittypeconfig     = Commonfunction.GetAppSetting("水果种类大类es");
                    sFruitMajortArrayEs = fruittypeconfig.Split(';');//分割具体水果种类 //Add by ChengSk - 20181016
                }
                byte[] btempArray = new byte[ConstPreDefine.MAX_FRUIT_TEXT_LENGTH];
                for (int i = 0; i < sFruitMajortArray.Length - 1; i++)
                {
                    row = new DataGridViewRow();
                    row.HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomLeft;         //设置文字格式
                    this.FruitTypedataGridView.Rows.Add(row);
                    if (GlobalDataInterface.selectLanguage == "en")                                   //英语
                    {
                        this.FruitTypedataGridView.Rows[i].HeaderCell.Value = sFruitMajortArrayEn[i]; //水果大类名称
                    }
                    else if (GlobalDataInterface.selectLanguage == "es")                              //西班牙语
                    {
                        this.FruitTypedataGridView.Rows[i].HeaderCell.Value = sFruitMajortArrayEs[i]; //水果大类名称
                    }
                    else //中文
                    {
                        this.FruitTypedataGridView.Rows[i].HeaderCell.Value = sFruitMajortArray[i];                                           //水果大类名称
                    }
                    this.FruitTypedataGridView[0, i].Value = GlobalDataInterface.globalOut_AnalogDensity.uAnalogDensity[i].ToString("#0.00"); //水果密度
                    fruittypeconfig = Commonfunction.GetAppSetting(sFruitMajortArray[i]);
                    if (fruittypeconfig == "")
                    {
                        continue;
                    }
                    string[] sFruitSubArray = fruittypeconfig.Split(';');
                    for (int j = 0; j < sFruitSubArray.Length - 1; j++)
                    {
                        m_FruitType.member[i * ConstPreDefine.MAX_FRUIT_TYPE_SUB_CLASS_NUM + j].iFruitTypeID = i * ConstPreDefine.MAX_FRUIT_TYPE_SUB_CLASS_NUM + j + 1;
                        btempArray = Encoding.Default.GetBytes(sFruitSubArray[j]);
                        Array.Copy(btempArray, m_FruitType.member[i * ConstPreDefine.MAX_FRUIT_TYPE_SUB_CLASS_NUM + j].bFruitName, btempArray.Length);
                        this.FruitTypedataGridView[j + 1, i].Value = sFruitSubArray[j];
                    }
                }
                /*标记已选水果种类*/
                fruittypeconfig = Commonfunction.GetAppSetting("已选水果种类");
                string[] sFruitSelecttArray = fruittypeconfig.Split(';');//分割已选水果种类
                for (int i = 0; i < sFruitSelecttArray.Length - 1; i++)
                {
                    //string[] tempArray = s.Split(new char[3] { 'c', 'd', 'e' });
                    //string[] tempArray = sFruitSelecttArray[i].Split('-');//分割ID号
                    string[] tempArray = sFruitSelecttArray[i].Split(new char[2] {
                        '.', '-'
                    });                                                                       //分割ID号
                    int ID           = int.Parse(tempArray[0]);
                    int ColoID       = int.Parse(tempArray[1]);
                    int RowIndex     = ID - 1 /*/ ConstPreDefine.MAX_FRUIT_TYPE_SUB_CLASS_NUM*/;
                    int ColoumnIndex = ColoID % ConstPreDefine.MAX_FRUIT_TYPE_SUB_CLASS_NUM;
                    this.FruitTypedataGridView[ColoumnIndex, RowIndex].Style.BackColor = Color.Pink;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ProjectSetForm-FruitSet中函数FruitSetInitial出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ProjectSetForm-FruitSet中函数FruitSetInitial出错" + ex);
#endif
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 初始化系统线程
        /// </summary>
        private static void InitialSysterm()
        {
            try
            {
                //信息提示框按钮附名称
                //MessageBoxManager.OK = "OK";
                //MessageBoxManager.No = "No";
                //MessageBoxManager.Yes = "Yes";
                //MessageBoxManager.Cancel = "Cancel";
                //MessageBoxManager.Retry = "Retry";
                //MessageBoxManager.Ignore = "Ignore";
                //MessageBoxManager.Abort = "Abort";
                //MessageBoxManager.Register();
                MessageBoxManager.OK     = LanguageContainer.ProgramMessageBoxManagerOK[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.No     = LanguageContainer.ProgramMessageBoxManagerNo[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Yes    = LanguageContainer.ProgramMessageBoxManagerYes[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Cancel = LanguageContainer.ProgramMessageBoxManagerCancel[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Retry  = LanguageContainer.ProgramMessageBoxManagerRetry[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Ignore = LanguageContainer.ProgramMessageBoxManagerIgnore[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Abort  = LanguageContainer.ProgramMessageBoxManagerAbort[GlobalDataInterface.selectLanguageIndex];
                MessageBoxManager.Register();

                Thread.Sleep(1000);
                if (m_splashForm != null)
                {
                    // m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "检查本地IP..."; }));
                    //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "Check the local IP..."; }));
                    m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text =
                                                                         LanguageContainer.ProgramMessagebox1Text[GlobalDataInterface.selectLanguageIndex]; }));
                }
                //检查IP地址
                string      hostName  = Dns.GetHostName();
                IPHostEntry IPEntry   = Dns.GetHostEntry(hostName);
                IPAddress   HCIP      = IPAddress.Parse(ConstPreDefine.HC_IP_ADDR);
                string      currentIP = "";

                //for (int i = 0; i < IPEntry.AddressList.Length; i++)
                //{
                //    if (IPEntry.AddressList[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                //    {
                //        currentIP = IPEntry.AddressList[i].ToString();
                //        break;
                //    }
                //}
                //if (!string.Equals(currentIP, ConstPreDefine.HC_IP_ADDR))
                //{
                //    //MessageBox.Show("IP地址错误或没有网络连接!");
                //    MessageBox.Show("0x10000001 IP address error or no network!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
                //    IsSystemContinue = false;
                //    return;
                //}

                //解决多网卡的问题
                bool IsExistCorrentIP = false;
                for (int i = 0; i < IPEntry.AddressList.Length; i++)
                {
                    if (IPEntry.AddressList[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    {
                        currentIP = IPEntry.AddressList[i].ToString();
                        if (string.Equals(currentIP, ConstPreDefine.HC_IP_ADDR))
                        {
                            IsExistCorrentIP = true;
                            break;
                        }
                    }
                }
                if (!IsExistCorrentIP)
                {
                    //MessageBox.Show("IP地址错误或没有网络连接!");
                    //MessageBox.Show("0x10000001 IP address error or no network!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MessageBox.Show("0x10000001 " +
                                    LanguageContainer.ProgramMessagebox2Text[GlobalDataInterface.selectLanguageIndex],
                                    LanguageContainer.ProgramMessageboxErrorCaption[GlobalDataInterface.selectLanguageIndex],
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    IsSystemContinue = false;
                    return;
                }

                //建立网络连接
                if (m_splashForm != null)
                {
                    //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "正在建立网络连接..."; }));
                    //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "Establishing network..."; }));
                    m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text =
                                                                         LanguageContainer.ProgramMessagebox3Text[GlobalDataInterface.selectLanguageIndex]; }));
                }
                global.Init();//网络初始化
                Thread.Sleep(1000);

                //建立数据库连接


                // 查询子系统
                if (m_splashForm != null)
                {
                    //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "正在查询子系统..."; }));
                    //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "Checking the Subsystems..."; }));
                    m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text =
                                                                         LanguageContainer.ProgramMessagebox4Text[GlobalDataInterface.selectLanguageIndex]; }));
                }
                string strSubSystemNum = Commonfunction.GetAppSetting("子系统个数");
                GlobalDataInterface.TransmitParam(-1, (int)HC_FSM_COMMAND_TYPE.HC_CMD_DISPLAY_ON, null);
                if (GlobalDataInterface.SubSystemIsConnected[0] == false)
                {
                    //MessageBox.Show("子系统1连接失败,请检查连接!");
                    //MessageBox.Show("0x10000003 Subsystem 1 connection failure,please check the connection!", "Error", MessageBoxButtons.OK,MessageBoxIcon.Error);
                    MessageBox.Show("0x10000003 初始化" + LanguageContainer.ProgramMessagebox5Text[GlobalDataInterface.selectLanguageIndex],
                                    LanguageContainer.ProgramMessageboxErrorCaption[GlobalDataInterface.selectLanguageIndex],
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //MessageBox.Show("初始化");
                    IsSystemContinue = false;
                    return;
                }
                if (GlobalDataInterface.ConnectSystemNum == 0)
                {
                    //MessageBox.Show("连接下位机失败,请检查连接!");
                    //MessageBox.Show("0x10000002 FSM connection failure,please check the connection!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MessageBox.Show("0x10000002 " + LanguageContainer.ProgramMessagebox6Text[GlobalDataInterface.selectLanguageIndex],
                                    LanguageContainer.ProgramMessageboxErrorCaption[GlobalDataInterface.selectLanguageIndex],
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    IsSystemContinue = false;
                    return;
                }

                if (GlobalDataInterface.ConnectSystemNum < byte.Parse(strSubSystemNum))
                {
                    //DialogResult result = MessageBox.Show("子系统与配置数目不符,是否继续运行?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    //DialogResult result = MessageBox.Show("0x20001001 Configuration does not match the number of subsystems,whether to continue to run?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    DialogResult result = MessageBox.Show("0x20001001 " + LanguageContainer.ProgramMessagebox7Text[GlobalDataInterface.selectLanguageIndex],
                                                          LanguageContainer.ProgramMessageboxWarningCaption[GlobalDataInterface.selectLanguageIndex],
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (result == DialogResult.No)
                    {
                        IsSystemContinue = false;
                        return;
                    }
                }
                if (m_splashForm != null)
                {
                    //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "正在启动..."; }));
                    //m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "Starting..."; }));
                    m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text =
                                                                         LanguageContainer.ProgramMessagebox8Text[GlobalDataInterface.selectLanguageIndex]; }));
                }
                Thread.Sleep(2000);
                // m_splashForm.Invoke(new MethodInvoker(delegate { m_splashForm.InitialStatuslabel.Text = "完成"; }));
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Program中函数InitialSysterm出错" + ex + "\n代码定位:" + ex.StackTrace);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("Program中函数InitialSysterm出错:" + ex + "\n代码定位:" + ex.StackTrace);
#endif
            }
        }
Exemplo n.º 7
0
        private void ExitSwitchForm_Load(object sender, EventArgs e)
        {
            try
            {
                //GlobalDataInterface.globalOut_GradeInfo.nSwitchLabel[m_nCurrentExitIndex] = 0; //add by xcw 20200528
                //(GlobalDataInterface.globalOut_GradeInfo.nSwitchLabel[m_nCurrentExitIndex]=
                m_bSwitchNumber = (GlobalDataInterface.globalOut_GradeInfo.nSwitchLabel[m_nCurrentExitIndex] == 0);
                m_bSwitchWeight = (GlobalDataInterface.globalOut_GradeInfo.nSwitchLabel[m_nCurrentExitIndex] == 1);
                m_bSwitchVolume = (GlobalDataInterface.globalOut_GradeInfo.nSwitchLabel[m_nCurrentExitIndex] == 2);
                if (m_bSwitchNumber)
                {
                    //GlobalDataInterface.globalOut_GradeInfo.nExitSwitchNum[m_nCurrentExitIndex] = GlobalDataInterface.globalOut_GradeInfo.nCheckNum;
                    //this.NumnumericUpDown.Text = GlobalDataInterface.globalOut_GradeInfo.nCheckNum.ToString();
                    this.NumnumericUpDown.Text    = GlobalDataInterface.globalOut_GradeInfo.nExitSwitchNum[m_nCurrentExitIndex].ToString();
                    this.WeightnumericUpDown.Text = "0";
                    this.VolumenumericUpDown.Text = "0";
                }
                else if (m_bSwitchWeight)
                {
                    this.NumnumericUpDown.Text    = "0";
                    this.WeightnumericUpDown.Text = GlobalDataInterface.globalOut_GradeInfo.nExitSwitchNum[m_nCurrentExitIndex].ToString();
                    this.VolumenumericUpDown.Text = "0";
                }
                else if (m_bSwitchVolume)
                {
                    this.NumnumericUpDown.Text    = "0";
                    this.WeightnumericUpDown.Text = "0";
                    this.VolumenumericUpDown.Text = GlobalDataInterface.globalOut_GradeInfo.nExitSwitchNum[m_nCurrentExitIndex].ToString();
                }
                this.NumnumericUpDown.Enabled    = m_bSwitchNumber;
                this.WeightnumericUpDown.Enabled = m_bSwitchWeight;
                this.VolumenumericUpDown.Enabled = m_bSwitchVolume;

                this.NumcheckBox.Checked    = m_bSwitchNumber;
                this.WeightcheckBox.Checked = m_bSwitchWeight;
                this.VolumecheckBox.Checked = m_bSwitchVolume;

                if (GlobalDataInterface.globalOut_GradeInfo.nLabelType != 2)
                {
                    this.LabelcheckBox1.Enabled = false;
                    this.LabelcheckBox2.Enabled = false;
                    this.LabelcheckBox3.Enabled = false;
                    this.LabelcheckBox4.Enabled = false;
                }
                else
                {
                    this.LabelcheckBox1.Enabled = true;
                    this.LabelcheckBox2.Enabled = true;
                    this.LabelcheckBox3.Enabled = true;
                    this.LabelcheckBox4.Enabled = true;
                    if (GlobalDataInterface.globalOut_GradeInfo.nLabelbyExit[m_nCurrentExitIndex] > 0)
                    {
                        m_nLabel = GlobalDataInterface.globalOut_GradeInfo.nLabelbyExit[m_nCurrentExitIndex];  //Add by ChengSk - 2017/11/01
                        //switch (GlobalDataInterface.globalOut_GradeInfo.nLabelbyExit[m_nCurrentExitIndex])   //Note by ChengSk - 2017/11/01
                        switch (m_nLabel)
                        {
                        case 1:
                            this.LabelcheckBox1.Checked = true;
                            break;

                        case 2:
                            this.LabelcheckBox2.Checked = true;
                            break;

                        case 3:
                            this.LabelcheckBox3.Checked = true;
                            break;

                        case 4:
                            this.LabelcheckBox4.Checked = true;
                            break;

                        default: break;
                        }
                    }
                }

                string str = Commonfunction.GetAppSetting("贴标机1");
                if (str != "")
                {
                    this.LabelcheckBox1.Text = str;
                }
                str = Commonfunction.GetAppSetting("贴标机2");
                if (str != "")
                {
                    this.LabelcheckBox2.Text = str;
                }
                str = Commonfunction.GetAppSetting("贴标机3");
                if (str != "")
                {
                    this.LabelcheckBox3.Text = str;
                }
                str = Commonfunction.GetAppSetting("贴标机4");
                if (str != "")
                {
                    this.LabelcheckBox4.Text = str;
                }

                int sizeNum, qualNum;
                //if ((((GlobalDataInterface.globalOut_GradeInfo.nClassifyType & 0x06) > 0) || ((GlobalDataInterface.globalOut_GradeInfo.nClassifyType & 0X38) > 0)) && ((GlobalDataInterface.globalOut_GradeInfo.nClassifyType & 1) > 0))//既有品质也有尺寸
                if ((GlobalDataInterface.globalOut_GradeInfo.nQualityGradeNum > 0) && (GlobalDataInterface.globalOut_GradeInfo.nClassifyType > 0))//既有品质也有尺寸
                {
                    sizeNum = GlobalDataInterface.globalOut_GradeInfo.nSizeGradeNum;
                    qualNum = GlobalDataInterface.globalOut_GradeInfo.nQualityGradeNum;
                }
                //else if (GlobalDataInterface.globalOut_GradeInfo.nClassifyType == 1)
                else if (GlobalDataInterface.globalOut_GradeInfo.nQualityGradeNum > 0 && GlobalDataInterface.globalOut_GradeInfo.nClassifyType == 0)
                {
                    sizeNum = 1;
                    qualNum = GlobalDataInterface.globalOut_GradeInfo.nQualityGradeNum;
                }
                else
                {
                    sizeNum = GlobalDataInterface.globalOut_GradeInfo.nSizeGradeNum;
                    qualNum = 1;
                }

                string strGradeNames = "";
                byte[] temp          = new byte[ConstPreDefine.MAX_TEXT_LENGTH];
                for (int i = 0; i < sizeNum; i++)
                {
                    for (int j = 0; j < qualNum; j++)
                    {
                        m_bIsExitGrade[i, j] = ((GlobalDataInterface.globalOut_GradeInfo.grades[j * ConstPreDefine.MAX_SIZE_GRADE_NUM + i].exit >> m_nCurrentExitIndex) & 1) == 1;
                        if (m_bIsExitGrade[i, j]) //被选中
                        {
                            Array.Copy(GlobalDataInterface.globalOut_GradeInfo.strSizeGradeName, i * ConstPreDefine.MAX_TEXT_LENGTH, temp, 0, ConstPreDefine.MAX_TEXT_LENGTH);
                            strGradeNames += Encoding.Default.GetString(temp).TrimEnd('\0');
                            Array.Copy(GlobalDataInterface.globalOut_GradeInfo.strQualityGradeName, j * ConstPreDefine.MAX_TEXT_LENGTH, temp, 0, ConstPreDefine.MAX_TEXT_LENGTH);
                            strGradeNames += Encoding.Default.GetString(temp).TrimEnd('\0');
                            strGradeNames += ",";
                        }
                    }
                }
                if (strGradeNames.Length > 0)
                {
                    strGradeNames = strGradeNames.Substring(0, strGradeNames.Length - 1);
                }
                this.ProductNametextBox.Text = strGradeNames;
                InitialExitGradeGrid();
                for (int i = 0; i < sizeNum; i++)
                {
                    for (int j = 0; j < qualNum; j++)
                    {
                        //MessageBox.Show(GlobalDataInterface.globalOut_GradeInfo.grades[j * ConstPreDefine.MAX_SIZE_GRADE_NUM + i].exit.ToString());
                        if (GlobalDataInterface.globalOut_GradeInfo.grades[j * ConstPreDefine.MAX_SIZE_GRADE_NUM + i].exit > 0)
                        {
                            this.ExitSwitchdataGridView[i, j].Style.BackColor = Color.White;
                        }
                        else
                        {
                            //this.ExitSwitchdataGridView[i, j].Style.BackColor = Color.Yellow;
                            this.ExitSwitchdataGridView[i, j].Value = this.OrangeimageList.Images[1];//Modify by xcw - 20191118
                        }
                    }
                }
                tempMotorInfo.ToCopy(GlobalDataInterface.globalOut_MotorInfo[m_nCurrentExitIndex]);
                //this.MotorEnableSwitchcomboBox.SelectedIndex = tempMotorInfo.bMotorSwitch;
                this.DelayTimenumericUpDown.Text             = GlobalDataInterface.globalOut_GlobalExitInfo[0].Delay_time[m_nCurrentExitIndex].ToString();
                this.HoldTimenumericUpDown.Text              = GlobalDataInterface.globalOut_GlobalExitInfo[0].Hold_time[m_nCurrentExitIndex].ToString(); //add by xcw - 20191209
                this.MotorEnableSwitchcomboBox.SelectedIndex = tempMotorInfo.bMotorSwitch - 2;                                                            //Modify by ChengSk - 20190708
                switch (tempMotorInfo.bMotorSwitch)
                {
                case 0:    //0表示个数使能,1表示重量使能
                    this.MotorEnableSwitchNumlabel.Enabled            = true;
                    this.MotorEnableSwitchNumnumericUpDown.Enabled    = true;
                    this.MotorEnableSwitchWeightlabel.Enabled         = false;
                    this.MotorEnableSwitchWeightnumericUpDown.Enabled = false;
                    break;

                case 1:
                    this.MotorEnableSwitchNumlabel.Enabled            = false;
                    this.MotorEnableSwitchNumnumericUpDown.Enabled    = false;
                    this.MotorEnableSwitchWeightlabel.Enabled         = true;
                    this.MotorEnableSwitchWeightnumericUpDown.Enabled = true;
                    break;

                case 2:
                    this.MotorEnableSwitchNumlabel.Enabled            = false;
                    this.MotorEnableSwitchNumnumericUpDown.Enabled    = false;
                    this.MotorEnableSwitchWeightlabel.Enabled         = false;
                    this.MotorEnableSwitchWeightnumericUpDown.Enabled = false;
                    break;

                default: break;
                }
                this.MotorEnableSwitchNumnumericUpDown.Text    = tempMotorInfo.nMotorEnableSwitchNum.ToString();
                this.MotorEnableSwitchWeightnumericUpDown.Text = tempMotorInfo.nMotorEnableSwitchWeight.ToString();
                //this.DelayTimenumericUpDown.Text = tempMotorInfo.fDelay_time.ToString();
                //this.HoldTimenumericUpDown.Text = tempMotorInfo.fHold_time.ToString();


                string strDisplayNameConfig = "出口" + (m_nCurrentExitIndex + 1).ToString() + "显示名称";
                this.DisplayNametextBox.Text = Commonfunction.GetAppSetting(strDisplayNameConfig);
                string strAdditionalTextConfig = "出口" + (m_nCurrentExitIndex + 1).ToString() + "附加信息";
                this.AdditionalTextrichTextBox.Text = Commonfunction.GetAppSetting(strAdditionalTextConfig);

                string strexitDisplayTypeConfig = "出口显示名称类型";
                long   exitDisplayType          = long.Parse(Commonfunction.GetAppSetting(strexitDisplayTypeConfig));
                if (((exitDisplayType >> m_nCurrentExitIndex) & 1) == 0)
                {
                    this.ReplaceSelectcheckBox.Checked = true;
                }
                else
                {
                    this.ReplaceSelectcheckBox.Checked = false;
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ExitSwitchForm中函数ExitSwitchForm_Load出错" + ex);
#if REALEASE
                GlobalDataInterface.WriteErrorInfo("ExitSwitchForm中函数ExitSwitchForm_Load出错" + ex);
#endif
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 保存配置控件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveConfigbutton_Click(object sender, EventArgs e)
        {
            if (this.EditConfigtextBox.Text == "")
            {
                //MessageBox.Show("配置文件名称不能为空!");
                //MessageBox.Show("0x30001020 The configuration file's name cannot be empty!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show("0x30001020 " + LanguageContainer.SaveConfigFormMessagebox1Text[GlobalDataInterface.selectLanguageIndex],
                                LanguageContainer.SaveConfigFormMessageboxInformationCaption[GlobalDataInterface.selectLanguageIndex],
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.EditConfigtextBox.Focus();
                return;
            }
            if (!Directory.Exists(System.Environment.CurrentDirectory + "\\config\\" + GlobalDataInterface.VERSION_SHOW + "\\"))
            {
                Directory.CreateDirectory(System.Environment.CurrentDirectory + "\\config\\" + GlobalDataInterface.VERSION_SHOW + "\\");
            }
            string FileName = System.Environment.CurrentDirectory;

            FileName += "\\config\\" + GlobalDataInterface.VERSION_SHOW + "\\";
            //if (this.EditConfigtextBox.Text=="")
            //{
            FileName += this.EditConfigtextBox.Text;
            if (m_IsProjectConfig)
            {
                FileName += ".exp";
            }
            else
            {
                FileName += ".cmc";
            }
            //}
            //else
            //{
            //    FileName += (string)this.ConfiglistBox.Items[this.ConfiglistBox.SelectedIndex];
            //}

            FileInfo configFile = new FileInfo(FileName);

            byte[]     FileData;
            FileStream configStream;

            try
            {
                if (configFile.Exists)
                {
                    //DialogResult result = MessageBox.Show("是否覆盖原来的配置信息?", "保存配置", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    //DialogResult result = MessageBox.Show("0x30001021 Whether to overwrite the original configuration information?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    DialogResult result = MessageBox.Show("0x30001021 " + LanguageContainer.SaveConfigFormMessagebox2Text[GlobalDataInterface.selectLanguageIndex],
                                                          LanguageContainer.SaveConfigFormMessageboxInformationCaption[GlobalDataInterface.selectLanguageIndex],
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                }

                configStream = new FileStream(FileName, FileMode.Create, FileAccess.Write);
                if (m_IsProjectConfig)
                {
                    //寻找最长结构体长度
                    int MaxLenth = Marshal.SizeOf(typeof(stSysConfig));
                    if (MaxLenth < Marshal.SizeOf(typeof(stExitInfo)))
                    {
                        MaxLenth = Marshal.SizeOf(typeof(stExitInfo));
                    }
                    if (MaxLenth < Marshal.SizeOf(typeof(stWeightBaseInfo)))
                    {
                        MaxLenth = Marshal.SizeOf(typeof(stWeightBaseInfo));
                    }
                    if (MaxLenth < Marshal.SizeOf(typeof(stParas)))
                    {
                        MaxLenth = Marshal.SizeOf(typeof(stParas));
                    }
                    if (MaxLenth < Marshal.SizeOf(typeof(stGlobalExitInfo)))
                    {
                        MaxLenth = Marshal.SizeOf(typeof(stGlobalExitInfo));
                    }
                    if (MaxLenth < Marshal.SizeOf(typeof(stGlobalWeightBaseInfo)))
                    {
                        MaxLenth = Marshal.SizeOf(typeof(stGlobalWeightBaseInfo));
                    }
                    //if (MaxLenth < Marshal.SizeOf(typeof(stSpotDetectThresh)))
                    //    MaxLenth = Marshal.SizeOf(typeof(stSpotDetectThresh));

                    FileData = new byte[MaxLenth];
                    configStream.Seek(0, SeekOrigin.Begin);

                    byte[] version = BitConverter.GetBytes(GlobalDataInterface.Version);
                    configStream.Write(version, 0, sizeof(Int32));//2016-12-6加版本号校验

                    FileData = Commonfunction.StructToBytes(GlobalDataInterface.globalOut_SysConfig);
                    configStream.Write(FileData, 0, Marshal.SizeOf(typeof(stSysConfig)));

                    for (int i = 0; i < ConstPreDefine.MAX_SUBSYS_NUM * ConstPreDefine.MAX_CHANNEL_NUM; i++)
                    {
                        FileData = Commonfunction.StructToBytes(GlobalDataInterface.globalOut_ExitInfo[i]);
                        configStream.Write(FileData, 0, Marshal.SizeOf(typeof(stExitInfo)));
                    }
                    for (int i = 0; i < ConstPreDefine.MAX_SUBSYS_NUM * ConstPreDefine.MAX_CHANNEL_NUM; i++)
                    {
                        FileData = Commonfunction.StructToBytes(GlobalDataInterface.globalOut_WeightBaseInfo[i]);
                        configStream.Write(FileData, 0, Marshal.SizeOf(typeof(stWeightBaseInfo)));
                    }
                    for (int i = 0; i < ConstPreDefine.MAX_SUBSYS_NUM * ConstPreDefine.MAX_IPM_NUM; i++)
                    {
                        FileData = Commonfunction.StructToBytes(GlobalDataInterface.globalOut_Paras[i]);
                        configStream.Write(FileData, 0, Marshal.SizeOf(typeof(stParas)));
                    }
                    for (int i = 0; i < ConstPreDefine.MAX_SUBSYS_NUM; i++)
                    {
                        FileData = Commonfunction.StructToBytes(GlobalDataInterface.globalOut_GlobalExitInfo[i]);
                        configStream.Write(FileData, 0, Marshal.SizeOf(typeof(stGlobalExitInfo)));
                    }
                    for (int i = 0; i < ConstPreDefine.MAX_SUBSYS_NUM; i++)
                    {
                        FileData = Commonfunction.StructToBytes(GlobalDataInterface.globalOut_GlobalWeightBaseInfo[i]);
                        configStream.Write(FileData, 0, Marshal.SizeOf(typeof(stGlobalWeightBaseInfo)));
                    }
                    //for (int i = 0; i < ConstPreDefine.MAX_SUBSYS_NUM * ConstPreDefine.MAX_IPM_NUM; i++)
                    //{
                    //    FileData = Commonfunction.StructToBytes(GlobalDataInterface.globalOut_SpotDetectThresh[i]);
                    //    configStream.Write(FileData, 0, Marshal.SizeOf(typeof(stSpotDetectThresh)));
                    //}

                    configStream.Write(FileData, 0, sizeof(bool));
                    FileData = BitConverter.GetBytes(GlobalDataInterface.CIRAvailable);
                    configStream.Write(FileData, 0, sizeof(bool));
                    FileData = BitConverter.GetBytes(GlobalDataInterface.WeightAvailable);
                    configStream.Write(FileData, 0, sizeof(bool));
                    GlobalDataInterface.NetStateSum = BitConverter.ToBoolean(FileData, 0);
                    for (int i = 0; i < ConstPreDefine.MAX_SUBSYS_NUM; i++)
                    {
                        FileData = BitConverter.GetBytes(GlobalDataInterface.NetState[i]);
                        configStream.Write(FileData, 0, sizeof(int));
                    }
                    FileData = BitConverter.GetBytes(GlobalDataInterface.CupStateSum);
                    configStream.Write(FileData, 0, sizeof(bool));
                    for (int i = 0; i < ConstPreDefine.MAX_SUBSYS_NUM; i++)
                    {
                        FileData = BitConverter.GetBytes(GlobalDataInterface.CupState[i]);
                        configStream.Write(FileData, 0, sizeof(int));
                    }
                    configStream.Close();
                }
                else//保存用户配置
                {
                    FileData = new byte[Marshal.SizeOf(typeof(stGradeInfo))];
                    configStream.Seek(0, SeekOrigin.Begin);

                    byte[] version = BitConverter.GetBytes(GlobalDataInterface.Version);
                    configStream.Write(version, 0, sizeof(Int32));//2016-12-6加版本号校验

                    FileData = Commonfunction.StructToBytes(GlobalDataInterface.globalOut_GradeInfo);
                    configStream.Write(FileData, 0, Marshal.SizeOf(typeof(stGradeInfo)));

                    /*用户配置增加颜色界面-》颜色列表背景颜色保存*/
                    string      color;
                    byte[]      tempcolor = new byte[ConstPreDefine.MAX_TEXT_LENGTH];
                    stColorList colorlist = new stColorList(true);
                    color     = Commonfunction.GetAppSetting("颜色参数-颜色1");
                    tempcolor = Encoding.Default.GetBytes(color);
                    Array.Copy(tempcolor, colorlist.color1, tempcolor.Length);
                    color     = Commonfunction.GetAppSetting("颜色参数-颜色2");
                    tempcolor = Encoding.Default.GetBytes(color);
                    Array.Copy(tempcolor, colorlist.color2, tempcolor.Length);
                    color     = Commonfunction.GetAppSetting("颜色参数-颜色3");
                    tempcolor = Encoding.Default.GetBytes(color);
                    Array.Copy(tempcolor, colorlist.color3, tempcolor.Length);
                    FileData = Commonfunction.StructToBytes(colorlist);
                    configStream.Write(FileData, 0, Marshal.SizeOf(typeof(stColorList)));

                    //Add by ChengSk - 20190929
                    string clientinfo;
                    byte[] tempclientinfo    = new byte[ConstPreDefine.MAX_CLIENTINFO_LENGTH];
                    string ClientName        = "";                                                     //客户名称 Add by ChengSk - 20191115
                    string FarmName          = "";                                                     //农场名称 Add by ChengSk - 20191115
                    string FruitName         = "";                                                     //水果名称 Add by ChengSk - 20191115
                    string clientInfoContent = FileOperate.ReadFile(1, m_mainform.clientInfoFileName); //Modify by ChengSk - 20180308
                    if (clientInfoContent == null || clientInfoContent == "")
                    {
                        ClientName = "";
                        FarmName   = "";
                        FruitName  = "";
                    }
                    else
                    {
                        string[] clientInfoContentItem = clientInfoContent.Split(',');
                        ClientName = clientInfoContentItem[0].Trim();
                        FarmName   = clientInfoContentItem[1].Trim();
                        FruitName  = clientInfoContentItem[2].Trim();
                    }
                    stClientInfo ClientInfo = new stClientInfo(true);
                    clientinfo     = ClientName; //客户名称
                    tempclientinfo = Encoding.Default.GetBytes(clientinfo);
                    Array.Copy(tempclientinfo, ClientInfo.customerName, tempclientinfo.Length);
                    clientinfo     = FarmName; //农场名称
                    tempclientinfo = Encoding.Default.GetBytes(clientinfo);
                    Array.Copy(tempclientinfo, ClientInfo.farmName, tempclientinfo.Length);
                    clientinfo     = FruitName; //水果名称
                    tempclientinfo = Encoding.Default.GetBytes(clientinfo);
                    Array.Copy(tempclientinfo, ClientInfo.fruitName, tempclientinfo.Length);
                    FileData = Commonfunction.StructToBytes(ClientInfo);
                    configStream.Write(FileData, 0, Marshal.SizeOf(typeof(stClientInfo)));

                    configStream.Close();
                    m_mainform.SetSeparationProgrameChangelabel(true, this.EditConfigtextBox.Text);//ivycc 2013.11.26
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("保存配置文件失败:" + ex);
                //MessageBox.Show("0x1000100C Save configuration failed:" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox.Show("0x1000100C " + LanguageContainer.SaveConfigFormMessagebox3Text[GlobalDataInterface.selectLanguageIndex] + ex,
                                LanguageContainer.SaveConfigFormMessageboxErrorCaption[GlobalDataInterface.selectLanguageIndex],
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }