using S7.Net; using System; using System.Collections.Generic; using System.Linq; using System.Text; using Prism.Mvvm; using System.Threading.Tasks; using S7NetModule.S7; namespace S7NetModule.Model { public class S7PlcModel:BindableBase { public S7Plc plcClient=null; // PLC的IP地址和端口号 private string ipAddress= "192.168.1.100"; public string IpAddress { get { return ipAddress; } set { SetProperty(ref ipAddress, value); } } private int port = 102; // 机架号,通常为0 public int Port { get { return port; } set { SetProperty(ref port, value); } } private int rack = 0; // 机架号,通常为0 public int Rack { get { return rack; } set { SetProperty(ref rack, value); } } private int slot= 1 ;// 槽号,根据你的PLC配置设置 public int Slot { get { return slot; } set { SetProperty(ref slot, value); } } private CpuType cpuType= CpuType.S7200;// CPU类型,2代表S7-300/400系列CPU public CpuType CpuType { get { return cpuType; } set { SetProperty(ref cpuType, value); } } private int timeout = 5000; // 超时时间,单位毫秒 public int Timeout { get { return timeout; } set { SetProperty(ref timeout, value); } } } }