using Newtonsoft.Json; using Newtonsoft.Json.Converters; using System; using System.Collections.Generic; using System.Linq; namespace NKC_SDK { /// /// Classe che rappresenta stato ordine ricevuto via REDIS da NESTING /// public class baseNestAnsw { #region Public Properties /// /// ID univoco invio del TASK /// public string EnvNum { get; set; } = ""; /// /// Elenco errori riscontrati /// public List ErrorList { get; set; } = null; /// /// Tempo STIMATO di taglio calcolato dal Nesting espresso in Secondi /// public double EstimatedWorktime { get; set; } = 0; /// /// Codice della amcchina x cui si effettua richiesta /// [JsonConverter(typeof(StringEnumConverter))] public mType MachineType { get; set; } = mType.Multiax; /// /// Tipo di ordine richiesto /// //[JsonConverter(typeof(StringEnumConverter))] public oType OrderType { get; set; } = oType.BatchRequest; /// /// Tempo di processing del Nesting espresso in Secondi /// public double ProcessingRuntime { get; set; } = 0; /// /// Note libere del nesting /// public string ProcessNotes { get; set; } = ""; /// /// Status del processo di nesting /// public procStatus ProcessStatus { get; set; } = procStatus.waiting; /// /// Tipo di processing richiesto /// 1 = stima /// 2 = nesting /// 3 = stima estesa: elenco ordini con tempo x ogni ordine (ORD.RIGA) + numero part + List... /// public int ProcType { get; set; } = 0; #endregion Public Properties } /// /// Classe che rappresenta la richiesta di processing di NESTING da inserire in REDIS /// public class batchRequest { #region Public Properties /// /// ID del processo richiesto (generato in fase di import) /// public int BatchId { get; set; } /// /// ID univoco dell'invio del TASK /// public string EnvNum { get; set; } = ""; /// /// Codice della macchina x cui si effettua richeista /// [JsonConverter(typeof(StringEnumConverter))] public mType MachineType { get; set; } /// /// tempo massimo permesso x nesting (secondi) /// public int MaxTime { get; set; } /// /// Elenco ordini richiesti da processare / nestare /// public List OrderList { get; set; } /// /// Tipo di ordine richiesto /// // riportato a numero //[JsonConverter(typeof(StringEnumConverter))] public oType OrderType { get; set; } /// /// Tipo di processing richiesto /// 1 = stima /// 2 = nesting /// 3 = stima extended /// public int ProcType { get; set; } /// /// Indice di aprtenza (per carrelli, bins...) /// public int NumIndexStart { get; set; } = 1; #endregion Public Properties } /// /// Classe che rappresenta la richiesta di AZIONI al NESTING /// public class commandRequest { #region Public Properties /// /// Richiesta per il nesting: DoNesting / HaltNesting /// public string ActionRequested { get; set; } /// /// ID del processo richiesto (generato in fase di import) /// public int BatchID { get; set; } #endregion Public Properties } /// /// Valori decodificati /// public class decodedData { #region Public Properties /// /// Codice decodificato /// public string code { get; set; } = ""; /// /// Codice decodificato in formato INT /// public int codeInt { get; set; } = 0; /// /// Tipo codice decodificato /// public codeType codeType { get; set; } = codeType.UNK; /// /// Descrizione associata /// public string description { get; set; } = ""; /// /// Dato letto RAW /// public string rawData { get; set; } = ""; #endregion Public Properties } /// /// Oggetto errore da poter rispondere con chiamate x stima/nesting /// public class ErrorRep { #region Public Properties /// /// Descrizione estesa (human readable) dell'errore /// public string Description { get; set; } = ""; /// /// DataOra registrazione record /// public DateTime DtRif { get; set; } = DateTime.Now; /// /// Tipo di errore /// public string ErrType { get; set; } = "NA"; /// /// Chiave di riferimento PARENT per l'errore (es il codice del batch, dell'item) /// es: BatchId.OrderId.Row /// public string ParentUid { get; set; } = "A.B.C"; /// /// Chiave univoca per l'errore /// es: BatchId.OrderId.Row.PartId... /// public string Uid { get; set; } = "A.B.C.D"; #endregion Public Properties } /// /// Oggetto KIT /// public class Kit { #region Public Properties /// /// Codice KIT da cod ordine ext /// public string KitExtCode { get; set; } = ""; /// /// ID KIT (da DB) /// public int KitId { get; set; } = 0; /// /// Elenco Items da produrre x KIT /// public List PartList { get; set; } #endregion Public Properties } public class MachineStatData { #region Public Properties /// /// Codice macchina /// public string Machine { get; set; } = "WRK000"; /// /// record registrati dalla macchina /// public List Records { get; set; } = new List(); #endregion Public Properties } public class MachineStatRecord { #region Public Properties /// /// Codice evento/stato /// 00 = KeepAlive --> imposto dataora/drift /// public string Code { get; set; } = ""; /// /// DataOra dell'informazione (clock mittente) /// public DateTime DtRecord { get; set; } = DateTime.Now; /// /// Valore / carico associato all'invio (opzionale) /// public string Payload { get; set; } = ""; /// /// Codice postazione /// public string Station { get; set; } = ""; #endregion Public Properties } /// /// Definizione classe x materiali /// public class Material { #region Public Properties public DateTime ApprovDate { get; set; } = DateTime.Now; public string ApprovUser { get; set; } = ""; public decimal L_mm { get; set; } = 0; public string MatDesc { get; set; } = ""; public string MatDtmx { get; set; } = ""; public int MatExtCode { get; set; } = 0; public int MatId { get; set; } = 0; public decimal T_mm { get; set; } = 0; public decimal W_mm { get; set; } = 0; #endregion Public Properties } /// /// dati del materiale /// public class MaterialData { #region Public Properties /// /// Codice P/N del materiale (cliente) /// public string MaterialDescription { get; set; } /// /// Identificativo univoco del materiale (DA ANAGRAFICA db) /// public int MaterialId { get; set; } /// /// Codice P/N del materiale (cliente) /// public string MaterialPN { get; set; } #endregion Public Properties } /// /// Dati di un Cart post nesting /// public class NestBin { #region Public Properties /// /// Indice del BIN nel TAKT / giorno /// public int BinIndex { get; set; } = 0; /// /// Elenco dei PART/ITEM dell'Ordine /// public List PartList { get; set; } #endregion Public Properties } /// /// Struttura stack /// public class NestBunk { #region Public Properties /// /// Identificativo univoco stack /// public String BunkId { get; set; } = ""; /// /// Indice del Bunk /// public int BunkIndex { get; set; } = 0; /// /// Num di fogli nello stack /// public int NumSheet { get { int answ = 0; if (SheetList != null) { answ = SheetList.Count; } return answ; } } /// /// Elenco Sheet previsti /// public List SheetList { get; set; } #endregion Public Properties } /// /// Dati di un Cart post nesting /// public class NestCart { #region Public Properties /// /// Indice del CART nel TAKC / giorno /// public int CartIndex { get; set; } = 0; /// /// Elenco dei KIT dell'ordine /// public List KitList { get; set; } /// /// Tempo previsto per produrre il Cart /// public double ProcTime { get; set; } = 0; #endregion Public Properties } /// /// Dati di un foglio di Remnant /// public class NestRemn { #region Public Properties /// /// Dimensione L del remnant /// public decimal L_mm { get; set; } = 0; /// /// Dimensione W del remnant /// public decimal W_mm { get; set; } = 0; #endregion Public Properties } /// /// Risposta NESTING x la STIMA iniziale ESTESA (chiede dati a livello di ORDERS aggregati) /// public class nestReplyBatchExtEst : nestReplyBatchInitial { #region Public Properties /// /// Elenco ordini con dati processing /// public List EstOrderList { get; set; } #endregion Public Properties } /// /// Risposta NESTING x la STIMA iniziale /// public class nestReplyBatchFinal : orderStatus { #region Public Properties /// /// Elenco Bin /// public List BinList { get; set; } = new List(); /// /// Elenco Stack previsti /// public List BunkList { get; set; } = new List(); /// /// Elenco Carts /// public List CartList { get; set; } = new List(); #endregion Public Properties } /// /// Risposta NESTING x la STIMA iniziale /// public class nestReplyBatchInitial : orderStatus { #region Public Properties /// /// Elenco Items da produrre x ordine /// public List PartList { get; set; } #endregion Public Properties } public class nestReplyOffOrd : orderStatus { #region Public Properties /// /// Path x folder dei vari CNC dell'offline order /// public string CncPath { get; set; } = ""; /// /// Path x folder dei vari SVG offline order da mostrare /// public string DrawingPath { get; set; } = ""; #endregion Public Properties } /// /// Classe Sheet x Nesting /// public class NestSheet { #region Public Properties /// /// SVG del lavoro previsto /// public string Drawing { get; set; } = ""; /// /// Tempo STIMATO di taglio calcolato dal Nesting espresso in Secondi /// public double EstimatedWorktime { get; set; } = 0; /// /// Programma x Machining /// public string MachiningProgram { get; set; } = ""; /// /// Materiale /// public int MatId { get; set; } /// /// Elenco Part da produrre x ordine /// public List PartList { get; set; } = null; /// /// Programma x printing /// public string PrintProgram { get; set; } = ""; /// /// Eventuale remnant /// public NestRemn Remnant { get; set; } /// /// Identificativo univoco Sheet /// public String SheetId { get; set; } = ""; /// /// Indice dello sheet /// public int SheetIndex { get; set; } = 0; /// /// Resa (OEE) dell'impiego del materiale /// public double SurfaceOEE { get { double answ = 0; try { answ = SurfaceWork / SurfaceTotal; } catch { } return answ; } } /// /// Superficie totale del foglio lavorato (= materiale) /// public double SurfaceTotal { get; set; } = 1; /// /// Superficie WORK (lavorata/tagliata) del foglio lavorato (= somma area dei pezzi disposti) /// public double SurfaceWork { get; set; } = 0; #endregion Public Properties } /// /// Struttura Ordine passata a NESTING /// public class Order { #region Public Properties /// /// Plant di destinazione /// public string DestPlant { get; set; } /// /// Elenco dei KIT dell'ordine /// public List KitList { get; set; } /// /// Cod ordine di NKC /// public string OrderCod { get; set; } /// /// Codice ordine esterno da cliente (HFA) /// public string OrderExtCode { get; set; } /// /// ID Ordine (da DB) /// public int OrderId { get; set; } = 0; #endregion Public Properties } /// /// Informazioni ordine tornate da Nesting (previsione) /// public class OrderPrev : Order { #region Public Properties /// /// Num totale BIN predisposti /// public int NumBin { get; set; } = 0; /// /// Num totale CART predisposti /// public int NumCart { get; set; } = 0; /// /// Num part previste per ordine /// public int NumPart { get; set; } = 0; /// /// Tempo totale in % /// public double Quota { get; set; } = 0; /// /// Tempo totale in minuti /// public double TotTime { get; set; } = 0; #endregion Public Properties } /// /// Classe simulazione di un assegnazione di un set di ordini (compreso score) /// public class OrderSetSim { #region Public Properties /// /// Valore attuale (somma dei punteggi degli elementi) /// public double ActualValue { get { return OrderSet.Sum(x => x.Value); } } /// /// Valore score (scostamento target/actual) /// public double IndexScore { get { return Math.Abs(TargetValue - ActualValue); } } /// /// Vettore Ordini + durate /// public Dictionary OrderSet { get; set; } = new Dictionary(); /// /// Valore target durate desiderate /// public double TargetValue { get; set; } = 0; #endregion Public Properties } /// /// Classe che rappresenta stato ordine ricevuto via REDIS da NESTING /// public class orderStatus : baseNestAnsw { #region Public Properties /// /// ID del processo di Nesting in corso (generato in fase di import) /// public int BatchID { get; set; } #endregion Public Properties } /// /// Struttura Item passata a NESTING /// public class Part { #region Public Properties /// /// Path del disegno CAD dell'item da produrre x NESTING /// public string CadFilePath { get; set; } /// /// ID del materiale dell'item /// public int MatId { get; set; } /// /// Parametri opzionali (es x risposta NESTING) /// public Dictionary OptParameters { get; set; } = null; /// /// Codice Datamatrix dell'ITEM /// public string PartDtmx { get; set; } = ""; /// /// Codice ITEM esterno da cliente (HFA) /// public string PartExtCode { get; set; } = ""; /// /// Revisione ITEM esterno da cliente (HFA) /// public string PartRev { get; set; } = ""; /// /// Cod ITEM di NKC /// public int PartId { get; set; } = 0; /// /// Quantità di Item per SINGOLO ordine /// public int PartQty { get; set; } #endregion Public Properties } /// /// Descrizione di un ITEM in fase di scarico /// public class PartUnload : Part { #region Public Properties /// /// Destinazione dell'item /// public ItemDest NextDest { get; set; } = ItemDest.Undef; /// /// Elenco di Secop opzionali (es T-NUT, RoundEdge) /// public List SecOp { get; set; } = new List(); /// /// Stato dell'item /// public ItemStatus Status { get; set; } = ItemStatus.Undef; #endregion Public Properties } /// /// Classe che rappresenta i BUNK da lavorare /// public class ProdBunk { #region Public Properties /// /// Identificativo univoco BUNK / Stack /// public int BunkId { get; set; } /// /// Codice dataMatrix del BUNK /// public string DataMatrix { get; set; } /// /// Data inizio processing dello Stack /// public DateTime DtEnd { get; set; } /// /// Data inizio processing del BUNK /// public DateTime DtStart { get; set; } /// /// Numero di Sheets da lavorare /// public int NumSheets { get { int answ = 0; try { answ = SheetList.Count; } catch { } return answ; } } /// /// Elenco dei pannelli(sheets) dello Stack /// public List SheetList { get; set; } /// /// Stato dello Stack di pannelli /// public CStatus Status { get; set; } #endregion Public Properties } /// /// Singolo Pannello IN LAVORAZIONE /// public class ProdSheet { #region Public Properties /// /// Tempi processo x fase CNC /// public WorkData Machining { get; set; } /// /// Materiale /// public MaterialData Material { get; set; } /// /// Tempi processo x fase printing /// public WorkData Printing { get; set; } /// /// Identificativo univoco pannello /// public int SheetId { get; set; } /// /// Stato del pannello /// public PStatus Status { get; set; } /// /// Tempi processo x scarico /// public WorkData Unloading { get; set; } #endregion Public Properties } /// /// Estensione classe sheet comprensiva di BunkId /// public class ProdSheetExt : ProdSheet { #region Public Properties /// /// Identificativo univoco BUNK / Stack /// public int BunkId { get; set; } /// /// INDICE del pannello (valido per BUNK) /// public int SheetIndex { get; set; } #endregion Public Properties } /// /// Classe che rappresenta un insieme di Sheet da lavorare (contenuti in 1 o + bunk) /// public class SheetWorkList { #region Public Properties /// /// Codice impianto/macchina /// public string Machine { get; set; } = "WRK000"; /// /// Numero di Sheets da lavorare /// public int NumSheets { get { int answ = 0; try { answ = SheetList.Count; } catch { } return answ; } } /// /// Elenco dei pannelli (sheets) in lavorazione /// public List SheetList { get; set; } #endregion Public Properties } /// /// Dati della lavorazione /// public class WorkData { #region Public Properties /// /// Data fine processing /// public DateTime? DtEnd { get; set; } /// /// Data inizio processing /// public DateTime? DtStart { get; set; } /// /// Percorso del programma da eseguire /// public string ProgramPath { get; set; } /// /// Indica che la lavorazione è stata eseguita con successo (default = true) /// public bool Success { get; set; } /// /// Tempo di lavorazione in minuti decimali /// public double WorkTimeMin { get { double answ = 0; if (DtStart != null && DtEnd != null) { try { answ = ((DateTime)DtEnd).Subtract((DateTime)DtStart).TotalMinutes; } catch { } } return answ; } } #endregion Public Properties } }