Exemplo n.º 1
0
 private void OnDeletePort()
 {
     if (SelectedPort != null)
     {
         PortList.Remove(SelectedPort);
     }
 }
Exemplo n.º 2
0
 public AnonymousFunction(IScope callScope, object body, PortList ports, TypeAnnotation?output)
 {
     _body      = body;
     _callScope = callScope;
     Output     = output;
     Inputs     = ports.List.ToArray();
 }
Exemplo n.º 3
0
 public CreateWindows()
 {
     InitializeComponent();
     this.Closing += CreateWindows_Closing;
     ports         = new PortList();
     this.listPort.ItemsSource = ports;
     //初始化参数
     Settings = new List <Setting>();
     //读取配置文件
     if (ConfigurationManager.AppSettings.AllKeys.Contains("mode"))
     {
         Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
         string        config        = configuration.AppSettings.Settings["mode"].Value.ToString();
         var           cfgs          = config.Split(';');
         foreach (var cfg in cfgs)
         {
             var     cs      = cfg.Split(',');
             Setting setting = new Setting()
             {
                 VarName   = cs[0],
                 VarValue  = cs[1],
                 VarHandle = cs[2]
             };
             Settings.Add(setting);
         }
     }
     else
     {
         ParamHandler.Save2Conf("mode", "默认配置,1.25,no");
         Settings.Add(DefaultSetting);
     }
     //下拉框绑定数据源
     cbSet.ItemsSource  = Settings;
     cbSet.SelectedItem = Settings.Where(p => p.VarName.Equals("默认配置")).FirstOrDefault();
 }
        public SerialCommunicationViewModel(SerialMessageProcessor prcessor)
        {
            MessageProcessor = prcessor;

            // for debugging
            _selectedPortName = PortList.FirstOrDefault();
        }
Exemplo n.º 5
0
        public Room(Project project)
            : base(project)
        {
            Name     = "Cave";
            Size     = new Vector(3 * Settings.GridSize, 2 * Settings.GridSize);
            Position = new Vector(-Size.X / 2, -Size.Y / 2);

            // connections may connect to any of our "corners"
            PortList.Add(new CompassPort(CompassPoint.North, this));
            PortList.Add(new CompassPort(CompassPoint.NorthNorthEast, this));
            PortList.Add(new CompassPort(CompassPoint.NorthEast, this));
            PortList.Add(new CompassPort(CompassPoint.EastNorthEast, this));
            PortList.Add(new CompassPort(CompassPoint.East, this));
            PortList.Add(new CompassPort(CompassPoint.EastSouthEast, this));
            PortList.Add(new CompassPort(CompassPoint.SouthEast, this));
            PortList.Add(new CompassPort(CompassPoint.SouthSouthEast, this));
            PortList.Add(new CompassPort(CompassPoint.South, this));
            PortList.Add(new CompassPort(CompassPoint.SouthSouthWest, this));
            PortList.Add(new CompassPort(CompassPoint.SouthWest, this));
            PortList.Add(new CompassPort(CompassPoint.WestSouthWest, this));
            PortList.Add(new CompassPort(CompassPoint.West, this));
            PortList.Add(new CompassPort(CompassPoint.WestNorthWest, this));
            PortList.Add(new CompassPort(CompassPoint.NorthWest, this));
            PortList.Add(new CompassPort(CompassPoint.NorthNorthWest, this));
        }
