Esempio n. 1
0
        private void button_save_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            ConfigHelper ch = new ConfigHelper();
            string defaultfilename = ch.GetConfig(Constant.CONFIG_TS_LOAD_PATH);
            sfd.InitialDirectory = defaultfilename;
            sfd.RestoreDirectory = true;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                fName = sfd.FileName;

                //this.dataDisplayBox.AppendText(fName + "\n");
                //init List<Tabcontent> tabs

                //get current tabs in mainform
                List<Tabcontent> tabs = GetCurrentTabs();

                TsFileHelper tfh = new TsFileHelper();
                tfh.SaveTab(tabs, fName);

            }
        }
Esempio n. 2
0
        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            //terminate cmdprocessthread
            cmdProcessThread_run = false;
            cmdQueue.Enqueue("");
            _waitcmdQueueEventHandle.Set();
            _cmdProcessThread.Abort();

            //stop RU Master
            //if(_TCA_ON)
            //    RumaControlClientFactory.StopDefaultTool();

            //save log
            //if (this._log)
                //LogManager.WriteLog(LogFile.Log, this.dataDisplayBox.Text);

            //save button ts file as default ts file
            string localpath = Application.StartupPath;
            string filepath = localpath + @"\default.ts";
            //get current tabs in mainform
            List<Tabcontent> tabs = GetCurrentTabs();

            TsFileHelper tfh = new TsFileHelper();
            tfh.SaveTab(tabs, filepath);

            //close session
            this.closVisa32sesn();
            this.closeVisacomsesn();

            //close serial port
            if(this._COM_RRU!=null)
            {
                Close_serial_port();
                this._COM_RRU.Dispose();
                this._COM_RRU = null;
            }
            //close serial 2
            if (this._COM2 != null)
            {
                Close_serial2_port();
                this._COM2.Dispose();
                this._COM2 = null;
            }

            //save color
            if (this.backcolor!="")
            {
                ConfigHelper ch = new ConfigHelper();
                ch.UpdateConfig("disp_backcolor", this.backcolor);
            }
            if (this.forecolor != "")
            {
                ConfigHelper ch = new ConfigHelper();
                ch.UpdateConfig("disp_forecolor", this.forecolor);
            }
            //save font
            if (this.fontstyle != "")
            {
                ConfigHelper ch = new ConfigHelper();
                ch.UpdateConfig("disp_font", this.fontstyle);
            }

            //close socket
            if(this.toolStripButton2.Checked==true)
            {
                try
                {
                    this._createServer.Abort();
                    newsock.Close();
                }
                catch
                {
                    WriteTraceText("Stop socket server failed.");
                }
                //this.RequestStopthread();
                //this._createServer.Join();
                //this._createServer = null;
            }
        }
Esempio n. 3
0
        private void button_load_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ConfigHelper ch = new ConfigHelper();
            string defaultfilename = ch.GetConfig(Constant.CONFIG_TS_LOAD_PATH);
            ofd.InitialDirectory = defaultfilename;
            ofd.RestoreDirectory = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                fName = ofd.FileName;

                //this.dataDisplayBox.AppendText(fName + "\n");
                string fpath = fName.Replace(ofd.SafeFileName, "");
                //this.dataDisplayBox.AppendText(fpath + "\n");
                TsFileHelper tfh = new TsFileHelper();
                //get tabs from file
                List<Tabcontent> tabs = tfh.getTabs(fName);
                //delete all current pages
                this.tabControl1.TabPages.Clear();
                //init tabindex
                this._tabindex = 0;
                //add tabpage from tabs
                foreach(Tabcontent tab in tabs)
                {
                    this.AddTab(tab);
                }
                ch.UpdateConfig(Constant.CONFIG_TS_LOAD_PATH, fpath);

            }
        }
