Rimozione riferimenti interni WPS, conf file e riferimento CNdex OSAI

This commit is contained in:
Samuele Locatelli
2024-12-23 16:57:08 +01:00
parent 00eb064a4b
commit d648f83a8b
7 changed files with 1 additions and 721 deletions
-7
View File
@@ -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);
-68
View File
@@ -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
-69
View File
@@ -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"
}
}
]
}
-68
View File
@@ -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
-69
View File
@@ -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"
}
}
]
}
+1 -10
View File
@@ -104,7 +104,7 @@
<HintPath>..\packages\BouncyCastle.Cryptography.2.4.0\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
</Reference>
<Reference Include="CndexLinkDotNet">
<HintPath>..\EgwProxy.MultiCncLib\ExtLib\CndexLinkDotNet.dll</HintPath>
<HintPath>..\ExtLibs\CndexLinkDotNet.dll</HintPath>
</Reference>
<Reference Include="EasyModbus, Version=5.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EasyModbusTCP.5.6.0\lib\net40\EasyModbus.dll</HintPath>
@@ -590,7 +590,6 @@
<Compile Include="IobSiemens\SiemensComur.cs" />
<Compile Include="IobSiemens\SiemensSaet.cs" />
<Compile Include="IobFile\FileGen.cs" />
<Compile Include="IobNet\WebPageScrap.cs" />
<Compile Include="Iob\OSAI.cs" />
<Compile Include="Iob\Kawasaki.cs" />
<Compile Include="IobSiemens\SiemensAprochim.cs" />
@@ -947,12 +946,6 @@
</None>
<None Include="DATA\CONF\INTERCL_02.json" />
<None Include="DATA\CONF\INTERCL_01.json" />
<None Include="DATA\CONF\3019.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\3019.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\3020.ini" />
<None Include="DATA\CONF\INTERCL_02.ini" />
<None Include="DATA\CONF\INTERCL_01.ini" />
@@ -963,9 +956,7 @@
<None Include="DATA\CONF\VL20.ini" />
<None Include="DATA\CONF\VL25.ini" />
<None Include="DATA\CONF\VL24.ini" />
<None Include="DATA\CONF\3018.ini" />
<None Include="DATA\CONF\3017.ini" />
<None Include="DATA\CONF\3018.json" />
<None Include="DATA\CONF\SIMUL_08.ini" />
<None Include="DATA\CONF\SIMUL_07.ini" />
<None Include="DATA\CONF\SIMUL_06.ini" />
-430
View File
@@ -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
{
/// <summary>
/// Generica classe per implementare WebPageScraping (scaricamento web pages anche js-based x
/// recupero informazioni)
/// </summary>
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
/// <summary>
/// Estende l'init della classe base...
/// </summary>
/// <param name="caller"></param>
/// <param name="adpConf"></param>
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);
}
/// <summary>
/// Recupero dati dinamici in formato dictionary
/// </summary>
/// <returns></returns>
public override Dictionary<string, string> getDynData()
{
lgInfo("Chiamata getDynData x IOB WebPageScraping!");
Dictionary<string, string> outVal = new Dictionary<string, string>();
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;
}
/// <summary>
/// Effettua processing del recupero delle OVERRIDE (spindle, feedrate, rapid)
/// </summary>
public override void processOverride()
{
}
/// <summary>
/// Effettua lettura semafori principale
/// <paramref name="currDispData">Parametri da aggiornare x display in form</paramref>
/// </summary>
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);
}
/// <summary>
/// Override x chiusura driver...
/// </summary>
/// <param name="tryRestart"></param>
/// <param name="forceDequeue"></param>
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);
}
/// <summary>
/// Connessione
/// </summary>
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);
}
}
/// <summary>
/// Disconnessione
/// </summary>
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
/// <summary>
/// Pagina web da scaricare
/// </summary>
protected string baseUri = "http://127.0.0.1";
/// <summary>
/// Array di configurazione degli oggetti da cercare x decodifica e recupero info
/// </summary>
protected Dictionary<string, string> dataLocatorLUT;
/// <summary>
/// Driver per gestione chiamate crawling/scraping
/// </summary>
protected IWebDriver driver;
/// <summary>
/// Elementi da recuperare nella apgina web
/// </summary>
protected IWebElement element;
/// <summary>
/// Vettore della frequenza di ogni status trovato... invio ogni 100 rilevazioni (modulo
/// 100, resto == 1)
/// </summary>
protected Dictionary<string, int> freqUnknStatus = new Dictionary<string, int>();
/// <summary>
/// Oggetti decodificati da pagina
/// </summary>
protected MonitoredItemsConf monitoredItems;
#endregion Protected Fields
#region Private Methods
/// <summary>
/// Processo stati unknown...
/// </summary>
/// <param name="cKey"></param>
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}");
}
}
/// <summary>
/// Ricarica conf adapter...
/// </summary>
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<MonitoredItemsConf>(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);
}
/// <summary>
/// Avvio del WebDriver
/// </summary>
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
}
}