194 lines
5.7 KiB
C#
194 lines
5.7 KiB
C#
using AppData;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace NKC_WF.WebUserControls
|
|
{
|
|
public partial class cmp_MachSem : BaseUserControl
|
|
{
|
|
#region Public Properties
|
|
|
|
public string currMachine
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
answ = memLayer.ML.QSS("mach");
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
if (!string.IsNullOrEmpty(value))
|
|
{
|
|
string url = $"{currPage}?mach={value}";
|
|
Response.Redirect(url);
|
|
}
|
|
}
|
|
}
|
|
|
|
public string currPage
|
|
{
|
|
get
|
|
{
|
|
string url = HttpContext.Current.Request.Url.PathAndQuery;
|
|
if (url.Contains("?mach="))
|
|
{
|
|
url = url.Substring(0, url.IndexOf("?mach="));
|
|
}
|
|
return url;
|
|
}
|
|
}
|
|
|
|
public bool machSelected
|
|
{
|
|
get
|
|
{
|
|
return (!string.IsNullOrEmpty(currMachine));
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void checkVisibility()
|
|
{
|
|
divSelect.Visible = !machSelected;
|
|
divRuntime.Visible = machSelected;
|
|
hfMachClass.Value = currMachine == "NE01" ? "dark" : "light";
|
|
lbtReset.Attributes.Remove("class");
|
|
lbtReset.Attributes.Add("class", $"btn btn-block text-center btn-{hfMachClass.Value}");
|
|
}
|
|
|
|
private DS_App.StatusDecodeRow getState(List<NKC_SDK.MachineStatData> currState, string name)
|
|
{
|
|
// recupero dati
|
|
DS_App.StatusDecodeRow thisState = null;
|
|
var currInfo = currState.Where(x => x.Machine == currMachine).FirstOrDefault();
|
|
var lastState = currInfo.Records.Where(x => x.Station == name).OrderByDescending(x => x.DtRecord).FirstOrDefault();
|
|
if (lastState == null)
|
|
{
|
|
// aggiungo ND
|
|
}
|
|
else
|
|
{
|
|
// verifico la decodifica x ognuno
|
|
thisState = ComLib.checkStationDecode(name, lastState.Code);
|
|
}
|
|
|
|
return thisState;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
protected void ddlMachine_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
currMachine = ddlMachine.SelectedValue;
|
|
}
|
|
|
|
protected void lbtReset_Click(object sender, EventArgs e)
|
|
{
|
|
Response.Redirect(currPage);
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
hfMachine.Value = currMachine;
|
|
checkVisibility();
|
|
lbtReset.DataBind();
|
|
}
|
|
|
|
protected void timerLoad_Tick(object sender, EventArgs e)
|
|
{
|
|
doUpdate();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
public void doUpdate()
|
|
{
|
|
// verifico status delle 3 parti e mostro relativo semaforo...
|
|
hfCode01.Value = "00";
|
|
hfCss01.Value = "dark";
|
|
hfStat01.Value = "UNKNOWN";
|
|
hfCode02.Value = "00";
|
|
hfCss02.Value = "dark";
|
|
hfStat02.Value = "UNKNOWN";
|
|
hfCode03.Value = "00";
|
|
hfCss03.Value = "dark";
|
|
hfStat03.Value = "UNKNOWN";
|
|
|
|
// leggo da redis lo status
|
|
var currState = ComLib.prodMachStateDataGet();
|
|
|
|
// traduco!
|
|
DS_App.StatusDecodeRow state01 = getState(currState, "PRINTER");
|
|
if (state01 != null)
|
|
{
|
|
hfCode01.Value = state01.Code;
|
|
hfCss01.Value = state01.Css;
|
|
hfStat01.Value = state01.Descript;
|
|
}
|
|
|
|
DS_App.StatusDecodeRow state02 = getState(currState, "NC_MACHINE");
|
|
if (state02 != null)
|
|
{
|
|
hfCode02.Value = state02.Code;
|
|
hfCss02.Value = state02.Css;
|
|
hfStat02.Value = state02.Descript;
|
|
}
|
|
|
|
DS_App.StatusDecodeRow state03 = getState(currState, "UNLOADER");
|
|
if (state03 != null)
|
|
{
|
|
hfCode03.Value = state03.Code;
|
|
hfCss03.Value = state03.Css;
|
|
hfStat03.Value = state03.Descript;
|
|
}
|
|
|
|
// imposto nuovi eventi FAKE...
|
|
|
|
//// FIXME TODO: fake....
|
|
//DateTime adesso = DateTime.Now;
|
|
//int numsec = adesso.Second;
|
|
//hfCss01.Value = "success";
|
|
//hfCss02.Value = "warning";
|
|
//hfCss03.Value = "danger";
|
|
//hfStat01.Value = $"{adesso.Second - 1 % 10:00}";
|
|
//hfStat02.Value = $"{adesso.Second + 3 % 10:00}";
|
|
//hfStat03.Value = $"{adesso.Second + 1 % 10:00}";
|
|
//switch (numsec % 3)
|
|
//{
|
|
// case 1:
|
|
// hfCss01.Value = "warning";
|
|
// hfCss02.Value = "danger";
|
|
// hfCss03.Value = "success";
|
|
// break;
|
|
|
|
// case 2:
|
|
// hfCss01.Value = "danger";
|
|
// hfCss02.Value = "success";
|
|
// hfCss03.Value = "warning";
|
|
// break;
|
|
|
|
// case 0:
|
|
// default:
|
|
// hfCss01.Value = "success";
|
|
// hfCss02.Value = "warning";
|
|
// hfCss03.Value = "danger";
|
|
// break;
|
|
//}
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |