Ejemplo n.º 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, "兩者");
        }
Ejemplo n.º 2
0
        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);
        }