Bläddra i källkod

增加物模型默认模板事件

煮面机(新)
Mr_z 1 år sedan
förälder
incheckning
bd840e91fb
7 ändrade filer med 160 tillägg och 36 borttagningar
  1. +7
    -0
      BPASmartClient.AliyunIot/AliyunIot.cs
  2. +9
    -0
      BPASmartClient.AliyunIot/BPASmartClient.AliyunIot.csproj
  3. +107
    -34
      DosingSystem/ExcuteControl.cs
  4. +1
    -1
      DosingSystem/Model/DeviceInquire.cs
  5. +1
    -1
      DosingSystem/ViewModel/NewRecipeViewModel.cs
  6. +12
    -0
      DosingSystem/ViewModel/RecipeSettingsViewModel.cs
  7. +23
    -0
      SmartClient.sln

+ 7
- 0
BPASmartClient.AliyunIot/AliyunIot.cs Visa fil

@@ -0,0 +1,7 @@
namespace BPASmartClient.AliyunIot
{
public class AliyunIot
{

}
}

+ 9
- 0
BPASmartClient.AliyunIot/BPASmartClient.AliyunIot.csproj Visa fil

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

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>

+ 107
- 34
DosingSystem/ExcuteControl.cs Visa fil

@@ -55,7 +55,7 @@ namespace BPASmartClient.DosingSystem
/// <summary>
/// 等待制作的配方
/// </summary>
public ObservableCollection<RecipeModel> UserTreeWait { get; set; } = new ObservableCollection<RecipeModel>();
public ObservableCollection<RecipeModel> UserTreeWait { get; set; } = new ObservableCollection<RecipeModel>() { new RecipeModel { RecipeName="we"} };

