Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ProcessReceived(ICommuniPort cp)
        {
            //ICommuniPort cp = (ICommuniPort)sender;
            byte[] bs = cp.Read();

            // TODO: cp.stations
            //
            StationCollection stations = new StationCollection();

            foreach (IStation st in this.Soft.Hardware.Stations)
            {
                if (st.CommuniPortConfig.IsMatch(cp))
                {
                    stations.Add(st);
                }
            }

            foreach (IStation st in stations)
            {
                foreach (IDevice d in st.Devices)
                {
                    if (bs.Length > 0)
                    {
                        //ITaskProcessor processor = d.Dpu.Processor;
                        //IUploadParseResult parseResult = processor.ProcessUpload(d, bs);
                        //bs = parseResult.Remain;
                        d.ProcessUpload(bs);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="task"></param>
        /// <param name="cp"></param>
        /// <returns></returns>
        private bool IsHighestLevel(ITask task, ICommuniPort cp)
        {
            bool r = false;
            StationCollection stations = GetStations(cp);

            TaskCollection tasks = GetNeedExecuteTasks(stations);

            r = IsHighestLevel(task, tasks);
            return(r);
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        private StationCollection GetStations(ICommuniPort cp)
        {
            StationCollection r = new StationCollection();

            foreach (IStation st in Soft.Hardware.Stations)
            {
                if (st.CommuniPort == cp)
                {
                    r.Add(st);
                }
            }
            return(r);
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="hardware"></param>
        /// <returns></returns>
        static public StationCollection Unbind(ICommuniPort cp, Hardware hardware)
        {
            StationCollection unbinded = new StationCollection();

            foreach (IStation station in hardware.Stations)
            {
                if (station.CommuniPort == cp)
                {
                    station.CommuniPort = null;
                    unbinded.Add(station);
                }
            }
            return(unbinded);
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stations"></param>
        /// <returns></returns>
        private TaskCollection GetNeedExecuteTasks(StationCollection stations)
        {
            TaskCollection r = new TaskCollection();

            foreach (IStation st in stations)
            {
                foreach (IDevice device in st.Devices)
                {
                    //Debug.Assert(device.TaskManager.Current == null);

                    foreach (ITask task in device.TaskManager.Tasks)
                    {
                        if (task.Check() == TaskStatus.Ready)
                        {
                            r.Add(task);
                        }
                    }
                }
            }
            return(r);
        }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stationType"></param>
        /// <param name="newStation"></param>
        /// <returns></returns>
        public DialogResult Add(StationType stationType, StationCollection stations, out IStation newStation)
        {
            newStation = null;

            Debug.Assert(stationType != null);
            Debug.Assert(stations != null);

            FrmStationGroups f = new FrmStationGroups();

            f.AdeStatus   = ADEStatus.Add;
            f.StationType = stationType;
            f.Stations    = stations;
            f.Station     = stationType.Create(this.Spu);
            f.Groups      = f.Station.Groups;
            DialogResult dr = f.ShowDialog();

            if (dr == DialogResult.OK)
            {
                newStation = f.Station;
            }
            return(dr);
        }
Exemple #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cp"></param>
        /// <param name="hardware"></param>
        static public StationCollection Bind(ICommuniPort cp, Hardware hardware)
        {
            StationCollection binded = new StationCollection();

            foreach (IStation station in hardware.Stations)
            {
                ICommuniPortConfig cpConfig = station.CommuniPortConfig;
                if (cpConfig.IsMatch(cp))
                {
                    ICommuniPort old = station.CommuniPort;
                    if (old != cp)
                    {
                        if (old != null)
                        {
                            old.Close();
                        }
                        station.CommuniPort = cp;
                        binded.Add(station);
                    }
                }
            }

            return(binded);
        }