1577 lines
61 KiB
C#
1577 lines
61 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
|
|
namespace MapoDb
|
|
{
|
|
|
|
public struct inputComando
|
|
{
|
|
/// <summary>
|
|
/// input comando valido si/no
|
|
/// </summary>
|
|
public bool isValid;
|
|
/// <summary>
|
|
/// testo da mostrare all'utente
|
|
/// </summary>
|
|
public string text2show;
|
|
/// <summary>
|
|
/// idx evento associato al comando
|
|
/// </summary>
|
|
public int idxTipoEvento;
|
|
/// <summary>
|
|
/// input precedente
|
|
/// </summary>
|
|
public string precInput;
|
|
/// <summary>
|
|
/// descrizione comando
|
|
/// </summary>
|
|
public string descrComando;
|
|
/// <summary>
|
|
/// refresh stato macchina encessario si/no
|
|
/// </summary>
|
|
public bool needStatusRefresh;
|
|
/// <summary>
|
|
/// lista del nome dei WebBrowserBox e delle relative url, nel formato {0}##{1} {0}=nome WebBrowserBox (es. box01), {1}=url relativo (es. http://server/MoonPro/Produzione.aspx?idxMacchina=99)
|
|
/// </summary>
|
|
public string[] wBrowsBoxUrls;
|
|
/// <summary>
|
|
/// valore di output dal comando
|
|
/// </summary>
|
|
public string outValue;
|
|
}
|
|
|
|
/// <summary>
|
|
/// tipologia evento inviato
|
|
/// </summary>
|
|
public enum tipoInputEvento
|
|
{
|
|
barcode,
|
|
hw
|
|
}
|
|
/// <summary>
|
|
/// nuovo stato ingressi e eventuale evento da inviare
|
|
/// </summary>
|
|
public struct hwMachineState
|
|
{
|
|
public int next_IdxMicroStato;
|
|
public int IdxTipoEvento;
|
|
}
|
|
|
|
public class MapoDb
|
|
{
|
|
#region area protected
|
|
|
|
protected string _separatore = ",";
|
|
protected string _connectionString = "";
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// avvio i table adapter della classe
|
|
/// </summary>
|
|
private void AvviaTabAdapt()
|
|
{
|
|
taEvList = new DS_applicazioneTableAdapters.EventListTableAdapter();
|
|
taDiario = new DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter();
|
|
taAnagSt = new DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter();
|
|
taAnagEv = new DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter();
|
|
taMacchine = new DS_applicazioneTableAdapters.MacchineTableAdapter();
|
|
taTranEv = new DS_applicazioneTableAdapters.TransizioneEventiTableAdapter();
|
|
taTranSt = new DS_applicazioneTableAdapters.TransizioneStatiTableAdapter();
|
|
taStatoMacchine = new DS_applicazioneTableAdapters.StatoMacchineTableAdapter();
|
|
taKeepAlive = new DS_applicazioneTableAdapters.KeepAliveTableAdapter();
|
|
taRRL = new DS_applicazioneTableAdapters.RemoteRebootLogTableAdapter();
|
|
taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter();
|
|
taAnOpr = new DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter();
|
|
taDatiMacch = new DS_applicazioneTableAdapters.DatiMacchineTableAdapter();
|
|
taMSM = new DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter();
|
|
taMSFD = new DS_applicazioneTableAdapters.MSFDTableAdapter();
|
|
taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter();
|
|
taODL = new DS_ProdTempiTableAdapters.ODLTableAdapter();
|
|
taTCRilevati = new DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter();
|
|
}
|
|
/// <summary>
|
|
/// forza la connString x i vari table adapters
|
|
/// </summary>
|
|
private void setConnString()
|
|
{
|
|
_connectionString = SteamWare.memLayer.ML.confReadString("MoonProConnectionString");
|
|
taEvList.Connection.ConnectionString = _connectionString;
|
|
taDiario.Connection.ConnectionString = _connectionString;
|
|
taAnagEv.Connection.ConnectionString = _connectionString;
|
|
taAnagSt.Connection.ConnectionString = _connectionString;
|
|
taMacchine.Connection.ConnectionString = _connectionString;
|
|
taTranEv.Connection.ConnectionString = _connectionString;
|
|
taTranSt.Connection.ConnectionString = _connectionString;
|
|
taStatoMacchine.Connection.ConnectionString = _connectionString;
|
|
taKeepAlive.Connection.ConnectionString = _connectionString;
|
|
taRRL.Connection.ConnectionString = _connectionString;
|
|
taTransIngr.Connection.ConnectionString = _connectionString;
|
|
taAnOpr.Connection.ConnectionString = _connectionString;
|
|
taDatiMacch.Connection.ConnectionString = _connectionString;
|
|
taMSM.Connection.ConnectionString = _connectionString;
|
|
taMSFD.Connection.ConnectionString = _connectionString;
|
|
taDatiMacchine.Connection.ConnectionString = _connectionString;
|
|
taODL.Connection.ConnectionString = _connectionString;
|
|
taTCRilevati.Connection.ConnectionString = _connectionString;
|
|
}
|
|
/// <summary>
|
|
/// cerca codice in anagrafica macchine ed eventualmente inserisce nuova macchina
|
|
/// </summary>
|
|
/// <param name="IdxMacchina"></param>
|
|
private void verificaIdxMacchina(string IdxMacchina)
|
|
{
|
|
bool needDB = false;
|
|
if (!memLayer.ML.CRB("disable_verificaIdxMacchina"))
|
|
{
|
|
if (memLayer.ML.CRB("IOB_RedEnab"))
|
|
{
|
|
try
|
|
{
|
|
// esecuzione in REDIS...cerco status macchina...
|
|
if (DataLayer.mDatiMacchine(IdxMacchina).Count == 0)
|
|
{
|
|
needDB = true;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
// ...oppure segno richiesta DB...
|
|
else
|
|
{
|
|
needDB = true;
|
|
}
|
|
if (needDB)
|
|
{
|
|
// 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto
|
|
if (memLayer.ML.CRB("disable_singleton"))
|
|
{
|
|
taMacchine = new DS_applicazioneTableAdapters.MacchineTableAdapter();
|
|
taMSM = new DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter();
|
|
}
|
|
// verifico esistenza macchina
|
|
if (taMacchine.GetByIdx(IdxMacchina).Rows.Count == 0)
|
|
{
|
|
// inserisco nuova macchina...
|
|
taMacchine.Insert(IdxMacchina, "9999", IdxMacchina, "Macchina non codificata", "-", "http://", "nd", "col", 0, 0);
|
|
}
|
|
// verifico ci sia un microstato macchina...
|
|
if (taMSM.getByIdxMacchina(IdxMacchina).Rows.Count == 0)
|
|
{
|
|
// inserisco nuovo stato...
|
|
taMSM.Insert(IdxMacchina, 0, DateTime.Now, "00");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// verifica se sia necessario inserire un cambio di stato impianto in modalità batch
|
|
/// </summary>
|
|
/// <param name="tipoInput"></param>
|
|
/// <param name="IdxMacchina"></param>
|
|
/// <param name="InizioStato"></param>
|
|
/// <param name="IdxTipo"></param>
|
|
/// <param name="CodArt"></param>
|
|
/// <param name="Value"></param>
|
|
/// <param name="MatrOpr"></param>
|
|
/// <param name="pallet"></param>
|
|
private void checkCambiaStatoBatch(tipoInputEvento tipoInput, string IdxMacchina, DateTime InizioStato, int IdxTipo, string CodArt, string Value, int MatrOpr, string pallet)
|
|
{
|
|
DS_applicazione.TransizioneStatiRow rigaTransStati;
|
|
switch (tipoInput)
|
|
{
|
|
case tipoInputEvento.barcode:
|
|
// effettuo cambio stato INDIPENDENTEMENTE da stato precedente
|
|
try
|
|
{
|
|
rigaTransStati = taTranSt.GetUserForcedTransitions(IdxMacchina, IdxTipo)[0];
|
|
// solo se cambia stato...
|
|
if (rigaTransStati.IdxStato != rigaTransStati.next_IdxStato)
|
|
{
|
|
taDiario.InsStatoBatch(IdxMacchina, InizioStato, rigaTransStati.next_IdxStato, CodArt, Value, MatrOpr, pallet);
|
|
// aggiorno MSE
|
|
DataLayer.obj.taMSE.forceRecalc(0, IdxMacchina);
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
// non dovrebbe succedere... input utente da barcode dovrebbero TUTTI essere inseriti in tab transizione con famiglia 1...
|
|
logger.lg.scriviLog(string.Format("Errore controllo transizione stato x evento barcode:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
break;
|
|
case tipoInputEvento.hw:
|
|
// verifico se ci sia necessità di cambio stato
|
|
try
|
|
{
|
|
rigaTransStati = taTranSt.GetHwTransitions(IdxMacchina, IdxTipo)[0];
|
|
if (rigaTransStati != null)
|
|
{
|
|
// solo se cambia stato...
|
|
if (rigaTransStati.IdxStato != rigaTransStati.next_IdxStato)
|
|
{
|
|
taDiario.InsStatoBatch(IdxMacchina, InizioStato, rigaTransStati.next_IdxStato, CodArt, Value, MatrOpr, pallet);
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
// non trovo riga [0]... NON scrivo!
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// metodo privato x fornire matricola che è correntemente sulla macchina
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
private int getMatrOpMacc(string idxMacchina)
|
|
{
|
|
int matr = -1;
|
|
try
|
|
{
|
|
matr = (taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]).MatrOpr;
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
return matr;
|
|
}
|
|
/// <summary>
|
|
/// metodo privato x fornire cognome-nome dalla matricola
|
|
/// </summary>
|
|
/// <param name="matrOpr"></param>
|
|
/// <returns></returns>
|
|
private string getGeneralitDaMatr(int matrOpr)
|
|
{
|
|
string cognNome = "";
|
|
// cerco operatore...
|
|
DS_applicazione.AnagraficaOperatoriRow rigaOpr;
|
|
try
|
|
{
|
|
rigaOpr = taAnOpr.getByMatrOpr(matrOpr)[0];
|
|
cognNome = string.Format("{0} {1}", rigaOpr.Cognome, rigaOpr.Nome);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
return cognNome;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region area public
|
|
|
|
#region area table adapters
|
|
|
|
// area applicazione
|
|
public DS_applicazioneTableAdapters.EventListTableAdapter taEvList;
|
|
public DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter taDiario;
|
|
public DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter taAnagEv;
|
|
public DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter taAnagSt;
|
|
public DS_applicazioneTableAdapters.MacchineTableAdapter taMacchine;
|
|
public DS_applicazioneTableAdapters.TransizioneEventiTableAdapter taTranEv;
|
|
public DS_applicazioneTableAdapters.TransizioneStatiTableAdapter taTranSt;
|
|
public DS_applicazioneTableAdapters.StatoMacchineTableAdapter taStatoMacchine;
|
|
public DS_applicazioneTableAdapters.KeepAliveTableAdapter taKeepAlive;
|
|
public DS_applicazioneTableAdapters.RemoteRebootLogTableAdapter taRRL;
|
|
public DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter taTransIngr;
|
|
public DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter taAnOpr;
|
|
public DS_applicazioneTableAdapters.DatiMacchineTableAdapter taDatiMacch;
|
|
public DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter taMSM;
|
|
public DS_applicazioneTableAdapters.MSFDTableAdapter taMSFD;
|
|
// area tempi ciclo
|
|
public DS_ProdTempiTableAdapters.DatiMacchineTableAdapter taDatiMacchine;
|
|
public DS_ProdTempiTableAdapters.ODLTableAdapter taODL;
|
|
public DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter taTCRilevati;
|
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
/// avvio della classe
|
|
/// </summary>
|
|
public MapoDb()
|
|
{
|
|
AvviaTabAdapt();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Oggetto singleton x MapoDb
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static MapoDb obj = new MapoDb();
|
|
/// <summary>
|
|
/// restituisce la stringa di connessione al db
|
|
/// </summary>
|
|
public string getStringaConnessione()
|
|
{
|
|
return _connectionString;
|
|
}
|
|
/// <summary>
|
|
/// imposta la stringa di connessione al db
|
|
/// </summary>
|
|
public bool setStringaConnessione(string valore)
|
|
{
|
|
_connectionString = valore;
|
|
setConnString();
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// scrive una riga di evento nel db
|
|
/// </summary>
|
|
/// <param name="IdxMacchina">codice macchina</param>
|
|
/// <param name="IdxTipo">idx evento</param>
|
|
/// <param name="CodArticolo">Codice Articolo</param>
|
|
/// <param name="Value">valore</param>
|
|
/// <param name="MatrOpr">matricola operatore</param>
|
|
/// <param name="pallet">pallet (vuoto se nd)</param>
|
|
/// <param name="eventTime">data-ora dell'evento</param>
|
|
/// <param name="currentTime">data-ora corrente dell'invio</param>
|
|
/// <returns></returns>
|
|
public inputComando scriviRigaEvento(string IdxMacchina, int IdxTipo, string CodArticolo, string Value, int MatrOpr, string pallet, DateTime eventTime, DateTime currentTime)
|
|
{
|
|
int inserito = 0;
|
|
// 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto
|
|
if (memLayer.ML.CRB("disable_singleton"))
|
|
{
|
|
// 2017.06.09 forzo init x errori "sovrapposizioni"
|
|
taEvList = new DS_applicazioneTableAdapters.EventListTableAdapter();
|
|
}
|
|
try
|
|
{
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(IdxMacchina);
|
|
// calcolo dataOra reale (evento + delta(ora server - ora remota)
|
|
DateTime dataOra = eventTime.Add(DateTime.Now - currentTime);
|
|
// inserisco evento
|
|
inserito = taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, MatrOpr, pallet);
|
|
// faccio controllo per eventuale cambio stato da tab transizioni...
|
|
checkCambiaStatoBatch(tipoInputEvento.hw, IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, MatrOpr, pallet);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in fase di scrittura evento con i seguenti dati:{0} macchina {1}{0} IdxTipo {2}{0} CodArticolo {3}{0} Value {4}{0} MatrOpr {5}{0} Pallet {6}{0} eventTime {7}{0} currentTime {8}{0} eccezione: {0}{9}", Environment.NewLine, IdxMacchina, IdxTipo, CodArticolo, Value, MatrOpr, pallet, eventTime, currentTime, exc), tipoLog.EXCEPTION);
|
|
}
|
|
// formatto output
|
|
inputComando answ = new inputComando();
|
|
answ.outValue = inserito.ToString();
|
|
answ.needStatusRefresh = true;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// scrive una riga di evento nel db
|
|
/// </summary>
|
|
/// <param name="IdxMacchina">codice macchina</param>
|
|
/// <param name="IdxTipo">idx evento</param>
|
|
/// <param name="CodArticolo">Codice Articolo</param>
|
|
/// <param name="Value">valore</param>
|
|
/// <param name="MatrOpr">matricola operatore</param>
|
|
/// <param name="pallet">pallet (vuoto se nd)</param>
|
|
/// <returns></returns>
|
|
public inputComando scriviRigaEvento(string IdxMacchina, int IdxTipo, string CodArticolo, string Value, int MatrOpr, string pallet)
|
|
{
|
|
int inserito = 0;
|
|
// 2017.06.09 forzo init x errori "sovrapposizioni"
|
|
taEvList = new DS_applicazioneTableAdapters.EventListTableAdapter();
|
|
try
|
|
{
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(IdxMacchina);
|
|
DateTime dataOra = DateTime.Now;
|
|
// inserisco evento
|
|
inserito = taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, MatrOpr, pallet);
|
|
// faccio controllo per eventuale cambio stato da tab transizioni...
|
|
checkCambiaStatoBatch(tipoInputEvento.hw, IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, MatrOpr, pallet);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in fase di scrittura evento con i seguenti dati:{0} macchina {1}{0} IdxTipo {2}{0} CodArticolo {3}{0} Value {4}{0} MatrOpr {5}{0} Pallet {6}{0} eccezione:{0}{7}", Environment.NewLine, IdxMacchina, IdxTipo, CodArticolo, Value, MatrOpr, pallet, exc), tipoLog.EXCEPTION);
|
|
}
|
|
// formatto output
|
|
inputComando answ = new inputComando();
|
|
answ.outValue = inserito.ToString();
|
|
answ.needStatusRefresh = true;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce boolean se la macchina sia abilitata x inserimento dati (tab DatiMacchine)
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public bool insEnabled(string idxMacchina)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
answ = taDatiMacch.GetByIdx(idxMacchina)[0].insEnabled;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce valore dell'ODL attivo (iniziato e NON concluso)
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public string currODL(string idxMacchina)
|
|
{
|
|
string answ = "";
|
|
// recupero con stored NUOVA...
|
|
DS_ProdTempi.ODLDataTable tabOdl = DataLayer.obj.taODL.getByMacchina(idxMacchina);
|
|
if (tabOdl.Rows.Count > 0)
|
|
{
|
|
// solo SE ho idxODL (altrimenti loggo errore)
|
|
if (tabOdl[0].IdxODL > 0)
|
|
{
|
|
answ = tabOdl[0].IdxODL.ToString();
|
|
answ = answ == "" ? "0" : answ;
|
|
}
|
|
else
|
|
{
|
|
answ = "0";
|
|
logger.lg.scriviLog("[currODL] Errore in currODL x idxMacchina " + idxMacchina + ": IdxODL = 0");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// se è empty --> 0!!!
|
|
answ = "0";
|
|
}
|
|
// ultimo controllo su idxOdl...
|
|
answ = answ == "" ? "0" : answ;
|
|
// restituisco!
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Testituisce tabella con riga dell'ODL attivo (iniziato e NON concluso)
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public DS_ProdTempi.ODLDataTable currODLTab(string idxMacchina)
|
|
{
|
|
DS_ProdTempi.ODLDataTable answ = null;
|
|
logger.lg.scriviLog("Recupero currODLTab da DB!", tipoLog.INFO);
|
|
try
|
|
{
|
|
answ = DataLayer.obj.taODL.getByMacchina(idxMacchina);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Eccezione in recupero currODLTab{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
|
}
|
|
// restituisco!
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Testituisce tabella con riga dell'ODL attivo (iniziato e NON concluso)
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public DS_applicazione.StatoMacchineDataTable currStatoMaccTab(string idxMacchina)
|
|
{
|
|
DS_applicazione.StatoMacchineDataTable answ = null;
|
|
logger.lg.scriviLog("Recupero currStatoMaccTab da DB!", tipoLog.INFO);
|
|
try
|
|
{
|
|
answ = DataLayer.obj.taStatoMacchine.GetDataByIdxMacchina(idxMacchina);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog($"Eccezione in recupero currStatoMaccTab{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
|
}
|
|
// restituisco!
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce boolean se la macchina sia abilitata x registrazione segnali in input (tab DatiMacchine)
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public bool sLogEnabled(string idxMacchina)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
// 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto
|
|
if (memLayer.ML.CRB("disable_singleton"))
|
|
{
|
|
//2017.06.09 forzo inizializzazione oggetto..
|
|
taDatiMacch = new DS_applicazioneTableAdapters.DatiMacchineTableAdapter();
|
|
}
|
|
answ = taDatiMacch.GetByIdx(idxMacchina)[0].sLogEnabled;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Restituisce il valore booleano se la macchina sia di tipo MULTI (con più state machine x INGRESSI)
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public bool isMulti(string idxMacchina)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
// 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto
|
|
if (memLayer.ML.CRB("disable_singleton"))
|
|
{
|
|
//2017.06.09 forzo inizializzazione oggetto..
|
|
taMSFD = new DS_applicazioneTableAdapters.MSFDTableAdapter();
|
|
}
|
|
answ = taMSFD.getByIdxMacc(idxMacchina)[0].Multi == 1;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// salva il segnale di "microstato"
|
|
/// </summary>
|
|
/// <param name="idxMacchina">idx macchina</param>
|
|
/// <param name="valore">valore ingresso</param>
|
|
/// <param name="dtEve">data-ora evento (server)</param>
|
|
/// <param name="contatore">sequenza dati inviati</param>
|
|
/// <returns></returns>
|
|
public void saveSigLog(string idxMacchina, string valore, DateTime dtEve, string contatore)
|
|
{
|
|
int cont = 0;
|
|
try
|
|
{
|
|
cont = Convert.ToInt32(contatore);
|
|
}
|
|
catch
|
|
{ }
|
|
// 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto
|
|
if (memLayer.ML.CRB("disable_singleton"))
|
|
{
|
|
// 2017.06.09 forzo init x errori "sovrapposizioni"
|
|
DataLayer.obj.taSigLog = new DS_applicazioneTableAdapters.SignalLogTableAdapter();
|
|
}
|
|
DataLayer.obj.taSigLog.Insert(DateTime.Now, idxMacchina, valore, dtEve, cont);
|
|
}
|
|
/// <summary>
|
|
/// controlla se da il segnale di "microstato" deriva un evento da generare - modalità OFFLINE
|
|
/// </summary>
|
|
/// <param name="idxMacchina">idx macchina</param>
|
|
/// <param name="valore">valore ingresso</param>
|
|
/// <param name="dtEve">data-ora evento (server)</param>
|
|
/// <param name="contatore">sequenza dati inviati</param>
|
|
/// <returns></returns>
|
|
public inputComando checkMicroStato(string idxMacchina, string valore, DateTime dtEve, string contatore)
|
|
{
|
|
int _logLevel = memLayer.ML.CRI("_logLevel");
|
|
// recupero SE IMPIEGATO REDIS i valori del Dictionary della macchina...
|
|
Dictionary<string, string> datiMacc = DataLayer.mDatiMacchine(idxMacchina);
|
|
|
|
if (_logLevel > 6)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt]{2}---------------------------{2}Richiesta verifica INPUT per Macchina {0}, seriale {1}", idxMacchina, valore, Environment.NewLine), tipoLog.INFO);
|
|
}
|
|
// formatto output
|
|
inputComando answ = new inputComando();
|
|
DS_applicazione.TransizioneIngressiDataTable TabTransIn;
|
|
DS_applicazione.TransizioneIngressiRow rigaTransIn = null;
|
|
// verifico se esista la macchina altrimenti la creo... REDIS compliant
|
|
verificaIdxMacchina(idxMacchina);
|
|
string CodArticolo = "";
|
|
if (memLayer.ML.CRB("IOB_RedEnab"))
|
|
{
|
|
try
|
|
{
|
|
// esecuzione in REDIS
|
|
CodArticolo = datiMacc["CodArticolo"];
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
// ...oppure dritto su DB
|
|
else
|
|
{
|
|
// esecuzione in DB...
|
|
// recupero CodArticolo corretto
|
|
try
|
|
{
|
|
// 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto
|
|
if (memLayer.ML.CRB("disable_singleton"))
|
|
{
|
|
// 2017.07.10 forzo init x errori "sovrapposizioni"
|
|
taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter();
|
|
}
|
|
CodArticolo = taDatiMacchine.getByIdx(idxMacchina)[0].CodArticolo_A;
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_4a] - Eccezione in recupero CodArticolo:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
}
|
|
// recupero next microstato
|
|
int? valINT = 0;
|
|
try
|
|
{
|
|
valINT = int.Parse(valore, System.Globalization.NumberStyles.HexNumber);
|
|
// esecuzione in REDIS...
|
|
if (memLayer.ML.CRB("IOB_RedEnab"))
|
|
{
|
|
try
|
|
{
|
|
int idxFamIn = Convert.ToInt32(datiMacc["IdxFamIn"]);
|
|
int idxMicroStato = Convert.ToInt32(datiMacc["IdxMicroStato"]);
|
|
int valIOB = Convert.ToInt32(valINT);
|
|
int idxTipoEv = 0;
|
|
int next_idxMS = idxMicroStato;
|
|
// verifico esistenza tab SMI...
|
|
string fiHASH = DataLayer.hSMI(idxFamIn);
|
|
string todoSMI = "";
|
|
bool trovato = memLayer.ML.redHashPresentSz(fiHASH);
|
|
if (!trovato)
|
|
{
|
|
// ricarico tabella!
|
|
KeyValuePair<string, string>[] valori = DataLayer.mTabSMI(idxFamIn);
|
|
}
|
|
// recupero singolo valore (stringa) x chiave
|
|
todoSMI = DataLayer.valoreSMI(idxFamIn, idxMicroStato, valIOB);
|
|
// solo se ho trovato un risultato nella tab SMI della famiglia macchina...
|
|
if (todoSMI != "")
|
|
{
|
|
// splitto e salvo valori OUT...
|
|
string[] valori = todoSMI.Split('_');
|
|
idxTipoEv = Convert.ToInt32(valori[0]);
|
|
next_idxMS = Convert.ToInt32(valori[1]);
|
|
// creo la riga tipizzatya dai dati di redis x procedere...
|
|
DS_applicazione.TransizioneIngressiDataTable tab = new DS_applicazione.TransizioneIngressiDataTable();
|
|
rigaTransIn = tab.NewTransizioneIngressiRow();
|
|
rigaTransIn.IdxFamigliaIngresso = idxFamIn;
|
|
rigaTransIn.IdxMicroStato = idxMicroStato;
|
|
rigaTransIn.ValoreIngresso = valIOB;
|
|
rigaTransIn.IdxTipoEvento = idxTipoEv;
|
|
rigaTransIn.next_IdxMicroStato = next_idxMS;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
// ...oppure dritto su DB
|
|
else
|
|
{
|
|
// 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto
|
|
if (memLayer.ML.CRB("disable_singleton"))
|
|
{
|
|
// 2017.06.09 forzo init x errori "sovrapposizioni"
|
|
taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter();
|
|
}
|
|
TabTransIn = taTransIngr.getByIdxMacchinaValore(idxMacchina, valINT);
|
|
if (TabTransIn.Rows.Count > 0)
|
|
{
|
|
rigaTransIn = TabTransIn[0];
|
|
}
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_5a] - - Eccezione in recupero riga Trans ingressi per idxMacchina {3} e valore {2}:{0}{1}", Environment.NewLine, exc, valINT, idxMacchina), tipoLog.EXCEPTION);
|
|
}
|
|
// effettuo update vari SU DB!!!
|
|
if (rigaTransIn != null)
|
|
{
|
|
try
|
|
{
|
|
if (_logLevel > 5)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_6a] - Salvo Update Microstato:{0}macchina: {1} | valore seriale: {2} | next micro stato: {3}", Environment.NewLine, idxMacchina, valINT, rigaTransIn.next_IdxMicroStato), tipoLog.INFO);
|
|
}
|
|
// 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto
|
|
if (memLayer.ML.CRB("disable_singleton"))
|
|
{
|
|
// 2017.06.09 forzo init x errori "sovrapposizioni"
|
|
taMSM = new DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter();
|
|
}
|
|
// salvo nuovo microstato...
|
|
taMSM.updateQuery(rigaTransIn.next_IdxMicroStato, dtEve, valore, idxMacchina);
|
|
// controllo se c'è evento
|
|
if (rigaTransIn.IdxTipoEvento > 0)
|
|
{
|
|
if (_logLevel > 5)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_7a] - Salvo evento:{0}macchina: {1} | tipoEvento: {2} | CodArticolo: {3} | contatore: {4} | valore: {5}", Environment.NewLine, idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo, contatore, valore), tipoLog.INFO);
|
|
}
|
|
string valEsteso = string.Format("[{0}] {1}", contatore.PadLeft(3, '0'), valore);
|
|
// aggiunto contatore!
|
|
answ = scriviRigaEvento(idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo, valEsteso, 0, "-", dtEve, DateTime.Now);
|
|
// 2017.09.12 SE era in modalità redis RICARICA dati macchina...
|
|
if (memLayer.ML.CRB("IOB_RedEnab"))
|
|
{
|
|
DataLayer.resetDatiMacchina(idxMacchina);
|
|
}
|
|
if (_logLevel > 5)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_a] - Macchina {0} | seriale(INT) {1} | valEsteso {3} | answ {4}{2}---------------------------{2}", idxMacchina, valINT, Environment.NewLine, valEsteso, answ), tipoLog.INFO);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_8a] - Eccezione:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// controlla se da il segnale di "microstato" deriva un evento da generare - modalità OFFLINE
|
|
/// </summary>
|
|
/// <param name="idxMacchina">idx macchina</param>
|
|
/// <param name="valore">valore ingresso</param>
|
|
/// <param name="dtEve">data-ora evento (server)</param>
|
|
/// <returns></returns>
|
|
public inputComando checkMicroStato(string idxMacchina, string valore, DateTime dtEve)
|
|
{
|
|
if (memLayer.ML.CRI("_logLevel") > 6)
|
|
{
|
|
logger.lg.scriviLog(string.Format("{2}---------------------------{2}Richiesta verifica INPUT per Macchina {0}, seriale {1}", idxMacchina, valore, Environment.NewLine), tipoLog.INFO);
|
|
}
|
|
// formatto output
|
|
inputComando answ = new inputComando();
|
|
DS_applicazione.TransizioneIngressiDataTable TabTransIn;
|
|
DS_applicazione.TransizioneIngressiRow rigaTransIn = null;
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(idxMacchina);
|
|
string CodArticolo = "";
|
|
// recupero CodArticolo corretto
|
|
try
|
|
{
|
|
// 2017.07.10 forzo init x errori "sovrapposizioni"
|
|
taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter();
|
|
CodArticolo = taDatiMacchine.getByIdx(idxMacchina)[0].CodArticolo_A;
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_4b] - Eccezione in recupero CodArticolo:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
// recupero next microstato
|
|
//int? valINT = Convert.ToInt32(valore);
|
|
int? valINT = 0;
|
|
try
|
|
{
|
|
// 2017.06.09 forzo init x errori "sovrapposizioni"
|
|
taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter();
|
|
valINT = int.Parse(valore, System.Globalization.NumberStyles.HexNumber);
|
|
TabTransIn = taTransIngr.getByIdxMacchinaValore(idxMacchina, valINT);
|
|
if (TabTransIn.Rows.Count > 0)
|
|
{
|
|
rigaTransIn = TabTransIn[0];
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_5b] - Eccezione in recupero riga Trans ingressi per idxMacchina {3} e valore {2}:{0}{1}", Environment.NewLine, exc, valINT, idxMacchina), tipoLog.EXCEPTION);
|
|
}
|
|
int _logLevel = memLayer.ML.CRI("_logLevel");
|
|
// effettuo update vari
|
|
if (rigaTransIn != null)
|
|
{
|
|
try
|
|
{
|
|
if (_logLevel > 5)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_6b] - Salvo Update Microstato:{0}macchina: {1} | valore seriale: {2} | next micro stato: {3}", Environment.NewLine, idxMacchina, valINT, rigaTransIn.next_IdxMicroStato), tipoLog.INFO);
|
|
}
|
|
// salvo nuovo microstato...
|
|
taMSM.updateQuery(rigaTransIn.next_IdxMicroStato, dtEve, valore, idxMacchina);
|
|
// controllo se c'è evento
|
|
if (rigaTransIn.IdxTipoEvento > 0)
|
|
{
|
|
if (_logLevel > 5)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_7b] - Salvo evento:{0}macchina: {1} | tipoEvento: {2} | CodArticolo: {3}", Environment.NewLine, idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo), tipoLog.INFO);
|
|
}
|
|
answ = scriviRigaEvento(idxMacchina, rigaTransIn.IdxTipoEvento, CodArticolo, valore, 0, "-", dtEve, DateTime.Now);
|
|
if (_logLevel > 5)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_b] -Macchina {0}, seriale(INT) {1}{2}---------------------------{2}", idxMacchina, valINT, Environment.NewLine), tipoLog.INFO);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("[ChkMiSt_8b] - Eccezione:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// controlla se da il segnale di "microstato" deriva un evento da generare
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <param name="valore"></param>
|
|
/// <returns></returns>
|
|
public inputComando checkMicroStato(string idxMacchina, string valore)
|
|
{
|
|
// wrapper ad ora corrente...
|
|
return checkMicroStato(idxMacchina, valore, DateTime.Now);
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <param name="IPv4"></param>
|
|
/// <param name="agent"></param>
|
|
/// <param name="macAddr">mac address (inviato dalla macchina)</param>
|
|
/// <returns></returns>
|
|
public inputComando registraStartup(string idxMacchina, string IPv4, string agent, string macAddr)
|
|
{
|
|
if (memLayer.ML.CRI("_logLevel") > 6)
|
|
{
|
|
logger.lg.scriviLog(string.Format("{0}---------------------------{0}Richiesta registrazione (ri)avvio Macchina {1} - mac: {2}", Environment.NewLine, idxMacchina, macAddr), tipoLog.INFO);
|
|
}
|
|
// formatto output
|
|
inputComando answ = new inputComando();
|
|
// scrivo remote reboot alive!
|
|
scriviRemoteReboot(idxMacchina, IPv4, agent, macAddr);
|
|
// scrivo PRIMO keep alive
|
|
scriviPrimoKeepAlive(idxMacchina, DateTime.Now);
|
|
|
|
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// scrive una riga di evento nel db SENZA passare operatore e pallet (mette a 0 e "-")
|
|
/// </summary>
|
|
/// <param name="IdxMacchina">codice macchina</param>
|
|
/// <param name="IdxTipo">idx evento</param>
|
|
/// <param name="CodArticolo">Codice Articolo</param>
|
|
/// <param name="Value">valore</param>
|
|
/// <returns></returns>
|
|
public inputComando scriviRigaEvento(string IdxMacchina, int IdxTipo, string CodArticolo, string Value)
|
|
{
|
|
int inserito = 0;
|
|
try
|
|
{
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(IdxMacchina);
|
|
DateTime dataOra = DateTime.Now;
|
|
// inserisco evento
|
|
inserito = taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, 0, "-");
|
|
// faccio controllo per eventuale cambio stato da tab transizioni...
|
|
checkCambiaStatoBatch(tipoInputEvento.hw, IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, 0, "-");
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in fase di scrittura evento con i seguenti dati:{0} macchina {1}{0} IdxTipo {2}{0} CodArticolo {3}{0} Value {4}{0} eccezione: {0}{5}", Environment.NewLine, IdxMacchina, IdxTipo, CodArticolo, Value), tipoLog.EXCEPTION);
|
|
}
|
|
// formatto output
|
|
inputComando answ = new inputComando();
|
|
answ.outValue = inserito.ToString();
|
|
answ.needStatusRefresh = true;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// scrive una riga di evento inviato da Barcode nel db
|
|
/// </summary>
|
|
/// <param name="IdxMacchina">codice macchina</param>
|
|
/// <param name="IdxTipo">idx evento</param>
|
|
/// <param name="CodArticolo">Codice Articolo</param>
|
|
/// <param name="Value">valore</param>
|
|
/// <param name="MatrOpr">matricola operatore</param>
|
|
/// <param name="pallet">pallet (vuoto se nd)</param>
|
|
/// <param name="eventTime">data-ora dell'evento</param>
|
|
/// <param name="currentTime">data-ora corrente dell'invio</param>
|
|
/// <returns></returns>
|
|
public inputComando scriviRigaEventoBarcode(string IdxMacchina, int IdxTipo, string CodArticolo, string Value, int MatrOpr, string pallet, DateTime eventTime, DateTime currentTime)
|
|
{
|
|
int inserito = 0;
|
|
try
|
|
{
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(IdxMacchina);
|
|
// calcolo dataOra reale (evento + delta(ora server - ora remota)
|
|
DateTime dataOra = eventTime.Add(DateTime.Now - currentTime);
|
|
// inserisco evento
|
|
inserito = taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, MatrOpr, pallet);
|
|
// faccio controllo per eventuale cambio stato da tab transizioni...
|
|
checkCambiaStatoBatch(tipoInputEvento.barcode, IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, MatrOpr, pallet);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in fase di scrittura evento con i seguenti dati:{0} macchina {1}{0} IdxTipo {2}{0} CodArticolo {3}{0} Value {4}{0} MatrOpr {5}{0} Pallet {6}{0} eventTime {7}{0} currentTime {8}{0} eccezione: {0}{9}", Environment.NewLine, IdxMacchina, IdxTipo, CodArticolo, Value, MatrOpr, pallet, eventTime, currentTime, exc), tipoLog.EXCEPTION);
|
|
}
|
|
// formatto output
|
|
inputComando answ = new inputComando();
|
|
answ.outValue = inserito.ToString();
|
|
answ.needStatusRefresh = true;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// scrive una riga di evento inviato da Barcode nel db
|
|
/// </summary>
|
|
/// <param name="IdxMacchina">codice macchina</param>
|
|
/// <param name="IdxTipo">idx evento</param>
|
|
/// <param name="CodArticolo">Codice Articolo</param>
|
|
/// <param name="Value">valore</param>
|
|
/// <param name="MatrOpr">matricola operatore</param>
|
|
/// <param name="pallet">pallet (vuoto se nd)</param>
|
|
/// <returns></returns>
|
|
public inputComando scriviRigaEventoBarcode(string IdxMacchina, int IdxTipo, string CodArticolo, string Value, int MatrOpr, string pallet)
|
|
{
|
|
int inserito = 0;
|
|
try
|
|
{
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(IdxMacchina);
|
|
DateTime dataOra = DateTime.Now;
|
|
// inserisco evento
|
|
inserito = taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, MatrOpr, pallet);
|
|
// faccio controllo per eventuale cambio stato da tab transizioni...
|
|
checkCambiaStatoBatch(tipoInputEvento.barcode, IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, MatrOpr, pallet);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in fase di scrittura evento con i seguenti dati:{0} macchina {1}{0} IdxTipo {2}{0} CodArticolo {3}{0} Value {4}{0} MatrOpr {5}{0} Pallet {6}{0} eccezione: {0}{7}", Environment.NewLine, IdxMacchina, IdxTipo, CodArticolo, Value, MatrOpr, pallet, exc), tipoLog.EXCEPTION);
|
|
}
|
|
// formatto output
|
|
inputComando answ = new inputComando();
|
|
answ.outValue = inserito.ToString();
|
|
answ.needStatusRefresh = true;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// scrive una riga di evento inviato da Barcode nel db SENZA operatore e pallet (mette a 0 e "-")
|
|
/// </summary>
|
|
/// <param name="IdxMacchina">codice macchina</param>
|
|
/// <param name="IdxTipo">idx evento</param>
|
|
/// <param name="CodArticolo">Codice Articolo</param>
|
|
/// <param name="Value">valore</param>
|
|
/// <returns></returns>
|
|
public inputComando scriviRigaEventoBarcode(string IdxMacchina, int IdxTipo, string CodArticolo, string Value)
|
|
{
|
|
int inserito = 0;
|
|
try
|
|
{
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(IdxMacchina);
|
|
DateTime dataOra = DateTime.Now;
|
|
// inserisco evento
|
|
inserito = taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, 0, "-");
|
|
// faccio controllo per eventuale cambio stato da tab transizioni...
|
|
checkCambiaStatoBatch(tipoInputEvento.barcode, IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, 0, "-");
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in fase di scrittura evento con i seguenti dati:{0} macchina {1}{0} IdxTipo {2}{0} CodArticolo {3}{0} Value {4}{0} eccezione: {0}{5}", Environment.NewLine, IdxMacchina, IdxTipo, CodArticolo, Value), tipoLog.EXCEPTION);
|
|
}
|
|
// formatto output
|
|
inputComando answ = new inputComando();
|
|
answ.outValue = inserito.ToString();
|
|
answ.needStatusRefresh = true;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// scrive una riga di stato nel diario di bordo
|
|
/// </summary>
|
|
/// <param name="IdxMacchina">codice macchina</param>
|
|
/// <param name="IdxStato">idx stato</param>
|
|
/// <param name="CodArticolo">Codice Articolo</param>
|
|
/// <param name="Value">valore</param>
|
|
/// <param name="MatrOpr">matricola operatore</param>
|
|
/// <param name="pallet">pallet (vuoto se nd)</param>
|
|
/// <param name="eventTime">data-ora dell'evento</param>
|
|
/// <param name="currentTime">data-ora corrente dell'invio</param>
|
|
/// <returns></returns>
|
|
public inputComando scriviRigaStato(string IdxMacchina, int IdxStato, string CodArticolo, string Value, int MatrOpr, string pallet, DateTime eventTime, DateTime currentTime)
|
|
{
|
|
int inserito = 0;
|
|
try
|
|
{
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(IdxMacchina);
|
|
// calcolo dataOra reale (evento + delta(ora server - ora remota)
|
|
DateTime dataOra = eventTime.Add(DateTime.Now - currentTime);
|
|
// inserisco la nuova riga di stato mentre il trigger aggiorna le tab...
|
|
inserito = taDiario.Insert(IdxMacchina, dataOra, null, IdxStato, null, Value, CodArticolo, null, null, MatrOpr, pallet);
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in fase di scrittura stato con i seguenti dati:{0} macchina {1}{0} IdxStato {2}{0} CodArticolo {3}{0} Value {4}{0} MatrOpr {5}{0} Pallet {6}{0} eventTime {7}{0} currentTime {8}{0} eccezione: {0}{9}", Environment.NewLine, IdxMacchina, IdxStato, CodArticolo, Value, MatrOpr, pallet, eventTime, currentTime), tipoLog.EXCEPTION);
|
|
}
|
|
// formatto output
|
|
inputComando answ = new inputComando();
|
|
answ.outValue = inserito.ToString();
|
|
answ.needStatusRefresh = true;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore
|
|
/// </summary>
|
|
/// <param name="chiave"></param>
|
|
/// <returns></returns>
|
|
public string getAnagEventi(string chiave)
|
|
{
|
|
int IdxTipo = Convert.ToInt32(chiave);
|
|
string _nomi = "";
|
|
string _valori = "";
|
|
DS_applicazione.AnagraficaEventiDataTable tabella = taAnagEv.GetByIdx(IdxTipo);
|
|
foreach (System.Data.DataColumn colonna in tabella.Columns)
|
|
{
|
|
_nomi += string.Format("{0}{1}", colonna.ColumnName, _separatore);
|
|
_valori += string.Format("{0}{1}", tabella[0][colonna.ColumnName], _separatore);
|
|
}
|
|
return string.Format("{0}\n\r{1}\n\r", _nomi, _valori);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore
|
|
/// </summary>
|
|
/// <param name="chiave"></param>
|
|
/// <returns></returns>
|
|
public string getAnagStati(string chiave)
|
|
{
|
|
int IdxStato = Convert.ToInt32(chiave);
|
|
string _nomi = "";
|
|
string _valori = "";
|
|
DS_applicazione.AnagraficaStatiDataTable tabella = taAnagSt.GetByIdx(IdxStato);
|
|
foreach (System.Data.DataColumn colonna in tabella.Columns)
|
|
{
|
|
_nomi += string.Format("{0}{1}", colonna.ColumnName, _separatore);
|
|
_valori += string.Format("{0}{1}", tabella[0][colonna.ColumnName], _separatore);
|
|
}
|
|
return string.Format("{0}\n\r{1}\n\r", _nomi, _valori);
|
|
}
|
|
/// <summary>
|
|
/// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore
|
|
/// </summary>
|
|
/// <param name="chiave"></param>
|
|
/// <returns></returns>
|
|
public string getAnagMacchine(string chiave)
|
|
{
|
|
string _nomi = "";
|
|
string _valori = "";
|
|
DS_applicazione.MacchineDataTable tabella = taMacchine.GetByIdx(chiave);
|
|
foreach (System.Data.DataColumn colonna in tabella.Columns)
|
|
{
|
|
_nomi += string.Format("{0}{1}", colonna.ColumnName, _separatore);
|
|
_valori += string.Format("{0}{1}", tabella[0][colonna.ColumnName], _separatore);
|
|
}
|
|
return string.Format("{0}\n\r{1}\n\r", _nomi, _valori);
|
|
}
|
|
/// <summary>
|
|
/// fornisce tabella elenco eventi
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DS_applicazione.EventListDataTable elencoEventi()
|
|
{
|
|
return taEvList.GetData();
|
|
}
|
|
/// <summary>
|
|
/// fornisce tabella elenco stati (DiarioDiBordo)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DS_applicazione.DiarioDiBordoDataTable elencoStati()
|
|
{
|
|
return taDiario.GetData();
|
|
}
|
|
/// <summary>
|
|
/// restituisce l'oggetto tipizzato che rappresenta i dati del setup di una macchina
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public DS_applicazione.DatiMacchineRow getDatiMacchina(string idxMacchina)
|
|
{
|
|
DS_applicazione.DatiMacchineRow answ = null;
|
|
try
|
|
{
|
|
answ = taDatiMacch.GetByIdx(idxMacchina)[0];
|
|
}
|
|
catch
|
|
{
|
|
SteamWare.logger.lg.scriviLog(string.Format("Non sono riuscito a leggere la conf della macchina {0}", idxMacchina), SteamWare.tipoLog.ERROR);
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce una tabella con tutte le transizioni degli ingressi per una data macchina
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public DS_applicazione.TransizioneIngressiDataTable getMatriceIngressi(string idxMacchina)
|
|
{
|
|
DS_applicazione.TransizioneIngressiDataTable answ;
|
|
try
|
|
{
|
|
answ = DataLayer.obj.taTranIngr.getMatriceByIdxMacchina(idxMacchina);
|
|
}
|
|
catch
|
|
{
|
|
answ = null;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
#region scritture eventi simulati
|
|
|
|
public int scriviRigaEventoSimulata(DateTime dataOra, string IdxMacchina, int IdxTipo, string CodArticolo, string Value, int MatrOpr, string pallet)
|
|
{
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(IdxMacchina);
|
|
// inserisco evento
|
|
int inserito = taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, MatrOpr, pallet);
|
|
return inserito;
|
|
}
|
|
public int scriviRigaStatoSimulata(DateTime dataOra, string IdxMacchina, int IdxStato, string CodArticolo, string Value, int MatrOpr, string pallet)
|
|
{
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(IdxMacchina);
|
|
// inserisco la nuova riga di stato mentre il trigger aggiorna le tab...
|
|
int inserito = taDiario.Insert(IdxMacchina, dataOra, null, IdxStato, null, Value, CodArticolo, null, null, MatrOpr, pallet);
|
|
return inserito;
|
|
}
|
|
|
|
public int scriviRigaEventoSimulata(DateTime dataOra, string IdxMacchina, int IdxTipo, string CodArticolo, string Value)
|
|
{
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(IdxMacchina);
|
|
// inserisco evento
|
|
int inserito = taEvList.Insert(IdxMacchina, dataOra, IdxTipo, CodArticolo, Value, 0, "-");
|
|
return inserito;
|
|
}
|
|
public int scriviRigaStatoSimulata(DateTime dataOra, string IdxMacchina, int IdxStato, string CodArticolo, string Value)
|
|
{
|
|
// verifico se esista la macchina altrimenti la creo...
|
|
verificaIdxMacchina(IdxMacchina);
|
|
// inserisco la nuova riga di stato mentre il trigger aggiorna le tab...
|
|
int inserito = taDiario.Insert(IdxMacchina, dataOra, null, IdxStato, null, Value, CodArticolo, null, null, 0, "-");
|
|
return inserito;
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// cancella tutti gli eventi
|
|
/// </summary>
|
|
public void deleteAllEventi()
|
|
{
|
|
taEvList.DeleteAll();
|
|
}
|
|
/// <summary>
|
|
/// cancella tutti gli stati
|
|
/// </summary>
|
|
public void deleteAllStati()
|
|
{
|
|
taDiario.DeleteAll();
|
|
}
|
|
|
|
/// <summary>
|
|
/// restituisce una riga di dati relativa ad una macchina
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public DS_applicazione.MacchineRow getRigaMacchina(string idxMacchina)
|
|
{
|
|
return taMacchine.GetByIdx(idxMacchina)[0];
|
|
}
|
|
|
|
public DS_applicazione.EventListDataTable elencoEventiImpianto(string idxMacchina)
|
|
{
|
|
return taEvList.GetDataByIdxMacchina(idxMacchina);
|
|
}
|
|
public DS_applicazione.DiarioDiBordoDataTable elencoStatiImpianto(string idxMacchina)
|
|
{
|
|
return taDiario.GetDataByIdxMacchina(idxMacchina);
|
|
}
|
|
public DS_applicazione.EventListDataTable elencoEventiImpiantoPeriodo(string idxMacchina, DateTime dal, DateTime al)
|
|
{
|
|
return taEvList.GetByMacchinaPeriodo(idxMacchina, dal, al);
|
|
}
|
|
public DS_applicazione.DiarioDiBordoDataTable nextEventoImpiantoFrom(string idxMacchina, DateTime prevData)
|
|
{
|
|
return taDiario.getNextByMacchInizioStato(idxMacchina, prevData);
|
|
}
|
|
public DS_applicazione.DiarioDiBordoDataTable elencoStatiImpiantoPeriodo(string idxMacchina, DateTime dal, DateTime al)
|
|
{
|
|
DS_applicazione.DiarioDiBordoDataTable answ = new DS_applicazione.DiarioDiBordoDataTable();
|
|
try
|
|
{
|
|
answ = taDiario.GetByMacchinaPeriodo(idxMacchina, dal, al);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Eccezione recupero elencoStatiImpiantoPeriodo:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary> verifica che il bar code sia un barcode Operatore
|
|
/// </summary>
|
|
/// <param name="codice"> Bar code da verificare</param>
|
|
/// <returns> true se bar code per operatore </returns>
|
|
public bool isOperatore(string codice)
|
|
{
|
|
// controlli validità bar code operatore : deve cominciare con O maiuscola
|
|
bool check = codice.StartsWith("O");
|
|
return check;
|
|
}
|
|
|
|
/// <summary> verifica che il bar code sia un barcode nomeMacchina
|
|
/// </summary>
|
|
/// <param name="codice"> Bar code da verificare</param>
|
|
/// <returns> true se bar code per operatore </returns>
|
|
public bool isNomeMacchina(string codice)
|
|
{
|
|
// FARE!!! controllare quale codice ci vuole
|
|
// controlli validità bar code nomeMacchina : deve cominciare con O maiuscola
|
|
bool check = codice.StartsWith("C#");
|
|
return check;
|
|
}
|
|
/// <summary>
|
|
/// verifica un codice se sia di tipo "comando"
|
|
/// </summary>
|
|
/// <param name="comando"></param>
|
|
/// <returns></returns>
|
|
public inputComando isComando(string comando)
|
|
{
|
|
inputComando answ = new inputComando();
|
|
answ.isValid = false;
|
|
DS_applicazione.TransizioneEventiDataTable tabTransEv = new DS_applicazione.TransizioneEventiDataTable();
|
|
try
|
|
{
|
|
tabTransEv = taTranEv.GetDataByCodInviato(comando);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
if (tabTransEv.Rows.Count != 0)
|
|
{
|
|
answ.isValid = true;
|
|
answ.idxTipoEvento = tabTransEv[0].IdxTipoEvento;
|
|
answ.precInput = tabTransEv[0].prec_codInviato;
|
|
answ.text2show = tabTransEv[0].text2show;
|
|
try
|
|
{
|
|
answ.descrComando = tabTransEv[0].descrComando;
|
|
}
|
|
catch
|
|
{
|
|
answ.descrComando = "-";
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// restituisce una riga di dati relativa ad una macchina
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public DS_applicazione.StatoMacchineRow getRigaStatoMacchina(string idxMacchina)
|
|
{
|
|
return taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0];
|
|
}
|
|
/// <summary>
|
|
/// converte la definizioen di stato nel suo valore
|
|
/// </summary>
|
|
/// <param name="idx"></param>
|
|
/// <returns></returns>
|
|
public string statoDaIdxStato(int idx)
|
|
{
|
|
return taAnagSt.GetByIdx(idx)[0].Descrizione;
|
|
}
|
|
|
|
/// <summary>
|
|
/// scrive un evento di keepalive sulla tabella
|
|
/// </summary>
|
|
/// <param name="IdxMacchina"></param>
|
|
/// <param name="oraMacchina"></param>
|
|
/// <returns></returns>
|
|
public void scriviKeepAlive(string IdxMacchina, DateTime oraMacchina)
|
|
{
|
|
string nomeVar = string.Format("KeepAlive:{0}", IdxMacchina);
|
|
// cerco se ho keep alive in redis,
|
|
bool keyPresent = false;
|
|
DateTime adesso = DateTime.Now;
|
|
try
|
|
{
|
|
keyPresent = memLayer.ML.redKeyPresentSz(memLayer.ML.redHash(nomeVar));
|
|
}
|
|
catch
|
|
{ }
|
|
// se NON presente salvo in REDIS con TTL 10 sec e sul DB...
|
|
if (!keyPresent)
|
|
{
|
|
memLayer.ML.setRSV(memLayer.ML.redHash(nomeVar), adesso.ToString("s"), 10);
|
|
try
|
|
{
|
|
if (memLayer.ML.CRB("resetConnKA"))
|
|
{
|
|
if (memLayer.ML.CRB("forceResetKeepAlive"))
|
|
{
|
|
taKeepAlive.Connection.Close();
|
|
taKeepAlive.Connection.Open();
|
|
}
|
|
else
|
|
{
|
|
if (taKeepAlive.Connection.State == ConnectionState.Closed)
|
|
{
|
|
taKeepAlive.Connection.Open();
|
|
}
|
|
}
|
|
}
|
|
if (memLayer.ML.CRI("_logLevel") > 6)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Scrittura keep alive! IdxMacchina:{0} | oraMacchina:{1}", IdxMacchina, oraMacchina));
|
|
}
|
|
// 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto
|
|
if (memLayer.ML.CRB("disable_singleton"))
|
|
{
|
|
// 2017.06.09 forzo init x errori "sovrapposizioni"
|
|
taKeepAlive = new DS_applicazioneTableAdapters.KeepAliveTableAdapter();
|
|
}
|
|
taKeepAlive.UpdateQueryNoStartTime(DateTime.Now, oraMacchina, IdxMacchina);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in scrittura keep alive!{0}oraMacchina:{1} - IdxMacchina:{2}{0}{3}", Environment.NewLine, oraMacchina, IdxMacchina, exc), tipoLog.EXCEPTION);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Registra un evento di RemoteReboot sulla tabella
|
|
/// </summary>
|
|
/// <param name="IdxMacchina"></param>
|
|
/// <param name="IPv4"></param>
|
|
/// <param name="macAddr"></param>
|
|
/// <returns></returns>
|
|
public void scriviRemoteReboot(string IdxMacchina, string IPv4, string agent, string macAddr)
|
|
{
|
|
taRRL.Insert(IdxMacchina, IPv4, agent, DateTime.Now, macAddr);
|
|
}
|
|
|
|
/// <summary>
|
|
/// scrive un evento di start di keepalive sulla tabella
|
|
/// </summary>
|
|
/// <param name="IdxMacchina"></param>
|
|
/// <param name="oraMacchina"></param>
|
|
/// <returns></returns>
|
|
public void scriviPrimoKeepAlive(string IdxMacchina, DateTime oraMacchina)
|
|
{
|
|
// se non c'è riga macchina insert...
|
|
if (taKeepAlive.GetData().FindByIdxMacchina(IdxMacchina) == null)
|
|
{
|
|
taKeepAlive.Insert(IdxMacchina, DateTime.Now, oraMacchina, DateTime.Now);
|
|
}
|
|
else // altrimenti update!
|
|
{
|
|
taKeepAlive.UpdateQuery(DateTime.Now, oraMacchina, DateTime.Now, IdxMacchina);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// fornisce il prossimo IdxMicroStato della macchina a stati della gestione segnali in input
|
|
/// </summary>
|
|
/// <param name="IdxMacchina"></param>
|
|
/// <param name="IdxMicroStato"></param>
|
|
/// <param name="ValoreIngresso"></param>
|
|
/// <returns></returns>
|
|
public hwMachineState getNextMicroStato(string IdxMacchina, int IdxMicroStato, int ValoreIngresso)
|
|
{
|
|
hwMachineState valori = new hwMachineState();
|
|
valori.IdxTipoEvento = -1;
|
|
valori.next_IdxMicroStato = IdxMicroStato; // se non trovo un nuovo stato, resto in questo
|
|
// provo a recuperare i dati...
|
|
DS_applicazione.TransizioneIngressiRow rigaIngr;
|
|
try
|
|
{
|
|
rigaIngr = taTransIngr.GetNextStatus(IdxMacchina, IdxMicroStato, ValoreIngresso)[0];
|
|
valori.IdxTipoEvento = rigaIngr.IdxTipoEvento;
|
|
valori.next_IdxMicroStato = rigaIngr.next_IdxMicroStato;
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
return valori;
|
|
}
|
|
|
|
/// <summary>
|
|
/// restituisce la stringa del colore della macchina (1 char, V/G/R)
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public string getColoreMacchina(string idxMacchina)
|
|
{
|
|
string colore = "";
|
|
// cerco stato macchina...
|
|
DS_applicazione.StatoMacchineRow rigaStato;
|
|
try
|
|
{
|
|
rigaStato = taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0];
|
|
// cerco il colore...
|
|
try
|
|
{
|
|
colore = taAnagSt.GetByIdx(rigaStato.IdxStato)[0].Semaforo;
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
return colore;
|
|
}
|
|
/// <summary>
|
|
/// restituisce la stringa del pallet correntemente in lavorazione sulla macchina
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public string getPalletMacchina(string idxMacchina)
|
|
{
|
|
string pallet = "";
|
|
try
|
|
{
|
|
pallet = (taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]).pallet;
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
return pallet;
|
|
}
|
|
/// <summary>
|
|
/// restituisce la matricola dell'operatore sulla macchina
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public int getMatrOprMacchina(string idxMacchina)
|
|
{
|
|
return getMatrOpMacc(idxMacchina);
|
|
}
|
|
|
|
/// <summary>
|
|
/// restituisce cognome nome dell'operatore data la sua matricola
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public string getCognomeNomeDaMatr(int matrOpr)
|
|
{
|
|
return getGeneralitDaMatr(matrOpr);
|
|
}
|
|
/// <summary>
|
|
/// restituisce cognome nome dell'operatore data la sua matricola
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public string getCognomeNomeOprMacchina(string idxMacchina)
|
|
{
|
|
string cognNome = "";
|
|
try
|
|
{
|
|
cognNome = getGeneralitDaMatr(getMatrOpMacc(idxMacchina));
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
return cognNome;
|
|
}
|
|
|
|
/// <summary>
|
|
/// restituisce il TempoCiclo effettivo (tecnico) della macchina
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public decimal getTcEffMacchina(string idxMacchina)
|
|
{
|
|
decimal tc = 0;
|
|
try
|
|
{
|
|
DS_ProdTempi.stp_repDonati_getDatiProdMacchinaPeriodoRow riga = DataLayer.obj.taDatiProdMacchPer.GetData(idxMacchina, DateTime.Now.AddMinutes(-30), DateTime.Now)[0];
|
|
if (riga.TCEffRT > 0)
|
|
{
|
|
tc = riga.TCEffRT;
|
|
}
|
|
else
|
|
{
|
|
tc = riga.TCAssegnato;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
// imposto a 99'TC
|
|
if (tc == 0)
|
|
{
|
|
tc = 99.9M;
|
|
// scrivo log per indicare mancato caricamento dati tc dichiarato e conseguente errore sul timer - 2/11/2012 EN&CV
|
|
logger.lg.scriviLog(string.Format("Impostato TC Tempo Ciclo a 99' (99.9M) causa mancato inserimento tempo ciclo dichiarato"));
|
|
}
|
|
return tc;
|
|
}
|
|
|
|
/// <summary>
|
|
/// rigenera la tab diario di bordo x la macchian richiesta nell'intervallo definito
|
|
/// </summary>
|
|
/// <param name="IdxMacchina"></param>
|
|
/// <param name="dataInizio"></param>
|
|
/// <param name="dataFine"></param>
|
|
public void rigeneraDiarioDiBordo(string IdxMacchina, DateTime dataInizio, DateTime dataFine)
|
|
{
|
|
// elimino da diario di bordo i valori nell'intervallo...
|
|
taDiario.DeleteByMacchinaPeriodo(IdxMacchina, dataInizio, dataFine);
|
|
// seleziono le righe eventi interessate e le processo 1 ad 1...
|
|
DS_applicazione.EventListDataTable tabEventi = taEvList.GetByMacchinaPeriodo(IdxMacchina, dataInizio, dataFine);
|
|
foreach (DS_applicazione.EventListRow rigaEv in tabEventi)
|
|
{
|
|
if (rigaEv.IdxTipo <= 12) // è barcode
|
|
{
|
|
checkCambiaStatoBatch(tipoInputEvento.barcode, IdxMacchina, rigaEv.InizioStato, rigaEv.IdxTipo, rigaEv.CodArticolo, rigaEv.Value, rigaEv.MatrOpr, rigaEv.pallet);
|
|
}
|
|
else // è hw
|
|
{
|
|
checkCambiaStatoBatch(tipoInputEvento.hw, IdxMacchina, rigaEv.InizioStato, rigaEv.IdxTipo, rigaEv.CodArticolo, rigaEv.Value, rigaEv.MatrOpr, rigaEv.pallet);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// restituisce la riga di transizione del comando...
|
|
/// </summary>
|
|
/// <param name="descrComando"></param>
|
|
/// <returns></returns>
|
|
public DS_applicazione.TransizioneEventiRow getRigaTransizioneDaDescrComando(string descrComando)
|
|
{
|
|
return taTranEv.getByDescrComando(descrComando)[0];
|
|
}
|
|
|
|
/// <summary>
|
|
/// Dichiara esplicitamente produzione e tempo ciclo rilevato per il numero di pezzi indicati (real time, NON confermati)
|
|
/// </summary>
|
|
/// <param name="IdxMacchina"></param>
|
|
/// <param name="CodArticolo"></param>
|
|
/// <param name="tempoRilevato"></param>
|
|
/// <param name="numPz"></param>
|
|
/// <param name="eventTime"></param>
|
|
/// <param name="currentTime"></param>
|
|
public void dichiaraProduzTempoCiclo(string IdxMacchina, string CodArticolo, decimal tempoRilevato, int numPz, DateTime eventTime, DateTime currentTime)
|
|
{
|
|
// calcolo dataOra reale (evento + delta(ora server - ora remota)
|
|
DateTime dataOra = eventTime.Add(DateTime.Now - currentTime);
|
|
// scrivo il dato del TC rilevato
|
|
taTCRilevati.Insert(IdxMacchina, CodArticolo, dataOra, tempoRilevato, numPz);
|
|
}
|
|
|
|
/// <summary>
|
|
/// effettua verifica del codice barcode e restituisce un oggetto inputComando che indica come proseguire
|
|
/// </summary>
|
|
/// <param name="barcodeValue"></param>
|
|
/// <returns></returns>
|
|
public inputComando tryBarcode(string barcodeValue)
|
|
{
|
|
inputComando answ = new inputComando();
|
|
// controllo...
|
|
|
|
return answ;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |