using Models.Const; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SamplePre.ProcessBll.BLL { public class CommunicationBll { /// /// 读取PLC状态数据-数组 /// /// /// /// /// public ushort[] ReadSateData(int Dbno, int start, int lenth) { if (SystemConst.ProtocolType == Communication.CommProtocolType.S7) { //读取下位机状态 ushort[] data1 = SystemConst.MasterPLC.ReadArraysShort(Dbno, start, lenth); return data1; } //这里应该增加一个协议数据解析层,解析后的格式返回给UI,后续完善 /// return null; } /// /// 写入plc指令,字节数组 /// /// /// /// /// /// public bool WritePlcData(int Dbno, int start, T[] bytes) { bool val = false; //if (SystemConst.ProtocolType == Communication.CommProtocolType.S7) //{ //写入PLC val = SystemConst.MasterPLC.WriteArraysBtye(Dbno, start, bytes); //} //else if (SystemConst.ProtocolType == Communication.CommProtocolType.ModbusTcp) //{ // //写入PLC // val = SystemConst.MasterPLC.WriteArraysBtye(Dbno, start, bytes); //} return val; } /// /// 写plc数据,单数据 /// /// /// /// public bool WriteSingleData(string Dbno, object obj) { //写入PLC var val = SystemConst.MasterPLC.WriteSingleData(Dbno, obj); return val; } } }