/// <summary>
/// 已完成的配方
@@ -102,36 +102,94 @@ namespace BPASmartClient.DosingSystem
RecipeRun();
BusinessExcute();
ConveyerPropertyReport();
AliyunMqConnectCheck();
#if Debug
Task.Run(() => {
while (true)
{
if (AliyunIsConnect)
{
AliyunEventReport("192.168.0.10", new AliyunStockEventReportModel { Result = "1" }, "StockJerk1StatusEvent", AliyunMaterialModelType.StockModel);
AliyunEventReport("192.168.0.10", new AliyunStockEventReportModel { Result = "1" }, "StockServoFalutEvent", AliyunMaterialModelType.StockModel);
AliyunEventReport("192.168.0.10", new AliyunStockEventReportModel { Result = "1" }, "StockJerk2StatusEvent", AliyunMaterialModelType.StockModel);
AliyunEventReport("192.168.0.10", new AliyunStockEventReportModel { Result = "1" }, "StockUpLimitEvent", AliyunMaterialModelType.StockModel);
AliyunEventReport("192.168.0.10", new AliyunStockEventReportModel { Result = "1" }, "StockDownLimitEvent", AliyunMaterialModelType.StockModel);

AliyunStockPropertyReportModel model = new AliyunStockPropertyReportModel();
model.StockRealWeight = 1;
model.BucketRealWeight = 2;
model.StockDeviceNum = 2;
model.StockDeviceName = "测试";
model.StockWorkModel = 0;
model.StockSlowlyAddWeight = 6;
model.StockPreCloseValueWeight = 7;
model.StockRapidAcceleration = 46;
model.StockSlowAcceleration = 24;
model.StockServoManualSpeed = 35;
model.StockUpperLimitWeight = 57;
model.StockLowerLimitWeight = 34;
model.StockStirringSpeed = 54;
model.StockMaterialType = "粉体";
model.StockBatchStatus = "待机";
StokcPropertyReport("192.168.0.10", model);
for (int i = 0; i < 6; i++)
{
AliyunEventReport($"192.168.0.{i+1}0", new AliyunStockEventReportModel { Result = "1" }, "StockJerk1StatusEvent", AliyunMaterialModelType.StockModel);
AliyunEventReport($"192.168.0.{i + 1}0", new AliyunStockEventReportModel { Result = "1" }, "StockServoFalutEvent", AliyunMaterialModelType.StockModel);
AliyunEventReport($"192.168.0.{i + 1}0", new AliyunStockEventReportModel { Result = "1" }, "StockJerk2StatusEvent", AliyunMaterialModelType.StockModel);
AliyunEventReport($"192.168.0.{i + 1}0", new AliyunStockEventReportModel { Result = "1" }, "StockUpLimitEvent", AliyunMaterialModelType.StockModel);
AliyunEventReport($"192.168.0.{i + 1}0", new AliyunStockEventReportModel { Result = "1" }, "StockDownLimitEvent", AliyunMaterialModelType.StockModel);

AliyunStockPropertyReportModel model = new AliyunStockPropertyReportModel();
model.StockRealWeight = 1;
model.BucketRealWeight = 2;
model.StockDeviceNum = 2;
model.StockDeviceName = "测试";
model.StockWorkModel = 0;
model.StockSlowlyAddWeight = 6;
model.StockPreCloseValueWeight = 7;
model.StockRapidAcceleration = 46;
model.StockSlowAcceleration = 24;
model.StockServoManualSpeed = 35;
model.StockUpperLimitWeight = 57;
model.StockLowerLimitWeight = 34;
model.StockStirringSpeed = 54;
model.StockMaterialType = "粉体";
model.StockBatchStatus = "待机";
StokcPropertyReport($"192.168.0.{i + 1}0", model);
}
AliyunConveyerPropertyReportModel model1 = new AliyunConveyerPropertyReportModel();
model1.TopBucketControlStatus = 1;
model1.DownBucketControlStatus =1;
model1.RunStatus = 1;
model1.WorkModel = 1;
model1.TopBucketSigleCheck = 1;
model1.ButtonBucketSigleCheck = 1;
model1.ConveyerOnlineStatus =1;
var mqdeviceTestProperty = new PostPropertyParams<AliyunConveyerPropertyReportModel>();
mqdeviceTestProperty.sys = new Sys { ack = 1 };
mqdeviceTestProperty.method = "thing.event.property.post";
mqdeviceTestProperty.version = "1.0";
mqdeviceTestProperty.ModelName = $"{produtInfo.Get("Conveyer")}";
mqdeviceTestProperty.Model = model1;
mqdeviceTestProperty.Init();
var message = JsonConvert.SerializeObject(mqdeviceTestProperty);
var topic = $"/sys/{produtInfo.Get("ProductKey")}/Conveyer/thing/event/property/post";//发布主题

var topicReply = $"/sys/{produtInfo.Get("ProductKey")}/Conveyer/thing/event/property/post_reply";//订阅主题
if (mqttCollection.ContainsKey("Conveyer"))
{
try
{
mqttCollection["Conveyer"].Publish((op) =>
{
op.Message = message;
op.Topic = topic;
op.TopicReply = topicReply;
//if (!PropertyReport)
//{
// op.ThresholdCallback += MqttPostProperty_MqttMsgPublishReceived; // MqttPostProperty_MqttMsgPublishReceived;
// PropertyReport = true;
//}
});
}
catch (Exception)
{

//throw;
}
}
SystemEventReport("ProcessRecipe", new { RecipeName = "测试5" });//正在执行配方上报
if (UserTreeWait.Count > 0)
{
string[] recipeNames = new string[UserTreeWait.Count];
for (int i = 0; i < recipeNames.Length; i++)
{
recipeNames[i] = UserTreeWait.ElementAt(i).RecipeName;
}
SystemEventReport("WaitProcessRecipe", new { RecipeNames = recipeNames });//等待执行配方上报
}
else
{
SystemEventReport("WaitProcessRecipe", new { RecipeNames = new string[] { } });//等待执行配方上报
}
}
Thread.Sleep(5000);
}
@@ -285,9 +343,9 @@ namespace BPASmartClient.DosingSystem
});

}
if (mqttCollection.Count == count + 1)
if (mqttCollection.ContainsKey("Conveyer")&& mqttCollection["Conveyer"]._mqttClient.IsConnected)
{
AliyunIsConnect = true;
AliyunSystemPropertyReportModel m1 = new AliyunSystemPropertyReportModel();
m1.RecipeCollection = new string[Json<LocalRecipe>.Data.Recipes.Count];
for (int i = 0; i < Json<LocalRecipe>.Data.Recipes.Count; i++)
@@ -306,9 +364,9 @@ namespace BPASmartClient.DosingSystem
/// </summary>
/// <param name="ipaddres"></param>
/// <param name="model"></param>
public void StokcPropertyReport(string ipaddres, AliyunStockPropertyReportModel model)
public void StokcPropertyReport<T>(string ipaddres, T model)
{
var mqdeviceTestProperty = new PostPropertyParams<AliyunStockPropertyReportModel>();
var mqdeviceTestProperty = new PostPropertyParams<T>();
mqdeviceTestProperty.sys = new Sys { ack = 1 };
mqdeviceTestProperty.method = "thing.event.property.post";
mqdeviceTestProperty.version = "1.0";
@@ -413,7 +471,7 @@ namespace BPASmartClient.DosingSystem
{
TaskManage.GetInstance.StartLong(() =>
{
if (AliyunIsConnect)
if (mqttCollection.ContainsKey("Conveyer") && mqttCollection["Conveyer"]._mqttClient.IsConnected)
{
AliyunConveyerPropertyReportModel model = new AliyunConveyerPropertyReportModel();
model.TopBucketControlStatus = Convert.ToInt32(SiemensDevice.GetInstance.MySiemens.Read<bool>("DB5.DBX4.0").Content);
@@ -465,7 +523,7 @@ namespace BPASmartClient.DosingSystem

}
/// <summary>
/// 默认模板中事件上报
/// 业务系统事件上报
/// </summary>
/// <param name="eventFlag"></param>
/// <param name="param"></param>
@@ -511,9 +569,9 @@ namespace BPASmartClient.DosingSystem
/// <summary>
/// 业务系统属性上报
/// </summary>
public void SystemPropertyReport(AliyunSystemPropertyReportModel model)
public void SystemPropertyReport<T>(T model)
{
var mqdeviceTestProperty = new PostPropertyParams<AliyunSystemPropertyReportModel>();
var mqdeviceTestProperty = new PostPropertyParams<T>();
mqdeviceTestProperty.sys = new Sys { ack = 1 };
mqdeviceTestProperty.method = "thing.event.property.post";
mqdeviceTestProperty.version = "1.0";
@@ -802,7 +860,22 @@ namespace BPASmartClient.DosingSystem
if (UserTreeWait.Count > 0) UserTreeWait.RemoveAt(0);
}));
CurrentRecipeName = Recipes.ElementAt(index).RecipeName;

#region 执行配方以及等待执行配方上报
SystemEventReport("ProcessRecipe", new { RecipeName = CurrentRecipeName });//正在执行配方上报
if (UserTreeWait.Count > 0)
{
string[] recipeNames = new string[UserTreeWait.Count];
for (int i = 0; i < recipeNames.Length; i++)
{
recipeNames[i] = UserTreeWait.ElementAt(i).RecipeName;
}
SystemEventReport("WaitProcessRecipe", new { RecipeNames = recipeNames });//等待执行配方上报
}
else
{
SystemEventReport("WaitProcessRecipe", new { RecipeNames=new string[] { } });//等待执行配方上报
}
#endregion
#region 配方下发到PLC操作相关
//配方数据写入到输送机
var res = Json<LocalRecipe>.Data.Recipes.FirstOrDefault(p => p.RecipeName == CurrentRecipeName);


+ 1
- 1
DosingSystem/Model/DeviceInquire.cs Visa fil

@@ -423,7 +423,7 @@ namespace BPASmartClient.DosingSystem
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloUpperLimit = deviceStatus.DeviceAlarmCode.GetBitValue(8);
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloLowerLimit = deviceStatus.DeviceAlarmCode.GetBitValue(9);
Thread.Sleep(10);
if (ExcuteControl.GetInstance.AliyunIsConnect)
if (ExcuteControl.GetInstance.mqttCollection.ContainsKey($"Stock{IpAddress.Split(".")[3].Substring(0,1)}") && ExcuteControl.GetInstance.mqttCollection[$"Stock{IpAddress.Split(".")[3].Substring(0, 1)}"]._mqttClient.IsConnected)
{

StockPropertyReport();


+ 1
- 1
DosingSystem/ViewModel/NewRecipeViewModel.cs Visa fil

@@ -140,7 +140,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
Json<LocalRecipe>.Save();
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"新建配方成功!");
//配方名称集合上报
if (ExcuteControl.GetInstance.AliyunIsConnect)
if (ExcuteControl.GetInstance.mqttCollection.ContainsKey("Conveyer")&& ExcuteControl.GetInstance.mqttCollection["Conveyer"]._mqttClient.IsConnected)
{
AliyunSystemPropertyReportModel m1 = new AliyunSystemPropertyReportModel();
m1.RecipeCollection = new string[Json<LocalRecipe>.Data.Recipes.Count];


+ 12
- 0
DosingSystem/ViewModel/RecipeSettingsViewModel.cs Visa fil

@@ -2,6 +2,7 @@
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.DosingSystem.Model;
using BPASmartClient.DosingSystem.View;
using System.Collections.ObjectModel;
using System.Linq;
@@ -44,6 +45,17 @@ namespace BPASmartClient.DosingSystem.ViewModel
Json<LocalRecipe>.Save();
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方删除成功!");
MessageNotify.GetInstance.ShowUserLog($"删除配方 {res.RecipeName}");
//配方名称集合上报
if (ExcuteControl.GetInstance.AliyunIsConnect)
{
AliyunSystemPropertyReportModel m1 = new AliyunSystemPropertyReportModel();
m1.RecipeCollection = new string[Json<LocalRecipe>.Data.Recipes.Count];
for (int i = 0; i < Json<LocalRecipe>.Data.Recipes.Count; i++)
{
m1.RecipeCollection[i] = Json<LocalRecipe>.Data.Recipes[i].RecipeName;
}
ExcuteControl.GetInstance.SystemPropertyReport(m1);
}
}
else
{


+ 23
- 0
SmartClient.sln Visa fil

@@ -168,6 +168,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Test\Test.csproj",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "阿里云IOT平台测试", "阿里云IOT平台测试\阿里云IOT平台测试.csproj", "{774286FD-0C88-4592-972C-101239F75954}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.AliyunIot", "BPASmartClient.AliyunIot\BPASmartClient.AliyunIot.csproj", "{75CD8585-6D44-4291-9524-0B6CE22D3C74}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -1582,6 +1584,26 @@ Global
{774286FD-0C88-4592-972C-101239F75954}.Release|x64.Build.0 = Release|Any CPU
{774286FD-0C88-4592-972C-101239F75954}.Release|x86.ActiveCfg = Release|Any CPU
{774286FD-0C88-4592-972C-101239F75954}.Release|x86.Build.0 = Release|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Debug|ARM.ActiveCfg = Debug|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Debug|ARM.Build.0 = Debug|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Debug|ARM64.Build.0 = Debug|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Debug|x64.ActiveCfg = Debug|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Debug|x64.Build.0 = Debug|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Debug|x86.ActiveCfg = Debug|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Debug|x86.Build.0 = Debug|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Release|Any CPU.Build.0 = Release|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Release|ARM.ActiveCfg = Release|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Release|ARM.Build.0 = Release|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Release|ARM64.ActiveCfg = Release|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Release|ARM64.Build.0 = Release|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Release|x64.ActiveCfg = Release|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Release|x64.Build.0 = Release|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Release|x86.ActiveCfg = Release|Any CPU
{75CD8585-6D44-4291-9524-0B6CE22D3C74}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1659,6 +1681,7 @@ Global
{82D5C479-7C38-41D6-8B42-24D4EC32D94F} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
{918B73A6-B6FF-46FE-8C96-8474A5BD648B} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F}
{36E8EDC4-DD22-4968-B43A-984A5DDE5D78} = {8712125E-14CD-4E1B-A1CE-4BDE03805942}
{75CD8585-6D44-4291-9524-0B6CE22D3C74} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC}


Laddar…
Avbryt
Spara