diff --git a/IOB-UT-NEXT/Enums.cs b/IOB-UT-NEXT/Enums.cs index a27dc83b..928ddfef 100644 --- a/IOB-UT-NEXT/Enums.cs +++ b/IOB-UT-NEXT/Enums.cs @@ -631,6 +631,15 @@ namespace IOB_UT_NEXT /// Shelly, + /// + /// Shelly's Device PM1 series (Gen1) + /// + ShellyPm1, + /// + /// Shelly's Device Pro3Em series (Gen2) + /// + ShellyPro3Em, + /// /// Adapter SIEMENS /// diff --git a/IOB-WIN-SHELLY.sln b/IOB-WIN-SHELLY.sln index 8611425e..1d2720b0 100644 --- a/IOB-WIN-SHELLY.sln +++ b/IOB-WIN-SHELLY.sln @@ -69,8 +69,8 @@ Global {7642AEAD-7A35-45A6-8761-81D97CD8905C}.Release|Any CPU.Build.0 = Release|Any CPU {7642AEAD-7A35-45A6-8761-81D97CD8905C}.Release|x86.ActiveCfg = Release|Any CPU {7642AEAD-7A35-45A6-8761-81D97CD8905C}.Release|x86.Build.0 = Release|Any CPU - {7642AEAD-7A35-45A6-8761-81D97CD8905C}.Remote_DEBUG|Any CPU.ActiveCfg = Release|Any CPU - {7642AEAD-7A35-45A6-8761-81D97CD8905C}.Remote_DEBUG|Any CPU.Build.0 = Release|Any CPU + {7642AEAD-7A35-45A6-8761-81D97CD8905C}.Remote_DEBUG|Any CPU.ActiveCfg = Remote_DEBUG|Any CPU + {7642AEAD-7A35-45A6-8761-81D97CD8905C}.Remote_DEBUG|Any CPU.Build.0 = Remote_DEBUG|Any CPU {7642AEAD-7A35-45A6-8761-81D97CD8905C}.Remote_DEBUG|x86.ActiveCfg = Release|Any CPU {7642AEAD-7A35-45A6-8761-81D97CD8905C}.Remote_DEBUG|x86.Build.0 = Release|Any CPU EndGlobalSection diff --git a/IOB-WIN-SHELLY/AdapterFormNext.cs b/IOB-WIN-SHELLY/AdapterFormNext.cs index fd328ab6..2d095067 100644 --- a/IOB-WIN-SHELLY/AdapterFormNext.cs +++ b/IOB-WIN-SHELLY/AdapterFormNext.cs @@ -34,7 +34,13 @@ namespace IOB_WIN_SHELLY switch (tipoScelto) { case tipoAdapter.Shelly: - iobObj = new ShellyClient(this, IOBConfFull); + case tipoAdapter.ShellyPm1: + iobObj = new ShellyClientGen1(this, IOBConfFull); + btnStart.Enabled = true; + break; + + case tipoAdapter.ShellyPro3Em: + iobObj = new ShellyClientGen2(this, IOBConfFull); btnStart.Enabled = true; break; diff --git a/IOB-WIN-SHELLY/DATA/CONF/LVF_SHELLY_01.ini b/IOB-WIN-SHELLY/DATA/CONF/LVF_SHELLY_01.ini new file mode 100644 index 00000000..d5d7d6d3 --- /dev/null +++ b/IOB-WIN-SHELLY/DATA/CONF/LVF_SHELLY_01.ini @@ -0,0 +1,67 @@ +;Configurazione IOB-WIN +[IOB] +CNCTYPE=ShellyPro3Em +PING_MS_TIMEOUT=500 +MinDeltaSec=5 +EnableRedisQueue=true +DIS_EXE_TASK=true +DIS_STATE_CH=true +IOB_NAME=LVF000 + +[MACHINE] +VENDOR=Shelly +MODEL=Pro3EM + +[CNC] +IP=192.168.2.15 +PORT=0000 + +[SERVER] +MPIP=http://192.168.1.64 +MPURL=/MP/IO +CMDBASE=/IOB/input/ +CMDFLOG=/IOB/flog/ +CMDALIVE=/IOB +CMDENABLED=/IOB/enabled/ +CMDADV1=?valore= +CMDREBO=/sendReboot.aspx?idxMacchina= +CMD_ODL_STARTED=/IOB/getCurrOdlStart/ +CMD_FORCLE_SPLIT_ODL=/IOB/forceSplitOdlFull/ +CMD_IDLE_TIME=/IOB/getIdlePeriod/ + +[MEMORY] + +[BLINK] +MAX_COUNTER_BLINK = 15 +BLINK_FILT=0 + +[OPTPAR] +DISABLE_SEND_WDST=TRUE +AUTO_CHANGE_ODL=false +; gestione custom timer +timerIntMs=100 +;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice +PZCOUNT_MODE=BIT +ENABLE_PZ_RESET=TRUE +;gestione invio pezzi in blocco +ENABLE_SEND_PZC_BLOCK=TRUE +MIN_SEND_PZC_BLOCK=0 +MAX_SEND_PZC_BLOCK=100 + +; gestione DynData +ENABLE_DYN_DATA=TRUE +FORCE_DYN_DATA=TRUE +NEW_DYN_DATA=TRUE + +; conf parametri memoria READ/WRITE +PARAM_CONF=LVF_SHELLY_01.json + +[BRANCH] +NAME=master + +; Tags manuali +[TAGS] +Customer=LVF +HostOS=WIN +HostName=Server-MAPO-IOB +HostAddr=192.168.1.208 diff --git a/IOB-WIN-SHELLY/DATA/CONF/LVF_SHELLY_01.json b/IOB-WIN-SHELLY/DATA/CONF/LVF_SHELLY_01.json new file mode 100644 index 00000000..637e47fe --- /dev/null +++ b/IOB-WIN-SHELLY/DATA/CONF/LVF_SHELLY_01.json @@ -0,0 +1,52 @@ +{ + "mMapRead": { + "Tot_Energy": { + "func": "MAX", + "onlyIncr": true, + "period": 300, + "sendEnabled": true, + "name": "Tot_Energy", + "description": "Energia totale impiegata", + "memAddr": "ActEnergy", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999999999.0, + "minVal": 0.0, + "unit": "KWh", + "value": "", + "decodeMap": [], + "displOrdinal": 1 + }, + "RT_Power": { + "func": "POINT", + "period": 60, + "sendEnabled": true, + "name": "RT_Power", + "description": "Potenza Istantanea", + "memAddr": "Power", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999999.0, + "minVal": 0.0, + "unit": "W", + "value": "", + "decodeMap": [], + "displOrdinal": 2 + } + }, + "mMapWrite": {}, + "DataDecodMap": {}, + "FileDecod": {}, + "mMapWriteLink": {}, + "OptKVP": { + "shelly_tout": "5", + "fluxLogReduce": "true", + "fluxLogRedDeadBand": "4.9", + "fluxLogResendPeriod": "60" + }, + "OptMemPar": {} +} \ No newline at end of file diff --git a/IOB-WIN-SHELLY/DATA/CONF/MAIN.ini b/IOB-WIN-SHELLY/DATA/CONF/MAIN.ini index 22176852..9192c286 100644 --- a/IOB-WIN-SHELLY/DATA/CONF/MAIN.ini +++ b/IOB-WIN-SHELLY/DATA/CONF/MAIN.ini @@ -19,7 +19,7 @@ CLI_INST=SteamWareSim ;STARTLIST=SIMUL_01,SIMUL_02,SIMUL_03,SIMUL_04 ;STARTLIST=SIMUL_01 ;STARTLIST=SHELLY_01 -STARTLIST=SIMUL_03_SHELLY - +STARTLIST=SHELLY_Pro3EM +;STARTLIST=LVF_SHELLY_01 MAXCNC=10 \ No newline at end of file diff --git a/IOB-WIN-SHELLY/DATA/CONF/SHELLY_Pro3EM.ini b/IOB-WIN-SHELLY/DATA/CONF/SHELLY_Pro3EM.ini new file mode 100644 index 00000000..10ee0ebc --- /dev/null +++ b/IOB-WIN-SHELLY/DATA/CONF/SHELLY_Pro3EM.ini @@ -0,0 +1,68 @@ +;Configurazione IOB-WIN +[IOB] +CNCTYPE=ShellyPro3Em +PING_MS_TIMEOUT=500 +MinDeltaSec=5 +EnableRedisQueue=true +DIS_EXE_TASK=true +DIS_STATE_CH=true +IOB_NAME=LVF000 + +[MACHINE] +VENDOR=Shelly +MODEL=Pro3EM + +[CNC] +IP=10.74.81.73 +PORT=0000 + +[SERVER] +MPIP=http://10.74.82.218 +MPURL=/MP/IO +CMDBASE=/IOB/input/ +CMDFLOG=/IOB/flog/ +CMDALIVE=/IOB +CMDENABLED=/IOB/enabled/ +CMDADV1=?valore= +CMDREBO=/sendReboot.aspx?idxMacchina= +CMD_ODL_STARTED=/IOB/getCurrOdlStart/ +CMD_FORCLE_SPLIT_ODL=/IOB/forceSplitOdlFull/ +CMD_IDLE_TIME=/IOB/getIdlePeriod/ + +[MEMORY] + +[BLINK] +MAX_COUNTER_BLINK = 15 +BLINK_FILT=0 + +[OPTPAR] +DISABLE_SEND_WDST=TRUE +AUTO_CHANGE_ODL=false +; gestione custom timer +timerIntMs=100 +;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice +PZCOUNT_MODE=BIT +ENABLE_PZ_RESET=TRUE +;gestione invio pezzi in blocco +ENABLE_SEND_PZC_BLOCK=TRUE +MIN_SEND_PZC_BLOCK=0 +MAX_SEND_PZC_BLOCK=100 + +; gestione DynData +ENABLE_DYN_DATA=TRUE +FORCE_DYN_DATA=TRUE +NEW_DYN_DATA=TRUE + +; conf parametri memoria READ/WRITE +PARAM_CONF=SHELLY_Pro3EM.json + +[BRANCH] +NAME=master + +; Tags manuali +[TAGS] +Customer=Steamware +HostOS=WIN +HostName=IOB-WIN-SIMULA +HostAddr=10.74.82.76 + diff --git a/IOB-WIN-SHELLY/DATA/CONF/SHELLY_Pro3EM.json b/IOB-WIN-SHELLY/DATA/CONF/SHELLY_Pro3EM.json new file mode 100644 index 00000000..00689a40 --- /dev/null +++ b/IOB-WIN-SHELLY/DATA/CONF/SHELLY_Pro3EM.json @@ -0,0 +1,289 @@ +{ + "mMapRead": { + "Tot_Energy": { + "func": "MAX", + "onlyIncr": true, + "period": 600, + "sendEnabled": true, + "name": "Tot_Energy", + "description": "Energia Totale impiegata", + "memAddr": "ActEnergy", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1000, + "maxVal": 999999999.0, + "minVal": 0.0, + "unit": "KWh", + "value": "", + "decodeMap": [], + "displOrdinal": 1 + }, + "Tot_Energy_PhaseA": { + "func": "MAX", + "onlyIncr": true, + "period": 1800, + "sendEnabled": true, + "name": "Tot_Energy_PhaseA", + "description": "Energia Totale Fase A", + "memAddr": "ActEnergy_PhaseA", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1000, + "maxVal": 999999999.0, + "minVal": 0.0, + "unit": "KWh", + "value": "", + "decodeMap": [], + "displOrdinal": 1 + }, + "Tot_Energy_PhaseB": { + "func": "MAX", + "onlyIncr": true, + "period": 1800, + "sendEnabled": true, + "name": "Tot_Energy_PhaseB", + "description": "Energia totale Fase B", + "memAddr": "ActEnergy_PhaseB", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1000, + "maxVal": 999999999.0, + "minVal": 0.0, + "unit": "KWh", + "value": "", + "decodeMap": [], + "displOrdinal": 1 + }, + "Tot_Energy_PhaseC": { + "func": "MAX", + "onlyIncr": true, + "period": 1800, + "sendEnabled": true, + "name": "Tot_Energy_PhaseC", + "description": "Energia totale Fase C", + "memAddr": "ActEnergy_PhaseC", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1000, + "maxVal": 999999999.0, + "minVal": 0.0, + "unit": "KWh", + "value": "", + "decodeMap": [], + "displOrdinal": 1 + }, + "RT_Power": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Power", + "description": "Potenza Istantanea periodo (MEDIANA)", + "memAddr": "Power", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999999.0, + "minVal": 0.0, + "unit": "W", + "value": "", + "decodeMap": [], + "displOrdinal": 2 + }, + "RT_Power_PhaseA": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Power_PhaseA", + "description": "Potenza Istantanea periodo Fase A (MEDIANA)", + "memAddr": "Power_PhaseA", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999999.0, + "minVal": 0.0, + "unit": "W", + "value": "", + "decodeMap": [], + "displOrdinal": 2 + }, + "RT_Power_PhaseB": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Power_PhaseB", + "description": "Potenza Istantanea periodo Fase B (MEDIANA)", + "memAddr": "Power_PhaseB", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999999.0, + "minVal": 0.0, + "unit": "W", + "value": "", + "decodeMap": [], + "displOrdinal": 2 + }, + "RT_Power_PhaseC": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Power_PhaseC", + "description": "Potenza Istantanea periodo Fase C (MEDIANA)", + "memAddr": "Power_PhaseC", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999999.0, + "minVal": 0.0, + "unit": "W", + "value": "", + "decodeMap": [], + "displOrdinal": 2 + }, + "RT_Current": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Current", + "description": "Corrente Istantanea periodo (MEDIANA)", + "memAddr": "Current", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999.0, + "minVal": 0.0, + "unit": "A", + "value": "", + "decodeMap": [], + "displOrdinal": 10 + }, + "RT_Current_PhaseA": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Current_PhaseA", + "description": "Corrente Istantanea periodo Fase A (MEDIANA)", + "memAddr": "Current_PhaseA", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999.0, + "minVal": 0.0, + "unit": "A", + "value": "", + "decodeMap": [], + "displOrdinal": 10 + }, + "RT_Current_PhaseB": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Current_PhaseB", + "description": "Corrente Istantanea periodo Fase B (MEDIANA)", + "memAddr": "Current_PhaseB", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999.0, + "minVal": 0.0, + "unit": "A", + "value": "", + "decodeMap": [], + "displOrdinal": 10 + }, + "RT_Current_PhaseC": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Current_PhaseC", + "description": "Corrente Istantanea periodo Fase C (MEDIANA)", + "memAddr": "Current_PhaseC", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999.0, + "minVal": 0.0, + "unit": "A", + "value": "", + "decodeMap": [], + "displOrdinal": 10 + }, + "RT_Voltage_PhaseA": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Voltage_PhaseA", + "description": "Voltaggio Fase A Istantaneo (MEDIANA)", + "memAddr": "Voltage_PhaseA", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 400.0, + "minVal": 0.0, + "unit": "V", + "value": "", + "decodeMap": [], + "displOrdinal": 21 + }, + "RT_Voltage_PhaseB": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Voltage_PhaseB", + "description": "Voltaggio Fase B Istantaneo (MEDIANA)", + "memAddr": "Voltage_PhaseB", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 400.0, + "minVal": 0.0, + "unit": "V", + "value": "", + "decodeMap": [], + "displOrdinal": 22 + }, + "RT_Voltage_PhaseC": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Voltage_PhaseC", + "description": "Voltaggio Fase C Istantaneo (MEDIANA)", + "memAddr": "Voltage_PhaseC", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 400.0, + "minVal": 0.0, + "unit": "V", + "value": "", + "decodeMap": [], + "displOrdinal": 23 + } + }, + "mMapWrite": {}, + "DataDecodMap": {}, + "FileDecod": {}, + "mMapWriteLink": {}, + "OptKVP": { + "shelly_tout": "5", + "fluxLogReduce": "true", + "fluxLogRedDeadBand": "4.9", + "fluxLogResendPeriod": "60" + }, + "OptMemPar": {} +} \ No newline at end of file diff --git a/IOB-WIN-SHELLY/DATA/CONF/SIMUL_05_SHELLY.ini b/IOB-WIN-SHELLY/DATA/CONF/SIMUL_05_SHELLY.ini new file mode 100644 index 00000000..5692d95c --- /dev/null +++ b/IOB-WIN-SHELLY/DATA/CONF/SIMUL_05_SHELLY.ini @@ -0,0 +1,68 @@ +;Configurazione IOB-WIN +[IOB] +CNCTYPE=ShellyPro3Em +PING_MS_TIMEOUT=500 +MinDeltaSec=5 +EnableRedisQueue=true +DIS_EXE_TASK=true +DIS_STATE_CH=true +IOB_NAME=SIMUL_05 + +[MACHINE] +VENDOR=Shelly +MODEL=Pro3EM + +[CNC] +IP=10.74.81.73 +PORT=0000 + +[SERVER] +MPIP=http://10.74.82.218 +MPURL=/MP/IO +CMDBASE=/IOB/input/ +CMDFLOG=/IOB/flog/ +CMDALIVE=/IOB +CMDENABLED=/IOB/enabled/ +CMDADV1=?valore= +CMDREBO=/sendReboot.aspx?idxMacchina= +CMD_ODL_STARTED=/IOB/getCurrOdlStart/ +CMD_FORCLE_SPLIT_ODL=/IOB/forceSplitOdlFull/ +CMD_IDLE_TIME=/IOB/getIdlePeriod/ + +[MEMORY] + +[BLINK] +MAX_COUNTER_BLINK = 15 +BLINK_FILT=0 + +[OPTPAR] +DISABLE_SEND_WDST=TRUE +AUTO_CHANGE_ODL=false +; gestione custom timer +timerIntMs=100 +;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice +PZCOUNT_MODE=BIT +ENABLE_PZ_RESET=TRUE +;gestione invio pezzi in blocco +ENABLE_SEND_PZC_BLOCK=TRUE +MIN_SEND_PZC_BLOCK=0 +MAX_SEND_PZC_BLOCK=100 + +; gestione DynData +ENABLE_DYN_DATA=TRUE +FORCE_DYN_DATA=TRUE +NEW_DYN_DATA=TRUE + +; conf parametri memoria READ/WRITE +PARAM_CONF=SIMUL_05_SHELLY.json + +[BRANCH] +NAME=master + +; Tags manuali +[TAGS] +Customer=Steamware +HostOS=WIN +HostName=IOB-WIN-SIMULA +HostAddr=10.74.82.76 + diff --git a/IOB-WIN-SHELLY/DATA/CONF/SIMUL_05_SHELLY.json b/IOB-WIN-SHELLY/DATA/CONF/SIMUL_05_SHELLY.json new file mode 100644 index 00000000..00689a40 --- /dev/null +++ b/IOB-WIN-SHELLY/DATA/CONF/SIMUL_05_SHELLY.json @@ -0,0 +1,289 @@ +{ + "mMapRead": { + "Tot_Energy": { + "func": "MAX", + "onlyIncr": true, + "period": 600, + "sendEnabled": true, + "name": "Tot_Energy", + "description": "Energia Totale impiegata", + "memAddr": "ActEnergy", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1000, + "maxVal": 999999999.0, + "minVal": 0.0, + "unit": "KWh", + "value": "", + "decodeMap": [], + "displOrdinal": 1 + }, + "Tot_Energy_PhaseA": { + "func": "MAX", + "onlyIncr": true, + "period": 1800, + "sendEnabled": true, + "name": "Tot_Energy_PhaseA", + "description": "Energia Totale Fase A", + "memAddr": "ActEnergy_PhaseA", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1000, + "maxVal": 999999999.0, + "minVal": 0.0, + "unit": "KWh", + "value": "", + "decodeMap": [], + "displOrdinal": 1 + }, + "Tot_Energy_PhaseB": { + "func": "MAX", + "onlyIncr": true, + "period": 1800, + "sendEnabled": true, + "name": "Tot_Energy_PhaseB", + "description": "Energia totale Fase B", + "memAddr": "ActEnergy_PhaseB", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1000, + "maxVal": 999999999.0, + "minVal": 0.0, + "unit": "KWh", + "value": "", + "decodeMap": [], + "displOrdinal": 1 + }, + "Tot_Energy_PhaseC": { + "func": "MAX", + "onlyIncr": true, + "period": 1800, + "sendEnabled": true, + "name": "Tot_Energy_PhaseC", + "description": "Energia totale Fase C", + "memAddr": "ActEnergy_PhaseC", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1000, + "maxVal": 999999999.0, + "minVal": 0.0, + "unit": "KWh", + "value": "", + "decodeMap": [], + "displOrdinal": 1 + }, + "RT_Power": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Power", + "description": "Potenza Istantanea periodo (MEDIANA)", + "memAddr": "Power", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999999.0, + "minVal": 0.0, + "unit": "W", + "value": "", + "decodeMap": [], + "displOrdinal": 2 + }, + "RT_Power_PhaseA": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Power_PhaseA", + "description": "Potenza Istantanea periodo Fase A (MEDIANA)", + "memAddr": "Power_PhaseA", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999999.0, + "minVal": 0.0, + "unit": "W", + "value": "", + "decodeMap": [], + "displOrdinal": 2 + }, + "RT_Power_PhaseB": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Power_PhaseB", + "description": "Potenza Istantanea periodo Fase B (MEDIANA)", + "memAddr": "Power_PhaseB", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999999.0, + "minVal": 0.0, + "unit": "W", + "value": "", + "decodeMap": [], + "displOrdinal": 2 + }, + "RT_Power_PhaseC": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Power_PhaseC", + "description": "Potenza Istantanea periodo Fase C (MEDIANA)", + "memAddr": "Power_PhaseC", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999999.0, + "minVal": 0.0, + "unit": "W", + "value": "", + "decodeMap": [], + "displOrdinal": 2 + }, + "RT_Current": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Current", + "description": "Corrente Istantanea periodo (MEDIANA)", + "memAddr": "Current", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999.0, + "minVal": 0.0, + "unit": "A", + "value": "", + "decodeMap": [], + "displOrdinal": 10 + }, + "RT_Current_PhaseA": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Current_PhaseA", + "description": "Corrente Istantanea periodo Fase A (MEDIANA)", + "memAddr": "Current_PhaseA", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999.0, + "minVal": 0.0, + "unit": "A", + "value": "", + "decodeMap": [], + "displOrdinal": 10 + }, + "RT_Current_PhaseB": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Current_PhaseB", + "description": "Corrente Istantanea periodo Fase B (MEDIANA)", + "memAddr": "Current_PhaseB", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999.0, + "minVal": 0.0, + "unit": "A", + "value": "", + "decodeMap": [], + "displOrdinal": 10 + }, + "RT_Current_PhaseC": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Current_PhaseC", + "description": "Corrente Istantanea periodo Fase C (MEDIANA)", + "memAddr": "Current_PhaseC", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 999.0, + "minVal": 0.0, + "unit": "A", + "value": "", + "decodeMap": [], + "displOrdinal": 10 + }, + "RT_Voltage_PhaseA": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Voltage_PhaseA", + "description": "Voltaggio Fase A Istantaneo (MEDIANA)", + "memAddr": "Voltage_PhaseA", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 400.0, + "minVal": 0.0, + "unit": "V", + "value": "", + "decodeMap": [], + "displOrdinal": 21 + }, + "RT_Voltage_PhaseB": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Voltage_PhaseB", + "description": "Voltaggio Fase B Istantaneo (MEDIANA)", + "memAddr": "Voltage_PhaseB", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 400.0, + "minVal": 0.0, + "unit": "V", + "value": "", + "decodeMap": [], + "displOrdinal": 22 + }, + "RT_Voltage_PhaseC": { + "func": "MEDIAN", + "period": 3600, + "sendEnabled": true, + "name": "RT_Voltage_PhaseC", + "description": "Voltaggio Fase C Istantaneo (MEDIANA)", + "memAddr": "Voltage_PhaseC", + "tipoMem": "Real", + "index": 0, + "size": 0, + "factor": 1.0, + "maxVal": 400.0, + "minVal": 0.0, + "unit": "V", + "value": "", + "decodeMap": [], + "displOrdinal": 23 + } + }, + "mMapWrite": {}, + "DataDecodMap": {}, + "FileDecod": {}, + "mMapWriteLink": {}, + "OptKVP": { + "shelly_tout": "5", + "fluxLogReduce": "true", + "fluxLogRedDeadBand": "4.9", + "fluxLogResendPeriod": "60" + }, + "OptMemPar": {} +} \ No newline at end of file diff --git a/IOB-WIN-SHELLY/IOB-WIN-SHELLY.csproj b/IOB-WIN-SHELLY/IOB-WIN-SHELLY.csproj index b77f3847..8a1e0386 100644 --- a/IOB-WIN-SHELLY/IOB-WIN-SHELLY.csproj +++ b/IOB-WIN-SHELLY/IOB-WIN-SHELLY.csproj @@ -45,7 +45,7 @@ - ..\packages\EgwProxy.Shelly.3.7.2507.1012\lib\EgwProxy.Shelly.dll + ..\packages\EgwProxy.Shelly.3.7.2508.708\lib\EgwProxy.Shelly.dll ..\packages\Flurl.4.0.0\lib\net461\Flurl.dll @@ -136,7 +136,8 @@ Form - + + Form @@ -170,6 +171,18 @@ Always + + Always + + + Always + + + Always + + + Always + Always @@ -182,12 +195,18 @@ Always + + Always + Always Always + + Always + Always diff --git a/IOB-WIN-SHELLY/Iob/ShellyClient.cs b/IOB-WIN-SHELLY/Iob/ShellyClientGen1.cs similarity index 92% rename from IOB-WIN-SHELLY/Iob/ShellyClient.cs rename to IOB-WIN-SHELLY/Iob/ShellyClientGen1.cs index d112feb9..27de8db4 100644 --- a/IOB-WIN-SHELLY/Iob/ShellyClient.cs +++ b/IOB-WIN-SHELLY/Iob/ShellyClientGen1.cs @@ -19,9 +19,9 @@ using System.Threading.Tasks; namespace IOB_WIN_SHELLY.Iob { /// - /// Classe gestione oggetti Shelly + /// Classe gestione oggetti Shelly tipo PM1 (Gen1) /// - public class ShellyClient : Iob.GenericNext + public class ShellyClientGen1 : GenericNext { #region Public Constructors @@ -32,9 +32,9 @@ namespace IOB_WIN_SHELLY.Iob /// /// Form chiamante /// Configurazione (v 4.x) - public ShellyClient(AdapterFormNext caller, IobConfTree IobConfFull) : base(caller, IobConfFull) + public ShellyClientGen1(AdapterFormNext caller, IobConfTree IobConfFull) : base(caller, IobConfFull) { - lgInfo("Init Iob.ShellyClient"); + lgInfo("Init Iob.ShellyClientGen1"); // imposto ping a 3 maxQueuePing = 3; // imposto @@ -59,7 +59,7 @@ namespace IOB_WIN_SHELLY.Iob } var devData = IobConfFull.Device.Connect; - Shelly1PmOptions options = new Shelly1PmOptions() + ShellyOptions options = new ShellyOptions() { DefaultTimeout = TimeSpan.FromMilliseconds(devData.PingMsTimeout * 10), ServerUri = new Uri($"http://{devData.IpAddr}/rpc") @@ -98,22 +98,22 @@ namespace IOB_WIN_SHELLY.Iob { case "ActEnergy": outValDbl = lastShellyResp.Value.ActEnergy.Total; - //outVal = lastShellyResp.Value.ActEnergy.Total.ToString("F3", CultureInfo.InvariantCulture); + //outVal = lastShellyRespRT.Value.ActEnergy.Total.ToString("F3", CultureInfo.InvariantCulture); break; case "Current": outValDbl = lastShellyResp.Value.Current; - //outVal = lastShellyResp.Value.Current.ToString("F3", CultureInfo.InvariantCulture); + //outVal = lastShellyRespRT.Value.Current.ToString("F3", CultureInfo.InvariantCulture); break; case "Power": outValDbl = lastShellyResp.Value.Power; - //outVal = lastShellyResp.Value.Power.ToString("F3", CultureInfo.InvariantCulture); + //outVal = lastShellyRespRT.Value.Power.ToString("F3", CultureInfo.InvariantCulture); break; case "Voltage": outValDbl = lastShellyResp.Value.Voltage; - //outVal = lastShellyResp.Value.Voltage.ToString("F3", CultureInfo.InvariantCulture); + //outVal = lastShellyRespRT.Value.Voltage.ToString("F3", CultureInfo.InvariantCulture); break; default: diff --git a/IOB-WIN-SHELLY/Iob/ShellyClientGen2.cs b/IOB-WIN-SHELLY/Iob/ShellyClientGen2.cs new file mode 100644 index 00000000..b2654b92 --- /dev/null +++ b/IOB-WIN-SHELLY/Iob/ShellyClientGen2.cs @@ -0,0 +1,372 @@ +using EgwProxy.Shelly; +using EgwProxy.Shelly.Clients; +using EgwProxy.Shelly.Options; +using IOB_UT_NEXT; +using IOB_UT_NEXT.Config; +using MapoSDK; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Net.NetworkInformation; +using System.Threading; +using System.Threading.Tasks; + +namespace IOB_WIN_SHELLY.Iob +{ + /// + /// Classe gestione oggetti Shelly tipo Gen2 (Pro3Em) + /// + public class ShellyClientGen2 : GenericNext + { + #region Public Constructors + + /// + /// Estende l'init della classe base, impiegando il pacchetto EgwProxy.Shelly + /// - gestione dei task da svolgere da configurazione json specifica + /// - specializzazione da conf e non da codice + /// + /// Form chiamante + /// Configurazione (v 4.x) + public ShellyClientGen2(AdapterFormNext caller, IobConfTree IobConfFull) : base(caller, IobConfFull) + { + lgInfo("Init Iob.ShellyClientGen2"); + // imposto ping a 3 + maxQueuePing = 3; + // imposto + B_input = 0; + // init datetime counters + DateTime adesso = DateTime.Now; + lastPzCountSend = adesso; + lastWarnODL = adesso; + vetoCheckStatus = adesso; + // 2023.09.05 imposto anche primo ping e check disconnected... + lastPING = adesso; + lastDisconnCheck = adesso; + var VETO_PING_SEC = getOptPar("VETO_PING_SEC"); + if (!string.IsNullOrEmpty(VETO_PING_SEC)) + { + int.TryParse(VETO_PING_SEC, out vetoPingSec); + } + var POWEROFF_TIMEOUT_SEC = getOptPar("POWEROFF_TIMEOUT_SEC"); + if (!string.IsNullOrEmpty(POWEROFF_TIMEOUT_SEC)) + { + int.TryParse(POWEROFF_TIMEOUT_SEC, out PoweroffTimeoutSec); + } + + var devData = IobConfFull.Device.Connect; + ShellyOptions options = new ShellyOptions() + { + DefaultTimeout = TimeSpan.FromMilliseconds(devData.PingMsTimeout * 10), + ServerUri = new Uri($"http://{devData.IpAddr}/rpc") + }; + // init secondo il tipo di Shelly... + + shellyCli = new ShellyPro3EmClient(new HttpClient(), options); + + // invio conf macchina all'inizio + SendMachineConf(); + } + + #endregion Public Constructors + + #region Public Methods + + public override Dictionary getDynData() + { + Dictionary outData = new Dictionary(); + // verifico che non sia una chiamata troppo frequente, ogni 10 sec minimo... + if (DateTime.Now > lastReadPLC.AddSeconds(shellyCallDelay)) + { + // chiama lettura status valor RT (Potenza, Corrente...) + lastShellyRespRT = Task.Run(() => ((ShellyPro3EmClient)shellyCli).GetEmStatus(CancellationToken.None, 0)).Result; + lastShellyRespEnergy = Task.Run(() => ((ShellyPro3EmClient)shellyCli).GetEmDataStatus(CancellationToken.None, 0)).Result; + + // Salvo negli oggetti DynData x EnergyTotal + if (lastShellyRespEnergy.IsSuccess) + { + lastReadPLC = DateTime.Now; + // recupero da conf memMap e ciclo + foreach (var item in IOBConfFull.Memory.mMapRead) + { + //string outVal = ""; + double outValDbl = 0; + // se trovo includo in dynData... + switch (item.Value.memAddr) + { + case "ActEnergy": + outValDbl = lastShellyRespEnergy.Value.TotalAll.ActEnergy; + break; + + case "ActEnergy_PhaseA": + outValDbl = lastShellyRespEnergy.Value.TotalPhaseA.ActEnergy; + break; + + case "ActEnergy_PhaseB": + outValDbl = lastShellyRespEnergy.Value.TotalPhaseB.ActEnergy; + break; + + case "ActEnergy_PhaseC": + outValDbl = lastShellyRespEnergy.Value.TotalPhaseC.ActEnergy; + break; + + default: + break; + } + // modalità saveValue x reduce fLog + saveValue(ref outData, item.Key, outValDbl); + } + } + + // Salvo negli oggetti DynData x RT + if (lastShellyRespRT.IsSuccess) + { + lastReadPLC = DateTime.Now; + // recupero da conf memMap e ciclo + foreach (var item in IOBConfFull.Memory.mMapRead) + { + //string outVal = ""; + double outValDbl = 0; + // se trovo includo in dynData... + switch (item.Value.memAddr) + { + + case "Current": + outValDbl = lastShellyRespRT.Value.TotalCurrent; + break; + case "Current_Neutral": + outValDbl = lastShellyRespRT.Value.NeutralCurrent; + break; + case "Current_PhaseA": + outValDbl = lastShellyRespRT.Value.PhaseA.Current; + break; + case "Current_PhaseB": + outValDbl = lastShellyRespRT.Value.PhaseB.Current; + break; + case "Current_PhaseC": + outValDbl = lastShellyRespRT.Value.PhaseC.Current; + break; + + case "Freq_PhaseA": + outValDbl = lastShellyRespRT.Value.PhaseA.Frequency; + break; + case "Freq_PhaseB": + outValDbl = lastShellyRespRT.Value.PhaseB.Frequency; + break; + case "Freq_PhaseC": + outValDbl = lastShellyRespRT.Value.PhaseC.Frequency; + break; + + case "Power": + outValDbl = lastShellyRespRT.Value.TotalActivePower; + break; + case "Power_PhaseA": + outValDbl = lastShellyRespRT.Value.PhaseA.ActivePower; + break; + case "Power_PhaseB": + outValDbl = lastShellyRespRT.Value.PhaseB.ActivePower; + break; + case "Power_PhaseC": + outValDbl = lastShellyRespRT.Value.PhaseC.ActivePower; + break; + + case "Voltage_PhaseA": + outValDbl = lastShellyRespRT.Value.PhaseA.Voltage; + break; + case "Voltage_PhaseB": + outValDbl = lastShellyRespRT.Value.PhaseB.Voltage; + break; + case "Voltage_PhaseC": + outValDbl = lastShellyRespRT.Value.PhaseC.Voltage; + break; + + default: + break; + } + // modalità saveValue x reduce fLog + saveValue(ref outData, item.Key, outValDbl); + } + } + // traccio dati ricevuti + trackExchDataRaw(lastShellyRespRT, 512); + // traccio dati ricevuti + trackExchDataRaw(lastShellyRespEnergy, 256); + } + return outData; + } + + /// + /// Effettua lettura semafori principale Parametri da + /// aggiornare x display in form + /// + public override void readSemafori(ref newDisplayData currDispData) + { + DateTime adesso = DateTime.Now; + // se ha risposto ad ultima chiamata --> ok + if (connectionOk && adesso.Subtract(lastReadPLC).TotalMinutes < 1) + { + B_input = 3; + // aggiungo NON emergenza... + B_input += (1 << 7); + } + else + { + B_input = 0; + } + lastReadPLC = DateTime.Now; + lastWatchDog = adesso; + } + + public override void startAdapter(bool resetQueue) + { + base.startAdapter(resetQueue); + // 2023.09.05 imposto anche primo ping e check disconnected... + DateTime adesso = DateTime.Now; + lastWatchDog = adesso; + //lastPING = adesso; + lastReadPLC = adesso; + lastDisconnCheck = adesso; + // faccio un primo check POST ritardo + tryConnect(); + } + + /// + /// Override connessione + /// + public override void tryConnect() + { + bool doLog = (verboseLog || periodicLog); + lgDebug($"Shelly: tryConnect step 01 | connectionOk: {connectionOk}"); + if (!connectionOk) + { + //// resetto coda... + //QueuePing = new DataQueue("000", "QueuePing", false); + // controllo che il ping sia stato tentato almeno pingTestSec fa... + if (DateTime.Now.Subtract(lastPING).TotalSeconds > vetoPingSec) + { + if (doLog) + { + lgInfo("Shelly: ConnKO - tryConnect"); + } + lgDebug("Shelly: tryConnect step 04"); + + lgDebug("Shelly: Reset QueuePing"); + + bool pingOK = testPingMachine == IPStatus.Success; + addTest(pingOK); + + // se passa il ping faccio il resto... + if (pingStatusOk() || pingOK) + { + // in primis salvo data ping... + lastPING = DateTime.Now; + connectionOk = true; + queueInEnabCurr = true; + lgInfo("Shelly - ping OK"); + } + else + { + // loggo no risposta ping ... + lgError("Shelly - ping KO"); + } + } + } + } + + /// + /// Override disconnessione + /// + public override void tryDisconnect() + { + lgInfo("Richiesta disconnessione adapter Shelly!"); + connectionOk = false; + queueInEnabCurr = false; + } + + #endregion Public Methods + + #region Private Fields + + private static Stopwatch sw = new Stopwatch(); + + /// + /// Oggetto dove viene salvata ultima risposta Shelly x dati RT (potenza, correnti, ...) + /// + private ShellyResult lastShellyRespRT; + + /// + /// Oggetto dove viene salvata ultima risposta Shelly x dati Energia (Total per fase e globle) + /// + private ShellyResult lastShellyRespEnergy; + + private int PoweroffTimeoutSec = 100; + + /// + /// Delay tra chiamate in sec + /// + private int shellyCallDelay = 1; + + /// + /// Client interno x comunicazione con Shelly devices + /// + private ShellyClientBase shellyCli; + + /// + /// Veto controllo status x log... + /// + private DateTime vetoCheckStatus = DateTime.Now; + + #endregion Private Fields + + #region Private Methods + + private void addTest(bool pingOk) + { + int score = pingOk ? 1 : 0; + // controllo: se era spenta e risulta ping ok --> reset coda! + if (B_input == 0 && pingOk) + { + B_input = 1; + QueuePing = new DataQueue(IOBConfFull.General.FilenameIOB, "QueuePing", false, redisMan); + lgTrace($"QueuePing resetted on addTest"); + } + QueuePing.Enqueue($"{score}"); + while (QueuePing.Count > maxQueuePing) + { + string res = ""; + QueuePing.TryDequeue(out res); + } + } + + /// + /// Calcola status ping: + /// - se ha ‹ 50% coda richiesta --› true + /// - se ha › 50% coda richiesta --› true se è maggior parte a 1 (true) + /// + /// + private bool pingStatusOk() + { + bool answ = false; + long numVal = QueuePing.Count; + if (numVal > maxQueuePing / 2) + { + var listaValori = QueuePing.ToList(); + long numOk = listaValori.Where(x => x == "1").Count(); + long numKo = numVal - numOk; + answ = numOk >= numKo; + lgTrace($"PING ok per: {numOk} > {numKo}"); + } + else + { + lgTrace($"PING check: {answ} per mancanza dati minimi test"); + } + return answ; + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/IOB-WIN-SHELLY/packages.config b/IOB-WIN-SHELLY/packages.config index c75a6381..18ba6cab 100644 --- a/IOB-WIN-SHELLY/packages.config +++ b/IOB-WIN-SHELLY/packages.config @@ -1,6 +1,6 @@  - + diff --git a/IOB-WIN-SHELLY/postBuildTgt.bat b/IOB-WIN-SHELLY/postBuildTgt.bat index 6bcfa2f4..5e33ef77 100644 --- a/IOB-WIN-SHELLY/postBuildTgt.bat +++ b/IOB-WIN-SHELLY/postBuildTgt.bat @@ -44,7 +44,8 @@ REM ROBOCOPY %2 \\10.51.90.5\Steamware\IOB-WIN-SHELLY-DEB /MIR REM ROBOCOPY %2 \\10.51.90.5\Steamware\IOB-WIN-SHELLY-DEB /MIR /log:RobocopyTransfer.log REM ROBOCOPY %2 Z:\IOB-WIN-SHELLY-DEB /MIR REM ROBOCOPY %2 \\10.51.90.10\Steamware\IOB-WIN-SHELLY-DEB /MIR -ROBOCOPY %2 \\10.51.90.9\Steamware\IOB-WIN-SHELLY-DEB /MIR +REM ROBOCOPY %2 \\10.51.90.9\Steamware\IOB-WIN-SHELLY-DEB /MIR +ROBOCOPY %2 \\10.51.90.13\Steamware\IOB-WIN-SHELLY-DEB /MIR goto END