Exemplo n.º 6
0
 private void SaveButtonPorts_Click(object sender, EventArgs e)
 {
     if (PortList.GetItemText(PortList.SelectedItem) != "")
     {
         this.mainForm.LabelText = (PortList.GetItemText(PortList.SelectedItem));
         mainForm.Text           = mainForm.LabelText;
         System.Windows.Forms.MessageBox.Show("Selected Port: " + mainForm.LabelText, "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         this.Close();
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Rescans and updates ports in combo box
 /// </summary>
 public void Rescan()
 {
     ports        = SerialPort.GetPortNames();
     PortSelected = null;
     PortList.Clear();
     foreach (string port in ports)
     {
         PortList.Add(port);
     }
 }
Exemplo n.º 8
0
 private void OnVertexRemoved(object sender, ItemEventArgs <Vertex> e)
 {
     e.Item.Connection = null;
     e.Item.Changed   -= OnVertexChanged;
     foreach (VertexPort port in PortList)
     {
         if (port.Vertex == e.Item)
         {
             PortList.Remove(port);
             break;
         }
     }
 }
        private static void ChangeComPortName(string comPort)
        {
            ReadPortList();

            if (PortList.Count != 0)
            {
                ComPortName = PortList.Contains(comPort) ? comPort : PortList[0];
            }
            else
            {
                ComPortName = "";
            }
        }
Exemplo n.º 10
0
 private void onVertexRemoved(object sender, ItemEventArgs <Vertex> e)
 {
     e.Item.Connection = null;
     e.Item.Changed   -= onVertexChanged;
     foreach (var port1 in PortList)
     {
         var port = (VertexPort)port1;
         if (port.Vertex == e.Item)
         {
             PortList.Remove(port);
             break;
         }
     }
 }
Exemplo n.º 11
0
        private void SearchForPortAndAddOrRemove(object sender, EventArgs e)
        {
            List <string> portlist = SerialPort.GetPortNames().ToList();

            var oldports = PortList.Except(portlist).ToList();
            var newports = portlist.Except(PortList).ToList();

            if (oldports.Count == 0 && newports.Count == 0)
            {
                return;
            }

            PortList = portlist;
            OnPropertyChanged(nameof(PortList));
        }
Exemplo n.º 12
0
        public ConnectionTypeDialog(int[] usbdevices, String[] ports, IPAddress[] addresses, String preferred)
        {
            this.usbdevices = usbdevices;
            this.ports      = ports;
            this.addresses  = addresses;
            this.selected   = null;

            int pref = 0;

            InitializeComponent();

            headerText.Text = MainWindowVM.GetLocalization["dHeaderConnection"];
            butCancel.Text  = MainWindowVM.GetLocalization["dButCancel"];
            butRetry.Text   = MainWindowVM.GetLocalization["dButRetry"];

            foreach (int i in usbdevices)
            {
                String txt = "USB " + i;
                if (txt.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(txt);
            }
            foreach (String p in ports)
            {
                if (p.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(p);
            }
            foreach (IPAddress a in addresses)
            {
                String txt = a.ToString();
                if (txt.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(txt);
            }

            if (PortList.Items.Count > 0)
            {
                PortList.Focus();
                PortList.SelectedIndex = pref;
            }
        }
Exemplo n.º 13
0
        public ConnectionTypeDialog(int[] usbdevices, String[] ports, IPAddress[] addresses, String preferred)
        {
            this.usbdevices = usbdevices;
            this.ports      = ports;
            this.addresses  = addresses;
            this.selected   = null;

            int pref = 0;

            InitializeComponent();

            foreach (int i in usbdevices)
            {
                String txt = "USB " + i;
                if (txt.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(txt);
            }
            foreach (String p in ports)
            {
                if (p.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(p);
            }
            foreach (IPAddress a in addresses)
            {
                String txt = a.ToString();
                if (txt.Equals(preferred))
                {
                    pref = PortList.Items.Count;
                }
                PortList.Items.Add(txt);
            }

            if (PortList.Items.Count > 0)
            {
                PortList.Focus();
                PortList.SelectedIndex = pref;
            }
        }
Exemplo n.º 14
0
        public SetPortViewModel(
            ModalWindowManager modalWindowManager,
            IAppConfigService appConfigService)
        {
            _modalWindowManager = modalWindowManager;
            _appConfigService   = appConfigService;

            RefreshPortList = ReactiveCommand.Create(() =>
            {
                PortList?.Clear();
                PortList = new ObservableCollection <string>(SerialPort.GetPortNames());
            });

            AppyPort = ReactiveCommand.Create(() =>
            {
                _appConfigService.Config.Port = SelectedPort;
                MessageBus.Current.SendMessage <ModalActions>(ModalActions.Close);
            });

            RefreshPortList.Execute().Subscribe();
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
0
        public void getAvailablePorts()
        {
            PortList.Items.Clear();
            ManagementScope          connectionScope = new ManagementScope();
            SelectQuery              serialQuery     = new SelectQuery("SELECT * FROM Win32_SerialPort");
            ManagementObjectSearcher searcher        = new ManagementObjectSearcher(connectionScope, serialQuery);

            try
            {
                foreach (ManagementObject item in searcher.Get())
                {
                    string desc     = item["Description"].ToString();
                    string deviceId = item["DeviceID"].ToString();

                    if (desc.Contains("Arduino"))
                    {
                        PortList.Items.Add(desc + " " + deviceId);
                    }
                }
                if (PortList.Items.Count == EMPTY)
                {
                    string info = "No Arduino COM Port Found.";
                    System.Windows.Forms.MessageBox.Show(info, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    this.PortList.SelectedIndex = 0;
                    this.mainForm.LabelText     = (PortList.GetItemText(PortList.SelectedItem));
                    mainForm.Text = mainForm.LabelText;
                }
            }
            catch (ManagementException e)
            {
                MessageBox.Show(e.Message);
            }
        }
Exemplo n.º 17
0
 private void btnNew_Click(object sender, RoutedEventArgs e)
 {
     ports = new PortList();
 }
Exemplo n.º 18
0
 protected override void GetPorts(PortList portList)
 {
     portList.Add(positionPort);
     base.GetPorts(portList);
 }
Exemplo n.º 19
0
 private void OnVertexAdded(object sender, ItemEventArgs <Vertex> e)
 {
     e.Item.Connection = this;
     e.Item.Changed   += OnVertexChanged;
     PortList.Add(new VertexPort(e.Item, this));
 }
Exemplo n.º 20
0
 protected override void GetPorts(PortList portList)
 {
     portList.Add(new OutputPort <Vector3>("Jump Pos", () => validJumpPos));
     base.GetPorts(portList);
 }
Exemplo n.º 21
0
 /// <summary>
 /// Returns a ConduitType list with the type of all ports associated to this instance.
 /// </summary>
 public List <ConduitType> GetPortTypes()
 {
     return(PortList.Select(x => x.ConduitType).ToList());
 }
Exemplo n.º 22
0
        //判断文件是否存在,以及坐标偏移
        private void FileExsits(string path, int offert, string Block, int RBFlag)
        {
            string tmpStr   = string.Empty;
            string FilePath = string.Empty;

            PathAndOffert temp = new PathAndOffert(null, null, null, null, offert, 1, 0);

            string[] FileName = path.Split(','); //FileName[0]必定是文件夹的名字
            string[] Blocks   = Block.Split(',');
            if (!Directory.Exists(FileName[0]))  //判断文件夹是否存在,没有则新建
            {
                Directory.CreateDirectory(FileName[0]);
            }
            if (Blocks.Count() != FileName.Count() - 1)//OutPath中的逗号数目比Block中的多1个
            {
                throw new Exception("ReadPage 中Block和plane数应该和数据路径对应!!!");
            }
            if (FileName.Count() == 2)//单plane
            {
                tmpStr           = FileName[0] + @"/" + FileName[1];
                temp.FilePath[0] = tmpStr;
                temp.PlaneNum    = 1;
            }
            else if (FileName.Count() == 3)//两个Plane
            {
                tmpStr           = FileName[0] + @"/" + FileName[1];
                temp.FilePath[0] = tmpStr;
                tmpStr           = FileName[0] + @"/" + FileName[2];
                temp.FilePath[1] = tmpStr;
                temp.PlaneNum    = 2;
            }
            else if (FileName.Count() == 5)//4个Plane
            {
                tmpStr           = FileName[0] + @"/" + FileName[1];
                temp.FilePath[0] = tmpStr;
                tmpStr           = FileName[0] + @"/" + FileName[2];
                temp.FilePath[1] = tmpStr;
                tmpStr           = FileName[0] + @"/" + FileName[3];
                temp.FilePath[2] = tmpStr;
                tmpStr           = FileName[0] + @"/" + FileName[4];
                temp.FilePath[3] = tmpStr;
                temp.PlaneNum    = 4;
            }
            else
            {
                throw new Exception("ReadPage 路径格式错误!!!");
            }
            if (RBFlag == 1)//如果统计R/B#拉低时间,则新建一个csv文件
            {
                try
                {
                    FileStream stream = new FileStream(FileName[0] + @"/" + @"R/B_Falling_Duration.csv", FileMode.Create, FileAccess.Write);
                    stream.Close();
                }
                catch
                {
                    throw new Exception("R/B统计表格创建失败!");
                }
            }
            if (PortList.Keys.Count == 1)
            {
                string name = PortList.FirstOrDefault().Key;
                if (!ComDataPath.Keys.Contains(name))
                {
                    List <PathAndOffert> tmpList = new List <PathAndOffert>();
                    ComDataPath.Add(name, tmpList);
                }
                for (int i = 0; i < temp.PlaneNum; i++)
                {
                    try
                    {
                        //temp.FilePath[i] += ".bin";
                        if (!File.Exists(temp.FilePath[i]))
                        {
                            //File.Create(temp.FilePath[i]).Dispose();
                            FileStream stream = new FileStream(temp.FilePath[i], FileMode.Create, FileAccess.Write);
                            stream.Close();
                        }
                    }
                    catch
                    {
                        throw new Exception("文件路径不正确!!!");
                    }
                }
                ComDataPath[name].Add(temp);
            }
            else
            {
                foreach (string name in PortList.Keys)
                {
                    PathAndOffert Privious = temp;
                    temp = Privious;
                    if (!ComDataPath.Keys.Contains(name))
                    {
                        List <PathAndOffert> tmpList = new List <PathAndOffert>();
                        ComDataPath.Add(name, tmpList);
                    }
                    for (int i = 0; i < Privious.PlaneNum; i++)
                    {
                        temp.FilePath[i] += name;
                        if (!File.Exists(temp.FilePath[i]))
                        {
                            //File.Create(temp.FilePath[i]).Dispose();
                            FileStream stream = new FileStream(temp.FilePath[i], FileMode.Create, FileAccess.Write);
                            stream.Close();
                        }
                    }
                    ComDataPath[name].Add(temp);
                }
            }
        }
Exemplo n.º 23
0
 internal protected abstract override void GetPorts(PortList portList);
Exemplo n.º 24
0
        private void button1_Click(object sender, EventArgs e)         //сканировать
        {
            btnScan.Enabled = false;
            lstPorts.Items.Clear();
            PortList portlist = new PortList();

            try
            {
                IPAddress ip2 = IPAddress.Parse(txtBoxIP.Text);

                if (chBoxTcp.Checked || chBoxUdp.Checked)
                {
                    switch (comboBoxBeetw.SelectedIndex)
                    {
                    case (0):
                    {
                        int index2 = (int)numList2.Value;
                        int index1 = (int)numList1.Value;
                        if (ip.ToString() == ip2.ToString())                                 //если текущая ЭВМ
                        {
                            portlist.GenFile();
                            PortList portlistcopy = new PortList();
                            for (int i = index1; i <= index2; i++)
                            {
                                foreach (PortStatus.PortStatus port in portlist.FindPort(i).GetPortList())
                                {
                                    portlistcopy.AddPort(port);
                                }
                            }
                            portlistcopy = portlistcopy.DelIns();
                            foreach (PortStatus.PortStatus port in portlistcopy.GetPortList())
                            {
                                if (port.Link == "TCP" && chBoxTcp.Checked)
                                {
                                    PortToWinList(port);
                                }
                                if (port.Link == "UDP" && chBoxUdp.Checked)
                                {
                                    PortToWinList(port);
                                }
                            }
                        }
                        else                                                                                            //если другая ЭВМ
                        {
                            for (int i = index1; i <= index2; i++)
                            {
                                if (chBoxTcp.Checked)
                                {
                                    CheckPort(i, "tcp", ip2);
                                }
                                if (chBoxUdp.Checked)
                                {
                                    Logic(i);
                                }
                            }
                        }

                        break;
                    }

                    case (1):
                    {
                        int index1 = (int)numList1.Value;
                        if (ip.ToString() == ip2.ToString())                                            //если текущая ЭВМ
                        {
                            portlist.GenFile();
                            PortList portlistcopy = new PortList();
                            foreach (PortStatus.PortStatus port in portlist.FindPort(index1).GetPortList())
                            {
                                portlistcopy.AddPort(port);
                            }
                            portlistcopy = portlistcopy.DelIns();
                            foreach (PortStatus.PortStatus port in portlistcopy.GetPortList())
                            {
                                if (port.Link == "TCP" && chBoxTcp.Checked)
                                {
                                    PortToWinList(port);
                                }
                                if (port.Link == "UDP" && chBoxUdp.Checked)
                                {
                                    PortToWinList(port);
                                }
                            }
                        }
                        else                                                                                                            //если другая ЭВМ
                        {
                            if (chBoxTcp.Checked)
                            {
                                CheckPort(index1, "tcp", ip2);
                            }
                            if (chBoxUdp.Checked)
                            {
                                Logic(index1);
                            }
                        }
                        break;
                    }

                    default: break;
                    }
                }
                else
                {
                    MessageBox.Show("Выберите порты для отображения.", "Ошибка");
                }
                portram         = portlist;
                btnScan.Enabled = true;
                Cursor.Current  = Cursors.Arrow;
            }
            catch (FormatException ex) { MessageBox.Show(ex.Message, "Ошибка"); }
        }
Exemplo n.º 25
0
 public PortScanner(IPAddress host, int portStart, int portStop)
 {
     _host     = host;
     _portList = new PortList(portStart, portStop);
 }