Ancora bozza omron

This commit is contained in:
Samuele E. Locatelli
2019-10-30 19:05:33 +01:00
parent 533cb2364e
commit bdbc16053d
4 changed files with 191 additions and 173 deletions
+4 -17
View File
@@ -10,6 +10,7 @@ MODEL=MiscelazioneOssidiFerro
[CNC]
IP=192.168.250.1
PORT=9600
OM_MOD=CP1EM60DRA
[SERVER]
@@ -51,26 +52,12 @@ BLINK_FILT=0
[OPTPAR]
;PZCOUNT_MODE=STD.[PAR/MEM].info|BIT.indice
; attenzione memoria sempre base BYTE (1604 DW --> 6416...)
PZCOUNT_MODE=STD.DB1275.DBDW4
PZCOUNT_MODE=STD.DM1275.DBDW4
DISABLE_PZCOUNT=TRUE
ENABLE_DYN_DATA=TRUE
FORCE_DYN_DATA=TRUE
TSVC_Power_01=MAX:5
TSVC_Power_02=MAX:5
TSVC_Power_03=MAX:5
TSVC_Power_04=MAX:5
TSVC_TempPirom_01=MAX:5
TSVC_TempPirom_02=MAX:5
TSVC_TempPirom_03=MAX:5
TSVC_TempPirom_04=MAX:5
TSVC_TempCool_01=MAX:5
TSVC_TempCool_02=MAX:5
TSVC_TempCool_03=MAX:5
TSVC_TempCool_04=MAX:5
TSVC_PartStatus_01=MAX:5
TSVC_PartStatus_02=MAX:5
TSVC_PartStatus_03=MAX:5
TSVC_PartStatus_04=MAX:5
; conf parametri memoria READ/WRITE
PARAM_CONF=INTERCL_02.json
[BRANCH]
NAME=master
+154
View File
@@ -0,0 +1,154 @@
{
"mMapWrite": {
"kgParz": {
"name": "kgParz",
"tipoMem": "Int",
"index": 66,
"size": 2,
"value": "0"
},
"set_th": {
"name": "set_th",
"tipoMem": "Int",
"index": 72,
"size": 2,
"value": "0"
},
"set_c": {
"name": "set_c",
"tipoMem": "Real",
"index": 74,
"size": 4,
"value": "0"
},
"aria_1": {
"name": "aria_1",
"tipoMem": "Int",
"index": 78,
"size": 2,
"value": "0"
},
"aria_2": {
"name": "aria_2",
"tipoMem": "Int",
"index": 80,
"size": 2,
"value": "0"
},
"setMmH20": {
"name": "setMmH20",
"tipoMem": "Real",
"index": 82,
"size": 4,
"value": "0"
},
"rpmci": {
"name": "rpmci",
"tipoMem": "Int",
"index": 86,
"size": 2,
"value": "0"
}
},
"mMapRead": {
"T_Attuale_Cil": {
"name": "T_Attuale_Cil",
"tipoMem": "Real",
"index": 16,
"size": 4,
"func": "MAX",
"period": 5,
"value": "0"
},
"Bruc_0_100": {
"name": "Bruc_0_100",
"tipoMem": "Int",
"index": 28,
"size": 2,
"func": "MAX",
"period": 5,
"value": "0"
},
"Dep_Cil_mmH2O": {
"name": "Dep_Cil_mmH2O",
"tipoMem": "Int",
"index": 30,
"size": 2,
"func": "MAX",
"period": 5,
"value": "0"
},
"Asp_0_100": {
"name": "Asp_0_100",
"tipoMem": "Int",
"index": 32,
"size": 2,
"func": "MAX",
"period": 5,
"value": "0"
},
"Ampere_Asp": {
"name": "Ampere_Asp",
"tipoMem": "Int",
"index": 34,
"size": 2,
"func": "MAX",
"period": 5,
"value": "0"
},
"Temp_Filtro": {
"name": "Temp_Filtro",
"tipoMem": "Int",
"index": 36,
"size": 2,
"func": "MAX",
"period": 5,
"value": "0"
},
"Ampere_Cil": {
"name": "Ampere_Cil",
"tipoMem": "Int",
"index": 38,
"size": 2,
"func": "MAX",
"period": 5,
"value": "0"
},
"Flowrate": {
"name": "Flowrate",
"tipoMem": "Int",
"index": 40,
"size": 2,
"func": "MAX",
"period": 5,
"value": "0"
},
"Ampere_Dosat": {
"name": "Ampere_Dosat",
"tipoMem": "Int",
"index": 42,
"size": 2,
"func": "MAX",
"period": 5,
"value": "0"
},
"Tot_Parz_Dosatore": {
"name": "Tot_Parz_Dosatore",
"tipoMem": "DInt",
"index": 48,
"size": 4,
"func": "MAX",
"period": 5,
"value": "0"
},
"Tot_Dosatore": {
"name": "Tot_Dosatore",
"tipoMem": "DInt",
"index": 52,
"size": 4,
"func": "MAX",
"period": 5,
"value": "0"
}
}
}
+3
View File
@@ -234,6 +234,9 @@
<None Include="DATA\CONF\3015.ini">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\INTERCL_02.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="DATA\CONF\INTERCL_01.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+30 -156
View File
@@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using OmronFinsTCP;
namespace IOB_WIN
{
@@ -57,18 +56,6 @@ namespace IOB_WIN
/// </summary>
protected System.Collections.ArrayList resDataArray;
/// <summary>
/// Comando inviato al robot
/// </summary>
protected string comando;
/// <summary>
/// Variabile verifica thread comunicazione
/// </summary>
protected bool threadOk = false;
/// <summary>
/// Nome e seriale macchina
/// </summary>
protected string macName = "";
/// <summary>
/// Variabile STATUS corrente (8bit INT)
/// </summary>
protected string cStatus;
@@ -84,10 +71,6 @@ namespace IOB_WIN
/// Ultimo TC registrato da robot
/// </summary>
protected decimal lastRecTC;
/// <summary>
/// Ultima missione svolta da robot
/// </summary>
protected string lastMissRobot;
/// <summary>
/// estende l'init della classe base...
@@ -101,6 +84,7 @@ namespace IOB_WIN
lastPzCountSend = DateTime.Now;
lastWarnODL = DateTime.Now;
#if false
OMRON_ref = new OmronFinsTCP.Net.EtherNetPLC();
OMRON_ref.Link("192.168.250.1", 9600, 500);
short[] response;
@@ -125,7 +109,8 @@ namespace IOB_WIN
valoriWord[i] = (short)i;
}
OMRON_ref.WriteWords(OmronFinsTCP.Net.PlcMemory.WR, 0, 10, valoriWord);
OMRON_ref.WriteWords(OmronFinsTCP.Net.PlcMemory.WR, 0, 10, valoriWord);
#endif
// init connessione
setConnection();
@@ -315,7 +300,6 @@ namespace IOB_WIN
// fix enable prgName
enablePrgName = fIni.ReadBoolean("CNC", "GETPRGNAME", false);
#if false
// SE è necessario refresh...
if (needRefresh)
{
@@ -325,19 +309,8 @@ namespace IOB_WIN
{
try
{
string connPar = string.Format("TCP {0}", cIobConf.cncIpAddr);
OMRON_ref = new KRcc.Commu(connPar);
//OMRON_ref = new KRcc.Commu("TCP 192.168.0.92");
// disconnetto e connetto...
if (utils.CRB("verbose"))
{
lgInfo("OMRON: tryDisconnect");
}
//tryDisconnect();
//lgInfo("OMRON: tryConnect");
//tryConnect();
lgInfo("End init Adapter OMRON");
short esitoLink = doConnect();
lgInfo($"End init Adapter OMRON, esitoLink: {esitoLink}");
if (utils.CRB("verbose"))
{
lgInfo("OMRON CONNESSIONE AVVENUTA");
@@ -351,6 +324,7 @@ namespace IOB_WIN
}
parentForm.commPlcActive = false;
// gestione pzCounter
#if false
if (utils.CRB("enableContapezzi"))
{
lgInfo("OMRON: inizio gestione contapezzi");
@@ -383,22 +357,35 @@ namespace IOB_WIN
{
lgError(exc, "Errore in contapezzi OMRON");
}
}
}
}
#endif
}
}
/// <summary>
/// Vera connessione ad OMRON
/// </summary>
/// <returns></returns>
private short doConnect()
{
// avvio un oggetto di comunicazione OMRON
OMRON_ref = new OmronFinsTCP.Net.EtherNetPLC();
short port = 9600;
short.TryParse(cIobConf.cncPort, out port);
short esitoLink = OMRON_ref.Link(cIobConf.cncIpAddr, port, 500);
return esitoLink;
}
/// <summary>
/// Override disconnessione
/// </summary>
public override void tryDisconnect()
{
#if false
if (connectionOk)
{
string szStatusConnection = "";
try
{
OMRON_ref.disconnect();
OMRON_ref.Close();
connectionOk = false;
lgInfo(szStatusConnection);
lgInfo("Effettuata disconnessione adapter OMRON!");
@@ -411,15 +398,13 @@ namespace IOB_WIN
else
{
lgError("IMPOSSIBILE effettuare disconnessione OMRON: Connessione non disponibile...");
}
#endif
}
}
/// <summary>
/// Override connessione
/// </summary>
public override void tryConnect()
{
#if false
if (!connectionOk)
{
// controllo che il ping sia stato tentato almeno pingTestSec fa...
@@ -439,10 +424,9 @@ namespace IOB_WIN
{
// ora provo connessione...
parentForm.commPlcActive = true;
string connPar = string.Format("TCP {0}", cIobConf.cncIpAddr);
OMRON_ref.connect(connPar);
short esitoLink = doConnect();
lgInfo($"szStatusConnection OMRON, esitoLink: {esitoLink}");
parentForm.commPlcActive = false;
lgInfo("szStatusConnection: " + OMRON_ref.IsConnected);
connectionOk = true;
// refresh stato allarmi!!!
if (connectionOk)
@@ -466,9 +450,9 @@ namespace IOB_WIN
}
catch (Exception exc)
{
lgFatal(string.Format("Errore nella connessione all'adapter OMRON: {0}{1}{2}", szStatusConnection, Environment.NewLine, exc));
lgFatal($"Errore nella connessione all'adapter OMRON: {szStatusConnection}{Environment.NewLine}{exc}");
connectionOk = false;
lgInfo(string.Format("Eccezione in TryConnect, Adapter OMRON NON running, pausa di {0} msec prima di ulteriori tentativi di riconnessione", utils.CRI("waitRecMSec")));
lgInfo($"Eccezione in TryConnect, Adapter OMRON NON running, pausa di {utils.CRI("waitRecMSec")} msec prima di ulteriori tentativi di riconnessione");
}
}
else
@@ -477,7 +461,7 @@ namespace IOB_WIN
connectionOk = false;
if (verboseLog || periodicLog)
{
lgInfo(string.Format("Attenzione: OMRON controllo PING fallito per IP {0}", cIobConf.cncIpAddr));
lgInfo($"Attenzione: OMRON controllo PING fallito per IP {cIobConf.cncIpAddr}");
}
}
}
@@ -487,8 +471,7 @@ namespace IOB_WIN
{
// processo semafori ed invio...
processMemoryDiscon();
}
#endif
}
}
/// <summary>
@@ -505,24 +488,6 @@ namespace IOB_WIN
resDataArray = OMRON_ref.command("TYPE i_prelevati", 3000); // num pz prelevati --> "0\r\n"
int.TryParse(resDataArray[1].ToString().Replace("\n", "").Replace("\r", ""), out answ);
}
#endif
return answ;
}
}
/// <summary>
/// Oggetto per lettura ULTIMO TC rilevato
/// </summary>
protected decimal lastTC
{
get
{
decimal answ = 0;
#if false
if (OMRON_ref.IsConnected)
{
resDataArray = OMRON_ref.command("TYPE r_tempo", 3000); // ultimo TCiclo rilevato --> " 349.19\r\n"
decimal.TryParse(resDataArray[1].ToString().Replace("\n", "").Replace("\r", "").Replace(".", ","), out answ);
}
#endif
return answ;
}
@@ -557,62 +522,6 @@ namespace IOB_WIN
}
}
/// <summary>
/// Verifica se il thread 4 di comm sia attivo
/// </summary>
protected bool commThreadOk
{
get
{
bool answ = false;
#if false
if (OMRON_ref.IsConnected)
{
int retVal = 0;
resDataArray = OMRON_ref.command("TYPE TASK (1004)", 3000); // thread 4 ok --> " 1\r\n"
int.TryParse(resDataArray[1].ToString().Replace("\n", "").Replace("\r", ""), out retVal);
answ = (retVal == 1);
}
#endif
return answ;
}
}
/// <summary>
/// Recupera nome e seriale macchina
/// </summary>
protected string machineName
{
get
{
string answ = "";
#if false
if (OMRON_ref.IsConnected)
{
resDataArray = OMRON_ref.command("TYPE $id_true", 3000); // id macchina --> "BX100N-B001 Sn. 2366\r\n"
answ = resDataArray[1].ToString().Replace("\n", "").Replace("\r", "");
}
#endif
return answ;
}
}
/// <summary>
/// Recupera ultima missione svolta
/// </summary>
protected string lastMission
{
get
{
string answ = "";
#if false
if (OMRON_ref.IsConnected)
{
resDataArray = OMRON_ref.command("TYPE $exe", 3000); // missione --> "\r\n" (vuoto, no missione)
answ = resDataArray[1].ToString().Replace("\n", "").Replace("\r", "");
}
#endif
return answ;
}
}
/// <summary>
/// Restituisce stato macchina nel formato (da sx a dx):
/// B0: POWER_ON
/// B1: AUTO
@@ -712,13 +621,11 @@ namespace IOB_WIN
parentForm.sIN = Semaforo.SV;
// effettuo TUTTE le letture
threadOk = commThreadOk;
cStatus = currBitmapStatus;
cSignals = currBitmapSignals;
lastCountCNC = pzCounter;
// decodifica e gestione
decodeToBaseBitmap();
decodeOtherData();
}
/// <summary>
@@ -852,37 +759,6 @@ namespace IOB_WIN
#endif
}
/// <summary>
/// Decodifica il resto dell'area x i dati accessori (allarmi, ...)
/// </summary>
private void decodeOtherData()
{
if (verboseLog)
{
}
}
/// <summary>
/// Recupero programma in lavorazione
/// </summary>
/// <returns></returns>
public override string getPrgName()
{
// valore non presente in vers default... se gestito fare override
string prgName = "";
return prgName;
}
/// <summary>
/// Recupero info sistema generiche
/// <returns></returns>
public override Dictionary<string, string> getSysInfo()
{
// valore non presente in vers default... se gestito fare override
Dictionary<string, string> outVal = new Dictionary<string, string>();
outVal.Add("MACHINE", machineName);
return outVal;
}
/// <summary>
/// Recupero dati dinamici...
/// </summary>
@@ -890,8 +766,6 @@ namespace IOB_WIN
{
// valore non presente in vers default... se gestito fare override
Dictionary<string, string> outVal = new Dictionary<string, string>();
outVal.Add("LAST_MISS", lastMissRobot);
outVal.Add("LAST_TC", lastTC.ToString());
outVal.Add("NUM_PZ_PREL", pzPrelevati.ToString());
outVal.Add("NUM_PZ_LAV", pzCounter.ToString());
outVal.Add("CURR_SIGNALS", currBitmapSignals.ToString());