@@ -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);