xxe 2 lat temu
rodzic
commit
d6803e6697
23 zmienionych plików z 1327 dodań i 10 usunięć
  1. +10
    -0
      HKCard.sln
  2. +2
    -0
      HKCardOUT/Bootstrapper.cs
  3. +5
    -3
      HKCardOUT/HKCardOUT.csproj
  4. +226
    -0
      HKCardOUT/Helper/BigScreen/DataCenter.cs
  5. +110
    -2
      HKCardOUT/Helper/DataBus.cs
  6. +10
    -0
      HKCardOUT/Logic/Service/HKCore.cs
  7. +5
    -2
      HKCardOUT/ViewModels/RootViewModel.cs
  8. +3
    -1
      HKCardOUT/options.pro.json
  9. +61
    -0
      HKControl/Arms/Alarm.cs
  10. +34
    -0
      HKControl/Arms/AlarmAttribute.cs
  11. +272
    -0
      HKControl/Arms/AlarmHelper.cs
  12. +14
    -0
      HKControl/Arms/AlarmLevel.cs
  13. +20
    -0
      HKControl/Arms/AlarmTriggerType.cs
  14. +43
    -2
      HKControl/DataModel.cs
  15. +28
    -0
      HKControl/Main.cs
  16. +9
    -0
      WpfTest/App.xaml
  17. +17
    -0
      WpfTest/App.xaml.cs
  18. +10
    -0
      WpfTest/AssemblyInfo.cs
  19. +13
    -0
      WpfTest/MainWindow.xaml
  20. +382
    -0
      WpfTest/MainWindow.xaml.cs
  21. +12
    -0
      WpfTest/Window1.xaml
  22. +27
    -0
      WpfTest/Window1.xaml.cs
  23. +14
    -0
      WpfTest/WpfTest.csproj

+ 10
- 0
HKCard.sln Wyświetl plik

@@ -21,6 +21,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HKLib", "HKLib\HKLib.csproj
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HKCardManager", "HKCardManager\HKCardManager.csproj", "{96C17249-7F4A-4D25-B658-507A8E876582}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfTest", "WpfTest\WpfTest.csproj", "{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -101,6 +103,14 @@ Global
{96C17249-7F4A-4D25-B658-507A8E876582}.Release|Any CPU.Build.0 = Release|Any CPU
{96C17249-7F4A-4D25-B658-507A8E876582}.Release|x86.ActiveCfg = Release|Any CPU
{96C17249-7F4A-4D25-B658-507A8E876582}.Release|x86.Build.0 = Release|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Debug|x86.ActiveCfg = Debug|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Debug|x86.Build.0 = Debug|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Release|Any CPU.Build.0 = Release|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Release|x86.ActiveCfg = Release|Any CPU
{8312F839-6DA5-4BF0-8BB3-D1505E194AB5}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


+ 2
- 0
HKCardOUT/Bootstrapper.cs Wyświetl plik

@@ -77,6 +77,7 @@ namespace HKCardOUT
DataBus.StartDevice = configer["StartDevice"].AsBool();
DataBus.Cancel = configer["Cancel"].AsBool();
DataBus.Count = configer["Count"].AsInt();
DataBus.MQTT = configer["MQTT"].ToString();
DataBus.Admin = configer.GetSection("Admin").GetChildren().Select(t => t.Value).ToList();
HKLib.Configer.SaasRoute = DataBus.SaasRoute;
RemoteService.PullShopInfo();
@@ -94,6 +95,7 @@ namespace HKCardOUT
DataBus.saleLogDtos = new System.Collections.Concurrent.ConcurrentQueue<DTO.SaleLogDto>();
RemoteService.GetFoodMenus();
RemoteService.GetRangeCtrl();
MQTTCon.Connection();
base.Configure();
}



+ 5
- 3
HKCardOUT/HKCardOUT.csproj Wyświetl plik

@@ -14,9 +14,9 @@
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>
<PropertyGroup>
<!--<PropertyGroup>
<ApplicationManifest>App.manifest</ApplicationManifest>
</PropertyGroup>
</PropertyGroup>-->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE;Core</DefineConstants>
</PropertyGroup>
@@ -33,7 +33,9 @@
<None Remove="HKResouces\背景.jpg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BPA.Helper" Version="1.0.25" />
<PackageReference Include="BPA.Communication" Version="1.0.42" />
<PackageReference Include="BPA.Helper" Version="1.0.28" />
<PackageReference Include="BPA.Message" Version="1.0.78" />
<PackageReference Include="CalcBinding" Version="2.5.2" />
<PackageReference Include="HandyControls" Version="3.4.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />


+ 226
- 0
HKCardOUT/Helper/BigScreen/DataCenter.cs Wyświetl plik

