diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll index 77c4c3f2..8e397114 100644 Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ diff --git a/Step.Config/Config/serverConfig.xml b/Step.Config/Config/serverConfig.xml index 9ed5e08e..ec1bcc1e 100644 --- a/Step.Config/Config/serverConfig.xml +++ b/Step.Config/Config/serverConfig.xml @@ -1,9 +1,9 @@ - OSAI + DEMO true - 192.168.157.2 + localhost 8080 Ares 37 OF diff --git a/Step.Config/Config/toolManagerConfig.xml b/Step.Config/Config/toolManagerConfig.xml index 55d616ad..d8a1dc71 100644 --- a/Step.Config/Config/toolManagerConfig.xml +++ b/Step.Config/Config/toolManagerConfig.xml @@ -17,36 +17,36 @@ - Test - Ita + Cooling + Raffreddamento - Test - Ita + Cooling 1 + Raffreddamento 1 - Test - Ita + Cooling 2 + Raffreddamento 2 - Test - Ita + Cooling 3 + Raffreddamento 3 - Test - Ita + Cooling 4 + Raffreddamento 4 - Test - Ita + Cooling 5 + Raffreddamento 5 - Test - Ita + Cooling 6 + Raffreddamento 6 - Test - Ita + Cooling 7 + Raffreddamento 7 \ No newline at end of file diff --git a/Step.Config/ServerConfigController.cs b/Step.Config/ServerConfigController.cs index 7d373eee..10624ea8 100644 --- a/Step.Config/ServerConfigController.cs +++ b/Step.Config/ServerConfigController.cs @@ -366,16 +366,16 @@ namespace Step.Config Cooling3 = x.Element("cooling3").Elements().ToDictionary( y => y.Attribute("langKey").Value, y => y.Value ), - Cooling4LocalizedNames = x.Element("cooling4").Elements().ToDictionary( + Cooling4 = x.Element("cooling4").Elements().ToDictionary( y => y.Attribute("langKey").Value, y => y.Value ), - Cooling5LocalizedNames = x.Element("cooling5").Elements().ToDictionary( + Cooling5 = x.Element("cooling5").Elements().ToDictionary( y => y.Attribute("langKey").Value, y => y.Value ), - Cooling6LocalizedNames = x.Element("cooling6").Elements().ToDictionary( + Cooling6 = x.Element("cooling6").Elements().ToDictionary( y => y.Attribute("langKey").Value, y => y.Value ), - Cooling7LocalizedNames = x.Element("cooling7").Elements().ToDictionary( + Cooling7 = x.Element("cooling7").Elements().ToDictionary( y => y.Attribute("langKey").Value, y => y.Value ) diff --git a/Step.Database/Controllers/NcToolManagerController.cs b/Step.Database/Controllers/NcToolManagerController.cs index bc6cab9a..12db0fe6 100644 --- a/Step.Database/Controllers/NcToolManagerController.cs +++ b/Step.Database/Controllers/NcToolManagerController.cs @@ -189,8 +189,7 @@ namespace Step.Database.Controllers .Where(x => x.MagazineId == magId) .ToList(); } - - + public List GetMagazinePositions(byte magId) { // Get only magazine positions that match with magazineId diff --git a/Step.Model/ConfigModels/ToolManagerConfigModel.cs b/Step.Model/ConfigModels/ToolManagerConfigModel.cs index a167cfea..18319cd7 100644 --- a/Step.Model/ConfigModels/ToolManagerConfigModel.cs +++ b/Step.Model/ConfigModels/ToolManagerConfigModel.cs @@ -24,7 +24,7 @@ namespace Step.Model.ConfigModels public CooligTranslations CooligsTranslations { get; set; } - } + } public class CooligTranslations { diff --git a/Step.Model/DTOModels/ToolModels/DTONcFamilyModel.cs b/Step.Model/DTOModels/ToolModels/DTONcFamilyModel.cs index 3b3fb430..826cd9af 100644 --- a/Step.Model/DTOModels/ToolModels/DTONcFamilyModel.cs +++ b/Step.Model/DTOModels/ToolModels/DTONcFamilyModel.cs @@ -15,7 +15,7 @@ namespace Step.Model.DTOModels.ToolModels public string Name { get; set; } [Required] - public byte Type { get; set; } + public byte ToolType { get; set; } [Required] public byte RightSize { get; set; } @@ -90,7 +90,7 @@ namespace Step.Model.DTOModels.ToolModels { Id = obj.FamilyId, Name = obj.Name, - Type = obj.Type, + ToolType = obj.ToolType, RightSize = obj.RightSize, LeftSize = obj.LeftSize, TcpTable = obj.TcpTable, @@ -126,7 +126,7 @@ namespace Step.Model.DTOModels.ToolModels return new DbNcFamilyModel() { Name = obj.Name, - Type = obj.Type, + ToolType = obj.ToolType, RightSize = obj.RightSize, LeftSize = obj.LeftSize, TcpTable = obj.TcpTable, @@ -181,7 +181,7 @@ namespace Step.Model.DTOModels.ToolModels { Id = obj.FamilyId, Name = obj.Name, - Type = obj.Type, + ToolType = obj.ToolType, RightSize = obj.RightSize, LeftSize = obj.LeftSize, TcpTable = obj.TcpTable, @@ -219,7 +219,7 @@ namespace Step.Model.DTOModels.ToolModels { FamilyId = obj.Id, Name = obj.Name, - Type = obj.Type, + ToolType = obj.ToolType, RightSize = obj.RightSize, LeftSize = obj.LeftSize, TcpTable = obj.TcpTable, diff --git a/Step.Model/DatabaseModels/NcFamilyModel.cs b/Step.Model/DatabaseModels/NcFamilyModel.cs index 803698bd..865ff9ca 100644 --- a/Step.Model/DatabaseModels/NcFamilyModel.cs +++ b/Step.Model/DatabaseModels/NcFamilyModel.cs @@ -16,7 +16,7 @@ namespace Step.Model.DatabaseModels public string Name { get; set; } [Column("type")] - public byte Type { get; set; } + public byte ToolType { get; set; } [Column("right_size")] public byte RightSize { get; set; } @@ -73,7 +73,7 @@ namespace Step.Model.DatabaseModels return new NcFamilyModel() { Id = (ushort)obj.FamilyId, - Type = obj.Type, + Type = obj.ToolType, RightSize = obj.RightSize, LeftSize = obj.LeftSize, TcpTable = obj.TcpTable, diff --git a/Step/Controllers/WebApi/LanguageController.cs b/Step/Controllers/WebApi/LanguageController.cs index 66221959..640c4479 100644 --- a/Step/Controllers/WebApi/LanguageController.cs +++ b/Step/Controllers/WebApi/LanguageController.cs @@ -1,152 +1,189 @@ -using Step.Model.DTOModels; -using Step.NC; -using System.Collections.Generic; -using System.Linq; -using System.Web.Http; -using static CMS_CORE_Library.DataStructures; -using static Step.Config.ServerConfig; -using static Step.Model.Constants; -using static Step.Utils.LanguageController; - -namespace Step.Controllers.WebApi -{ - [RoutePrefix("api/language")] - public class LanguageController : ApiController - { - [Route("languages"), HttpGet] - public IHttpActionResult GetLanguageList() - { - List availableLanguages = GetLanguageListFromDirectory(); - if (availableLanguages == null) - return NotFound(); - - return Ok(availableLanguages); - } - - [Route("{language}"), HttpGet()] - public IHttpActionResult GetTranslations(string language) - { - if (!IsValidLanguage(language)) - return BadRequest("Language not exists"); - - if (!LanguageIsAvailable(language)) - return NotFound(); - - Dictionary translations = GetTranslationsFromFile(language); - - // Get Maintenance, Softkey, Plc Alarm translations - Dictionary maintenance = GetLocalizeMaintenanceName(language); - Dictionary softKeys = GetLocalizedSoftKeysNames(language); - Dictionary alarms = GetPlcAlarmsTranslations(language); - Dictionary heads = GetLocalizedHeadsNames(language); - - - // Concat maintenances dictionary with translations dictionary - translations = translations.Concat(maintenance).ToDictionary(x => x.Key, x => x.Value); - translations = translations.Concat(softKeys).ToDictionary(x => x.Key, x => x.Value); - translations = translations.Concat(alarms).ToDictionary(x => x.Key, x => x.Value); - translations = translations.Concat(heads).ToDictionary(x => x.Key, x => x.Value); +using Step.Model.DTOModels; +using Step.NC; +using System.Collections.Generic; +using System.Linq; +using System.Web.Http; +using static CMS_CORE_Library.DataStructures; +using static Step.Config.ServerConfig; +using static Step.Model.Constants; +using static Step.Utils.LanguageController; - if (translations == null) - return InternalServerError(); - - return Ok(translations); - } - - private static Dictionary GetLocalizeMaintenanceName(string language) - { - Dictionary localizedStrings = new Dictionary(); - - // Get localized name - localizedStrings = MaintenancesConfig - .ToDictionary( - x => MAINTENANCE_PREFIX_ID + x.Id.ToString(), // Prefix + maintenance id - x => GetValueFromLocalizationList(x.LocalizedName, language, "Maintenance_" + x.Id) - ); - - // Get localized description - localizedStrings = localizedStrings.Concat( MaintenancesConfig - .ToDictionary( - x => MAINTENANCE_DESC_PREFIX_ID + x.Id.ToString(), // Description Prefix + maintenance id - x => GetValueFromLocalizationList(x.LocalizedDescription, language, "Maintenance_" + x.Id) - )).ToDictionary(x => x.Key, x => x.Value); - - return localizedStrings; - } - - private static Dictionary GetLocalizedSoftKeysNames(string language) - { - return SoftKeysConfig - .ToDictionary( - x => SOFTKEY_PREFIX_ID + x.Id.ToString(), // PREFIX + softkey Id - x => GetValueFromLocalizationList(x.LocalizedNames, language, "SoftKey_" + x.Id) - ); +namespace Step.Controllers.WebApi +{ + [RoutePrefix("api/language")] + public class LanguageController : ApiController + { + [Route("languages"), HttpGet] + public IHttpActionResult GetLanguageList() + { + List availableLanguages = GetLanguageListFromDirectory(); + if (availableLanguages == null) + return NotFound(); + + return Ok(availableLanguages); + } + + [Route("{language}"), HttpGet()] + public IHttpActionResult GetTranslations(string language) + { + if (!IsValidLanguage(language)) + return BadRequest("Language not exists"); + + if (!LanguageIsAvailable(language)) + return NotFound(); + + Dictionary translations = GetTranslationsFromFile(language); + + // Get Maintenance, Softkey, Plc Alarm translations + Dictionary maintenance = GetLocalizeMaintenanceName(language); + Dictionary softKeys = GetLocalizedSoftKeysNames(language); + Dictionary alarms = GetPlcAlarmsTranslations(language); + Dictionary heads = GetLocalizedHeadsNames(language); + Dictionary cooling = GetCoolingTranslations(language); + + + // Concat maintenances dictionary with translations dictionary + translations = translations.Concat(maintenance).ToDictionary(x => x.Key, x => x.Value); + // Softkeys + translations = translations.Concat(softKeys).ToDictionary(x => x.Key, x => x.Value); + // Alarms + translations = translations.Concat(alarms).ToDictionary(x => x.Key, x => x.Value); + // Heads + translations = translations.Concat(heads).ToDictionary(x => x.Key, x => x.Value); + // Cooling + translations = translations.Concat(cooling).ToDictionary(x => x.Key, x => x.Value); + + if (translations == null) + return InternalServerError(); + + return Ok(translations); + } + + private static Dictionary GetLocalizeMaintenanceName(string language) + { + Dictionary localizedStrings = new Dictionary(); + + // Get localized name + localizedStrings = MaintenancesConfig + .ToDictionary( + x => MAINTENANCE_PREFIX_ID + x.Id.ToString(), // Prefix + maintenance id + x => GetValueFromLocalizationList(x.LocalizedName, language, "Maintenance_" + x.Id) + ); + + // Get localized description + localizedStrings = localizedStrings.Concat( MaintenancesConfig + .ToDictionary( + x => MAINTENANCE_DESC_PREFIX_ID + x.Id.ToString(), // Description Prefix + maintenance id + x => GetValueFromLocalizationList(x.LocalizedDescription, language, "Maintenance_" + x.Id) + )).ToDictionary(x => x.Key, x => x.Value); + + return localizedStrings; + } + + private static Dictionary GetLocalizedSoftKeysNames(string language) + { + return SoftKeysConfig + .ToDictionary( + x => SOFTKEY_PREFIX_ID + x.Id.ToString(), // PREFIX + softkey Id + x => GetValueFromLocalizationList(x.LocalizedNames, language, "SoftKey_" + x.Id) + ); } - private static Dictionary GetLocalizedHeadsNames(string language) - { - return HeadsConfig - .ToDictionary( - x => SOFTKEY_HEAD_ID + x.Id.ToString(), // PREFIX + softkey Id - x => GetValueFromLocalizationList(x.LocalizedNames, language, "Head_" + x.Id) - ); - } - - private static string GetValueFromLocalizationList(Dictionary localizedNames, string language, string defaultString) - { - // Find text from names by language id - var value = localizedNames.Where(y => y.Key == language).FirstOrDefault(); - // Set default value - if (value.Key == null) - return defaultString; - else - return value.Value; - } - - private static Dictionary GetPlcAlarmsTranslations(string language) - { - using (NcHandler ncHandler = new NcHandler()) - { - CmsError cmsError = ncHandler.Connect(); - Dictionary returnValue = new Dictionary(); - - Dictionary messages = new Dictionary(); - // Read data from CN - cmsError = ncHandler.numericalControl.NC_GetTranslatedPlcMessages(language, ref messages); - - // Id start from 1 - for(int i = 1; i <= 1024; i++) - { - // Get configurated alarms - var tmpAlarmConfig = InitialAlarmsConfig.Where(x => x.PlcId == i).FirstOrDefault(); - // Default string - string message = "Alarm_id_" + i + ": Message not configurated"; - // If is configurated - if (tmpAlarmConfig != null) - { - // Find translated string - message = messages.Where(x => x.Key == tmpAlarmConfig.AlarmId).FirstOrDefault().Value; - if (message == null) - message = "Alarm_id_" + i + ": Message not found"; - } - // Add to dictionary - returnValue.Add( - ALARM_PREFIX + i, - message - ); - } - return returnValue; - } - } - + private static Dictionary GetLocalizedHeadsNames(string language) + { + return HeadsConfig + .ToDictionary( + x => SOFTKEY_HEAD_ID + x.Id.ToString(), // PREFIX + softkey Id + x => GetValueFromLocalizationList(x.LocalizedNames, language, "Head_" + x.Id) + ); + } + + private static string GetValueFromLocalizationList(Dictionary localizedNames, string language, string defaultString) + { + // Find text from names by language id + var value = localizedNames.Where(y => y.Key == language).FirstOrDefault(); + // Set default value + if (value.Key == null) + return defaultString; + else + return value.Value; + } + + private static Dictionary GetPlcAlarmsTranslations(string language) + { + using (NcHandler ncHandler = new NcHandler()) + { + CmsError cmsError = ncHandler.Connect(); + Dictionary returnValue = new Dictionary(); + + Dictionary messages = new Dictionary(); + // Read data from CN + cmsError = ncHandler.numericalControl.NC_GetTranslatedPlcMessages(language, ref messages); + + // Id start from 1 + for(int i = 1; i <= 1024; i++) + { + // Get configurated alarms + var tmpAlarmConfig = InitialAlarmsConfig.Where(x => x.PlcId == i).FirstOrDefault(); + // Default string + string message = "Alarm_id_" + i + ": Message not configurated"; + // If is configurated + if (tmpAlarmConfig != null) + { + // Find translated string + message = messages.Where(x => x.Key == tmpAlarmConfig.AlarmId).FirstOrDefault().Value; + if (message == null) + message = "Alarm_id_" + i + ": Message not found"; + } + // Add to dictionary + returnValue.Add( + ALARM_PREFIX + i, + message + ); + } + return returnValue; + } + } + private static Dictionary GetCoolingTranslations(string language) { Dictionary dictionary = new Dictionary(); + // Find translated key var key = ToolManagerConfig.CooligsTranslations.Cooling.Where(x => x.Key == language).FirstOrDefault(); + if(key.Value != null) + dictionary.Add("cooling", key.Value); - dictionary.Add("cooling", key.Value); - } - } + key = ToolManagerConfig.CooligsTranslations.Cooling.Where(x => x.Key == language).FirstOrDefault(); + if (key.Value != null) + dictionary.Add("cooling1", key.Value); + + key = ToolManagerConfig.CooligsTranslations.Cooling.Where(x => x.Key == language).FirstOrDefault(); + if (key.Value != null) + dictionary.Add("cooling2", key.Value); + + key = ToolManagerConfig.CooligsTranslations.Cooling.Where(x => x.Key == language).FirstOrDefault(); + if (key.Value != null) + dictionary.Add("cooling3", key.Value); + + key = ToolManagerConfig.CooligsTranslations.Cooling.Where(x => x.Key == language).FirstOrDefault(); + if (key.Value != null) + dictionary.Add("cooling4", key.Value); + + key = ToolManagerConfig.CooligsTranslations.Cooling.Where(x => x.Key == language).FirstOrDefault(); + if (key.Value != null) + dictionary.Add("cooling5", key.Value); + + key = ToolManagerConfig.CooligsTranslations.Cooling.Where(x => x.Key == language).FirstOrDefault(); + if (key.Value != null) + dictionary.Add("cooling6", key.Value); + + key = ToolManagerConfig.CooligsTranslations.Cooling.Where(x => x.Key == language).FirstOrDefault(); + if (key.Value != null) + dictionary.Add("cooling7", key.Value); + + return dictionary; + } + } } \ No newline at end of file