210 lines
5.9 KiB
C#
210 lines
5.9 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, IDisposable
|
|
{
|
|
#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 bool machSelected
|
|
{
|
|
get
|
|
{
|
|
return (!string.IsNullOrEmpty(currMachine));
|
|
}
|
|
}
|
|
|
|
public bool showSemaphore
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
bool.TryParse(hfShowSemap.Value, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
hfShowSemap.Value = $"{value}";
|
|
upnlTitle.Visible = value;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public override void Dispose()
|
|
{
|
|
timerLoad.Tick -= timerLoad_Tick;
|
|
timerLoad.Dispose();
|
|
base.Dispose();
|
|
}
|
|
|
|
public void doUpdate()
|
|
{
|
|
lblUpdated.Text = $"upd: {DateTime.Now:HH:mm:ss}";
|
|
// verifico status delle 3 parti e mostro relativo semaforo...
|
|
hfCode01.Value = "00";
|
|
hfCss01.Value = "secondary";
|
|
hfStat01.Value = "UNKNOWN";
|
|
hfCode02.Value = "00";
|
|
hfCss02.Value = "secondary";
|
|
hfStat02.Value = "UNKNOWN";
|
|
hfCode03.Value = "00";
|
|
hfCss03.Value = "secondary";
|
|
hfStat03.Value = "UNKNOWN";
|
|
|
|
if (!string.IsNullOrEmpty(currMachine))
|
|
{
|
|
|
|
|
|
// leggo da redis lo status
|
|
var currState = ComLib.prodMachStateDataGet(currMachine);
|
|
|
|
// 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;
|
|
}
|
|
|
|
icnLiveOk.Visible = false;
|
|
icnLiveKo.Visible = false;
|
|
if (ComLib.getMachLiveStatus(currMachine))
|
|
{
|
|
icnLiveOk.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
icnLiveKo.Visible = true;
|
|
}
|
|
}
|
|
//upnlTitle.Update();
|
|
}
|
|
|
|
#endregion Public 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();
|
|
if (!Page.IsPostBack)
|
|
{
|
|
setTimer();
|
|
doUpdate();
|
|
}
|
|
}
|
|
|
|
protected void timerLoad_Tick(object sender, EventArgs e)
|
|
{
|
|
doUpdate();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Methods
|
|
|
|
private void checkVisibility()
|
|
{
|
|
divSelect.Visible = !machSelected;
|
|
divRuntime.Visible = machSelected;
|
|
hfMachClass.Value = currMachine == "NE01" ? "dark" : "primary";
|
|
lbtReset.Attributes.Remove("class");
|
|
lbtReset.Attributes.Add("class", $"btn btn-block text-center btn-{hfMachClass.Value}");
|
|
}
|
|
|
|
private DS_App.StatusDecodeRow getState(NKC_SDK.MachineStatData currState, string station)
|
|
{
|
|
// recupero dati
|
|
DS_App.StatusDecodeRow thisState = null;
|
|
try
|
|
{
|
|
if (currState != null)
|
|
{
|
|
var lastState = currState.Records.Where(x => x.Station == station).OrderByDescending(x => x.DtRecord).FirstOrDefault();
|
|
if (lastState == null)
|
|
{
|
|
// aggiungo ND
|
|
}
|
|
else
|
|
{
|
|
// verifico la decodifica x ognuno
|
|
thisState = ComLib.checkStationDecode(station, lastState.Code);
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
|
|
return thisState;
|
|
}
|
|
|
|
/// <summary>
|
|
/// imposta il tempo di scadenza del timer x il refresh del componente
|
|
/// </summary>
|
|
private void setTimer()
|
|
{
|
|
int timer = memLayer.ML.CRI("timerStatus");
|
|
timer = timer > 0 ? timer : 5000;
|
|
timerLoad.Interval = timer;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |