Selaa lähdekoodia

阿里云联调更新

煮面机(新)
Mr_z 1 vuosi sitten
vanhempi
commit
5e818a85b3
4 muutettua tiedostoa jossa 93 lisäystä ja 48 poistoa
  1. +16
    -11
      DosingSystem/ExcuteControl.cs
  2. +75
    -35
      DosingSystem/Model/DeviceInquire.cs
  3. +1
    -1
      DosingSystem/ViewModel/RecipeControlViewModel.cs
  4. +1
    -1
      DosingSystem/ViewModel/RecipeSettingsViewModel.cs

+ 16
- 11
DosingSystem/ExcuteControl.cs Näytä tiedosto

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

/// <summary>
/// 已完成的配方
@@ -375,7 +375,6 @@ namespace BPASmartClient.DosingSystem
mqdeviceTestProperty.Init();
var message = JsonConvert.SerializeObject(mqdeviceTestProperty);
var topic = $"/sys/{produtInfo.Get("ProductKey")}/{aliyun[ipaddres]}/thing/event/property/post";//发布主题

var topicReply = $"/sys/{produtInfo.Get("ProductKey")}/{aliyun[ipaddres]}/thing/event/property/post_reply";//订阅主题
if (mqttCollection.ContainsKey(aliyun[ipaddres]))
{
@@ -764,9 +763,9 @@ namespace BPASmartClient.DosingSystem
{
if (RecipeName != null)
{
var res = MessageNotify.GetInstance.ShowDialog($"是否取消配方 【{RecipeName}】制作", DialogType.Warning);
if (res)
{
//var res = MessageNotify.GetInstance.ShowDialog($"是否取消配方 【{RecipeName}】制作", DialogType.Warning);
//if (res)
//{
int index = Recipes.ToList().FindIndex(p => p.RecipeName == RecipeName);
if (index >= 0 && index < Recipes.Count)
{
@@ -781,7 +780,10 @@ namespace BPASmartClient.DosingSystem
Thread.Sleep(1000);
SiemensDevice.GetInstance.MySiemens.Write("M10.5", false);
MessageNotify.GetInstance.ShowRunLog($"M10.5:false");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方 [{RecipeName}] 取消成功");
App.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方 [{RecipeName}] 取消成功");
});
MessageNotify.GetInstance.ShowUserLog($"取消配方制作 {RecipeName}");
//取消成功
}));
@@ -790,11 +792,11 @@ namespace BPASmartClient.DosingSystem
{
//取消失败
}
}
//}
}
else
{
//取消失败
MessageNotify.GetInstance.ShowUserLog($"配方 {RecipeName}取消失败");
}

}
@@ -834,9 +836,9 @@ namespace BPASmartClient.DosingSystem
RecipeNames.Enqueue(RecipeName);

var res = Recipes.FirstOrDefault(p => p.RecipeName == RecipeName);
UserTreeWait.Add(new RecipeModel { RecipStatus = "等待制作", SerialNum = UserTreeWait.Count + 1, RecipeName = RecipeName, RawMaterials = res.RawMaterials });
App.Current.Dispatcher.Invoke(() => { UserTreeWait.Add(new RecipeModel { RecipStatus = "等待制作", SerialNum = UserTreeWait.Count + 1, RecipeName = RecipeName, RawMaterials = res.RawMaterials }); });
}
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!");
App.Current.Dispatcher.Invoke(() => { NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); });

}
/// <summary>
@@ -857,7 +859,10 @@ namespace BPASmartClient.DosingSystem
App.Current.Dispatcher.Invoke(new Action(() =>
{
recipeProcesses.Clear();
if (UserTreeWait.Count > 0) UserTreeWait.RemoveAt(0);
if (UserTreeWait.Count > 0) App.Current.Dispatcher.Invoke(() =>
{
UserTreeWait.RemoveAt(0);
});
}));
CurrentRecipeName = Recipes.ElementAt(index).RecipeName;
#region 执行配方以及等待执行配方上报


+ 75
- 35
DosingSystem/Model/DeviceInquire.cs Näytä tiedosto

@@ -352,62 +352,62 @@ namespace BPASmartClient.DosingSystem
AlarmHelper<AlarmInfo>.Init();
if (IsConnected)
{
TaskManage.GetInstance.StartLong(new Action(() =>
{
var dn = modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20);
if (dn.IsSuccess) { this.DeviceName = dn.Content.Trim().Replace(" ", ""); deviceStatus.DeviceName = this.DeviceName; }

//获取设备运行状态
var rs = this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd());
var rs = this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (rs.IsSuccess) deviceStatus.RunStatus = rs.Content;

////获取设备料仓剩余重量
var wf = this.modbusTcp.Read<uint>(DeviceAddress.WeightFeedback.ToAdd());
var wf = this.modbusTcp.Read<uint>(DeviceAddress.WeightFeedback.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (wf.IsSuccess) deviceStatus.WeightFeedback = (float)(wf.Content);

////获取下料重量
var nwf = this.modbusTcp.Read<float>(DeviceAddress.CutWeightFeedback.ToAdd());
var nwf = this.modbusTcp.Read<float>(DeviceAddress.CutWeightFeedback.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (nwf.IsSuccess) deviceStatus.NowWeightFeedback = nwf.Content;

////获取设备编号
var dnum = this.modbusTcp.Read<ushort>(DeviceAddress.DeviceNum.ToAdd());
var dnum = this.modbusTcp.Read<ushort>(DeviceAddress.DeviceNum.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (dnum.IsSuccess) deviceStatus.DeviceNum = dnum.Content;

////获取设备故障编码
var dac = this.modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd());
var dac = this.modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (dac.IsSuccess) deviceStatus.DeviceAlarmCode = dac.Content;

//获取原料类型
var mt = this.modbusTcp.Read<ushort>(DeviceAddress.MaterialDeviceType.ToAdd());
var mt = this.modbusTcp.Read<ushort>(DeviceAddress.MaterialDeviceType.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (mt.IsSuccess) deviceStatus.RawMaterialType = mt.Content;

//获取工作模式
var wm = this.modbusTcp.Read<ushort>(DeviceAddress.WorkModel.ToAdd());
var wm = this.modbusTcp.Read<ushort>(DeviceAddress.WorkModel.ToAdd(),1, BPA.Helper.DataFormat.CDAB);
if (wm.IsSuccess) deviceStatus.WorkModel = wm.Content.GetBitValue(1);
//慢加重量
var ssaw = this.modbusTcp.Read<float>(DeviceAddress.SlowlyAddWeight.ToAdd());
var ssaw = this.modbusTcp.Read<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (ssaw.IsSuccess) deviceStatus.SlowAddWeight = ssaw.Content;
//提前关阀重量
var pcvw = this.modbusTcp.Read<float>(DeviceAddress.PreCloseValveWeight.ToAdd());
var pcvw = this.modbusTcp.Read<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (pcvw.IsSuccess) deviceStatus.PreCloseValueWeight = pcvw.Content;
//快加速度
var ra = this.modbusTcp.Read<uint>(DeviceAddress.RapidAcceleration.ToAdd());
var ra = this.modbusTcp.Read<uint>(DeviceAddress.RapidAcceleration.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (ra.IsSuccess) deviceStatus.RapidAcceleration = ra.Content;
//慢加速度
var sa = this.modbusTcp.Read<uint>(DeviceAddress.SlowAcceleration.ToAdd());
var sa = this.modbusTcp.Read<uint>(DeviceAddress.SlowAcceleration.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (sa.IsSuccess) deviceStatus.SlowAcceleration = sa.Content;
//伺服手动速度
var sms = this.modbusTcp.Read<uint>(DeviceAddress.ServoManualSpeed.ToAdd());
var sms = this.modbusTcp.Read<uint>(DeviceAddress.ServoManualSpeed.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (sms.IsSuccess) deviceStatus.ServoManualSpeed = sms.Content;
//料仓上限重量
var ulw = this.modbusTcp.Read<uint>(DeviceAddress.SiloUpperLimitWeight.ToAdd());
var ulw = this.modbusTcp.Read<uint>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (ulw.IsSuccess) deviceStatus.SiloUpperLimitWeight = ulw.Content;
//料仓下限重量
var llw = this.modbusTcp.Read<uint>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd());
var llw = this.modbusTcp.Read<uint>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (llw.IsSuccess) deviceStatus.SiloLowerLimitWeight = llw.Content;
//料仓搅拌速度
var ss = this.modbusTcp.Read<uint>(DeviceAddress.StirringSpeed.ToAdd());
var ss = this.modbusTcp.Read<uint>(DeviceAddress.StirringSpeed.ToAdd(), 1, BPA.Helper.DataFormat.CDAB);
if (ss.IsSuccess) deviceStatus.StirringSpeed = ss.Content;
//this.DeviceName = modbusTcp.Read<string>(DeviceAddress.DeviceName.ToAdd(), 20).Content.Trim().Replace(" ", "");
//deviceStatus.RunStatus = (ushort)this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd()).Content; //获取设备运行状态
@@ -422,15 +422,21 @@ namespace BPASmartClient.DosingSystem
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop2 = deviceStatus.DeviceAlarmCode.GetBitValue(7);
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloUpperLimit = deviceStatus.DeviceAlarmCode.GetBitValue(8);
AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloLowerLimit = deviceStatus.DeviceAlarmCode.GetBitValue(9);
Thread.Sleep(10);
if (ExcuteControl.GetInstance.mqttCollection.ContainsKey($"Stock{IpAddress.Split(".")[3].Substring(0,1)}") && ExcuteControl.GetInstance.mqttCollection[$"Stock{IpAddress.Split(".")[3].Substring(0, 1)}"]._mqttClient.IsConnected)
}), $"{DeviceName} 开始监听", true);
TaskManage.GetInstance.StartLong(new Action(() =>
{
Thread.Sleep(1000);
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();
StockEventReport();
}
Thread.Sleep(10);
}), $"{DeviceName} 开始监听", true);
}),$"{DeviceName}属性实时上报",true);
}
}
/// <summary>
@@ -504,26 +510,60 @@ namespace BPASmartClient.DosingSystem
public void StockEventReport()
{
#if !Debug
if (ExcuteControl.GetInstance.AliyunIsConnect && RTrig.GetInstance("stop1").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop1))
try
{
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockJerk1StatusEvent", AliyunMaterialModelType.StockModel);
}
if (ExcuteControl.GetInstance.AliyunIsConnect && RTrig.GetInstance("Servo").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).Servo))
{
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockServoFalutEvent", AliyunMaterialModelType.StockModel);
}
if (RTrig.GetInstance($"stop1:{IpAddress}").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop1))
{
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockJerk1StatusEvent", AliyunMaterialModelType.StockModel);
}
if (RTrig.GetInstance($"Servo:{IpAddress}").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).Servo))
{
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockServoFalutEvent", AliyunMaterialModelType.StockModel);
}

if (ExcuteControl.GetInstance.AliyunIsConnect && RTrig.GetInstance("EStop2").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop2))
{
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockJerk2StatusEvent", AliyunMaterialModelType.StockModel);
}
if (ExcuteControl.GetInstance.AliyunIsConnect && RTrig.GetInstance("SiloUpperLimit").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloUpperLimit))
{
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockUpLimitEvent", AliyunMaterialModelType.StockModel);
if (RTrig.GetInstance($"EStop2:{IpAddress}").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop2))
{

ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockJerk2StatusEvent", AliyunMaterialModelType.StockModel);
}
if (RTrig.GetInstance($"SiloUpperLimit:{IpAddress}").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloUpperLimit))
{
if (DeviceName == "盐")
MessageNotify.GetInstance.ShowRunLog("料仓1 上限报警");
if (DeviceName == "A20")
MessageNotify.GetInstance.ShowRunLog("料仓2 上限报警");
if (DeviceName == "A30")
MessageNotify.GetInstance.ShowRunLog("料仓3 上限报警");
if (DeviceName == "A40")
MessageNotify.GetInstance.ShowRunLog("料仓4 上限报警");
if (DeviceName == "A50")
MessageNotify.GetInstance.ShowRunLog("料仓5 上限报警");
if (DeviceName == "A60")
MessageNotify.GetInstance.ShowRunLog("料仓6 上限报警");
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockUpLimitEvent", AliyunMaterialModelType.StockModel);
}
if (RTrig.GetInstance($"SiloLowerLimit:{IpAddress}").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloLowerLimit))
{
if (DeviceName == "盐")
MessageNotify.GetInstance.ShowRunLog("料仓1 下限报警");
if (DeviceName == "A20")
MessageNotify.GetInstance.ShowRunLog("料仓2 下限报警");
if (DeviceName == "A30")
MessageNotify.GetInstance.ShowRunLog("料仓3 下限报警");
if (DeviceName == "A40")
MessageNotify.GetInstance.ShowRunLog("料仓4 下限报警");
if (DeviceName == "A50")
MessageNotify.GetInstance.ShowRunLog("料仓5 下限报警");
if (DeviceName == "A60")
MessageNotify.GetInstance.ShowRunLog("料仓6 下限报警");
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockDownLimitEvent", AliyunMaterialModelType.StockModel);

}
}
if (ExcuteControl.GetInstance.AliyunIsConnect && RTrig.GetInstance("SiloLowerLimit").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloLowerLimit))
catch (Exception)
{
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockDownLimitEvent", AliyunMaterialModelType.StockModel);

//throw;
}
#endif
#if Debug


+ 1
- 1
DosingSystem/ViewModel/RecipeControlViewModel.cs Näytä tiedosto

@@ -1000,7 +1000,7 @@ namespace BPASmartClient.DosingSystem.ViewModel

public BPARelayCommand<object> CancelRecipeCommand { get; set; }

//public static ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocalRecipe>.Data.Recipes;
public static ObservableCollection<RecipeModel> Recipes { get; set; } =ExcuteControl.GetInstance.Recipes;

// public static string CurrentRecipeName { get { return _RecipeName; } set { _RecipeName = value; OnStaticPropertyChanged(); } }
// private static string _RecipeName;


+ 1
- 1
DosingSystem/ViewModel/RecipeSettingsViewModel.cs Näytä tiedosto

@@ -46,7 +46,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方删除成功!");
MessageNotify.GetInstance.ShowUserLog($"删除配方 {res.RecipeName}");
//配方名称集合上报
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];


Ladataan…
Peruuta
Tallenna