DOvrebbe inviare prgName e pezzi prod...

This commit is contained in:
Samuele E. Locatelli
2016-07-13 12:27:06 +02:00
parent 163f58fec9
commit 3dcb7d53b1
2 changed files with 73 additions and 56 deletions
+46 -35
View File
@@ -207,13 +207,14 @@ namespace MTC_Adapter
/// Oggetto elenco dati produzione
/// </summary>
public datiProdSCM[] elencoDatiProd;
/// <summary>
/// leggo altri file:
/// - dati produzione
/// </summary>
protected override void loadOtherFile()
public override void getSlowChangingData()
{
base.loadOtherFile();
base.getSlowChangingData();
// carico dati x Maintenance
if (utils.CRB("verbose")) lg.Info(string.Format("Inizio caricamento file dati produzione ({0})", ScmProdFileName));
@@ -242,10 +243,19 @@ namespace MTC_Adapter
// ora trimmo vettore al solo numero VERO degli allarmi caricati...
Array.Resize<datiProdSCM>(ref elencoDatiProdNew, rumRiga);
// !!!FARE!!! (ri-fare)
// ora devo verificare il contenuto rispetto ai "vecchi" valori... conto numero righe (devono essere diverse o uguali e ultima riga con qta differente e pari cod PRG...)
/*--------------------------------------------------
* Gestione verifica dati prod (naive)
* - se file curr vuoto --> inizio a popolare
* - se i 2 file hannos tessa lunghezza --> verifico +update last row
* - se nNew > nCurr --> accodo
* - se nCurr > nNew e nNew ==0 --> aggiorno last row giorno prec
* - se nCurr > nNew e nNew > 0 --> svuoto file curr e riparto
*--------------------------------------------------*/
// verifica preliminare dati da lung vettori
int nRecCur = 0;
int nRecIst = 0;
if (elencoDatiProd != null)
{
try
@@ -255,53 +265,54 @@ namespace MTC_Adapter
catch
{ }
}
int nRecIst = 0;
if (elencoDatiProdNew != null)
{
try
{
nRecCur = elencoDatiProdNew.Length;
nRecIst = elencoDatiProdNew.Length;
}
catch
{ }
}
// in primis devo verificare che sia > 0 num oggetti su entrambi i vettori
// se vett curr è nullo --> devo inizializzare
// se NONE' nullo devo confrontare ULTIMO record Curr con equivalente record NEW x verificare se sia variato
// se ultimo curr === corrispondente new DEVO aggiungere 1 riga
// riporto comunque ultima riga del vettore CURR (sia perché variato sia perché aggiunto)
#if false
bool checkNumRow = nRecCur != nRecIst;
bool checkPart = elencoDatiProd[nRecCur - 1].fileName != elencoDatiProdNew[nRecIst - 1].fileName;
bool checkQta = elencoDatiProd[nRecCur - 1].qta != elencoDatiProdNew[nRecIst - 1].qta;
// se differiscono processo
if (checkNumRow || checkPart || (!checkPart && checkQta))
if (nRecCur + nRecIst > 0)
{
// CARICO IN vettore IST il primo dei NUOVI particolari coi suoi pezzi prodotti
istPathPartId[0] = elencoDatiProdNew[nRecIst - 1].fileName;
istPathPartCount[0] = Convert.ToUInt32(elencoDatiProdNew[nRecIst - 1].qta);
// aggiorno ultima riga (son diverse x numeri righe...)
if (checkNumRow)
// verifico se ho meno valori CURR e quindi devo accodare
if (nRecCur < nRecIst)
{
// resize vettore!
Array.Resize<datiProdSCM>(ref elencoDatiProd, nRecCur + 1);
elencoDatiProd[nRecCur + 1] = elencoDatiProdNew[nRecCur + 1];
// carico nuovo record
elencoDatiProd[nRecCur] = elencoDatiProdNew[nRecCur];
nRecCur++;
}
else if (nRecCur == nRecIst)
{
// devo confrontare ULTIMO record Curr con equivalente record NEW x verificare se sia variato.. verifico PRG + start
bool checkName = elencoDatiProd[nRecCur].fileName == elencoDatiProdNew[nRecCur].fileName;
bool checkStart = elencoDatiProd[nRecCur].start == elencoDatiProdNew[nRecCur].start;
if (checkName && checkStart)
{
elencoDatiProd[nRecCur] = elencoDatiProdNew[nRecCur];
}
}
//... aggiorno ultima riga dati...
else
{
elencoDatiProd[nRecCur] = elencoDatiProdNew[nRecCur];
// inizio svuotando elenco eventi CURR (migliorabile leggendo da data prec?!?)
elencoDatiProd = null;
nRecCur = 0;
}
// al prossimo giro caricherà altro particolare...
}
#endif
// riporto comunque ultima riga del vettore CURR (sia perché variato sia perché aggiunto)
if (nRecCur > 0)
{
string prgName = elencoDatiProd[nRecCur - 1].fileName;
prgName = prgName.Substring(prgName.LastIndexOf(@"\") + 1);
istPathPartId[0] = prgName;
istPathPartCount[0] = Convert.ToUInt32(elencoDatiProd[nRecCur - 1].qta);
}
}
}
/// <summary>
/// Processo stti macchina...
+27 -21
View File
@@ -2052,19 +2052,22 @@ namespace MTC_Adapter
// controllo valore riferimento x tutti i path se sia cambiato programma...
for (int i = 0; i < currAdpConf.nPath; i++)
{
if (istPathPartId[i] != currPathPartId[i])
if (istPathPartId[i] != null)
{
// aggiorno valore in Path RefList
updatePathRefList(i, "Path_{0:00}_PartId", istPathPartId[i]);
if (istPathPartId[i] != currPathPartId[i])
{
// aggiorno valore in Path RefList
updatePathRefList(i, "Path_{0:00}_PartId", istPathPartId[i]);
// prendo nuovo valore programma x path!
vettPath[i].mPathPartId.Value = istPathPartId[i];
// imposto a ZERO i pezzi del nuovo articolo
vettPath[i].mPathPartCount.Value = 0;
// segnalo necessità salvataggio!
needSave = true;
// ...aggiorno valore riferimento...
currPathPartId[i] = istPathPartId[i];
// prendo nuovo valore programma x path!
vettPath[i].mPathPartId.Value = istPathPartId[i];
// imposto a ZERO i pezzi del nuovo articolo
vettPath[i].mPathPartCount.Value = 0;
// segnalo necessità salvataggio!
needSave = true;
// ...aggiorno valore riferimento...
currPathPartId[i] = istPathPartId[i];
}
}
}
return needSave;
@@ -2079,20 +2082,23 @@ namespace MTC_Adapter
// controllo valore riferimento x tutti i path se sia cambiato programma...
for (int i = 0; i < currAdpConf.nPath; i++)
{
// controllo valore riferimento...
if (istPathPartCount[i] > currPathPartCount[i])
if (istPathPartCount[i] != null)
{
uint deltaPz = istPathPartCount[i] - currPathPartCount[i];
uint contTotPz = updatePathRefListByIncr(i, deltaPz, "Path_{0:00}_PZ_TOT");
// controllo valore riferimento...
if (istPathPartCount[i] > currPathPartCount[i])
{
uint deltaPz = istPathPartCount[i] - currPathPartCount[i];
uint contTotPz = updatePathRefListByIncr(i, deltaPz, "Path_{0:00}_PZ_TOT");
// passo valore num pz all'adapter
vettPath[i].mPathPartCount.Value = contTotPz;
// passo valore num pz all'adapter
vettPath[i].mPathPartCount.Value = contTotPz;
// segnalo necessità salvataggio!
needSave = true;
// segnalo necessità salvataggio!
needSave = true;
}
// ...aggiorno valore riferimento...
currPathPartCount[i] = istPathPartCount[i];
}
// ...aggiorno valore riferimento...
currPathPartCount[i] = istPathPartCount[i];
}
return needSave;
}