Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void task_AfterProcessReceived(object sender, EventArgs e)
        {
            Task      t    = sender as Task;
            GRStation grst = t.CommCmd.Station as GRStation;

            if (grst != null)
            {
                ListViewItem lvi = GetLviByGRStation(grst);

                if (t.LastCommResultState == CommResultState.Correct)
                {
                    GRReadTLCommand grreadtlcmd = t.CommCmd as GRReadTLCommand;
                    if (grreadtlcmd != null)
                    {
                        lvi.SubItems[1].Text = grreadtlcmd.TimeTempLine.ToString();
                        lvi.SubItems[2].Text = "读取成功";
                    }

                    GRWriteTimeTempLine grwritetimetemplinecmd = t.CommCmd as GRWriteTimeTempLine;
                    if (grwritetimetemplinecmd != null)
                    {
                        lvi.SubItems[1].Text = grwritetimetemplinecmd.TimeTempLine.ToString();
                        lvi.SubItems[2].Text = "设置成功";
                    }
                }
                else
                {
                    lvi.SubItems[1].Text = "";
                    lvi.SubItems[2].Text = GetCommResultTextDetail(t.LastCommResultState);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnWrite_Click(object sender, System.EventArgs e)
        {
            ArrayList list = new ArrayList();

            foreach (ListViewItem lvi in this.lvXg.Items)
            {
                if (lvi.Checked)
                {
                    list.Add(lvi.Tag as GRStation);
                }
            }

            if (list.Count > 0)
            {
                frmTimeTempPointSetting frmTtps = new frmTimeTempPointSetting();
                DialogResult            dr      = frmTtps.ShowDialog(this);
                if (dr == DialogResult.OK)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        GRStation grst = list[i] as GRStation;
                        //						GRReadTLCommand cmd = new GRReadTLCommand( grst );
                        //						GRWriteTLCommand cmd = new GRWriteTLCommand( grst,
                        //							null,
                        //							frmTtps.TimeTempLine );
                        GRWriteTimeTempLine cmd = new GRWriteTimeTempLine(grst,
                                                                          frmTtps.TimeTempLine);
                        Task task = new Task(cmd, new ImmediateTaskStrategy());

                        Singles.S.TaskScheduler.Tasks.AddFirstExectueTask(task);
                        task.AfterProcessReceived += new EventHandler(task_AfterProcessReceived);
                    }
                    MessageBox.Show("命令已提交", "提示",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("请先选择站点", "提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }