@@ -13,6 +13,8 @@ namespace BPASmartClient.ScreenLib | |||
{ | |||
public AppMain(Window window, Type type) | |||
{ | |||
//启动Redis数据读取 | |||
Main.GetInstance.Start(); | |||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | |||
FSystemHelper.GetInstance.CreateDesktopShortcut(); | |||
WindowLargeScreen windowLarge = new WindowLargeScreen(); | |||
@@ -43,8 +45,6 @@ namespace BPASmartClient.ScreenLib | |||
} | |||
#endregion | |||
window = windowLarge; | |||
Main main = new Main(); | |||
main.Start(); | |||
} | |||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) | |||
@@ -1,5 +1,6 @@ | |||
using BPA.Communication; | |||
using BPA.Helper; | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
@@ -13,7 +14,7 @@ namespace BPASmartClient.ScreenLib | |||
/// <summary> | |||
/// 主函数 | |||
/// </summary> | |||
public class Main | |||
public class Main | |||
{ | |||
#region 接口继承变量 | |||
/// <summary> | |||
@@ -53,18 +54,26 @@ namespace BPASmartClient.ScreenLib | |||
/// </summary> | |||
private static volatile Main _Instance; | |||
public static Main GetInstance => _Instance ?? (_Instance = new Main()); | |||
public Main() { | |||
RedisConnection= System.Configuration.ConfigurationManager.AppSettings["RedisConnection"].ToString(); | |||
Name = System.Configuration.ConfigurationManager.AppSettings["DeviceMC"].ToString(); | |||
public Main() | |||
{ | |||
ReadPZ(); | |||
if (PZdic.ContainsKey("RedisConnection")) | |||
RedisConnection = PZdic["RedisConnection"]; | |||
if (PZdic.ContainsKey("DeviceMC")) | |||
Name = PZdic["DeviceMC"]; | |||
} | |||
/// <summary> | |||
/// 设备数据 | |||
/// </summary> | |||
public List<RedisDataModel> reeisDatas { get; set; } = new List<RedisDataModel>(); | |||
public Dictionary<string, Dictionary<string, RedisDataModel>> redisDatasDic = new Dictionary<string, Dictionary<string, RedisDataModel>>(); | |||
/// <summary> | |||
/// 告警数据 | |||
/// </summary> | |||
public List<RedisDataModel> reeisDatasAic { get; set; } = new List<RedisDataModel>(); | |||
public Dictionary<string, Dictionary<string, RedisDataModel>> redisAicDatasDic = new Dictionary<string, Dictionary<string, RedisDataModel>>(); | |||
/// <summary> | |||
/// 配置数据 | |||
/// </summary> | |||
public Dictionary<string,string> PZdic=new Dictionary<string,string>(); | |||
#endregion | |||
#region 线程处理函数 | |||
@@ -80,8 +89,42 @@ namespace BPASmartClient.ScreenLib | |||
if (IsRunning && IsRunningReids) | |||
{ | |||
//1.读取Redis变量 | |||
List<RedisDataModel> Values = RedisHelper.GetInstance.Read<List<RedisDataModel>>($"{Name}[Device]").Content; | |||
List<RedisDataModel> reeisDatasAic = RedisHelper.GetInstance.Read<List<RedisDataModel>>($"{Name}[Alarm]").Content; | |||
if (!string.IsNullOrEmpty(Name)) | |||
{ | |||
redisDatasDic = new Dictionary<string, Dictionary<string, RedisDataModel>>(); | |||
redisAicDatasDic = new Dictionary<string, Dictionary<string, RedisDataModel>>(); | |||
if (Name.Contains(",")) | |||
{ | |||
Name.Split(',')?.ToList().ForEach(x => | |||
{ | |||
Dictionary<string, RedisDataModel> valuePairs = new Dictionary<string, RedisDataModel>(); | |||
RedisHelper.GetInstance.Read<List<RedisDataModel>>($"{x}[Device]").Content?.ToList().ForEach(k => { | |||
valuePairs[k.VarName] = k; | |||
}); | |||
redisDatasDic[x]= valuePairs;//设备数据 | |||
Dictionary<string, RedisDataModel> valuePairsAic = new Dictionary<string, RedisDataModel>(); | |||
RedisHelper.GetInstance.Read<List<RedisDataModel>>($"{x}[Alarm]").Content?.ToList().ForEach(k => { | |||
valuePairsAic[k.VarName] = k; | |||
}); | |||
redisAicDatasDic[x] = valuePairsAic;//告警数据 | |||
}); | |||
} | |||
else | |||
{ | |||
Dictionary<string, RedisDataModel> valuePairs = new Dictionary<string, RedisDataModel>(); | |||
RedisHelper.GetInstance.Read<List<RedisDataModel>>($"{Name}[Device]").Content?.ToList().ForEach(k => { | |||
valuePairs[k.VarName] = k; | |||
}); | |||
redisDatasDic[Name] = valuePairs;//设备数据 | |||
Dictionary<string, RedisDataModel> valuePairsAic = new Dictionary<string, RedisDataModel>(); | |||
RedisHelper.GetInstance.Read<List<RedisDataModel>>($"{Name}[Alarm]").Content?.ToList().ForEach(k => { | |||
valuePairsAic[k.VarName] = k; | |||
}); | |||
redisAicDatasDic[Name] = valuePairsAic;//告警数据 | |||
} | |||
} | |||
} | |||
} | |||
catch (Exception ex) | |||
@@ -150,6 +193,15 @@ namespace BPASmartClient.ScreenLib | |||
#region 调用事件 | |||
/// <summary> | |||
/// 读取配置 | |||
/// </summary> | |||
public void ReadPZ() | |||
{ | |||
System.Configuration.ConfigurationManager.AppSettings.AllKeys?.ToList().ForEach(key => { | |||
PZdic[key]= System.Configuration.ConfigurationManager.AppSettings[key].ToString(); | |||
}); | |||
} | |||
/// <summary> | |||
/// 初始化连接Redis MQTT | |||
/// </summary> | |||
public void Connection() | |||
@@ -7,12 +7,19 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using Newtonsoft.Json; | |||
namespace BPASmartClient.ScreenLib | |||
{ | |||
public class ScreenMorksControlViewModel : NotifyBase | |||
{ | |||
#region 变量 | |||
/// <summary> | |||
/// 广告地址 | |||
/// </summary> | |||
public Uri GgAdder { get { return _GgAdder; } set { _GgAdder = value; OnPropertyChanged(); } } | |||
private Uri _GgAdder = new Uri(System.Configuration.ConfigurationManager.AppSettings["GgAdder"].ToString()); | |||
/// <summary> | |||
/// 柱状图显示集合 | |||
/// </summary> | |||
@@ -43,12 +50,6 @@ namespace BPASmartClient.ScreenLib | |||
public int YCDdCount { get { return _YCDdCount; } set { _YCDdCount = value; OnPropertyChanged(); } } | |||
private int _YCDdCount = 0; | |||
/// <summary> | |||
/// 广告地址 | |||
/// </summary> | |||
public Uri GgAdder { get { return _GgAdder; } set { _GgAdder = value; OnPropertyChanged(); } } | |||
private Uri _GgAdder = new Uri(System.Configuration.ConfigurationManager.AppSettings["GgAdder"].ToString()); | |||
/// <summary> | |||
/// 正在制作订单数据 | |||
/// </summary> | |||
@@ -186,6 +187,125 @@ namespace BPASmartClient.ScreenLib | |||
})); | |||
Thread.Sleep(5000); | |||
}), $"{DateTime.Now},线程服务"); | |||
} | |||
/// <summary> | |||
/// 数据运行器 | |||
/// </summary> | |||
public void DataRun() | |||
{ | |||
string Dev = "MorkS";//当前设备名称 | |||
string name = Main.GetInstance.PZdic.ContainsKey($"{Dev}_Name") ? Main.GetInstance.PZdic[$"{Dev}_Name"].ToString(): DateTime.Now.ToString(); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() => | |||
{ | |||
if (!string.IsNullOrEmpty(name) && Main.GetInstance.redisDatasDic != null && Main.GetInstance.redisDatasDic.ContainsKey(name) && Main.GetInstance.redisDatasDic[name]!=null) | |||
{ | |||
List<string> list=new List<string> { "IsRun", "RunStatus", "OrderCount", "ErrorOrderCount", "OrderMakeList", "OrderMakeListOver", "AlarmList" }; | |||
list?.ForEach(x => { | |||
if (Main.GetInstance.PZdic.ContainsKey($"{Dev}_{x}")) | |||
{ | |||
if (Main.GetInstance.redisDatasDic[name].ContainsKey(Main.GetInstance.PZdic[$"{Dev}_{x}"])) | |||
{ | |||
string _value = Main.GetInstance.redisDatasDic[name][Main.GetInstance.PZdic[$"{Dev}_{x}"]].VarVaule; | |||
#region 执行更新界面数据 | |||
switch (x) | |||
{ | |||
case "IsRun"://是否运行 | |||
DevIsRun = _value == "0" ? DevIsRun.停止 : DevIsRun.运行; | |||
break; | |||
case "RunStatus"://运行状态 | |||
DevIsRun = _value == "0" ? DevIsRun.停止 : DevIsRun.运行; | |||
break; | |||
case "OrderCount"://是否运行 | |||
try | |||
{ | |||
DdCount = int.Parse(_value); | |||
} | |||
catch (Exception ex) | |||
{ | |||
DdCount = 0; | |||
} | |||
break; | |||
case "ErrorOrderCount": | |||
try | |||
{ | |||
YCDdCount = int.Parse(_value); | |||
} | |||
catch (Exception ex) | |||
{ | |||
YCDdCount = 0; | |||
} | |||
break; | |||
case "OrderMakeList": | |||
try | |||
{ | |||
OrderMakeList = new ObservableCollection<OrderMakeModel>(); | |||
JsonConvert.DeserializeObject<List<OrderMakeModel>>(_value)?.OrderBy(l => l.SortNum)?.ToList().ForEach(par => { | |||
OrderMakeList.Add(par); | |||
}); | |||
} | |||
catch (Exception ex) | |||
{ | |||
OrderMakeList = new ObservableCollection<OrderMakeModel>(); | |||
} | |||
break; | |||
case "OrderMakeListOver": | |||
try | |||
{ | |||
OrderMakeListOver = new ObservableCollection<OrderMakeModel>(); | |||
JsonConvert.DeserializeObject<List<OrderMakeModel>>(_value)?.OrderBy(l => l.SortNum)?.ToList().ForEach(par => { | |||
OrderMakeListOver.Add(par); | |||
}); | |||
} | |||
catch (Exception ex) | |||
{ | |||
OrderMakeListOver = new ObservableCollection<OrderMakeModel>(); | |||
} | |||
break; | |||
case "AlarmList": | |||
try | |||
{ | |||
AlarmList = new ObservableCollection<AlarmMsModel>(); | |||
JsonConvert.DeserializeObject<List<AlarmMsModel>>(_value)?.OrderBy(l => l.AlarmTime)?.ToList().ForEach(par => { | |||
AlarmList.Add(par); | |||
}); | |||
//Histogram=new | |||
//if (AlarmList.Count > 0) | |||
//{ | |||
//} | |||
} | |||
catch (Exception ex) | |||
{ | |||
OrderMakeListOver = new ObservableCollection<OrderMakeModel>(); | |||
} | |||
break; | |||
default: | |||
break; | |||
} | |||
#endregion | |||
} | |||
} | |||
}); | |||
} | |||
//Histogram = new[] { | |||
// new KeyValuePair<string, double>(name_s[0], new Random().Next(0,400)), | |||
// new KeyValuePair<string, double>(name_s[1], new Random().Next(0,400)), | |||
// new KeyValuePair<string, double>(name_s[2], new Random().Next(0,400)), | |||
// new KeyValuePair<string, double>(name_s[3], new Random().Next(0,400)), | |||
// new KeyValuePair<string, double>(name_s[4], new Random().Next(0,400))}; | |||
})); | |||
Thread.Sleep(500); | |||
}), $"{name},线程服务"); | |||
} | |||
} | |||
} |
@@ -3,7 +3,186 @@ | |||
<appSettings> | |||
<!--Redis配置--> | |||
<add key="RedisConnection" value="10.2.1.254,6379,BapAdmin123456.,1"/> | |||
<add key="DeviceMC" value="1"/> | |||
<add key="DeviceMC" value="test_1"/> | |||
<add key="GgAdder" value="https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4"/> | |||
<!--变量名称配置--> | |||
<!--MorkS 变量配置--> | |||
<!--设备名称--> | |||
<add key="MorkS_Name" value="MorkS"/> | |||
<!--设备是否运行--> | |||
<add key="MorkS_IsRun" value="IsRun"/> | |||
<!--设备运行状态--> | |||
<add key="MorkS_RunStatus" value="RunStatus"/> | |||
<!--设备订单数量--> | |||
<add key="MorkS_OrderCount" value="OrderCount"/> | |||
<!--设备异常订单数量--> | |||
<add key="MorkS_ErrorOrderCount" value="ErrorOrderCount"/> | |||
<!--正在制作订单数据--> | |||
<add key="MorkS_OrderMakeList" value="OrderMakeList"/> | |||
<!--制作完成订单数据--> | |||
<add key="MorkS_OrderMakeListOver" value="OrderMakeListOver"/> | |||
<!--告警数据--> | |||
<add key="MorkS_AlarmList" value="AlarmList"/> | |||
<!--大炒 变量配置--> | |||
<!--设备名称--> | |||
<add key="MaxWok_Name" value="大炒"/> | |||
<!--1号_设备是否运行--> | |||
<add key="MaxWok1_IsRun" value="IsRun"/> | |||
<!--1号_设备运行状态--> | |||
<add key="MaxWok1_RunStatus" value="RunStatus"/> | |||
<!--1号_设备订单数量--> | |||
<add key="MaxWok1_OrderCount" value="OrderCount"/> | |||
<!--1号_设备异常订单数量--> | |||
<add key="MaxWok1_ErrorOrderCount" value="ErrorOrderCount"/> | |||
<!--1号_正在制作订单数据--> | |||
<add key="MaxWok1_OrderMakeList" value="OrderMakeList"/> | |||
<!--1号_制作完成订单数据--> | |||
<add key="MaxWok1_OrderMakeListOver" value="OrderMakeListOver"/> | |||
<!--1号_告警数据--> | |||
<add key="MaxWok1_AlarmList" value="AlarmList"/> | |||
<!--2号_设备是否运行--> | |||
<add key="MaxWok2_IsRun" value="IsRun_1"/> | |||
<!--2号_设备运行状态--> | |||
<add key="MaxWok2_RunStatus" value="RunStatus_1"/> | |||
<!--2号_设备订单数量--> | |||
<add key="MaxWok2_OrderCount" value="OrderCount_1"/> | |||
<!--2号_设备异常订单数量--> | |||
<add key="MaxWok2_ErrorOrderCount" value="ErrorOrderCount_1"/> | |||
<!--2号_正在制作订单数据--> | |||
<add key="MaxWok2_OrderMakeList" value="OrderMakeList_1"/> | |||
<!--2号_制作完成订单数据--> | |||
<add key="MaxWok2_OrderMakeListOver" value="OrderMakeListOver_1"/> | |||
<!--2号_告警数据--> | |||
<add key="MaxWok2_AlarmList" value="AlarmList_1"/> | |||
<!--小炒 变量配置--> | |||
<!--设备名称--> | |||
<add key="MinWok_Name" value="小炒"/> | |||
<!--1号_设备是否运行--> | |||
<add key="MinWok1_IsRun" value="IsRun"/> | |||
<!--1号_设备运行状态--> | |||
<add key="MinWok1_RunStatus" value="RunStatus"/> | |||
<!--1号_设备订单数量--> | |||
<add key="MinWok1_OrderCount" value="OrderCount"/> | |||
<!--1号_设备异常订单数量--> | |||
<add key="MinWok1_ErrorOrderCount" value="ErrorOrderCount"/> | |||
<!--1号_正在制作订单数据--> | |||
<add key="MinWok1_OrderMakeList" value="OrderMakeList"/> | |||
<!--1号_制作完成订单数据--> | |||
<add key="MinWok1_OrderMakeListOver" value="OrderMakeListOver"/> | |||
<!--1号_告警数据--> | |||
<add key="MinWok1_AlarmList" value="AlarmList"/> | |||
<!--2号_设备是否运行--> | |||
<add key="MinWok2_IsRun" value="IsRun_1"/> | |||
<!--2号_设备运行状态--> | |||
<add key="MinWok2_RunStatus" value="RunStatus_1"/> | |||
<!--2号_设备订单数量--> | |||
<add key="MinWok2_OrderCount" value="OrderCount_1"/> | |||
<!--2号_设备异常订单数量--> | |||
<add key="MinWok2_ErrorOrderCount" value="ErrorOrderCount_1"/> | |||
<!--2号_正在制作订单数据--> | |||
<add key="MinWok2_OrderMakeList" value="OrderMakeList_1"/> | |||
<!--2号_制作完成订单数据--> | |||
<add key="MinWok2_OrderMakeListOver" value="OrderMakeListOver_1"/> | |||
<!--2号_告警数据--> | |||
<add key="MinWok2_AlarmList" value="AlarmList_1"/> | |||
<!--分餐机 变量配置--> | |||
<!--设备名称--> | |||
<add key="SplitMeals_Name" value="分餐机"/> | |||
<!--1号_设备是否运行--> | |||
<add key="SplitMeals1_IsRun" value="IsRun_1"/> | |||
<!--1号_设备运行状态--> | |||
<add key="SplitMeals1_RunStatus" value="RunStatus_1"/> | |||
<!--1号_设备刷卡数量--> | |||
<add key="SplitMeals1_OrderCount" value="OrderCount_1"/> | |||
<!--1号_设备异常刷卡数量--> | |||
<add key="SplitMeals1_ErrorOrderCount" value="ErrorOrderCount_1"/> | |||
<!--1号_菜品集合--> | |||
<add key="SplitMeals1_CookTypeList" value="CookTypeList_1"/> | |||
<!--1号_菜品统计集合--> | |||
<add key="SplitMeals1_CookStatsList" value="CookStatsList_1"/> | |||
<!--1号_告警数据--> | |||
<add key="SplitMeals1_AlarmList" value="AlarmList_1"/> | |||
<!--2号_设备是否运行--> | |||
<add key="SplitMeals2_IsRun" value="IsRun_2"/> | |||
<!--2号_设备运行状态--> | |||
<add key="SplitMeals2_RunStatus" value="RunStatus_2"/> | |||
<!--2号_设备刷卡数量--> | |||
<add key="SplitMeals2_OrderCount" value="OrderCount_2"/> | |||
<!--2号_设备异常刷卡数量--> | |||
<add key="SplitMeals2_ErrorOrderCount" value="ErrorOrderCount_2"/> | |||
<!--2号_菜品集合--> | |||
<add key="SplitMeals2_CookTypeList" value="CookTypeList_2"/> | |||
<!--2号_菜品统计集合--> | |||
<add key="SplitMeals2_CookStatsList" value="CookStatsList_2"/> | |||
<!--2号_告警数据--> | |||
<add key="SplitMeals2_AlarmList" value="AlarmList_2"/> | |||
<!--3号_设备是否运行--> | |||
<add key="SplitMeals3_IsRun" value="IsRun_3"/> | |||
<!--3号_设备运行状态--> | |||
<add key="SplitMeals3_RunStatus" value="RunStatus_3"/> | |||
<!--3号_设备刷卡数量--> | |||
<add key="SplitMeals3_OrderCount" value="OrderCount_3"/> | |||
<!--3号_设备异常刷卡数量--> | |||
<add key="SplitMeals3_ErrorOrderCount" value="ErrorOrderCount_3"/> | |||
<!--3号_菜品集合--> | |||
<add key="SplitMeals3_CookTypeList" value="CookTypeList_3"/> | |||
<!--3号_菜品统计集合--> | |||
<add key="SplitMeals3_CookStatsList" value="CookStatsList_3"/> | |||
<!--3号_告警数据--> | |||
<add key="SplitMeals3_AlarmList" value="AlarmList_3"/> | |||
<!--4号_设备是否运行--> | |||
<add key="SplitMeals4_IsRun" value="IsRun_4"/> | |||
<!--4号_设备运行状态--> | |||
<add key="SplitMeals4_RunStatus" value="RunStatus_4"/> | |||
<!--4号_设备刷卡数量--> | |||
<add key="SplitMeals4_OrderCount" value="OrderCount_4"/> | |||
<!--4号_设备异常刷卡数量--> | |||
<add key="SplitMeals4_ErrorOrderCount" value="ErrorOrderCount_4"/> | |||
<!--4号_菜品集合--> | |||
<add key="SplitMeals4_CookTypeList" value="CookTypeList_4"/> | |||
<!--4号_菜品统计集合--> | |||
<add key="SplitMeals4_CookStatsList" value="CookStatsList_4"/> | |||
<!--4号_告警数据--> | |||
<add key="SplitMeals4_AlarmList" value="AlarmList_4"/> | |||
<!--5号_设备是否运行--> | |||
<add key="SplitMeals5_IsRun" value="IsRun_5"/> | |||
<!--5号_设备运行状态--> | |||
<add key="SplitMeals5_RunStatus" value="RunStatus_5"/> | |||
<!--5号_设备刷卡数量--> | |||
<add key="SplitMeals5_OrderCount" value="OrderCount_5"/> | |||
<!--5号_设备异常刷卡数量--> | |||
<add key="SplitMeals5_ErrorOrderCount" value="ErrorOrderCount_5"/> | |||
<!--5号_菜品集合--> | |||
<add key="SplitMeals5_CookTypeList" value="CookTypeList_5"/> | |||
<!--5号_菜品统计集合--> | |||
<add key="SplitMeals5_CookStatsList" value="CookStatsList_5"/> | |||
<!--5号_告警数据--> | |||
<add key="SplitMeals5_AlarmList" value="AlarmList_5"/> | |||
<!--6号_设备是否运行--> | |||
<add key="SplitMeals6_IsRun" value="IsRun_6"/> | |||
<!--6号_设备运行状态--> | |||
<add key="SplitMeals6_RunStatus" value="RunStatus_6"/> | |||
<!--6号_设备刷卡数量--> | |||
<add key="SplitMeals6_OrderCount" value="OrderCount_6"/> | |||
<!--6号_设备异常刷卡数量--> | |||
<add key="SplitMeals6_ErrorOrderCount" value="ErrorOrderCount_6"/> | |||
<!--6号_菜品集合--> | |||
<add key="SplitMeals6_CookTypeList" value="CookTypeList_6"/> | |||
<!--6号_菜品统计集合--> | |||
<add key="SplitMeals6_CookStatsList" value="CookStatsList_6"/> | |||
<!--6号_告警数据--> | |||
<add key="SplitMeals6_AlarmList" value="AlarmList_6"/> | |||
</appSettings> | |||
</configuration> |