Beispiel #1
0
        private void OptionsInitial()
        {
            //Append Default Baudrates
            foreach (uint i in DefaultBaudRate)
            {
                BaudRateList.Add(i);
            }

            DataBitsList.Add("8", 8);
            DataBitsList.Add("7", 7);
            DataBitsList.Add("6", 6);
            DataBitsList.Add("5", 5);


            StopBitsList.Add("n", System.IO.Ports.StopBits.None, "無");
            StopBitsList.Add("1", System.IO.Ports.StopBits.One);
            StopBitsList.Add("1.5", System.IO.Ports.StopBits.OnePointFive);
            StopBitsList.Add("2", System.IO.Ports.StopBits.Two);

            ParityList.Add("n", System.IO.Ports.Parity.None, "無");
            ParityList.Add("o", System.IO.Ports.Parity.Odd, "奇數");
            ParityList.Add("e", System.IO.Ports.Parity.Even, "偶數");
            ParityList.Add("m", System.IO.Ports.Parity.Mark, "Mark (1)");
            ParityList.Add("s", System.IO.Ports.Parity.Space, "Space (0)");

            HandshakeList.Add("N", System.IO.Ports.Handshake.None, "無");
            HandshakeList.Add("R", System.IO.Ports.Handshake.RequestToSend, "硬體");
            HandshakeList.Add("X", System.IO.Ports.Handshake.XOnXOff, "軟體");
            HandshakeList.Add("D", System.IO.Ports.Handshake.RequestToSendXOnXOff, "兩者");
        }
Beispiel #2
0
 private void _init_rest()
 {
     _com_update();
     cbb_baud_rate.DataSource = BaudRateList.getInstance().getArray();
     tbx_send.Multiline       = false;
     _settings_load();
     rtb_terminal.Font      = new Font("Courier New", 11);
     rtb_terminal.BackColor = _color_background;
     this.ActiveControl     = tbx_send;
 }
        private void Init_rest()
        {
            /* COM port */
            _start_reading = false;
            _update_com();
            cbb_baud_rate.DataSource = BaudRateList.getInstance().getArray();

            /* data collection for accelerometer data */
            _received_data             = new BindingList <byte>();
            _received_data.AllowNew    = true;
            _received_vectors          = new BindingList <Vector3D>();
            _received_vectors.AllowNew = true;

            _received_data.ListChanged    += new ListChangedEventHandler(raw_list_changed);
            _received_vectors.ListChanged += new ListChangedEventHandler(list_changed);

            /* register mousewheel event handler for chart1 */
            chart1.MouseWheel += chart1_MouseWheel;
        }
        public AlarmContentViewModel()
        {
            //填充端口号
            InitPortNames();
            //填充波特率
            InitBaudRates();
            //填充数据位
            InitDataBits();
            //填充校验位
            InitParity();
            //填充停止位
            InitStopBits();

            //读取配置文件
            //串口
            SerialComm comm = new SerialComm();

            this.PortName = PortList.SingleOrDefault(p => p.Value.ToString() == comm.PortName);
            this.BaudRate = BaudRateList.SingleOrDefault(b => (int)b.Value == comm.BaudRate);
            this.Parity   = ParityList.SingleOrDefault(p => (Parity)p.Value == comm.Parity);
            this.DataBits = DataBitList.SingleOrDefault(d => (int)d.Value == comm.DataBits);
            this.StopBits = StopBitList.SingleOrDefault(s => (StopBits)s.Value == comm.StopBits);
            //CopyImagePath
            XDocument doc  = XDocument.Load("Application.config");
            var       path = doc.Descendants("copyImagePath").Single();

            this.CopyImagePath = path.Attribute("path").Value;
            //UDP
            this.UDPServer = UDPServer.GetServerFromConfig();
            //Clients
            this.Clients = UDPHost.GetClients();
            this.ChangeSerialPortParamsCommand = new DelegateCommand <ExCommandParameter>(ChangeSerialPortsParam);
            this.ChangeUDPServerParamsCommand  = new DelegateCommand <ExCommandParameter>(ChangeUDPServerParams);
            this.BeginningEditCommand          = new DelegateCommand <ExCommandParameter>(BeginningEdit);
            this.RowEditEndingCommand          = new DelegateCommand <ExCommandParameter>(RowEditEnding);
            this.DeleteClientCommand           = new DelegateCommand <ExCommandParameter>(DeleteClient);
            this.AddNewClientCommand           = new DelegateCommand(AddNewClient);
            this.BrowseDirCommand           = new DelegateCommand(BrowseDir);
            this.ChangeCopyImagePathCommand = new DelegateCommand <ExCommandParameter>(ChangeCopyImagePath);
        }