Autor | SHA1 | Zpráva | Datum |
---|---|---|---|
Mr_z | 84fb2cfd6c | Merge branch 'reconfiguration' of http://111.9.47.105:10244/bpa/BPASmartClient into reconfiguration | před 1 rokem |
Mr_z | 8079a30c82 | 柔性配料系统接入阿里云Iot | před 1 rokem |
@@ -57,19 +57,27 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||
BPA.Helper.MessageLog.GetInstance.NotifyShow = new Action<string>((o) => | |||
{ | |||
Application.Current?.Dispatcher?.Invoke(() => | |||
try | |||
{ | |||
//ff20aefe | |||
var temp = new MessageModel() | |||
{ | |||
LogInfo = o, | |||
Forground = new SolidColorBrush(Color.FromArgb(255, 32, 174, 254)) | |||
}; | |||
if (DebugLogViewModel.MessageModels.Count > 0) | |||
DebugLogViewModel.MessageModels.Insert(0, temp); | |||
else | |||
DebugLogViewModel.MessageModels.Add(temp); | |||
}); | |||
Application.Current?.Dispatcher?.Invoke(() => | |||
{ | |||
//ff20aefe | |||
var temp = new MessageModel() | |||
{ | |||
LogInfo = o, | |||
Forground = new SolidColorBrush(Color.FromArgb(255, 32, 174, 254)) | |||
}; | |||
if (DebugLogViewModel.MessageModels.Count > 0) | |||
DebugLogViewModel.MessageModels.Insert(0, temp); | |||
else | |||
DebugLogViewModel.MessageModels.Add(temp); | |||
}); | |||
} | |||
catch (Exception) | |||
{ | |||
//throw; | |||
} | |||
}); | |||
BPA.Helper.MessageLog.GetInstance.NotifyShowEx = new Action<string>((o) => | |||
{ | |||
@@ -1,6 +1,63 @@ | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<configuration> | |||
<appSettings> | |||
<add key="IP" value="192.168.0.15"/> | |||
</appSettings> | |||
<configSections> | |||
<sectionGroup name="FlexBatchSystem"> | |||
<section name="ProductInfo" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="MqttInfo" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="ConveyerInfo" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo1" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo2" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo3" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo4" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo5" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo6" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="Services" type="System.Configuration.NameValueSectionHandler"/> | |||
</sectionGroup> | |||
</configSections> | |||
<FlexBatchSystem> | |||
<ProductInfo> | |||
<add key="ProductKey" value="j090GlJPJNv"/> | |||
<add key="ProductSecret" value="OVTPKMuGlBLZRBFt"/> | |||
<add key="Stock" value="StockModel"/> | |||
<add key="Conveyer" value="ConveyerModel"/> | |||
</ProductInfo> | |||
<MqttInfo> | |||
<add key="mqttHostUrl" value="iot-06z00carjduqaue.mqtt.iothub.aliyuncs.com"/> | |||
</MqttInfo> | |||
<ConveyerInfo> | |||
<add key="DeviceName" value="Conveyer"/> | |||
<add key="DeviceSecret" value="b3df8aaa82de59f478dffb172acf78cd"/> | |||
</ConveyerInfo> | |||
<StockInfo1> | |||
<add key="DeviceName" value="Stock1"/> | |||
<add key="DeviceSecret" value="b0928d8f6e36aabd94f0fce3f9b02536"/> | |||
</StockInfo1> | |||
<StockInfo2> | |||
<add key="DeviceName" value="Stock2"/> | |||
<add key="DeviceSecret" value="8373c57ddc6cd134b19cd89fad564157"/> | |||
</StockInfo2> | |||
<StockInfo3> | |||
<add key="DeviceName" value="Stock3"/> | |||
<add key="DeviceSecret" value="83f1457dbbb3c155d512c7a632d4c033"/> | |||
</StockInfo3> | |||
<StockInfo4> | |||
<add key="DeviceName" value="Stock4"/> | |||
<add key="DeviceSecret" value="9f9d37bebfc94900613890a294f1302d"/> | |||
</StockInfo4> | |||
<StockInfo5> | |||
<add key="DeviceName" value="Stock5"/> | |||
<add key="DeviceSecret" value="7ce871f33f86e9b71d30bdaa39899169"/> | |||
</StockInfo5> | |||
<StockInfo6> | |||
<add key="DeviceName" value="Stock6"/> | |||
<add key="DeviceSecret" value="f18b9d31180c7b7e32508b255c418d07"/> | |||
</StockInfo6> | |||
<Services> | |||
<add key="Service1" value="RunControlService"/> | |||
<add key="Service2" value="StockAirControlService"/> | |||
<add key="Service3" value="RecipeSendService"/> | |||
<add key="Service4" value="CancelRecipeService"/> | |||
</Services> | |||
</FlexBatchSystem> | |||
</configuration> |
@@ -1,25 +1,17 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.Linq; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.Pages.Enums; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.CustomResource.Pages.View; | |||
using BPASmartClient.CustomResource.Pages.ViewModel; | |||
using BPASmartClient.DosingSystem.View; | |||
using BPA.Helper; | |||
using BPASmartClient.DosingSystem.Model; | |||
using System; | |||
using System.Collections.ObjectModel; | |||
using System.Collections.Specialized; | |||
using System.Configuration; | |||
using System.Diagnostics; | |||
using System.IO; | |||
using BPASmartClient.Update.Model; | |||
using BPASmartClient.DosingSystem.ViewModel; | |||
using System.Drawing; | |||
using System.Windows.Media; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -28,12 +20,15 @@ namespace BPASmartClient.DosingSystem | |||
/// </summary> | |||
public partial class App : Application | |||
{ | |||
public static Window MainWindow; | |||
public ExcuteControl excute; | |||
public EventWaitHandle ProgramStarted { get; set; } | |||
protected override void OnStartup(StartupEventArgs e) | |||
protected override async void OnStartup(StartupEventArgs e) | |||
{ | |||
bool createNew; | |||
MessageLog.GetInstance.NotifyShow = new Action<string>(o => | |||
{ | |||
DebugLogViewModel.MessageModels.Add(new MessageModel() | |||
@@ -60,6 +55,7 @@ namespace BPASmartClient.DosingSystem | |||
base.OnStartup(e); | |||
SystemHelper.GetInstance.CreateDesktopShortcut(); | |||
DataInit(); | |||
await Task.Run(() => { excute = ExcuteControl.GetInstance; }); | |||
MenuInit(); | |||
//SiemensTest.GetInstance.Init(); | |||
DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 | |||
@@ -101,11 +97,13 @@ namespace BPASmartClient.DosingSystem | |||
protected override void OnExit(ExitEventArgs e) | |||
{ | |||
base.OnExit(e); | |||
excute?.MqttDisConnect(); | |||
Json<LocalRecipe>.Save(); | |||
Json<DevicePar>.Save(); | |||
Json<LocaMaterial>.Save(); | |||
BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.LogSave(); | |||
TaskManage.GetInstance.Dispose(); | |||
//Process.GetCurrentProcess().Kill(); | |||
} | |||
private void MenuInit() | |||
@@ -1,6 +0,0 @@ | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<configuration> | |||
<appSettings> | |||
<add key="" value=""/> | |||
</appSettings> | |||
</configuration> |
@@ -12,7 +12,6 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<None Remove="App.config" /> | |||
<None Remove="tsconfig1.json" /> | |||
</ItemGroup> | |||
@@ -21,8 +20,10 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Communication" Version="1.0.116" /> | |||
<PackageReference Include="BPA.Message" Version="1.0.86" /> | |||
<PackageReference Include="BPA.Communication" Version="1.0.117" /> | |||
<PackageReference Include="BPA.PahoMQ" Version="1.0.8"> | |||
<Aliases>aliyun</Aliases> | |||
</PackageReference> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |||
</ItemGroup> | |||
@@ -1,9 +1,5 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Globalization; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows.Data; | |||
using System.Windows.Media; | |||
@@ -1,9 +1,5 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Globalization; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows.Data; | |||
namespace BPASmartClient.DosingSystem.Converter | |||
@@ -35,7 +31,7 @@ namespace BPASmartClient.DosingSystem.Converter | |||
{ | |||
if (tempValue == 0) return true; | |||
if (tempValue == 1) return false; | |||
} | |||
return true; | |||
} | |||
@@ -1,9 +1,4 @@ | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -0,0 +1,21 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
public class AliyunConveyerPropertyReportModel | |||
{ | |||
//private static AliyunConveyerPropertyReportModel Instance; | |||
//public static AliyunConveyerPropertyReportModel GetInstance=>Instance??=new AliyunConveyerPropertyReportModel(); | |||
public int ConveyerOnlineStatus { get; set; } | |||
public int ButtonBucketSigleCheck { get; set; } | |||
public int TopBucketSigleCheck { get; set; } | |||
public int WorkModel { get; set; } | |||
public int RunStatus { get; set; } | |||
public int TopBucketControlStatus { get; set; } | |||
public int DownBucketControlStatus { get; set; } | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
/// <summary> | |||
/// 阿里云物模型模板类型 | |||
/// </summary> | |||
public enum AliyunMaterialModelType | |||
{ | |||
// DefaultModel,//默认模板 | |||
StockModel,//料仓模板 | |||
ConveyerModel//输送线模板 | |||
} | |||
} |
@@ -0,0 +1,16 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
public class AliyunStockEventReportModel | |||
{ | |||
/// <summary> | |||
/// 触发值 | |||
/// </summary> | |||
public string Result { get; set; } | |||
} | |||
} |
@@ -0,0 +1,37 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
public class AliyunStockPropertyReportModel | |||
{ | |||
public int StockRealWeight { get; set; } | |||
public float BucketRealWeight { get; set; } | |||
public string StockBatchStatus { get; set; } | |||
public int StockWorkModel { get; set; } | |||
public string StockMaterialType { get; set; } | |||
public int StockDeviceNum { get; set; } | |||
public string StockDeviceName { get; set; } | |||
public float StockSlowlyAddWeight { get; set; } | |||
public float StockPreCloseValueWeight { get; set; } | |||
public int StockRapidAcceleration { get; set; } | |||
public int StockSlowAcceleration { get; set; } | |||
public int StockServoManualSpeed { get; set; } | |||
public int StockUpperLimitWeight { get; set; } | |||
public int StockLowerLimitWeight { get; set; } | |||
public int StockStirringSpeed { get; set; } | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
public class AliyunSystemReportModel | |||
{ | |||
public string RecipeName { get; set; } | |||
} | |||
} |
@@ -1,16 +1,10 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
public enum ConveryType | |||
{ | |||
U型, | |||
直线型, | |||
} | |||
} |
@@ -1,10 +1,5 @@ | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -1,9 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -1,10 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
public class DeviceAddress | |||
{ | |||
@@ -13,6 +7,7 @@ namespace BPASmartClient.DosingSystem | |||
/// </summary> | |||
public static string DeviceName { get; set; } = "LW0"; | |||
public static string WorkModel { get; set; } = "LW50"; | |||
/// <summary> | |||
/// 料仓重量反馈起始地址 | |||
/// </summary> | |||
@@ -1,10 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using BPA.Helper; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -1,4 +1,8 @@ | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
//#define Debug | |||
using BPA.Communication; | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.DosingSystem.Model; | |||
using BPASmartClient.DosingSystem.ViewModel; | |||
//using BPASmartClient.Modbus; | |||
using BPASmartClient.Model; | |||
@@ -6,15 +10,12 @@ using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Diagnostics; | |||
using System.Linq; | |||
using System.Net.NetworkInformation; | |||
using System.Reflection; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Text.RegularExpressions; | |||
using BPA.Communication; | |||
using BPASmartClient.DosingSystem.Model; | |||
using Google.Protobuf.WellKnownTypes; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -204,7 +205,7 @@ namespace BPASmartClient.DosingSystem | |||
} | |||
} | |||
}*/ | |||
stockCount = Json<DevicePar>.Data.BaseParModel.StockCount; | |||
stockCount = Json<DevicePar>.Data.BaseParModel.StockCount; | |||
for (int i = 0; i < stockCount; i++) | |||
{ | |||
IPLists.Add($"{IPSegment}{(i + 1) * 10}"); | |||
@@ -242,7 +243,7 @@ namespace BPASmartClient.DosingSystem | |||
{ | |||
devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip }); | |||
//2023/7/3调整 | |||
if (stockCount<=8||(stockCount>8&&TopDeviceCurrentStatuses.Count <= stockCount / 2 + 1 &&int.TryParse( ip.Split('.')[3],out int res)&&res<= (stockCount / 2 + 1)*10)) | |||
if (stockCount <= 8 || (stockCount > 8 && TopDeviceCurrentStatuses.Count <= stockCount / 2 + 1 && int.TryParse(ip.Split('.')[3], out int res) && res <= (stockCount / 2 + 1) * 10)) | |||
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | |||
else | |||
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | |||
@@ -351,10 +352,11 @@ 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(" ", ""); | |||
if (dn.IsSuccess) { this.DeviceName = dn.Content.Trim().Replace(" ", ""); deviceStatus.DeviceName = this.DeviceName; } | |||
//获取设备运行状态 | |||
var rs = this.modbusTcp.Read<ushort>(DeviceAddress.RunStatus.ToAdd()); | |||
@@ -376,7 +378,37 @@ namespace BPASmartClient.DosingSystem | |||
var dac = this.modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd()); | |||
if (dac.IsSuccess) deviceStatus.DeviceAlarmCode = dac.Content; | |||
//获取原料类型 | |||
var mt = this.modbusTcp.Read<ushort>(DeviceAddress.MaterialDeviceType.ToAdd()); | |||
if (mt.IsSuccess) deviceStatus.RawMaterialType = mt.Content; | |||
//获取工作模式 | |||
var wm = this.modbusTcp.Read<ushort>(DeviceAddress.WorkModel.ToAdd()); | |||
if (wm.IsSuccess) deviceStatus.WorkModel = wm.Content.GetBitValue(1); | |||
//慢加重量 | |||
var ssaw = this.modbusTcp.Read<float>(DeviceAddress.SlowlyAddWeight.ToAdd()); | |||
if (ssaw.IsSuccess) deviceStatus.SlowAddWeight = ssaw.Content; | |||
//提前关阀重量 | |||
var pcvw = this.modbusTcp.Read<float>(DeviceAddress.PreCloseValveWeight.ToAdd()); | |||
if (pcvw.IsSuccess) deviceStatus.PreCloseValueWeight = pcvw.Content; | |||
//快加速度 | |||
var ra = this.modbusTcp.Read<uint>(DeviceAddress.RapidAcceleration.ToAdd()); | |||
if (ra.IsSuccess) deviceStatus.RapidAcceleration = ra.Content; | |||
//慢加速度 | |||
var sa = this.modbusTcp.Read<uint>(DeviceAddress.SlowAcceleration.ToAdd()); | |||
if (sa.IsSuccess) deviceStatus.SlowAcceleration = sa.Content; | |||
//伺服手动速度 | |||
var sms = this.modbusTcp.Read<uint>(DeviceAddress.ServoManualSpeed.ToAdd()); | |||
if (sms.IsSuccess) deviceStatus.ServoManualSpeed = sms.Content; | |||
//料仓上限重量 | |||
var ulw = this.modbusTcp.Read<uint>(DeviceAddress.SiloUpperLimitWeight.ToAdd()); | |||
if (ulw.IsSuccess) deviceStatus.SiloUpperLimitWeight = ulw.Content; | |||
//料仓下限重量 | |||
var llw = this.modbusTcp.Read<uint>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd()); | |||
if (llw.IsSuccess) deviceStatus.SiloLowerLimitWeight = llw.Content; | |||
//料仓搅拌速度 | |||
var ss = this.modbusTcp.Read<uint>(DeviceAddress.StirringSpeed.ToAdd()); | |||
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; //获取设备运行状态 | |||
//deviceStatus.WeightFeedback = (float)this.modbusTcp.Read<uint>(DeviceAddress.WeightFeedback.ToAdd()).Content;//获取设备料仓剩余重量 | |||
@@ -391,10 +423,115 @@ 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) | |||
{ | |||
StockPropertyReport(); | |||
StockEventReport(); | |||
} | |||
Thread.Sleep(10); | |||
}), $"{DeviceName} 开始监听", true); | |||
} | |||
} | |||
/// <summary> | |||
/// 料仓属性上报 | |||
/// </summary> | |||
public void StockPropertyReport() | |||
{ | |||
#if !Debug | |||
AliyunStockPropertyReportModel model = new AliyunStockPropertyReportModel(); | |||
model.StockRealWeight = (int)deviceStatus.WeightFeedback; | |||
model.BucketRealWeight = deviceStatus.NowWeightFeedback; | |||
model.StockDeviceNum = (int)deviceStatus.DeviceNum; | |||
model.StockDeviceName = deviceStatus.DeviceName; | |||
model.StockWorkModel = deviceStatus.WorkModel == true ? 1 : 0; | |||
model.StockSlowlyAddWeight = deviceStatus.SlowAddWeight; | |||
model.StockPreCloseValueWeight = deviceStatus.PreCloseValueWeight; | |||
model.StockRapidAcceleration = (int)deviceStatus.RapidAcceleration; | |||
model.StockSlowAcceleration = (int)deviceStatus.SlowAcceleration; | |||
model.StockServoManualSpeed = (int)deviceStatus.ServoManualSpeed; | |||
model.StockUpperLimitWeight = (int)deviceStatus.SiloUpperLimitWeight; | |||
model.StockLowerLimitWeight = (int)deviceStatus.SiloLowerLimitWeight; | |||
model.StockStirringSpeed = (int)deviceStatus.StirringSpeed; | |||
switch (deviceStatus.RawMaterialType) | |||
{ | |||
case 1: | |||
model.StockMaterialType = "膏体"; break; | |||
case 2: | |||
model.StockMaterialType = "液体"; break; | |||
case 3: | |||
model.StockMaterialType = "粉体"; break; | |||
} | |||
switch (deviceStatus.RunStatus) | |||
{ | |||
case 0: | |||
model.StockBatchStatus = "待机"; break; | |||
case 1: | |||
model.StockBatchStatus = "等待配料"; break; | |||
case 2: | |||
model.StockBatchStatus = "配料中"; break; | |||
case 3: | |||
model.StockBatchStatus = "配料完成"; break; | |||
} | |||
#endif | |||
#if Debug | |||
//本地模拟测试 | |||
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 = "待机"; | |||
ExcuteControl.GetInstance.StokcPropertyReport(IpAddress, model); | |||
#endif | |||
} | |||
/// <summary> | |||
/// 事件上报 | |||
/// </summary> | |||
public void StockEventReport() | |||
{ | |||
#if !Debug | |||
if (ExcuteControl.GetInstance.AliyunIsConnect && RTrig.GetInstance("stop1").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).EStop1)) | |||
{ | |||
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 (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 (ExcuteControl.GetInstance.AliyunIsConnect && RTrig.GetInstance("SiloLowerLimit").Start(AlarmHelper<AlarmInfo>.GetInstance(DeviceName).SiloLowerLimit)) | |||
{ | |||
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockDownLimitEvent", AliyunMaterialModelType.StockModel); | |||
} | |||
#endif | |||
#if Debug | |||
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockJerk1StatusEvent", AliyunMaterialModelType.StockModel); | |||
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockServoFalutEvent", AliyunMaterialModelType.StockModel); | |||
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockJerk2StatusEvent", AliyunMaterialModelType.StockModel); | |||
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockUpLimitEvent", AliyunMaterialModelType.StockModel); | |||
ExcuteControl.GetInstance.AliyunEventReport(IpAddress, new AliyunStockEventReportModel { Result = "1" }, "StockDownLimitEvent", AliyunMaterialModelType.StockModel); | |||
#endif | |||
} | |||
public void SetDeviceName(string name) | |||
{ | |||
this.modbusTcp.Write(DeviceAddress.DeviceName.ToAdd(), new ushort[20]); | |||
@@ -403,7 +540,7 @@ namespace BPASmartClient.DosingSystem | |||
public void StatusReset() | |||
{ | |||
// prop1: | |||
// prop1: | |||
this.modbusTcp.Write(DeviceAddress.FinfishStatus.ToAdd(), (ushort)1); | |||
//MessageNotify.GetInstance.ShowRunLog($"料仓复位,值:{1}"); | |||
//var value = this.modbusTcp.Read<ushort>(DeviceAddress.FinfishStatus.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; | |||
@@ -422,17 +559,17 @@ namespace BPASmartClient.DosingSystem | |||
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName); | |||
if (res != null) | |||
{ | |||
//modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), res.SlowlyAddWeight); | |||
//modbusTcp.Write(DeviceAddress.PreCloseValveWeight.ToAdd(), res.PreCloseValveWeight); | |||
//modbusTcp.Write(DeviceAddress.RapidAcceleration.ToAdd(), (uint)res.RapidAcceleration); | |||
//modbusTcp.Write(DeviceAddress.SlowAcceleration.ToAdd(), (uint)res.SlowAcceleration); | |||
//modbusTcp.Write(DeviceAddress.ServoManualSpeed.ToAdd(), (uint)res.ServoManualSpeed); | |||
//modbusTcp.Write(DeviceAddress.SiloUpperLimitWeight.ToAdd(), (uint)res.SiloUpperLimitWeight); | |||
//modbusTcp.Write(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), (uint)res.LowerLimitWeightOfSilo); | |||
//modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), (uint)res.StirringSpeed); | |||
//MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成"); | |||
//modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), res.SlowlyAddWeight); | |||
//modbusTcp.Write(DeviceAddress.PreCloseValveWeight.ToAdd(), res.PreCloseValveWeight); | |||
//modbusTcp.Write(DeviceAddress.RapidAcceleration.ToAdd(), (uint)res.RapidAcceleration); | |||
//modbusTcp.Write(DeviceAddress.SlowAcceleration.ToAdd(), (uint)res.SlowAcceleration); | |||
//modbusTcp.Write(DeviceAddress.ServoManualSpeed.ToAdd(), (uint)res.ServoManualSpeed); | |||
//modbusTcp.Write(DeviceAddress.SiloUpperLimitWeight.ToAdd(), (uint)res.SiloUpperLimitWeight); | |||
//modbusTcp.Write(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), (uint)res.LowerLimitWeightOfSilo); | |||
//modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), (uint)res.StirringSpeed); | |||
//MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成"); | |||
prop1: | |||
modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), res.SlowlyAddWeight); | |||
@@ -481,7 +618,7 @@ namespace BPASmartClient.DosingSystem | |||
modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量 | |||
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value}"); | |||
var value9 = modbusTcp.Read<float>(DeviceAddress.WeightSet.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; | |||
var value9 = modbusTcp.Read<float>(DeviceAddress.WeightSet.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content; | |||
if ((value9 != null && value9.ToString() != Value.ToString()) || value9 == 0) goto prop9; | |||
//prop10: | |||
//MessageNotify.GetInstance.ShowRunLog($"写入配方重量,值{Value}:{value9}"); | |||
@@ -507,10 +644,11 @@ namespace BPASmartClient.DosingSystem | |||
}); | |||
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value},味魔方启动配料"); | |||
} | |||
} | |||
static string DecToBinary(int a) | |||
{ | |||
int r; | |||
@@ -1,8 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
@@ -1,10 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
public class GlobalDevice | |||
{ | |||
@@ -1,9 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
namespace BPASmartClient.DosingSystem | |||
@@ -1,10 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
public class RawMaterialDeviceStatus | |||
{ | |||
@@ -61,5 +55,46 @@ namespace BPASmartClient.DosingSystem | |||
/// </summary> | |||
public ushort DeviceNum { get; set; } | |||
/// <summary> | |||
/// 原料名称 | |||
/// </summary> | |||
public string DeviceName { get; set; } | |||
/// <summary> | |||
/// 工作模式0:手动 1:自动 | |||
/// </summary> | |||
public bool WorkModel { get; set; } | |||
/// <summary> | |||
/// 慢加重量 | |||
/// </summary> | |||
public float SlowAddWeight { get; set; } | |||
/// <summary> | |||
/// 提前关阀重量 | |||
/// </summary> | |||
public float PreCloseValueWeight { get; set; } | |||
/// <summary> | |||
/// 快加速度 | |||
/// </summary> | |||
public uint RapidAcceleration { get; set; } | |||
/// <summary> | |||
/// 慢加速度 | |||
/// </summary> | |||
public uint SlowAcceleration { get; set; } | |||
/// <summary> | |||
/// 伺服手动速度 | |||
/// </summary> | |||
public uint ServoManualSpeed { get; set; } | |||
/// <summary> | |||
/// 料仓上限重量 | |||
/// </summary> | |||
public uint SiloUpperLimitWeight { get; set; } | |||
/// <summary> | |||
/// 料仓下限重量 | |||
/// </summary> | |||
public uint SiloLowerLimitWeight { get; set; } | |||
/// <summary> | |||
/// 搅拌速度 | |||
/// </summary> | |||
public uint StirringSpeed { get; set; } | |||
} | |||
} |
@@ -1,12 +1,7 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using BPA.Helper; | |||
using BPASmartClient.Model; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Model; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -1,9 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -1,10 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.Model | |||
namespace BPASmartClient.DosingSystem.Model | |||
{ | |||
public class ComputerToPlc | |||
@@ -1,10 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
/// <summary> | |||
/// PLC 到上位机数据 | |||
@@ -1,9 +1,4 @@ | |||
using BPA.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -42,7 +37,7 @@ namespace BPASmartClient.DosingSystem | |||
/// <summary> | |||
/// 是否故障报警 | |||
/// </summary> | |||
public bool IsFault { get { return _isFault; } set { _isFault = value; OnPropertyChanged(); } } | |||
public bool IsFault { get { return _isFault; } set { _isFault = value; OnPropertyChanged(); } } | |||
private bool _isFault; | |||
/// <summary> | |||
@@ -1,11 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -1,11 +1,5 @@ | |||
using System; | |||
using BPA.Helper; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Diagnostics; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -42,21 +36,25 @@ namespace BPASmartClient.DosingSystem | |||
/// <summary> | |||
/// 输送线类型集合 | |||
/// </summary> | |||
private List<string> _converyTypeList=new List<string> (); | |||
public List<string> ConveryTypeList { | |||
private List<string> _converyTypeList = new List<string>(); | |||
public List<string> ConveryTypeList | |||
{ | |||
get { return _converyTypeList; } | |||
set { | |||
set | |||
{ | |||
foreach (var item in value) | |||
{ | |||
if (_converyTypeList.Contains(item)) | |||
{ | |||
continue; | |||
} | |||
_converyTypeList.Add(item); | |||
_converyTypeList.Add(item); | |||
} | |||
OnPropertyChanged(); } } | |||
OnPropertyChanged(); | |||
} | |||
} | |||
/// <summary> | |||
/// 输送带数量 | |||
/// </summary> | |||
@@ -1,10 +1,5 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -1,9 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -1,11 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.DosingSystem.ViewModel; | |||
using BPASmartClient.Model; | |||
using System.Collections.ObjectModel; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -1,11 +1,4 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.DosingSystem.ViewModel; | |||
using BPASmartClient.Model; | |||
using System.Collections.ObjectModel; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -1,13 +1,7 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using BPA.Communication; | |||
using BPA.Helper; | |||
using S7.Net; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPA.Communication; | |||
using System; | |||
using System.Threading; | |||
namespace BPASmartClient.DosingSystem | |||
{ | |||
@@ -38,7 +32,7 @@ namespace BPASmartClient.DosingSystem | |||
TaskManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
GlobalDevice.PlcData = MySiemens.Read<PlcToComputer>(3).Content;//获取PLC到上位机的数据 | |||
//var tt = MySiemens.Read<PlcToComputer>(3);//获取PLC到上位机的数据 | |||
//var tt = MySiemens.Read<PlcToComputer>(3);//获取PLC到上位机的数据 | |||
var res = MySiemens.Read<ushort[]>("DB4.DBW134", 32).Content; | |||
if (res != null && res is ushort[] ushorts && ushorts.Length == 32) | |||
{ | |||
@@ -52,8 +46,8 @@ namespace BPASmartClient.DosingSystem | |||
}; | |||
try | |||
{ | |||
IsConnect = MySiemens.Connect(new BPA.Communication.Base.ConfigurationOptions() { IpAddress = "192.168.0.100", cpuType = BPA.Communication.CpuType.S71200, Port = 102 }); | |||
IsConnect = MySiemens.Connect(new BPA.Communication.Base.ConfigurationOptions() { IpAddress = "192.168.0.100", cpuType = BPA.Communication.CpuType.S71200, Port = 102 }); | |||
} | |||
catch (Exception) | |||
{ | |||
@@ -1,17 +1,7 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System; | |||
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; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,18 +1,5 @@ | |||
using BPA.Helper; | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,17 +1,4 @@ | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
using System.Windows.Controls; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,17 +1,4 @@ | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
using System.Windows.Controls; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,17 +1,4 @@ | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
using System.Windows.Controls; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,18 +1,5 @@ | |||
using BPA.Helper; | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,18 +1,6 @@ | |||
using BPA.Helper; | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,17 +1,5 @@ | |||
using BPA.Helper; | |||
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; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,17 +1,6 @@ | |||
using BPA.Helper; | |||
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 BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,17 +1,8 @@ | |||
using BPA.Helper; | |||
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 BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,18 +1,6 @@ | |||
using BPA.Helper; | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,18 +1,6 @@ | |||
using BPASmartClient.DosingSystem.ViewModel; | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -32,7 +20,7 @@ namespace BPASmartClient.DosingSystem.View | |||
//repiceList.ItemsSource = RecipeControlViewModel.UserTreeCompelete; | |||
//repiceList.Visibility = Visibility.Visible; | |||
//repiceListMaking.Visibility = Visibility.Hidden; | |||
this.Wait.ItemsSource = RecipeControlViewModel.UserTreeCompelete; | |||
this.Wait.ItemsSource = ExcuteControl.GetInstance.UserTreeCompelete; | |||
CookingGrid.Visibility = Visibility.Collapsed; | |||
WaitOrCompleteGrid.Visibility = Visibility.Visible; | |||
this.Wait.Visibility = Visibility.Visible; | |||
@@ -43,7 +31,7 @@ namespace BPASmartClient.DosingSystem.View | |||
//repiceList.ItemsSource = RecipeControlViewModel.UserTreeWait; | |||
//repiceList.Visibility = Visibility.Visible; | |||
//repiceListMaking.Visibility = Visibility.Hidden; | |||
this.Wait.ItemsSource = RecipeControlViewModel.UserTreeWait; | |||
this.Wait.ItemsSource = ExcuteControl.GetInstance.UserTreeWait; | |||
CookingGrid.Visibility = Visibility.Collapsed; | |||
WaitOrCompleteGrid.Visibility = Visibility.Visible; | |||
this.Wait.Visibility = Visibility.Visible; | |||
@@ -1,19 +1,6 @@ | |||
using BPA.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Reflection; | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,17 +1,4 @@ | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
using System.Windows.Controls; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -25,6 +12,6 @@ namespace BPASmartClient.DosingSystem.View | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -1,17 +1,4 @@ | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
using System.Windows.Controls; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,17 +1,4 @@ | |||
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.Navigation; | |||
using System.Windows.Shapes; | |||
using System.Windows.Controls; | |||
namespace BPASmartClient.DosingSystem.View | |||
{ | |||
@@ -1,10 +1,7 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using System; | |||
using System.Linq; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -1,12 +1,7 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using System.Text; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -38,7 +33,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
//private BasePar _mCommBaseParModel; | |||
public BPARelayCommand SaveCommand { get; set; } | |||
} | |||
@@ -1,10 +1,5 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -20,7 +15,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
Num = i + 1, | |||
Speed = GlobalDevice.MotorSpeed[i], | |||
ConveyerBeltWork = GlobalDevice.MotorControl.GetBitValue((byte)(i + 1)) | |||
}) ; | |||
}); | |||
} | |||
} | |||
public ObservableCollection<ConveyerBeltModel> ConveyerBeltModels { get; set; } = new ObservableCollection<ConveyerBeltModel>(); | |||
@@ -1,14 +1,9 @@ | |||
using System; | |||
using BPA.Helper; | |||
using BPASmartClient.DosingSystem.View; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPASmartClient.DosingSystem.View; | |||
using System.Windows.Data; | |||
using System.Linq; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -16,7 +11,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
public DeviceListViewModel() | |||
{ | |||
DetailsCommand = new BPARelayCommand<object>((o) => | |||
{ | |||
if (o != null && o is string str) | |||
@@ -26,20 +21,20 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
cdn.ShowDialog(); | |||
} | |||
}); | |||
//devices = DeviceInquire.GetInstance.devices; | |||
//devices = DeviceInquire.GetInstance.devices; | |||
//2023/6/29新加 改为升序排列显示 | |||
devices = ConvertToObservableCollention(DeviceInquire.GetInstance.devices.OrderByDescending(p => p.IpAddress.Split(".")[3]).Reverse()); | |||
} | |||
public ObservableCollection<Devices> devices { get; set; } | |||
public ObservableCollection<T> ConvertToObservableCollention<T>(IEnumerable<T> array) | |||
{ | |||
ObservableCollection<T> collec =new ObservableCollection<T>(); | |||
ObservableCollection<T> collec = new ObservableCollection<T>(); | |||
foreach (var item in array) | |||
{ | |||
collec.Add(item); | |||
collec.Add(item); | |||
} | |||
return collec; | |||
} | |||
@@ -1,13 +1,8 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.UserControls; | |||
using System.Diagnostics; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -1,14 +1,9 @@ | |||
using System; | |||
using BPA.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using System.Linq; | |||
using System.Threading; | |||
using BPASmartClient.DosingSystem.Model; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -16,7 +11,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
public HardwareStatusViewModel() | |||
{ | |||
//TopDeviceCurrentStatuses = DeviceInquire.GetInstance.TopDeviceCurrentStatuses; | |||
//BottomDeviceCurrentStatuses = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses; | |||
@@ -1,10 +1,7 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPA.Helper; | |||
using System; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Threading; | |||
//using BPASmartClient.S7Net; | |||
@@ -1,14 +1,9 @@ | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPA.Helper; | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.Model; | |||
using BPA.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.ViewModel; | |||
@@ -1,11 +1,7 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using BPA.Helper; | |||
using System; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
@@ -1,14 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.Model; | |||
using System; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -18,13 +16,13 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
ActionManage.GetInstance.RegisterAsync(new Action<object>((o) => | |||
{ | |||
if (!string.IsNullOrEmpty(o?.ToString())) | |||
{ | |||
if (RawMaterials.FirstOrDefault(p => p.RawMaterialName == o.ToString()) != null) | |||
{ | |||
App.Current.Dispatcher.Invoke(() => { MessageNotify.GetInstance.ShowDialog("当前原料和其它原料重复,请重新选择!", DialogType.Warning); }); | |||
} | |||
} | |||
if (!string.IsNullOrEmpty(o?.ToString())) | |||
{ | |||
if (RawMaterials.FirstOrDefault(p => p.RawMaterialName == o.ToString()) != null) | |||
{ | |||
App.Current.Dispatcher.Invoke(() => { MessageNotify.GetInstance.ShowDialog("当前原料和其它原料重复,请重新选择!", DialogType.Warning); }); | |||
} | |||
} | |||
}), "原料选择修改"); | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
@@ -43,11 +41,11 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
AddCommand = new BPARelayCommand(() => | |||
{ | |||
//if (RawMaterials.Count >= DeviceInquire.GetInstance.devices.Count) | |||
//{ | |||
// MessageNotify.GetInstance.ShowDialog("原材料不足!"); | |||
// return; | |||
//} | |||
//if (RawMaterials.Count >= DeviceInquire.GetInstance.devices.Count) | |||
//{ | |||
// MessageNotify.GetInstance.ShowDialog("原材料不足!"); | |||
// return; | |||
//} | |||
p: | |||
string guid = Guid.NewGuid().ToString(); | |||
if (RawMaterials.FirstOrDefault(p => p.RawMaterialId == guid) == null) | |||
@@ -1,11 +1,7 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using BPA.Helper; | |||
using BPASmartClient.DosingSystem.View; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using BPASmartClient.DosingSystem.View; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
@@ -1,22 +1,10 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
using System.Collections.Concurrent; | |||
using System.Collections.ObjectModel; | |||
using System.Windows; | |||
using BPA.Helper; | |||
using BPASmartClient.DosingSystem.View; | |||
using BPA.Helper; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.CustomResource.UserControls; | |||
using BPASmartClient.CustomResource.UserControls.Model; | |||
using BPASmartClient.CustomResource.UserControls.Enum; | |||
using System.Windows.Media; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.DosingSystem.View; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -1,11 +1,5 @@ | |||
| |||
using System; | |||
using System.Collections.Generic; | |||
using BPA.Helper; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPA.Helper; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
@@ -1,10 +1,6 @@ | |||
using BPA.Communication; | |||
using BPA.Helper; | |||
//using BPASmartClient.S7Net; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
@@ -1,13 +1,9 @@ | |||
using BPA.Helper; | |||
using BPASmartClient.DosingSystem.Model; | |||
using BPASmartClient.DosingSystem; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
@@ -37,10 +33,10 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
//TopDeviceCurrentStatuses = DeviceInquire.GetInstance.TopDeviceCurrentStatuses; | |||
//BottomDeviceCurrentStatuses = DeviceInquire.GetInstance.BottomDeviceCurrentStatuses; | |||
//2023/7/3调整 | |||
TopDeviceCurrentStatuses= ConvertToObservableCollention(DeviceInquire.GetInstance.TopDeviceCurrentStatuses.OrderByDescending(p => p.DeviceNum).Reverse()); | |||
TopDeviceCurrentStatuses = ConvertToObservableCollention(DeviceInquire.GetInstance.TopDeviceCurrentStatuses.OrderByDescending(p => p.DeviceNum).Reverse()); | |||
BottomDeviceCurrentStatuses = ConvertToObservableCollention(DeviceInquire.GetInstance.BottomDeviceCurrentStatuses.OrderByDescending(p => p.DeviceNum).Reverse()); | |||
UnifordColumNum(); | |||
TaskManage.GetInstance.StartLong(new Action(() => | |||
{ | |||
for (int i = 0; i < Json<DevicePar>.Data.OutletInfoModels.Count; i++) | |||
@@ -64,7 +60,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
StatusUpdate(BottomDeviceCurrentStatuses); | |||
OnDetection = GlobalDevice.PlcData.OnDetection; | |||
UnderDetection = GlobalDevice.PlcData.UnderDetection; | |||
ConveyerBeltStatus = GlobalDevice.MotorControlFeedback>0?2: GlobalDevice.MotorControlFeedback; | |||
ConveyerBeltStatus = GlobalDevice.MotorControlFeedback > 0 ? 2 : GlobalDevice.MotorControlFeedback; | |||
Thread.Sleep(100); | |||
}), "输送带料仓状态监控", true); | |||
@@ -115,7 +111,7 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
{ | |||
//StockNum = Json<DevicePar>.Data.BaseParModel.StockCount; | |||
StockNum=TopDeviceCurrentStatuses.Count >= BottomDeviceCurrentStatuses.Count ? TopDeviceCurrentStatuses.Count : BottomDeviceCurrentStatuses.Count; | |||
StockNum = TopDeviceCurrentStatuses.Count >= BottomDeviceCurrentStatuses.Count ? TopDeviceCurrentStatuses.Count : BottomDeviceCurrentStatuses.Count; | |||
} | |||
@@ -166,5 +162,5 @@ namespace BPASmartClient.DosingSystem.ViewModel | |||
public bool UnderDetection { get { return _mUnderDetection; } set { _mUnderDetection = value; OnPropertyChanged(); } } | |||
private bool _mUnderDetection; | |||
} | |||
} | |||
} | |||
@@ -9,6 +9,8 @@ | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Communication" Version="1.0.116" /> | |||
<PackageReference Include="BPA.PahoMQ" Version="1.0.6" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,61 @@ | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<configuration> | |||
<configSections> | |||
<sectionGroup name="FlexBatchSystem"> | |||
<section name="ProductInfo" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="MqttInfo" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="ConveyerInfo" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo1" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo2" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo3" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo4" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo5" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="StockInfo6" type="System.Configuration.NameValueSectionHandler"/> | |||
<section name="Services" type="System.Configuration.NameValueSectionHandler"/> | |||
</sectionGroup> | |||
</configSections> | |||
<FlexBatchSystem> | |||
<ProductInfo> | |||
<add key="ProductKey" value="j090GlJPJNv"/> | |||
<add key="ProductSecret" value="OVTPKMuGlBLZRBFt"/> | |||
</ProductInfo> | |||
<MqttInfo> | |||
<add key="mqttHostUrl" value="iot-06z00carjduqaue.mqtt.iothub.aliyuncs.com"/> | |||
</MqttInfo> | |||
<ConveyerInfo> | |||
<add key="DeviceName" value="Conveyer"/> | |||
<add key="DeviceSecret" value="b3df8aaa82de59f478dffb172acf78cd"/> | |||
</ConveyerInfo> | |||
<StockInfo1> | |||
<add key="DeviceName" value="StockDevie1"/> | |||
<add key="DeviceSecret" value="21f2fa559c1dee1055a49b1a933697ae"/> | |||
</StockInfo1> | |||
<StockInfo2> | |||
<add key="DeviceName" value="StockDevie2"/> | |||
<add key="DeviceSecret" value="ff7923741d1eca91f4417f7cb9bbbc10"/> | |||
</StockInfo2> | |||
<StockInfo3> | |||
<add key="DeviceName" value="StockDevie3"/> | |||
<add key="DeviceSecret" value="e51577e333d6210e92d4a354319b5cce"/> | |||
</StockInfo3> | |||
<StockInfo4> | |||
<add key="DeviceName" value="StockDevie4"/> | |||
<add key="DeviceSecret" value="a5dc2997c10d87b9fef5b63c0b01393e"/> | |||
</StockInfo4> | |||
<StockInfo5> | |||
<add key="DeviceName" value="StockDevie5"/> | |||
<add key="DeviceSecret" value="7e4e16bad60f52a6644dda950c3740b2"/> | |||
</StockInfo5> | |||
<StockInfo6> | |||
<add key="DeviceName" value="StockDevie6"/> | |||
<add key="DeviceSecret" value="7c7547142be4989c14135b15496f8923"/> | |||
</StockInfo6> | |||
<Services> | |||
<add key="Service1" value="RunControlService"/> | |||
<add key="Service2" value="StockAirControlService"/> | |||
<add key="Service3" value="RecipeSendService"/> | |||
<add key="Service4" value="CancelRecipeService"/> | |||
</Services> | |||
</FlexBatchSystem> | |||
</configuration> |
@@ -1,10 +1,275 @@ | |||
namespace 阿里云IOT平台测试 | |||
using BPA.PahoMQ; | |||
using Newtonsoft.Json; | |||
using System.Collections.Specialized; | |||
using System.Reflection; | |||
using System.Text; | |||
using System.Text.RegularExpressions; | |||
using uPLibrary.Networking.M2Mqtt.Messages; | |||
namespace 阿里云IOT平台测试 | |||
{ | |||
/// <summary> | |||
/// 以输送线设备作为测试对象 | |||
/// </summary> | |||
internal class Program | |||
{ | |||
public static bool PropertyReport = false; //属性上报主题订阅标志 | |||
//public static bool PropertySet = false; //属性设置主题订阅标志 | |||
public static bool EventReport = false; //事件上报主题订阅标志 | |||
//public static bool ServiceCall = false; //服务调用主题订阅标志 | |||
public static string productKey = "j090GlJPJNv"; | |||
//public static string deviceName = "Conveyer"; | |||
//public static string deviceSecret = "b3df8aaa82de59f478dffb172acf78cd"; | |||
public static string deviceName = "Stock1"; | |||
public static string deviceSecret = "b0928d8f6e36aabd94f0fce3f9b02536"; | |||
private static MessageHandler _messageHandler; | |||
static void Main(string[] args) | |||
{ | |||
//string s= JsonConvert.SerializeObject(new Test()); | |||
//string s2 = JsonConvert.SerializeXmlNode(); | |||
//string s1 = JsonConvert.SerializeXNode(new Test()); | |||
if (_messageHandler == null) | |||
_messageHandler = new MessageHandler(new PahoMQOption() | |||
{ | |||
Broker = "iot-06z00carjduqaue.mqtt.iothub.aliyuncs.com", | |||
ProductKey = productKey, | |||
DeviceName = deviceName, | |||
DeviceSecret = deviceSecret, | |||
Port = 1883 | |||
}); | |||
//云端属性设置主题订阅及回调 | |||
_messageHandler.Subscribe((op) => | |||
{ | |||
op.TopicReply = $"/sys/{productKey}/{deviceName}/thing/service/property/set"; | |||
op.ThresholdCallback += Op_ThresholdCallback; | |||
}); | |||
//服务订阅 | |||
var serviceIdentifier = "RecipeSendService"; | |||
var serviceTopicReply = $"/sys/{productKey}/{deviceName}/thing/service/{serviceIdentifier}"; | |||
_messageHandler.Subscribe((op) => | |||
{ | |||
op.TopicReply = serviceTopicReply; | |||
op.ThresholdCallback += Op_ThresholdCallback1; ; // MqttPostProperty_MqttMsgPublishReceived; | |||
}); | |||
Console.WriteLine("云端属性设置主题订阅成功"); | |||
Console.WriteLine("云端服务调用主题订阅成功"); | |||
ep: string result = Console.ReadLine(); | |||
if (result.Equals("属性上报")) | |||
{ | |||
//属性上报与订阅 | |||
var mqdeviceTestProperty = new PostPropertyParams<StockModel>(); | |||
mqdeviceTestProperty.sys = new Sys { ack = 1 }; | |||
mqdeviceTestProperty.method = "thing.event.property.post"; | |||
mqdeviceTestProperty.version = "1.0"; | |||
//默认模板 | |||
// mqdeviceTestProperty.Model = new StockModel(); | |||
//自定义模板 | |||
mqdeviceTestProperty.ModelName = "StockModel"; | |||
mqdeviceTestProperty.Model = new StockModel(); | |||
mqdeviceTestProperty.Init(); | |||
var message = JsonConvert.SerializeObject(mqdeviceTestProperty); | |||
var topic = $"/sys/{productKey}/{deviceName}/thing/event/property/post";//发布主题 | |||
var topicReply = $"/sys/{productKey}/{deviceName}/thing/event/property/post_reply";//订阅主题 | |||
_messageHandler.Publish((op) => | |||
{ | |||
op.Message = message; | |||
op.Topic = topic; | |||
op.TopicReply = topicReply; | |||
if (!PropertyReport) | |||
{ | |||
op.ThresholdCallback += MqttPostProperty_MqttMsgPublishReceived; // MqttPostProperty_MqttMsgPublishReceived; | |||
PropertyReport = true; | |||
} | |||
}); | |||
} | |||
if (result.Equals("事件上报")) | |||
{ | |||
string eventIdentifier = "StockModel:StockJerk1StatusEvent"; | |||
var mqdeviceTestEvent = new PostEventParams<EventModel>(); | |||
mqdeviceTestEvent.id = Guid.NewGuid().ToString(); | |||
mqdeviceTestEvent.sys = new Sys { ack = 1 }; | |||
mqdeviceTestEvent.method = $"thing.event.{eventIdentifier}.post"; | |||
mqdeviceTestEvent.version = "1.0"; | |||
mqdeviceTestEvent.@params = new EventParam<EventModel> { value = new EventModel (), time = new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds() }; | |||
var eventMessage = JsonConvert.SerializeObject(mqdeviceTestEvent); | |||
//事件上报 | |||
var eventTopic = $"/sys/{productKey}/{deviceName}/thing/event/{eventIdentifier}/post"; | |||
//事件订阅主题 | |||
var eventTopicReply = $"/sys/{productKey}/{deviceName}/thing/event/{eventIdentifier}/post_reply"; | |||
_messageHandler.Publish((op) => | |||
{ | |||
op.Message = eventMessage; | |||
op.Topic = eventTopic; | |||
op.TopicReply = eventTopicReply; | |||
if (!EventReport) | |||
{ | |||
op.ThresholdCallback += MqttPostEvent_MqttMsgPublishReceived; // MqttPostProperty_MqttMsgPublishReceived; | |||
EventReport= true; | |||
} | |||
}); | |||
} | |||
//if (result.Equals("事件上报2")) | |||
//{ | |||
// string eventIdentifier = "StockServoFaultEvent"; | |||
// var mqdeviceTestEvent = new PostEventParams<EventModel>(); | |||
// mqdeviceTestEvent.id = Guid.NewGuid().ToString(); | |||
// mqdeviceTestEvent.sys = new Sys { ack = 1 }; | |||
// mqdeviceTestEvent.method = $"thing.event.{eventIdentifier}.post"; | |||
// mqdeviceTestEvent.version = "1.0"; | |||
// mqdeviceTestEvent.@params = new EventParam<EventModel> { value = new EventModel { StockNum = 1 }, time = new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds() }; | |||
// var eventMessage = JsonConvert.SerializeObject(mqdeviceTestEvent); | |||
// //事件上报 | |||
// var eventTopic = $"/sys/{productKey}/{deviceName}/thing/event/{eventIdentifier}/post"; | |||
// //事件订阅主题 | |||
// var eventTopicReply = $"/sys/{productKey}/{deviceName}/thing/event/{eventIdentifier}/post_reply"; | |||
// _messageHandler.Publish((op) => | |||
// { | |||
// op.Message = eventMessage; | |||
// op.Topic = eventTopic; | |||
// op.TopicReply = eventTopicReply; | |||
// if (!EventReport) | |||
// { | |||
// op.ThresholdCallback += MqttPostEvent_MqttMsgPublishReceived; // MqttPostProperty_MqttMsgPublishReceived; | |||
// EventReport = true; | |||
// } | |||
// }); | |||
// } | |||
goto ep; | |||
} | |||
/// <summary> | |||
/// 云端服务调用回调 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private static void Op_ThresholdCallback1(object sender, MqttMsgPublishEventArgs e) | |||
{ | |||
if (Regex.IsMatch(e.Topic, "[0-9a-zA-Z/]*thing/service/[0-9a-zA-Z:]*$")) | |||
{ | |||
Console.WriteLine("---------------------------云端设备服务调用Start---------------------"); | |||
Console.WriteLine("reply topic :" + e.Topic); | |||
var rtn = JsonConvert.DeserializeObject<ServiceBaseResponse<object>>(Encoding.UTF8.GetString(e.Message, 0, e.Message.Length)); | |||
PropertyInfo property = rtn.@params.GetType().GetProperty("Root"); | |||
string result = property.GetValue(rtn.@params).ToString(); | |||
var array = result.Replace("\r\n", "").Replace(" ", "").Replace("{", "").Replace("}", "").Replace("\"", "").Split(','); | |||
Console.WriteLine("reply payload:" + Encoding.UTF8.GetString(e.Message, 0, e.Message.Length)); | |||
Console.WriteLine("---------------------------云端设备服务调用End---------------------"); | |||
} | |||
} | |||
/// <summary> | |||
/// 事件上报 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
/// <exception cref="NotImplementedException"></exception> | |||
private static void MqttPostEvent_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) | |||
{ | |||
if (Regex.IsMatch(e.Topic, "[0-9a-zA-Z/]*thing/event/(?!property).*/(post_reply)$")) | |||
{ | |||
Console.WriteLine("---------------------------设备事件上报Start---------------------"); | |||
Console.WriteLine("reply topic :" + e.Topic); | |||
var rtn = JsonConvert.DeserializeObject<BaseMqResponse<object>>(Encoding.UTF8.GetString(e.Message, 0, e.Message.Length)); | |||
Console.WriteLine("reply payload:" + Encoding.UTF8.GetString(e.Message, 0, e.Message.Length)); | |||
Console.WriteLine("---------------------------设备事件上报End---------------------"); | |||
} | |||
} | |||
/// <summary> | |||
/// 云端属性设置回调 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
/// <exception cref="NotImplementedException"></exception> | |||
private static void Op_ThresholdCallback(object sender, MqttMsgPublishEventArgs e) | |||
{ | |||
if (Regex.IsMatch(e.Topic, "[0-9a-zA-Z/]*(thing/service/property/set)$")) | |||
{ | |||
Console.WriteLine("---------------------------云端设置属性Start---------------------"); | |||
Console.WriteLine("reply topic :" + e.Topic); | |||
var rtn = JsonConvert.DeserializeObject<ServiceBaseResponse<object>>(Encoding.UTF8.GetString(e.Message, 0, e.Message.Length)); | |||
PropertyInfo property= rtn.@params.GetType().GetProperty("Root"); | |||
string result=property.GetValue(rtn.@params).ToString(); | |||
var array= result.Replace("\r\n", "").Replace(" ","").Replace("{","").Replace("}","").Replace("\"", "").Split(','); | |||
foreach (var item in array) | |||
{ | |||
var str=item.Split(":"); //数据格式: | |||
switch (str[1]) | |||
{ | |||
} | |||
} | |||
Console.WriteLine("reply payload:" + Encoding.UTF8.GetString(e.Message, 0, e.Message.Length)); | |||
Console.WriteLine("---------------------------云端设置属性End---------------------"); | |||
} | |||
} | |||
private static void MqttPostProperty_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) | |||
{ | |||
//考虑使用正则表达判断是属性,事件,服务其中那个回调 | |||
if (Regex.IsMatch(e.Topic, "[0-9a-zA-Z/]*thing/event/property/post_reply")) | |||
{ | |||
Console.WriteLine("---------------------------设备端属性上报回调Start---------------------"); | |||
var rtn = JsonConvert.DeserializeObject<BaseMqResponse<object>>(Encoding.UTF8.GetString(e.Message, 0, e.Message.Length)); | |||
Console.WriteLine($"code:{rtn.code}"); | |||
Console.WriteLine("reply topic :" + e.Topic); | |||
Console.WriteLine("messageID :" + rtn.id); | |||
Console.WriteLine("reply payload:" + Encoding.UTF8.GetString(e.Message, 0, e.Message.Length)); | |||
Console.WriteLine("---------------------------设备端属性上报回调End---------------------"); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 属性测试类 | |||
/// </summary> | |||
public class StockModel | |||
{ | |||
//public string Test { get; set; } = "测试2"; | |||
public int StockRealWeight { get; set; } = 250000; | |||
public float BucketRealWeight { get; set; } = 16000; | |||
public string StockBatchStatus { get; set; } = "配料完成"; | |||
public int StockWorkModel { get; set; } = 1; | |||
} | |||
/// <summary> | |||
/// 事件测试类 | |||
/// </summary> | |||
public class EventModel | |||
{ | |||
// public string Result { get; set; } | |||
} | |||
} |
@@ -1,4 +1,4 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<OutputType>Exe</OutputType> | |||
@@ -7,4 +7,10 @@ | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Communication" Version="1.0.117" /> | |||
<PackageReference Include="BPA.PahoMQ" Version="1.0.8" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | |||
</ItemGroup> | |||
</Project> |