diff --git a/Thermo.Active.Config/Config/IOConfig.xml b/Thermo.Active.Config/Config/IOConfig.xml index 57e7bed7..6974bff5 100644 --- a/Thermo.Active.Config/Config/IOConfig.xml +++ b/Thermo.Active.Config/Config/IOConfig.xml @@ -17,6 +17,7 @@ 301 405 A32.5 + true 3 diff --git a/Thermo.Active.Config/Config/IOConfigValidator.xsd b/Thermo.Active.Config/Config/IOConfigValidator.xsd index 19e57569..a5649327 100644 --- a/Thermo.Active.Config/Config/IOConfigValidator.xsd +++ b/Thermo.Active.Config/Config/IOConfigValidator.xsd @@ -15,6 +15,7 @@ + diff --git a/Thermo.Active.Config/ServerConfigController.cs b/Thermo.Active.Config/ServerConfigController.cs index 32e91330..de8b6946 100644 --- a/Thermo.Active.Config/ServerConfigController.cs +++ b/Thermo.Active.Config/ServerConfigController.cs @@ -518,7 +518,8 @@ namespace Thermo.Active.Config Position = x.Element("position") != null ? x.Element("position").Value : "0", Page = x.Element("page") != null ? x.Element("page").Value : "", Wire = x.Element("wire") != null ? x.Element("wire").Value : "", - Profinet = x.Element("profinet") != null ? x.Element("profinet").Value : "" + Profinet = x.Element("profinet") != null ? x.Element("profinet").Value : "", + DisableForce = x.Element("disableForce") != null ? Convert.ToBoolean(x.Element("disableForce").Value): false }) .ToList(); } diff --git a/Thermo.Active.Model/ConfigModels/IOConfigModel.cs b/Thermo.Active.Model/ConfigModels/IOConfigModel.cs index e8c6a2b0..2cfc288c 100644 --- a/Thermo.Active.Model/ConfigModels/IOConfigModel.cs +++ b/Thermo.Active.Model/ConfigModels/IOConfigModel.cs @@ -5,18 +5,19 @@ namespace Thermo.Active.Model.ConfigModels { public class IOConfigModel { - public int Id { get; set; } =0; public TACT_IO_TYPE Category { get; set; } + public int Id { get; set; } =0; public string Bank { get; set; } = "0"; - public string Position { get; set; } = ""; + public string Position { get; set; } = "0"; public string Page { get; set; } = ""; public string Wire { get; set; } = ""; public string Profinet { get; set; } = ""; + public bool DisableForce { get; set; } = false; public string Label { get { - string answ = $"LBL_IO_{Id}_{Bank}_{Position}"; + string answ = $"LBL_IO_{Category}_{Id}"; return answ; } } diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs new file mode 100644 index 00000000..1dd7b908 --- /dev/null +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Thermo.Active.Model.DTOModels.ThIO +{ + public class DTOChannelsIOModel + { + public List DI { get; set; } + public List DO { get; set; } + public List AI { get; set; } + public List AO { get; set; } + } + public class DigitalIN : IoBaseConf + { + public bool Value { get; set; } = false; + + public override bool Equals(object obj) + { + if (!(obj is DigitalIN item)) + return false; + + if (Value != item.Value) + return false; + + return base.Equals((IoBaseConf)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + public class DigitalOUT : DigitalIN + { + public bool ForceEnabled { get; set; } = false; + public bool ForceZero { get; set; } = false; + public bool ForceOne { get; set; } = false; + public bool IsForced { get; set; } = false; + + public override bool Equals(object obj) + { + if (!(obj is DigitalOUT item)) + return false; + + if (ForceEnabled != item.ForceEnabled) + return false; + if (ForceZero != item.ForceZero) + return false; + if (ForceOne != item.ForceOne) + return false; + if (IsForced != item.IsForced) + return false; + + return base.Equals((DigitalIN)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + public class AnalogIN : IoBaseConf + { + public double Value { get; set; } = 0; + + public override bool Equals(object obj) + { + if (!(obj is AnalogIN item)) + return false; + + if (Value != item.Value) + return false; + + return base.Equals((IoBaseConf)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + + public class AnalogOUT : AnalogIN + { + public bool ForceEnabled { get; set; } = false; + public double ForcedValue { get; set; } = 0; + public bool IsForced { get; set; } = false; + + public override bool Equals(object obj) + { + if (!(obj is AnalogOUT item)) + return false; + + if (ForceEnabled != item.ForceEnabled) + return false; + if (ForcedValue != item.ForcedValue) + return false; + if (IsForced != item.IsForced) + return false; + + return base.Equals((AnalogIN)obj); + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + + public class IoBaseConf + { + public int Id { get; set; } = 0; + public int Bank { get; set; } = 0; + public string Position { get; set; } = ""; + public string Page { get; set; } = ""; + public string Wire { get; set; } = ""; + public string Profinet { get; set; } = ""; + public string Label { get; set; } = ""; + public bool Visible { get; set; } = false; + + + public override bool Equals(object obj) + { + if (!(obj is IoBaseConf item)) + return false; + + if (Id != item.Id) + return false; + if (Bank != item.Bank) + return false; + if (Position != item.Position) + return false; + if (Page != item.Page) + return false; + if (Wire != Wire) + return false; + if (Profinet != item.Profinet) + return false; + if (Label != item.Label) + return false; + if (Visible != item.Visible) + return false; + + return true; + } + /// + /// Hash gen + /// + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + } + + + +} diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOIOConfigModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOIOConfigModel.cs deleted file mode 100644 index 9690d6f4..00000000 --- a/Thermo.Active.Model/DTOModels/ThIO/DTOIOConfigModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Thermo.Active.Model.DTOModels.ThIO -{ - public class DTOIOConfigModel - { - public int Bank { get; set; } = 0; - public int Bit { get; set; } = 0; - public string Page { get; set; } = ""; - public string Wire { get; set; } = ""; - public string Profinet { get; set; } = ""; - } -} diff --git a/Thermo.Active.Model/Thermo.Active.Model.csproj b/Thermo.Active.Model/Thermo.Active.Model.csproj index 5ef98cd0..83f412a9 100644 --- a/Thermo.Active.Model/Thermo.Active.Model.csproj +++ b/Thermo.Active.Model/Thermo.Active.Model.csproj @@ -114,7 +114,7 @@ - + diff --git a/Thermo.Active.NC/NcAdapter.cs b/Thermo.Active.NC/NcAdapter.cs index 1b85a73c..109647a9 100644 --- a/Thermo.Active.NC/NcAdapter.cs +++ b/Thermo.Active.NC/NcAdapter.cs @@ -2167,6 +2167,57 @@ namespace Thermo.Active.NC return libraryError; } + + public CmsError ReadIO(out Dictionary currModules) + { + CmsError libraryError = NO_ERROR; + currModules = new Dictionary(); + DTOModulesBlock currVal = new DTOModulesBlock(); + + // read and return warmers data + if (NcConfig.NcVendor == NC_VENDOR.S7NET) + { + Dictionary currModBlock = new Dictionary(); + libraryError = numericalControl.PLC_RModulesBlockList(false, ref currModBlock); + + foreach (var item in ModBlockConfig) + { + try + { + ThermoModels.ModuleBlock currModule = currModBlock[item.Id]; + currVal = new DTOModulesBlock() + { + Id = item.Id, + Label = item.Label, + Type = item.Type, + Section = item.Section, + IdParam = item.IdParam, + ShowDelay = item.ShowDelay, + Priority = item.Priority, + ScaleFactor = item.ScaleFactor, + NumDec = item.NumDec, + ActualDelay = (double)currModule.ActualDelay / item.ScaleFactor, + ActualDuration = (double)currModule.ActualDuration / item.ScaleFactor, + EstimatedDelay = (double)currModule.EstimatedDelay / item.ScaleFactor, + EstimatedDuration = (double)currModule.EstimatedDuration / item.ScaleFactor, + PrecedingId = currModule.PrecedingId, + Visible = currModule.Visible, + Running = currModule.Running, + HasError = currModule.HasError, + Terminated = currModule.Terminated, + Category = item.Category, + SubCategory_1 = item.SubCategory_1, + SubCategory_2 = item.SubCategory_2 + }; + currModules.Add(item.Id, currVal); + } + catch + { } + } + } + return libraryError; + } + /// /// Legge tutti i parametri della ricetta ///