@@ -0,0 +1,226 @@
using BPA.Communication;
using BPA.Helper;
using BPA.Message;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.Model;
using DTO;
using HKCardOUT.Helper;
using HKCardOUT.Logic.Service;
using HKControl;
using HKLib.Dto;
using ImTools;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Helper.BigScreen
{
public class DataCenter
{
public static List<string> S1 { get; set; } = new List<string>(2);
public static List<string> S2 { get; set; } = new List<string>(2);
public static List<string> S3 { get; set; } = new List<string>(2);
public static List<string> S4 { get; set; } = new List<string>(2);
public static List<string> S5 { get; set; } = new List<string>(2);
public static List<string> S6 { get; set; } = new List<string>(2);
public static void CreateData()
{

var sender = new ScreenModelSplitMeals();
sender.Alarm = new List<AlarmModel>();

AlarmHelper<DataModel>.AddAction = new Action<string>((param) =>
{
sender.Alarm.Add(new AlarmModel
{
AlarmMs = param,
AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
});
});

ThreadManage.GetInstance().StartLong(() =>
{
var model = new HKCore().GetDayData();


sender.IsRun = IsRun.运行;
if (!Main.GetInstance.GetIsConnect(6) || !Main.GetInstance.GetIsConnect(5))
sender.RobotStatu1 = WorkStatus.停止;
if (!Main.GetInstance.GetIsConnect(4) || !Main.GetInstance.GetIsConnect(3))
sender.RobotStatu2 = WorkStatus.停止;
if (!Main.GetInstance.GetIsConnect(2) || !Main.GetInstance.GetIsConnect(1))
sender.RobotStatu3 = WorkStatus.停止;

sender.WorkStatus_1 = Main.GetInstance.GetIsSwipe(6) ? WorkStatus.工作 : WorkStatus.待机;
sender.WorkStatus_2 = Main.GetInstance.GetIsSwipe(5) ? WorkStatus.工作 : WorkStatus.待机;
sender.WorkStatus_3 = Main.GetInstance.GetIsSwipe(4) ? WorkStatus.工作 : WorkStatus.待机;
sender.WorkStatus_4 = Main.GetInstance.GetIsSwipe(3) ? WorkStatus.工作 : WorkStatus.待机;
sender.WorkStatus_5 = Main.GetInstance.GetIsSwipe(2) ? WorkStatus.工作 : WorkStatus.待机;
sender.WorkStatus_6 = Main.GetInstance.GetIsSwipe(1) ? WorkStatus.工作 : WorkStatus.待机;

sender.SplitMeals_CreditCardCount_1 = model["6"];
if (DataBus.SaleLogDtoList.ContainsKey("6"))
{
if (DataBus.SaleLogDtoList["6"].Count > 0)
{
if (DataBus.SaleLogDtoList["6"].TryDequeue(out SaleLogDto info))
{
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S1.Count >= 2)
{
S1.RemoveAt(0);
S1.Add(Name);
}
else
S1.Add(Name);
sender.SplitMeals_CreditCardNameBefore_1 = S1[0];
sender.SplitMeals_CreditCardName_1 = S1.Count >= 2 ? S1[1] : S1[0];
}
}
}
var GateId = DataBus.StoreInfo.Devices.Where(t => t.Address == $"05" || t.Address == $"06").Select(t => t.GateId).FirstOrDefault();
var res = DataBus.Menu.GateFood.Where(t => t.GateId == GateId)?.Select(t => t.Foods)?.FirstOrDefault();
sender.SplitMeals_CookType_1 = res;

sender.SplitMeals_CreditCardCount_2 = model["5"];
if (DataBus.SaleLogDtoList.ContainsKey("5"))
{
if (DataBus.SaleLogDtoList["5"].Count > 0)
{
if (DataBus.SaleLogDtoList["5"].TryDequeue(out SaleLogDto info))
{
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S2.Count >= 2)
{
S2.RemoveAt(0);
S2.Add(Name);
}
else
S2.Add(Name);
sender.SplitMeals_CreditCardNameBefore_2 = S2[0];
sender.SplitMeals_CreditCardName_2 = S2.Count >= 2 ? S2[1] : S2[0];
}
}
}
sender.SplitMeals_CookType_2 = res;

sender.SplitMeals_CreditCardCount_3 = model["4"];
if (DataBus.SaleLogDtoList.ContainsKey("4"))
{
if (DataBus.SaleLogDtoList["4"].Count > 0)
{
if (DataBus.SaleLogDtoList["4"].TryDequeue(out SaleLogDto info))
{
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S3.Count >= 2)
{
S3.RemoveAt(0);
S3.Add(Name);
}
else
S3.Add(Name);
sender.SplitMeals_CreditCardNameBefore_3 = S3[0];
sender.SplitMeals_CreditCardName_3 = S3.Count >= 2 ? S3[1] : S3[0];
}
}
}
sender.SplitMeals_CookType_3 = res;

sender.SplitMeals_CreditCardCount_4 = model["3"];
if (DataBus.SaleLogDtoList.ContainsKey("3"))
{
if (DataBus.SaleLogDtoList["3"].Count > 0)
{
if (DataBus.SaleLogDtoList["3"].TryDequeue(out SaleLogDto info))
{
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S4.Count >= 2)
{
S4.RemoveAt(0);
S4.Add(Name);
}
else
S4.Add(Name);
sender.SplitMeals_CreditCardNameBefore_4 = S4[0];
sender.SplitMeals_CreditCardName_4 = S4.Count >= 2 ? S4[1] : S4[0];
}
}
}
sender.SplitMeals_CookType_4 = res;

sender.SplitMeals_CreditCardCount_5 = model["2"];
if (DataBus.SaleLogDtoList.ContainsKey("2"))
{
if (DataBus.SaleLogDtoList["2"].Count > 0)
{
if (DataBus.SaleLogDtoList["2"].TryDequeue(out SaleLogDto info))
{
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S5.Count >= 2)
{
S5.RemoveAt(0);
S5.Add(Name);
}
else
S5.Add(Name);
sender.SplitMeals_CreditCardNameBefore_5 = S5[0];
sender.SplitMeals_CreditCardName_5 = S5.Count >= 2 ? S5[1] : S5[0];
}
}
}
sender.SplitMeals_CookType_5 = res;

sender.SplitMeals_CreditCardCount_6 = model["1"];
if (DataBus.SaleLogDtoList.ContainsKey("1"))
{
if (DataBus.SaleLogDtoList["1"].Count > 0)
{
if (DataBus.SaleLogDtoList["1"].TryDequeue(out SaleLogDto info))
{
var Name = DataBus.UserListDto.Where(t => t.Cards.Select(x => x.CardNum).Contains(info.CardNo)).Select(x => x.Name).FirstOrDefault();
if (S6.Count >= 2)
{
S6.RemoveAt(0);
S6.Add(Name);
}
else
S6.Add(Name);
sender.SplitMeals_CreditCardNameBefore_6 = S6[0];
sender.SplitMeals_CreditCardName_6 = S6.Count >= 2 ? S6[1] : S6[0];
}
}
}
sender.SplitMeals_CookType_6 = res;



sender.StatsCount = new List<StatsModel> {
new StatsModel { }
};
MQTTCon.Send(sender);
Thread.Sleep(10);
}, $"屏幕刷卡信息", true);
}
public static void InitQueeue()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (DataBus.saleLogDtos.Count > 0)
{
if (DataBus.saleLogDtos.TryDequeue(out SaleLogDto info))
{
if (!DataBus.SaleLogDtoList.ContainsKey(info.Location))
DataBus.SaleLogDtoList.TryAdd(info.Location, new ConcurrentQueue<SaleLogDto>());
DataBus.SaleLogDtoList[info.Location].Enqueue(info);
}
}
Thread.Sleep(100);
}), "刷卡队列分配");
}
}
}

+ 110
- 2
HKCardOUT/Helper/DataBus.cs Wyświetl plik

@@ -1,8 +1,13 @@
using DTO;
using BPA.Communication;
using BPA.Helper;
using BPA.Message.Enum;
using BPA.Message;
using DTO;
using HKCardOUT.Logic.Model;
using HKCardOUT.Views;
using HKLib.Dto;
using Logic.RemoteModel;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -12,7 +17,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Xml.Linq;
using XExten.Advance.StaticFramework;
using static System.Net.Mime.MediaTypeNames;

namespace HKCardOUT.Helper
{
@@ -38,6 +45,7 @@ namespace HKCardOUT.Helper
public static string SaasRoute { get; set; }
public static int Span { get; set; }
public static int Count { get; set; }
public static string MQTT { get; set; }
public static List<string> Admin { get; set; }
public static TimeSpilte Times { get; set; }
public static StoreInfoResponse StoreInfo { get; set; }
@@ -92,8 +100,108 @@ namespace HKCardOUT.Helper
}
}
public class MemoryBus
{
{
public static List<CardStutas> CardStatus { get; set; } = new List<CardStutas>();
public static List<SaleLog> CardRecord { get; set; } = new List<SaleLog>();
}

public static class MQTTCon
{
static MqttHelper mqttHelper;
static MQTTCon()
{
mqttHelper = new MqttHelper();
}
/// <summary>
/// Mqtt是否运行
/// </summary>
static bool IsRunningMqtt = false;
public static void Connection()
{
try
{
//2.Mqtt连接
if (!string.IsNullOrEmpty(DataBus.MQTT) && DataBus.MQTT.Contains(','))
{
string[] mqttcom = DataBus.MQTT.Split(',');
if (mqttcom != null && mqttcom.Count() == 4)
{
mqttHelper.Connect(mqttcom[2], mqttcom[3], mqttcom[0], int.Parse(mqttcom[1]), $"分餐机{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
}
mqttHelper.Disconnect = new Action(() =>
{
IsRunningMqtt = false;
MessageLog.GetInstance.ShowEx($"分餐机MQTT异常断开....");
});
mqttHelper.ConnectOk = new Action(() =>
{
IsRunningMqtt = true;//连接成功
});
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"分餐机初始化连接 MQTT,原因:{ex.Message}");
}

}

public static void Send(ScreenModelSplitMeals screenModel)
{
SendScreenDataModel sendScreenData = new SendScreenDataModel();
sendScreenData.Name = ScreenDeviceType.分餐机;
sendScreenData.Value = screenModel;
//new ScreenModelSplitMeals
//{
// IsRun = k2 == 0 ? IsRun.运行 : IsRun.停止,
// WorkStatus = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
// RobotStatu = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
// Alarm = new List<AlarmModel> {
// new AlarmModel { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(2).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// },
// FailuresCount = 0,
// StatsCount = new List<StatsModel> {
// new StatsModel { Name = name_s[0], Count = new Random().Next(0, 100) },
// new StatsModel { Name = name_s[1], Count = new Random().Next(0, 100) },
// new StatsModel { Name = name_s[2], Count = new Random().Next(0, 100) },
// new StatsModel { Name = name_s[3], Count = new Random().Next(0, 100) },
// new StatsModel { Name = name_s[4], Count = new Random().Next(0, 100) },
// },
// SplitMeals_CreditCardCount_1 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_1 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_1 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_1 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

// SplitMeals_CreditCardCount_2 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_2 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_2 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_2 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

// SplitMeals_CreditCardCount_3 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_3 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_3 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_3 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

// SplitMeals_CreditCardCount_4 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_4 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_4 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_4 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

// SplitMeals_CreditCardCount_5 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_5 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_5 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_5 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

// SplitMeals_CreditCardCount_6 = new Random().Next(0, 100),
// SplitMeals_CreditCardNameBefore_6 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CreditCardName_6 = name_XM[new Random().Next(0, 5)],
// SplitMeals_CookType_6 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

//};
string message = JsonConvert.SerializeObject(sendScreenData);
mqttHelper.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.分餐机), message);
}
}
}

+ 10
- 0
HKCardOUT/Logic/Service/HKCore.cs Wyświetl plik

@@ -292,6 +292,16 @@ namespace HKCardOUT.Logic.Service
.WhereIF(screen.Length == 2, t => t.Location == a || t.Location == b).Select(t => t.Location).ToList();
return count.GroupBy(t => t).ToDictionary(t => t.Key, t => t.Count());
}
/// <summary>
/// 获取当天的刷卡
/// </summary>
/// <returns></returns>
public Dictionary<string, int> GetDayData()
{
var today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
var count = DbContext.Context.Queryable<SaleLog>().Select(t => t.Location).ToList();
return count.GroupBy(t => t).ToDictionary(t => t.Key, t => t.Count());
}

public void WriteData()
{


+ 5
- 2
HKCardOUT/ViewModels/RootViewModel.cs Wyświetl plik

@@ -1,5 +1,6 @@
using BPA.Helper;
using DTO;
using Helper.BigScreen;
using HKCardOUT.Helper;
using HKCardOUT.Logic.Model;
using HKCardOUT.Logic.Service;
@@ -39,6 +40,8 @@ namespace HKCardOUT.ViewModels
serv.GetAllCardStatus();
ProcessCard();
InsertData();
DataCenter.InitQueeue();
DataCenter.CreateData();
}

/// <summary>
@@ -133,7 +136,7 @@ namespace HKCardOUT.ViewModels
Device = t.Name,
Stalls = x.Name
}).ToList();
if (Init != null)
/* if (Init != null)
{
Ad = new ObservableCollection<AdDTO>(Init);
var route = SyncStatic.CreateFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AD.txt"));
@@ -145,7 +148,7 @@ namespace HKCardOUT.ViewModels
var jsons = SyncStatic.Decompress(SyncStatic.ReadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AD.txt")), SecurityType.Base64);
Ad = new ObservableCollection<AdDTO>(jsons.ToModel<List<AdDTO>>());
AdOpen();
}
}*/
}));

}


+ 3
- 1
HKCardOUT/options.pro.json Wyświetl plik

@@ -24,8 +24,10 @@
//"MQ": "host=10.2.1.21:5672;username=guest;password=guest"
//MQ正式地址
"MQ": "host=47.108.65.220;username=root;password=pwd",
//MQTT
"MQTT": "10.2.1.254,1883,admin,public",
//超级卡
"Admin": [6666666666666666666,8888888888888888888,9999999999999999999,1590198360768385024,1590198442460844032],
"Admin": [ 6666666666666666666, 8888888888888888888, 9999999999999999999, 1590198360768385024, 1590198442460844032 ],
//刷卡间隔
"Span": 5
}

+ 61
- 0
HKControl/Arms/Alarm.cs Wyświetl plik

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Model
{
public class Alarm
{
/// <summary>
/// ID
/// </summary>
[Key]
public int Id
{
get { return _mId; }
set { _mId = value; }
}
private int _mId;

/// <summary>
/// 编号ID
/// </summary>
public int NumId { get { return _mNumId; } set { _mNumId = value; } }
private int _mNumId;


/// <summary>
/// 日期
/// </summary>
public string Date { get { return _mDate; } set { _mDate = value; } }
private string _mDate;

/// <summary>
/// 时间
/// </summary>
public string Time { get { return _mTime; } set { _mTime = value; } }
private string _mTime;

/// <summary>
/// 报警信息
/// </summary>
public string Info { get { return _mInfo; } set { _mInfo = value; } }
private string _mInfo;

/// <summary>
/// 报警值
/// </summary>
public string Value { get { return _mValue; } set { _mValue = value; } }
private string _mValue;

/// <summary>
/// 报警等级
/// </summary>
public string Grade { get { return _mGrade; } set { _mGrade = value; } }
private string _mGrade;

}
}

+ 34
- 0
HKControl/Arms/AlarmAttribute.cs Wyświetl plik

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.CustomResource.Pages.Model
{
[AttributeUsage(AttributeTargets.Property)]
public class AlarmAttribute : Attribute
{
public AlarmAttribute(string Info, AlarmTriggerType alarmTriggerType = AlarmTriggerType.Rising, AlarmLevel alarmLevel = AlarmLevel.一般报警)
{
AlarmInfo = Info;
AlarmType = alarmTriggerType;
@AlarmLevel = alarmLevel;
}

/// <summary>
/// 报警信息
/// </summary>
public string AlarmInfo { get; set; }

/// <summary>
/// 告警类型
/// </summary>
public AlarmTriggerType AlarmType { get; set; }

/// <summary>
/// 告警级别
/// </summary>
public AlarmLevel @AlarmLevel { get; set; }
}
}

+ 272
- 0
HKControl/Arms/AlarmHelper.cs Wyświetl plik

@@ -0,0 +1,272 @@
using BPA.Helper;
using BPASmartClient.Model;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;

namespace BPASmartClient.CustomResource.Pages.Model
{

public class AlarmHelper<AlarmT> where AlarmT : class, new()
{
private volatile static ConcurrentDictionary<string, AlarmT> _Instance;
private static readonly object Obj_Lock = new object();
public static AlarmT GetInstance(string name = "")
{
lock (Obj_Lock)
{
if (string.IsNullOrEmpty(name)) name = typeof(AlarmT).Name;
if (_Instance == null) _Instance = new ConcurrentDictionary<string, AlarmT>();
if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new AlarmT());
return _Instance[name];
}
}
private AlarmHelper() { }


public static List<Alarm> Alarms { get; set; } = new List<Alarm>();
public static List<Alarm> HistoryAlarms { get; set; } = new List<Alarm>();
static ConcurrentDictionary<string, bool> flagbit = new ConcurrentDictionary<string, bool>();
static ConcurrentDictionary<string, Delay> delays = new ConcurrentDictionary<string, Delay>();
public static Action<string> AddAction { get; set; }
public static Action<string> RemoveAction { get; set; }
public static Action ChangeAction { get; set; }

//public static AlarmT Alarm { get; set; } = new AlarmT();

public static void Init()
{
//AlarmViewModel.AlarmInfos = Alarms;
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (_Instance != null)
{
foreach (var temp in _Instance)
{
foreach (var item in temp.Value.GetType().GetProperties())
{
if (item.CustomAttributes.Count() > 0)
{
var AlarmModel = item.GetCustomAttribute<AlarmAttribute>();
if (AlarmModel != null)
{
bool value = Convert.ToBoolean(_Instance[temp.Key].GetType().GetProperty(item.Name)?.GetValue(_Instance[temp.Key]));
string text = typeof(AlarmT).Name == temp.Key ? AlarmModel.AlarmInfo : $"{temp.Key}:{AlarmModel.AlarmInfo}";
EdgeAlarm(value, text, 1, AlarmModel.AlarmLevel, AlarmModel.AlarmType);
}
}
}
}
}
Thread.Sleep(100);
}), $"{typeof(AlarmT).Name},报警通用模块监听");

}

/// <summary>
/// 沿报警检测
/// </summary>
/// <param name="Trigger">触发变量</param>
/// <param name="text">报警信息</param>
/// <param name="edgeType">触发类型,上升沿 或 下降沿</param>
private static void EdgeAlarm(bool Trigger, string text, int delay = 2, AlarmLevel alarmLevel = AlarmLevel.一般报警, AlarmTriggerType edgeType = AlarmTriggerType.Rising)
{
if (!flagbit.ContainsKey(text)) flagbit.TryAdd(text, false);
if (!delays.ContainsKey(text)) delays.TryAdd(text, Delay.GetInstance(text));
if (edgeType == AlarmTriggerType.Rising ? delays[text].Start(Trigger, delay) : delays[text].Start(!Trigger, delay))
{
if (edgeType == AlarmTriggerType.Rising ? !flagbit[text] : flagbit[text])
{
AddAlarm(Trigger, text, alarmLevel);
flagbit[text] = edgeType == AlarmTriggerType.Rising ? true : false;
}
}
else RemoveAlarm(text);
if (edgeType == AlarmTriggerType.Rising ? flagbit[text] : !flagbit[text]) flagbit[text] = Trigger;
}

/// <summary>
/// 添加报警信息
/// </summary>
/// <param name="AlarmInfo">报警信息</param>
private static void AddAlarm(object value, string AlarmInfo, AlarmLevel alarmLevel)
{
Alarm tempAlarm = new Alarm()
{
NumId = Alarms.Count + 1,
Date = DateTime.Now.ToString("yyyy/MM/dd"),
Grade = alarmLevel.ToString(),
Info = AlarmInfo,
Value = value.ToString(),
Time = DateTime.Now.ToString("HH:mm:ss"),
};

var res = Sqlite<Alarm>.GetInstance.Base.Add(tempAlarm);
Sqlite<Alarm>.GetInstance.Save();

if (Alarms.FirstOrDefault(p => p.Info == AlarmInfo) == null)
{
Alarms.Insert(0, tempAlarm);
for (int i = 0; i < Alarms.Count; i++) { Alarms.ElementAt(i).NumId = i + 1; }

AddAction?.Invoke(AlarmInfo);//添加报警通知
ChangeAction?.Invoke();//更改报警通知
}
}

/// <summary>
/// 移除报警信息
/// </summary>
/// <param name="AlarmInfo">报警信息</param>
private static void RemoveAlarm(string AlarmInfo)
{
var result = Alarms.FirstOrDefault(p => p.Info == AlarmInfo);
if (result != null)
{
Alarms.Remove(result);
for (int i = 0; i < Alarms.Count; i++) { Alarms.ElementAt(i).NumId = i + 1; }

if (RemoveAction != null) RemoveAction(AlarmInfo);
if (ChangeAction != null) ChangeAction();
}
}

}

