update x gestione nuove aree memoria 14512
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
<DataItem category="EVENT" id="FUNCT_MODE" type="MESSAGE"/>
|
||||
<DataItem category="EVENT" id="USER_ACTION" type="MESSAGE"/>
|
||||
<DataItem category="EVENT" id="TESTING_DATA" type="MESSAGE"/>
|
||||
<DataItem category="EVENT" id="PROTECTION_STATUS" type="MESSAGE"/>
|
||||
<DataItem category="EVENT" id="UNK_STATUS" type="MESSAGE"/>
|
||||
<DataItem category="EVENT" id="UNK_STROBE" type="MESSAGE"/>
|
||||
<DataItem category="CONDITION" id="CNC" type="SYSTEM"/>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<DataItem category="EVENT" id="FUNCT_MODE" type="MESSAGE"/>
|
||||
<DataItem category="EVENT" id="USER_ACTION" type="MESSAGE"/>
|
||||
<DataItem category="EVENT" id="TESTING_DATA" type="MESSAGE"/>
|
||||
<DataItem category="EVENT" id="PROTECTION_STATUS" type="MESSAGE"/>
|
||||
<DataItem category="EVENT" id="UNK_STATUS" type="MESSAGE"/>
|
||||
<DataItem category="EVENT" id="UNK_STROBE" type="MESSAGE"/>
|
||||
<DataItem category="CONDITION" id="CNC" type="SYSTEM"/>
|
||||
|
||||
@@ -14,8 +14,14 @@ namespace MTC_Adapter
|
||||
{
|
||||
// vettore valori in file interscambio
|
||||
public Dictionary<string, string> generalStatus;
|
||||
|
||||
/// <summary>
|
||||
/// Contenuto valori maintenance data da PLC
|
||||
/// </summary>
|
||||
public otherData[] maintData;
|
||||
/// <summary>
|
||||
/// Contenuto valori status data da PLC
|
||||
/// </summary>
|
||||
public otherData[] statusData;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto MAIN x connessione FANUC
|
||||
@@ -894,6 +900,83 @@ namespace MTC_Adapter
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gestione lettura dati status da PLC
|
||||
/// </summary>
|
||||
private void getStatusDataFromPlc()
|
||||
{
|
||||
// recupero i dati di manutenzione dall'area di memoria IN BLOCCO
|
||||
int memIndex = 14512;
|
||||
int bitNum = 0;
|
||||
int byteNum = 0;
|
||||
byte byteVal;
|
||||
int numByte = 1 + (statusData.Length / 8);
|
||||
byte[] tabDatiStatus = new byte[numByte];
|
||||
inizio = DateTime.Now;
|
||||
FANUC_ref.F_RW_Byte(R, FANUC.MemType.R, memIndex, ref tabDatiStatus);
|
||||
if (utils.CRB("recTime")) TimingData.addResult(string.Format("R{0}-DatiStatus", tabDatiStatus.Length), DateTime.Now.Subtract(inizio).Ticks);
|
||||
// uno ad uno vado a inserirli nella mappa dei dati dell'adapter...
|
||||
int numero = 0;
|
||||
string status = "";
|
||||
for (int i = 0; i < statusData.Length; i++)
|
||||
{
|
||||
numero = 0;
|
||||
status = "";
|
||||
|
||||
// calcolo quale byte e quale bit devo leggere..
|
||||
byteNum = i / 8;
|
||||
bitNum = i - (8 * byteNum) ; // indice zero dei bit nel byte ( da cui -1 )
|
||||
// faccio vera lettura
|
||||
byteVal = tabDatiStatus[byteNum];
|
||||
// leggo bit come ON/OFF
|
||||
if (((StFlag8)byteVal).HasFlag((StFlag8)Math.Pow(2, bitNum)))
|
||||
{
|
||||
status = "ON";
|
||||
}
|
||||
else
|
||||
{
|
||||
status = "OFF";
|
||||
}
|
||||
|
||||
if (statusData[i].varName == "PROTECTION_STATUS")
|
||||
{
|
||||
mProtectionStatus.Value = status;
|
||||
}
|
||||
else if (statusData[i].varName.StartsWith("VacPump_"))
|
||||
{
|
||||
if (statusData[i].varName.EndsWith("_Status"))
|
||||
{
|
||||
try
|
||||
{
|
||||
numero = Convert.ToInt32(statusData[i].varName.Replace("VacPump_", "").Replace("_Status", ""));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
if (numero > 0)
|
||||
{
|
||||
vettVacPump[numero - 1].mVacPumpStatus.Value = status;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (statusData[i].varName.StartsWith("Cooler_"))
|
||||
{
|
||||
if (statusData[i].varName.EndsWith("_Status"))
|
||||
{
|
||||
try
|
||||
{
|
||||
numero = Convert.ToInt32(statusData[i].varName.Replace("Cooler_", "").Replace("_Status", ""));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
if (numero > 0)
|
||||
{
|
||||
vettCooler[numero - 1].mCoolStatus.Value = status;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Leggo dati globali comuni (x path, assi...)
|
||||
/// </summary>
|
||||
@@ -945,8 +1028,11 @@ namespace MTC_Adapter
|
||||
|
||||
parentForm.dataMonitor = sb.ToString();
|
||||
|
||||
// gestisco lettura dati manutenzione...
|
||||
// gestisco lettura dati manutenzione da PLC...
|
||||
getMtzDataFromPlc();
|
||||
|
||||
// gestisco lettura dati status da PLC...
|
||||
getStatusDataFromPlc();
|
||||
}
|
||||
/// <summary>
|
||||
/// Carico file conf dati CMS
|
||||
@@ -954,7 +1040,14 @@ namespace MTC_Adapter
|
||||
protected override void loadOtherFile()
|
||||
{
|
||||
base.loadOtherFile();
|
||||
|
||||
loadMaintData();
|
||||
loadStatusData();
|
||||
}
|
||||
/// <summary>
|
||||
/// Lettura file gestione dati manutenzione da PLC
|
||||
/// </summary>
|
||||
private void loadMaintData()
|
||||
{
|
||||
// carico dati x Maintenance
|
||||
if (utils.CRB("verbose")) lg.Info("Inizio caricamento vettore variabili manutenzione gestite");
|
||||
int totRighe = 0;
|
||||
@@ -966,23 +1059,57 @@ namespace MTC_Adapter
|
||||
// carica da file...
|
||||
System.IO.StreamReader file = new System.IO.StreamReader(fileName);
|
||||
// leggo 1 linea alla volta...
|
||||
int rumRiga = 0;
|
||||
int numRiga = 0;
|
||||
while ((linea = file.ReadLine()) != null)
|
||||
{
|
||||
// SE non è un commento...
|
||||
if (linea.Substring(0, 1) != "#")
|
||||
{
|
||||
//elencoAllarmi[rumRiga] = decodeAlarmLine(linea, ':');
|
||||
maintData[rumRiga] = decodeOtherData(linea, utils.CRC("testCharSep"), "R", 14000, 4);
|
||||
rumRiga++;
|
||||
maintData[numRiga] = decodeOtherData(linea, utils.CRC("testCharSep"), "R", 14000, 4);
|
||||
numRiga++;
|
||||
}
|
||||
}
|
||||
// chiudo file
|
||||
file.Close();
|
||||
// ora trimmo vettore al solo numero VERO degli allarmi caricati...
|
||||
Array.Resize<otherData>(ref maintData, rumRiga);
|
||||
// ora trimmo vettore al solo numero VERO dei valori caricati...
|
||||
Array.Resize<otherData>(ref maintData, numRiga);
|
||||
|
||||
if (utils.CRB("verbose")) lg.Info("Fine caricamento vettore variabili manutenzione gestite");
|
||||
if (utils.CRB("verbose")) lg.Info(string.Format("Fine caricamento vettore di {0} variabili manutenzione gestite", numRiga));
|
||||
}
|
||||
/// <summary>
|
||||
/// Lettura file gestione dati status da PLC
|
||||
/// </summary>
|
||||
private void loadStatusData()
|
||||
{
|
||||
// carico dati x Maintenance
|
||||
if (utils.CRB("verbose")) lg.Info("Inizio caricamento vettore variabili status gestite");
|
||||
int totRighe = 0;
|
||||
string fileName = string.Format(@"{0}\{1}", Application.StartupPath, utils.CRS("CmsStatusDataConfFilePath"));
|
||||
string linea;
|
||||
totRighe = File.ReadLines(fileName).Count();
|
||||
// creo un vettore della dimensione corretta... conta anche commenti tanto poi riduco...
|
||||
statusData = new otherData[File.ReadLines(fileName).Count()];
|
||||
// carica da file...
|
||||
System.IO.StreamReader file = new System.IO.StreamReader(fileName);
|
||||
// leggo 1 linea alla volta...
|
||||
int numRiga = 0;
|
||||
while ((linea = file.ReadLine()) != null)
|
||||
{
|
||||
// SE non è un commento...
|
||||
if (linea.Substring(0, 1) != "#")
|
||||
{
|
||||
//elencoAllarmi[rumRiga] = decodeAlarmLine(linea, ':');
|
||||
statusData[numRiga] = decodeBitData(linea, utils.CRC("testCharSep"), "R", 14512, 1, numRiga);
|
||||
numRiga++;
|
||||
}
|
||||
}
|
||||
// chiudo file
|
||||
file.Close();
|
||||
// ora trimmo vettore al solo numero VERO dei valori caricati...
|
||||
Array.Resize<otherData>(ref statusData, numRiga);
|
||||
|
||||
if (utils.CRB("verbose")) lg.Info(string.Format("Fine caricamento vettore di {0} variabili status gestite", numRiga));
|
||||
}
|
||||
|
||||
public override void processAlarm()
|
||||
|
||||
@@ -873,6 +873,10 @@ namespace MTC_Adapter
|
||||
/// </summary>
|
||||
public Event mTestingData = new Event("TESTING_DATA");
|
||||
/// <summary>
|
||||
/// Stato protezioni (0/1, off/on)
|
||||
/// </summary>
|
||||
public Event mProtectionStatus = new Event("PROTECTION_STATUS");
|
||||
/// <summary>
|
||||
/// Strobe rilevati ma non qualificati
|
||||
/// </summary>
|
||||
public Event mUnkStrobe = new Event("UNK_STROBE");
|
||||
@@ -958,6 +962,9 @@ namespace MTC_Adapter
|
||||
// testing e autodiagnostica
|
||||
mAdapter.AddDataItem(mTestingData);
|
||||
|
||||
// stato protezioni
|
||||
mAdapter.AddDataItem(mProtectionStatus);
|
||||
|
||||
// strobe/status non riconosciuti
|
||||
mAdapter.AddDataItem(mUnkStatus);
|
||||
mAdapter.AddDataItem(mUnkStrobe);
|
||||
@@ -1221,7 +1228,31 @@ namespace MTC_Adapter
|
||||
string memAddr = string.Format("{0}{1}", memPre, baseAddr + shift * memSize);
|
||||
return new otherData(valori[0], memAddr, valori[1].Trim(), valori[2].Trim());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodifica file allarme
|
||||
/// </summary>
|
||||
/// <param name="linea"></param>
|
||||
/// <param name="separator"></param>
|
||||
/// <param name="memPre">tipo memoria (R/D/...)</param>
|
||||
/// <param name="baseAddr">indirizzo di partenza memoria</param>
|
||||
/// <param name="memSize">dimensione singolo slot in byte</param>
|
||||
/// <param name="numRiga">numero riga x calcolo indice bit</param>
|
||||
/// <returns></returns>
|
||||
protected otherData decodeBitData(string linea, char separator, string memPre, int baseAddr, int memSize, int numRiga)
|
||||
{
|
||||
string[] valori = linea.Split(separator);
|
||||
int shift = 0;
|
||||
try
|
||||
{
|
||||
shift = Convert.ToInt32(valori[0]) - 1;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
int resto = 0;
|
||||
Math.DivRem(numRiga, 8, out resto);
|
||||
string memAddr = string.Format("{0}{1}.{2}", memPre, baseAddr + shift * memSize, resto);
|
||||
return new otherData(valori[0], memAddr, valori[1].Trim(), valori[2].Trim());
|
||||
}
|
||||
|
||||
#region metodi adapter
|
||||
|
||||
@@ -2134,8 +2165,6 @@ namespace MTC_Adapter
|
||||
}
|
||||
// ...aggiorno valore riferimento...
|
||||
contOreMaccOn = istOreMaccOn;
|
||||
//// passo valore in ORE (float) all'adapter
|
||||
//mAccTime.Value = currAdpConf.ContOreMaccOn.ToString("0.000", CultureInfo.InvariantCulture);
|
||||
return needSave;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -2145,21 +2174,21 @@ namespace MTC_Adapter
|
||||
/// <returns></returns>
|
||||
public bool procOreMaccLav(bool needSave)
|
||||
{
|
||||
double delta = 0;
|
||||
// controllo valore riferimento...
|
||||
if (istOreMaccLav > contOreMaccLav)
|
||||
{
|
||||
double delta = istOreMaccLav - contOreMaccLav;
|
||||
double contatore = updateValDoubleByIncr(0, delta, "ACC_TIME_WORK");
|
||||
currAdpConf.ContOreMaccLav += delta;
|
||||
// salvo valore su persistent layer
|
||||
mAccTimeWork.Value = contatore.ToString("0.000", CultureInfo.InvariantCulture);
|
||||
delta = istOreMaccLav - contOreMaccLav;
|
||||
// segnalo necessità salvataggio!
|
||||
needSave = true;
|
||||
}
|
||||
double contatore = updateValDoubleByIncr(0, delta, "ACC_TIME_WORK");
|
||||
currAdpConf.ContOreMaccLav += delta;
|
||||
// salvo valore su persistent layer
|
||||
mAccTimeWork.Value = contatore.ToString("0.000", CultureInfo.InvariantCulture);
|
||||
|
||||
// ...aggiorno valore riferimento...
|
||||
contOreMaccLav = istOreMaccLav;
|
||||
//// passo valore in ORE (float) all'adapter
|
||||
//mAccTimeWork.Value = currAdpConf.ContOreMaccLav.ToString("0.000", CultureInfo.InvariantCulture);
|
||||
return needSave;
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
<!--percorso file scambio dati "lenti" e conf MaintData memory area -->
|
||||
<add key="GeneralStatusFilePath" value="CmsGeneralStatus.txt" />
|
||||
<add key="CmsMaintDataConfFilePath" value="CmsMaintDataConf.txt" />
|
||||
<add key="CmsStatusDataConfFilePath" value="CmsStatusDataConf.txt" />
|
||||
<add key="ScmProdFile" value="SCM_prodFile.pro" />
|
||||
|
||||
<add key="fattdecimale" value="1000" />
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# 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|PROTECTION_STATUS |BIT
|
||||
002|VacPump_01_Status |BIT
|
||||
003|VacPump_02_Status |BIT
|
||||
004|Cooler_01_Status |BIT
|
||||
005|Cooler_02_Status |BIT
|
||||
@@ -130,6 +130,9 @@
|
||||
<Content Include="CmsGeneralStatus.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="CmsStatusDataConf.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Resources\CMS\probe.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("1.1.26.99")]
|
||||
[assembly: AssemblyFileVersion("1.1.26.99")]
|
||||
[assembly: AssemblyVersion("1.1.27.99")]
|
||||
[assembly: AssemblyFileVersion("1.1.27.99")]
|
||||
[assembly: AssemblyCopyright("Steamware-SCM-CMS © 2015-2016")]
|
||||
[assembly: AssemblyCompany("Steamware-SCM-CMS")]
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("1.1.26.<#= this.RevisionNumber #>")]
|
||||
[assembly: AssemblyFileVersion("1.1.26.<#= this.RevisionNumber #>")]
|
||||
[assembly: AssemblyVersion("1.1.27.<#= this.RevisionNumber #>")]
|
||||
[assembly: AssemblyFileVersion("1.1.27.<#= this.RevisionNumber #>")]
|
||||
[assembly: AssemblyCopyright("Steamware-SCM-CMS © 2015-<#= DateTime.Now.Year #>")]
|
||||
[assembly: AssemblyCompany("Steamware-SCM-CMS")]
|
||||
<#+
|
||||
|
||||
Reference in New Issue
Block a user