/// <summary> /// 补偿秒信号 /// </summary> /// <param name="client">PcbTesterClient句柄</param> /// <param name="parameter">秒信号参数</param> /// <param name="clockValue"></param> private void CompensateClockSignal(PcbTesterClient client, SecondSignalCalibrationParameter parameter, decimal clockValue) { //1.开透明通道 MeterCommunicationCommand communicationCommand = new MeterCommunicationCommand(); var openResult = MeterCommunicationHelper.OpenTransparentChannel( client, new MeterCommunicationCommandParameter( parameter.ComPort, parameter.BaudRate, parameter.DataBits, parameter.Parity)); //2.发送读部标信息帧 byte[] resultBuffer = client.Write(MinistryStandardFrames.ReadMeterMessage, true); //3.处理表回的信息帧 int b = resultBuffer[14] - 0x33; if ((b & 0x40) != 0) { b = b | 0x80; } int complementCode = (int)ComplementCodeHelper.CalcComplementCode(clockValue); int sendComplementCode = (b + complementCode) & 0x7F; //秒信号无法修补 if (!((0x00 <= sendComplementCode && sendComplementCode <= 0x0A) || (0x70 <= sendComplementCode && sendComplementCode <= 0x7F))) { MeterCommunicationHelper.ExitTransparentChannel(client); //退出透明通道 return; } //4.若能补偿,则发送补偿秒信号的帧 string clockChipFrame = GetWriteClockChipFrame((byte)sendComplementCode); //写时钟芯片信号帧 client.Write(clockChipFrame, true); string compensateClockSignalFrame = GetCompensateClockSignalFrame((byte)sendComplementCode); client.Write(clockChipFrame, true); MeterCommunicationHelper.ExitTransparentChannel(client); //退出透明通道 }
/// <summary> /// 激活表的秒信号 /// </summary> /// <returns></returns> private void ActivateSecond(PcbTesterClient client, SecondSignalCalibrationParameter parameter) { //1.开透明通道 MeterCommunicationCommand communicationCommand = new MeterCommunicationCommand(); var communicationParamter = new MeterCommunicationCommandParameter( parameter.ComPort, parameter.BaudRate, parameter.DataBits, parameter.Parity); MeterCommunicationHelper.OpenTransparentChannel(client, communicationParamter); //2.发送激活秒信号帧 client.Write(MinistryStandardFrames.ActivateSecond, true); //激活秒信号帧 //3.发完退出透明通道 MeterCommunicationHelper.ExitTransparentChannel(client); //退出透明通道 }