diff --git a/Jenkinsfile b/Jenkinsfile index 24b3943..bb02ab2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,7 @@ pipeline { /* calcolo numero versione... diverso x branch MASTER/DEVELOP */ script { - withEnv(['NEXT_BUILD_NUMBER=391']) { + withEnv(['NEXT_BUILD_NUMBER=392']) { // env.versionNumber = VersionNumber(versionNumberString : '2.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true) env.versionNumber = VersionNumber(versionNumberString : '2.1.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}') env.APP_NAME = 'SCMA' diff --git a/MTC_Adapter/SCMA/AdapterGeneric.cs b/MTC_Adapter/SCMA/AdapterGeneric.cs index 1f0ad51..8243a2f 100644 --- a/MTC_Adapter/SCMA/AdapterGeneric.cs +++ b/MTC_Adapter/SCMA/AdapterGeneric.cs @@ -1364,8 +1364,26 @@ namespace SCMA { lg.Info("Inizio caricamento dizionario remapping nomi variabili"); } + try + { + // processo file pre REPLACE parziale (con like) - file DI BASE ESPLICITO + importFile(utils.nameRepRoleFile); + + // ora leggo il file GENERATO di replacement... NON dando per scontato ci sia... + if (File.Exists(utils.nameRepRoleFileGen)) + { + importFile(utils.nameRepRoleFileGen); + } + } + + catch + { } + } + + private void importFile(string fileName) + { + // init variabili string linea; - string fileName = ""; int rumRiga = 0; string valSost = ""; string valTrad; @@ -1376,77 +1394,69 @@ namespace SCMA substSearch tipoCerca; StreamReader file; replDict replacement; - try + // carica da file... + file = new StreamReader(fileName); + // leggo 1 linea alla volta + while ((linea = file.ReadLine()) != null) { - // processo file pre REPLACE parziale (con like) - fileName = string.Format(@"{0}\{1}", utils.confDir, utils.CRS("NameRepRolesList")); - // carica da file... - file = new StreamReader(fileName); - // leggo 1 linea alla volta... - while ((linea = file.ReadLine()) != null) + linea = linea.Trim(); + // se HA CONTENUTO + if (linea != "") { - linea = linea.Trim(); - // se HA CONTENUTO - if (linea != "") + // SE non è un commento... + if (linea.Substring(0, 1) != "#") { - // SE non è un commento... - if (linea.Substring(0, 1) != "#") + dictSubst = linea.Split(utils.CRC("testCharSep")); + // recupero valori inseriti + sMode = dictSubst[0].Trim(); + sSearch = dictSubst[1].Trim(); + valSost = dictSubst[2].Trim(); + valTrad = dictSubst[3].Trim(); + switch (sMode) { - dictSubst = linea.Split(utils.CRC("testCharSep")); - // recupero valori inseriti - sMode = dictSubst[0].Trim(); - sSearch = dictSubst[1].Trim(); - valSost = dictSubst[2].Trim(); - valTrad = dictSubst[3].Trim(); - switch (sMode) - { - case "X": - modoSearch = subsMode.X; - break; - default: - case "A": - modoSearch = subsMode.A; - break; - } - switch (sSearch) - { - case "B": - tipoCerca = substSearch.B; - break; - case "C": - tipoCerca = substSearch.C; - break; - case "E": - tipoCerca = substSearch.E; - break; - default: - case "I": - tipoCerca = substSearch.I; - break; - } - replacement = new replDict { modo = modoSearch, search = tipoCerca, tradz = valTrad }; - // 3 oggetti: tipo ricerca | valOriginale | valTradotto - if (currGateway.nameRepRoles != null && currGateway.nameRepRoles.ContainsKey(valSost)) - { - currGateway.nameRepRoles.Remove(valSost); - } - currGateway.nameRepRoles.Add(valSost, replacement); - rumRiga++; + case "X": + modoSearch = subsMode.X; + break; + default: + case "A": + modoSearch = subsMode.A; + break; } + switch (sSearch) + { + case "B": + tipoCerca = substSearch.B; + break; + case "C": + tipoCerca = substSearch.C; + break; + case "E": + tipoCerca = substSearch.E; + break; + default: + case "I": + tipoCerca = substSearch.I; + break; + } + replacement = new replDict { modo = modoSearch, search = tipoCerca, tradz = valTrad }; + // 3 oggetti: tipo ricerca | valOriginale | valTradotto + if (currGateway.nameRepRoles != null && currGateway.nameRepRoles.ContainsKey(valSost)) + { + currGateway.nameRepRoles.Remove(valSost); + } + currGateway.nameRepRoles.Add(valSost, replacement); + rumRiga++; } } - // chiudo file - file.Close(); - - // registro chiusura - if (utils.CRB("verbose")) - { - lg.Info(string.Format("Fine caricamento dizionario traduzioni nomi: {0} regole caricate", rumRiga)); - } } + // chiudo file + file.Close(); - catch - { } + // registro chiusura + if (utils.CRB("verbose")) + { + lg.Info(string.Format("Fine caricamento file {0} con dizionario traduzioni nomi: {1} regole caricate", fileName, rumRiga)); + } } /// @@ -1530,7 +1540,7 @@ namespace SCMA file = new StreamReader(fileName); // leggo file... string rawDataModel = file.ReadToEnd(); - + // pre-processo datamodel... currGateway.DataModel = utils.xmlSanitize(rawDataModel); // chiudo file diff --git a/MTC_Adapter/SCMA/MainForm.cs b/MTC_Adapter/SCMA/MainForm.cs index 0579049..6e30b84 100644 --- a/MTC_Adapter/SCMA/MainForm.cs +++ b/MTC_Adapter/SCMA/MainForm.cs @@ -1280,9 +1280,42 @@ namespace SCMA adpConf.NomeAdapt = plcName; adpConf.TipoAdapt = tipoScelto; adpConf.Version = 2; - // cerco i dati di VacuumPump... + + // preparo file temp x generazione regole + StreamWriter fileOut; + // apro in scrittura il file x mettere le regole... + fileOut = new StreamWriter(utils.nameRepRoleFileGen); + fileOut.WriteLine("#------------------------------------------------------------"); + fileOut.WriteLine("# AUTO GENERATED Replacement Conf File"); + fileOut.WriteLine("#------------------------------------------------------------"); + fileOut.WriteLine(""); + + /********************************************************* + * verificare come mappare la NameRepRolesList.map in memoria da NOMI COMPONENTI... NON ANDREBBE ricaricata dopo ma composto già qui... + * es: + * A|I|VacPump_01_Status|AuxiliaryGroups:04:Status + * A|I|ST_VacPump_01_Status|AuxiliaryGroups:04:Status + * A|I|VacPump_01_WrkTime|AuxiliaryGroups:04:ActiveTime + * A|I|VacPump_02_Status|AuxiliaryGroups:05:Status + * A|I|ST_VacPump_02_Status|AuxiliaryGroups:05:Status + * A|I|VacPump_02_WrkTime|AuxiliaryGroups:05:ActiveTime + * + * al posto di chiamare loadNameRepRoles in AdapterGeneric che salva in currGateway --> comporre un valore stringa da ACCODARE / SOSTITUIRE a quello ?!? + * + ***********************************************/ + + // cerco i dati dei vari elementi opzionali + + // VacuumPump... int numVP = 0; List listaVP = new List(); + // VacuumAct + int numVA = 0; + List listaVA = new List(); + + /// numero righe roles generate + int numRules = 0; + string replString = ""; List listaAux = currDataModel.Properties.FindAll(x => x.BrowseName.Contains("Machine:AuxiliaryGroups")); foreach (var item in listaAux) { @@ -1294,14 +1327,46 @@ namespace SCMA ident = $"VacPump_{numVP.ToString("00")}" }; listaVP.Add(newVP); + // aggiungo su file... + replString = item.BrowseName.Replace("Machine:", "").Replace(":Type", ""); + fileOut.WriteLine($"A|I|{newVP.ident}_Status|{replString}:Status"); + fileOut.WriteLine($"A|I|ST_{newVP.ident}_Status|{replString}:Status"); + fileOut.WriteLine($"A|I|{newVP.ident}_WrkTime|{replString}:ActiveTime"); + numRules += 3; + } + if (item.Value == "VACUUM_ACT") + { + numVA++; + element newVA = new element() + { + ident = $"VacAct_{numVA.ToString("00")}" + }; + listaVA.Add(newVA); + // aggiungo su file... + replString = item.BrowseName.Replace("Machine:", "").Replace(":Type", ""); + fileOut.WriteLine($"A|I|{newVA.ident}_Count|{replString}:Repetitions"); + numRules ++; } } + // aggiungo elementi trovati... if (numVP > 0) { element[] elencoVP = listaVP.ToArray(); adpConf.Cooler = elencoVP; } + if (numVA > 0) + { + element[] elencoVA = listaVA.ToArray(); + adpConf.VacuumAct = elencoVA; + } + + fileOut.WriteLine(""); + fileOut.WriteLine("#------------------------------------------------------------"); + fileOut.WriteLine($"# EOF: {numRules} rules added"); + fileOut.WriteLine("#------------------------------------------------------------"); + // chiudo file regole! + fileOut.Close(); } else { diff --git a/MTC_Adapter/SCMA/utils.cs b/MTC_Adapter/SCMA/utils.cs index 9593c96..f7022d3 100644 --- a/MTC_Adapter/SCMA/utils.cs +++ b/MTC_Adapter/SCMA/utils.cs @@ -46,7 +46,26 @@ namespace SCMA return string.Format(@"{0}\{1}", Application.StartupPath, CRS("dataPath")); } } - + /// + /// File x regole di replacement USER DEFINED + /// + public static string nameRepRoleFile + { + get + { + return string.Format(@"{0}\{1}", utils.confDir, utils.CRS("NameRepRolesList")); + } + } + /// + /// File x regole di replacement GENERATED + /// + public static string nameRepRoleFileGen + { + get + { + return string.Format(@"{0}\{1}", utils.confDir, utils.CRS("NameRepRolesList").Replace(".map", ".gen.map")); + } + } /// /// Metodo di sanitizzazione XML