Beispiel #1
0
        public void PortLoad()
        {
            GetMenutype = Menutype.ProntSetting;
            gridItem.VerticalAlignment      = VerticalAlignment.Top;
            gridItem.HorizontalAlignment    = HorizontalAlignment.Center;
            CountMap.Content                = gridItem;
            gridNetwork.VerticalAlignment   = VerticalAlignment.Top;
            gridNetwork.HorizontalAlignment = HorizontalAlignment.Left;
            networkCount.Content            = gridNetwork;
            MySqlDataReader PortData = mapMessage.ListDevice(MapRegulate.UTCTime);
            int             i        = 0;

            while (PortData.Read())
            {
                AddRows(i, PortData["Com"].ToString(), PortData["Baud"].ToString(), PortData["Agv"].ToString());
                Index = i;
                i++;
            }
            PortData.Close();
            if (gridItem.RowDefinitions.Count.Equals(1) || gridItem.RowDefinitions.Count.Equals(0))
            {
                DeletePort.IsEnabled = false;
            }
            MySqlDataReader reader = mapMessage.SelectNetworkBLL(MapRegulate.UTCTime);

            if (reader != null)
            {
                int id = 0;
                while (reader.Read())
                {
                    AddNetwork(id, reader["IP_Address"].ToString(), reader["IP_Port"].ToString());
                    NetworkIndex = id;
                    id++;
                }
            }
            if (gridNetwork.RowDefinitions.Count.Equals(1) || gridNetwork.RowDefinitions.Count.Equals(0))
            {
                Network_Delete.IsEnabled = false;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 显示所有串口信息
        /// </summary>
        /// <param name="Time"></param>
        /// <returns></returns>
        public ObservableCollection <Ga_PortInfo> agvGather(long Time)
        {
            ObservableCollection <Ga_PortInfo> portInfos = new ObservableCollection <Ga_PortInfo>();
            MySqlDataReader Read = MapBLL.ListDevice(Time);

            PortInfo.AgvPortsList.Clear();
            PortInfo.DePortsList.Clear();
            SerialPort SP = new SerialPort();

            SP.StopBits     = StopBits.One;
            SP.Parity       = Parity.Odd;
            SP.ReadTimeout  = 1000;
            SP.WriteTimeout = 1000;
            while (Read.Read())
            {
                PortType Port_type;
                SP.PortName = "COM" + Read["Com"].ToString();
                if (Read["Agv"].ToString() == "Button")
                {
                    //PortInfo.buttonPort.Add(new SerialPort());
                    //PortInfo.buttonCom.Add(Convert.ToInt32(Read["Com"].ToString()));
                    //PortInfo.buttonBaud.Add(Convert.ToInt32(Read["Baud"].ToString()));
                    //PortInfo.buttonStr.Add("Button");
                    Port_type = PortType.Button;
                    PortInfo.DePortsList.Add(new DevicePortInfo()
                    {
                        ComNumber = Convert.ToInt32(Read["Com"].ToString()),
                        BaudRate  = Convert.ToInt32(Read["Baud"].ToString()),
                        Port      = SP,
                        PortType  = PortType.Button
                    });
                }
                else if (Read["Agv"].ToString() == "Charge")
                {
                    //PortInfo.chargePort.Add(new SerialPort());
                    //PortInfo.chargeCom.Add(Convert.ToInt32(Read["Com"].ToString()));
                    //PortInfo.chargeBaud.Add(Convert.ToInt32(Read["Baud"].ToString()));
                    //PortInfo.chargeStr.Add("Charge");
                    Port_type = PortType.Charge;
                    PortInfo.DePortsList.Add(new DevicePortInfo()
                    {
                        ComNumber = Convert.ToInt32(Read["Com"].ToString()),
                        BaudRate  = Convert.ToInt32(Read["Baud"].ToString()),
                        Port      = SP,
                        PortType  = PortType.Charge
                    });
                }
                else if (Read["Agv"].ToString() == "Plc")
                {
                    //PortInfo.chargePort.Add(new SerialPort());
                    //PortInfo.plcCom.Add(Convert.ToInt32(Read["Com"].ToString()));
                    //PortInfo.plcBaud.Add(Convert.ToInt32(Read["Baud"].ToString()));
                    //PortInfo.plcStr.Add("Plc");
                    Port_type = PortType.PLC;
                    PortInfo.DePortsList.Add(new DevicePortInfo()
                    {
                        ComNumber = Convert.ToInt32(Read["Com"].ToString()),
                        BaudRate  = Convert.ToInt32(Read["Baud"].ToString()),
                        Port      = SP,
                        PortType  = PortType.PLC
                    });
                }
                else
                {
                    //PortInfo.AGVCom.Add(Convert.ToInt32(Read["Com"].ToString()));
                    //PortInfo.Baud.Add(Convert.ToInt32(Read["Baud"].ToString()));
                    //PortInfo.agv.Add((Read["Agv"].ToString()));
                    Port_type = PortType.AGV;

                    PortInfo.AgvPortsList.Add(new AgvPortInfo()
                    {
                        AgvDll    = new AGVDLL.AGVDLL(),
                        AgvStr    = Read["Agv"].ToString(),
                        BaudRate  = Convert.ToInt32(Read["Baud"].ToString()),
                        ComNumber = Convert.ToInt32(Read["Com"].ToString())
                    });
                }
                portInfos.Add(
                    new Ga_PortInfo()
                {
                    ComNumber      = "COM" + Read["Com"].ToString().Trim(),
                    ComPortType    = Port_type,
                    ComStatic      = "关闭",
                    ComStaticColor = new SolidColorBrush(Colors.Red)
                });
            }
            Read.Close();
            return(portInfos);
        }