From d648f83a8bcd0d1e02bb41c39837c49db9e0a8cd Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 23 Dec 2024 16:57:08 +0100 Subject: [PATCH] Rimozione riferimenti interni WPS, conf file e riferimento CNdex OSAI --- IOB-WIN-NEXT/AdapterFormNext.cs | 7 - IOB-WIN-NEXT/DATA/CONF/3018.ini | 68 ----- IOB-WIN-NEXT/DATA/CONF/3018.json | 69 ----- IOB-WIN-NEXT/DATA/CONF/3019.ini | 68 ----- IOB-WIN-NEXT/DATA/CONF/3019.json | 69 ----- IOB-WIN-NEXT/IOB-WIN-NEXT.csproj | 11 +- IOB-WIN-NEXT/IobNet/WebPageScrap.cs | 430 ---------------------------- 7 files changed, 1 insertion(+), 721 deletions(-) delete mode 100644 IOB-WIN-NEXT/DATA/CONF/3018.ini delete mode 100644 IOB-WIN-NEXT/DATA/CONF/3018.json delete mode 100644 IOB-WIN-NEXT/DATA/CONF/3019.ini delete mode 100644 IOB-WIN-NEXT/DATA/CONF/3019.json delete mode 100644 IOB-WIN-NEXT/IobNet/WebPageScrap.cs diff --git a/IOB-WIN-NEXT/AdapterFormNext.cs b/IOB-WIN-NEXT/AdapterFormNext.cs index 056aa1a8..368c4dc3 100644 --- a/IOB-WIN-NEXT/AdapterFormNext.cs +++ b/IOB-WIN-NEXT/AdapterFormNext.cs @@ -358,13 +358,6 @@ namespace IOB_WIN_NEXT btnStart.Enabled = true; break; -#if false - case tipoAdapter.WPS: - iobObj = new IobNet.WebPageScrap(this, IOBConf); - btnStart.Enabled = true; - break; -#endif - case tipoAdapter.ND: default: iobObj = new IOB_WIN_FORM.Iob.Simula(this, IOBConf); diff --git a/IOB-WIN-NEXT/DATA/CONF/3018.ini b/IOB-WIN-NEXT/DATA/CONF/3018.ini deleted file mode 100644 index 35fc0230..00000000 --- a/IOB-WIN-NEXT/DATA/CONF/3018.ini +++ /dev/null @@ -1,68 +0,0 @@ -;Configurazione IOB-WIN -[IOB] -;Complessore Atlas Copco -CNCTYPE=WPS -PING_MS_TIMEOUT=500 - -[MACHINE] -VENDOR=Atlas Copco -MODEL=GA18VP_13 - -[CNC] -IP=192.168.1.55 - -[SERVER] -MPIP=http://192.168.1.7 -MPURL=/MP/IO -CMDBASE=/IOB/input/ -CMDFLOG=/IOB/flog/ -CMDALIVE=/IOB -CMDENABLED=/IOB/enabled/ -CMDADV1=?valore= -CMDREBO=/sendReboot.aspx?idxMacchina= - -[MEMORY] -ADDR_READ=DB550.DBB0 -ADDR_WRITE=DB701.DBB0 -SIZE_READ=1 -SIZE_WRITE=0 -;BIT0=CONN -BIT1=DB550.DBB1 -;BIT2=PZCOUNT.STD.DB700.DBW22 -BIT3=DB550.DBB3 -BIT4=DB550.DBB4 - - -[BLINK] -;MAX_COUNTER_BLINK = 30 -MAX_COUNTER_BLINK = 15 -;bit0 = 0 -;bit1 = 0 -;bit2 = 1 -;bit3 = 1 -;bit4 = 1 -;bit5 = 0 -;bit6 = 0 -;bit7 = 0 -BLINK_FILT=0 -;BLINK_FILT=28 - -[OPTPAR] -;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice -; attenzione memoria sempre base BYTE (1604 DW --> 6416...) -;PZCOUNT_MODE=STD.DB550.DBDW0 -PZCOUNT_MODE=NONE -DISABLE_PZCOUNT=TRUE -ENABLE_DYN_DATA=TRUE -FORCE_DYN_DATA=TRUE -;gestione invio pezzi in blocco -ENABLE_SEND_PZC_BLOCK=TRUE -MIN_SEND_PZC_BLOCK=0 -MAX_SEND_PZC_BLOCK=100 -; gestione custom timer -timerIntMs=50 -; CONF variabili da recuperare in WebPage (stato macchina, contatori, variabili, ...) -LUT_CONF=3018.json - -[BRANCH] -NAME=master diff --git a/IOB-WIN-NEXT/DATA/CONF/3018.json b/IOB-WIN-NEXT/DATA/CONF/3018.json deleted file mode 100644 index b1d1756a..00000000 --- a/IOB-WIN-NEXT/DATA/CONF/3018.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "SrvData": { - "baseUri": "http://192.168.1.55/", - "driverName": "EDGE" - }, - "DynData": [ - { - "key": "analoginputsr0c1", - "val": "analoginputsr0c2", - "unit": "bar", - "func": "CHANGE", - "speriod": 3600 - }, - { - "key": "ANALOGINPUTSR1C1", - "val": "ANALOGINPUTSR1C2", - "unit": "C", - "func": "CHANGE", - "sPeriod": 3600 - }, - { - "key": "analoginputsr2c1", - "val": "analoginputsr2c2", - "unit": "C", - "func": "CHANGE", - "speriod": 3600 - }, - { - "key": "countersr0c1", - "val": "countersr0c2", - "unit": "ore", - "func": "CHANGE", - "speriod": 3600 - }, - { - "key": "countersr2c1", - "val": "countersr2c2", - "unit": "#", - "func": "CHANGE", - "speriod": 3600 - }, - { - "key": "digitalinputsr0c1", - "val": "digitalinputsr0c2", - "unit": "enum", - "func": "CHANGE", - "speriod": 3600 - } - ], - "Status": [ - { - "key": "MACHINESTATER0C1", - "name": "CURR_STATUS", - "val": "MACHINESTATER0C2", - "unit": "ENUM", - "func": "CHANGE", - "sPeriod": 1, - "codeMapping": { - "Spento": "00", - "PowerOn": "01", - "Attesa": "01", - "Carico": "03", - "A vuoto": "05", - "Riserva": "09", - "Alarm": "11" - } - } - ] -} \ No newline at end of file diff --git a/IOB-WIN-NEXT/DATA/CONF/3019.ini b/IOB-WIN-NEXT/DATA/CONF/3019.ini deleted file mode 100644 index 99b8a157..00000000 --- a/IOB-WIN-NEXT/DATA/CONF/3019.ini +++ /dev/null @@ -1,68 +0,0 @@ -;Configurazione IOB-WIN -[IOB] -;Complessore Atlas Copco -CNCTYPE=WPS -PING_MS_TIMEOUT=500 - -[MACHINE] -VENDOR=Atlas Copco -MODEL=GA18VP_12 - -[CNC] -IP=192.168.1.56 - -[SERVER] -MPIP=http://192.168.1.7 -MPURL=/MP/IO -CMDBASE=/IOB/input/ -CMDFLOG=/IOB/flog/ -CMDALIVE=/IOB -CMDENABLED=/IOB/enabled/ -CMDADV1=?valore= -CMDREBO=/sendReboot.aspx?idxMacchina= - -[MEMORY] -ADDR_READ=DB550.DBB0 -ADDR_WRITE=DB701.DBB0 -SIZE_READ=1 -SIZE_WRITE=0 -;BIT0=CONN -BIT1=DB550.DBB1 -;BIT2=PZCOUNT.STD.DB700.DBW22 -BIT3=DB550.DBB3 -BIT4=DB550.DBB4 - - -[BLINK] -;MAX_COUNTER_BLINK = 30 -MAX_COUNTER_BLINK = 15 -;bit0 = 0 -;bit1 = 0 -;bit2 = 1 -;bit3 = 1 -;bit4 = 1 -;bit5 = 0 -;bit6 = 0 -;bit7 = 0 -BLINK_FILT=0 -;BLINK_FILT=28 - -[OPTPAR] -;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice -; attenzione memoria sempre base BYTE (1604 DW --> 6416...) -;PZCOUNT_MODE=STD.DB550.DBDW0 -PZCOUNT_MODE=NONE -DISABLE_PZCOUNT=TRUE -ENABLE_DYN_DATA=TRUE -FORCE_DYN_DATA=TRUE -;gestione invio pezzi in blocco -ENABLE_SEND_PZC_BLOCK=TRUE -MIN_SEND_PZC_BLOCK=0 -MAX_SEND_PZC_BLOCK=100 -; gestione custom timer -timerIntMs=50 -; CONF variabili da recuperare in WebPage (stato macchina, contatori, variabili, ...) -LUT_CONF=3019.json - -[BRANCH] -NAME=master diff --git a/IOB-WIN-NEXT/DATA/CONF/3019.json b/IOB-WIN-NEXT/DATA/CONF/3019.json deleted file mode 100644 index 17c2d53b..00000000 --- a/IOB-WIN-NEXT/DATA/CONF/3019.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "SrvData": { - "baseUri": "http://192.168.1.56/", - "driverName": "EDGE" - }, - "DynData": [ - { - "key": "analoginputsr0c1", - "val": "analoginputsr0c2", - "unit": "bar", - "func": "CHANGE", - "speriod": 3600 - }, - { - "key": "ANALOGINPUTSR1C1", - "val": "ANALOGINPUTSR1C2", - "unit": "C", - "func": "CHANGE", - "sPeriod": 3600 - }, - { - "key": "analoginputsr2c1", - "val": "analoginputsr2c2", - "unit": "C", - "func": "CHANGE", - "speriod": 3600 - }, - { - "key": "countersr0c1", - "val": "countersr0c2", - "unit": "ore", - "func": "CHANGE", - "speriod": 3600 - }, - { - "key": "countersr2c1", - "val": "countersr2c2", - "unit": "#", - "func": "CHANGE", - "speriod": 3600 - }, - { - "key": "digitalinputsr0c1", - "val": "digitalinputsr0c2", - "unit": "enum", - "func": "CHANGE", - "speriod": 3600 - } - ], - "Status": [ - { - "key": "MACHINESTATER0C1", - "name": "CURR_STATUS", - "val": "MACHINESTATER0C2", - "unit": "ENUM", - "func": "CHANGE", - "sPeriod": 1, - "codeMapping": { - "Spento": "00", - "PowerOn": "01", - "Attesa": "01", - "Carico": "03", - "A vuoto": "05", - "Riserva": "09", - "Alarm": "11" - } - } - ] -} \ No newline at end of file diff --git a/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj b/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj index a16ba809..591b09c9 100644 --- a/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj +++ b/IOB-WIN-NEXT/IOB-WIN-NEXT.csproj @@ -104,7 +104,7 @@ ..\packages\BouncyCastle.Cryptography.2.4.0\lib\net461\BouncyCastle.Cryptography.dll - ..\EgwProxy.MultiCncLib\ExtLib\CndexLinkDotNet.dll + ..\ExtLibs\CndexLinkDotNet.dll ..\packages\EasyModbusTCP.5.6.0\lib\net40\EasyModbus.dll @@ -590,7 +590,6 @@ - @@ -947,12 +946,6 @@ - - Always - - - Always - @@ -963,9 +956,7 @@ - - diff --git a/IOB-WIN-NEXT/IobNet/WebPageScrap.cs b/IOB-WIN-NEXT/IobNet/WebPageScrap.cs deleted file mode 100644 index 5d5d6bcf..00000000 --- a/IOB-WIN-NEXT/IobNet/WebPageScrap.cs +++ /dev/null @@ -1,430 +0,0 @@ -using IOB_UT_NEXT; -using MapoSDK; -using Newtonsoft.Json; -using OpenQA.Selenium; -using OpenQA.Selenium.Chrome; -using OpenQA.Selenium.Edge; -using OpenQA.Selenium.Firefox; -using System; -using System.Collections.Generic; -using System.IO; -using System.Net.NetworkInformation; -using System.Threading; -using System.Windows.Forms; - -namespace IOB_WIN_NEXT.IobNet -{ - /// - /// Generica classe per implementare WebPageScraping (scaricamento web pages anche js-based x - /// recupero informazioni) - /// - public class WebPageScrap : Iob.GenericNext, IDisposable - { - /* -------------------------------------------------------------------------------- - * Controlli dotati di GENERICA pagina WEB in cui cercare e recuperare informazioni - * - * - il file di conf deve contenere l'URL di base - * - il file di conf deve contenere COSA cercare (es il "contenitore" del dato da estrarre) - * - * -------------------------------------------------------------------------------- */ - - #region Public Constructors - - /// - /// Estende l'init della classe base... - /// - /// - /// - public WebPageScrap(AdapterFormNext caller, IobConfiguration IOBConf) : base(caller, IOBConf) - { - lgInfo("INIT IobWPS"); - //reloadAdapterConf(); - } - - #endregion Public Constructors - - #region Public Methods - - public void Dispose() - { - driver.Dispose(); - GC.SuppressFinalize(this); - } - - /// - /// Recupero dati dinamici in formato dictionary - /// - /// - public override Dictionary getDynData() - { - lgInfo("Chiamata getDynData x IOB WebPageScraping!"); - Dictionary outVal = new Dictionary(); - if (driver != null) - { - try - { - /* ---------------------------------------------------------- - * Recupero dalla TUTTE le chiavi richieste... - * */ - - string cKey = ""; - string cVal = ""; - // processo tutti i DynData... - foreach (var item in monitoredItems.DynData) - { - try - { - // cerco elemento indicato - var element = driver.FindElement(By.Id(item.val)); - cVal = element.Text; - // verifico nome o key... - if (!string.IsNullOrEmpty(item.name)) - { - cKey = item.name; - } - else - { - element = driver.FindElement(By.Id(item.key)); - cKey = element.Text; - } - // controllo se devo inviare (per tipo di dato, x scadenza) - if (monItem2Send(cVal, item)) - { - item.actVal = cVal; - item.DTScad = DateTime.Now.AddSeconds(item.sPeriod); - // accodo! - outVal.Add(cKey, cVal); - } - } - catch (Exception exc) - { - lgError($"Errore in FindElement | key: {item.key} | val: {item.val}{Environment.NewLine}{exc}"); - } - } - } - catch (Exception exc) - { - lgError(exc, "Errore in getDynData x IOB WPS"); - } - } - else - { - lgError("Errore: driver null"); - } - return outVal; - } - - /// - /// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid) - /// - public override void processOverride() - { - } - - /// - /// Effettua lettura semafori principale - /// Parametri da aggiornare x display in form - /// - public override void readSemafori(ref newDisplayData currDispData) - { - base.readSemafori(ref currDispData); - // init a zero... - B_input = 0; - // ciclo! - try - { - // controllo SE il driver SIA attivo... - if (driver != null) - { - string cKey = ""; - string cVal = ""; - // IPOTESI: un UNICO oggetto decodifica status - if (monitoredItems.Status.Count == 1) - { - var item = monitoredItems.Status[0]; - // cerco elemento indicato - element = driver.FindElement(By.Id(item.val)); - cKey = element.Text; - // verifico se mancasse il mapping... - if (!item.codeMapping.ContainsKey(cKey)) - { - processUnknStatus(cKey); - } - else - { - // ora decodifico da variabile status a valore secondo impostazione "codeMapping" - cVal = item.codeMapping[cKey]; - B_input = int.Parse(cVal, System.Globalization.NumberStyles.HexNumber); - if (currDispData != null) - { - currDispData.semIn = Semaforo.SV; - } - } - } - } - else - { - lgError("Errore: driver non pronto (null)"); - } - // riporto bitmap... - reportRawInput(ref currDispData); - } - catch (Exception exc) - { - lgError(exc, "Errore in readSemafori x IOB WPS"); - if (currDispData != null) - currDispData.semIn = Semaforo.SR; - } - } - - public override void startAdapter(bool resetQueue) - { - // in primis RICARICO conf specifica... - reloadAdapterConf(); - // continuo con start... - base.startAdapter(resetQueue); - } - - /// - /// Override x chiusura driver... - /// - /// - /// - public override void stopAdapter(bool tryRestart, bool forceDequeue) - { - try - { - // in primis chiudo driver... - if (driver != null) - { - driver.Quit(); - } - } - catch (Exception exc) - { - lgError(exc, "Eccezione in tryDisconnect"); - } - // continuo - base.stopAdapter(tryRestart, forceDequeue); - } - - /// - /// Connessione - /// - public override void tryConnect() - { - // controllo ping --> segno connected... - connectionOk = (testPingMachine == IPStatus.Success); - if (connectionOk) - { - queueInEnabCurr = true; - try - { - //var t = TaskEx.Run(() => startDriver()); - //t.Wait(); - // modalità sincrona - startDriver(); - lgInfo("Completato start driver"); - } - catch (Exception exc) - { - lgError(exc, "Eccezione in tryConnect"); - } - } - else - { - // aspetto prima di riprovare... - Thread.Sleep(200); - } - } - - /// - /// Disconnessione - /// - public override void tryDisconnect() - { - connectionOk = false; - queueInEnabCurr = false; - try - { - // in primis chiudo driver... - if (driver != null) - //if (driver != null && driver.WindowHandles.Count > 0) - { - driver.Quit(); - } - } - catch (Exception exc) - { - lgError(exc, "Eccezione in tryDisconnect"); - } - } - - #endregion Public Methods - - #region Protected Fields - - /// - /// Pagina web da scaricare - /// - protected string baseUri = "http://127.0.0.1"; - - /// - /// Array di configurazione degli oggetti da cercare x decodifica e recupero info - /// - protected Dictionary dataLocatorLUT; - - /// - /// Driver per gestione chiamate crawling/scraping - /// - protected IWebDriver driver; - - /// - /// Elementi da recuperare nella apgina web - /// - protected IWebElement element; - - /// - /// Vettore della frequenza di ogni status trovato... invio ogni 100 rilevazioni (modulo - /// 100, resto == 1) - /// - protected Dictionary freqUnknStatus = new Dictionary(); - - /// - /// Oggetti decodificati da pagina - /// - protected MonitoredItemsConf monitoredItems; - - #endregion Protected Fields - - #region Private Methods - - /// - /// Processo stati unknown... - /// - /// - private void processUnknStatus(string cKey) - { - // cerco se avevo già una key nella dictionary... - if (freqUnknStatus.ContainsKey(cKey)) - { - freqUnknStatus[cKey]++; - // se è 1 ogni 100 (%100, resto ==1) --> loggo... - if (freqUnknStatus[cKey] % 100 == 1) - { - lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey} | freq: {freqUnknStatus[cKey]}"); - // accodo come invio di tipo FLOG... - string sVal = string.Format("[UnknStatus] {0}, freq: {1}", cKey, freqUnknStatus); - // chiamo accodamento... - accodaFLog(sVal, qEncodeFLog("UnknStatus", sVal)); - } - } - else - { - // creo chiave con freq = 1 - freqUnknStatus.Add(cKey, 1); - // log iniziale - lgInfo($"Errore in decodifica status: MAPPING non trovato per {cKey}"); - } - } - - /// - /// Ricarica conf adapter... - /// - private void reloadAdapterConf() - { - // init obj display - newDisplayData currDispData = new newDisplayData(); - lgInfo("BEGIN reloadAdapterConf"); - // inizializzo LUT decodifica - string jsonConf = getOptPar("LUT_CONF"); - if (!string.IsNullOrEmpty(jsonConf)) - { - string jsonFullPath = $"{Application.StartupPath}/DATA/CONF/{jsonConf}"; - lgInfo($"Apertura file {jsonFullPath}"); - StreamReader reader = new StreamReader(jsonFullPath); - string jsonData = reader.ReadToEnd(); - if (!string.IsNullOrEmpty(jsonData)) - { - try - { - monitoredItems = JsonConvert.DeserializeObject(jsonData); - // salvo baseUri - baseUri = monitoredItems.SrvData.baseUri; - lgInfo($"baseUri = {baseUri}"); - // imposto a zero la bitmap x riavvio! - B_input = 0; - // FORZO invio dati... - accodaSigIN(ref currDispData); - // loggo! - lgInfo($"init input bitmap to zero: {B_input}"); - } - catch (Exception exc) - { - lgError(exc, "Eccezione in decodifica conf json"); - } - } - reader.Dispose(); - } - lgInfo("DONE reloadAdapterConf"); - raiseRefresh(currDispData); - } - - /// - /// Avvio del WebDriver - /// - private void startDriver() - { - bool startOk = false; - if (monitoredItems.SrvData.driverName == "CHROME") - { - lgInfo("Starting CHROME Driver"); - // preparo opzione headless x CHROME - var o = new ChromeOptions(); - o.AddArgument("headless"); - ChromeDriverService service = ChromeDriverService.CreateDefaultService(Application.StartupPath); - service.HideCommandPromptWindow = true; - driver = new ChromeDriver(service, o); - startOk = true; - } - else if (monitoredItems.SrvData.driverName == "EDGE") - { - lgInfo("Starting EDGE Driver"); - // preparo opzione headless x CHROME - var o = new EdgeOptions(); - o.AddArgument("headless"); - EdgeDriverService service = EdgeDriverService.CreateDefaultService(Application.StartupPath); - service.HideCommandPromptWindow = true; - driver = new EdgeDriver(service, o); - startOk = true; - } - else if (monitoredItems.SrvData.driverName == "FIREFOX") - { - lgInfo("Starting FIREFOX Driver"); - // preparo opzione headless x FIREFOX - var o = new FirefoxOptions(); - o.AddArgument("-headless"); - o.SetPreference("app.update.auto", false); - o.SetPreference("app.update.enabled", false); - FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(Application.StartupPath); - service.HideCommandPromptWindow = true; - driver = new FirefoxDriver(service, o); - startOk = true; - } - else - { - lgError("ERRORE: manca indicazione driver: CHROME/EDGE/FIREFOX"); - } - if (startOk) - { - // aggiungo timeout x JScripts - driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20); - driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(20); - // imposto pagina di acquisizione - driver.Navigate().GoToUrl(baseUri); - } - } - - #endregion Private Methods - } -} \ No newline at end of file