diff --git a/MP-MON/Controllers/HomeController.cs b/MP-MON/Controllers/HomeController.cs index c54464a2..fe807ee0 100644 --- a/MP-MON/Controllers/HomeController.cs +++ b/MP-MON/Controllers/HomeController.cs @@ -24,12 +24,15 @@ namespace MP_MON.Controllers } catch { } - if (pageRefreshSec == "") pageRefreshSec = "60"; + if (pageRefreshSec == "") + { + pageRefreshSec = "60"; + } + ViewBag.pageRefreshMs = pageRefreshMs; Response.AddHeader("Refresh", pageRefreshSec); return View(); } - public ActionResult Blink() { // ricarico ogni minuto COMUNQUE tutto... @@ -43,7 +46,11 @@ namespace MP_MON.Controllers } catch { } - if (pageRefreshSec == "") pageRefreshSec = "60"; + if (pageRefreshSec == "") + { + pageRefreshSec = "60"; + } + ViewBag.pageRefreshMs = pageRefreshMs; Response.AddHeader("Refresh", pageRefreshSec); return View("Index"); @@ -61,7 +68,11 @@ namespace MP_MON.Controllers } catch { } - if (pageRefreshSec == "") pageRefreshSec = "60"; + if (pageRefreshSec == "") + { + pageRefreshSec = "60"; + } + ViewBag.pageRefreshMs = pageRefreshMs; Response.AddHeader("Refresh", pageRefreshSec); return View("Index"); diff --git a/MP-MON/Controllers/MSEController.cs b/MP-MON/Controllers/MSEController.cs index 4b26b056..3ad15015 100644 --- a/MP-MON/Controllers/MSEController.cs +++ b/MP-MON/Controllers/MSEController.cs @@ -1,11 +1,10 @@ using MP_MON.Models; +using Newtonsoft.Json; +using SteamWare; using System; +using System.Collections.Generic; using System.Linq; using System.Web.Mvc; -using SteamWare; -using System.Data; -using Newtonsoft.Json; -using System.Collections.Generic; namespace MP_MON.Controllers { @@ -15,8 +14,23 @@ namespace MP_MON.Controllers // GET: StatusMap public ActionResult StatusMap(string baseCss) + { + return SingleStatus(baseCss, ""); + } + + // GET: StatusMap + public ActionResult SingleStatus(string baseCss, string IdxMacchina) { int dataRefresh = 2000; + // salvo idxMacc in sessione se c'è... + if (IdxMacchina != "" && IdxMacchina != null) + { + memLayer.ML.setSessionVal("IdxMacchina", IdxMacchina); + } + else + { + IdxMacchina = memLayer.ML.StringSessionObj("IdxMacchina"); + } try { dataRefresh = Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["dataRefreshMs"]); @@ -26,14 +40,14 @@ namespace MP_MON.Controllers // cerco su REDIS... string hMSE = MapoDb.DataLayer.hMSE(); string dataSer = memLayer.ML.getRSV(hMSE); - List dati= new List(); + List dati = new List(); if (dataSer != "" && dataSer != null) { try { dati = JsonConvert.DeserializeObject>(dataSer); } - catch(Exception exc) + catch (Exception exc) { dati = db.stp_MSE_getData(dataRefresh).ToList(); logger.lg.scriviLog(string.Format("Recuperata MSE da DB{0}{1}", Environment.NewLine, exc)); @@ -47,9 +61,12 @@ namespace MP_MON.Controllers dataSer = JsonConvert.SerializeObject(dati); // metto in redis memLayer.ML.setRSV(hMSE, dataSer, memLayer.ML.CRI("MSE_cacheDuration")); - } + } + // filtro dati SOLO PER la macchina che mi interessa... + dati = dati.Where(e => e.IdxMacchina == IdxMacchina).ToList(); ViewBag.baseCss = baseCss; - return PartialView("_StatusMap", dati); + ViewBag.IdxMacchina = IdxMacchina; + return PartialView("_StatusMapSingle", dati); } diff --git a/MP-MON/Controllers/MachineController.cs b/MP-MON/Controllers/MachineController.cs new file mode 100644 index 00000000..f424c4d4 --- /dev/null +++ b/MP-MON/Controllers/MachineController.cs @@ -0,0 +1,116 @@ +using MP_MON.Models; +using System.Web.Configuration; +using System.Web.Mvc; + +namespace MP_MON.Controllers +{ + public class MachineController : Controller + { + private MoonProEntities db = new MoonProEntities(); + /// + /// Restituisce una view per SINGOLA macchina + /// + /// + /// + public ActionResult Index(string id) + { + // ricarico ogni minuto COMUNQUE tutto... + string pageRefreshSec = "60"; + // refresh std ogni sec + int pageRefreshMs = 1000; + ViewBag.cssSemBase = "sem"; + try + { + pageRefreshSec = WebConfigurationManager.AppSettings["pageRefreshSec"]; + } + catch + { } + if (pageRefreshSec == "") + { + pageRefreshSec = "60"; + } + + ViewBag.pageRefreshMs = pageRefreshMs; + Response.AddHeader("Refresh", pageRefreshSec); + return View(); + } + /// + /// Restituisce una view per SINGOLA macchina + /// + /// + /// + public ActionResult Status(string id) + { + // ricarico ogni minuto COMUNQUE tutto... + string pageRefreshSec = "60"; + // refresh std ogni sec + int pageRefreshMs = 1000; + ViewBag.cssSemBase = "sem"; + ViewBag.IdxMacchina = id; + try + { + pageRefreshSec = WebConfigurationManager.AppSettings["pageRefreshSec"]; + } + catch + { } + if (pageRefreshSec == "") + { + pageRefreshSec = "60"; + } + + ViewBag.pageRefreshMs = pageRefreshMs; + Response.AddHeader("Refresh", pageRefreshSec); + return View(); + } +#if false + public ActionResult Blink() + { + // ricarico ogni minuto COMUNQUE tutto... + string pageRefreshSec = "60"; + // se ho animazione refresh è ogni 2 sec... + int pageRefreshMs = 2000; + ViewBag.cssSemBase = "semBlink"; + try + { + pageRefreshSec = WebConfigurationManager.AppSettings["pageRefreshSec"]; + } + catch + { } + if (pageRefreshSec == "") + { + pageRefreshSec = "60"; + } + + ViewBag.pageRefreshMs = pageRefreshMs; + Response.AddHeader("Refresh", pageRefreshSec); + return View("Index"); + } + public ActionResult Fix() + { + // ricarico ogni minuto COMUNQUE tutto... + string pageRefreshSec = "60"; + // refresh std ogni sec + int pageRefreshMs = 1000; + ViewBag.cssSemBase = "semFix"; + try + { + pageRefreshSec = WebConfigurationManager.AppSettings["pageRefreshSec"]; + } + catch + { } + if (pageRefreshSec == "") + { + pageRefreshSec = "60"; + } + + ViewBag.pageRefreshMs = pageRefreshMs; + Response.AddHeader("Refresh", pageRefreshSec); + return View("Index"); + } +#endif + public ActionResult GetClock() + { + return PartialView("_mmClock"); + } + } +} \ No newline at end of file diff --git a/MP-MON/MP-MON.csproj b/MP-MON/MP-MON.csproj index da3ae750..6e2c5b61 100644 --- a/MP-MON/MP-MON.csproj +++ b/MP-MON/MP-MON.csproj @@ -140,6 +140,7 @@ + @@ -385,6 +386,9 @@ + + + Web.config diff --git a/MP-MON/Views/MSE/_StatusMapSingle.cshtml b/MP-MON/Views/MSE/_StatusMapSingle.cshtml new file mode 100644 index 00000000..44054fc5 --- /dev/null +++ b/MP-MON/Views/MSE/_StatusMapSingle.cshtml @@ -0,0 +1,86 @@ +@model IEnumerable + + +
+ + @foreach (var item in Model) + { + // fix codice semaforo: sVe -> Ve, sRo ->Ro... + string codSemaf = item.Semaforo; + if (codSemaf.Length == 3) + { + codSemaf = codSemaf.Substring(1, 2); + } + string cssStatus = ViewBag.baseCss + codSemaf; + // calcolo durata... + TimeSpan TCAss = TimeSpan.FromMinutes((double)item.TCAssegnato); + TimeSpan TCLav = TimeSpan.FromMinutes((double)item.TCLavRT); + // converto a stringa! + string TCAssegnato = TCAss.ToString(@"mm\:ss"); + string TCLavorato = TCLav.ToString(@"mm\:ss"); + + // verifico SE è disabilitata modalità animazione -> blink a stati (e refresh 1s) + if (System.Web.Configuration.WebConfigurationManager.AppSettings["doAnimate"] == "1") + { + // blink se secondo pari... + DateTime adesso = DateTime.Now; + int resto = 0; + Math.DivRem(adesso.Second, 2, out resto); + if (resto == 0) + { + cssStatus += "_b"; + } + } + // verifico se mostrare sarticolo o disegno... + string sArticolo = ""; + if (System.Web.Configuration.WebConfigurationManager.AppSettings["sART"] == "CodArticolo") + { + sArticolo = item.CodArticolo; + } + else + { + sArticolo = item.Disegno; + } + // se fosse vuoto mostro cmq codArt tra parentesi... + if (sArticolo == "") + { + sArticolo = string.Format("[{0}]", item.CodArticolo); + } + // se NON trova update da oltre 1 minuto rosso lo status comunicazione + string cssComStatus = cssStatus; + if (DateTime.Now.Subtract((DateTime)item.lastUpdate).TotalMinutes>1) + { + cssComStatus = ViewBag.baseCss + "Ro"; + } +
+
+ @*noCpu*@ +
+
+
@Html.DisplayFor(modelItem => item.Nome)
+
+
+
+
Art.
+
@sArticolo
+
@Html.DisplayFor(modelItem => item.DescrizioneStato)
+
@item.durata'
+ @*
OEE
+
xx%
*@ +
T.Ciclo
+
std: @TCAssegnato
+
act: @TCLavorato
+
Pezzi(prod/ord)
+
@Html.DisplayFor(modelItem => item.PezziProd) / @Html.DisplayFor(modelItem => item.NumPezzi)
+
+
+
+
+
+ +
+
+
+
+ } +
diff --git a/MP-MON/Views/Machine/Index.cshtml b/MP-MON/Views/Machine/Index.cshtml new file mode 100644 index 00000000..5dc24334 --- /dev/null +++ b/MP-MON/Views/Machine/Index.cshtml @@ -0,0 +1,18 @@ +@model IEnumerable +@{ + ViewBag.Title = "Index"; +} + +
+ @Html.Action("StatusMap", "MSE", new { baseCss = ViewBag.cssSemBase }) +
+ + diff --git a/MP-MON/Views/Machine/Status.cshtml b/MP-MON/Views/Machine/Status.cshtml new file mode 100644 index 00000000..967476ca --- /dev/null +++ b/MP-MON/Views/Machine/Status.cshtml @@ -0,0 +1,18 @@ +@model IEnumerable +@{ + ViewBag.Title = "Index"; +} + +
+ @Html.Action("SingleStatus", "MSE", new { baseCss = ViewBag.cssSemBase, IdxMacchina = ViewBag.IdxMacchina }) +
+ +