nodyang@aliyun.com 1 week ago
parent 6925c22d4d
commit 058ce925c6

@ -192,7 +192,9 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tool\BaseManager.cs" />
<Compile Include="Tool\HimAlarmManager.cs" />
<Compile Include="Tool\PromptAlarmManager.cs" />
<Compile Include="Tool\TestFactory.cs" />
<Compile Include="Tool\UserManager.cs" />
<EmbeddedResource Include="FormLogin.resx">

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DB.Entity;
using DB.Service;
using NewLife.Caching;
namespace RfidWeb
{
public class BaseManager
{
protected AlarmDataService alarmDataService = new AlarmDataService();
protected ICache cache = Cache.Default;
protected readonly int Max = 31;
protected readonly TimeSpan timeOut = TimeSpan.FromSeconds(5);
protected Dictionary<int, string> GetDic(List<AlarmData> list, string plcAb, string address)
{
var dicCha = list.Where(x => x.PlcAb == plcAb && x.Address == address
&& !string.IsNullOrEmpty(x.Msg))
.ToDictionary(x => x.No, x => x.Msg);
return dicCha;
}
}
}

@ -9,24 +9,11 @@ using Tool.Model;
namespace RfidWeb
{
public class HimAlarmManager
public class HimAlarmManager:BaseManager
{
private HmiChAlarm hmiChAlarm = new HmiChAlarm();
private HmiCqAlarm hmiCq = new HmiCqAlarm();
EsStop esStop=new EsStop();
AlarmDataService alarmDataService = new AlarmDataService();
private readonly int Max = 31;
private readonly TimeSpan timeOut = TimeSpan.FromSeconds(5);
private Dictionary<int, string> GetDic(List<AlarmData> list, string plcAb, string address)
{
var dicCha = list.Where(x => x.PlcAb == plcAb && x.Address == address
&& !string.IsNullOrEmpty(x.Msg))
.ToDictionary(x => x.No, x => x.Msg);
return dicCha;
}
private void SetCH_alarm(Dictionary<string, DateTime> dictionary,List<AlarmData> list)
{
@ -176,7 +163,6 @@ namespace RfidWeb
}
ICache cache = Cache.Default;
public Dictionary<string, DateTime> GetList()
{
@ -194,63 +180,4 @@ namespace RfidWeb
}
public class PromptAlarmManager
{
private Dictionary<int, string> GetDic(List<AlarmData> list, string plcAb, string address)
{
var dicCha = list.Where(x => x.PlcAb == plcAb && x.Address == address
&& !string.IsNullOrEmpty(x.Msg))
.ToDictionary(x => x.No, x => x.Msg);
return dicCha;
}
AlarmDataService alarmDataService = new AlarmDataService();
PromptAlarm cPromptAlarm=new PromptAlarm();
private readonly int Max = 31;
private readonly TimeSpan timeOut = TimeSpan.FromSeconds(5);
ICache cache = Cache.Default;
public Dictionary<string, DateTime> GetList()
{
Dictionary<string, DateTime> dictionary = cache[CacheKeyManager.Prompt_alarmList] as Dictionary<string, DateTime>
?? new Dictionary<string, DateTime>();
List<AlarmData> list = alarmDataService.GetList();
var listEs = GetDic(list, "", "Prompt_alarm");
var bools = cPromptAlarm.GetDb();
cache.Set(CacheKeyManager.Prompt_alarm, bools, timeOut);
for (int i = 0; i < Max; i++)
{
var obj = bools[i];
if (!listEs.TryGetValue(i, out var value)) continue;
if (Convert.ToBoolean(obj))
{
if (!dictionary.ContainsKey(value))
{
dictionary[value] = DateTime.Now;
}
}
else
{
dictionary.Remove(value);
}
}
cache.Set(CacheKeyManager.Prompt_alarmList, dictionary, TimeSpan.FromMinutes(10));
return dictionary;
}
}
//
}

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DB.Entity;
using DB.Service;
using NewLife.Caching;
using Tool.Model;
namespace RfidWeb
{
public class PromptAlarmManager:BaseManager
{
PromptAlarm cPromptAlarm=new PromptAlarm();
public Dictionary<string, DateTime> GetList()
{
Dictionary<string, DateTime> dictionary = cache[CacheKeyManager.Prompt_alarmList] as Dictionary<string, DateTime>
?? new Dictionary<string, DateTime>();
List<AlarmData> list = alarmDataService.GetList();
var listEs = GetDic(list, "", "Prompt_alarm");
var bools = cPromptAlarm.GetDb();
cache.Set(CacheKeyManager.Prompt_alarm, bools, timeOut);
for (int i = 0; i < Max; i++)
{
var obj = bools[i];
if (!listEs.TryGetValue(i, out var value)) continue;
if (Convert.ToBoolean(obj))
{
if (!dictionary.ContainsKey(value))
{
dictionary[value] = DateTime.Now;
}
}
else
{
dictionary.Remove(value);
}
}
cache.Set(CacheKeyManager.Prompt_alarmList, dictionary, TimeSpan.FromMinutes(10));
return dictionary;
}
}
}

@ -0,0 +1,25 @@
namespace Tool.Model
{
public class CacheKeyManager
{
public static readonly string UpdateLog = "UpdateLog";
public static readonly string User = "HmiUser";
public static readonly string AesPwd = "nodyang";
public static readonly string AramlList = "AramlList";
public static readonly string AramlDataList = "AramlDataList";
public static readonly string CH_alarm = "CH_alarm";
public static readonly string CQ_alarm = "CQ_alarm";
public static readonly string estop_temporary_storage = "estop_temporary_storage";
public static readonly string Prompt_alarm = "Prompt_alarm";
public static readonly string Prompt_alarmList = "Prompt_alarmList";
}
}

@ -54,29 +54,4 @@ namespace Tool.Model
return ls.ToArray();
}
}
public class CacheKeyManager
{
public static readonly string UpdateLog = "UpdateLog";
public static readonly string User = "HmiUser";
public static readonly string AesPwd = "nodyang";
public static readonly string AramlList = "AramlList";
public static readonly string AramlDataList = "AramlDataList";
public static readonly string CH_alarm = "CH_alarm";
public static readonly string CQ_alarm = "CQ_alarm";
public static readonly string estop_temporary_storage = "estop_temporary_storage";
public static readonly string Prompt_alarm = "Prompt_alarm";
public static readonly string Prompt_alarmList = "Prompt_alarmList";
}
}

@ -68,6 +68,7 @@
<Compile Include="HttpUtil.cs" />
<Compile Include="ILogNetFactory.cs" />
<Compile Include="Model\BoolModelFactory.cs" />
<Compile Include="Model\CacheKeyManager.cs" />
<Compile Include="Model\EsStop.cs" />
<Compile Include="Model\HmiChAlarm.cs" />
<Compile Include="Model\HmiChModel.cs" />

Loading…
Cancel
Save