Esempio n. 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < Constant.DEVICE_LIST.Length; i++)
            {

                this.comboBox_instrumentprefix.Items.Add(Constant.DEVICE_LIST[i]);

            }

            string filepath = localpath +@"\default.ts";
            if(File.Exists(filepath))
            {

                TsFileHelper tfh = new TsFileHelper();
                //get tabs from file
                List<Tabcontent> tabs = tfh.getTabs(filepath);
                //delete all current pages
                this.tabControl1.TabPages.Clear();
                //init tabindex
                this._tabindex = 0;
                //add tabpage from tabs
                if(tabs.Count!=0)
                {
                    foreach (Tabcontent tab in tabs)
                    {
                        this.AddTab(tab);
                    }
                }
                else
                {
                    Tabcontent tc = new Tabcontent();
                    this.AddTab(tc);
                }

            }
            else
            {
                string filePath = System.IO.Path.Combine(localpath, "default.ts");
                File.Create(filePath);
                Tabcontent tc = new Tabcontent();
                this.AddTab(tc);
            }

            //load config

            Dictionary<string, string> tempaddr = new Dictionary<string, string>();
            ConfigHelper ch = new ConfigHelper();
            tempaddr = ch.GetAddr();
            this.addr.SetAddress(tempaddr,this.link);

            //load color

            this.backcolor = ch.GetConfig("disp_backcolor");
            if (this.backcolor != "")
            {
                this.dataDisplayBox.BackColor = ColorTranslator.FromHtml(this.backcolor);
            }

            this.forecolor = ch.GetConfig("disp_forecolor");
            if (this.forecolor != "")
            {
                this.dataDisplayBox.ForeColor = ColorTranslator.FromHtml(this.forecolor);
            }

            //load font
            FontConverter fc = new FontConverter();
            this.fontstyle = ch.GetConfig("disp_font");
            if (this.fontstyle != "")
            {
                this.dataDisplayBox.Font = (Font)fc.ConvertFromString(this.fontstyle);
            }

            //init instrument status
            //initInstrumentStatus(this.addr, this.addr,true);
            this.initInstrumentStatusbyVisa32(this.addr, this.addr, true);
            foreach (Control ctl in this.SerialpropertyBox.Controls)
            {
                if (ctl.Name == "label_rruport")
                {
                    ctl.Text = this.addr.RRU;
                }
                else if (ctl.Name == "label_rrubaud")
                {
                    ctl.Text = this.addr.Baudrate_rru;
                }
                else if (ctl.Name == "label_serial2port")
                {
                    ctl.Text = this.addr.SERIAL2;
                }
                else if (ctl.Name == "label_serial2baud")
                {
                    ctl.Text = this.addr.Baudrate_com2;
                }
            }

            //ipep
            ipep = new IPEndPoint(IPAddress.Any, int.Parse(this.addr.Server_Port));

            //log
            LogManager.LogFielPrefix = "RTT ";
            //string logPath = System.Environment.CurrentDirectory + @"\log\";

            if (!Directory.Exists(logPath))
                Directory.CreateDirectory(logPath);
            LogManager.LogPath = logPath;
            LogManager.WriteLog(LogFile.Trace, "RTT start, version is "+ Assembly.GetExecutingAssembly().GetName().Version.ToString());

            //update

            if (!Directory.Exists(updatePath))
                Directory.CreateDirectory(updatePath);

            if (!Directory.Exists(backuppath))
                Directory.CreateDirectory(backuppath);
            //snapshot
            //_snapPath = System.Environment.CurrentDirectory + @"\snapshot\";

            if (!Directory.Exists(_snapPath))
                Directory.CreateDirectory(_snapPath);

            //rxevm

            if (!Directory.Exists(_rxevmPath))
                Directory.CreateDirectory(_rxevmPath);

            //cmd queue process thread
            cmdProcessThread_run = true;
            _cmdProcessThread = new Thread(new ThreadStart(cmdProcessThread));
            _cmdProcessThread.Start();

            //cqEventSender.QueueChanged += new cmdQueueEventSender.QueueChangHandler(cmdProcessThread);

            this.Text = "RTT v" + Assembly.GetExecutingAssembly().GetName().Version.ToString();
            this.label_terminal_IP.Text = this.addr.DU_IP;
            this.Show();
            //this.InputBox.Focus();
        }