Esempio n. 1
0
        /**
         * 设置按钮-点击
         */
        void SettingButtonClick(object sender, EventArgs e)
        {
            SettingForm fSetting = new SettingForm();

            fSetting.ShowDialog(this);

            for (var idx = 0; idx < Common.comdata.Count; idx++)
            {
                GetComClick(idx, Common.comdata[idx].com_port);
            }
        }
Esempio n. 2
0
        private void ReadInitializeFile()
        {
            string filePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ProcedureStepCounter.ini");

            if (System.IO.File.Exists(filePath))
            {
                Common.rvs_server_ip   = IniAccessory.Read("net", "rvs_server_ip", "", filePath);
                Common.rvs_server_name = IniAccessory.Read("net", "rvs_server_name", "", filePath);
                Common.local_ip        = IniAccessory.Read("net", "local_ip", "", filePath);
                Common.process_code    = IniAccessory.Read("position", "process_code", "", filePath);
                Common.line_part       = IniAccessory.Read("position", "line_part", "", filePath);
                if (Common.rvs_server_ip.Equals("") ||
                    Common.local_ip.Equals("") ||
                    Common.process_code.Equals("")
                    )
                {
                    SettingForm fSetting = new SettingForm();
                    fSetting.ShowDialog(null);

                    MessageBox.Show("请完成基本配置设定后,再使用本工具。", "Error");
                    Environment.Exit(0);
                }
            }
            else
            {
                MessageBox.Show("请完成配置文件 ProcedureStepCounter.ini 中的设定后,再使用本工具。", "Error");

                IniAccessory.Write("net", "rvs_server_ip", "10.220.130.100", filePath);
                IniAccessory.Write("net", "rvs_server_name", "rvs", filePath);
                IniAccessory.Write("net", "local_ip", "10.220.126.181", filePath);

                IniAccessory.Write("position", "process_code", "431", filePath);
                IniAccessory.Write("position", "line_part", "A", filePath);

                SettingForm fSetting = new SettingForm();
                fSetting.ShowDialog(null);

                Environment.Exit(0);
            }
        }
Esempio n. 3
0
        private void checkResContent(string resContent)
        {
            if (resContent == null || resContent.Equals(""))
            {
                resContent = "无法通信";
            }

            bool isIniSet = true;

            if (!resContent.StartsWith("{"))
            {
                MessageBox.Show(string.Format("在连接服务器[{0}]时发生错误:{1}。\r\n" +
                                              "请确认RVS是否能正常使用;本机的网络连接是否正常;\r\n" +
                                              "修改服务器IP设定后,再使用本工具。",
                                              Common.rvs_server_ip, resContent), "Error");
                SettingForm fSetting = new SettingForm();
                fSetting.ShowDialog(null);
                Environment.Exit(0);
            }
            else
            {
                // MessageBox.Show("json:" + resContent, "JSON");
                JavaScriptSerializer jss = new JavaScriptSerializer();

                ResFromServer recv = jss.Deserialize <ResFromServer>(resContent);
                if (recv == null)
                {
                    MessageBox.Show(string.Format("从服务器[{0}]时取得的配置错误:无法取得配置。\r\n" +
                                                  "请RVS系统管理者确认配置后,再使用本工具。",
                                                  Common.rvs_server_ip), "Error");
                    Environment.Exit(0);
                }
                else if (recv.error != null)
                {
                    MessageBox.Show(string.Format("从服务器[{0}]时取得的配置错误:{1}。\r\n" +
                                                  "请RVS系统管理者确认配置,或者确认本机配置后,再使用本工具。",
                                                  Common.rvs_server_ip, recv.error), "Error");
                    SettingForm fSetting = new SettingForm();
                    fSetting.ShowDialog(null);
                    Environment.Exit(0);
                }
                else
                {
                    string filePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "ProcedureStepCounter.ini");

                    foreach (var o in recv.avaCounterList)
                    {
                        Dictionary <string, object> avaCounter = o as Dictionary <string, object>;
                        string avaCounterId = avaCounter["procedure_step_count_id"] as string;

                        ComData transData = new ComData();
                        transData.item_id   = avaCounterId;
                        transData.item_name = avaCounter["name"] as string;

                        transData.set_times = "-";
                        transData.count     = 0;

                        transData.pbs = 9600;
                        string iniComPort =
                            IniAccessory.Read("item." + avaCounterId, "com_port", "", filePath);
                        if ("".Equals(iniComPort))
                        {
                            isIniSet = false;
                        }
                        else
                        {
                            transData.com_port = iniComPort;
                        }

                        string iniPbs =
                            IniAccessory.Read("item." + avaCounterId, "pbs", "9600", filePath);
                        transData.pbs = int.Parse(iniPbs);

                        string iniAddressCode =
                            IniAccessory.Read("item." + avaCounterId, "address_code", "01", filePath);
                        transData.address_code = iniAddressCode;

                        transData.connect_status = "断开";

                        // 记录COM的bps
                        if (isIniSet && !ComConnector.baudRateOfCom.ContainsKey(transData.com_port))
                        {
                            ComConnector.baudRateOfCom[transData.com_port] = transData.pbs;
                        }

                        Common.comdata.Add(transData);
                    }
                }
            }

            ComDataGrid.DataSource = Common.comdata;
            SetComGrid.InitDataGridColumnHeader(ComDataGrid);
            if (isIniSet)
            {
                for (var idx = 0; idx < Common.comdata.Count; idx++)
                {
                    GetComClick(idx, Common.comdata[idx].com_port);
                }
            }
            else
            {
                SettingForm fSetting = new SettingForm();
                fSetting.ShowDialog(this);
            }
        }