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); } }
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); } }
//open Visa Device setup form private void visaDeviceToolStripMenuItem_Click(object sender, EventArgs e) { Address oldaddr = (Address)this.addr.Clone(); VisaDeviceSetupForm sf = new VisaDeviceSetupForm(this.addr); if (sf.ShowDialog() == DialogResult.OK) { this.addr.SA = sf.localaddr.SA; this.addr.SG = sf.localaddr.SG; this.addr.SG2 = sf.localaddr.SG2; this.addr.RFBOX = sf.localaddr.RFBOX; this.addr.RFBOX2 = sf.localaddr.RFBOX2; this.addr.IS1 = sf.localaddr.IS1; this.addr.IS2 = sf.localaddr.IS2; this.addr.DC5767A = sf.localaddr.DC5767A; this.addr.capture1 = sf.localaddr.capture1; this.addr.capture2 = sf.localaddr.capture2; if (this.VisaSwitch) //true == visa32 { this.initInstrumentStatusbyVisa32(this.addr, oldaddr); } else { this.initInstrumentStatus(this.addr, oldaddr); } //SA if (this.addr.capture1 == Constant.VISADEVICE_LIST[0]) viCapture1 = viSA; //SG1 else if (this.addr.capture1 == Constant.VISADEVICE_LIST[1]) viCapture1 = viSG; //SG2 else if (this.addr.capture1 == Constant.VISADEVICE_LIST[2]) viCapture1 = viSG2; //RFBOX1 else if (this.addr.capture1 == Constant.VISADEVICE_LIST[3]) viCapture1 = viRFBOX; //RFBOX2 else if (this.addr.capture1 == Constant.VISADEVICE_LIST[4]) viCapture1 = viRFBOX2; //DC5767A else if (this.addr.capture1 == Constant.VISADEVICE_LIST[5]) viCapture1 = viDC5767A; //ISG1 else if (this.addr.capture1 == Constant.VISADEVICE_LIST[6]) viCapture1 = viIS; //ISG2 else if (this.addr.capture1 == Constant.VISADEVICE_LIST[7]) viCapture1 = viIS2; //SA if (this.addr.capture2 == Constant.VISADEVICE_LIST[0]) viCapture2 = viSA; //SG1 else if (this.addr.capture2 == Constant.VISADEVICE_LIST[1]) viCapture2 = viSG; //SG2 else if (this.addr.capture2 == Constant.VISADEVICE_LIST[2]) viCapture2 = viSG2; //RFBOX1 else if (this.addr.capture2 == Constant.VISADEVICE_LIST[3]) viCapture2 = viRFBOX; //RFBOX2 else if (this.addr.capture2 == Constant.VISADEVICE_LIST[4]) viCapture2 = viRFBOX2; //DC5767A else if (this.addr.capture2 == Constant.VISADEVICE_LIST[5]) viCapture2 = viDC5767A; //ISG1 else if (this.addr.capture2 == Constant.VISADEVICE_LIST[6]) viCapture2 = viIS; //ISG2 else if (this.addr.capture2 == Constant.VISADEVICE_LIST[7]) viCapture2 = viIS2; //save address and port to config file ConfigHelper ch = new ConfigHelper(); Dictionary<string, string> adds = this.addr.UpdateAddress(); ch.UpdateAddr(adds); sf.Close(); } }
private void otherDeviceToolStripMenuItem_Click(object sender, EventArgs e) { Address oldaddr = (Address)this.addr.Clone(); OtherDeviceForm sf = new OtherDeviceForm(this.addr); if (sf.ShowDialog() == DialogResult.OK) { this.addr.Server_Port = sf.localaddr.Server_Port; if(sf.localaddr.DU_IP != String.Empty) { label_terminal_IP.Text = sf.localaddr.DU_IP; this.addr.DU_IP = sf.localaddr.DU_IP; } //save address and port to config file ConfigHelper ch = new ConfigHelper(); Dictionary<string, string> adds = this.addr.UpdateAddress(); ch.UpdateAddr(adds); sf.Close(); } }
private void menuSetup_Click(object sender, EventArgs e) { Address oldaddr = (Address)this.addr.Clone(); SerialPortSetupForm sf = new SerialPortSetupForm(this.addr); //SetupForm sf = new SetupForm(this.addr); if(sf.ShowDialog() == DialogResult.OK) { if(sf.localaddr.RRU != "") { this.addr.RRU = sf.localaddr.RRU; this.addr.Baudrate_rru = sf.localaddr.Baudrate_rru; } if(sf.localaddr.SERIAL2 != "") { this.addr.Baudrate_com2 = sf.localaddr.Baudrate_com2; this.addr.SERIAL2 = sf.localaddr.SERIAL2; } //this.addr.SA = sf.localaddr.SA; //this.addr.SG = sf.localaddr.SG; //this.addr.SG2 = sf.localaddr.SG2; //this.addr.RFBOX = sf.localaddr.RFBOX; //this.addr.RFBOX2 = sf.localaddr.RFBOX2; //this.addr.IS1 = sf.localaddr.IS1; //this.addr.IS2 = sf.localaddr.IS2; //this.addr.DC5767A = sf.localaddr.DC5767A; //this.addr.Server_Port = sf.localaddr.Server_Port; //ipep = new IPEndPoint(IPAddress.Any, int.Parse(this.addr.Server_Port)); 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; } } if (this.addr.RRU != ""&& oldaddr.RRU!= this.addr.RRU) { if (this._COM_RRU.IsOpen == true) { if (Close_serial_port()) { this._COM_RRU.PortName = this.addr.RRU; this._COM_RRU.BaudRate = int.Parse(this.addr.Baudrate_rru); try { this._COM_RRU.Open(); this._COM_RRU.DiscardOutBuffer(); this._COM_RRU.DiscardInBuffer(); } catch (Exception exp_rru) { WriteErrorText("Serial port rru init error! please check serial infomation first. " + exp_rru.Message); } } else WriteErrorText("Close serial port failed! Please stop serial port listening and re-setup serial port first!"); //if (Close_serial_port()) //{ // try // { // //设定port,波特率,无检验位,8个数据位,1个停止位 // this._COM_RRU = new SerialPort(this.addr.RRU, int.Parse(this.addr.Baudrate_rru), Parity.None, 8, StopBits.One); // this._COM_RRU.ReadBufferSize = 2048; // this._COM_RRU.ReceivedBytesThreshold = 1; // this._COM_RRU.NewLine = "\n"; // this._COM_RRU.RtsEnable = true; // this._COM_RRU.DtrEnable = true; // this._COM_RRU.Open(); // this._COM_RRU.DiscardOutBuffer(); // this._COM_RRU.DiscardInBuffer(); // this._COM_RRU.DataReceived += new SerialDataReceivedEventHandler(Com_rru_DataReceived); // this._COM_RRU.ErrorReceived += new SerialErrorReceivedEventHandler(Com_rru_ErrorReceived); // } // catch (Exception exp_rru) // { // WriteErrorText("Serial port rru init error! please check serial infomation first. " + exp_rru.Message); // } //} //else // WriteErrorText("Close serial port failed! Please stop serial port listening and re-setup serial port first!"); } } if (this.addr.SERIAL2 != "" && oldaddr.SERIAL2 != this.addr.SERIAL2) { if (this._COM2.IsOpen == true) { if (Close_serial_port()) { this._COM2.PortName = this.addr.SERIAL2; this._COM2.BaudRate = int.Parse(this.addr.Baudrate_com2); try { this._COM2.Open(); this._COM2.DiscardOutBuffer(); this._COM2.DiscardInBuffer(); } catch (Exception exp_rru) { WriteErrorText("Serial port 2 init error! please check serial infomation first. " + exp_rru.Message); } } else WriteErrorText("Close serial port 2 failed! Please stop serial port listening and re-setup serial port first!"); //try { // Close_serial2_port(); // //设定port,波特率,无检验位,8个数据位,1个停止位 // this._COM2 = new SerialPort(this.addr.SERIAL2, int.Parse(this.addr.Baudrate_com2), Parity.None, 8, StopBits.One); // this._COM2.ReadBufferSize = 4096; // this._COM2.ReceivedBytesThreshold = 1; // this._COM2.NewLine = "\r"; // this._COM2.RtsEnable = true; // this._COM2.DtrEnable = true; // this._COM2.Open(); // this._COM2.DataReceived += new SerialDataReceivedEventHandler(Com_2_DataReceived); // this._COM2.ErrorReceived += new SerialErrorReceivedEventHandler(Com2_ErrorReceived); //} //catch (Exception exp_com2) { // WriteErrorText("Serial port 2 init error! please check serial infomation first. "+ exp_com2.Message); //} } } //if(this.VisaSwitch) //true == visa32 //{ // this.initInstrumentStatusbyVisa32(this.addr, oldaddr); //} //else //{ // this.initInstrumentStatus(this.addr, oldaddr); //} //save address and port to config file ConfigHelper ch = new ConfigHelper(); Dictionary<string, string> adds = this.addr.UpdateAddress(); ch.UpdateAddr(adds); sf.Close(); } }
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; } }
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(); }