using Prism.Mvvm; using System; using TeamAAS_VP.Core.PLCs; using TeamAAS_VP.Enums; namespace TeamAAS_VP.Models { public class PlcInfo : BindableBase { private Guid _Id; public Guid Id { get { return _Id; } set { SetProperty(ref _Id, value); } } private string _Name; public string Name { get { return _Name; } set { SetProperty(ref _Name, value); } } private CommunicationType _CommunicationType; public CommunicationType CommunicationType { get { return _CommunicationType; } set { SetProperty(ref _CommunicationType, value); } } private string _EndpointUrl; public string EndpointUrl { get { return _EndpointUrl; } set { SetProperty(ref _EndpointUrl, value); } } #region Mitsubishi MC public string PlcIp { get; set; } = "192.168.0.10"; public int PlcPort { get; set; } = 5000; public bool PlcForwardEnabled { get; set; } = true; public string PlcPortDevice { get; set; } = "D101"; public string PlcQualityDevice { get; set; } = "D102"; public string PlcDataStartDevice { get; set; } = "D110"; public string PlcReadyBitDevice { get; set; } = "M100"; public string PlcOkBitDevice { get; set; } = "0"; public string PlcNgBitDevice { get; set; } = "0"; public string PlcReceiveBitDevice { get; set; } = "M103"; public string PlcHeartbeatDevice { get; set; } = "M200"; public int PlcHeartbeatIntervalMs { get; set; } = 1000; public string PlcBitTestDevice { get; set; } = "M3001"; public int PlcMaxDataBytes { get; set; } = 32; public PlcRfidMapping ToPlcMapping() { return new PlcRfidMapping { PortDevice = PlcPortDevice, QualityDevice = PlcQualityDevice, DataStartDevice = PlcDataStartDevice, ReadyBitDevice = PlcReadyBitDevice, OkBitDevice = PlcOkBitDevice, NgBitDevice = PlcNgBitDevice, ReceiveBitDevice = PlcReceiveBitDevice, MaxDataBytes = PlcMaxDataBytes }; } public void ApplyMcInfo(MCToPCInfo info) { if (info == null) return; PlcIp = info.PlcIp; PlcPort = info.PlcPort; PlcForwardEnabled = info.PlcForwardEnabled; PlcPortDevice = info.PlcPortDevice; PlcQualityDevice = info.PlcQualityDevice; PlcDataStartDevice = info.PlcDataStartDevice; PlcReadyBitDevice = info.PlcReadyBitDevice; PlcOkBitDevice = info.PlcOkBitDevice; PlcNgBitDevice = info.PlcNgBitDevice; PlcReceiveBitDevice = info.PlcReceiveBitDevice; PlcHeartbeatDevice = info.PlcHeartbeatDevice; PlcHeartbeatIntervalMs = info.PlcHeartbeatIntervalMs; PlcBitTestDevice = info.PlcBitTestDevice; PlcMaxDataBytes = info.PlcMaxDataBytes; } #endregion } }