示例#1
0
        static bool checkedStatus = false; // Radio修改从CheckChange开始

        public SettingForm()
        {
            InitializeComponent();

            changeBas                     = 0;
            ComSetGrid.DataSource         = GetFromComdata();
            this.txt_rvs_server_ip.Text   = Common.rvs_server_ip;
            this.txt_rvs_server_name.Text = Common.rvs_server_name;

            this.txt_local_ip.Text     = Common.local_ip;
            this.txt_process_code.Text = Common.process_code;

            checkedStatus = false;
            switch (Common.line_part)
            {
            case "A": this.rad_px_a.Checked = true; checkedStatus = true; break;

            case "B": this.rad_px_b.Checked = true; checkedStatus = true; break;
            }

            SetComGrid.InitSetDataGridColumnHeader(ComSetGrid);
            changeBas = -1;
        }
示例#2
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);
            }
        }