Beispiel #1
0
        private void FormSetting_Load(object sender, EventArgs e)
        {
            string[] portName;
            int      i;

            //serialComm1.DateReceived += new Comm.EventHandle(OnDataReceived);
            //post请求地址
            IniHelper.GetAllKeyValues("Http_Setting", out string[] keys, out string[] values, iniHelper.FileName);
            if (values.Length > 0)
            {
                tbURL.Text = values[0];
            }
            //串口初始化设置
            cBCom.Items.Clear();
            cBWeightComm.Items.Clear();
            IniHelper.GetAllKeyValues("SerialPort_Setting", out string[] keys2, out string[] values2, iniHelper.FileName);
            IniHelper.GetAllKeyValues("WeightPort_Setting", out string[] keys3, out string[] values3, iniHelper.FileName);
            portName = System.IO.Ports.SerialPort.GetPortNames();
            if (portName.Length > 0)
            {
                for (i = 0; i < portName.Length; i++)
                {
                    cBCom.Items.Add(portName[i]);
                    cBWeightComm.Items.Add(portName[i]);
                    if (values2.Length > 1)
                    {
                        if (values2[0] == portName[i])
                        {
                            cBCom.Text  = values2[0];
                            cBBaud.Text = values2[1];
                            serialComm1.Close();
                            serialComm1._serialPort.PortName = values2[0];
                            serialComm1._serialPort.BaudRate = Convert.ToInt32(values2[1]);
                            serialComm1.Open();
                        }
                    }
                    if (values3.Length > 1)
                    {
                        if (values3[0] == portName[i])
                        {
                            cBWeightComm.Text  = values3[0];
                            cBWeightBaund.Text = values3[1];
                            cbWorkSole.Text    = values3[2];
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void LoadSetting()
        {
            //串口设置
            IniHelper.GetAllKeyValues("SerialPort_Setting", out string[] keys2, out string[] values2, iniHelper.FileName);
            IniHelper.GetAllKeyValues("WeightPort_Setting", out string[] keys3, out string[] values3, iniHelper.FileName);
            IniHelper.GetAllKeyValues("Other_Setting", out string[] keys4, out string[] values4, iniHelper.FileName);
            //post请求地址
            IniHelper.GetAllKeyValues("Http_Setting", out string[] keys, out string[] values, iniHelper.FileName);

            try
            {
                for (int i = 0; i < keys.Length; i++)
                {
                    if (keys.Length == 1)
                    {
                        url = values[0];
                    }
                }
                if (values2.Length > 1)
                {
                    serialComm.Close();
                    serialComm._serialPort.PortName = values2[0];
                    serialComm._serialPort.BaudRate = Convert.ToInt32(values2[1]);
                    serialComm.Open();
                }
                if (values3.Length > 1)
                {
                    weightComm.Close();
                    weightComm._serialPort.PortName = values3[0];
                    weightComm._serialPort.BaudRate = Convert.ToInt32(values3[1]);
                    if (values3.Length > 2)
                    {
                        workConsole = values3[2];
                    }
                    weightComm.Open();
                }
                if (values4.Length > 0)
                {
                    if (Convert.ToBoolean(values4[0]))
                    {
                        IsSavaCode = true;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }