Exemplo n.º 1
0
        private void GRStRds_Changed(object sender, EventArgs e)
        {
            GRStationLastRealDatasCollection snd = sender as GRStationLastRealDatasCollection;

            if (snd != null)
            {
                GRStationLastRealData strd = snd.ChangedSTRD;
                if (strd != null)
                {
                    ListViewItem lvi = FindLvi(strd.GRStation.StationName);
                    if (lvi != null)
                    {
                        if (strd.GRRealData != null)
                        {
                            string [] ss   = GetSubItemTexts(strd.GRStation.StationName, strd.GRRealData);
                            string    text = lvi.Text;
                            Color     clr  = lvi.BackColor;

                            lvi.SubItems.Clear();
                            lvi.Text      = text;
                            lvi.BackColor = clr;
                            lvi.SubItems.AddRange(ss);
                        }
                    }
                }
            }
//            RefreshListView ();
        }
Exemplo n.º 2
0
        public void ChangeWithStName(string stationName, int address, GRRealData grRd)
        {
            bool c = false;

            foreach (GRStationLastRealData strd in this)
            {
                if (strd.GRStation.StationName == stationName &&
                    strd.GRStation.Address == address)
                {
                    strd.GRRealData = grRd;
                    _strd           = strd;
                    c = true;
                }
            }

            if (c && this.Changed != null)
            {
                EventHandler temp = Changed;
                temp(this, EventArgs.Empty);
            }
        }
Exemplo n.º 3
0
        public void ChangeWithRemoteIP(string remoteIP, int address, GRRealData grRd)
        {
            bool c = false;

            foreach (GRStationLastRealData strd in this)
            {
                if (strd.GRStation.DestinationIP == remoteIP &&
                    strd.GRStation.Address == address)
                {
                    strd.GRRealData = grRd;
                    _strd           = strd;
                    c = true;
                }
            }

            if (c && this.Changed != null)
            {
                EventHandler temp = Changed;
                temp(this, EventArgs.Empty);
            }
        }
Exemplo n.º 4
0
 public void Add(GRStationLastRealData grStRd)
 {
     ArgumentChecker.CheckNotNull(grStRd);
     InternalAdd(grStRd);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 解析采集供热实时数据命令,
        /// parse xgdata read
        /// </summary>
        /// <returns></returns>
        private static TasksCollection  ResolveGRRealDataTaskFromDB()
        {
            string FailMsg = "Fail list:\r\n";
            //TODO: ResolveGRRealDataTaskFromDB
            //
            // 2007.03.10 Modify not use client flag, use serverIP diff local or remote gprs module,
            //
            //            string sql = string.Format(
            //                "select * from v_gprs_gr_xg where client = {0}",
            //                XGConfig.Default.ClientAorB  );
            string sql = "select * from v_gprs_gr_xg";

            DataSet         ds    = XGDB.DbClient.Execute(sql);
            DataTable       tbl   = ds.Tables[0];
            TasksCollection tasks = new TasksCollection();

            foreach (DataRow r in tbl.Rows)
            {
                string name   = r["name"].ToString();
                int    grAddr = int.Parse(r["gr_address"].ToString());
                int    xgAddr = int.Parse(r["xg_address"].ToString());

                string ip       = r["ip"].ToString();
                string serverIP = r["serverIP"].ToString();
                string team     = r["team"].ToString().Trim();

                //GRStation grst = new GRStation(name, grAddr, ip);
                GRStation grst = CreateGrStation(name, grAddr, ip, team);
                grst.ServerIP = serverIP;

                if (grst != null)
                {
                    // 2007.03.07 Added grstation to singles.grstationsCollection
                    //
                    Singles.S.GRStsCollection.Add(grst);

                    // 2007.03.01 Added gtstation last grRealdata
                    //
                    if (Singles.S.GRStRds == null)
                    {
                        Singles.S.GRStRds = new GRStationLastRealDatasCollection();
                    }

                    // create and add a new grstation last read data object to Singles.GRStRds
                    //
                    GRStationLastRealData grstLastRd = new GRStationLastRealData(grst);

                    Singles.S.GRStRds.Add(grstLastRd);

                    // 2007.03.10 Added check grstation(gprsstation).serverIP is the localhost ip
                    //
                    if (serverIP == XGConfig.Default.ServerIP)
                    {
                        // create a new grrealdata task for grStation
                        //
                        GRRealDataCommand cmd      = new GRRealDataCommand(grst);
                        TimeSpan          timeSp   = new TimeSpan(0, 0, XGConfig.Default.GrRealDataCollCycle, 0, 0);
                        CycleTaskStrategy strategy = new CycleTaskStrategy(timeSp);
                        Task t = new Task(cmd, strategy);
                        tasks.Add(t);
                    }
                }
                else
                {
                    FailMsg += name + Environment.NewLine;
                }

                // 2007.03.12 Added xg data task
                //
                XGStation xgst = CreateXgStation(name, xgAddr, ip);
                //TODO: ? xgst.serverIP = serverip
                //
                xgst.ServerIP = serverIP;

                if (xgst != null)
                {
                    Singles.S.XGStsCollection.Add(xgst);
                    if (serverIP == XGConfig.Default.ServerIP)
                    {
                        ReadTotalCountCommand xgCountCmd = new ReadTotalCountCommand(xgst);
                        TimeSpan          ts             = new TimeSpan(0, 0, XGConfig.Default.XgReadCountCycle, 0, 0);
                        CycleTaskStrategy strategy       = new CycleTaskStrategy(ts);
                        Task t = new Task(xgCountCmd, strategy);
                        tasks.Add(t);
                        //                        t.AfterProcessReceived +=new EventHandler(t_AfterProcessReceived);
                    }
                }
                else
                {
                }
            }

            if (FailMsg.Length >= 13)
            {
                MsgBox.Show(FailMsg);
            }
            return(tasks);
        }