/// <summary> /// 写入PID /// </summary> /// <param name="IsSuccess"></param> public bool SendPid(string type, double value) { if (!IsTCPLink) { return(false); } try { if (type == "P") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.P); } else if (type == "I") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.I); } else if (type == "D") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.D); } _MASTER.WriteSingleRegister(_SlaveID, _StartAddress, (ushort)value); return(true); } catch (Exception ex) { Logger.Error(ex); return(false); } }
/// <summary> /// 获取风速显示 /// </summary> public double GetFSXS(ref bool IsSuccess) { double res = 0; lock (_MASTER) { try { ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.风速显示); ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); res = double.Parse((double.Parse(holding_register[0].ToString()) / 100).ToString()); res = Formula.GetValues(PublicEnum.DemarcateType.enum_风速传感器, float.Parse(res.ToString())); } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; Log.Error("ExportReport.Eexport", "message:获取风速显示" + ex.Message); MessageBox.Show("获取风速异常", "获取风速异常", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification ); System.Environment.Exit(0); } IsSuccess = true; } return(res); }
/// <summary> /// 读取差压显示 /// </summary> /// <param name="IsSuccess"></param> /// <returns></returns> public int GetCYXS(ref bool IsSuccess) { double res = 0; lock (_MASTER) { ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.差压显示); ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); res = double.Parse(holding_register[0].ToString()) / 100; if (int.Parse(holding_register[0].ToString()) > 1100) { res = -(65535 - int.Parse(holding_register[0].ToString())); } else { res = int.Parse(holding_register[0].ToString()); } res = Formula.GetValues(PublicEnum.DemarcateType.enum_差压传感器, float.Parse(res.ToString())); IsSuccess = true; } return(int.Parse(Math.Round(res, 0).ToString())); }
/// <summary> /// 发送抗风压负压预备 /// </summary> /// <param name="IsSuccess"></param> public bool SendKFYFYYB() { if (!IsTCPLink) { return(false); } try { var res = SendFYF(); if (!res) { return(false); } _StartAddress = BFMCommand.GetCommandDict(BFMCommand.风压负压预备); _MASTER.WriteSingleCoil(_StartAddress, false); _MASTER.WriteSingleCoil(_StartAddress, true); } catch (Exception ex) { Logger.Error(ex); return(false); } return(true); }
/// <summary> /// 获取风速显示 /// </summary> public double GetFSXS(ref bool IsSuccess) { double res = 0; if (!IsTCPLink) { IsSuccess = false; return(res); } try { lock (_MASTER) { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.风速显示); ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); var f = double.Parse((double.Parse(holding_register[0].ToString()) / 100).ToString()); res = Formula.GetValues(PublicEnum.DemarcateType.enum_风速传感器, float.Parse(f.ToString())); IsSuccess = true; } } catch (Exception ex) { IsSuccess = false; Logger.Error(ex); } return(res); }
/// <summary> /// 设置负安全 /// </summary> public bool SendFAQ(double value) { if (!IsTCPLink) { return(false); } try { var res = SendZYF(); if (!res) { return(false); } _StartAddress = BFMCommand.GetCommandDict(BFMCommand.安全数值); _MASTER.WriteSingleRegister(_SlaveID, _StartAddress, (ushort)(value)); _StartAddress = BFMCommand.GetCommandDict(BFMCommand.负安全); _MASTER.WriteSingleCoil(_StartAddress, false); _MASTER.WriteSingleCoil(_StartAddress, true); return(true); } catch (Exception ex) { Logger.Error(ex); return(false); } }
/// <summary> /// 读取正负压阀 /// </summary> public bool GetZFYF(ref bool z, ref bool f) { if (!IsTCPLink) { return(false); } try { lock (_MASTER) { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.正压阀); bool[] readCoils_z = _MASTER.ReadCoils(_StartAddress, _NumOfPoints); z = bool.Parse(readCoils_z[0].ToString()); _StartAddress = BFMCommand.GetCommandDict(BFMCommand.负压阀); bool[] readCoils_f = _MASTER.ReadCoils(_StartAddress, _NumOfPoints); f = bool.Parse(readCoils_f[0].ToString()); } } catch (Exception ex) { Logger.Error(ex); return(false); } return(true); }
/// <summary> /// 写入PID /// </summary> /// <param name="IsSuccess"></param> public void SendPid(ref bool IsSuccess, string type, double value) { try { if (IsTCPLink == false) { TcpOpen(); } else { ushort _StartAddress = 0; if (type == "P") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.P); } else if (type == "I") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.I); } else if (type == "D") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.D); } _MASTER.WriteSingleRegister(_SlaveID, _StartAddress, (ushort)value); } } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; Log.Error("ExportReport.Eexport", "message:设置Pid" + ex.Message + "\r\nsource:" + ex.Source + "\r\nStackTrace:" + ex.StackTrace); } }
/// <summary> /// 设置高压标0 /// </summary> public bool SendGYBD(bool logon = false) { if (!IsTCPLink) { return(false); } try { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.高压标0_交替型按钮); bool[] readCoils = _MASTER.ReadCoils(_SlaveID, _StartAddress, _NumOfPoints); if (readCoils[0]) { _MASTER.WriteSingleCoil(_StartAddress, false); } else { if (logon == false) { _MASTER.WriteSingleCoil(_StartAddress, true); } } } catch (Exception ex) { Logger.Error(ex); return(false); } return(true); }
/// <summary> /// 读取正压预备结束 /// </summary> /// <param name="IsSuccess"></param> public int GetFYYBJS(ref bool IsSuccess) { int res = 0; if (!IsTCPLink) { IsSuccess = false; return(res); } try { lock (_MASTER) { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.负压预备结束); ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); res = int.Parse(holding_register[0].ToString()); IsSuccess = true; } } catch (Exception ex) { IsSuccess = false; Logger.Error(ex); } return(res); }
/// <summary> /// 获取负压降100Pa是否开始计时 /// </summary> public bool Get_F_J100PaTimeStart(ref bool IsSuccess) { bool res = false; lock (_MASTER) { try { ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.负压_100TimeStart); ushort[] t = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); if (Convert.ToInt32(t[0]) > 20) { return(true); } else { return(false); } } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; Log.Error("ExportReport.Eexport", "message:获取负压降100Pa是否开始计时" + ex.Message); } } return(res); }
/// <summary> /// 获取温度显示 /// </summary> public double GetWDXS(ref bool IsSuccess) { double res = 0; lock (_MASTER) { try { ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.温度显示); ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); res = double.Parse((double.Parse(holding_register[0].ToString()) / 10).ToString()); res = Formula.GetValues(PublicEnum.DemarcateType.enum_温度传感器, float.Parse(res.ToString())); } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; // Log.Error("ExportReport.Eexport", "message:获取温度显示" + ex.Message); } IsSuccess = true; } return(res); }
/// <summary> /// 设置风速归零 /// </summary> public void SendFSGL(ref bool IsSuccess, bool logon = false) { try { ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.风速标0_交替型按钮); bool[] readCoils = _MASTER.ReadCoils(_SlaveID, _StartAddress, _NumOfPoints); if (readCoils[0]) { _MASTER.WriteSingleCoil(_StartAddress, false); } else { if (logon == false) { _MASTER.WriteSingleCoil(_StartAddress, true); } } } catch (Exception ex) { IsTCPLink = false; IsSuccess = false; } IsSuccess = true; }
/// <summary> /// 获取负压降100Pa是否开始计时 /// </summary> public bool Get_F_J100PaTimeStart() { if (!IsTCPLink) { return(false); } try { lock (_MASTER) { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.负压_100TimeStart); ushort[] t = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); if (Convert.ToInt32(t[0]) > 20) { return(true); } else { return(false); } } } catch (Exception ex) { Logger.Error(ex); return(false); } }
/// <summary> /// 发送水密开始 /// </summary> public bool SendSMXKS() { if (!IsTCPLink) { return(false); } try { var res = SendZYF(); if (!res) { return(false); } _StartAddress = BFMCommand.GetCommandDict(BFMCommand.水密性开始); _MASTER.WriteSingleCoil(_SlaveID, _StartAddress, false); _MASTER.WriteSingleCoil(_SlaveID, _StartAddress, true); return(true); } catch (Exception ex) { Logger.Error(ex); return(false); } }
/// <summary> /// 获取位移传感器3 /// </summary> public double GetDisplace3(ref bool IsSuccess) { double res = 0; try { if (!IsTCPLink) { IsSuccess = false; return(res); } lock (_MASTER) { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.位移3); ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); res = double.Parse((double.Parse(holding_register[0].ToString()) / 10).ToString()); //todo:位移标定 //res = Formula.GetValues(PublicEnum.DemarcateType.enum_大气压力传感器, float.Parse(res.ToString())); } IsSuccess = true; } catch (Exception ex) { Logger.Error(ex); IsSuccess = false; } return(res); }
/// <summary> /// 读取PID /// </summary> /// <param name="IsSuccess"></param> public int GetPID(string type, ref bool IsSuccess) { int res = 0; if (!IsTCPLink) { IsSuccess = false; return(res); } try { if (type == "P") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.P); } else if (type == "I") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.I); } else if (type == "D") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.D); } ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); res = int.Parse(holding_register[0].ToString()); IsSuccess = true; } catch (Exception ex) { IsSuccess = false; Logger.Error(ex); } return(res); }
/// <summary> /// 设置风机控制 /// </summary> public void SendFJKZ(double value, ref bool IsSuccess) { try { ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.风机控制); _MASTER.WriteSingleRegister(_SlaveID, _StartAddress, (ushort)(value)); } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; Log.Error("ExportReport.Eexport", "message:设置风机控制" + ex.Message); } IsSuccess = true; }
/// <summary> /// 发送水密性下一级 /// </summary> public void SendSMXXYJ(ref bool IsSuccess) { try { ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.一级); _MASTER.WriteSingleCoil(_SlaveID, _StartAddress, false); _MASTER.WriteSingleCoil(_SlaveID, _StartAddress, true); } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; Log.Error("ExportReport.Eexport", "message:下一级" + ex.Message); } IsSuccess = true; }
/// <summary> /// 发送水密性下一级 /// </summary> public bool SendSMXXYJ() { if (!IsTCPLink) { return(false); } try { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.一级); _MASTER.WriteSingleCoil(_SlaveID, _StartAddress, false); _MASTER.WriteSingleCoil(_SlaveID, _StartAddress, true); return(true); } catch (Exception ex) { Logger.Error(ex); return(false); } }
/// <summary> /// 读取水密预备结束 /// </summary> /// <param name="IsSuccess"></param> public int GetSMYBJS(ref bool IsSuccess) { int res = 0; try { ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.水密预备结束); ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); res = int.Parse(holding_register[0].ToString()); } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; Log.Error("ExportReport.Eexport", "message:水密预备结束" + ex.Message); } IsSuccess = true; return(res); }
/// <summary> /// 获取正压预备时,设定压力值 /// </summary> public double GetZYYBYLZ(ref bool IsSuccess, string type) { double res = 0; if (!IsTCPLink) { IsSuccess = false; return(res); } try { lock (_MASTER) { if (type == "ZYYB") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.正压预备_设定值); } else if (type == "ZYKS") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.正压开始_设定值); } else if (type == "FYYB") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.负压预备_设定值); } else if (type == "FYKS") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.负压开始_设定值); } ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); res = double.Parse((double.Parse(holding_register[0].ToString())).ToString()); IsSuccess = true; } } catch (Exception ex) { IsSuccess = false; Logger.Error(ex); } return(res); }
/// <summary> /// 读取负压开始结束 /// </summary> /// <param name="IsSuccess"></param> public double GetFYKSJS(ref bool IsSuccess) { double res = 0; try { ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.负压开始结束); ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); res = double.Parse(holding_register[0].ToString()); Log.Info("", res.ToString()); } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; Log.Error("ExportReport.Eexport", "message:读取正压开始结束" + ex.Message); } IsSuccess = true; return(res); }
/// <summary> /// 设置负压阀 /// </summary> /// <param name="IsSuccess"></param> public void SendFYF(ref bool IsSuccess) { lock (_MASTER) { try { ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.正压阀); _MASTER.WriteSingleCoil(_StartAddress, false); _StartAddress = BFMCommand.GetCommandDict(BFMCommand.负压阀); _MASTER.WriteSingleCoil(_StartAddress, true); } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; Log.Error("ExportReport.Eexport", "message:设置负压阀" + ex.Message); } } IsSuccess = true; }
/// <summary> /// 发送负压开始 /// </summary> public void SendFYKS(ref bool IsSuccess) { try { SendFYF(ref IsSuccess); if (!IsSuccess) { return; } ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.负压开始); _MASTER.WriteSingleCoil(_SlaveID, _StartAddress, false); _MASTER.WriteSingleCoil(_SlaveID, _StartAddress, true); } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; Log.Error("ExportReport.Eexport", "message:发送负压开始" + ex.Message); } IsSuccess = true; }
/// <summary> /// 设置水密依次加压 /// </summary> public void SendSMYCJY(double value, ref bool IsSuccess) { try { SendZYF(ref IsSuccess); ushort _StartAddress = BFMCommand.GetCommandDict(BFMCommand.以此加压数值); _MASTER.WriteSingleRegister(_SlaveID, _StartAddress, (ushort)(value)); _StartAddress = BFMCommand.GetCommandDict(BFMCommand.以此加压); _MASTER.WriteSingleCoil(_StartAddress, false); _MASTER.WriteSingleCoil(_StartAddress, true); } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; Log.Error("ExportReport.Eexport", "message:设置水密依次加压" + ex.Message); } IsSuccess = true; }
/// <summary> /// 设置风机控制 /// </summary> public bool SendFJKZ(double value) { if (!IsTCPLink) { return(false); } try { lock (_MASTER) { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.风机控制); _MASTER.WriteSingleRegister(_SlaveID, _StartAddress, (ushort)(value)); } } catch (Exception ex) { Logger.Error(ex); return(false); } return(true); }
/// <summary> /// 急停 /// </summary> public bool Stop() { if (!IsTCPLink) { return(false); } try { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.急停); _MASTER.WriteSingleCoil(_StartAddress, false); _MASTER.WriteSingleCoil(_StartAddress, true); return(true); } catch (Exception ex) { Logger.Error(ex); return(false); // System.Environment.Exit(0); } }
/// <summary> /// 读取水密预备设定压力 /// </summary> /// <param name="IsSuccess"></param> public int GetSMYBSDYL(ref bool IsSuccess, string type) { int res = 0; if (!IsTCPLink) { IsSuccess = false; return(res); } try { if (type == "SMYB") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.水密预备_设定值); } else if (type == "SMKS") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.水密开始_设定值); } else if (type == "YCJY") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.水密依次加压_设定值); } else if (type == "XYJ") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.水密开始_设定值); } ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); res = int.Parse(holding_register[0].ToString()); IsSuccess = true; } catch (Exception ex) { IsSuccess = false; Logger.Error(ex); } return(res); }
/// <summary> /// 读取PID /// </summary> /// <param name="IsSuccess"></param> public int GetPID(ref bool IsSuccess, string type) { int res = 0; try { if (IsTCPLink == false) { TcpOpen(); } else { ushort _StartAddress = 0; if (type == "P") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.P); } else if (type == "I") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.I); } else if (type == "D") { _StartAddress = BFMCommand.GetCommandDict(BFMCommand.D); } ushort[] holding_register = _MASTER.ReadHoldingRegisters(_SlaveID, _StartAddress, _NumOfPoints); res = int.Parse(holding_register[0].ToString()); } } catch (Exception ex) { IsSuccess = false; IsTCPLink = false; Log.Error("ExportReport.Eexport", "message:读取Pid" + ex.Message + "\r\nsource:" + ex.Source + "\r\nStackTrace:" + ex.StackTrace); } IsSuccess = true; return(res); }