Beispiel #1
0
        public GRWriteTwoPressChaCommand(GRStation st,
//            byte cyclePumpCtrlMode,
                                         CyclePumpMode cyclePumpCtrlMode,
                                         float pressChaSet,
                                         float backPressSet)
        {
            ArgumentChecker.CheckNotNull(st);
            this.Station = st;

            _cycPumpCtrlMode   = cyclePumpCtrlMode;
            _pressChaSetValue  = pressChaSet;
            _backPressSetValue = backPressSet;
        }
Beispiel #2
0

        
Beispiel #3
0
        public override CommResultState ProcessReceived(byte[] data)
        {
            CommResultState r = GRCommandMaker.CheckReceivedData(Station.Address,
                                                                 GRDef.DEVICE_TYPE,
                                                                 GRDef.FC_READ_SETTINGS,
                                                                 data);

            if (r == CommResultState.Correct)
            {
                byte[] innerDatas = GRCommandMaker.GetReceivedInnerData(data);

//                System.Diagnostics.Debug.Assert ( innerDatas != null &&
//                    innerDatas.Length == 10 );
                if (innerDatas.Length < 10)
                {
                    return(CommResultState.LengthError);
                }

                if (innerDatas [0] == GRDef.MC_TWOPRESS_CHA)
                {
                    _cycPumpCtrlMode = (CyclePumpMode)innerDatas[1];
                    //                    byte[] pressChaSetValue = new byte[ 4 ];
                    //                    byte[] backPressSetValue = new byte[ 4 ];
                    //                    Array.Copy( innerDatas,2, pressChaSetValue, 0, 4 );
                    //                    Array.Copy( innerDatas,6, backPressSetValue, 0, 4 );

                    _pressChaSetValue  = BitConverter.ToSingle(innerDatas, 2);
                    _backPressSetValue = BitConverter.ToSingle(innerDatas, 6);
                }
                else
                {
                    return(CommResultState.DataError);
                }
            }

            return(r);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnWriteCycle_Click(object sender, System.EventArgs e)
        {
            GRStation[] sts = this.GetSelectGRStations();
            if (sts.Length > 0)
            {
                CyclePumpMode mode        = CyclePumpMode.PID控制;
                float         pressChaSet = 0;

                frmCycleParam f  = new frmCycleParam();
                DialogResult  dr = f.ShowDialog(this);
                if (dr == DialogResult.OK)
                {
                    mode        = f.Mode;
                    pressChaSet = f.PressCha;

                    foreach (GRStation st in sts)
                    {
                        //					GRReadTwoPressChaCommand cmd = new GRReadTwoPressChaCommand( st );
                        GRWriteTwoPressChaCommand cmd = new GRWriteTwoPressChaCommand(st,
                                                                                      mode,
                                                                                      pressChaSet,
                                                                                      0);
                        Task task = new Task(cmd, new ImmediateTaskStrategy());
                        task.AfterProcessReceived += new EventHandler(task_AfterProcessReceived);
                        Singles.S.TaskScheduler.Tasks.AddFirstExectueTask(task);
                    }
                    MessageBox.Show("命令已提交", "提示",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("请选择站点", "提示",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }