From 770e77afc8aa5657f03a2626b7739b65458ef6da Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Tue, 21 Jan 2020 10:11:58 +0100 Subject: [PATCH] Inizio update gestione css calcolati --- NKC_SDK/Enums.cs | 44 ++++++++++++++++++ NKC_SDK/Objects.cs | 21 +++++++++ NKC_WF/Controllers/getMUCssController.cs | 49 +++++++++++++++------ NKC_WF/Controllers/getMUCssRevController.cs | 45 +++++++++++++------ 4 files changed, 132 insertions(+), 27 deletions(-) diff --git a/NKC_SDK/Enums.cs b/NKC_SDK/Enums.cs index 84b5e32..fcc1408 100644 --- a/NKC_SDK/Enums.cs +++ b/NKC_SDK/Enums.cs @@ -165,6 +165,50 @@ /// Present } + /// + /// Destinazioni per ITEM post CNC WORK + /// + public enum ItemDest + { + /// + /// Destinato a BIN (painting) + /// + Bin, + /// + /// Destinato a Cart (KIT) + /// + Cart, + /// + /// Indefinito + /// + Undef + } + /// + /// Stati ammessi per ITEM + /// + public enum ItemStatus + { + /// + /// Programmato + /// + Programmed, + /// + /// Completato/Fatto/tagliato + /// + Made, + /// + /// Preso da operatore + /// + PickUp, + /// + /// Depositato su Bin/Cesta + /// + Removed, + /// + /// Indefinito + /// + Undef + } /// /// Tipi di barcode gestiti diff --git a/NKC_SDK/Objects.cs b/NKC_SDK/Objects.cs index 5e45e7f..6cb2ad3 100644 --- a/NKC_SDK/Objects.cs +++ b/NKC_SDK/Objects.cs @@ -140,6 +140,27 @@ namespace NKC_SDK /// public Dictionary OptParameters { get; set; } = null; } + /// + /// Descrizione di un ITEM in fase di scarico + /// + public class PartUnload : Part + { + /// + /// Destinazione dell'item + /// + public ItemDest NextDest { get; set; } = ItemDest.Undef; + /// + /// Stato dell'item + /// + public ItemStatus Status { get; set; } = ItemStatus.Undef; + /// + /// Elenco di Secop opzionali (es T-NUT, RoundEdge) + /// + public List SecOp { get; set; } = new List(); + } + + + /// /// Classe Sheet x Nesting /// diff --git a/NKC_WF/Controllers/getMUCssController.cs b/NKC_WF/Controllers/getMUCssController.cs index 05f36d0..6bb53c5 100644 --- a/NKC_WF/Controllers/getMUCssController.cs +++ b/NKC_WF/Controllers/getMUCssController.cs @@ -1,4 +1,5 @@ -using SteamWare; +using AppData; +using SteamWare; using System.IO; using System.Net; using System.Net.Http; @@ -10,12 +11,39 @@ namespace NKC_WF.Controllers { public class getMUCssController : ApiController { - // GET api/ + // GET api/getMUCssController public HttpResponseMessage Get() { string answ = ""; + string codPost = "01"; + answ = getCssByPost(answ, codPost); + return new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(answ, Encoding.UTF8, "text/css") + }; + } + + // GET api/getMUCssController/5 + public HttpResponseMessage Get(int id) + { + string answ = ""; + string codPost = id.ToString("00"); + answ = getCssByPost(answ, codPost); + return new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(answ, Encoding.UTF8, "text/css") + }; + } + /// + /// Calcola CSS da postsazione + /// + /// + /// + /// + private static string getCssByPost(string answ, string codPost) + { // recupero da REDIS! - string redKey = memLayer.ML.redHash("MachineUnload:01:Css"); + string redKey = $"{ComLib.machineUnloadArea(codPost)}:Css";// memLayer.ML.redHash($"MachineUnload:{codPost}:Css"); // se vuoto scrivo versione attuale... if (!memLayer.ML.redKeyPresent(redKey)) { @@ -52,21 +80,14 @@ namespace NKC_WF.Controllers //answ = answ.Replace("#BLK-CART", "#IT000002"); // salvo redis! - memLayer.ML.setRSV(redKey, answ); + int cssCacheTTL = memLayer.ML.cdvi("cssCacheTTL"); + cssCacheTTL = cssCacheTTL <= 0 ? 60: cssCacheTTL; + memLayer.ML.setRSV(redKey, answ, cssCacheTTL); } - - return new HttpResponseMessage(HttpStatusCode.OK) - { - Content = new StringContent(answ, Encoding.UTF8, "text/css") - }; + return answ; } - // GET api//5 - public string Get(int id) - { - return "value"; - } // POST api/ public void Post([FromBody]string value) diff --git a/NKC_WF/Controllers/getMUCssRevController.cs b/NKC_WF/Controllers/getMUCssRevController.cs index 4743a9f..77b9cf2 100644 --- a/NKC_WF/Controllers/getMUCssRevController.cs +++ b/NKC_WF/Controllers/getMUCssRevController.cs @@ -1,31 +1,50 @@ -using SteamWare; +using AppData; +using SteamWare; using System.Web.Http; namespace NKC_WF.Controllers { public class getMUCssRevController : ApiController { - // GET api/ + // GET api/getMUCssRev public int Get() { int answ = 0; - // recupero da REDIS! - string redKey = memLayer.ML.redHash("MachineUnload:01:CssRev"); - // se vuoto scrivo 1... - if (!memLayer.ML.redKeyPresent(redKey)) - { - memLayer.ML.setRCntI(redKey); - } - answ = memLayer.ML.getRCnt(redKey); + string codPost = "01"; + answ = getRevByPost(codPost); + return answ; + } + // GET api/getMUCssRev/5 + public int Get(int id) + { + int answ = 0; + string codPost = id.ToString("00"); + answ = getRevByPost(codPost); return answ; } - // GET api//5 - public string Get(int id) + private static int getRevByPost(string codPost) { - return "value"; + int answ; + // recupero da REDIS! + string redKey = $"{ComLib.machineUnloadArea(codPost)}:Css";// memLayer.ML.redHash($"MachineUnload:{codPost}:Css"); + string redKeyRev = $"{ComLib.machineUnloadArea(codPost)}:CssRev";// memLayer.ML.redHash($"MachineUnload:{codPost}:CssRev"); + // se vuoto scrivo 1... + if (!memLayer.ML.redKeyPresent(redKeyRev)) + { + memLayer.ML.setRCntI(redKeyRev); + } + // SE fosse scaduto CSS --> aggiorno revisione... + if (!memLayer.ML.redKeyPresent(redKey)) + { + // incremento... + memLayer.ML.setRCntI(redKeyRev); + } + answ = memLayer.ML.getRCnt(redKeyRev); + return answ; } + // POST api/ public void Post([FromBody]string value) {