Ejemplo n.º 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);
                    }
                }
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }