using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AUCMA.STORE.DeviceAdapter { public enum CommType { RJ45 = 1, //网口 RS232 = 2, //com口 RS485 = 3, //485接口 }; public enum DeviceType { /// /// 1200系列 /// S1200 = 1, /// /// 300系列 /// S300 = 2, /// /// 400系列 /// S400 = 3, /// /// 1500系列PLC /// S1500 = 4, /// /// 200的smart系列 /// S200Smart = 5, /// /// 200系统,需要额外配置以太网模块 /// S200 = 6 }; /// /// 设备层接口 /// public interface IDeviceAdapter { /// /// 设备初始化 /// /// true成功,false失败 /// 通讯类型 1,RJ45 2,串口。 /// 连接字符串 当iCommType为1时,pUrl格式“192.168.1.100:23”,为2时,pUrl格式为:“Com1:9600“ /// 详见DeviceType bool Device_Init(CommType iCommType, string pUrl, UInt16 iDeviceId, string deviceType); /// /// 连接设备 /// /// true成功,false失败 bool Device_Connect(); /// /// 重新连接设备 /// /// true成功,false失败 bool Device_ReConnect(); /// /// 设备销毁 /// void Device_Destroy(); /// /// 设备状态 /// /// true正常,false异常 bool Device_GetState(); bool ReadBoolByAddress(string address); string ReadStringByAddress(string address); int ReadInt16ByAddress(string address); int ReadInt32ByAddress(string address); bool WriteInt16ByAddress(string address, string value); bool WriteInt32ByAddress(string address, int value); bool WriteStringByAddress(string address, string value); bool WriteByteByAddress(string address, byte[] bytes); } }