コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cmd"></param>
        private void ProcessReadTimeCmd(CommCmdBase cmd)
        {
            ReadTimeCommand rtcmd = cmd as ReadTimeCommand;

            Debug.Assert(rtcmd != null);

            ListViewItem lvi = lvXg.SelectedItems[0];

            lvi.SubItems[2].Text = string.Format(
                "{0}:{1}:{2}",
                rtcmd.Hour,
                rtcmd.Minute,
                rtcmd.Second
                );

            lvi.SubItems[3].Text = DateTime.Now.ToString();
        }
コード例 #2
0
        /// <summary>
        /// Read all xgstation Time or Date process
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void t_AfterProcessReceived(object sender, EventArgs e)
        {
            Task t = sender as Task;

            if (t.LastCommResultState == CommResultState.Correct)
            {
                XGStation xgst = t.CommCmd.Station as XGStation;
                if (t.CommCmd is ReadTimeCommand)
                {
                    ReadTimeCommand rtCmd  = t.CommCmd as ReadTimeCommand;
                    TimeSpan        xgTime = new TimeSpan(
                        0,
                        rtCmd.Hour,
                        rtCmd.Minute,
                        rtCmd.Second
                        );
                    // TODO: 2007-11-8 应先设置xgst.DtCollXgCtrlTime, 否则更新
                    //      xgCtrlTime时候,刷新listview控件是使用的是上次的采集时间
                    //
                    //xgst.XgCtrlTime = xgTime;
                    //xgst.DtCollXgCtrlTime = DateTime.Now;
                    xgst.DtCollXgCtrlTime = DateTime.Now;
                    xgst.XgCtrlTime       = xgTime;
                }
                else if (t.CommCmd is ReadDateCommand)
                {
                    ReadDateCommand rdCmd  = t.CommCmd as ReadDateCommand;
                    DateTime        xgDate = new DateTime(
                        // 2007-11-8 Modify rdCmd.Year,
                        //
                        2000 + rdCmd.Year,
                        rdCmd.Month,
                        rdCmd.Day
                        );
                    xgst.XgCtrlDate = xgDate;
                }
            }
        }