616 lines
22 KiB
C#
616 lines
22 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
/// <summary>
|
|
/// Summary description for resoconti
|
|
/// </summary>
|
|
public enum statoMacchina
|
|
{
|
|
Run = 1,
|
|
Setup,
|
|
Guasto,
|
|
Campionatura,
|
|
Disposizione,
|
|
Varie
|
|
}
|
|
/// <summary>
|
|
/// oggetto dati per grafico sequencer
|
|
/// </summary>
|
|
public struct objSequencer
|
|
{
|
|
public intervalloDate intervallo;
|
|
/// <summary>
|
|
/// serie dei dati da plottare
|
|
/// </summary>
|
|
public DataLayer_generic.serieDatiDataTable serieDati;
|
|
}
|
|
|
|
/// <summary>
|
|
/// oggetto dati per grafico TempiCiclo
|
|
/// </summary>
|
|
public struct objTempiCiclo
|
|
{
|
|
public intervalloDate intervallo;
|
|
public decimal minVal;
|
|
public decimal maxVal;
|
|
public decimal targetVal;
|
|
public bool palletChange;
|
|
/// <summary>
|
|
/// serie dei dati da plottare
|
|
/// </summary>
|
|
public DataLayer_generic.serieTimeValDataTable serieDati;
|
|
}
|
|
//public struct intervallo
|
|
//{
|
|
// public DateTime inizio;
|
|
// public DateTime fine;
|
|
//}
|
|
public class resoconti
|
|
{
|
|
#region area protected
|
|
|
|
protected MapoDb.DS_applicazioneTableAdapters.MacchineTableAdapter taMacchine;
|
|
protected MapoDb.DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter taTempiCiclo;
|
|
protected MapoDb.DS_applicazione.MacchineDataTable _Macchine;
|
|
protected MapoDb.DS_applicazione.MacchineDataTable Macchine
|
|
{
|
|
get
|
|
{
|
|
if (!memLayer.ML.isInCacheObject("Macchine"))
|
|
//if (HttpContext.Current.Cache["Macchine"] == null)
|
|
{
|
|
_Macchine = taMacchine.GetData();
|
|
SteamWare.memLayer.ML.setCacheVal("Macchine", _Macchine, true);
|
|
//HttpContext.Current.Cache["Macchine"] = _Macchine;
|
|
}
|
|
else
|
|
{
|
|
_Macchine = (MapoDb.DS_applicazione.MacchineDataTable)SteamWare.memLayer.ML.objCacheObj("Macchine");
|
|
//_Macchine = (MapoDb.DS_applicazione.MacchineDataTable)HttpContext.Current.Cache["Macchine"];
|
|
}
|
|
return _Macchine;
|
|
}
|
|
}
|
|
protected MapoDb.DS_applicazioneTableAdapters.StatoMacchineTableAdapter taStatoMacchine;
|
|
protected MapoDb.DS_applicazione.StatoMacchineDataTable _StatoMacchine;
|
|
protected MapoDb.DS_applicazione.StatoMacchineDataTable StatoMacchine
|
|
{
|
|
get
|
|
{
|
|
//if (_StatoMacchine == null)
|
|
//{
|
|
// _StatoMacchine = taStatoMacchine.GetData();
|
|
//}
|
|
if (!memLayer.ML.isInCacheObject("StatoMacchine"))
|
|
{
|
|
_StatoMacchine = taStatoMacchine.GetData();
|
|
SteamWare.memLayer.ML.setCacheVal("StatoMacchine", _StatoMacchine, true);
|
|
}
|
|
else
|
|
{
|
|
_StatoMacchine = (MapoDb.DS_applicazione.StatoMacchineDataTable)SteamWare.memLayer.ML.objCacheObj("StatoMacchine");
|
|
}
|
|
return _StatoMacchine;
|
|
}
|
|
}
|
|
protected MapoDb.DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter taStati;
|
|
protected MapoDb.DS_applicazione.AnagraficaStatiDataTable _Stati;
|
|
protected MapoDb.DS_applicazione.AnagraficaStatiDataTable Stati
|
|
{
|
|
get
|
|
{
|
|
if (!memLayer.ML.isInCacheObject("Stati"))
|
|
{
|
|
_Stati = taStati.GetData();
|
|
memLayer.ML.setCacheVal("Stati", _Stati, true);
|
|
}
|
|
else
|
|
{
|
|
_Stati = (MapoDb.DS_applicazione.AnagraficaStatiDataTable)memLayer.ML.objCacheObj("Stati");
|
|
}
|
|
return _Stati;
|
|
}
|
|
}
|
|
protected MapoDb.DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter taDiarioDiBordo;
|
|
protected MapoDb.DS_applicazione.DiarioDiBordoDataTable _DiarioDiBordo;
|
|
protected MapoDb.DS_applicazione.DiarioDiBordoDataTable DiarioDiBordo
|
|
{
|
|
get
|
|
{
|
|
if (_DiarioDiBordo == null)
|
|
{
|
|
_DiarioDiBordo = taDiarioDiBordo.GetData();
|
|
}
|
|
return _DiarioDiBordo;
|
|
}
|
|
}
|
|
protected MapoDb.DS_applicazioneTableAdapters.ParetoDurateTableAdapter taParetoDurate;
|
|
#if false
|
|
protected MapoDb.DS_applicazione.ParetoDurateDataTable _ParetoDurate;
|
|
protected MapoDb.DS_applicazione.ParetoDurateDataTable ParetoDurate
|
|
{
|
|
get
|
|
{
|
|
if (_ParetoDurate == null)
|
|
{
|
|
// set vuoto...
|
|
_ParetoDurate = taParetoDurate.GetParetoDurateFilt("", 100, DateTime.Now, DateTime.Now);
|
|
}
|
|
return _ParetoDurate;
|
|
}
|
|
}
|
|
#endif
|
|
protected MapoDb.DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter taAnagraficaEventi;
|
|
protected MapoDb.DS_applicazione.AnagraficaEventiDataTable _AnagraficaEventi;
|
|
protected MapoDb.DS_applicazione.AnagraficaEventiDataTable AnagraficaEventi
|
|
{
|
|
get
|
|
{
|
|
if (!memLayer.ML.isInCacheObject("AnagraficaEventi"))
|
|
//if (HttpContext.Current.Cache["AnagraficaEventi"] == null)
|
|
{
|
|
_AnagraficaEventi = taAnagraficaEventi.GetData();
|
|
SteamWare.memLayer.ML.setCacheVal("AnagraficaEventi", _AnagraficaEventi, true);
|
|
//HttpContext.Current.Cache["AnagraficaEventi"] = _AnagraficaEventi;
|
|
}
|
|
else
|
|
{
|
|
_AnagraficaEventi = (MapoDb.DS_applicazione.AnagraficaEventiDataTable)SteamWare.memLayer.ML.objCacheObj("AnagraficaEventi");
|
|
//_AnagraficaEventi = (MapoDb.DS_applicazione.AnagraficaEventiDataTable)HttpContext.Current.Cache["AnagraficaEventi"];
|
|
}
|
|
return _AnagraficaEventi;
|
|
}
|
|
}
|
|
protected MapoDb.DS_applicazioneTableAdapters.AnagArticoliTableAdapter taAnagArt;
|
|
protected MapoDb.DS_applicazione.AnagArticoliDataTable _AnagArt;
|
|
protected MapoDb.DS_applicazione.AnagArticoliDataTable AnagArt
|
|
{
|
|
get
|
|
{
|
|
if (!memLayer.ML.isInCacheObject("AnagArt"))
|
|
{
|
|
_AnagArt = taAnagArt.GetData();
|
|
SteamWare.memLayer.ML.setCacheVal("AnagArt", _AnagArt, true);
|
|
}
|
|
else
|
|
{
|
|
_AnagArt = (MapoDb.DS_applicazione.AnagArticoliDataTable)SteamWare.memLayer.ML.objCacheObj("AnagArt");
|
|
}
|
|
return _AnagArt;
|
|
}
|
|
}
|
|
protected MapoDb.DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter taAnagOpr;
|
|
protected MapoDb.DS_applicazione.AnagraficaOperatoriDataTable _AnagOpr;
|
|
protected MapoDb.DS_applicazione.AnagraficaOperatoriDataTable AnagOpr
|
|
{
|
|
get
|
|
{
|
|
if (!memLayer.ML.isInCacheObject("AnagOpr"))
|
|
//if (HttpContext.Current.Cache["AnagOpr"] == null)
|
|
{
|
|
_AnagOpr = taAnagOpr.GetData();
|
|
SteamWare.memLayer.ML.setCacheVal("AnagOpr", _AnagOpr, true);
|
|
//HttpContext.Current.Cache["AnagOpr"] = _AnagOpr;
|
|
}
|
|
else
|
|
{
|
|
_AnagOpr = (MapoDb.DS_applicazione.AnagraficaOperatoriDataTable)SteamWare.memLayer.ML.objCacheObj("AnagOpr");
|
|
//_AnagOpr = (MapoDb.DS_applicazione.AnagraficaOperatoriDataTable)HttpContext.Current.Cache["AnagOpr"];
|
|
}
|
|
return _AnagOpr;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region area public
|
|
|
|
public resoconti()
|
|
{
|
|
AvviaTabAdapt();
|
|
setConnString();
|
|
}
|
|
/// <summary>
|
|
/// singleton accesso resoconti
|
|
/// </summary>
|
|
public static resoconti mngr = new resoconti();
|
|
|
|
/// <summary>
|
|
/// avvio i table adapter della classe
|
|
/// </summary>
|
|
private void AvviaTabAdapt()
|
|
{
|
|
taMacchine = new MapoDb.DS_applicazioneTableAdapters.MacchineTableAdapter();
|
|
taStatoMacchine = new MapoDb.DS_applicazioneTableAdapters.StatoMacchineTableAdapter();
|
|
taStati = new MapoDb.DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter();
|
|
taDiarioDiBordo = new MapoDb.DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter();
|
|
taParetoDurate = new MapoDb.DS_applicazioneTableAdapters.ParetoDurateTableAdapter();
|
|
taAnagraficaEventi = new MapoDb.DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter();
|
|
taAnagArt = new MapoDb.DS_applicazioneTableAdapters.AnagArticoliTableAdapter();
|
|
taAnagOpr = new MapoDb.DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter();
|
|
taTempiCiclo = new MapoDb.DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter();
|
|
}
|
|
/// <summary>
|
|
/// forza la connString x i vari table adapters
|
|
/// </summary>
|
|
private void setConnString()
|
|
{
|
|
string _connectionString = SteamWare.memLayer.ML.confReadString("MoonProConnectionString");
|
|
taMacchine.Connection.ConnectionString = _connectionString;
|
|
taStatoMacchine.Connection.ConnectionString = _connectionString;
|
|
taStati.Connection.ConnectionString = _connectionString;
|
|
taDiarioDiBordo.Connection.ConnectionString = _connectionString;
|
|
taParetoDurate.Connection.ConnectionString = _connectionString;
|
|
taAnagraficaEventi.Connection.ConnectionString = _connectionString;
|
|
taAnagArt.Connection.ConnectionString = _connectionString;
|
|
taAnagOpr.Connection.ConnectionString = _connectionString;
|
|
taTempiCiclo.Connection.ConnectionString = _connectionString;
|
|
}
|
|
|
|
public string locazioneDaIdx(string idx)
|
|
{
|
|
MapoDb.DS_applicazione.MacchineRow riga = Macchine.FindByIdxMacchina(idx);
|
|
return string.Format("{0}", riga.locazione);
|
|
}
|
|
public string idxDaLocazione(string locazione)
|
|
{
|
|
string answ = "";
|
|
MapoDb.DS_applicazione.MacchineRow riga = null;
|
|
try
|
|
{
|
|
riga = (MapoDb.DS_applicazione.MacchineRow)Macchine.Select(string.Format("locazione = '{0}'", locazione))[0];
|
|
answ = string.Format("{0}", riga.IdxMacchina);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
return answ;
|
|
}
|
|
public string nomeMacchina(string idx)
|
|
{
|
|
string answ = "";
|
|
MapoDb.DS_applicazione.MacchineRow riga = Macchine.FindByIdxMacchina(idx);
|
|
try
|
|
{
|
|
answ = string.Format("{0} ({1} - {2})", riga.Nome, riga.CodMacchina, riga.Descrizione);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
public string macchinaDaIdx(string idx)
|
|
{
|
|
MapoDb.DS_applicazione.MacchineRow riga = Macchine.FindByIdxMacchina(idx);
|
|
return string.Format("{0}", riga.CodMacchina);
|
|
}
|
|
public string urlMacchina(string idx)
|
|
{
|
|
string answ = "";
|
|
MapoDb.DS_applicazione.MacchineRow riga = null;
|
|
try
|
|
{
|
|
riga = Macchine.FindByIdxMacchina(idx);
|
|
answ = string.Format("{0}", riga.url);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// fornisce idxStato della macchina indicata
|
|
/// </summary>
|
|
/// <param name="idx"></param>
|
|
/// <returns></returns>
|
|
public int statoMacchina(string idx)
|
|
{
|
|
int answ = 0;
|
|
try
|
|
{
|
|
MapoDb.DS_ProdTempi.stp_repDonati_getLastStatoDurataMacchinaRow riga = (MapoDb.DS_ProdTempi.stp_repDonati_getLastStatoDurataMacchinaRow)(MapoDb.DataLayer.obj.taDatiStatoMacch.GetData(idx, 0)[0]);
|
|
answ = riga.idxStato;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// fornisce descrizione stato da IdxStato
|
|
/// </summary>
|
|
/// <param name="idx"></param>
|
|
/// <returns></returns>
|
|
public string statoDaIdx(int idx)
|
|
{
|
|
return Stati.FindByIdxStato(idx).Descrizione;
|
|
}
|
|
/// <summary>
|
|
/// fornisce cod operatore data matricola
|
|
/// </summary>
|
|
/// <param name="matr"></param>
|
|
/// <returns></returns>
|
|
public string oprDaMatr(int matr)
|
|
{
|
|
string answ = "nd";
|
|
try
|
|
{
|
|
MapoDb.DS_applicazione.AnagraficaOperatoriRow riga = AnagOpr.FindByMatrOpr(matr);
|
|
answ = string.Format("{0} {1}", riga.Cognome, riga.Nome);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Dizionario codici colore (chiave = idxStato), valore = codice colore
|
|
/// </summary>
|
|
protected Dictionary<int, string> codColore
|
|
{
|
|
get
|
|
{
|
|
Dictionary<int, string> answ = new Dictionary<int, string>();
|
|
if (memLayer.ML.isInCacheObject("codColore"))
|
|
{
|
|
answ = (Dictionary<int, string>)memLayer.ML.objCacheObj("codColore");
|
|
}
|
|
else
|
|
{
|
|
string _colore = "";
|
|
foreach (MapoDb.DS_applicazione.AnagraficaStatiRow item in Stati)
|
|
{
|
|
switch (item.Semaforo)
|
|
{
|
|
case "sGi": // giallo
|
|
_colore = "#ffec00";
|
|
break;
|
|
case "sRo": // rosso
|
|
_colore = "#e2001a";
|
|
break;
|
|
case "sGr": // grigio - spenta
|
|
_colore = "#bcbcbc";
|
|
break;
|
|
case "sVe": // verde
|
|
_colore = "#009036";
|
|
break;
|
|
case "sBl": // blu
|
|
_colore = "#3690FF";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
answ.Add(item.IdxStato, _colore);
|
|
}
|
|
memLayer.ML.setCacheVal("codColore", answ, true);
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Dizionario codici semaforo (chiave = idxStato), valore = codice semaforo
|
|
/// </summary>
|
|
protected Dictionary<int, string> codSemaforo
|
|
{
|
|
get
|
|
{
|
|
Dictionary<int, string> answ = new Dictionary<int, string>();
|
|
if (memLayer.ML.isInCacheObject("codSemaforo"))
|
|
{
|
|
answ = (Dictionary<int, string>)memLayer.ML.objCacheObj("codSemaforo");
|
|
}
|
|
else
|
|
{
|
|
foreach (MapoDb.DS_applicazione.AnagraficaStatiRow item in Stati)
|
|
{
|
|
answ.Add(item.IdxStato, item.Semaforo);
|
|
}
|
|
memLayer.ML.setCacheVal("codSemaforo", answ, true);
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Restituisce colore da IdxStato
|
|
/// </summary>
|
|
/// <param name="idx"></param>
|
|
/// <returns></returns>
|
|
public string coloreDaIdx(int idx)
|
|
{
|
|
string _answ = "";
|
|
|
|
if (memLayer.ML.CRB("fastColorDecode"))
|
|
{
|
|
_answ = codColore[idx];
|
|
}
|
|
else
|
|
{
|
|
switch (Stati.FindByIdxStato(idx).Semaforo)
|
|
{
|
|
case "sGi": // giallo
|
|
_answ = "#ffec00";
|
|
break;
|
|
case "sRo": // rosso
|
|
_answ = "#e2001a";
|
|
break;
|
|
case "sGr": // grigio - spenta
|
|
_answ = "#bcbcbc";
|
|
break;
|
|
case "sVe": // verde
|
|
_answ = "#009036";
|
|
break;
|
|
case "sBl": // blu
|
|
_answ = "#3690FF";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return _answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce cod semaforo dato IdxStato
|
|
/// </summary>
|
|
/// <param name="idx"></param>
|
|
/// <returns></returns>
|
|
public string semaforoDaIdxStato(int idx)
|
|
{
|
|
string _answ = "";
|
|
if (memLayer.ML.CRB("fastColorDecode"))
|
|
{
|
|
_answ = codSemaforo[idx];
|
|
}
|
|
else
|
|
{
|
|
_answ = Stati.FindByIdxStato(idx).Semaforo;
|
|
}
|
|
return _answ;
|
|
}
|
|
/// <summary>
|
|
/// fornisce una torta stati
|
|
/// </summary>
|
|
/// <param name="idx"></param>
|
|
/// <param name="_intervallo"></param>
|
|
/// <param name="minDurata"></param>
|
|
/// <param name="hideSpenta"></param>
|
|
/// <returns></returns>
|
|
public DataLayer_generic.serieDatiDataTable tortaStati(string idx, intervalloDate _intervallo, int minDurata, bool hideSpenta)
|
|
{
|
|
// leggo i dati e costituisco una collezione...
|
|
DataLayer_generic.serieDatiDataTable punti = new DataLayer_generic.serieDatiDataTable();
|
|
// seleziono i dati...
|
|
MapoDb.DS_applicazione.ParetoDurateDataTable tabPareto;
|
|
if (hideSpenta)
|
|
{
|
|
tabPareto = taParetoDurate.GetParetoDurateHideSpenta(idx, minDurata, _intervallo.fine, _intervallo.inizio);
|
|
}
|
|
else
|
|
{
|
|
tabPareto = taParetoDurate.GetParetoDurateFilt(idx, minDurata, _intervallo.fine, _intervallo.inizio);
|
|
}
|
|
double totale = 1;
|
|
try
|
|
{
|
|
totale = (double)tabPareto.Compute("SUM(DurataMinuti)", "");
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
foreach (MapoDb.DS_applicazione.ParetoDurateRow riga in tabPareto.Rows)
|
|
{
|
|
punti.AddserieDatiRow((float)((Math.Round(((float)riga.DurataMinuti) / totale * 1000)) / 1000), coloreDaIdx(riga.IdxStato), statoDaIdx(riga.IdxStato), riga.InizioStato);
|
|
}
|
|
return punti;
|
|
}
|
|
/// <summary>
|
|
/// tipo evento da Idx
|
|
/// </summary>
|
|
/// <param name="idx"></param>
|
|
/// <returns></returns>
|
|
public string tipoDaIdx(int idx)
|
|
{
|
|
return AnagraficaEventi.FindByIdxTipo(idx).Nome;
|
|
}
|
|
/// <summary>
|
|
/// oggetto sequenza dati x sequencer
|
|
/// </summary>
|
|
/// <param name="idxMacchina">IdxMacchina</param>
|
|
/// <param name="_intervallo"></param>
|
|
/// <returns></returns>
|
|
public objSequencer sequenzaDati(string idxMacchina, intervalloDate _intervallo)
|
|
{
|
|
DateTime start = DateTime.Now;
|
|
// leggo i dati e costituisco una collezione...
|
|
objSequencer _sequenza = new objSequencer();
|
|
if (idxMacchina != null && idxMacchina != "")
|
|
{
|
|
_sequenza.serieDati = new DataLayer_generic.serieDatiDataTable();
|
|
// seleziono i dati...
|
|
MapoDb.DS_applicazione.DiarioDiBordoDataTable tabSeq = taDiarioDiBordo.GetSequenza(idxMacchina, _intervallo.inizio, _intervallo.fine);
|
|
foreach (MapoDb.DS_applicazione.DiarioDiBordoRow riga in tabSeq.Rows)
|
|
{
|
|
_sequenza.serieDati.AddserieDatiRow(riga.DurataMinuti, semaforoDaIdxStato(riga.IdxStato), riga.CodArticolo, riga.InizioStato);
|
|
}
|
|
// faccio trim x primo evento...
|
|
if (_sequenza.serieDati[0].timeData < _intervallo.inizio)
|
|
{
|
|
_sequenza.serieDati[0].valore -= _intervallo.inizio.Subtract(_sequenza.serieDati[0].timeData).TotalMinutes;
|
|
_sequenza.serieDati[0].timeData = _intervallo.inizio;
|
|
}
|
|
//...e ultimo evento...
|
|
int numValori = _sequenza.serieDati.Count - 1;
|
|
_sequenza.serieDati[numValori].valore = _intervallo.fine.Subtract(_sequenza.serieDati[numValori].timeData).TotalMinutes;
|
|
// salvo intervallo
|
|
_sequenza.intervallo = _intervallo;
|
|
}
|
|
|
|
return _sequenza;
|
|
}
|
|
/// <summary>
|
|
/// oggetto sequenza tempi ciclo x visualizzatore
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <param name="_intervallo"></param>
|
|
/// <param name="targetVal">tempo target di riferimento (se zero calcola la media...)</param>
|
|
/// <returns></returns>
|
|
public objTempiCiclo tempiCiclo(string idxMacchina, intervalloDate _intervallo, decimal targetVal)
|
|
{
|
|
// inizializzo
|
|
objTempiCiclo _serie = new objTempiCiclo();
|
|
if (idxMacchina != null && idxMacchina != "")
|
|
{
|
|
_serie.serieDati = new DataLayer_generic.serieTimeValDataTable();
|
|
// seleziono i dati
|
|
if (targetVal > 0)
|
|
{
|
|
_serie.targetVal = targetVal;
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
_serie.targetVal = taTempiCiclo.getMedByMacchinaPeriodo(idxMacchina, _intervallo.inizio, _intervallo.fine)[0].TCMedio;
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
int TcMaxFactor = memLayer.ML.confReadInt("TcMaxFactor");
|
|
MapoDb.DS_ProdTempi.TempiCicloRilevatiDataTable tabTempi = taTempiCiclo.getByMacchinaPeriodoFiltMax(idxMacchina, _intervallo.inizio, _intervallo.fine, _serie.targetVal * TcMaxFactor);
|
|
// converto!
|
|
DateTime inizio;
|
|
foreach (MapoDb.DS_ProdTempi.TempiCicloRilevatiRow riga in tabTempi.Rows)
|
|
{
|
|
inizio = riga.DataOraRif.AddMinutes(Convert.ToDouble(-riga.TCMedio * riga.PzProd)); // tolgo il tempo necessario a produrre i pezzi indicati come inizio
|
|
_serie.serieDati.AddserieTimeValRow(inizio, riga.DataOraRif, riga.TCMedio, string.Format("Art: {0} - T.C. {1}'", riga.CodArticolo, riga.TCMedio), riga.CodArticolo);
|
|
}
|
|
// sistemo estremi x date e valori
|
|
try
|
|
{
|
|
_serie.maxVal = taTempiCiclo.getMaxByMacchinaPeriodo(idxMacchina, _intervallo.inizio, _intervallo.fine)[0].TCMedio;
|
|
if (_serie.maxVal > _serie.targetVal * TcMaxFactor)
|
|
{
|
|
_serie.maxVal = _serie.targetVal * TcMaxFactor;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
try
|
|
{
|
|
_serie.minVal = taTempiCiclo.getMinByMacchinaPeriodo(idxMacchina, _intervallo.inizio, _intervallo.fine)[0].TCMedio;
|
|
}
|
|
catch
|
|
{ }
|
|
_serie.intervallo = _intervallo;
|
|
|
|
// imposto se abbia cambio pallet
|
|
_serie.palletChange = false;
|
|
try
|
|
{
|
|
_serie.palletChange = MapoDb.DataLayer.obj.taDatiMacchine.getByIdx(Convert.ToInt32(idxMacchina))[0].palletChange;
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return _serie;
|
|
}
|
|
|
|
#endregion
|
|
}
|