//public class AlarmHelper<AlarmT> where AlarmT : class, new()
//{


// //private volatile static ConcurrentDictionary<string, AlarmT> _Instance;
// //public static AlarmT GetInstance(string name)
// //{
// // if (_Instance == null) _Instance = new ConcurrentDictionary<string, AlarmT>();
// // if (!_Instance.ContainsKey(name)) _Instance.TryAdd(name, new AlarmT());
// // return _Instance[name];
// //}
// //private AlarmHelper() { }


// public static ObservableCollection<Alarm> Alarms { get; set; } = new ObservableCollection<Alarm>();
// public static List<Alarm> HistoryAlarms { get; set; } = new List<Alarm>();
// static ConcurrentDictionary<string, bool> flagbit = new ConcurrentDictionary<string, bool>();
// static ConcurrentDictionary<string, Delay> delays = new ConcurrentDictionary<string, Delay>();
// public static Action<string> AddAction { get; set; }
// public static Action<string> RemoveAction { get; set; }
// public static Action ChangeAction { get; set; }

// public static AlarmT Alarm { get; set; } = new AlarmT();

// public static void Init()
// {
// AlarmViewModel.AlarmInfos = Alarms;
// ThreadManage.GetInstance().StartLong(new Action(() =>
// {
// foreach (var item in Alarm.GetType().GetProperties())
// {
// if (item.CustomAttributes.Count() > 0)
// {
// var AlarmModel = item.GetCustomAttribute<AlarmAttribute>();
// if (AlarmModel != null)
// {
// bool value = Convert.ToBoolean(Alarm.GetType().GetProperty(item.Name)?.GetValue(Alarm));
// EdgeAlarm(value, AlarmModel.AlarmInfo, 1, AlarmModel.AlarmLevel, AlarmModel.AlarmType);
// }
// }
// }
// Thread.Sleep(100);
// }), $"{typeof(AlarmT).Name},报警通用模块监听");

// }


// //public static void AnalogAlarm(dynamic Trigger, string info, dynamic HH = null, dynamic H = 0, dynamic L = 0, dynamic LL = 0)
// //{

// //}




// /// <summary>
// /// 沿报警检测
// /// </summary>
// /// <param name="Trigger">触发变量</param>
// /// <param name="text">报警信息</param>
// /// <param name="edgeType">触发类型,上升沿 或 下降沿</param>
// private static void EdgeAlarm(bool Trigger, string text, int delay = 2, AlarmLevel alarmLevel = AlarmLevel.一般报警, AlarmTriggerType edgeType = AlarmTriggerType.Rising)
// {
// if (!flagbit.ContainsKey(text)) flagbit.TryAdd(text, false);
// if (!delays.ContainsKey(text)) delays.TryAdd(text, Delay.GetInstance(text));
// if (edgeType == AlarmTriggerType.Rising ? delays[text].Start(Trigger, delay) : delays[text].Start(!Trigger, delay))
// {
// if (edgeType == AlarmTriggerType.Rising ? !flagbit[text] : flagbit[text])
// {
// AddAlarm(Trigger, text, alarmLevel);
// flagbit[text] = edgeType == AlarmTriggerType.Rising ? true : false;
// }
// }
// else RemoveAlarm(text);
// if (edgeType == AlarmTriggerType.Rising ? flagbit[text] : !flagbit[text]) flagbit[text] = Trigger;
// }

// /// <summary>
// /// 添加报警信息
// /// </summary>
// /// <param name="AlarmInfo">报警信息</param>
// private static void AddAlarm(object value, string AlarmInfo, AlarmLevel alarmLevel)
// {
// Alarm tempAlarm = new Alarm()
// {
// NumId = Alarms.Count + 1,
// Date = DateTime.Now.ToString("yyyy/MM/dd"),
// Grade = alarmLevel.ToString(),
// Info = AlarmInfo,
// Value = value.ToString(),
// Time = DateTime.Now.ToString("HH:mm:ss"),
// };

// var res = Sqlite<Alarm>.GetInstance.Base.Add(tempAlarm);
// Sqlite<Alarm>.GetInstance.Save();

// if (Alarms.FirstOrDefault(p => p.Info == AlarmInfo) == null)
// {
// Application.Current.Dispatcher.Invoke(new Action(() =>
// {
// Alarms.Insert(0, tempAlarm);
// for (int i = 0; i < Alarms.Count; i++) { Alarms.ElementAt(i).NumId = i + 1; }
// }));

// AddAction?.Invoke(AlarmInfo);//添加报警通知
// ChangeAction?.Invoke();//更改报警通知
// }
// }

// /// <summary>
// /// 移除报警信息
// /// </summary>
// /// <param name="AlarmInfo">报警信息</param>
// private static void RemoveAlarm(string AlarmInfo)
// {
// var result = Alarms.FirstOrDefault(p => p.Info == AlarmInfo);
// if (result != null)
// {
// Application.Current.Dispatcher.Invoke(new Action(() =>
// {
// Alarms.Remove(result);
// for (int i = 0; i < Alarms.Count; i++) { Alarms.ElementAt(i).NumId = i + 1; }
// }));

// if (RemoveAction != null) RemoveAction(AlarmInfo);
// if (ChangeAction != null) ChangeAction();
// }
// }

//}
}

+ 14
- 0
HKControl/Arms/AlarmLevel.cs Wyświetl plik

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.CustomResource.Pages.Model
{
public enum AlarmLevel
{
一般报警,
严重报警
}
}

+ 20
- 0
HKControl/Arms/AlarmTriggerType.cs Wyświetl plik

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.CustomResource.Pages.Model
{
public enum AlarmTriggerType
{
/// <summary>
/// 上升沿
/// </summary>
Rising,
/// <summary>
/// 下降沿
/// </summary>
Falling
}
}

+ 43
- 2
HKControl/DataModel.cs Wyświetl plik

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.CustomResource.Pages.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -6,7 +7,7 @@ using System.Threading.Tasks;

