Пример #1
0
        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();
            }
        }
Пример #2
0
        //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();
            }
        }
Пример #3
0
        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();
            }
        }