diff --git a/Thermo.Active.Config/Config/IOConfigValidator.xsd b/Thermo.Active.Config/Config/IOConfigValidator.xsd index a5649327..2f1a68ab 100644 --- a/Thermo.Active.Config/Config/IOConfigValidator.xsd +++ b/Thermo.Active.Config/Config/IOConfigValidator.xsd @@ -15,7 +15,7 @@ - + diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs index 1dd7b908..5e62404b 100644 --- a/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs +++ b/Thermo.Active.Model/DTOModels/ThIO/DTOChannelsIOModel.cs @@ -38,7 +38,7 @@ namespace Thermo.Active.Model.DTOModels.ThIO } public class DigitalOUT : DigitalIN { - public bool ForceEnabled { get; set; } = false; + public bool ForceEnabled { get; set; } = true; public bool ForceZero { get; set; } = false; public bool ForceOne { get; set; } = false; public bool IsForced { get; set; } = false; @@ -94,7 +94,7 @@ namespace Thermo.Active.Model.DTOModels.ThIO public class AnalogOUT : AnalogIN { - public bool ForceEnabled { get; set; } = false; + public bool ForceEnabled { get; set; } = true; public double ForcedValue { get; set; } = 0; public bool IsForced { get; set; } = false; @@ -125,13 +125,13 @@ namespace Thermo.Active.Model.DTOModels.ThIO 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 string Bank { get; set; } = "0"; + public string Position { get; set; } = "0"; + public string Page { get; set; } = "0"; + public string Wire { get; set; } = "0"; + public string Profinet { get; set; } = "0"; + public string Label { get; set; } = "LBL"; + public bool Visible { get; set; } = true; public override bool Equals(object obj) diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTODigInModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTODigInModel.cs deleted file mode 100644 index be5fcba8..00000000 --- a/Thermo.Active.Model/DTOModels/ThIO/DTODigInModel.cs +++ /dev/null @@ -1,47 +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 DTODigInModel - { - public int Block { get; set; } = 0; - public int Num { get; set; } = 0; - public string Page { get; set; } = "0"; - public string Wire { get; set; } = "0"; - public string Profinet { get; set; } = ""; - public string Label { get; set; } = ""; - public bool Value { get; set; } = false; - - public override bool Equals(object obj) - { - if (!(obj is DTODigInModel item)) - return false; - - if (Block != item.Block) - return false; - if (Num != item.Num) - 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 (Value != item.Value) - return false; - - return true; - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - } -} diff --git a/Thermo.Active.Model/DTOModels/ThIO/DTODigOutModel.cs b/Thermo.Active.Model/DTOModels/ThIO/DTODigOutModel.cs deleted file mode 100644 index 4f1e84cf..00000000 --- a/Thermo.Active.Model/DTOModels/ThIO/DTODigOutModel.cs +++ /dev/null @@ -1,56 +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 DTODigOutModel - { - public int Block { get; set; } = 0; - public int Num { get; set; } = 0; - public string Page { get; set; } = "0"; - public string Wire { get; set; } = "0"; - public string Profinet { get; set; } = ""; - public string Label { get; set; } = ""; - public bool Value { 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 DTODigOutModel item)) - return false; - - if (Block != item.Block) - return false; - if (Num != item.Num) - 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 (Value != item.Value) - return false; - if (ForceZero != item.ForceZero) - return false; - if (ForceOne != item.ForceOne) - return false; - if (IsForced != item.IsForced) - return false; - - return true; - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - } -} diff --git a/Thermo.Active.Model/Thermo.Active.Model.csproj b/Thermo.Active.Model/Thermo.Active.Model.csproj index 83f412a9..3e779827 100644 --- a/Thermo.Active.Model/Thermo.Active.Model.csproj +++ b/Thermo.Active.Model/Thermo.Active.Model.csproj @@ -113,9 +113,7 @@ - - diff --git a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs index 10ae29d5..32ce7a7f 100644 --- a/Thermo.Active/Controllers/WebApi/ConfigurationController.cs +++ b/Thermo.Active/Controllers/WebApi/ConfigurationController.cs @@ -5,6 +5,7 @@ using Thermo.Active.Database.Controllers; using Thermo.Active.Model.ConfigModels; using Thermo.Active.Model.DTOModels; using Thermo.Active.Model.DTOModels.AlarmModels; +using Thermo.Active.Model.DTOModels.ThIO; using Thermo.Active.Model.DTOModels.ThProd; using Thermo.Active.Model.DTOModels.ThRecipe; using static Thermo.Active.Config.ServerConfig; @@ -124,6 +125,68 @@ namespace Thermo.Active.Controllers.WebApi return Ok(recipeConfig); } +#if false + [Route("IO"), HttpGet] + public IHttpActionResult GetIOConfig() + { + DTOChannelsIOModel ChannelsIO = new DTOChannelsIOModel(); + // leggo i 4 tipi di oggetti e popolo + List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).Select(x => new DigitalIN() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listDO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DO).Select(x => new DigitalOUT() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listAI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AI).Select(x => new AnalogIN() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listAO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AO).Select(x => new AnalogOUT() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + + // assegno! + ChannelsIO.DI = listDI; + ChannelsIO.DO = listDO; + ChannelsIO.AI = listAI; + ChannelsIO.AO = listAO; + + // restituisco + return Ok(ChannelsIO); + } +#endif + [Route("thermoProd"), HttpGet] public IHttpActionResult GetThermoProdConfig() { diff --git a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs index adac2447..07c7451f 100644 --- a/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs +++ b/Thermo.Active/Controllers/WebApi/UnderTheHoodController.cs @@ -15,6 +15,7 @@ using TeamDev.SDK.MVVM; using Thermo.Active.Config; using Thermo.Active.Database.Controllers; using Thermo.Active.Model.DTOModels; +using Thermo.Active.Model.DTOModels.ThIO; using Thermo.Active.Model.DTOModels.ThRecipe; using Thermo.Active.Model.DTOModels.ThWarmers; using Thermo.Active.NC; @@ -52,5 +53,65 @@ namespace Thermo.Active.Controllers.WebApi return Ok(machineLog); } + + [Route("channels_io"), HttpGet] + public IHttpActionResult GetChannelsIO() + { + DTOChannelsIOModel ChannelsIO = new DTOChannelsIOModel(); + // leggo i 4 tipi di oggetti e popolo + List listDI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DI).Select(x => new DigitalIN() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listDO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.DO).Select(x => new DigitalOUT() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listAI = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AI).Select(x => new AnalogIN() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + List listAO = IOConfig.Where(x => x.Category == Model.Constants.TACT_IO_TYPE.AO).Select(x => new AnalogOUT() + { + Id = x.Id, + Bank = x.Bank, + Position = x.Position, + //Page = x.Category.ToString(), + Page = x.Page, + Wire = x.Wire, + Profinet = x.Profinet, + Label = x.Label.Replace("__", "_").Replace("__", "_").ToLower() + }).ToList(); + + // assegno! + ChannelsIO.DI = listDI; + ChannelsIO.DO = listDO; + ChannelsIO.AI = listAI; + ChannelsIO.AO = listAO; + + // restituisco + return Ok(ChannelsIO); + } } } \ No newline at end of file