TAB3:
- Gestione fermate RT - fix lettura h2IOB
This commit is contained in:
@@ -24,7 +24,7 @@ namespace MP.Data.Controllers
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce l'anagrafica eventi per intero
|
||||
/// Restituisce l'anagrafica EVENTI per intero
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagEventiModel> AnagEventiGetAll()
|
||||
@@ -33,9 +33,25 @@ namespace MP.Data.Controllers
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagEventi
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
.DbSetAnagEventi
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// Restituisce l'anagrafica STATI per intero
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagStatiModel> AnagStatiGetAll()
|
||||
{
|
||||
List<AnagStatiModel> dbResult = new List<AnagStatiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagStati
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
@@ -138,6 +154,94 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stato macchina (da key)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public StatoMacchineModel StatoMacchina(string idxMacchina)
|
||||
{
|
||||
StatoMacchineModel dbResult = new StatoMacchineModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetStatoMacc
|
||||
.Where(x => x.IdxMacchina == idxMacchina)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefault();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// MicroStato macchina (da key)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public MicroStatoMacchinaModel MicroStatoMacchina(string idxMacchina)
|
||||
{
|
||||
MicroStatoMacchinaModel dbResult = new MicroStatoMacchinaModel();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
.Where(x => x.IdxMacchina == idxMacchina)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefault();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// Stato macchina - tutte
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public List<MicroStatoMacchinaModel> MicroStatoMacchinaGetAll()
|
||||
{
|
||||
List<MicroStatoMacchinaModel> dbResult = new List<MicroStatoMacchinaModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// Aggiornamento record Microstato macchina
|
||||
/// </summary>
|
||||
/// <param name="newRec"></param>
|
||||
/// <returns></returns>
|
||||
public bool MicroStatoMacchinaUpsert(MicroStatoMacchinaModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
.Where(x => x.IdxMacchina == newRec.IdxMacchina)
|
||||
.AsNoTracking()
|
||||
.FirstOrDefault();
|
||||
if(actRec==null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetMicroStatoMacc
|
||||
.Add(newRec);
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.IdxMicroStato = newRec.IdxMicroStato;
|
||||
actRec.InizioStato = newRec.InizioStato;
|
||||
actRec.Value = newRec.Value;
|
||||
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
dbCtx.SaveChanges();
|
||||
fatto = true;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua conferma prod macchina dell'intero periodo da confermare (ultima conferma
|
||||
/// --> dtEvent)
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.DTO
|
||||
{
|
||||
public class IobInfoDTO
|
||||
{
|
||||
public string name { get; set; } = "ND";
|
||||
public string IP { get; set; } = "::1";
|
||||
public string iType { get; set; } = "Win";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.DatabaseModels
|
||||
{
|
||||
[Table("AnagraficaStati")]
|
||||
public class AnagStatiModel
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int IdxStato { get; set; } = 0;
|
||||
public string Descrizione { get; set; } = "";
|
||||
public string Semaforo { get; set; } = "";
|
||||
public int Priorita { get; set; } = 0;
|
||||
public string ClasseTempo { get; set; } = "";
|
||||
public bool ShowArticolo { get; set; } = true;
|
||||
public string KeyStato { get; set; } = "";
|
||||
public string NoteStato { get; set; } = "";
|
||||
//public string CssClass { get; set; } = "";
|
||||
//public string Icon { get; set; } = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
#nullable disable
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
namespace MP.Data.DatabaseModels
|
||||
{
|
||||
[Table("MicroStatoMacchina")]
|
||||
public partial class MicroStatoMacchinaModel
|
||||
{
|
||||
[Key]
|
||||
public string IdxMacchina { get; set; } = "NA";
|
||||
public int IdxMicroStato { get; set; } = 0;
|
||||
public DateTime InizioStato { get; set; } = DateTime.Now;
|
||||
public string Value { get; set; } = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
#nullable disable
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
namespace MP.Data.DatabaseModels
|
||||
{
|
||||
[Table("StatoMacchine")]
|
||||
public partial class StatoMacchineModel
|
||||
{
|
||||
[Key]
|
||||
public string IdxMacchina { get; set; } = "NA";
|
||||
public int IdxStato { get; set; } = 0;
|
||||
public DateTime InizioStato { get; set; } = DateTime.Now;
|
||||
public string Value { get; set; } = "";
|
||||
public string CodArticolo { get; set; } = "";
|
||||
public float TempoCicloBase { get; set; } = 0;
|
||||
public int PzPalletProd { get; set; } = 0;
|
||||
public int MatrOpr { get; set; } = 0;
|
||||
public string pallet { get; set; } = "";
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ namespace MP.Data
|
||||
public virtual DbSet<StatsAnagArticoli> DbSetStatArticoli { get; set; }
|
||||
public virtual DbSet<AnagArticoli> DbSetArticoli { get; set; }
|
||||
public virtual DbSet<AnagEventiModel> DbSetAnagEventi { get; set; }
|
||||
public virtual DbSet<AnagStatiModel> DbSetAnagStati { get; set; }
|
||||
public virtual DbSet<Macchine> DbSetMacchine { get; set; }
|
||||
public virtual DbSet<MappaStatoExpl> DbSetMSE { get; set; }
|
||||
public virtual DbSet<ConfigModel> DbSetConfig { get; set; }
|
||||
@@ -63,6 +64,8 @@ namespace MP.Data
|
||||
public virtual DbSet<Macchine2SlaveModel> DbSetM2S { get; set; }
|
||||
public virtual DbSet<TransizioneIngressiModel> DbSetSMI { get; set; }
|
||||
public virtual DbSet<KeepAliveModel> DbSetKeepAlive { get; set; }
|
||||
public virtual DbSet<MicroStatoMacchinaModel> DbSetMicroStatoMacc { get; set; }
|
||||
public virtual DbSet<StatoMacchineModel> DbSetStatoMacc { get; set; }
|
||||
public virtual DbSet<StatoProdModel> DbSetStatoProd { get; set; }
|
||||
|
||||
public virtual DbSet<ST_Act> DbSetStAct { get; set; }
|
||||
|
||||
@@ -0,0 +1,459 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Objects
|
||||
{
|
||||
public class Enums
|
||||
{
|
||||
public enum DataItemCategory
|
||||
{
|
||||
CONDITION = 0,
|
||||
EVENT = 1,
|
||||
SAMPLE = 2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tipo di esito (generico)
|
||||
/// </summary>
|
||||
public enum esitoExec
|
||||
{
|
||||
undone,
|
||||
ok,
|
||||
error
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tipo di IOB
|
||||
/// </summary>
|
||||
public enum IobType
|
||||
{
|
||||
/// <summary>
|
||||
/// Non definito
|
||||
/// </summary>
|
||||
ND,
|
||||
|
||||
/// <summary>
|
||||
/// IOB rPI
|
||||
/// </summary>
|
||||
rPi,
|
||||
|
||||
/// <summary>
|
||||
/// IOB Windows
|
||||
/// </summary>
|
||||
WIN
|
||||
}
|
||||
|
||||
public enum modBusAddrType
|
||||
{
|
||||
/// <summary>
|
||||
/// ModBus Coil 0xxxxx (booleano) - OUT R/W
|
||||
/// </summary>
|
||||
Coil = 0,
|
||||
|
||||
/// <summary>
|
||||
/// ModBus Input discreto 1xxxxx (booleano) - IN R
|
||||
/// </summary>
|
||||
DiscreteInput = 1,
|
||||
|
||||
/// <summary>
|
||||
/// ModBus Input Register 3xxxxx (int[] convertibile a vari int/real) - IN R
|
||||
/// </summary>
|
||||
InputRegister = 3,
|
||||
|
||||
/// <summary>
|
||||
/// ModBus Holding Register 4xxxxx (int[] convertibile a vari int/real) - OUT R/W
|
||||
/// </summary>
|
||||
HoldingRegister = 4
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco dei tipi di valore gestiti da PLC (inizialmente SIEMENS)
|
||||
/// </summary>
|
||||
public enum plcDataType
|
||||
{
|
||||
/// <summary>
|
||||
/// Tipo boolean
|
||||
/// </summary>
|
||||
Boolean,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo Int16 intero 16bit
|
||||
/// </summary>
|
||||
Int,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo UInt16 reversed LowHigh
|
||||
/// </summary>
|
||||
IntLH,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo Int32 intero 32bit
|
||||
/// </summary>
|
||||
DInt,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo UInt32 reversed LowHigh
|
||||
/// </summary>
|
||||
DIntLH,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo UInt16, intero 16bit
|
||||
/// </summary>
|
||||
Word,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo UInt32, intero Unsigned 32bit
|
||||
/// </summary>
|
||||
DWord,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo REAL 32 bit
|
||||
/// </summary>
|
||||
Real,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo REAL 32 bit standard (HighLow) - sinonimo di Real, creato x simmetria con caso LH
|
||||
/// </summary>
|
||||
RealHL,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo REAL 32 bit con swap byte (LowHigh) al posto del normale caso HL (HighLow)
|
||||
/// </summary>
|
||||
RealLH,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo stringa
|
||||
/// </summary>
|
||||
String,
|
||||
|
||||
/// <summary>
|
||||
/// Timpo intero da High/Low Bit positivo (high bit va moltiplicato x 32768 = Uint16Max/2)
|
||||
/// </summary>
|
||||
HLPInt,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo FLOAT 32 bit con endiannes standard (es modbus)
|
||||
/// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float -
|
||||
/// Big Endian (ABCD)
|
||||
/// </summary>
|
||||
FloatABCD,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo FLOAT 32 bit con endiannes NON standard (es modbus)
|
||||
/// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float -
|
||||
/// Mid-Big Endian (BADC)
|
||||
/// </summary>
|
||||
FloatBADC,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo FLOAT 32 bit con endiannes NON standard (es modbus)
|
||||
/// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float -
|
||||
/// Mid-Little Endian (CDAB)
|
||||
/// </summary>
|
||||
FloatCDAB,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo FLOAT 32 bit con endiannes NON standard (es modbus)
|
||||
/// https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ Float -
|
||||
/// Little Endian (DCBA)
|
||||
/// </summary>
|
||||
FloatDCBA,
|
||||
|
||||
/// <summary>
|
||||
/// Valore bitmap, inteso come array di bit ognuno da trattare come uno stato on/off
|
||||
/// indipendente e sommabile (es allarmi)
|
||||
/// </summary>
|
||||
BitMap,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo Byte 8 bit equivalente a BitMap
|
||||
/// </summary>
|
||||
Byte,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo UInt16 intero senza segno 16bit
|
||||
/// </summary>
|
||||
UInt,
|
||||
|
||||
/// <summary>
|
||||
/// Tipo UInt32 intero senza segno 32bit
|
||||
/// </summary>
|
||||
UDInt
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia dato Raw Transfer
|
||||
/// </summary>
|
||||
/// serializzazione Native [JsonConverter(typeof(JsonStringEnumConverter))] serializzazione
|
||||
/// Newtonsoft json [JsonConverter(typeof(StringEnumConverter))]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum rawTransfType
|
||||
{
|
||||
ND = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Icoel: Batch info
|
||||
/// </summary>
|
||||
IcoelBatch,
|
||||
|
||||
/// <summary>
|
||||
/// Icoel: Variety + layout info relative
|
||||
/// </summary>
|
||||
IcoelVarInfo,
|
||||
|
||||
/// <summary>
|
||||
/// Info tipo tabella RegGiacenze (MAG)
|
||||
/// </summary>
|
||||
RegGiacenze
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumerazione tipi di semaforo
|
||||
/// </summary>
|
||||
public enum Semaforo
|
||||
{
|
||||
/// <summary>
|
||||
/// Stato non definito
|
||||
/// </summary>
|
||||
ND,
|
||||
|
||||
/// <summary>
|
||||
/// Verde
|
||||
/// </summary>
|
||||
SV,
|
||||
|
||||
/// <summary>
|
||||
/// Giallo
|
||||
/// </summary>
|
||||
SG,
|
||||
|
||||
/// <summary>
|
||||
/// Rosso
|
||||
/// </summary>
|
||||
SR,
|
||||
|
||||
/// <summary>
|
||||
/// Grigio/Spento
|
||||
/// </summary>
|
||||
SS
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco task ammessi (x IOB-WIN da eseguire...)
|
||||
/// </summary>
|
||||
public enum taskType
|
||||
{
|
||||
/// <summary>
|
||||
/// Task nullo / fake
|
||||
/// </summary>
|
||||
nihil,
|
||||
|
||||
/// <summary>
|
||||
/// Rimanda a PLC eventuale segnale NON in setup (MA NON RESETTA)
|
||||
/// </summary>
|
||||
fixStopSetup,
|
||||
|
||||
/// <summary>
|
||||
/// Indica al PLC di forzare il reset del contapezzi
|
||||
/// </summary>
|
||||
forceResetPzCount,
|
||||
|
||||
/// <summary>
|
||||
/// Indica al PLC di forzare il NUOVO valore di contapezzi (impostato come value)
|
||||
/// </summary>
|
||||
forceSetPzCount,
|
||||
|
||||
/// <summary>
|
||||
/// Imposta Articolo su PLC
|
||||
/// </summary>
|
||||
setArt,
|
||||
|
||||
/// <summary>
|
||||
/// Imposta Commessa su PLC
|
||||
/// </summary>
|
||||
setComm,
|
||||
|
||||
/// <summary>
|
||||
/// Set di un PARAMETRO su PLC (in value avremo un JSON object)
|
||||
/// </summary>
|
||||
setParameter,
|
||||
|
||||
/// <summary>
|
||||
/// Set Programma CNC su PLC
|
||||
/// </summary>
|
||||
setProg,
|
||||
|
||||
/// <summary>
|
||||
/// Indica al PLC di impostare il numero di pezzi da produrre per la commessa (impostato
|
||||
/// come value)
|
||||
/// </summary>
|
||||
setPzComm,
|
||||
|
||||
/// <summary>
|
||||
/// Indica al PLC iniziato setup (e secondo casi ferma contapezzi /resetta)
|
||||
/// </summary>
|
||||
startSetup,
|
||||
|
||||
/// <summary>
|
||||
/// Indica al PLC finito setup (e secondo casi ferma contapezzi /resetta)
|
||||
/// </summary>
|
||||
stopSetup,
|
||||
|
||||
/// <summary>
|
||||
/// Richiesta invio watchdog a PLC
|
||||
/// </summary>
|
||||
sendWatchDogMes2Plc,
|
||||
|
||||
/// <summary>
|
||||
/// Indica che è FINITA la produzione (e quindi cancello dati backup)
|
||||
/// </summary>
|
||||
endProd,
|
||||
|
||||
/// <summary>
|
||||
/// Richiesta esecuzione di un sync dei dati DB di frontiera
|
||||
/// </summary>
|
||||
syncDbData,
|
||||
|
||||
/// <summary>
|
||||
/// Imposta Fornitore (es grower x ICOEL)
|
||||
/// </summary>
|
||||
setSupplier,
|
||||
|
||||
/// <summary>
|
||||
/// Effettua processing other info (es ritorno consumi x ricette FIMAT)
|
||||
/// </summary>
|
||||
processOtherInfo
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finestra temporale di aggregazione dati VC
|
||||
/// </summary>
|
||||
public enum timeWindow
|
||||
{
|
||||
free,
|
||||
hour,
|
||||
day,
|
||||
week,
|
||||
month
|
||||
}
|
||||
|
||||
public enum tipoBarcode
|
||||
{
|
||||
/// <summary>
|
||||
/// tipo non riconosciuto
|
||||
/// </summary>
|
||||
nd,
|
||||
|
||||
/// <summary>
|
||||
/// identifica una matricola operatore nel formato OPxxxxx (xxxxx è un intero che
|
||||
/// rappresenta la matricola, std fino a 8 cifre)
|
||||
/// </summary>
|
||||
matrOperatore,
|
||||
|
||||
/// <summary>
|
||||
/// identifica un cartellino di tipo CodArticolo
|
||||
/// </summary>
|
||||
codArticolo,
|
||||
|
||||
/// <summary>
|
||||
/// identifica un codice per le attività di inizio/fine attrezzaggio e inizio/fine produzione
|
||||
/// </summary>
|
||||
attrezzaggio,
|
||||
|
||||
/// <summary>
|
||||
/// identifica un codice per le attività di conferma produzione/fermi
|
||||
/// </summary>
|
||||
confermaProduzione,
|
||||
|
||||
/// <summary>
|
||||
/// identifica un cartellino di dichiarazione fermata nel formato FExxxx dove xxxx è
|
||||
/// idxEvento dichiarato...
|
||||
/// </summary>
|
||||
dichiaraFermata,
|
||||
|
||||
/// <summary>
|
||||
/// indentifica un codice di modifica turno
|
||||
/// </summary>
|
||||
modificaTurno
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// tipologia di evento (generico) segnalato
|
||||
/// </summary>
|
||||
public enum tipoEvento
|
||||
{
|
||||
/// <summary>
|
||||
/// evento di reset
|
||||
/// </summary>
|
||||
reset,
|
||||
|
||||
/// <summary>
|
||||
/// richiesta editing
|
||||
/// </summary>
|
||||
edit,
|
||||
|
||||
/// <summary>
|
||||
/// nuova selezione
|
||||
/// </summary>
|
||||
selection,
|
||||
|
||||
/// <summary>
|
||||
/// eliminazione record(s)
|
||||
/// </summary>
|
||||
delete
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// tipologia evento inviato
|
||||
/// </summary>
|
||||
public enum tipoInputEvento
|
||||
{
|
||||
barcode,
|
||||
hw
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia di selettore
|
||||
/// </summary>
|
||||
public enum tipoSelettore
|
||||
{
|
||||
articoli
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tipologia di elaborazione/funzione da applicare a VC
|
||||
/// </summary>
|
||||
public enum VC_func
|
||||
{
|
||||
/// <summary>
|
||||
/// Valore puntuale
|
||||
/// </summary>
|
||||
POINT = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Valore medio del periodo
|
||||
/// </summary>
|
||||
AVG,
|
||||
|
||||
/// <summary>
|
||||
/// Valore massimo del periodo
|
||||
/// </summary>
|
||||
MAX,
|
||||
|
||||
/// <summary>
|
||||
/// Valore minimo del periodo
|
||||
/// </summary>
|
||||
MIN,
|
||||
|
||||
/// <summary>
|
||||
/// Calcolo della mediana del periodo
|
||||
/// </summary>
|
||||
MEDIAN
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static MP.Data.Objects.Enums;
|
||||
|
||||
namespace MP.Data.Objects
|
||||
{
|
||||
/// <summary>
|
||||
/// Dati resoconto IOB
|
||||
/// </summary>
|
||||
public class IOB_data
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
public bool CNC_Counter { get; set; }=false;
|
||||
public string IP { get; set; } ="";
|
||||
public IobType iType { get; set; } = IobType.ND;
|
||||
public string name { get; set; } ="ND";
|
||||
public string typeCss { get; set; } = "fa fa-question-circle-o";
|
||||
|
||||
#endregion Public Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Objects
|
||||
{
|
||||
/// <summary>
|
||||
/// Struttura gestione comandi di input
|
||||
/// </summary>
|
||||
public struct inputComandoMapo
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// descrizione comando
|
||||
/// </summary>
|
||||
public string descrComando;
|
||||
|
||||
/// <summary>
|
||||
/// idx evento associato al comando
|
||||
/// </summary>
|
||||
public int idxTipoEvento;
|
||||
|
||||
/// <summary>
|
||||
/// input comando valido si/no
|
||||
/// </summary>
|
||||
public bool isValid;
|
||||
|
||||
/// <summary>
|
||||
/// refresh stato macchina encessario si/no
|
||||
/// </summary>
|
||||
public bool needStatusRefresh;
|
||||
|
||||
/// <summary>
|
||||
/// valore di output dal comando
|
||||
/// </summary>
|
||||
public string outValue;
|
||||
|
||||
/// <summary>
|
||||
/// input precedente
|
||||
/// </summary>
|
||||
public string precInput;
|
||||
|
||||
/// <summary>
|
||||
/// testo da mostrare all'utente
|
||||
/// </summary>
|
||||
public string text2show;
|
||||
|
||||
/// <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;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public static bool operator !=(inputComandoMapo left, inputComandoMapo right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public static bool operator ==(inputComandoMapo left, inputComandoMapo right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is inputComandoMapo item))
|
||||
return false;
|
||||
|
||||
if (descrComando != item.descrComando)
|
||||
return false;
|
||||
if (idxTipoEvento != item.idxTipoEvento)
|
||||
return false;
|
||||
if (isValid != item.isValid)
|
||||
return false;
|
||||
if (needStatusRefresh != item.needStatusRefresh)
|
||||
return false;
|
||||
if (outValue != item.outValue)
|
||||
return false;
|
||||
if (precInput != item.precInput)
|
||||
return false;
|
||||
if (text2show != item.text2show)
|
||||
return false;
|
||||
if (wBrowsBoxUrls != item.wBrowsBoxUrls)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,11 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
public Dictionary<string, string> DictConfig { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario Eventi (codice, record completo)
|
||||
/// </summary>
|
||||
public Dictionary<int, AnagEventiModel> DictEventi { get; set; } = new Dictionary<int, AnagEventiModel>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario macchine (shared)
|
||||
/// </summary>
|
||||
@@ -30,6 +35,20 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
public Dictionary<string, int> DictMacchMulti { get; set; } = new Dictionary<string, int>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario Menu
|
||||
/// </summary>
|
||||
public Dictionary<string, List<LinkMenu>> DictMenu { get; set; } = new Dictionary<string, List<LinkMenu>>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario Stati (codice, record completo)
|
||||
/// </summary>
|
||||
public Dictionary<int, AnagStatiModel> DictStati { get; set; } = new Dictionary<int, AnagStatiModel>();
|
||||
|
||||
/// <summary>
|
||||
/// Lista completa eventi
|
||||
/// </summary>
|
||||
public List<AnagEventiModel> ListEventi { get; set; } = new List<AnagEventiModel>();
|
||||
|
||||
/// <summary>
|
||||
/// List configurazione attiva da tab DB
|
||||
@@ -37,9 +56,9 @@ namespace MP.Data.Services
|
||||
public List<VMSFDModel> ListMSFD { get; set; } = new List<VMSFDModel>();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario Menu
|
||||
/// Lista completa stati
|
||||
/// </summary>
|
||||
public Dictionary<string, List<LinkMenu>> DictMenu { get; set; } = new Dictionary<string, List<LinkMenu>>();
|
||||
public List<AnagStatiModel> ListStati { get; set; } = new List<AnagStatiModel>();
|
||||
|
||||
public bool MenuOk
|
||||
{
|
||||
@@ -50,6 +69,75 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Reset cache memory
|
||||
/// </summary>
|
||||
public void ClearCache()
|
||||
{
|
||||
DictMacchine = new Dictionary<string, string>();
|
||||
DictMacchMulti = new Dictionary<string, int>();
|
||||
DictMenu = new Dictionary<string, List<LinkMenu>>();
|
||||
DbConfig = new List<ConfigModel>();
|
||||
DictConfig = new Dictionary<string, string>();
|
||||
DictEventi = new Dictionary<int, AnagEventiModel>();
|
||||
DictStati = new Dictionary<int, AnagStatiModel>();
|
||||
Log.Info("SharedMemService | Cache resetted!");
|
||||
}
|
||||
|
||||
public string GetConf(string chiave)
|
||||
{
|
||||
string answ = "";
|
||||
if (DictConfig.ContainsKey(chiave))
|
||||
{
|
||||
answ = DictConfig[chiave];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public bool GetConfBool(string chiave)
|
||||
{
|
||||
bool answ = false;
|
||||
bool.TryParse(GetConf(chiave), out answ);
|
||||
return answ;
|
||||
}
|
||||
|
||||
public int GetConfInt(string chiave)
|
||||
{
|
||||
int answ = 0;
|
||||
int.TryParse(GetConf(chiave), out answ);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero riga evento da dizionario
|
||||
/// </summary>
|
||||
/// <param name="IdxTipo"></param>
|
||||
/// <returns></returns>
|
||||
public AnagEventiModel GetEventRow(int IdxTipo)
|
||||
{
|
||||
AnagEventiModel answ = new AnagEventiModel();
|
||||
if (DictEventi.ContainsKey(IdxTipo))
|
||||
{
|
||||
answ = DictEventi[IdxTipo];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero riga stato da dizionario
|
||||
/// </summary>
|
||||
/// <param name="IdxStato"></param>
|
||||
/// <returns></returns>
|
||||
public AnagStatiModel GetStateRow(int IdxStato)
|
||||
{
|
||||
AnagStatiModel answ = new AnagStatiModel();
|
||||
if (DictStati.ContainsKey(IdxStato))
|
||||
{
|
||||
answ = DictStati[IdxStato];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce il livello pagina dato URL
|
||||
/// - se contiene ?IdxMacc --> T2D (detail)
|
||||
@@ -76,26 +164,22 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset cache memory
|
||||
/// </summary>
|
||||
public void ClearCache()
|
||||
public void SetConfig(List<ConfigModel>? allConf)
|
||||
{
|
||||
DictMacchine = new Dictionary<string, string>();
|
||||
DictMenu = new Dictionary<string, List<LinkMenu>>();
|
||||
DbConfig = new List<ConfigModel>();
|
||||
DictConfig = new Dictionary<string, string>();
|
||||
Log.Info("SharedMemService | Cache resetted!");
|
||||
}
|
||||
|
||||
public void SetConfig(List<ConfigModel>? newConfList)
|
||||
{
|
||||
DbConfig = newConfList ?? new List<ConfigModel>();
|
||||
DbConfig = allConf ?? new List<ConfigModel>();
|
||||
// salvo dizionario
|
||||
DictConfig = DbConfig.ToDictionary(x => x.Chiave, x => x.Valore);
|
||||
Log.Info("SharedMemService | SetConfig executed!");
|
||||
}
|
||||
|
||||
public void SetEventi(List<AnagEventiModel> allEvents)
|
||||
{
|
||||
ListEventi = allEvents ?? new List<AnagEventiModel>();
|
||||
// salvo dizionario
|
||||
DictEventi = ListEventi.ToDictionary(x => x.IdxTipo, x => x);
|
||||
Log.Info("SharedMemService | SetEventi executed!");
|
||||
}
|
||||
|
||||
public void SetMsfd(List<VMSFDModel> newList)
|
||||
{
|
||||
ListMSFD = newList ?? new List<VMSFDModel>();
|
||||
@@ -104,6 +188,14 @@ namespace MP.Data.Services
|
||||
Log.Info("SharedMemService | SetMsfd executed!");
|
||||
}
|
||||
|
||||
public void SetStati(List<AnagStatiModel> allStati)
|
||||
{
|
||||
ListStati = allStati ?? new List<AnagStatiModel>();
|
||||
// salvo dizionario
|
||||
DictStati = ListStati.ToDictionary(x => x.IdxStato, x => x);
|
||||
Log.Info("SharedMemService | SetStati executed!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua setup memorie menu recuperando dati dal DB + popolando dizionario x livelli
|
||||
/// </summary>
|
||||
@@ -132,30 +224,6 @@ namespace MP.Data.Services
|
||||
Log.Info("SharedMemService | SetupMenu executed!");
|
||||
}
|
||||
|
||||
public string GetConf(string chiave)
|
||||
{
|
||||
string answ = "";
|
||||
if (DictConfig.ContainsKey(chiave))
|
||||
{
|
||||
answ = DictConfig[chiave];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
public int GetConfInt(string chiave)
|
||||
{
|
||||
int answ = 0;
|
||||
int.TryParse(GetConf(chiave), out answ);
|
||||
return answ;
|
||||
}
|
||||
public bool GetConfBool(string chiave)
|
||||
{
|
||||
bool answ = false;
|
||||
bool.TryParse(GetConf(chiave), out answ);
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.DTO;
|
||||
using MP.Data.Objects;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
@@ -9,6 +10,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static MP.Data.Objects.Enums;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
@@ -25,8 +27,8 @@ namespace MP.Data.Services
|
||||
redisDb = redisConn.GetDatabase();
|
||||
|
||||
// conf DB
|
||||
string connStr = _configuration.GetConnectionString("Mp.All");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
ConnStr = _configuration.GetConnectionString("Mp.All");
|
||||
if (string.IsNullOrEmpty(ConnStr))
|
||||
{
|
||||
Log.Error("ConnString empty!");
|
||||
}
|
||||
@@ -38,9 +40,47 @@ namespace MP.Data.Services
|
||||
dbIocController = new Controllers.MpIocController(configuration);
|
||||
sb.AppendLine($"TabDataService | MpIocController OK");
|
||||
Log.Info(sb.ToString());
|
||||
// sistemo i parametri x redHas...
|
||||
CodModulo = _configuration.GetValue<string>("OptConf:CodModulo");
|
||||
var cstringArray = ConnStr.Split(";");
|
||||
foreach (var item in cstringArray)
|
||||
{
|
||||
var cData = item.Trim().Split("=");
|
||||
if (cData.Length == 2)
|
||||
{
|
||||
if (!connStrParams.ContainsKey(cData[0]))
|
||||
{
|
||||
connStrParams.Add(cData[0], cData[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// sistemo
|
||||
DataSource = connStrParams["Server"];
|
||||
DataBase = connStrParams["Database"];
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, string> connStrParams = new Dictionary<string, string>();
|
||||
private string ConnStr = "";
|
||||
private string CodModulo = "";
|
||||
private string DataSource = "";
|
||||
private string DataBase = "";
|
||||
|
||||
private string redHash(string keyName)
|
||||
{
|
||||
string result = keyName;
|
||||
try
|
||||
{
|
||||
result = $"{CodModulo}:{DataSource}:{DataBase}:{keyName}".Replace("\\", "_");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in redHash{Environment.NewLine}{exc}");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
@@ -52,6 +92,10 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco completo EVENTI
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagEventiModel>> AnagEventiGetAll()
|
||||
{
|
||||
// setup parametri costanti
|
||||
@@ -85,6 +129,43 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco completo STATI
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagStatiModel>> AnaStatiGetAll()
|
||||
{
|
||||
// setup parametri costanti
|
||||
DateTime startDate = new DateTime(2000, 1, 1);
|
||||
DateTime endDate = DateTime.Today.AddDays(1);
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<AnagStatiModel>? result = new List<AnagStatiModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:AnagStati";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<AnagStatiModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbTabController.AnagStatiGetAll();
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<AnagStatiModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"AnaStatiGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua conferma prod macchina dell'intero periodo da confermare (ultima conferma
|
||||
/// --> dtEvent)
|
||||
@@ -160,24 +241,23 @@ namespace MP.Data.Services
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<IobInfoDTO> IobInfo(string IdxMacchina)
|
||||
public async Task<IOB_data> IobInfo(string IdxMacchina)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
IobInfoDTO? result = new IobInfoDTO();
|
||||
IOB_data? result = new IOB_data();
|
||||
// cerco in redis...
|
||||
string currKey = $"{moonProRedisBaseKey}:{IdxMacchina}";
|
||||
string currKey = redHash($"hM2IOB:{IdxMacchina}");
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<IobInfoDTO>($"{rawData}");
|
||||
result = JsonConvert.DeserializeObject<IOB_data>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new IobInfoDTO();
|
||||
result = new IOB_data();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"IobInfo | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
@@ -314,6 +394,41 @@ namespace MP.Data.Services
|
||||
Log.Debug($"StatoProdMacchina | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Stato macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<StatoMacchineModel> StatoMacchina(string idxMacchina)
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
StatoMacchineModel? result = new StatoMacchineModel();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:StatoMacc:{idxMacchina}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<StatoMacchineModel>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbTabController.StatoMacchina(idxMacchina);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, TimeSpan.FromSeconds(2));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new StatoMacchineModel();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"StatoMacchina | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intera vista v_MSFD
|
||||
@@ -444,5 +559,292 @@ namespace MP.Data.Services
|
||||
private string moonProRedisBaseKey = "MoonPro:SQL2016DEV:MoonPro:hM2IOB";
|
||||
|
||||
#endregion Private Fields
|
||||
/// <summary>
|
||||
/// Aggiunta record EventList
|
||||
/// </summary>
|
||||
/// <param name="newRec"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> EvListInsert(EventListModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = dbCtx
|
||||
.DbSetEvList
|
||||
.Add(newRec);
|
||||
await dbCtx.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante EvListInsert{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
await Task.Delay(1);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <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 async Task<inputComandoMapo> scriviRigaEventoBarcode(string idxMacchina, int idxTipo, string codArticolo, string value, int matrOpr, string pallet)
|
||||
{
|
||||
bool inserito = false;
|
||||
DateTime adesso = DateTime.Now;
|
||||
EventListModel newRec = new EventListModel()
|
||||
{
|
||||
IdxMacchina = idxMacchina,
|
||||
InizioStato = adesso,
|
||||
IdxTipo = idxTipo,
|
||||
CodArticolo = codArticolo,
|
||||
Value = value,
|
||||
MatrOpr = matrOpr,
|
||||
pallet = pallet
|
||||
};
|
||||
try
|
||||
{
|
||||
// inserisco evento
|
||||
inserito = await EvListInsert(newRec);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
string logMsg = $"Eccezione in fase di scrittura evento con i seguenti dati | macchina: {idxMacchina} | IdxTipo: {idxTipo} | CodArticolo: {codArticolo} | Value {value} | MatrOpr {matrOpr} | Pallet {pallet}{Environment.NewLine}{exc}";
|
||||
Log.Error(logMsg);
|
||||
}
|
||||
try
|
||||
{
|
||||
// faccio controllo per eventuale cambio stato da tab transizioni...
|
||||
checkCambiaStatoBatch(tipoInputEvento.barcode, idxMacchina, adesso, idxTipo, codArticolo, value, matrOpr, pallet);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
string logMsg = $"Eccezione in checkCambiaStatoBatch(6) | tipoInputEvento: {tipoInputEvento.barcode} | macchina: {idxMacchina} | dataOra: {adesso} | IdxTipo: {idxTipo} | CodArticolo: {codArticolo} | Value {value} | MatrOpr {matrOpr} | Pallet {pallet}{Environment.NewLine}{exc}";
|
||||
Log.Error(logMsg);
|
||||
}
|
||||
// formatto output
|
||||
inputComandoMapo answ = new inputComandoMapo();
|
||||
answ.outValue = inserito.ToString();
|
||||
answ.needStatusRefresh = true;
|
||||
return answ;
|
||||
}
|
||||
/// <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)
|
||||
{
|
||||
#if false
|
||||
DS_applicazione.TransizioneStatiDataTable tabTransStati;
|
||||
DS_applicazione.TransizioneStatiRow rigaTransStati;
|
||||
switch (tipoInput)
|
||||
{
|
||||
case tipoInputEvento.barcode:
|
||||
// effettuo cambio stato INDIPENDENTEMENTE da stato precedente
|
||||
try
|
||||
{
|
||||
tabTransStati = MapoDbObj.taTranSt.GetUserForcedTransitions(IdxMacchina, IdxTipo);
|
||||
if (tabTransStati != null)
|
||||
{
|
||||
if (tabTransStati.Count > 0)
|
||||
{
|
||||
rigaTransStati = tabTransStati[0];
|
||||
// solo se cambia stato...
|
||||
if (rigaTransStati.IdxStato != rigaTransStati.next_IdxStato)
|
||||
{
|
||||
MapoDbObj.taDiario.InsStatoBatch(IdxMacchina, InizioStato, rigaTransStati.next_IdxStato, CodArt, Value, MatrOpr, pallet);
|
||||
// aggiorno MSE
|
||||
taMSE.forceRecalc(0, IdxMacchina);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_logLevel > 6)
|
||||
{
|
||||
Log.Info($"Non trovata riga per: BARCODE | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}", tipoLog.INFO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
// non dovrebbe succedere... input utente da barcode dovrebbero TUTTI essere
|
||||
// inseriti in tab transizione con famiglia 1...
|
||||
Log.Info($"Errore controllo transizione stato x evento barcode: BARCODE | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
||||
}
|
||||
break;
|
||||
|
||||
case tipoInputEvento.hw:
|
||||
// verifico se ci sia necessità di cambio stato
|
||||
try
|
||||
{
|
||||
tabTransStati = MapoDbObj.taTranSt.GetHwTransitions(IdxMacchina, IdxTipo);
|
||||
if (tabTransStati != null)
|
||||
{
|
||||
if (tabTransStati.Count > 0)
|
||||
{
|
||||
rigaTransStati = tabTransStati[0];
|
||||
if (rigaTransStati != null)
|
||||
{
|
||||
// solo se cambia stato...
|
||||
if (rigaTransStati.IdxStato != rigaTransStati.next_IdxStato)
|
||||
{
|
||||
MapoDbObj.taDiario.InsStatoBatch(IdxMacchina, InizioStato, rigaTransStati.next_IdxStato, CodArt, Value, MatrOpr, pallet);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_logLevel > 6)
|
||||
{
|
||||
Log.Info($"Non trovata riga per: HW | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}", tipoLog.INFO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
// non trovo riga [0]... NON scrivo!
|
||||
Log.Info($"Errore controllo transizione stato x evento barcode: HW | IdxMacchina: {IdxMacchina} | IdxTipo: {IdxTipo} | CodArt: {CodArt} | Value: {Value} | MatrOpr: {MatrOpr} | pallet: {pallet}{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua reset microstato macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
public void resetMicrostatoMacchina(string idxMacchina)
|
||||
{
|
||||
// salvo microstato 0...
|
||||
MicroStatoMacchinaModel newRecMS = new MicroStatoMacchinaModel()
|
||||
{
|
||||
IdxMacchina = idxMacchina,
|
||||
InizioStato = DateTime.Now,
|
||||
IdxMicroStato = 0,
|
||||
Value = "FER"
|
||||
};
|
||||
var result = dbTabController.MicroStatoMacchinaUpsert(newRecMS);
|
||||
// reset in redis
|
||||
resetDatiMacchina(idxMacchina);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resetta (rileggendo) i dati della macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> resetDatiMacchina(string idxMacchina)
|
||||
{
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
#if false
|
||||
string currHash = dtMaccHash(idxMacchina);
|
||||
// inizio con un bel reset...
|
||||
memLayer.ML.redFlushKey(currHash);
|
||||
DS_applicazione.MSFDDataTable tabMSFD = new DS_applicazione.MSFDDataTable();
|
||||
// 2018.01.08 SEMPRE senza singleton: instanzio un nuovo oggetto MapoDb
|
||||
MapoDb connDb = new MapoDb();
|
||||
tabMSFD = connDb.taMSFD.getByIdxMacc(idxMacchina);
|
||||
bool trovato = false;
|
||||
// se ho righe...
|
||||
DS_applicazione.MSFDDataTable tab = new DS_applicazione.MSFDDataTable();
|
||||
DS_applicazione.MSFDRow rigaMSFD;
|
||||
if (tabMSFD.Rows.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
rigaMSFD = tabMSFD[0];
|
||||
trovato = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
rigaMSFD = tab.NewMSFDRow();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rigaMSFD = tab.NewMSFDRow();
|
||||
}
|
||||
if (trovato)
|
||||
{
|
||||
// ora provo a compilare...
|
||||
try
|
||||
{
|
||||
// salvo 1:1 i valori... STATO
|
||||
answ.Add("IdxMicroStato", rigaMSFD.IdxMicroStato.ToString());
|
||||
answ.Add("IdxStato", rigaMSFD.IdxStato.ToString());
|
||||
answ.Add("CodArticolo", rigaMSFD.CodArticolo);
|
||||
answ.Add("insEnabled", rigaMSFD.insEnabled.ToString());
|
||||
answ.Add("sLogEnabled", rigaMSFD.sLogEnabled.ToString());
|
||||
answ.Add("pallet", rigaMSFD.pallet);
|
||||
answ.Add("CodArticolo_A", rigaMSFD.CodArticolo_A);
|
||||
answ.Add("CodArticolo_B", rigaMSFD.CodArticolo_B);
|
||||
answ.Add("TempoCicloBase", rigaMSFD.TempoCicloBase.ToString());
|
||||
answ.Add("PzPalletProd", rigaMSFD.PzPalletProd.ToString());
|
||||
answ.Add("MatrOpr", rigaMSFD.MatrOpr.ToString());
|
||||
answ.Add("lastVal", rigaMSFD.lastVal);
|
||||
answ.Add("TCBase", rigaMSFD.TempoCicloBase.ToString());
|
||||
|
||||
//...e SETUP
|
||||
answ.Add("CodMacc", rigaMSFD.codmacchina);
|
||||
answ.Add("IdxFamIn", rigaMSFD.IdxFamigliaIngresso.ToString());
|
||||
answ.Add("Multi", rigaMSFD.Multi.ToString());
|
||||
answ.Add("BitFilt", rigaMSFD.BitFilt.ToString());
|
||||
answ.Add("MaxVal", rigaMSFD.MaxVal.ToString());
|
||||
answ.Add("BSR", rigaMSFD.BSR.ToString());
|
||||
answ.Add("ExplodeBit", rigaMSFD.ExplodeBit.ToString());
|
||||
answ.Add("NumBit", rigaMSFD.NumBit.ToString());
|
||||
answ.Add("IdxFamMacc", rigaMSFD.IdxFamiglia.ToString());
|
||||
answ.Add("simplePallet", rigaMSFD.simplePallet.ToString());
|
||||
answ.Add("palletChange", rigaMSFD.palletChange.ToString());
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Info(string.Format("Errore in compilazione dati MSFD:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
// cerco dati master/slave...
|
||||
string isMaster = connDb.taM2S.getByMaster(idxMacchina).Count > 0 ? "1" : "0";
|
||||
string isSlave = connDb.taM2S.getBySlave(idxMacchina).Count > 0 ? "1" : "0";
|
||||
answ.Add("Master", isMaster);
|
||||
answ.Add("Slave", isSlave);
|
||||
|
||||
// verifico il timeout che cambia a seconda che sia vero o falso insEnabled...
|
||||
int tOutShort = memLayer.ML.cdvi("TmOut.MS.S");
|
||||
int tOutLong = memLayer.ML.cdvi("TmOut.MS.L");
|
||||
int redDtMacTOut = tOutLong;
|
||||
try
|
||||
{
|
||||
redDtMacTOut = (answ["insEnabled"].ToLower() == "true") ? tOutShort : tOutLong;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Info($"Eccezione in calcolo timeout dati macchina: idxMacchina{idxMacchina} | TShort: {tOutShort} | TLong {tOutLong}{Environment.NewLine}{exc}");
|
||||
}
|
||||
// salvo in redis!
|
||||
memLayer.ML.redSaveHashDict(currHash, answ, redDtMacTOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Info("Errore in chiamata stp_MSFD_getMacc (connDb.taMSFD.getByIdxMacc(idxMacchina))");
|
||||
}
|
||||
#endif
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user