示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public StationCollection CreateRainStations(CommuniSoft soft)
        {
            string deviceType = "LXRainDevice";

            StationCollection stations = new StationCollection();
            DataTable         stTable  = LXDBDBI.LXDB.GetRainStationDataTable();

            foreach (DataRow row in stTable.Rows)
            {
                string    rainName    = row["Rain_Name"].ToString();
                int       rainAddress = Convert.ToInt32(row["Rain_addr"]);
                string    ipString    = row["Rain_IP"].ToString();
                IPAddress ip          = IPAddress.Parse(ipString);
                int       deviceid    = rainAddress;
                int       stationid   = rainAddress;

                SocketCommuniType ct = new SocketCommuniType(ip);
                Station           st = new Station(rainName, ct);
                st.ID = stationid;

                DeviceDefine dd = soft.DeviceDefineManager.
                                  DeviceDefineCollection.FindDeviceDefine(deviceType);
                LXRainDevice d = new LXRainDevice(dd, rainAddress);
                d.ID = deviceid;

                st.Devices.Add(d);

                stations.Add(st);
            }
            return(stations);
        }
示例#2
0
文件: frmMain.cs 项目: wpmyj/c3
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mnuStationAdd_Click(object sender, EventArgs e)
        {
            frmStationType f  = new frmStationType();
            DialogResult   dr = f.ShowDialog();

            if (dr == DialogResult.OK)
            {
                StationType stationType = f.SelectedStationType;
                ISPU        spu         = Soft.SPUs[stationType];
                IStationUI  stationUI   = spu.StationUI;

                StationCollection stations = this.Soft.Hardware.Stations;
                IStation          newStation;
                DialogResult      dr2 = stationUI.Add(stationType, stations, out newStation);
                if (dr2 == DialogResult.OK)
                {
                    Debug.Assert(newStation.StationType != null);
                    Debug.Assert(newStation.Spu != null);
                    Debug.Assert(newStation.Guid != null);

                    stations.Add(newStation);
                    spu.StationPersister.Add(newStation);

                    StationTreeNode stationNode = new StationTreeNode(newStation);
                    this.HardwareTreeView.Nodes.Add(stationNode);
                }
            }
        }
示例#3
0
        /// <summary>
        /// 获取候选站点列表
        /// </summary>
        /// <returns></returns>
        public StationCollection GetCandidateStationList()
        {
            StationCollection list = new StationCollection();
            DataTable         tbl  = StationDBI.GetNotAssociateStationDataTable();

            foreach (DataRow row in tbl.Rows)
            {
                int          stationID = Convert.ToInt32(row["StationID"]);
                string       name      = row["Name"].ToString();
                StationClass n         = new StationClass();
                n.StationID   = stationID;
                n.StationName = name;
                list.Add(n);
            }
            list.Remove(this.StationCollection);
            list.Add(GetDeletedStationCollection());
            return(list);
        }
示例#4
0
        /// <summary>
        /// Add a station to the collection of stations to be processed rejecting duplicates.
        /// </summary>
        /// <param name="newStation">The station to be added.</param>
        public static bool AddStation(TVStation newStation)
        {
            if (newStation == null)
            {
                throw (new ArgumentException("The new station cannot be null", "newStation"));
            }

            foreach (TVStation oldStation in StationCollection)
            {
                if (oldStation.OriginalNetworkID != -1)
                {
                    if (oldStation.OriginalNetworkID == newStation.OriginalNetworkID &&
                        oldStation.TransportStreamID == newStation.TransportStreamID &&
                        oldStation.ServiceID == newStation.ServiceID)
                    {
                        oldStation.Name = newStation.Name;
                        return(false);
                    }
                }
                else
                {
                    if (oldStation.Frequency != -1)
                    {
                        if (oldStation.Frequency == newStation.Frequency &&
                            oldStation.ServiceID == newStation.ServiceID)
                        {
                            oldStation.Name = newStation.Name;
                            oldStation.OriginalNetworkID = newStation.OriginalNetworkID;
                            oldStation.TransportStreamID = newStation.TransportStreamID;
                            return(false);
                        }
                    }
                    else
                    {
                        if (oldStation.ServiceID == newStation.ServiceID)
                        {
                            oldStation.Name = newStation.Name;
                            oldStation.OriginalNetworkID = newStation.OriginalNetworkID;
                            oldStation.TransportStreamID = newStation.TransportStreamID;
                            oldStation.Frequency         = newStation.Frequency;
                            return(false);
                        }
                    }
                }
            }

            StationCollection.Add(newStation);

            return(true);
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="channelID"></param>
        private StationCollection GetStationList(int channelID)
        {
            StationCollection list       = new StationCollection();
            DataTable         stationTbl = ChannelDBI.GetStationDataTable(channelID);

            foreach (DataRow row in stationTbl.Rows)
            {
                StationClass sc = new StationClass();
                sc.StationID   = Convert.ToInt32(row["StationID"]);
                sc.StationName = row["Name"].ToString();
                //this.StationCollection.Add(sc);
                list.Add(sc);
            }
            return(list);
        }
示例#6
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static StationCollection CreateStationCollection(int channelID)
        {
            StationCollection stations = new StationCollection();
            DataTable channelStationMapTbl = ChannelStationMapDBI.GetChannelStationMapDataTable(channelID);

            //int[] stationIDs = ChannelStationMapDBI.GetStationIDs(channelID);
            int[] stationIDs = DataTableHelper.GetIDs(channelStationMapTbl, "stationid");

            DataTable tbl =  StationDBI.GetStationDataTable(stationIDs);
            foreach (DataRow row in tbl.Rows)
            {
                StationClass c = CreateStation(row);
                c.StationOrdinal = GetStationOrdinal(channelStationMapTbl, c.StationID);
                stations.Add(c);
            }

            stations.SortByStationOrdinal();
            return stations;
        }
示例#7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private bool DistributeQueryStringParam_Real()
        {
            string[] paramNames = new string[] { QueryStringNames.StationID };
            Type[]   paramTypes = new Type[] { typeof(int) };

            object [] result;
            bool      b = QueryStringParamPicker.Pick(this.Request.QueryString, paramNames, paramTypes,
                                                      out result);

            if (b)
            {
                int stationid = (int)result[0];
                this.UCConditionDTTwo1.WaterUser = SessionManager.LoginSession.WaterUser;

                StationClass      sc       = StationFactory.CreateStationByStationID(stationid);
                StationCollection stations = new StationCollection();
                stations.Add(sc);
                this.UCConditionDTTwo1.Stations = stations;
                this.UCConditionDTTwo1.Begin    = DateTime.Now.Date;
                this.UCConditionDTTwo1.End      = DateTime.Now.Date + TimeSpan.FromDays(1d);
                return(true);
            }
            return(false);
        }
示例#8
0
        public StationCollection getStations(int line)
        {
            SqlConnection con = new SqlConnection(conStr);
            con.Open();

            StationCollection stations = new StationCollection();

            String qry = String.Empty;
            qry = @"SELECT id , description FROM stations where line={0} ORDER by id";

            qry = String.Format(qry, line);

            SqlCommand cmd = new SqlCommand(qry, con);
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(dr);
            dr.Close();
            cmd.Dispose();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                stations.Add(new Station(line,(int)dt.Rows[i]["id"], (string)dt.Rows[i]["description"]));
            }

            con.Close();
            con.Dispose();
            return stations;
        }
示例#9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cp_Received(object sender, EventArgs e)
        {
            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 pr = processor.ProcessUpload(d, bs);
                        //bs = pr.Remain;
                        d.ProcessUpload(bs);
                    }
                }
            }
        }
示例#10
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="channelID"></param>
 private StationCollection GetStationList(int channelID)
 {
     StationCollection list = new StationCollection();
     DataTable stationTbl = ChannelDBI.GetStationDataTable(channelID);
     foreach (DataRow row in stationTbl.Rows)
     {
         StationClass sc = new StationClass();
         sc.StationID = Convert.ToInt32(row["StationID"]);
         sc.StationName = row["Name"].ToString();
         //this.StationCollection.Add(sc);
         list.Add(sc);
     }
     return list;
 }
示例#11
0
 /// <summary>
 /// 获取候选站点列表
 /// </summary>
 /// <returns></returns>
 public StationCollection GetCandidateStationList()
 {
     StationCollection list = new StationCollection();
     DataTable tbl =  StationDBI.GetNotAssociateStationDataTable();
     foreach (DataRow row in tbl.Rows)
     {
         int stationID = Convert.ToInt32(row["StationID"]);
         string name = row["Name"].ToString();
         StationClass n = new StationClass();
         n.StationID = stationID;
         n.StationName = name;
         list.Add(n);
     }
     list.Remove(this.StationCollection);
     list.Add(GetDeletedStationCollection());
     return list;
 }
示例#12
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override StationCollection BuildStationCollection()
        {
            StationCollection stations = new StationCollection();
            string sql = "select * from tblStation where StationDeleted = 0";
            DataTable stationTbl = DBI.ExecuteDataTable(sql);
            foreach (DataRow row in stationTbl.Rows)
            {
                Station newStation = BuildStation(row);
                stations.Add(newStation);

                DeviceCollection devices = BuildDeviceCollection(newStation);

                newStation.Devices.AddDeviceCollection(devices);
            }
            return stations;
        }
示例#13
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private bool DistributeQueryStringParam_Real()
        {
            string[] paramNames = new string[] { QueryStringNames.StationID};
            Type[] paramTypes = new Type[]{typeof(int)};

            object []result ;
            bool b = QueryStringParamPicker.Pick(this.Request.QueryString, paramNames, paramTypes,
                out result);

            if (b)
            {
                int stationid = (int)result[0];
                this.UCConditionDTTwo1.WaterUser = SessionManager.LoginSession.WaterUser;

                StationClass sc = StationFactory.CreateStationByStationID(stationid);
                StationCollection stations = new StationCollection();
                stations.Add (sc);
                this.UCConditionDTTwo1.Stations = stations;
                this.UCConditionDTTwo1.Begin = DateTime.Now.Date;
                this.UCConditionDTTwo1.End = DateTime.Now.Date + TimeSpan.FromDays(1d);
                return true;
            }
            return false;
        }
示例#14
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="tbl"></param>
 /// <returns></returns>
 private static StationCollection CreateStationCollection(DataTable tbl)
 {
     StationCollection stations = new StationCollection();
     foreach (DataRow row in tbl.Rows)
     {
         StationClass s = CreateStation(row);
         stations.Add(s);
     }
     return stations;
 }
示例#15
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public StationCollection CreateRainStations(CommuniSoft soft)
        {
            string deviceType = "LXRainDevice";

            StationCollection stations = new StationCollection();
            DataTable stTable = LXDBDBI.LXDB.GetRainStationDataTable();
            foreach (DataRow row in stTable.Rows)
            {
                string rainName = row["Rain_Name"].ToString();
                int rainAddress = Convert.ToInt32(row["Rain_addr"]);
                string ipString = row["Rain_IP"].ToString();
                IPAddress ip = IPAddress.Parse(ipString);
                int deviceid = rainAddress;
                int stationid = rainAddress;

                SocketCommuniType ct = new SocketCommuniType(ip);
                Station st = new Station(rainName, ct);
                st.ID = stationid;

                DeviceDefine dd = soft.DeviceDefineManager.
                    DeviceDefineCollection.FindDeviceDefine(deviceType);
                LXRainDevice d = new LXRainDevice(dd,rainAddress);
                d.ID = deviceid;

                st.Devices.Add(d);

                stations.Add(st);
            }
            return stations;
        }
示例#16
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;
 }