Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Samuele E. Locatelli
2017-05-22 09:22:52 +02:00
18 changed files with 1821 additions and 967 deletions
+11 -1
View File
@@ -245,9 +245,11 @@ namespace MTC_Adapter
if (utils.CRB("verbose")) lg.Info("step 01: impostato INI File {0}", iniPath);
loadOtherFile();
parentForm.commPlcActive = true;
//ncDevice = new thdNcEsaGvKvara(EsaIni, mapIOT_Byte.Length, mapIOT_Word.Length, mapIOT_DWord.Length, 255); // impostato a 255 byte (char) FISSO x la parte stringa... mapIOT_String.Length);
ncDevice = new thdNcEsaGvKvara(EsaIni, numByte, numWord, numDWord, numString); // impostato a 255 byte (char) FISSO x la parte stringa... mapIOT_String.Length);
parentForm.commPlcActive = false;
if (utils.CRB("verbose")) lg.Info("step 02: avviato thdNcEsaGvKvara da INI File {0}", iniPath);
@@ -315,9 +317,11 @@ namespace MTC_Adapter
if (connectionOk)
{
// leggo TUTTO il blocco di memoria
parentForm.commPlcActive = true;
inizio = DateTime.Now;
ncDevice.ReadBufferByte();
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-Byte", ncDevice.PLC_MemoryAreaIOT_Byte.Length), DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
}
else
{
@@ -582,9 +586,11 @@ namespace MTC_Adapter
if (connectionOk)
{
// leggo TUTTO il blocco di memoria
parentForm.commPlcActive = true;
inizio = DateTime.Now;
ncDevice.ReadBufferWord();
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-Word", ncDevice.PLC_MemoryAreaIOT_Word.Length), DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
}
else
{
@@ -779,9 +785,11 @@ namespace MTC_Adapter
if (connectionOk)
{
// leggo TUTTO il blocco di memoria
parentForm.commPlcActive = true;
inizio = DateTime.Now;
ncDevice.ReadBufferDWord();
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-DWord", ncDevice.PLC_MemoryAreaIOT_DWord.Length), DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
}
else
{
@@ -942,9 +950,11 @@ namespace MTC_Adapter
if (connectionOk)
{
// leggo TUTTO il blocco di memoria
parentForm.commPlcActive = true;
inizio = DateTime.Now;
ncDevice.ReadBufferString();
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-PLC_IOT-DWord", ncDevice.PLC_MemoryAreaIOT_DWord.Length), DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
}
else
{
+26 -6
View File
@@ -30,11 +30,13 @@ namespace MTC_Adapter
{
try
{
parentForm.commPlcActive = true;
answ = FANUC_ref.F_RW_Byte(bWrite, MemType, memIndex, ref Value);
}
catch
{ }
}
parentForm.commPlcActive = false;
return answ;
}
/// <summary>
@@ -52,11 +54,13 @@ namespace MTC_Adapter
{
try
{
parentForm.commPlcActive = true;
answ = FANUC_ref.F_RW_Byte(bWrite, MemType, memIndex, ref Value);
}
catch
{ }
}
parentForm.commPlcActive = false;
return answ;
}
@@ -79,7 +83,9 @@ namespace MTC_Adapter
{
lg.Info("Start init Adapter FANUC all'IP {0}", utils.CRS("ipPLC"));
parentForm.commPlcActive = true;
Runtime.CreateNC(CNC.NcType.FANUC, utils.CRS("ipPLC"));
parentForm.commPlcActive = false;
// inizializzo posizioni assi...
prevPosAxis = new double[adpConf.nAxis];
@@ -130,7 +136,9 @@ namespace MTC_Adapter
string szStatusConnection = "";
try
{
parentForm.commPlcActive = true;
FANUC_ref.Connect(ref szStatusConnection);
parentForm.commPlcActive = false;
lg.Info("szStatusConnection: " + szStatusConnection);
connectionOk = true;
// refresh stato allarmi!!!
@@ -209,7 +217,7 @@ namespace MTC_Adapter
string UnkStrobe = "";
// !!!FARE!!! multipath...
// verifico i vari strobe x recuperare i dati... PER ORA SOLO DW1 per path1 (indice 0)...
//int idxPath = 0;
int idxPath = 0;
int memIndex = 0;
int bitNum = 0;
inizio = DateTime.Now;
@@ -264,18 +272,18 @@ namespace MTC_Adapter
// AREA strobe USER ACTION
// chiamato Start...
bitNum = 4;
gestStrobeUserAction(bitNum, ref retACK_DW1, ref UserAction, " (START) ");
gestStrobeUserAction(idxPath, bitNum, ref retACK_DW1, ref UserAction, " (START) ");
// chiamato Stop...
bitNum = 5;
gestStrobeUserAction(bitNum, ref retACK_DW1, ref UserAction, " (STOP) ");
gestStrobeUserAction(idxPath, bitNum, ref retACK_DW1, ref UserAction, " (STOP) ");
// chiamato Reset...
bitNum = 6;
gestStrobeUserAction(bitNum, ref retACK_DW1, ref UserAction, " (RESET) ");
gestStrobeUserAction(idxPath, bitNum, ref retACK_DW1, ref UserAction, " (RESET) ");
// processo tutti gli strobe x i BIT 7-29 NON gestiti in modo da dare comunque ACK e event...
for (int i = 7; i < 30; i++)
{
gestStrobeUserAction(i, ref retACK_DW1, ref UnkStrobe, string.Format(" [STROBE_{0:00}] ", i));
gestStrobeUserAction(idxPath, i, ref retACK_DW1, ref UnkStrobe, string.Format(" [STROBE_{0:00}] ", i));
}
// AREA strobe x TEST
@@ -353,7 +361,7 @@ namespace MTC_Adapter
int memIndex = 10508;
return FanucMemRW(W, FANUC.MemType.R, memIndex, ref retACK_DW);
}
/// <summary>
/// Recupero info su test: numero + elenco parametri IN/OUT
/// </summary>
@@ -770,9 +778,11 @@ namespace MTC_Adapter
sb1.AppendLine(string.Format("POWER {0}: | EmStop:{1:N3} | ProcSel: {2}", mPower.Value, mEStop.Value, mProcSel.Value));
// leggo dati globali...
parentForm.commPlcActive = true;
inizio = DateTime.Now;
allDynData = FANUC_ref.getAllDynData();
if (utils.CRB("recTime")) TimingData.addResult("R-ALL-DYN-DATA", DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
FeedRate = allDynData.actf;
@@ -798,9 +808,11 @@ namespace MTC_Adapter
{
sb1.AppendLine(string.Format("Allarmi CNC: {0}", allDynData.alarm));
parentForm.commPlcActive = true;
inizio = DateTime.Now;
allarmiCNC = FANUC_ref.getCncAlarm();
if (utils.CRB("recTime")) TimingData.addResult("R-CNC-ALARMS", DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
checkCNCAlarms();
}
else
@@ -1000,9 +1012,11 @@ namespace MTC_Adapter
base.getPath();
// recupero vettore generale G MODE
parentForm.commPlcActive = true;
inizio = DateTime.Now;
CMSCncLib.Focas1.ODBGCD vettGCodes = FANUC_ref.getPathGCodeMod();
if (utils.CRB("recTime")) TimingData.addResult("R-GCodModal", DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
string GCodAttivi = "";
GCodAttivi += string.Format("[{0}]", vettGCodes.gcd0.code);
@@ -1034,17 +1048,21 @@ namespace MTC_Adapter
GCodAttivi += string.Format("[{0}]", vettGCodes.gcd26.code);
GCodAttivi += string.Format("[{0}]", vettGCodes.gcd27.code);
parentForm.commPlcActive = true;
inizio = DateTime.Now;
vettGCodes = FANUC_ref.getPathGCode1Shot();
parentForm.commPlcActive = false;
if (utils.CRB("recTime")) TimingData.addResult("R-GCodOneShot", DateTime.Now.Subtract(inizio).Ticks);
if (vettGCodes.gcd0.flag > 0) GCodAttivi += string.Format("[{0}]", vettGCodes.gcd0.code);
if (vettGCodes.gcd1.flag > 0) GCodAttivi += string.Format("[{0}]", vettGCodes.gcd1.code);
if (vettGCodes.gcd2.flag > 0) GCodAttivi += string.Format("[{0}]", vettGCodes.gcd2.code);
if (vettGCodes.gcd3.flag > 0) GCodAttivi += string.Format("[{0}]", vettGCodes.gcd3.code);
parentForm.commPlcActive = true;
inizio = DateTime.Now;
CMSCncLib.Focas1.ODB5AXMAN vettTTCoord = FANUC_ref.getPathTTCoord();
if (utils.CRB("recTime")) TimingData.addResult("R-TTCoord", DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
// ciclo su path
StringBuilder sb_2;
@@ -1088,6 +1106,7 @@ namespace MTC_Adapter
// mostro assi in DataMonitor......
StringBuilder sb = new StringBuilder();
parentForm.commPlcActive = true;
inizio = DateTime.Now;
CMSCncLib.Focas1.ODBPOS posAssi = FANUC_ref.getAllAxisPos();
if (utils.CRB("recTime")) TimingData.addResult("R-AXIS_POS", DateTime.Now.Subtract(inizio).Ticks);
@@ -1095,6 +1114,7 @@ namespace MTC_Adapter
inizio = DateTime.Now;
CMSCncLib.Focas1.ODBSVLOAD loadAssi = FANUC_ref.getAllAxisLoad();
if (utils.CRB("recTime")) TimingData.addResult("R-AXIS_LOAD", DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
CMSCncLib.Focas1.LOADELM valLoad = new CMSCncLib.Focas1.LOADELM();
CMSCncLib.Focas1.POSELMALL valPos = new CMSCncLib.Focas1.POSELMALL();
+12 -7
View File
@@ -1678,6 +1678,7 @@ namespace MTC_Adapter
public virtual void startAdapter(int port)
{
lg.Info("Starting adapter...");
parentForm.commPlcActive = false;
adpRunning = true;
dtAvvioAdp = DateTime.Now;
TimingData.resetData();
@@ -1867,6 +1868,7 @@ namespace MTC_Adapter
parentForm.dataMonitor_2 = "";
parentForm.dataMonitor_3 = "";
parentForm.displayTaskAndWait("Adapter Stopped.");
parentForm.commPlcActive = false;
}
/// <summary>
@@ -2040,6 +2042,8 @@ namespace MTC_Adapter
// riporto conteggio medio al secondo...
lg.Info("Chiamate GLOBALI: {0}, periodo: {1:N2} minuti.cent, tempo medio {2:N2} msec | impegno canale {3:P3}", globNumCall, DateTime.Now.Subtract(dtAvvioAdp).TotalMinutes, globAvgMsec.TotalMilliseconds / globNumCall, globAvgMsec.TotalSeconds / DateTime.Now.Subtract(dtAvvioAdp).TotalSeconds);
lg.Info("{0}--------------- STOP TIMING DATA ---------------{0}", Environment.NewLine);
// mostro in form statistiche globali!
parentForm.updateComStats(string.Format("Periodo: {0:N2}min | {1} x {2:N2}ms | canale {3:P3}", DateTime.Now.Subtract(dtAvvioAdp).TotalMinutes, globNumCall, globAvgMsec.TotalMilliseconds / globNumCall, globAvgMsec.TotalSeconds / DateTime.Now.Subtract(dtAvvioAdp).TotalSeconds));
}
}
@@ -2387,13 +2391,14 @@ namespace MTC_Adapter
/// <summary>
/// Gestione strobe UserAction: salva dati e gestione ACK
/// </summary>
/// <param name="idxPath"></param>
/// <param name="bitNum"></param>
/// <param name="retACK_DW1"></param>
/// <param name="UserAction"></param>
/// <param name="azione"></param>
public void gestStrobeUserAction(int bitNum, ref byte[] retACK_DW1, ref string UserAction, string azione)
public void gestStrobeUserAction(int idxPath, int bitNum, ref byte[] retACK_DW1, ref string UserAction, string azione)
{
if (STRB_DW1.HasFlag((StFlag32)Math.Pow(2, bitNum)))
if (STRB_DW1.HasFlag((StFlag32)Math.Pow(2, bitNum + 16 * idxPath)))
{
// salvo evento UserAction in variabile...
UserAction += azione;
@@ -2628,7 +2633,7 @@ namespace MTC_Adapter
// converto! e aggiungo allarmi sollevati al corretto controller allarmi...
if (STRB_DW3.HasFlag((StFlag32)Math.Pow(2, i)))
{
SubMode += string.Format(" [P{0:00}_{1}]", idxPath, elencoSubMode[i.ToString()]);
SubMode += string.Format(" [P{0:00}_{1}]", idxPath + 1, elencoSubMode[i.ToString()]);
}
}
}
@@ -2719,7 +2724,7 @@ namespace MTC_Adapter
// converto! e aggiungo allarmi sollevati al corretto controller allarmi...
if (STRB_DW4.HasFlag((StFlag32)Math.Pow(2, i)))
{
SubMode += string.Format(" [P{0:00}_{1}]", idxPath, elencoSubMode[i.ToString()]);
SubMode += string.Format(" [P{0:00}_{1}]", idxPath + 1, elencoSubMode[i.ToString()]);
}
}
}
@@ -2836,13 +2841,13 @@ namespace MTC_Adapter
// AREA strobe USER ACTION
// chiamato Start...
bitNum = 4;
gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} START) ", idxPath));
gestStrobeUserAction(idxPath, bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} START) ", idxPath + 1));
// chiamato Stop...
bitNum = 5;
gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} STOP) ", idxPath));
gestStrobeUserAction(idxPath, bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} STOP) ", idxPath + 1));
// chiamato Reset...
bitNum = 6;
gestStrobeUserAction(bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} RESET) ", idxPath));
gestStrobeUserAction(idxPath, bitNum, ref currACK_DW, ref UserAction, string.Format(" (P{0:00} RESET) ", idxPath + 1));
}
else
+20
View File
@@ -30,11 +30,13 @@ namespace MTC_Adapter
{
try
{
parentForm.commPlcActive = true;
answ = OSAI_ref.O_RW_Byte(bWrite, MemType, memIndex, memOrderStart, ref Value);
}
catch
{ }
}
parentForm.commPlcActive = false;
return answ;
}
/// <summary>
@@ -52,11 +54,13 @@ namespace MTC_Adapter
{
try
{
parentForm.commPlcActive = true;
answ = OSAI_ref.O_RW_Word(bWrite, MemType, memIndex, ref Value);
}
catch
{ }
}
parentForm.commPlcActive = false;
return answ;
}
/// <summary>
@@ -74,11 +78,13 @@ namespace MTC_Adapter
{
try
{
parentForm.commPlcActive = true;
answ = OSAI_ref.O_RW_DWord(bWrite, MemType, memIndex, ref Value);
}
catch
{ }
}
parentForm.commPlcActive = false;
return answ;
}
/// <summary>
@@ -96,11 +102,13 @@ namespace MTC_Adapter
{
try
{
parentForm.commPlcActive = true;
answ = OSAI_ref.O_RW_Short(bWrite, MemType, memIndex, ref Value);
}
catch
{ }
}
parentForm.commPlcActive = false;
return answ;
}
/// <summary>
@@ -118,11 +126,13 @@ namespace MTC_Adapter
{
try
{
parentForm.commPlcActive = true;
answ = OSAI_ref.O_RW_Integer(bWrite, MemType, memIndex, ref Value);
}
catch
{ }
}
parentForm.commPlcActive = false;
return answ;
}
/// <summary>
@@ -140,11 +150,13 @@ namespace MTC_Adapter
{
try
{
parentForm.commPlcActive = true;
answ = OSAI_ref.O_RW_Double(bWrite, MemType, memIndex, ref Value);
}
catch
{ }
}
parentForm.commPlcActive = false;
return answ;
}
@@ -175,8 +187,10 @@ namespace MTC_Adapter
prevPosAxis = new double[adpConf.nAxis];
prevDirAxis = new int[adpConf.nAxis];
parentForm.commPlcActive = true;
OSAI_ref = (OSAI)Runtime.NC;
if (utils.CRB("verbose")) lg.Info(string.Format("Generato oggetto OSAI_ref da CMSCncLib:{0}{1}", Environment.NewLine, OSAI_ref.Descrizione));
parentForm.commPlcActive = false;
// disconnetto e connetto...
if (utils.CRB("verbose")) lg.Info("OSAI: tryDisconnect");
@@ -517,9 +531,11 @@ namespace MTC_Adapter
sb1.AppendLine(string.Format("POWER {0}: | EmStop:{1:N3} | ProcSel: {2}", mPower.Value, mEStop.Value, mProcSel.Value));
// leggo dati globali...
parentForm.commPlcActive = true;
inizio = DateTime.Now;
OSAI_ref.O_GetNcInfo1(ref allNcData);
if (utils.CRB("recTime")) TimingData.addResult("R-NcInfo", DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
// recupero speed e feed...
FeedRate = Convert.ToInt32(allNcData.realfeed);
@@ -838,10 +854,12 @@ namespace MTC_Adapter
public override void getPath()
{
// recupero vettore generale G MODE
parentForm.commPlcActive = true;
inizio = DateTime.Now;
ushort[] vettGCodes = new ushort[14];
OSAI_ref.getPathGCodeMod(ref vettGCodes);
if (utils.CRB("recTime")) TimingData.addResult("R-GCodModal", DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
// attenzione: il vettore contiene come campi "vuoti" il valore MAX di USHort (16bit) ovvero 2^16 -1 (base 0) --> 65535
string GCodAttivi = "";
@@ -907,6 +925,7 @@ namespace MTC_Adapter
// mostro assi in DataMonitor......
StringBuilder sb = new StringBuilder();
parentForm.commPlcActive = true;
inizio = DateTime.Now;
// inizializzo x numero assi...
CMSCncLib.OPENcontrol.GETINTDATA[] posAssiTgt = new CMSCncLib.OPENcontrol.GETINTDATA[currAdpConf.nAxis];
@@ -914,6 +933,7 @@ namespace MTC_Adapter
OSAI_ref.getAllAxisPos(1, ref posAssiTgt);
OSAI_ref.getAllAxisPos(2, ref posAssi);
if (utils.CRB("recTime")) TimingData.addResult("R-AXIS_POS", DateTime.Now.Subtract(inizio).Ticks);
parentForm.commPlcActive = false;
// nuova posizione (per calcoli)
double newPos = 0;
+116 -73
View File
@@ -27,8 +27,7 @@ namespace MTC_Adapter
/// Area di memoria base x dati TESTE (DB254)
/// </summary>
protected int baseMemUO = 254;
/// <summary>
/// wrapper chiamata lettura/scrittura SINGOLO BYTE...
/// </summary>
@@ -40,10 +39,22 @@ namespace MTC_Adapter
public bool SIEMENSMemRW_Byte(bool bWrite, int MemType, Int32 memIndex, ref byte Value)
{
bool answ = false;
// chiamo la versione multibyte...
byte[] ValArray = new byte[1];
SIEMENSMemRW_Byte(bWrite, MemType, memIndex, ref ValArray);
Value = ValArray[0];
if (SIEMENS_ref.Connected)
{
try
{
parentForm.commPlcActive = true;
// chiamo la versione multibyte...
byte[] ValArray = new byte[1];
SIEMENSMemRW_Byte(bWrite, MemType, memIndex, ref ValArray);
Value = ValArray[0];
}
catch (Exception exc)
{
lg.Error(string.Format("Eccezione in SIEMENSMemRW_Byte: {0}{1}", Environment.NewLine, exc));
}
}
parentForm.commPlcActive = false;
return answ;
}
/// <summary>
@@ -61,11 +72,15 @@ namespace MTC_Adapter
{
try
{
parentForm.commPlcActive = true;
answ = SIEMENS_ref.S_RW_Byte(bWrite, MemType, memIndex, ref Value);
}
catch
{ }
catch (Exception exc)
{
lg.Error(string.Format("Eccezione in SIEMENSMemRW_ByteArray: {0}{1}", Environment.NewLine, exc));
}
}
parentForm.commPlcActive = false;
return answ;
}
/// <summary>
@@ -83,11 +98,15 @@ namespace MTC_Adapter
{
try
{
parentForm.commPlcActive = true;
answ = SIEMENS_ref.S_RW_Word(bWrite, MemType, memIndex, ref Value);
}
catch
{ }
catch (Exception exc)
{
lg.Error(string.Format("Eccezione in SIEMENSMemRW_Word: {0}{1}", Environment.NewLine, exc));
}
}
parentForm.commPlcActive = false;
return answ;
}
/// <summary>
@@ -105,11 +124,15 @@ namespace MTC_Adapter
{
try
{
parentForm.commPlcActive = true;
answ = SIEMENS_ref.S_RW_DWord(bWrite, MemType, memIndex, ref Value);
}
catch
{ }
catch(Exception exc)
{
lg.Error(string.Format("Eccezione in SIEMENSMemRW_DWord: {0}{1}", Environment.NewLine, exc));
}
}
parentForm.commPlcActive = false;
return answ;
}
@@ -133,9 +156,11 @@ namespace MTC_Adapter
// !!!HARD CODED!!! aggiunto banco STATUS del 2 processo IN CODA... (4+1)DW=20byte x strobes...!!!
Strobes = new byte[20];
lg.Info("Start init Adapter SIEMENS", utils.CRS("ipPLC"));
lg.Info("Start init Adapter SIEMENS");
parentForm.commPlcActive = true;
Runtime.CreateNC(CNC.NcType.SIEMENS, utils.CRS("ipPLC"));
parentForm.commPlcActive = false;
// inizializzo posizioni assi...
prevPosAxis = new double[adpConf.nAxis];
@@ -151,7 +176,6 @@ namespace MTC_Adapter
tryConnect();
lg.Info("End init Adapter SIEMENS");
}
/// <summary>
/// Override disconnessione
/// </summary>
@@ -218,7 +242,6 @@ namespace MTC_Adapter
}
}
}
/// <summary>
/// Verifico connessione SIEMENS...
/// </summary>
@@ -232,7 +255,7 @@ namespace MTC_Adapter
}
/// <summary>
/// Effettuo lettura dei 16 byte di strobe/status
/// Effettuo lettura dei 16+4 byte di strobe/status
/// </summary>
public override void getStrobeAndAckStatus()
{
@@ -270,14 +293,14 @@ namespace MTC_Adapter
// processo ora i dati dei path... di sicuro il primo
currStrobe = (StFlag8)(Strobes[4]); // 5° byte
currAck = (StFlag8)(Acknowl[4]); // 5° byte
procPathStrobes(0, currStrobe, currAck, 246, 24, ref UserAction);
procPathStrobes(0, currStrobe, currAck, 164, 4, ref UserAction);
//...e se c'è pure il secondo...
if (currAdpConf.nPath > 1)
{
currStrobe = (StFlag8)(Strobes[6]); // 7° byte
currAck = (StFlag8)(Acknowl[6]); // 7° byte
procPathStrobes(1, currStrobe, currAck, 292, 26, ref UserAction);
procPathStrobes(1, currStrobe, currAck, 210, 6, ref UserAction);
}
// 2017.01.16 INVIO vettore azioni (1 o +)... SE CE NE SONO!
@@ -290,7 +313,7 @@ namespace MTC_Adapter
// verifico strobe dell'auto-test
currStrobe = (StFlag8)(Strobes[7]); // 8° byte
currAck = (StFlag8)(Acknowl[7]); // 8° byte
processTestStrobe(currStrobe, currAck, 26, 1);
processTestStrobe(currStrobe, currAck, 7, 1);
// gestione bit di watchdog... sulal DWord successiva
sendWatchDog();
@@ -308,7 +331,7 @@ namespace MTC_Adapter
try
{
inizio = DateTime.Now;
SIEMENSMemRW_Byte(W, baseMemDb, memIndexAck, ref currACK_DW);
SIEMENSMemRW_Byte(W, baseMemDb, memIndexAck, ref currACK_DW);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("W{0}-ACK_DW0", currACK_DW.Length), DateTime.Now.Subtract(inizio).Ticks);
fatto = true;
}
@@ -342,7 +365,6 @@ namespace MTC_Adapter
}
return fatto;
}
/// <summary>
/// Scrive watchdog
/// </summary>
@@ -350,8 +372,8 @@ namespace MTC_Adapter
/// <returns></returns>
public override bool writeWatchDog(ref byte[] retACK_DW)
{
int memIndex = 38;
return SIEMENSMemRW_Byte(W, baseMemDb, memIndex, ref retACK_DW);
int memIndex = 8;
return SIEMENSMemRW_Byte(W, baseMemDb, memIndex, ref retACK_DW);
}
/// <summary>
/// Effettua lettura dati TESTING
@@ -364,7 +386,7 @@ namespace MTC_Adapter
try
{
// leggo tutto!!!
int memIndex = 522;
int memIndex = 256;
inizio = DateTime.Now;
SIEMENSMemRW_DWord(R, baseMemDb, memIndex, ref MemBlockTestData);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-TEST_DATA", MemBlockTestData.Length), DateTime.Now.Subtract(inizio).Ticks);
@@ -386,7 +408,7 @@ namespace MTC_Adapter
{
// DB1499.DBX0.0
int memIndexAck = 0;
return SIEMENSMemRW_Byte(W, baseMemDb, memIndexAck, ref retACK_DW0);
return SIEMENSMemRW_Byte(W, baseMemDb, memIndexAck, ref retACK_DW0);
}
/// <summary>
@@ -396,8 +418,8 @@ namespace MTC_Adapter
/// <returns></returns>
public override bool readAllAlarms(ref uint[] MemBlock)
{
// DB1499.DBW118
int memIndex = 118;
// DB1499.DBW36
int memIndex = 36;
return SIEMENSMemRW_DWord(R, baseMemDb, memIndex, ref MemBlock);
}
/// <summary>
@@ -408,55 +430,63 @@ namespace MTC_Adapter
/// <returns></returns>
public override bool readAlarmBlock(ref uint[] MemBlock, int blockIndex)
{
// DB1499.DBW118
int memIndex = 118;
return SIEMENSMemRW_DWord(R, baseMemDb, memIndex + blockIndex * 2, ref MemBlock);
// DB1499.DBW36
int memIndex = 36;
return SIEMENSMemRW_DWord(R, baseMemDb, memIndex + blockIndex * 4, ref MemBlock);
}
/// <summary>
/// Gestione lettura dati manutenzione
/// </summary>
private void getMtzDataFromPlc()
{
// recupero i dati di manutenzione dall'area di memoria IN BLOCCO
int memIndex = 822;
uint[] tabDatiMtz = new uint[maintData.Length];
inizio = DateTime.Now;
SIEMENSMemRW_DWord(R, baseMemDb, memIndex, ref tabDatiMtz);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-DatiMtz", tabDatiMtz.Length * 4), DateTime.Now.Subtract(inizio).Ticks);
// decodifico aree memoria secondo tab configurazione
processMaintData(tabDatiMtz, maintData);
// verifica se debba salvare e mostrare dati
checkSavePersDataLayer();
if (maintData.Length > 0)
{
// recupero i dati di manutenzione dall'area di memoria IN BLOCCO
int memIndex = 524;
uint[] tabDatiMtz = new uint[maintData.Length];
inizio = DateTime.Now;
SIEMENSMemRW_DWord(R, baseMemDb, memIndex, ref tabDatiMtz);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-DatiMtz", tabDatiMtz.Length * 4), DateTime.Now.Subtract(inizio).Ticks);
// decodifico aree memoria secondo tab configurazione
processMaintData(tabDatiMtz, maintData);
// verifica se debba salvare e mostrare dati
checkSavePersDataLayer();
}
}
/// <summary>
/// Gestione lettura dati status da PLC
/// </summary>
private void getStatusDataFromPlc()
{
if (statusData.Length > 0)
{
// recupero i dati di manutenzione dall'area di memoria IN BLOCCO
int memIndex = 1036;
int numByte = 1 + (statusData.Length / 8);
byte[] tabDatiStatus = new byte[numByte];
inizio = DateTime.Now;
SIEMENSMemRW_Byte(R, baseMemDb, memIndex, ref tabDatiStatus);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-DatiStatus", tabDatiStatus.Length), DateTime.Now.Subtract(inizio).Ticks);
// decodifico aree memoria secondo tab configurazione
processStatusData(tabDatiStatus, statusData);
}
}
/// <summary>
/// Gestione lettura dati analogici
/// </summary>
private void getAnalogDataFromPlc()
{
// recupero i dati di manutenzione dall'area di memoria IN BLOCCO
int memIndex = 1350;
uint[] tabDatiAnalog = new uint[analogData.Length];
inizio = DateTime.Now;
SIEMENSMemRW_DWord(R, baseMemDb, memIndex, ref tabDatiAnalog);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-DatiAnalog", tabDatiAnalog.Length * 4), DateTime.Now.Subtract(inizio).Ticks);
// decodifico aree memoria secondo tab configurazione
processAnalogData(tabDatiAnalog, analogData);
}
/// <summary>
/// Gestione lettura dati status da PLC
/// </summary>
private void getStatusDataFromPlc()
{
// recupero i dati di manutenzione dall'area di memoria IN BLOCCO
int memIndex = 1334;
int numByte = 1 + (statusData.Length / 8);
byte[] tabDatiStatus = new byte[numByte];
inizio = DateTime.Now;
SIEMENSMemRW_Byte(R, baseMemDb, memIndex, ref tabDatiStatus);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-DatiStatus", tabDatiStatus.Length), DateTime.Now.Subtract(inizio).Ticks);
// decodifico aree memoria secondo tab configurazione
processStatusData(tabDatiStatus, statusData);
if (analogData.Length > 0)
{
// recupero i dati di manutenzione dall'area di memoria IN BLOCCO
int memIndex = 1052;
uint[] tabDatiAnalog = new uint[analogData.Length];
inizio = DateTime.Now;
SIEMENSMemRW_DWord(R, baseMemDb, memIndex, ref tabDatiAnalog);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-DatiAnalog", tabDatiAnalog.Length * 4), DateTime.Now.Subtract(inizio).Ticks);
// decodifico aree memoria secondo tab configurazione
processAnalogData(tabDatiAnalog, analogData);
}
}
/// <summary>
/// Leggo dati globali comuni (x path, assi...)
@@ -541,8 +571,9 @@ namespace MTC_Adapter
protected override void loadOtherFile()
{
base.loadOtherFile();
loadMaintData("R", 14000, 4);
loadStatusData("R", 14512, 1);
loadMaintData("DB1499", 524, 4);
loadStatusData("DB1499", 1036, 1);
loadAnalogData("DB1499", 1052, 1);
}
/// <summary>
/// Processing allarmi CNC
@@ -614,7 +645,7 @@ namespace MTC_Adapter
public override void getUnOp()
{
// leggo in blocco tutte le speed da memoria...
int memIndex = 3140;
int memIndex = 140;
// buffer memoria 60 byte... speed (16bit 2 * 20) + load (8bit 1 * 20) visto che sono 20 teste max
byte[] unOpSpeedMem = new byte[60];
@@ -633,9 +664,11 @@ namespace MTC_Adapter
public override int getDatiUt_step4(ref byte[] int32Mem, int j)
{
int memIndex = 13100 + 4 * j;
#if false
inizio = DateTime.Now;
SIEMENSMemRW_Byte(R, baseMemUT, memIndex, ref int32Mem);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-TabUT-VitaRes", int32Mem.Length), DateTime.Now.Subtract(inizio).Ticks);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-TabUT-VitaRes", int32Mem.Length), DateTime.Now.Subtract(inizio).Ticks);
#endif
return memIndex;
}
/// <summary>
@@ -647,9 +680,11 @@ namespace MTC_Adapter
public override int getDatiUt_step3b(ref byte int8Mem, int j)
{
int memIndex = 10700 + 1 * j;
#if false
inizio = DateTime.Now;
SIEMENSMemRW_Byte(R, baseMemUT, memIndex, ref int8Mem);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-TabUT-FamUT", 8), DateTime.Now.Subtract(inizio).Ticks);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-TabUT-FamUT", 8), DateTime.Now.Subtract(inizio).Ticks);
#endif
return memIndex;
}
/// <summary>
@@ -660,9 +695,11 @@ namespace MTC_Adapter
public override int getDatiUt_step3a(ref byte[] tabFam_FamUt)
{
int memIndex = 8900;
#if false
inizio = DateTime.Now;
SIEMENSMemRW_Byte(R, baseMemUT, memIndex, ref tabFam_FamUt);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-TabFamUT-FamUT", tabFam_FamUt.Length), DateTime.Now.Subtract(inizio).Ticks);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-TabFamUT-FamUT", tabFam_FamUt.Length), DateTime.Now.Subtract(inizio).Ticks);
#endif
return memIndex;
}
/// <summary>
@@ -674,9 +711,11 @@ namespace MTC_Adapter
public override int getDatiUt_step2b(ref byte[] int16Mem, int j)
{
int memIndex = 11700 + 2 * j;
#if false
inizio = DateTime.Now;
SIEMENSMemRW_Byte(R, baseMemUT, memIndex, ref int16Mem);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-TabUT-FamUT", int16Mem.Length), DateTime.Now.Subtract(inizio).Ticks);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-TabUT-FamUT", int16Mem.Length), DateTime.Now.Subtract(inizio).Ticks);
#endif
return memIndex;
}
/// <summary>
@@ -687,9 +726,11 @@ namespace MTC_Adapter
public override int getDatiUt_step2a(ref byte[] tabUt_UT)
{
int memIndex = 11300;
#if false
inizio = DateTime.Now;
SIEMENSMemRW_Byte(R, baseMemUT, memIndex, ref tabUt_UT);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-TabUT-UT", tabUt_UT.Length), DateTime.Now.Subtract(inizio).Ticks);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-TabUT-UT", tabUt_UT.Length), DateTime.Now.Subtract(inizio).Ticks);
#endif
return memIndex;
}
/// <summary>
@@ -700,9 +741,11 @@ namespace MTC_Adapter
public override int getDatiUt_step1(ref byte[] elencoUtMem)
{
int memIndex = 2960;
#if false
inizio = DateTime.Now;
SIEMENSMemRW_Byte(R, baseMemUT, memIndex, ref elencoUtMem);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-NUMUT", elencoUtMem.Length), DateTime.Now.Subtract(inizio).Ticks);
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-NUMUT", elencoUtMem.Length), DateTime.Now.Subtract(inizio).Ticks);
#endif
return memIndex;
}
@@ -2,6 +2,7 @@
<!-- For more information on using app.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="waitEndCycle" value="0" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="loglevel" value="5" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="mode" value="prod" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="autoLoadConf" value="true" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
@@ -2,6 +2,7 @@
<!-- For more information on using app.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="waitEndCycle" value="0" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="loglevel" value="5" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="mode" value="prod" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="autoLoadConf" value="true" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
@@ -2,6 +2,8 @@
<!-- For more information on using app.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="timerIntMs" value="10" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="waitEndCycle" value="20" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="loglevel" value="5" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="mode" value="prod" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="autoLoadConf" value="true" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
@@ -2,6 +2,7 @@
<!-- For more information on using app.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="waitEndCycle" value="0" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="loglevel" value="5" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="mode" value="prod" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="autoLoadConf" value="true" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
+6 -4
View File
@@ -1,19 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<startup useLegacyV2RuntimeActivationPolicy="true">
<!--<startup>-->
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
<!--<supportedRuntime version="v3.5" sku=".NETFramework,Version=v3.5"/>-->
<supportedRuntime version="v2.0" sku=".NETFramework,Version=v2.0"/>
<!--<supportedRuntime version="v2.0" sku=".NETFramework,Version=v2.0"/>-->
</startup>
<appSettings>
<add key="appName" value="MTConnect Adapter"/>
<!--gestione TIMERS e periodi multipli x thread lenti-->
<add key="startTimerMs" value="250"/>
<add key="timerIntMs" value="5"/><!--invio da adapter ad agent: 5ms-->
<add key="timerIntMs" value="10"/><!--invio da adapter ad agent: 5ms-->
<add key="fastCount" value="20"/><!--100ms-->
<add key="normCount" value="50"/><!--250ms-->
<add key="slowCount" value="500"/><!--2.5 sec-->
<add key="alarmSyncCount" value="6000"/><!--30 sec-->
<add key="waitEndCycle" value="20"/><!--20ms attesa dopo ogni ciclo lettura...-->
<!--30 sec-->
<!--parametri gestione watchdog-->
<add key="maxAdapterLockSec" value="5"/>
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<AdapterConf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Version>1</Version>
<NomeAdapt>ADAPTER_OSAI</NomeAdapt>
<TipoAdapt>OSAI</TipoAdapt>
<NomeAdapt>ADAPTER_SIEMENS</NomeAdapt>
<TipoAdapt>SIEMENS</TipoAdapt>
<ContOreMaccOn>0</ContOreMaccOn>
<ContOreMaccLav>0</ContOreMaccLav>
<ContSlittaTast>0</ContSlittaTast>
@@ -41,11 +41,13 @@
<ident>ProtMagazzino_01</ident>
<dataRefList />
</element>
</ProtMag>
<SlittaMag>
<element>
<ident>ProtMagazzino_02</ident>
<ident>SlittaMagazzino_</ident>
<dataRefList />
</element>
</ProtMag>
</SlittaMag>
<Cooler>
<element>
<ident>Cooler_01</ident>
File diff suppressed because it is too large Load Diff
@@ -1,7 +1 @@
# Commenti con cancelletto, struttura un variabile per riga, tipo chiave|valore (occhio che il separatore è configurato da .cofig come "testCharSep"); spazi e tabulazioni dovrei trimmarli in acquisizione (qui inseriti per comodità di lettura)
001|Axis_01_Load |NUM
002|Axis_02_Load |NUM
003|Axis_03_Load |NUM
004|Axis_04_Load |NUM
005|Axis_05_Load |NUM
006|Axis_06_Load |NUM
# Commenti con cancelletto, struttura un variabile per riga, tipo chiave|valore (occhio che il separatore è configurato da .cofig come "testCharSep"); spazi e tabulazioni dovrei trimmarli in acquisizione (qui inseriti per comodità di lettura)
@@ -21,8 +21,8 @@
020|VacAct_02_Count |COUNT
021|Lubro_01_Num |COUNT
022|SlittaTastatore_Count |COUNT
023|ProtMagazzino_01_Count |COUNT
024|ProtMagazzino_02_Count |COUNT
023|SlittaMagazzino_01_Count |COUNT
024|ProtMagazzino_01_Count |COUNT
025|UnOp_01_NumCambiUT |COUNT
026|Axis_01_AccTime |COUNT
027|Axis_02_AccTime |COUNT
File diff suppressed because it is too large Load Diff
+25
View File
@@ -108,6 +108,14 @@ namespace MTC_Adapter
lg.Info(txt2show);
Thread.Sleep(startTimerMs);
}
/// <summary>
/// Mostra update delle statistiche di comunicazione (numero chiamate, tempo medio...)
/// </summary>
/// <param name="txt2show"></param>
public void updateComStats(string txt2show)
{
lblComStats.Text = string.Format("{0} | ", txt2show);
}
#endregion
@@ -563,6 +571,10 @@ namespace MTC_Adapter
checkSlowTask();
// check esecuzione AlarmSync
checkAlarmSync();
if (utils.CRI("waitEndCycle") > 0)
{
Thread.Sleep(utils.CRI("waitEndCycle"));
}
}
else
{
@@ -597,6 +609,19 @@ namespace MTC_Adapter
{
MainProgrBar.Value = 0;
}
/// <summary>
/// Visualizzazione stato di comunicazione attiva con PLC
/// </summary>
public bool commPlcActive
{
set
{
// se true --> comunica/verde, altrimenti grigio
lblApp.ForeColor = value ? Color.SeaGreen : Color.Black;
lblVers.ForeColor = value ? Color.SeaGreen : Color.DarkSlateGray;
statusStrip1.Refresh();
}
}
private void checkAlarmSync()
{
+3
View File
@@ -2676,6 +2676,9 @@
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
</value>
</data>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>59</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAA0AAAAAAAEAIAA3LgAA1gAAAICAAAABACAAKAgBAA0vAACAgAAAAQAIAChMAAA1NwEAQEAAAAEA
@@ -36,6 +36,18 @@
<dataRefList />
</element>
</Lubro>
<ProtMag>
<element>
<ident>ProtMagazzino_01</ident>
<dataRefList />
</element>
</ProtMag>
<SlittaMag>
<element>
<ident>SlittaMagazzino_</ident>
<dataRefList />
</element>
</SlittaMag>
<Cooler>
<element>
<ident>Cooler_01</ident>
@@ -71,6 +83,10 @@
<ident>Path_01</ident>
<dataRefList />
</element>
<element>
<ident>Path_02</ident>
<dataRefList />
</element>
</Path>
<UnOp>
<element>