/// <summary>
        /// 执行秒信号检测命令
        /// </summary>
        /// <param name="client">PcbTesterClient句柄</param>
        /// <param name="parameter">命令参数</param>
        /// <param name="context">不同命令之间的通信参数</param>
        /// <returns>检测结果</returns>
        public CommandResult Execute(PcbTesterClient client, CommandParameter parameter, CommandContext context)
        {
            var secondParameter = parameter as SecondSignalCalibrationParameter;

            while (true)
            {
                RelayControlHelper.On5V(client);

                if (secondParameter.EnableActivateClockSignal)  //如果需要激活表秒信号功能
                {
                    logger.Debug("Activate second signal...");
                    ActivateSecond(client, secondParameter);
                }

                logger.Debug("Start test second signal...");
                WriteResult writeResult = client.Write(Obis, string.Empty);

                //开始检测秒信号失败
                if (!writeResult.Success)
                {
                    string message = string.Format(
                        Resources.SecondSignalCalibrationCommand_WriteFailedMessageFormat,
                        this.Name,
                        writeResult.Error.ToString(),
                        string.Empty);

                    logger.Error(message);
                    throw new CommunicationException(message);
                }
                //等待发送读取秒信号检测结果命令
                System.Threading.Thread.Sleep((int)secondParameter.DelayTime);

                logger.Debug("Read test second signal result...");
                ReadResult readResult = client.Read(Obis, string.Empty); //发送读秒信号检测结果帧

                //检测结果为错误码
                if (!readResult.Success)
                {
                    string message = string.Format(
                        Resources.SecondSignalCalibrationCommand_ReadResultFailedMessageFormat,
                        this.Name,
                        readResult.Error.ToString(),
                        string.Empty);

                    logger.Error(message);
                    throw new CommunicationException(message);
                }
                decimal clockValue = ParseClockSignalResult(readResult.Data);

                if (clockValue == noValue) //无秒信号值
                {
                    logger.Error(Resources.SecondSignalCalibrationCommand_NoValue);
                    throw new CommunicationException(Resources.SecondSignalCalibrationCommand_NoValue);
                }

                //结果在误差范围内 正确结果
                if (secondParameter.IsWithinRange(clockValue))
                {
                    return(new CommandResult(true, readResult.Data));
                }

                //秒信号错误,不在误差范围内,判断是否需要补偿秒信号
                if (!secondParameter.EnableAutoClockCompensation) // 不需要补偿,返回错误结果
                {
                    string expectedValue = secondParameter.ExpectedValueRange;

                    return(new CommandResult(
                               false,
                               readResult.Data,
                               string.Format(
                                   Resources.SecondSignalCalibrationCommand_MeasureErrorMessageFormat,
                                   this.Name,
                                   secondParameter.ToString(),
                                   secondParameter.ExpectedValueRange,
                                   readResult.Data)));
                }

                logger.Debug("Compensate second signal...");
                //补偿秒信号
                CompensateClockSignal(client, secondParameter, clockValue);
            }
        }
        /// <summary>
        /// 执行脉冲检测命令
        /// </summary>
        /// <param name="client">PcbTesterClient句柄</param>
        /// <param name="parameter">命令参数</param>
        /// <param name="context">不同命令之间的通信参数</param>
        /// <returns>检测结果</returns>
        public CommandResult Execute(PcbTesterClient client, CommandParameter parameter, CommandContext context)
        {
            RelayControlHelper.On5V(client);

            StringBuilder sb = new StringBuilder();

            var relayControlPara = new RelayControlCommandParameter();

            relayControlPara.SelectedNumber = "20";

            RelayControlHelper.PulseRelayControl(client, RelayControlAction.OPEN);

            CommandResult commandResult = new CommandResult();

            for (int i = 0; i < 2; i++)
            {
                if (i == 0)
                {
                    relayControlPara.Action = RelayControlAction.OPEN;
                }
                else if (i == 1)
                {
                    relayControlPara.Action = RelayControlAction.CLOSE;
                }

                //控制脉冲检测对应继电器
                var relayControlCommand = new RelayControlCommand();
                commandResult = relayControlCommand.Execute(client, relayControlPara, context);

                //继电器操作失败
                if (!commandResult.Success)
                {
                    return(commandResult);
                }
                System.Threading.Thread.Sleep(500);

                //发送检测命令
                WriteResult writeResult = client.Write("0-0:199.128.1", string.Empty);

                //启动脉冲采集命令异常应答
                if (!writeResult.Success)
                {
                    string message = string.Format("{0};0x{1:X};{2}", this.Name, string.Empty, writeResult.Error.ToString());
                    logger.ErrorFormat("{0}", message);
                    throw new CommunicationException(message);
                }

                //等待1s发送读取脉冲检测结果命令
                System.Threading.Thread.Sleep(1000);
                ReadResult testResult = client.Read("0-0:199.128.1", string.Empty);

                //检测结果为错误码
                if (!testResult.Success)
                {
                    logger.ErrorFormat("{0}", testResult.Data);
                    throw new CommunicationException(testResult.Data);
                }

                commandResult.Success = true;
                sb.Append(testResult);
                if (i == 0)
                {
                    sb.Append(",");
                }
            }
            commandResult.Data = sb.ToString();
            return(commandResult);
        }