diff --git a/MP.Data/Conf/IobTags.cs b/MP.Data/Conf/IobTags.cs
new file mode 100644
index 00000000..500a9684
--- /dev/null
+++ b/MP.Data/Conf/IobTags.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MP.Data.Conf
+{
+ ///
+ /// Struttura conf del file conf TAG x IOB
+ ///
+ public class IobTags
+ {
+ ///
+ /// Oggetto dizionario di configurazione x IOB
+ ///
+ public Dictionary> IobSetup = new Dictionary>();
+ }
+}
diff --git a/MP.Data/DTO/TagDataDTO.cs b/MP.Data/Conf/TagData.cs
similarity index 88%
rename from MP.Data/DTO/TagDataDTO.cs
rename to MP.Data/Conf/TagData.cs
index da341069..4ea5b582 100644
--- a/MP.Data/DTO/TagDataDTO.cs
+++ b/MP.Data/Conf/TagData.cs
@@ -4,12 +4,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace MP.Data.DTO
+namespace MP.Data.Conf
{
///
/// Item da mostrare nei blocchi MON degli impianti come override ai dati MSE
///
- public class TagDataDTO
+ public class TagData
{
///
/// Indice della colonna (ordine) del dato
@@ -26,6 +26,6 @@ namespace MP.Data.DTO
///
/// Indicazione della chiave REDIS dove recuperare il tag indicato (già in formato string)
///
- public string TagLocation{ get; set; } = "";
+ public string TagLocation { get; set; } = "";
}
}
diff --git a/MP.Mon/Conf/ICOEL.json b/MP.Mon/Conf/ICOEL.json
deleted file mode 100644
index 7a762740..00000000
--- a/MP.Mon/Conf/ICOEL.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- [
- {
- "ColNum": 1,
- "RowNum": 1,
- "TagName": "Vel",
- "TagLocation": "FluxData:TonnOra"
- },
- {
- "ColNum": 2,
- "RowNum": 1,
- "TagName": "Vel",
- "TagLocation": "FluxData:PezziMin"
- },
- {
- "ColNum": 1,
- "RowNum": 2,
- "TagName": "Batch SX",
- "TagLocation": "FluxData:BatchL1"
- },
- {
- "ColNum": 2,
- "RowNum": 2,
- "TagName": "Batch DX",
- "TagLocation": "FluxData:BatchL2"
- }
- ]
-}
\ No newline at end of file
diff --git a/MP.Mon/Conf/iobTagsConf.json b/MP.Mon/Conf/iobTagsConf.json
new file mode 100644
index 00000000..5a42529a
--- /dev/null
+++ b/MP.Mon/Conf/iobTagsConf.json
@@ -0,0 +1,56 @@
+{
+ "IobSetup": {
+ "GIACO_ICOEL_001": [
+ {
+ "ColNum": 1,
+ "RowNum": 1,
+ "TagName": "Vel",
+ "TagLocation": "FluxData:TonnOra"
+ },
+ {
+ "ColNum": 2,
+ "RowNum": 1,
+ "TagName": "Vel",
+ "TagLocation": "FluxData:PezziMin"
+ },
+ {
+ "ColNum": 1,
+ "RowNum": 2,
+ "TagName": "Batch SX",
+ "TagLocation": "FluxData:BatchL1"
+ },
+ {
+ "ColNum": 2,
+ "RowNum": 2,
+ "TagName": "Batch DX",
+ "TagLocation": "FluxData:BatchL2"
+ }
+ ],
+ "GIACO_ICOEL_002": [
+ {
+ "ColNum": 1,
+ "RowNum": 1,
+ "TagName": "Vel",
+ "TagLocation": "FluxData:TonnOra"
+ },
+ {
+ "ColNum": 2,
+ "RowNum": 1,
+ "TagName": "Vel",
+ "TagLocation": "FluxData:PezziMin"
+ },
+ {
+ "ColNum": 1,
+ "RowNum": 2,
+ "TagName": "Batch SX",
+ "TagLocation": "FluxData:BatchL1"
+ },
+ {
+ "ColNum": 2,
+ "RowNum": 2,
+ "TagName": "Batch DX",
+ "TagLocation": "FluxData:BatchL2"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/MP.Mon/Data/MpDataService.cs b/MP.Mon/Data/MpDataService.cs
index 2d9bed3d..37136dc7 100644
--- a/MP.Mon/Data/MpDataService.cs
+++ b/MP.Mon/Data/MpDataService.cs
@@ -5,6 +5,7 @@ using NLog;
using MP.Data.DTO;
using Newtonsoft.Json;
using MP.Data;
+using MP.Data.Conf;
namespace MP.Mon.Data
{
@@ -17,6 +18,11 @@ namespace MP.Mon.Data
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
+ ///
+ /// Dizionario dei tag configurati per IOB
+ ///
+ protected Dictionary> currTagConf { get; set; } = new Dictionary>();
+
///
/// Oggetto per connessione a REDIS
///
@@ -36,6 +42,57 @@ namespace MP.Mon.Data
#endregion Public Fields
+
+ ///
+ /// restituisce il valore da REDIS associato al tag richeisto
+ ///
+ /// Chiave in cui cercare il valore
+ ///
+ public async Task getTagConf(string redKey)
+ {
+ string outVal = "";
+ // cerco in REDIS la conf x l'IOB
+ string rawData = await redisDb.StringGetAsync(redKey);
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ outVal = rawData;
+ }
+ return await Task.FromResult(outVal);
+ }
+
+ ///
+ /// Prova a caricare da file la conf degli IOB se presente
+ ///
+ private void tryLoadIobTags()
+ {
+ Dictionary> currConf = new Dictionary>();
+ string strExeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
+ if (!string.IsNullOrEmpty(strExeFilePath))
+ {
+ string? strWorkPath = Path.GetDirectoryName(strExeFilePath);
+ if (!string.IsNullOrEmpty(strWorkPath))
+ {
+ string filePath = $"{strWorkPath}/Conf/iobTagsConf.json";
+ if (File.Exists(filePath))
+ {
+ string rawData = File.ReadAllText(filePath);
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ var fileConfData = JsonConvert.DeserializeObject(rawData);
+ if (fileConfData != null)
+ {
+ currConf = fileConfData.IobSetup;
+ }
+ }
+ }
+ if (currConf != null)
+ {
+ currTagConf = currConf;
+ }
+ }
+ }
+ }
+
#region Public Constructors
public MpDataService(IConfiguration configuration, ILogger logger)
@@ -43,6 +100,9 @@ namespace MP.Mon.Data
_logger = logger;
_configuration = configuration;
+ // setup conf IOB da dizionario
+ tryLoadIobTags();
+
// setup compoenti REDIS
this.redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
this.redisDb = this.redisConn.GetDatabase();
@@ -95,62 +155,6 @@ namespace MP.Mon.Data
return Task.FromResult(dbResult);
}
- ///
- /// Configurazione (REDIS) dei tag in override
- ///
- /// IOB di cui cercare la conf
- ///
- public async Task> getTagConf(string CodIOB)
- {
- List? currResult = new List();
- // cerco in REDIS la conf x l'IOB
- string rawData = await redisDb.StringGetAsync($"{Constants.CONF_MON_KEY}:{CodIOB}");
- if (!string.IsNullOrEmpty(rawData))
- {
- currResult = JsonConvert.DeserializeObject>(rawData);
- }
- // altrimenti in conf file, se presente, e salvo
- if (currResult == null)
- {
- currResult = tryLoadConf(CodIOB);
- }
- // altrimenti vuoto!
- if (currResult == null)
- {
- currResult = new List();
- }
- return await Task.FromResult(currResult);
- }
-
- ///
- /// Prova a caricare da file la conf dell'IOB richiesto salvando su REDIS
- ///
- ///
- ///
- private List tryLoadConf(string codIOB)
- {
- List currConf = new List();
- string strExeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
- string strWorkPath = Path.GetDirectoryName(strExeFilePath);
-
- string filePath = $"{strWorkPath}/Conf/{codIOB}";
- if (File.Exists(filePath))
- {
- string rawData = File.ReadAllText(filePath);
- if (!string.IsNullOrEmpty(rawData))
- {
- currConf = JsonConvert.DeserializeObject>(rawData);
- // salvo in redis!
- redisDb.StringSet($"{Constants.CONF_MON_KEY}:{codIOB}", rawData);
- }
- }
- if (currConf == null)
- {
- currConf = new List();
- }
- // rendo!
- return currConf;
- }
#endregion Public Methods
}
diff --git a/MP.Mon/Program.cs b/MP.Mon/Program.cs
index 5d1efe06..2754d799 100644
--- a/MP.Mon/Program.cs
+++ b/MP.Mon/Program.cs
@@ -21,7 +21,6 @@ string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"))
// avvio oggetto shared x redis...
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
-
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();