public bool OperDevice(int Addr, OnOffRelay bOnOff, string area, DeviceRunModel runModel, bool blRecord, IsWait isWait) { bool isok = false; try { bool blRet = false; bytOperXF[0] = (byte)Addr; bytOperXF[1] = 0x05; bytOperXF[2] = 0x00; bytOperXF[4] = (byte)bOnOff; bytOperXF[5] = 0x00; ushort crc = crc16.CalculateCrc16(bytOperXF, 6); bytOperXF[7] = (byte)(crc); bytOperXF[6] = (byte)(crc >> 8); byte[] bRece = new byte[8]; int iReceLen = serial.SendReceByte(bytOperXF, ref bRece, 10, isWait); //txt 发送 接受 txtLog.TxtWriteByte("XF.txt", "OnOff Send", bytOperXF, false); if (iReceLen > 0) { txtLog.TxtWriteByte("XF.txt", "OnOff Rece", bRece, true); } if (iReceLen == 8 && bRece[0] == bytOperXF[0] && bRece[1] == bytOperXF[1] && bRece[2] == bytOperXF[2] && bRece[3] == bytOperXF[3] && bRece[4] == bytOperXF[4] && bRece[5] == bytOperXF[5] && bRece[6] == bytOperXF[6] && bRece[7] == bytOperXF[7]) { blRet = true; if (blRecord) { EventType eventType = EventType.新风; string strContent = bOnOff.ToString(); if (eventType != EventType.初值) { NewEventRecord(eventType, area, runModel, strContent); } } } return(blRet); } catch (Exception ex) { } return(isok); }
/// <summary> /// 开启关闭 设备 空调、加热、除湿、新风 /// </summary> /// <param name="Addr">板地址</param> /// <param name="bOnOff">开启关闭4</param> /// <param name="bHotDehumi">继电器序号 加热为0 除湿为1 即继电器0 继电器1 </param> public bool OnOffDevice(int Addr, OnOffRelay bOnOff, DeviceRelayNo bRelayNo, string area, DeviceRunModel runModel, bool blRecord, IsWait isWait) { bool blRet = false; SendRelay[0] = (byte)Addr; SendRelay[1] = 0x05; SendRelay[2] = 0x00; SendRelay[3] = (byte)bRelayNo; SendRelay[4] = (byte)bOnOff; SendRelay[5] = 0x00; ushort crc = crc16.CalculateCrc16(SendRelay, 6); SendRelay[7] = (byte)(crc); SendRelay[6] = (byte)(crc >> 8); byte[] bRece = new byte[8]; int iReceLen = serial.SendReceByte(SendRelay, ref bRece, 10, isWait); //txt 发送 接受 txtLog.TxtWriteByte("Io.txt", "OnOff Send", SendRelay, false); if (iReceLen > 0) { txtLog.TxtWriteByte("Io.txt", "OnOff Rece", bRece, true); } if (iReceLen == 8 && bRece[0] == SendRelay[0] && bRece[1] == SendRelay[1] && bRece[2] == SendRelay[2] && bRece[3] == SendRelay[3] && bRece[4] == SendRelay[4] && bRece[5] == SendRelay[5] && bRece[6] == SendRelay[6] && bRece[7] == SendRelay[7]) { blRet = true; if (blRecord) { EventType eventType = EventType.初值; switch (bRelayNo) { case DeviceRelayNo.除湿: eventType = EventType.除湿; break; case DeviceRelayNo.烘干: eventType = EventType.烘干; break; case DeviceRelayNo.警灯: eventType = EventType.警灯; break; case DeviceRelayNo.新风: eventType = EventType.新风; break; } string strContent = bOnOff.ToString(); if (eventType != EventType.初值) { NewEventRecord(eventType, area, runModel, strContent); //commonCls.NewEnvirEventRecord(eventType, area, runModel, strContent); //if (NewEventShowEvent != null) //{ // NewEventShowEvent(new NewEventEventArgs(eventType, area, strContent, "", "")); //} } } } return(blRet); }