namespace HKControl
{
internal class DataModel
public class DataModel
{
public WindowDataModel LeftWindowData { get; set; } = new WindowDataModel();
public WindowDataModel RightWindowData { get; set; } = new WindowDataModel();
@@ -33,5 +34,45 @@ namespace HKControl
/// 刷卡机编号
/// </summary>
public string CarNum { get; set; }

[Alarm("警告左侧机构餐盘无盘")]
public bool L1 { get; set; }
[Alarm("警告左侧升降气缸下降不到位")]
public bool L2 { get; set; }
[Alarm("警告左侧升降气缸中间不到位")]
public bool L3 { get; set; }
[Alarm("警告左侧升降气缸上升不到位")]
public bool L4 { get; set; }
[Alarm("警告左侧升降气缸上升不到位")]
public bool L5 { get; set; }
[Alarm("警告左侧机构推空餐盘不到位")]
public bool L6 { get; set; }
[Alarm("警告左侧出餐推不到位")]
public bool L7 { get; set; }
[Alarm("警告左侧出餐回退不到位")]
public bool L8 { get; set; }
[Alarm("警告左餐盘掉落位置有餐盘")]
public bool L9 { get; set; }


[Alarm("警告右侧机构餐盘无盘")]
public bool R1 { get; set; }
[Alarm("警告右侧升降气缸下降不到位")]
public bool R2 { get; set; }
[Alarm("警告右侧升降气缸中间不到位")]
public bool R3 { get; set; }
[Alarm("警告右侧升降气缸上升不到位")]
public bool R4 { get; set; }
[Alarm("警告右侧升降气缸上升不到位")]
public bool R5 { get; set; }
[Alarm("警告右侧机构推空餐盘不到位")]
public bool R6 { get; set; }
[Alarm("警告右侧出餐推不到位")]
public bool R7 { get; set; }
[Alarm("警告右侧出餐回退不到位")]
public bool R8 { get; set; }
[Alarm("警告右餐盘掉落位置有餐盘")]
public bool R9 { get; set; }

}
}

+ 28
- 0
HKControl/Main.cs Wyświetl plik

@@ -1,6 +1,7 @@
using System.Collections.Concurrent;
using System.Diagnostics;
using BPA.Helper;
using BPASmartClient.CustomResource.Pages.Model;
using S7.Net;

namespace HKControl
@@ -131,12 +132,39 @@ namespace HKControl
{
SiemensDicitonary[item.DeviceNum].ConnectOk = new Action(() =>
{
AlarmHelper<DataModel>.GetInstance($"{item.DeviceNum}号档口");
AlarmHelper<DataModel>.Init();
HKLog.HKLogImport.WriteInfo($"{item.DeviceNum}:连接成功");
ThreadManage.GetInstance().StartLong(new Action(() =>
{
try
{
var md = AlarmHelper<DataModel>.GetInstance($"{item.DeviceNum}号档口");
var res = SiemensDicitonary[item.DeviceNum].Read<byte>("MB7");
var res1 = SiemensDicitonary[item.DeviceNum].Read<byte>("MB10");
var res2 = SiemensDicitonary[item.DeviceNum].Read<byte>("MB11");
md.LeftWindowData.L1 = Get8bitValue(res1, 2);
md.LeftWindowData.L2 = Get8bitValue(res1, 3);
md.LeftWindowData.L3 = Get8bitValue(res1, 4);
md.LeftWindowData.L4 = Get8bitValue(res1, 5);
md.LeftWindowData.L5 = Get8bitValue(res1, 6);
md.LeftWindowData.L6 = Get8bitValue(res1, 7);
md.LeftWindowData.L7 = Get8bitValue(res1, 8);
md.LeftWindowData.L8 = Get8bitValue(res2, 1);
md.LeftWindowData.L9 = Get8bitValue(res2, 2);


var res3 = SiemensDicitonary[item.DeviceNum].Read<byte>("MB12");
var res4 = SiemensDicitonary[item.DeviceNum].Read<byte>("MB13");
md.RightWindowData.R1 = Get8bitValue(res3, 2);
md.RightWindowData.R2 = Get8bitValue(res3, 3);
md.RightWindowData.R3 = Get8bitValue(res3, 4);
md.RightWindowData.R4 = Get8bitValue(res3, 5);
md.RightWindowData.R5 = Get8bitValue(res3, 6);
md.RightWindowData.R6 = Get8bitValue(res3, 7);
md.RightWindowData.R7 = Get8bitValue(res3, 8);
md.RightWindowData.R8 = Get8bitValue(res4, 1);
md.RightWindowData.R9 = Get8bitValue(res4, 2);

DataModels[item.DeviceNum].LeftWindowData.IsSwipe = Get8bitValue(res, 1);
DataModels[item.DeviceNum].LeftWindowData.Complete = Get8bitValue(res, 2);


+ 9
- 0
WpfTest/App.xaml Wyświetl plik

@@ -0,0 +1,9 @@
<Application x:Class="WpfTest.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfTest"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

+ 17
- 0
WpfTest/App.xaml.cs Wyświetl plik

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace WpfTest
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

+ 10
- 0
WpfTest/AssemblyInfo.cs Wyświetl plik

@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

+ 13
- 0
WpfTest/MainWindow.xaml Wyświetl plik

@@ -0,0 +1,13 @@
<Window x:Class="WpfTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfTest"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<TextBox x:Name="textwb" Background="Black" Foreground="#FFC000FB" TextWrapping="Wrap" AcceptsReturn="True" ></TextBox>
<Button Width="100" Height="100" Click="Button_Click" Visibility="Collapsed"></Button>
</Grid>
</Window>

+ 382
- 0
WpfTest/MainWindow.xaml.cs Wyświetl plik

@@ -0,0 +1,382 @@
using BPA.Communication;
using BPA.Helper;
using BPA.Message;
using BPA.Message.Enum;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
/// <summary>
/// MQTT连接信息
/// </summary>
public string MQTTConnection { get; set; } = "10.2.1.254,1883,admin,public";

/// <summary>
/// Mqtt是否运行
/// </summary>
public bool IsRunningMqtt = false;
/// <summary>
/// Mqtt
/// </summary>
public MqttHelper mqttHelper = new MqttHelper();

public MainWindow()
{
InitializeComponent();
Connection();
ThreadServer();
//Button_Click(null, null);
}
public void ThreadServer()
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
try
{
if (IsRunningMqtt)
{
Send(ScreenDeviceType.大炒);
Thread.Sleep(1000);
Send(ScreenDeviceType.小炒); Thread.Sleep(1000);

Send(ScreenDeviceType.煮面机); Thread.Sleep(1000);

Send(ScreenDeviceType.分餐机); Thread.Sleep(1000);

}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"{Name}:线程服务异常,原因:{ex.Message}");
}
Thread.Sleep(100);
}), $"{Name},线程服务");
}
/// <summary>
/// 初始化连接Redis MQTT
/// </summary>
public void Connection()
{
try
{
//2.Mqtt连接
if (!string.IsNullOrEmpty(this.MQTTConnection) && this.MQTTConnection.Contains(','))
{
string[] mqttcom = this.MQTTConnection.Split(',');
if (mqttcom != null && mqttcom.Count() == 4)
{
mqttHelper.Connect(mqttcom[2], mqttcom[3], mqttcom[0], int.Parse(mqttcom[1]), $"{Name}:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
}
mqttHelper.Disconnect = new Action(() =>
{
IsRunningMqtt = false;
MessageLog.GetInstance.ShowEx($"{Name}:MQTT异常断开....");
});
mqttHelper.ConnectOk = new Action(() =>
{
IsRunningMqtt = true;//连接成功
});
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"{Name}:初始化连接 MQTT,原因:{ex.Message}");
}

}

public void Send(ScreenDeviceType screen)
{
int k2 =new Random().Next(0, 2);
SendScreenDataModel sendScreenData = new SendScreenDataModel();

List<ORDER_STATUS> oRDER_STATUS = new List<ORDER_STATUS>() { ORDER_STATUS.WAIT, ORDER_STATUS.COOKING, ORDER_STATUS.COMPLETED_COOK, ORDER_STATUS.COMPLETED_TAKE, ORDER_STATUS.ERR_NOT_REPLY_WHEN_COOKING };
List<string> name_s = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花", "尖椒鸡杂", "回锅肉" };
List<string> name_s_zm = new List<string>() { "清汤面", "鸡蛋面", "火鸡面", "回锅肉面", "鸡杂面" };

List<string> name_XM = new List<string>() { "王权贵", "张哲", "李青古", "龙西", "李富贵" };
int k = new Random().Next(0, 5);
int M = new Random().Next(0, 5);
if (screen == ScreenDeviceType.大炒)
{
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelMaxWok
{
IsRun = k2 == 0 ? IsRun.运行 : IsRun.停止,
WorkStatus_1 = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
WorkStatus_2 = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
RobotStatu = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
// Alarm = new List<AlarmModel> {
// new AlarmModel { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(2).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//},
FailuresCount = 0,
StatsCount = new List<StatsModel> {
new StatsModel{Name= name_s[0],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[1],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[2],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[3],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[4],Count=new Random().Next(0, 100)},
},
MaxWok_Dishes_1 = "回锅肉",
MaxWok_Task_1 = "炒菜中",
MaxWok_Process_1 = new List<ProcessModel> {
new ProcessModel{ Id=0,Name= "清洗", Status=(M==0) ? ProcessStatus.正在执行:((M>0)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=1,Name= "到菜", Status=(M==1) ? ProcessStatus.正在执行:((M>1)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=2,Name= "翻炒", Status=(M==2) ? ProcessStatus.正在执行:((M>2)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=3,Name= "调料", Status=(M==3) ? ProcessStatus.正在执行:((M>3)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=4,Name= "完成", Status=(M==4) ? ProcessStatus.正在执行:((M>4)?ProcessStatus.执行完成:ProcessStatus.未执行)},
},
MaxWok_HeatGear_1 = "1",
MaxWok_StirGear_1 = "2",
MaxWok_FlipSpeed_1 = "30",
MaxWok_Temp_1 = "102",
MaxWok_OrderCount_1 = new Random().Next(0, 100),
MaxWok_ErrorOrderCount_1 = new Random().Next(0, 100),

MaxWok_Dishes_2 = "烂肉豇豆",
MaxWok_Task_2 = "炒菜中",
MaxWok_Process_2 = new List<ProcessModel> {
new ProcessModel{ Id=0,Name= "清洗", Status=(k==0) ? ProcessStatus.正在执行:((k>0)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=1,Name= "到菜", Status=(k==1) ? ProcessStatus.正在执行:((k>1)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=2,Name= "翻炒", Status=(k==2) ? ProcessStatus.正在执行:((k>2)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=3,Name= "调料", Status=(k==3) ? ProcessStatus.正在执行:((k>3)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=4,Name= "完成", Status=(k==4) ? ProcessStatus.正在执行:((k>4)?ProcessStatus.执行完成:ProcessStatus.未执行)},
},
MaxWok_HeatGear_2 = "2",
MaxWok_StirGear_2 = "3",
MaxWok_FlipSpeed_2 = "32",
MaxWok_Temp_2 = "132",
MaxWok_OrderCount_2 = new Random().Next(0, 100),
MaxWok_ErrorOrderCount_2 = new Random().Next(0, 100),
};
}
else if (screen == ScreenDeviceType.小炒)
{
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelMinWok
{
IsRun = k2 == 0 ? IsRun.运行 : IsRun.停止,
WorkStatus_1 = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
WorkStatus_2 = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
RobotStatu = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
// Alarm = new List<AlarmModel> {
// new AlarmModel { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
// new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(2).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//},
FailuresCount = 0,
StatsCount = new List<StatsModel> {
new StatsModel{Name= name_s[0],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[1],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[2],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[3],Count=new Random().Next(0, 100)},
new StatsModel{Name= name_s[4],Count=new Random().Next(0, 100)},
},
MinWok_Dishes_1 = "回锅肉",
MinWok_Task_1 = "炒菜中",
MinWok_Process_1 = new List<ProcessModel> {
new ProcessModel{ Id=0,Name= "清洗", Status=(M==0) ? ProcessStatus.正在执行:((M>0)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=1,Name= "到菜", Status=(M==1) ? ProcessStatus.正在执行:((M>1)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=2,Name= "翻炒", Status=(M==2) ? ProcessStatus.正在执行:((M>2)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=3,Name= "调料", Status=(M==3) ? ProcessStatus.正在执行:((M>3)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=4,Name= "完成", Status=(M==4) ? ProcessStatus.正在执行:((M>4)?ProcessStatus.执行完成:ProcessStatus.未执行)},
},
MinWok_HeatGear_1 = "1",
MinWok_StirGear_1 = "2",
MinWok_FlipSpeed_1 = "30",
MinWok_Temp_1 = "102",
MinWok_OrderCount_1 = new Random().Next(0, 100),
MinWok_ErrorOrderCount_1 = new Random().Next(0, 100),

MinWok_Dishes_2 = "烂肉豇豆",
MinWok_Task_2 = "炒菜中",
MinWok_Process_2 = new List<ProcessModel> {
new ProcessModel{ Id=0,Name= "清洗", Status=(k==0) ? ProcessStatus.正在执行:((k>0)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=1,Name= "到菜", Status=(k==1) ? ProcessStatus.正在执行:((k>1)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=2,Name= "翻炒", Status=(k==2) ? ProcessStatus.正在执行:((k>2)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=3,Name= "调料", Status=(k==3) ? ProcessStatus.正在执行:((k>3)?ProcessStatus.执行完成:ProcessStatus.未执行)},
new ProcessModel{ Id=4,Name= "完成", Status=(k==4) ? ProcessStatus.正在执行:((k>4)?ProcessStatus.执行完成:ProcessStatus.未执行)},
},
MinWok_HeatGear_2 = "2",
MinWok_StirGear_2 = "3",
MinWok_FlipSpeed_2 = "32",
MinWok_Temp_2 = "132",
MinWok_OrderCount_2 = new Random().Next(0, 100),
MinWok_ErrorOrderCount_2 = new Random().Next(0, 100),
};
}
else if (screen == ScreenDeviceType.煮面机)
{
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelMorkS
{
IsRun = k2 == 0 ? IsRun.运行 : IsRun.停止,
WorkStatus = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
RobotStatu = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
Alarm = new List<AlarmModel> {
new AlarmModel { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "煮面机警告,水温过低!!!!" },
//new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(2).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
},
FailuresCount = 0,
StatsCount = new List<StatsModel> {
new StatsModel { Name = name_s_zm[0], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s_zm[1], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s_zm[2], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s_zm[3], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s_zm[4], Count = new Random().Next(0, 100) },
},
MorkS_OrderCount = new Random().Next(0, 100),
MorkS_ErrorOrderCount = new Random().Next(0, 100),
MorkS_NoodleUpOrDown_1 = k2 == 0 ? "true" : "false",
MorkS_NoodleUpOrDown_2 = k2 == 0 ? "true" : "false",
MorkS_NoodleUpOrDown_3 = k2 == 0 ? "true" : "false",
MorkS_NoodleUpOrDown_4 = k2 == 0 ? "true" : "false",
MorkS_NoodleUpOrDown_5 = k2 == 0 ? "true" : "false",
MorkS_NoodleUpOrDown_6 = k2 == 0 ? "true" : "false",

MorkS_Temp = "false",// k2 == 0 ? "true" : "false",
MorkS_BinLocation = new Random().Next(0, 6).ToString(),
MorkS_SiloMeas = k2 == 0 ? "true" : "false",
MorkS_NoBowMeas = k2 == 0 ? "true" : "false",
MakeOrder = new List<OrderMakeModel> {
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.WAIT, SortNum="007".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.WAIT, SortNum="008".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.WAIT, SortNum="009".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.WAIT, SortNum="010".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.WAIT, SortNum="011".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_COOK, SortNum="006".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_TAKE, SortNum="005".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_TAKE, SortNum="004".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_TAKE, SortNum="003".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_TAKE, SortNum="002".ToString()},
new OrderMakeModel { GoodName= name_s_zm[new Random().Next(0, 5)], StartTime=DateTime.Now.ToString("HH:mm:ss"), Status=ORDER_STATUS.COMPLETED_TAKE, SortNum="001".ToString()},
},

};
}
else if (screen == ScreenDeviceType.分餐机)
{
sendScreenData.Name = screen;
sendScreenData.Value = new ScreenModelSplitMeals
{
IsRun = k2 == 0 ? IsRun.运行 : IsRun.停止,
WorkStatus = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
RobotStatu = k2 == 0 ? WorkStatus.工作 : WorkStatus.待机,
//Alarm = new List<AlarmModel> {
// new AlarmModel { AlarmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//new AlarmModel { AlarmTime = DateTime.Now.AddSeconds(2).ToString("yyyy-MM-dd HH:mm:ss"), AlarmMs = "XXXX机构出现故障!!!!" },
//},
FailuresCount = 0,
StatsCount = new List<StatsModel> {
new StatsModel { Name = name_s[0], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s[1], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s[2], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s[3], Count = new Random().Next(0, 100) },
new StatsModel { Name = name_s[4], Count = new Random().Next(0, 100) },
},
SplitMeals_CreditCardCount_1 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_1 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_1 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_1 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

SplitMeals_CreditCardCount_2 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_2 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_2 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_2 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

SplitMeals_CreditCardCount_3 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_3 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_3 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_3 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

SplitMeals_CreditCardCount_4 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_4 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_4 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_4 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

SplitMeals_CreditCardCount_5 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_5 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_5 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_5 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

SplitMeals_CreditCardCount_6 = new Random().Next(0, 100),
SplitMeals_CreditCardNameBefore_6 = name_XM[new Random().Next(0, 5)],
SplitMeals_CreditCardName_6 = name_XM[new Random().Next(0, 5)],
SplitMeals_CookType_6 = new List<string>() { "回锅肉", "烂肉豇豆", "火爆腰花" },

};
}

string message = JsonConvert.SerializeObject(sendScreenData);
mqttHelper.Publish(ScreenTOPIC.GetInstance.GetTopic(screen), message);

System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
{

if (textwb.Text.Length > 100000)
{
textwb.Text = "";
}
string text = $"{ScreenTOPIC.GetInstance.GetTopic(screen)} {message}\n";
textwb.Text += text;
}));

}

private void Button_Click(object sender, RoutedEventArgs e)
{
int i = 0;
Window1 window1 = new Window1();
foreach (System.Windows.Forms.Screen scr in System.Windows.Forms.Screen.AllScreens)
{
//if (!scr.Primary)
{
if (i == 1)
{
window1.WindowStartupLocation = WindowStartupLocation.Manual;

window1.Left = scr.WorkingArea.Left;
window1.Top = scr.WorkingArea.Top;
window1.Width = scr.Bounds.Width;
window1.Height = scr.Bounds.Height;
window1.WindowState = WindowState.Maximized;
window1.ResizeMode = ResizeMode.NoResize;
window1.WindowStyle = WindowStyle.None;
window1.WindowState = WindowState.Normal;
window1.ShowInTaskbar = false;
window1.Show();
}
else if (i == 2)
{
}
i++;
}
}

}
}
}

+ 12
- 0
WpfTest/Window1.xaml Wyświetl plik

@@ -0,0 +1,12 @@
<Window x:Class="WpfTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfTest"
mc:Ignorable="d"
Title="Window1" Height="450" Width="800">
<Grid>
</Grid>
</Window>

+ 27
- 0
WpfTest/Window1.xaml.cs Wyświetl plik

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfTest
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
}
}

+ 14
- 0
WpfTest/WpfTest.csproj Wyświetl plik

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.CustomResource" Version="1.0.14" />
</ItemGroup>

</Project>

Ładowanie…
Anuluj
Zapisz