public void OnExecuteResultCompleted(MeasureExecuteResultEventArgs obj)
        {
            Action <MeasureExecuteResultEventArgs> handler = ExecuteResultCompleted;

            if (handler != null)
            {
                handler(obj);
            }
        }
예제 #2
0
        private void OnReceiveExecuteResult(MeasureExecuteResultEventArgs pArgs)
        {
            Action <MeasureExecuteResultEventArgs> handler = ExecuteResultCompleted;

            if (handler != null)
            {
                handler(pArgs);
            }
        }
예제 #3
0
        private void ReceiveExecuteResult(object pObj)
        {
            try
            {
                RmtpDataFrame pDataFrame = pObj as RmtpDataFrame;

                var args   = new MeasureExecuteResultEventArgs();
                var result = RmtpDataFrame.GetDataFrame <RmtpExecuteResult>(pDataFrame);

                if (result.Result != ExecuteResult.SUCCESSED)
                {
                    if (result.ErrorCode != ExecuteResultErrorCode.已停止)
                    {
                        args.Error = result.ErrorMessage;
                        OnReceiveExecuteResult(args);
                    }

                    throw new Exception();
                }

                _executeresultNum++;
                //通道指令,发送测量序号
                if (_executeresultNum == 1)
                {
                    RmtpManager.Rmtp.ChannelCommand(_channelId, 1);
                }
                //下参数指令
                else if (_executeresultNum == 2)
                {
                    RmtpManager.Rmtp.ExecuteCommand(RmtpCommand.PARAM, new object[] { _parameter.ToParameterList() });
                }
                //开始测量
                else if (_executeresultNum == 3)
                {
                    if (StartMeasureCompleted != null)
                    {
                        StartMeasureCompleted();
                    }
                }
                //停止测量
                else if (_executeresultNum == 4)
                {
                    RmtpManager.Rmtp.Close(); //关闭socket连接
                    _executeresultNum = 0;

                    if (StopMeasureCompleted != null)
                    {
                        StopMeasureCompleted();
                    }
                }
            }
            catch (Exception)
            {
                RmtpManager.Rmtp.Close(); //关闭socket连接
                _executeresultNum = 0;
            }
        }