@@ -65,7 +65,6 @@ namespace BPASmartClient.Business | |||||
{ | { | ||||
string Namespace = device.DeviceNamespace.Substring(0, device.DeviceNamespace.LastIndexOf('.')); | string Namespace = device.DeviceNamespace.Substring(0, device.DeviceNamespace.LastIndexOf('.')); | ||||
//string startModel = device.DeviceNamespace.Substring(device.DeviceNamespace.LastIndexOf('.') + 1); | |||||
var deviceTemp = Assembly.Load(Namespace).CreateInstance(device.DeviceNamespace) as IDevice; | var deviceTemp = Assembly.Load(Namespace).CreateInstance(device.DeviceNamespace) as IDevice; | ||||
deviceTemp.Name = device?.DeviceName; | deviceTemp.Name = device?.DeviceName; | ||||
deviceTemp.DeviceId = int.Parse(device.DeviceId); | deviceTemp.DeviceId = int.Parse(device.DeviceId); | ||||
@@ -75,7 +74,6 @@ namespace BPASmartClient.Business | |||||
foreach (var comms in device.communicationDevcies)//通讯集合 | foreach (var comms in device.communicationDevcies)//通讯集合 | ||||
{ | { | ||||
string IPeripheralNamespace = comms.CommunicationNamespace.Substring(0, comms.CommunicationNamespace.LastIndexOf('.')); | string IPeripheralNamespace = comms.CommunicationNamespace.Substring(0, comms.CommunicationNamespace.LastIndexOf('.')); | ||||
//string IPeripheralStartModel = comms.CommunicationNamespace.Substring(comms.CommunicationNamespace.LastIndexOf('.')); | |||||
var peripheralTemp = Assembly.Load(IPeripheralNamespace).CreateInstance(comms.CommunicationNamespace) as IPeripheral; | var peripheralTemp = Assembly.Load(IPeripheralNamespace).CreateInstance(comms.CommunicationNamespace) as IPeripheral; | ||||
peripheralTemp.variables = comms.variables; | peripheralTemp.variables = comms.variables; | ||||
peripheralTemp.communicationPar = comms.communicationPar; | peripheralTemp.communicationPar = comms.communicationPar; | ||||
@@ -141,24 +139,22 @@ namespace BPASmartClient.Business | |||||
if (PushType == 1) | if (PushType == 1) | ||||
{ | { | ||||
device.recipeBoms = JsonConvert.DeserializeObject<RecipeBoms>(result); | |||||
//EventBus.EventBus.GetInstance().Publish(new RecipeBomEvent() | |||||
//{ | |||||
// DeviceId = device.DeviceId, | |||||
// recipeBoms = JsonConvert.DeserializeObject<RecipeBoms>(result) | |||||
//}); | |||||
MessageLog.GetInstance.Show("接收到辅料信息"); | |||||
new RecipeBomEvent() | |||||
{ | |||||
DeviceId = device.DeviceId, | |||||
recipeBoms = JsonConvert.DeserializeObject<RecipeBoms>(result) | |||||
}.Publish(); | |||||
MessageLog.GetInstance.Show("接收到【 API 】获取的辅料信息"); | |||||
} | } | ||||
else if (PushType == 0) | else if (PushType == 0) | ||||
{ | { | ||||
var apiData = JsonConvert.DeserializeObject<OrderMaterialDelivery>(result); | var apiData = JsonConvert.DeserializeObject<OrderMaterialDelivery>(result); | ||||
device.orderMaterialDelivery = apiData; | |||||
//EventBus.EventBus.GetInstance().Publish(new MaterialDeliveryEvent() | |||||
//{ | |||||
// DeviceId = device.DeviceId, | |||||
// orderMaterialDelivery = apiData | |||||
//}); | |||||
MessageLog.GetInstance.Show("接收到物料信息"); | |||||
new MaterialDeliveryEvent() | |||||
{ | |||||
DeviceId = device.DeviceId, | |||||
orderMaterialDelivery = apiData | |||||
}.Publish(); | |||||
MessageLog.GetInstance.Show("接收到【 API 】获取的物料信息"); | |||||
apiData?.BatchingInfo?.ForEach(x => | apiData?.BatchingInfo?.ForEach(x => | ||||
{ | { | ||||
MessageLog.GetInstance.Show($"物料ID:=[{x.BatchingId}],{x.BatchingLoc}号位置:{x.BatchingCount}"); | MessageLog.GetInstance.Show($"物料ID:=[{x.BatchingId}],{x.BatchingLoc}号位置:{x.BatchingCount}"); | ||||
@@ -78,12 +78,26 @@ namespace BPASmartClient.Business | |||||
//辅料信息 | //辅料信息 | ||||
else if (message is RecipeBoms recipe) | else if (message is RecipeBoms recipe) | ||||
{ | { | ||||
new RecipeBomEvent() | |||||
{ | |||||
DeviceId = recipe.DeviceId, | |||||
recipeBoms = recipe | |||||
}.Publish(); | |||||
MessageLog.GetInstance.Show("接收到 【 MQTT 】 的辅料信息"); | |||||
} | } | ||||
//物料消息 | //物料消息 | ||||
else if (message is OrderMaterialDelivery delivery) | else if (message is OrderMaterialDelivery delivery) | ||||
{ | { | ||||
new MaterialDeliveryEvent() | |||||
{ | |||||
DeviceId = delivery.DeviceId, | |||||
orderMaterialDelivery = delivery | |||||
}.Publish(); | |||||
MessageLog.GetInstance.Show("接收到 【 MQTT 】 的物料信息"); | |||||
delivery?.BatchingInfo?.ForEach(x => | |||||
{ | |||||
MessageLog.GetInstance.Show($"物料ID:=[{x.BatchingId}],{x.BatchingLoc}号位置:{x.BatchingCount}"); | |||||
}); | |||||
} | } | ||||
}); | }); | ||||
@@ -86,4 +86,95 @@ | |||||
</Style> | </Style> | ||||
<!--#endregion--> | <!--#endregion--> | ||||
<!--#region 长方形按钮--> | |||||
<Style x:Key="RectangleRadioButtonStyle" TargetType="{x:Type RadioButton}"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="Width" Value="100" /> | |||||
<Setter Property="IsChecked" Value="False" /> | |||||
<Setter Property="FontSize" Value="16" /> | |||||
<Setter Property="Foreground" Value="#ff2AB2E7" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type RadioButton}"> | |||||
<Grid SnapsToDevicePixels="True"> | |||||
<Border | |||||
x:Name="bb" | |||||
BorderBrush="#4B8EC4" | |||||
BorderThickness="0,0,0,2" /> | |||||
<ContentPresenter | |||||
x:Name="contentPresenter" | |||||
Margin="10" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
ContentStringFormat="{TemplateBinding ContentStringFormat}" | |||||
ContentTemplate="{TemplateBinding ContentTemplate}" | |||||
Focusable="False" | |||||
RecognizesAccessKey="True" | |||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsChecked" Value="True"> | |||||
<!--<Setter TargetName="bb" Property="Background" Value="#4B8EC4" />--> | |||||
<Setter TargetName="bb" Property="Visibility" Value="Visible" /> | |||||
</Trigger> | |||||
<Trigger Property="IsChecked" Value="False"> | |||||
<Setter TargetName="bb" Property="Visibility" Value="Hidden" /> | |||||
<!--<Setter TargetName="bb" Property="Background" Value="Transparent" />--> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<!--#endregion--> | |||||
<!--#region 长方形左侧按钮--> | |||||
<Style x:Key="RectangleLeftRadioButtonStyle" TargetType="{x:Type RadioButton}"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="Width" Value="100" /> | |||||
<Setter Property="IsChecked" Value="False" /> | |||||
<Setter Property="FontSize" Value="16" /> | |||||
<Setter Property="Foreground" Value="#ff2AB2E7" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type RadioButton}"> | |||||
<Grid SnapsToDevicePixels="True"> | |||||
<Border x:Name="bb"> | |||||
<Border.Background> | |||||
<ImageBrush ImageSource="../Image/leftImageSub.png" /> | |||||
</Border.Background> | |||||
</Border> | |||||
<ContentPresenter | |||||
x:Name="contentPresenter" | |||||
Margin="10" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
ContentStringFormat="{TemplateBinding ContentStringFormat}" | |||||
ContentTemplate="{TemplateBinding ContentTemplate}" | |||||
Focusable="False" | |||||
RecognizesAccessKey="True" | |||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsChecked" Value="True"> | |||||
<Setter TargetName="bb" Property="Visibility" Value="Visible" /> | |||||
<!--<Setter TargetName="bb" Property="Background" Value="#4B8EC4" />--> | |||||
</Trigger> | |||||
<Trigger Property="IsChecked" Value="False"> | |||||
<Setter TargetName="bb" Property="Visibility" Value="Hidden" /> | |||||
<!--<Setter TargetName="bb" Property="Background" Value="Transparent" />--> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<!--#endregion--> | |||||
</ResourceDictionary> | </ResourceDictionary> |
@@ -1273,7 +1273,7 @@ | |||||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | <Setter Property="HorizontalContentAlignment" Value="Center" /> | ||||
<Setter Property="SnapsToDevicePixels" Value="true" /> | <Setter Property="SnapsToDevicePixels" Value="true" /> | ||||
<Setter Property="Foreground" Value="#abf4ff" /> | <Setter Property="Foreground" Value="#abf4ff" /> | ||||
<Setter Property="BorderBrush" Value="#abf4ff"></Setter> | |||||
<Setter Property="BorderBrush" Value="#abf4ff" /> | |||||
<Setter Property="FontSize" Value="10" /> | <Setter Property="FontSize" Value="10" /> | ||||
<Setter Property="Template"> | <Setter Property="Template"> | ||||
<Setter.Value> | <Setter.Value> | ||||
@@ -103,7 +103,7 @@ namespace BPASmartClient.DRCoffee | |||||
//一系列解包 | //一系列解包 | ||||
while (dataStorage.GetSize() > 0) | while (dataStorage.GetSize() > 0) | ||||
{ | { | ||||
IsConnected = true; | |||||
byte item = dataStorage.GetData(); | byte item = dataStorage.GetData(); | ||||
if (DrCoffee.HEADER == item) | if (DrCoffee.HEADER == item) | ||||
{ | { | ||||
@@ -147,6 +147,7 @@ namespace BPASmartClient.DRCoffee | |||||
status["Status"] = package.Status; | status["Status"] = package.Status; | ||||
lastRefreshTime = DateTime.Now; | lastRefreshTime = DateTime.Now; | ||||
IsConnected = OnLine; | |||||
new DRCoffee_CoffeEndCookEvent() { DeviceId = DeviceId }.Publish(); | new DRCoffee_CoffeEndCookEvent() { DeviceId = DeviceId }.Publish(); | ||||
} | } | ||||
else status["Status"] = package.Status; | else status["Status"] = package.Status; | ||||
@@ -160,8 +161,7 @@ namespace BPASmartClient.DRCoffee | |||||
|| (DrCoffeeFault)status["Fault"] != DrCoffeeFault.无故障 | || (DrCoffeeFault)status["Fault"] != DrCoffeeFault.无故障 | ||||
) | ) | ||||
{ | { | ||||
IsWork = false; | |||||
IsWork = false; | |||||
} | } | ||||
else | else | ||||
IsWork = true; | IsWork = true; | ||||
@@ -32,12 +32,12 @@ namespace BPASmartClient.Device | |||||
/// <summary> | /// <summary> | ||||
/// 订单物料信息 | /// 订单物料信息 | ||||
/// </summary> | /// </summary> | ||||
OrderMaterialDelivery orderMaterialDelivery { get; set; } | |||||
//OrderMaterialDelivery orderMaterialDelivery { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 配方数据信息 | /// 配方数据信息 | ||||
/// </summary> | /// </summary> | ||||
RecipeBoms recipeBoms { get; set; } | |||||
//RecipeBoms recipeBoms { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 设备所有状态 | /// 设备所有状态 | ||||
@@ -48,7 +48,6 @@ namespace BPASmartClient.GSIceCream | |||||
try | try | ||||
{ | { | ||||
commProxy.Start(); | commProxy.Start(); | ||||
IsConnected = true; | |||||
free = false; | free = false; | ||||
MainLoop(); | MainLoop(); | ||||
} | } | ||||
@@ -177,6 +176,7 @@ namespace BPASmartClient.GSIceCream | |||||
private void ProcessHeart(ICMSG_Heart_UP heartUpMsg) | private void ProcessHeart(ICMSG_Heart_UP heartUpMsg) | ||||
{ | { | ||||
IsConnected = OnLine; | |||||
status["CurrentMode"] = heartUpMsg.MS; | status["CurrentMode"] = heartUpMsg.MS; | ||||
status["YLWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.YLWD_L,heartUpMsg.YLWD_H },0); | status["YLWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.YLWD_L,heartUpMsg.YLWD_H },0); | ||||
status["HQWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HQWD_L,heartUpMsg.HQWD_H },0); | status["HQWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HQWD_L,heartUpMsg.HQWD_H },0); | ||||
@@ -195,6 +195,7 @@ namespace BPASmartClient.GSIceCream | |||||
{ | { | ||||
MessageLog.GetInstance.Show("打料中"); | MessageLog.GetInstance.Show("打料中"); | ||||
} | } | ||||
Thread.Sleep(1000); | |||||
} | } | ||||
private void ProcessModeUp(ICMSG_MODE_UP modeUpMsg) | private void ProcessModeUp(ICMSG_MODE_UP modeUpMsg) | ||||
@@ -5,10 +5,15 @@ | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="AlibabaCloud.OpenApiClient" Version="0.1.3" /> | |||||
<PackageReference Include="AlibabaCloud.SDK.Iot20180120" Version="3.0.5" /> | |||||
<PackageReference Include="AlibabaCloud.TeaConsole" Version="0.1.0" /> | |||||
<PackageReference Include="AlibabaCloud.TeaUtil" Version="0.1.13" /> | |||||
<PackageReference Include="Aliyun.OSS.SDK" Version="2.13.0" /> | <PackageReference Include="Aliyun.OSS.SDK" Version="2.13.0" /> | ||||
<PackageReference Include="M2Mqtt" Version="4.3.0" /> | <PackageReference Include="M2Mqtt" Version="4.3.0" /> | ||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | <PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" /> | <PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" /> | ||||
<PackageReference Include="Tea" Version="1.0.11" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -298,25 +298,17 @@ namespace BPASmartClient.IoT | |||||
{ | { | ||||
string FileName = result.data?.fileName; | string FileName = result.data?.fileName; | ||||
string uploadId = result.data?.uploadId; | string uploadId = result.data?.uploadId; | ||||
FileUpload.SetUploadData(result.id,uploadId); | |||||
FileUpload.FileSend(DeviceDataV, uploadId); | |||||
MessageLog.GetInstance.Show($"请求上传【阿里云】成功,准备上传日志文件【HBL.LogDir{DateTime.Now.ToString("yyyy_M_d")}.log】"); | |||||
FileUpload.FileSend(DeviceDataV, uploadId, result.data.offset); | |||||
MessageLog.GetInstance.Show($"[阿里云上传]:请求上传云回执成功."); | |||||
} | } | ||||
else | else | ||||
MessageLog.GetInstance.Show($"【HBL.LogDir{DateTime.Now.ToString("yyyy_M_d")}.log】请求上传【阿里云】失败,{result.message}"); | |||||
MessageLog.GetInstance.Show($"[阿里云上传]:请求上传云回执失败.原因:{result.message}"); | |||||
} | } | ||||
else if (DeviceDataV.FileUpLoadSendReplyTopic == topic)//文件上传Topic | else if (DeviceDataV.FileUpLoadSendReplyTopic == topic)//文件上传Topic | ||||
{ | { | ||||
FileUploadModelResult result = Tools.JsonToObjectTools<FileUploadModelResult>(message); | FileUploadModelResult result = Tools.JsonToObjectTools<FileUploadModelResult>(message); | ||||
if (result.code == 200) | |||||
{ | |||||
MessageLog.GetInstance.Show($"今日日志文件“HBL.LogDir{DateTime.Now.ToString("yyyy_M_d")}.log”更新上传【阿里云】成功"); | |||||
bool complete = result.data.complete; | |||||
string uploadId = result.data?.uploadId; | |||||
}else | |||||
MessageLog.GetInstance.Show($"今日日志文件“HBL.LogDir{DateTime.Now.ToString("yyyy_M_d")}.log”更新上传【阿里云】失败,{result.message}"); | |||||
FileUpload.modelResult = result; | |||||
} | } | ||||
else if (DeviceDataV.CancelFileUpLoadSendReplyTopic == topic)//取消文件上传Topic | else if (DeviceDataV.CancelFileUpLoadSendReplyTopic == topic)//取消文件上传Topic | ||||
{ | { | ||||
@@ -1,4 +1,5 @@ | |||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using BPASmartClient.Message; | |||||
using BPASmartDatavDeviceClient.IoT; | using BPASmartDatavDeviceClient.IoT; | ||||
using DataVAPI.Tool.IOT; | using DataVAPI.Tool.IOT; | ||||
using System; | using System; | ||||
@@ -6,7 +7,9 @@ using System.Collections.Generic; | |||||
using System.IO; | using System.IO; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Text; | using System.Text; | ||||
using System.Threading; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using static AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileResponseBody; | |||||
namespace BPASmartClient.IoT.Model | namespace BPASmartClient.IoT.Model | ||||
{ | { | ||||
@@ -15,55 +18,112 @@ namespace BPASmartClient.IoT.Model | |||||
/// </summary> | /// </summary> | ||||
public class FileUpload | public class FileUpload | ||||
{ | { | ||||
public static Dictionary<string, string> UploadData = new Dictionary<string, string>(); | |||||
public static string FileName = $"HBL.LogDir{DateTime.Now.ToString("yyyy_M_d")}"; | public static string FileName = $"HBL.LogDir{DateTime.Now.ToString("yyyy_M_d")}"; | ||||
public static string path = $"{System.AppDomain.CurrentDomain.BaseDirectory}LogDir\\{FileName}.log"; | public static string path = $"{System.AppDomain.CurrentDomain.BaseDirectory}LogDir\\{FileName}.log"; | ||||
public static void SetUploadData(string key, string value) | |||||
{ | |||||
UploadData[key] = value; | |||||
} | |||||
public static string GetUploadData(string key) | |||||
{ | |||||
return UploadData.ContainsKey(key) ? UploadData[key] : string.Empty; | |||||
} | |||||
public static long length = 0; | |||||
/// <summary> | |||||
/// 一次性上传的包 | |||||
/// </summary> | |||||
public static byte[] FileBlock; | public static byte[] FileBlock; | ||||
/// <summary> | /// <summary> | ||||
/// 请求反馈信息 | |||||
/// </summary> | |||||
public static FileUploadModelResult modelResult=null; | |||||
/// <summary> | |||||
/// 文件请求上传 | /// 文件请求上传 | ||||
/// </summary> | /// </summary> | ||||
public static void FileRequest(DataVReport dataV) | public static void FileRequest(DataVReport dataV) | ||||
{ | { | ||||
FileBlock = FileContent(path); | |||||
length = FileBlock.Count(); | |||||
FileUploadModel fileUpload = new FileUploadModel(); | |||||
fileUpload.@params.fileName = FileName; | |||||
fileUpload.@params.fileSize = length; | |||||
fileUpload.@params.conflictStrategy = "overwrite";//覆盖模式 | |||||
//fileUpload.@params.ficMode = "crc64"; | |||||
//fileUpload.@params.ficValue = CRC.ToCRC16(FileBlock); | |||||
fileUpload.@params.initUid = $"ab{RandomHelper.GenerateRandomCode()}"; | |||||
ThreadManage.GetInstance().Start(new Action(() => | |||||
{ | |||||
try | |||||
{ | |||||
List<QueryDeviceFileResponseBodyData> queryDeviceFiles= Sample.FileQueryALL(DataVClient.GetInstance().DeviceName); | |||||
QueryDeviceFileResponseBodyData _data= queryDeviceFiles?.Find(par => par.Name == FileName); | |||||
if (_data != null)//删除文件 | |||||
{ | |||||
MessageLog.GetInstance.Show("阿里云设备下文件已存在,准备删除续传..."); | |||||
Sample.DeleteFile(DataVClient.GetInstance().DeviceName, _data.FileId); | |||||
MessageLog.GetInstance.Show("删除成功.准备上传.."); | |||||
} | |||||
byte[] FileBlockALL = FileContent(path); | |||||
//分包上传 | |||||
int length = FileBlockALL.Count(); | |||||
int bfb = (FileBlockALL.Count() / 130000) + 1; | |||||
MessageLog.GetInstance.Show($"[阿里云上传]:文件整理中总长度[{length}]字节,分包数[{bfb}]包."); | |||||
//分包上传 | |||||
for (int i = 0; i < bfb; i++) | |||||
{ | |||||
modelResult = null; | |||||
byte[] data; | |||||
if (i == bfb - 1) data = new byte[FileBlockALL.Count() - i * 130000];//最后一包 | |||||
else data = new byte[130000];//前面的包 | |||||
//上传到阿里云物联网平台的OSS存储空间中 | |||||
fileUpload.@params.extraParams.ossOwnerType = "iot-platform"; | |||||
for (int k = 0; k < data.Length; k++) | |||||
{ | |||||
data[k] = FileBlockALL[k + i * 130000]; | |||||
} | |||||
FileBlock = data; | |||||
//表示上传到设备所属用户自己的OSS存储空间中 | |||||
//{ossbucket}/aliyun-iot-device-file/${instanceId}/${productKey}/${serviceId}/${deviceName}/${fileName} | |||||
//fileUpload.@params.extraParams.ossOwnerType = "device-user"; | |||||
//fileUpload.@params.extraParams.serviceId = "black"; | |||||
//fileUpload.@params.extraParams.fileTag = new Dictionary<string, string> { {"Time", DateTime.Now.ToString("yyyy_M_d") },{"Name", "HBL.LogDir" } }; | |||||
FileUploadModel fileUpload = new FileUploadModel(); | |||||
fileUpload.@params.fileName = FileName; | |||||
fileUpload.@params.fileSize =-1; | |||||
dataV.IOT_Publish(dataV.FileUpLoadTopic, Tools.JsonConvertTools(fileUpload)); | |||||
fileUpload.@params.conflictStrategy = length>130000 ? "append":"overwrite"; | |||||
//fileUpload.@params.conflictStrategy = "append";// "overwrite";//覆盖模式 | |||||
//fileUpload.@params.ficMode = "crc64"; | |||||
//fileUpload.@params.ficValue = CRC.ToCRC16(FileBlock); | |||||
fileUpload.@params.initUid = $"ab{RandomHelper.GenerateRandomCode()}"; | |||||
//上传到阿里云物联网平台的OSS存储空间中 | |||||
fileUpload.@params.extraParams.ossOwnerType = "iot-platform"; | |||||
//表示上传到设备所属用户自己的OSS存储空间中 | |||||
//{ossbucket}/aliyun-iot-device-file/${instanceId}/${productKey}/${serviceId}/${deviceName}/${fileName} | |||||
//fileUpload.@params.extraParams.ossOwnerType = "device-user"; | |||||
//fileUpload.@params.extraParams.serviceId = "black"; | |||||
//fileUpload.@params.extraParams.fileTag = new Dictionary<string, string> { {"Time", DateTime.Now.ToString("yyyy_M_d") },{"Name", "HBL.LogDir" } }; | |||||
dataV.IOT_Publish(dataV.FileUpLoadTopic, Tools.JsonConvertTools(fileUpload)); | |||||
MessageLog.GetInstance.Show($"[阿里云上传]:第[{i+1}]包数据,请求上传."); | |||||
int count = 0; | |||||
while (modelResult == null)//等待上传完成 | |||||
{ | |||||
if (count > 5) | |||||
{ | |||||
MessageLog.GetInstance.Show($"[阿里云上传]:超时上传、未知原因、退出线程."); | |||||
return; | |||||
} | |||||
Thread.Sleep(3000); count++; | |||||
} | |||||
; | |||||
if(modelResult.code==200) | |||||
MessageLog.GetInstance.Show($"[阿里云上传]:第[{i + 1}]包,上传成功."); | |||||
else | |||||
MessageLog.GetInstance.Show($"[阿里云上传]:第[{i + 1}]包,上传失败.原因:{modelResult.message}"); | |||||
; | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||||
} | |||||
}), "文件请求上传", false); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 文件上传 | /// 文件上传 | ||||
/// </summary> | /// </summary> | ||||
public static void FileSend(DataVReport dataV, string uploadId) | |||||
public static void FileSend(DataVReport dataV, string uploadId,long offset) | |||||
{ | { | ||||
FileSendModel fileSend = new FileSendModel(); | FileSendModel fileSend = new FileSendModel(); | ||||
fileSend.@params.uploadId = uploadId; | fileSend.@params.uploadId = uploadId; | ||||
fileSend.@params.offset = 0; | |||||
fileSend.@params.bSize = length; | |||||
fileSend.@params.offset = offset; | |||||
fileSend.@params.bSize = FileBlock.Count(); | |||||
fileSend.@params.isComplete = FileBlock.Count()==130000?false:true; | |||||
//结构如下图 | //结构如下图 | ||||
//Header.length(高 低) + Header(字节数组UTF-8) + 文件分片的字节数组 + "分片校验值CrC16 低 高" | //Header.length(高 低) + Header(字节数组UTF-8) + 文件分片的字节数组 + "分片校验值CrC16 低 高" | ||||
byte[] Header = Encoding.UTF8.GetBytes(Tools.JsonConvertTools(fileSend)); | byte[] Header = Encoding.UTF8.GetBytes(Tools.JsonConvertTools(fileSend)); | ||||
@@ -0,0 +1,152 @@ | |||||
using DataVAPI.Tool.IOT; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using Tea; | |||||
using static AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileResponseBody; | |||||
namespace BPASmartClient.IoT.Model | |||||
{ | |||||
public class Sample | |||||
{ | |||||
/** | |||||
* 使用AK&SK初始化账号Client | |||||
* @param accessKeyId | |||||
* @param accessKeySecret | |||||
* @return Client | |||||
* @throws Exception | |||||
*/ | |||||
public static AlibabaCloud.SDK.Iot20180120.Client CreateClient(string accessKeyId, string accessKeySecret) | |||||
{ | |||||
AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config | |||||
{ | |||||
// 您的AccessKey ID | |||||
AccessKeyId = accessKeyId, | |||||
// 您的AccessKey Secret | |||||
AccessKeySecret = accessKeySecret, | |||||
}; | |||||
// 访问的域名 | |||||
config.Endpoint = "iot.cn-shanghai.aliyuncs.com"; | |||||
return new AlibabaCloud.SDK.Iot20180120.Client(config); | |||||
} | |||||
public static List<QueryDeviceFileResponseBodyData> FileQueryALL(string DeviceName) | |||||
{ | |||||
List<QueryDeviceFileResponseBodyData> retdata = new List<QueryDeviceFileResponseBodyData>(); | |||||
AlibabaCloud.SDK.Iot20180120.Client client = CreateClient("LTAI5tDbUDuCvqU5hP8ZpHHV", "SvNIRQuz3BQFEaC3PFSJdgpeOKWFRi"); | |||||
AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileListRequest queryDeviceFileListRequest = new AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileListRequest | |||||
{ | |||||
IotInstanceId = "iot-06z00g9pf3kwtxp", | |||||
DeviceName = DataVClient.GetInstance().DeviceName, | |||||
ProductKey = DataVClient.GetInstance().ProductKey, | |||||
}; | |||||
AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); | |||||
AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileListResponse resp = client.QueryDeviceFileListWithOptions(queryDeviceFileListRequest, runtime); | |||||
AlibabaCloudRes cloudRes = Tools.JsonToObjectTools<AlibabaCloudRes>(AlibabaCloud.TeaUtil.Common.ToJSONString(resp.ToMap())); | |||||
cloudRes?.body?.Data?.FileSummary?.ForEach(fileSummary => | |||||
{ | |||||
QueryDeviceFileResponseBodyData _data = FileQuery(DeviceName, fileSummary.FileId); | |||||
if (_data != null) | |||||
{ | |||||
_data.UtcCreatedOn = DateTime.Parse(_data.UtcCreatedOn).AddHours(8).ToString("yyyy-MM-dd HH:mm:ss"); | |||||
_data.DownloadUrl = _data.DownloadUrl.Replace("http://", "https://"); | |||||
retdata.Add(_data); | |||||
} | |||||
}); | |||||
return retdata; | |||||
} | |||||
/// <summary> | |||||
/// 替换字符串起始位置(开头)中指定的字符串 | |||||
/// </summary> | |||||
/// <param name="s">源串</param> | |||||
/// <param name="searchStr">查找的串</param> | |||||
/// <param name="replaceStr">替换的目标串</param> | |||||
/// <returns></returns> | |||||
public static string CutStarStr(string s, string searchStr, string replaceStr) | |||||
{ | |||||
var result = s; | |||||
try | |||||
{ | |||||
if (string.IsNullOrEmpty(result)) | |||||
{ | |||||
return result; | |||||
} | |||||
if (s.Length < searchStr.Length) | |||||
{ | |||||
return result; | |||||
} | |||||
if (s.IndexOf(searchStr, 0, searchStr.Length, StringComparison.Ordinal) > -1) | |||||
{ | |||||
result = s.Substring(searchStr.Length); | |||||
} | |||||
return result; | |||||
} | |||||
catch (Exception e) | |||||
{ | |||||
return result; | |||||
} | |||||
} | |||||
public static QueryDeviceFileResponseBodyData FileQuery(string DeviceName, string FileId) | |||||
{ | |||||
AlibabaCloud.SDK.Iot20180120.Client client = CreateClient("LTAI5tDbUDuCvqU5hP8ZpHHV", "SvNIRQuz3BQFEaC3PFSJdgpeOKWFRi"); | |||||
AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileRequest queryDeviceFileRequest = new AlibabaCloud.SDK.Iot20180120.Models.QueryDeviceFileRequest | |||||
{ | |||||
IotInstanceId = "iot-06z00g9pf3kwtxp", | |||||
DeviceName = DataVClient.GetInstance().DeviceName, | |||||
ProductKey = DataVClient.GetInstance().ProductKey, | |||||
FileId = FileId, | |||||
}; | |||||
AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); | |||||
// 复制代码运行请自行打印 API 的返回值 | |||||
QueryDeviceFileResponseBodyData queryDeviceFile = client.QueryDeviceFileWithOptions(queryDeviceFileRequest, runtime).Body.Data; | |||||
return queryDeviceFile; | |||||
} | |||||
public static bool? DeleteFile(string DeviceName, string FileId) | |||||
{ | |||||
AlibabaCloud.SDK.Iot20180120.Client client = CreateClient("LTAI5tDbUDuCvqU5hP8ZpHHV", "SvNIRQuz3BQFEaC3PFSJdgpeOKWFRi"); | |||||
AlibabaCloud.SDK.Iot20180120.Models.DeleteDeviceFileRequest deleteDeviceFileRequest = new AlibabaCloud.SDK.Iot20180120.Models.DeleteDeviceFileRequest | |||||
{ | |||||
IotInstanceId = "iot-06z00g9pf3kwtxp", | |||||
DeviceName = DataVClient.GetInstance().DeviceName, | |||||
ProductKey = DataVClient.GetInstance().ProductKey, | |||||
FileId = FileId, | |||||
}; | |||||
AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); | |||||
// 复制代码运行请自行打印 API 的返回值 | |||||
return client.DeleteDeviceFileWithOptions(deleteDeviceFileRequest, runtime).Body.Success; | |||||
} | |||||
} | |||||
public class AlibabaCloudRes | |||||
{ | |||||
public object headers { get; set; } | |||||
public StrRes body { get; set; } | |||||
} | |||||
public class StrRes | |||||
{ | |||||
public string code { get; set; } | |||||
public string CurrentPage { get; set; } | |||||
public ResData Data { get; set; } | |||||
public string ErrorMessage { get; set; } | |||||
public int PageCount { get; set; } | |||||
public int PageSize { get; set; } | |||||
public string RequestId { get; set; } | |||||
public bool Success { get; set; } | |||||
public int Total { get; set; } | |||||
} | |||||
public class ResData | |||||
{ | |||||
public List<summary> FileSummary { get; set; } | |||||
} | |||||
public class summary | |||||
{ | |||||
public string UtcCreatedOn { get; set; } | |||||
public string Size { get; set; } | |||||
public string FileId { get; set; } | |||||
public string Name { get; set; } | |||||
} | |||||
} |
@@ -15,11 +15,7 @@ namespace BPASmartClient.LebaiRobot | |||||
public class LebaiHelper:Singleton<LebaiHelper> | public class LebaiHelper:Singleton<LebaiHelper> | ||||
{ | { | ||||
private LebaiRobotClient client; | private LebaiRobotClient client; | ||||
public RobotData robotData; | public RobotData robotData; | ||||
public bool IsIdle { get; set; } = false; | public bool IsIdle { get; set; } = false; | ||||
@@ -35,7 +35,7 @@ namespace BPASmartClient.PLC | |||||
{ | { | ||||
if (par?.Address.Length > 0) | if (par?.Address.Length > 0) | ||||
{ | { | ||||
var res = modbusTcp.READD(par.Address, (ushort)par.ReadLeng); | |||||
var res = modbusTcp.Read(par.Address, (ushort)par.ReadLeng); | |||||
if (status.ContainsKey(par.Address)) | if (status.ContainsKey(par.Address)) | ||||
{ | { | ||||
status[par.Address] = res; | status[par.Address] = res; | ||||
@@ -106,7 +106,7 @@ namespace BPASmartClient.PLC | |||||
if (@event == null) return; | if (@event == null) return; | ||||
var par = @event as WriteModel; | var par = @event as WriteModel; | ||||
modbusTcp.WRITEE(par?.Address, par?.Value); | |||||
modbusTcp.Write(par?.Address, par?.Value); | |||||
//ushort address = (ushort)modbusTcp.GetAddress(par?.Address); | //ushort address = (ushort)modbusTcp.GetAddress(par?.Address); | ||||
//if (par.Address.ToUpper().Contains("M")) | //if (par.Address.ToUpper().Contains("M")) | ||||
//{ | //{ | ||||
@@ -129,7 +129,7 @@ namespace BPASmartClient.Modbus | |||||
// } | // } | ||||
//} | //} | ||||
public object READD(string address, ushort len = 1, byte slaveAddress = 1) | |||||
public object Read(string address, ushort len = 1, byte slaveAddress = 1) | |||||
{ | { | ||||
if (address == null || tcpClient == null) return default(object); | if (address == null || tcpClient == null) return default(object); | ||||
ushort startAddress = (ushort)GetAddress(address); | ushort startAddress = (ushort)GetAddress(address); | ||||
@@ -164,7 +164,7 @@ namespace BPASmartClient.Modbus | |||||
return default(object); | return default(object); | ||||
} | } | ||||
public void WRITEE<T>(string address, T value, byte slaveAddress = 1) | |||||
public void Write<T>(string address, T value, byte slaveAddress = 1) | |||||
{ | { | ||||
if (address == null || tcpClient == null) return; | if (address == null || tcpClient == null) return; | ||||
ushort startAddress = (ushort)GetAddress(address); | ushort startAddress = (ushort)GetAddress(address); | ||||
@@ -1,7 +1,9 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | <Project Sdk="Microsoft.NET.Sdk"> | ||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFramework>net6.0</TargetFramework> | |||||
<TargetFramework>net6.0-windows</TargetFramework> | |||||
<Nullable>enable</Nullable> | |||||
<UseWPF>true</UseWPF> | |||||
<BaseOutputPath>bin\</BaseOutputPath> | <BaseOutputPath>bin\</BaseOutputPath> | ||||
<DebugType>portable</DebugType> | <DebugType>portable</DebugType> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
@@ -1,7 +1,8 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | <Project Sdk="Microsoft.NET.Sdk"> | ||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFramework>net6.0</TargetFramework> | |||||
<TargetFramework>net6.0-windows</TargetFramework> | |||||
<UseWPF>true</UseWPF> | |||||
<ImplicitUsings>enable</ImplicitUsings> | <ImplicitUsings>enable</ImplicitUsings> | ||||
<Nullable>enable</Nullable> | <Nullable>enable</Nullable> | ||||
<BaseOutputPath>bin\</BaseOutputPath> | <BaseOutputPath>bin\</BaseOutputPath> | ||||
@@ -1,16 +1,20 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFramework>net6.0</TargetFramework> | |||||
<TargetFramework>net6.0-windows</TargetFramework> | |||||
<Nullable>enable</Nullable> | |||||
<UseWPF>true</UseWPF> | |||||
<BaseOutputPath>bin\</BaseOutputPath> | <BaseOutputPath>bin\</BaseOutputPath> | ||||
<DebugType>portable</DebugType> | <DebugType>portable</DebugType> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="BPA.Models" Version="1.0.10" /> | <PackageReference Include="BPA.Models" Version="1.0.10" /> | ||||
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | <ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.EventBus\BPASmartClient.EventBus.csproj" /> | <ProjectReference Include="..\BPASmartClient.EventBus\BPASmartClient.EventBus.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" /> | <ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" /> | ||||
@@ -73,116 +73,130 @@ namespace BPASmartClient.MorkS | |||||
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); | EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); | ||||
} | } | ||||
private void ReadData(string address, ushort len = 1, Action<bool[]> action = null) | |||||
{ | |||||
EventBus.EventBus.GetInstance().Publish(new ReadModel() { DeviceId = DeviceId, Address = address, Length = len }, (o) => | |||||
{ | |||||
if (o != null && o.Length > 0 && o[0] is bool[] bools) | |||||
{ | |||||
action(bools); | |||||
} | |||||
}); | |||||
} | |||||
private void GetStatus(string key, Action<bool[]> action) | |||||
private void GetStatus(string key, Action<object> action) | |||||
{ | { | ||||
if (peripheralStatus.ContainsKey(key)) | if (peripheralStatus.ContainsKey(key)) | ||||
{ | { | ||||
if (peripheralStatus[key] is bool[] bools) | |||||
if (peripheralStatus[key] != null) | |||||
{ | { | ||||
action?.Invoke(bools); | |||||
action?.Invoke(peripheralStatus[key]); | |||||
} | } | ||||
//action((bool[])peripheralStatus[key]); | |||||
} | } | ||||
} | } | ||||
public override void ReadData() | public override void ReadData() | ||||
{ | { | ||||
GetStatus("M230.0", new Action<bool[]>((bools) => | |||||
GetStatus("M230.0", new Action<object>((obj) => | |||||
{ | { | ||||
alarm.MachineLeftLowTemperature = bools[0]; | |||||
alarm.MachineRightLowTemperature = bools[1]; | |||||
alarm.Supply1_LossBowl = bools[2]; | |||||
alarm.Supply2_LossBowl = bools[3]; | |||||
alarm.Supply1_ErrorOutBowl = bools[4]; | |||||
alarm.Supply2_ErrorOutBowl = bools[5]; | |||||
alarm.PushBowlCylinderError = bools[6]; | |||||
alarm.NoodleMacCommunicateError = bools[7]; | |||||
alarm.DosingMacCommunicateError = bools[8]; | |||||
alarm.RobotMacCommunicateError = bools[9]; | |||||
alarm.DeviceEstop = bools[10]; | |||||
alarm.RobotInitError = bools[11]; | |||||
alarm.RobotUrgentStop = bools[12]; | |||||
alarm.RobotNotInRemoteMode = bools[13]; | |||||
alarm.RobotNotInReady = bools[14]; | |||||
alarm.RobotSelfInException = bools[15]; | |||||
alarm.LeftLackWater = bools[16]; | |||||
alarm.RightLackWater = bools[17]; | |||||
alarm.SvrewInitFail = bools[18]; | |||||
alarm.TurntableInitFail = bools[19]; | |||||
alarm.RobotInitFail = bools[20]; | |||||
alarm.NoodleCookerInitFail = bools[21]; | |||||
alarm.PushBowlInitFail1 = bools[22]; | |||||
alarm.PushBowlInitFail2 = bools[23]; | |||||
if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 24) | |||||
{ | |||||
alarm.MachineLeftLowTemperature = bools[0]; | |||||
alarm.MachineRightLowTemperature = bools[1]; | |||||
alarm.Supply1_LossBowl = bools[2]; | |||||
alarm.Supply2_LossBowl = bools[3]; | |||||
alarm.Supply1_ErrorOutBowl = bools[4]; | |||||
alarm.Supply2_ErrorOutBowl = bools[5]; | |||||
alarm.PushBowlCylinderError = bools[6]; | |||||
alarm.NoodleMacCommunicateError = bools[7]; | |||||
alarm.DosingMacCommunicateError = bools[8]; | |||||
alarm.RobotMacCommunicateError = bools[9]; | |||||
alarm.DeviceEstop = bools[10]; | |||||
alarm.RobotInitError = bools[11]; | |||||
alarm.RobotUrgentStop = bools[12]; | |||||
alarm.RobotNotInRemoteMode = bools[13]; | |||||
alarm.RobotNotInReady = bools[14]; | |||||
alarm.RobotSelfInException = bools[15]; | |||||
alarm.LeftLackWater = bools[16]; | |||||
alarm.RightLackWater = bools[17]; | |||||
alarm.SvrewInitFail = bools[18]; | |||||
alarm.TurntableInitFail = bools[19]; | |||||
alarm.RobotInitFail = bools[20]; | |||||
alarm.NoodleCookerInitFail = bools[21]; | |||||
alarm.PushBowlInitFail1 = bools[22]; | |||||
alarm.PushBowlInitFail2 = bools[23]; | |||||
} | |||||
})); | })); | ||||
GetStatus("M0.3", new Action<bool[]>((bools) => | |||||
GetStatus("M0.3", new Action<object>((obj) => | |||||
{ | { | ||||
mORKS.RobotTakeNoodle = bools[0]; | |||||
mORKS.RobotOutMeal = bools[1]; | |||||
mORKS.MoveTurntable = bools[2]; | |||||
if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 3) | |||||
{ | |||||
mORKS.RobotTakeNoodle = bools[0]; | |||||
mORKS.RobotOutMeal = bools[1]; | |||||
mORKS.MoveTurntable = bools[2]; | |||||
} | |||||
})); | })); | ||||
GetStatus("M100.0", new Action<bool[]>((bools) => | |||||
GetStatus("M100.0", new Action<object>((obj) => | |||||
{ | { | ||||
mORKS.InitComplete = bools[0]; | |||||
mORKS.TakeBowlIdle = bools[1]; | |||||
mORKS.TemperatureReached = bools[2]; | |||||
mORKS.AllowFallNoodle = bools[3]; | |||||
mORKS.RbTakeNoodleComplete = bools[4]; | |||||
mORKS.RbFallNoodleComplete = bools[5]; | |||||
mORKS.RbOutMealComplete = bools[6]; | |||||
mORKS.RobotIdle = bools[7]; | |||||
mORKS.TakeMealDetect = bools[8]; | |||||
mORKS.MissingBowl = bools[9]; | |||||
Initing = bools[10]; | |||||
mORKS.TurntableLowerLimit = bools[11]; | |||||
mORKS.MissingBowlSignal2 = bools[12]; | |||||
mORKS.TurntableUpLimit = bools[13]; | |||||
mORKS.FeedComplete = bools[14]; | |||||
mORKS.TurntableMoveInPlace = bools[15]; | |||||
if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 16) | |||||
{ | |||||
mORKS.InitComplete = bools[0]; | |||||
mORKS.TakeBowlIdle = bools[1]; | |||||
mORKS.TemperatureReached = bools[2]; | |||||
mORKS.AllowFallNoodle = bools[3]; | |||||
mORKS.RbTakeNoodleComplete = bools[4]; | |||||
mORKS.RbFallNoodleComplete = bools[5]; | |||||
mORKS.RbOutMealComplete = bools[6]; | |||||
mORKS.RobotIdle = bools[7]; | |||||
mORKS.TakeMealDetect = bools[8]; | |||||
mORKS.MissingBowl = bools[9]; | |||||
Initing = bools[10]; | |||||
mORKS.TurntableLowerLimit = bools[11]; | |||||
mORKS.MissingBowlSignal2 = bools[12]; | |||||
mORKS.TurntableUpLimit = bools[13]; | |||||
mORKS.FeedComplete = bools[14]; | |||||
mORKS.TurntableMoveInPlace = bools[15]; | |||||
} | |||||
})); | })); | ||||
GetStatus("M235.0", new Action<bool[]>((bools) => | |||||
GetStatus("M235.0", new Action<object>((obj) => | |||||
{ | { | ||||
mORKS.Error = bools[0]; | |||||
if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 1) | |||||
{ | |||||
mORKS.Error = bools[0]; | |||||
} | |||||
})); | })); | ||||
GetStatus("M102.0", new Action<bool[]>((bools) => | |||||
GetStatus("M102.0", new Action<object>((obj) => | |||||
{ | { | ||||
for (int i = 0; i < 6; i++) | |||||
if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 7) | |||||
{ | { | ||||
mORKS.NoodleCookerStatus[i] = bools[i]; | |||||
for (int i = 0; i < 6; i++) | |||||
{ | |||||
mORKS.NoodleCookerStatus[i] = bools[i]; | |||||
} | |||||
mORKS.Feeding = bools[6]; | |||||
} | } | ||||
mORKS.Feeding = bools[6]; | |||||
})); | })); | ||||
GetStatus("M103.0", new Action<bool[]>((bools) => | |||||
GetStatus("M103.0", new Action<object>((obj) => | |||||
{ | { | ||||
for (int i = 0; i < 6; i++) | |||||
if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 6) | |||||
{ | { | ||||
mORKS.CookNoodlesComplete[i] = bools[i]; | |||||
for (int i = 0; i < 6; i++) | |||||
{ | |||||
mORKS.CookNoodlesComplete[i] = bools[i]; | |||||
} | |||||
} | } | ||||
})); | })); | ||||
EventBus.EventBus.GetInstance().Publish(new ReadModel() { DeviceId = DeviceId, Address = "VW372", Length = 1 }, (o) => | |||||
GetStatus("VW372", new Action<object>((obj) => | |||||
{ | { | ||||
if (o != null && o.Length > 0 && o[0] is ushort value) | |||||
{ | |||||
mORKS.TurntableFeedbackloc = value; | |||||
} | |||||
}); | |||||
if (obj is ushort[] UshortValue && UshortValue.Length > 0 && UshortValue.Length <= 1) | |||||
mORKS.TurntableFeedbackloc = UshortValue[0]; | |||||
})); | |||||
//EventBus.EventBus.GetInstance().Publish(new ReadModel() { DeviceId = DeviceId, Address = "VW372", Length = 1 }, (o) => | |||||
//{ | |||||
// if (o != null && o.Length > 0 && o[0] is ushort value) | |||||
// { | |||||
// mORKS.TurntableFeedbackloc = value; | |||||
// } | |||||
//}); | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -0,0 +1,25 @@ | |||||
<UserControl | |||||
x:Class="BPASmartClient.MorkS.View.Debug" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmartClient.MorkS.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:vm="clr-namespace:BPASmartClient.MorkS.ViewModel" | |||||
Name="调试界面" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<UserControl.DataContext> | |||||
<vm:DebugViewModel /> | |||||
</UserControl.DataContext> | |||||
<Grid> | |||||
<Label | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="调试界面" | |||||
FontSize="40" /> | |||||
</Grid> | |||||
</UserControl> |
@@ -0,0 +1,28 @@ | |||||
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.MorkS.View | |||||
{ | |||||
/// <summary> | |||||
/// Debug.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class Debug : UserControl | |||||
{ | |||||
public Debug() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,25 @@ | |||||
<UserControl | |||||
x:Class="BPASmartClient.MorkS.View.Monitor" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmartClient.MorkS.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:vm="clr-namespace:BPASmartClient.MorkS.ViewModel" | |||||
Name="监控画面" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<UserControl.DataContext> | |||||
<vm:MonitorViewModel /> | |||||
</UserControl.DataContext> | |||||
<Grid> | |||||
<Label | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="监控画面" | |||||
FontSize="40" /> | |||||
</Grid> | |||||
</UserControl> |
@@ -0,0 +1,28 @@ | |||||
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.MorkS.View | |||||
{ | |||||
/// <summary> | |||||
/// Monitor.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class Monitor : UserControl | |||||
{ | |||||
public Monitor() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,147 @@ | |||||
<UserControl | |||||
x:Class="BPASmartClient.MorkS.View.ParSet" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmartClient.MorkS.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||||
xmlns:vm="clr-namespace:BPASmartClient.MorkS.ViewModel" | |||||
Name="参数设置界面" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<UserControl.DataContext> | |||||
<vm:ParSetViewModel /> | |||||
</UserControl.DataContext> | |||||
<UserControl.Resources> | |||||
<ResourceDictionary> | |||||
<ResourceDictionary.MergedDictionaries> | |||||
<ResourceDictionary> | |||||
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="18" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||||
</Style> | |||||
<Style x:Key="TextBoxStyle" TargetType="TextBox"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="22" /> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="BorderBrush" Value="#FF23CACA" /> | |||||
<Setter Property="CaretBrush" Value="Aqua" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
</Style> | |||||
</ResourceDictionary> | |||||
</ResourceDictionary.MergedDictionaries> | |||||
</ResourceDictionary> | |||||
</UserControl.Resources> | |||||
<Grid Margin="10"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="40" /> | |||||
<RowDefinition Height="35" /> | |||||
<RowDefinition Height="Auto" /> | |||||
</Grid.RowDefinitions> | |||||
<CheckBox | |||||
Grid.Row="0" | |||||
Grid.Column="2" | |||||
Height="20" | |||||
Margin="10" | |||||
VerticalAlignment="Top" | |||||
Background="#FF2AB2E7" | |||||
Content="开机启动" | |||||
FontSize="14" | |||||
Foreground="#00c2f4" | |||||
IsChecked="{Binding IsSelected}" | |||||
Template="{StaticResource CbTemplate}" /> | |||||
<StackPanel | |||||
Grid.Row="1" | |||||
HorizontalAlignment="Right" | |||||
Orientation="Horizontal"> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="请点击按钮保存参数:" /> | |||||
<pry:IcoButton | |||||
Grid.Column="5" | |||||
Width="140" | |||||
HorizontalAlignment="Left" | |||||
Command="{Binding SaveInfoCommand}" | |||||
Content="保存配置" | |||||
FontSize="16" | |||||
IcoText="" | |||||
Style="{StaticResource NewButtonStyle}"> | |||||
<pry:IcoButton.Foreground> | |||||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||||
<GradientStop Color="#FFBB662A" /> | |||||
<GradientStop Offset="1" Color="White" /> | |||||
</LinearGradientBrush> | |||||
</pry:IcoButton.Foreground> | |||||
</pry:IcoButton> | |||||
</StackPanel> | |||||
<!-- 参数放置面板 --> | |||||
<Grid Grid.Row="2"> | |||||
<ItemsControl ItemsSource="{Binding parSets}"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<StackPanel Orientation="Horizontal"> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding TextBlockContext}" /> | |||||
<TextBox | |||||
Width="100" | |||||
Margin="10,0,0,0" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Text="{Binding Minute}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(分)" /> | |||||
<TextBox | |||||
Width="100" | |||||
Margin="0,10" | |||||
VerticalAlignment="Center" | |||||
Background="Transparent" | |||||
BorderBrush="#FF23CACA" | |||||
CaretBrush="Aqua" | |||||
FontFamily="楷体" | |||||
FontSize="21" | |||||
Foreground="#ff34f7f7" | |||||
Text="{Binding Second}" /> | |||||
<TextBlock Style="{StaticResource TextBlockStyle}" Text="(秒)" /> | |||||
<CheckBox | |||||
Height="20" | |||||
Margin="10" | |||||
VerticalAlignment="Center" | |||||
Background="#FF2AB2E7" | |||||
Content="{Binding CheckBoxContext}" | |||||
FontSize="14" | |||||
Foreground="#00c2f4" | |||||
IsChecked="{Binding IsShield}" | |||||
Template="{StaticResource CbTemplate}" /> | |||||
</StackPanel> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
</Grid> | |||||
</Grid> | |||||
</UserControl> |
@@ -0,0 +1,28 @@ | |||||
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.MorkS.View | |||||
{ | |||||
/// <summary> | |||||
/// ParSet.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class ParSet : UserControl | |||||
{ | |||||
public ParSet() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,18 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
namespace BPASmartClient.MorkS.ViewModel | |||||
{ | |||||
public class DebugViewModel : ObservableObject | |||||
{ | |||||
public DebugViewModel() | |||||
{ | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,17 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
namespace BPASmartClient.MorkS.ViewModel | |||||
{ | |||||
public class MonitorViewModel : ObservableObject | |||||
{ | |||||
public MonitorViewModel() | |||||
{ | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,17 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
namespace BPASmartClient.MorkS.ViewModel | |||||
{ | |||||
public class ParSetViewModel : ObservableObject | |||||
{ | |||||
public ParSetViewModel() | |||||
{ | |||||
} | |||||
} | |||||
} |
@@ -1,15 +1,32 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | <Project Sdk="Microsoft.NET.Sdk"> | ||||
<PropertyGroup> | <PropertyGroup> | ||||
<TargetFramework>net6.0</TargetFramework> | |||||
<TargetFramework>net6.0-windows</TargetFramework> | |||||
<Nullable>enable</Nullable> | |||||
<UseWPF>true</UseWPF> | |||||
<BaseOutputPath>D:\HBL\Porgram\BPASmartClient\BPASmartClient\bin\Debug\net6.0-windows\Devices</BaseOutputPath> | <BaseOutputPath>D:\HBL\Porgram\BPASmartClient\BPASmartClient\bin\Debug\net6.0-windows\Devices</BaseOutputPath> | ||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | <ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.DRCoffee\BPASmartClient.DRCoffee.csproj" /> | |||||
<ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" /> | <ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.Lebai\BPASmartClient.Lebai.csproj" /> | <ProjectReference Include="..\BPASmartClient.Lebai\BPASmartClient.Lebai.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" /> | <ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | |||||
<Compile Update="View\DebugView.xaml.cs"> | |||||
<SubType>Code</SubType> | |||||
</Compile> | |||||
</ItemGroup> | |||||
<ItemGroup> | |||||
<Page Update="View\DebugView.xaml"> | |||||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||||
<SubType>Designer</SubType> | |||||
</Page> | |||||
</ItemGroup> | |||||
</Project> | </Project> |
@@ -1,14 +1,14 @@ | |||||
<UserControl x:Class="BPASmartClient.Control.MorkT_DebugView" | |||||
<UserControl x:Class="BPASmartClient.MorkT.View.DebugView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||||
xmlns:vm ="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" | |||||
xmlns:vm ="clr-namespace:BPASmartClient.MorkT.ViewModel" | |||||
mc:Ignorable="d" | mc:Ignorable="d" | ||||
Name="调试界面" | |||||
d:DesignHeight="450" d:DesignWidth="1000" > | d:DesignHeight="450" d:DesignWidth="1000" > | ||||
<UserControl.DataContext> | <UserControl.DataContext> | ||||
<vm:MorkT_DebugViewModel/> | |||||
<vm:DebugViewModel/> | |||||
</UserControl.DataContext> | </UserControl.DataContext> | ||||
<UserControl.Resources> | <UserControl.Resources> | ||||
<ResourceDictionary> | <ResourceDictionary> |
@@ -13,14 +13,14 @@ using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | using System.Windows.Navigation; | ||||
using System.Windows.Shapes; | using System.Windows.Shapes; | ||||
namespace BPASmartClient.Control | |||||
namespace BPASmartClient.MorkT.View | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// MorkT_DebugView.xaml 的交互逻辑 | /// MorkT_DebugView.xaml 的交互逻辑 | ||||
/// </summary> | /// </summary> | ||||
public partial class MorkT_DebugView : UserControl | |||||
public partial class DebugView : UserControl | |||||
{ | { | ||||
public MorkT_DebugView() | |||||
public DebugView() | |||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
} | } |
@@ -1,29 +1,23 @@ | |||||
using BPASmartClient.Business; | using BPASmartClient.Business; | ||||
using BPASmartClient.Device; | |||||
using BPASmartClient.DRCoffee; | using BPASmartClient.DRCoffee; | ||||
using BPASmartClient.EventBus; | using BPASmartClient.EventBus; | ||||
using BPASmartClient.GSIceCream; | using BPASmartClient.GSIceCream; | ||||
using BPASmartClient.Helper; | using BPASmartClient.Helper; | ||||
using BPASmartClient.Lebai; | |||||
using BPASmartClient.LebaiRobot; | using BPASmartClient.LebaiRobot; | ||||
using BPASmartClient.Message; | |||||
using BPASmartClient.Model; | using BPASmartClient.Model; | ||||
using BPASmartClient.Model.乐白机器人; | using BPASmartClient.Model.乐白机器人; | ||||
using BPASmartClient.Model.冰淇淋.Enum; | using BPASmartClient.Model.冰淇淋.Enum; | ||||
using BPASmartClient.Model.咖啡机.Enum; | using BPASmartClient.Model.咖啡机.Enum; | ||||
using BPASmartClient.SCChip; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | using Microsoft.Toolkit.Mvvm.ComponentModel; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
using System; | using System; | ||||
using System.Collections.Concurrent; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | |||||
namespace BPASmartClient.ViewModel | |||||
namespace BPASmartClient.MorkT.ViewModel | |||||
{ | { | ||||
public class MorkT_DebugViewModel : ObservableObject | |||||
public class DebugViewModel : ObservableObject | |||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// 设备ID | /// 设备ID | ||||
@@ -33,11 +27,13 @@ namespace BPASmartClient.ViewModel | |||||
/// <summary> | /// <summary> | ||||
/// 乐白机器人连接状态 | /// 乐白机器人连接状态 | ||||
/// </summary> | /// </summary> | ||||
public string RobotConnected { get; set; } | |||||
public string RobotConnected { get { return _robotConnected; } set { _robotConnected = value; OnPropertyChanged(); } } | |||||
private string _robotConnected { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 乐白机器人的模式状态 | /// 乐白机器人的模式状态 | ||||
/// </summary> | /// </summary> | ||||
public ELebaiRModel RobotMode { get; set; } | |||||
public ELebaiRModel RobotMode { get { return _robotMode; } set { _robotMode = value; OnPropertyChanged(); } } | |||||
private ELebaiRModel _robotMode { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 机器人控制指令 | /// 机器人控制指令 | ||||
/// </summary> | /// </summary> | ||||
@@ -66,43 +62,53 @@ namespace BPASmartClient.ViewModel | |||||
/// <summary> | /// <summary> | ||||
/// 冰淇淋连接状态 | /// 冰淇淋连接状态 | ||||
/// </summary> | /// </summary> | ||||
public string IceCreamConnected { get; set; } | |||||
public string IceCreamConnected { get { return _iceCreamConnected; } set { _iceCreamConnected = value; OnPropertyChanged(); } } | |||||
private string _iceCreamConnected { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 预冷温度 | /// 预冷温度 | ||||
/// </summary> | /// </summary> | ||||
public short YLWD { get; set; } | |||||
public short YLWD { get { return _yLWD; } set { _yLWD = value; OnPropertyChanged(); } } | |||||
private short _yLWD { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 回气温度 | /// 回气温度 | ||||
/// </summary> | /// </summary> | ||||
public short HQWD { get; set; } | |||||
public short HQWD { get { return _hQWD; } set { _hQWD = value; OnPropertyChanged(); } } | |||||
private short _hQWD { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 环境温度 | /// 环境温度 | ||||
/// </summary> | /// </summary> | ||||
public short HJWD { get; set; } | |||||
public short HJWD { get { return _hJWD; } set { _hJWD = value; OnPropertyChanged(); } } | |||||
private short _hJWD { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 电流 | /// 电流 | ||||
/// </summary> | /// </summary> | ||||
public short DL { get; set; } | |||||
public short DL { get { return _DL; } set { _DL = value; OnPropertyChanged(); } } | |||||
private short _DL { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 电压 | /// 电压 | ||||
/// </summary> | /// </summary> | ||||
public short DY { get; set; } | |||||
public short DY { get { return _dy; } set { _dy = value; OnPropertyChanged(); } } | |||||
private short _dy { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 当前模式 | /// 当前模式 | ||||
/// </summary> | /// </summary> | ||||
public MORKI_MODE CurrentMode { get; set; } | |||||
public MORKI_MODE CurrentMode { get { return _CurrentMode; } set { _CurrentMode = value; OnPropertyChanged(); } } | |||||
private MORKI_MODE _CurrentMode; | |||||
/// <summary> | /// <summary> | ||||
/// 故障 | /// 故障 | ||||
/// </summary> | /// </summary> | ||||
public MORKI_FAULT IceCreamFault { get; set; } | |||||
public MORKI_FAULT IceCreamFault { get { return _IceCreamFault; } set { _IceCreamFault = value; OnPropertyChanged(); } } | |||||
private MORKI_FAULT _IceCreamFault { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 成型比 | /// 成型比 | ||||
/// </summary> | /// </summary> | ||||
public byte CXB { get; set; } | |||||
public byte CXB { get { return _cXB; } set { _cXB = value; OnPropertyChanged(); } } | |||||
private byte _cXB { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 打料完成状态 | /// 打料完成状态 | ||||
/// </summary> | /// </summary> | ||||
public string DLCompleted { get; set; } | |||||
public string DLCompleted { get { return _dLCompleted; } set { _dLCompleted = value; OnPropertyChanged(); } } | |||||
private string _dLCompleted { get; set; } | |||||
public List<string> IceCreamModes { get; set; } = new List<string>(); | public List<string> IceCreamModes { get; set; } = new List<string>(); | ||||
public string SelecteIceCreamdMode { get; set; } | public string SelecteIceCreamdMode { get; set; } | ||||
@@ -114,8 +120,6 @@ namespace BPASmartClient.ViewModel | |||||
private void Button_SetIceCreamModel() | private void Button_SetIceCreamModel() | ||||
{ | { | ||||
MORKI_MODE mORKI_MODE = (MORKI_MODE)Enum.Parse(typeof(MORKI_MODE), SelecteIceCreamdMode); | MORKI_MODE mORKI_MODE = (MORKI_MODE)Enum.Parse(typeof(MORKI_MODE), SelecteIceCreamdMode); | ||||
//ActionManage.GetInstance.Send("测试", mORKI_MODE); | |||||
new GSIceCream_ModeSetEvent() { DeviceId = DeviceId, Mode = mORKI_MODE }.Publish(); | new GSIceCream_ModeSetEvent() { DeviceId = DeviceId, Mode = mORKI_MODE }.Publish(); | ||||
} | } | ||||
#endregion | #endregion | ||||
@@ -124,23 +128,28 @@ namespace BPASmartClient.ViewModel | |||||
/// <summary> | /// <summary> | ||||
/// 咖啡机连接状态 | /// 咖啡机连接状态 | ||||
/// </summary> | /// </summary> | ||||
public string CoffeeConnected { get; set; } | |||||
public string CoffeeConnected { get { return _coffeeConnected; } set { _coffeeConnected = value; OnPropertyChanged(); } } | |||||
private string _coffeeConnected { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 咖啡机状态 | /// 咖啡机状态 | ||||
/// </summary> | /// </summary> | ||||
public DrCoffeeStatus CoffeeStatus { get; set; } | |||||
public DrCoffeeStatus CoffeeStatus { get { return _coffeeStatus; } set { _coffeeStatus = value; OnPropertyChanged(); } } | |||||
private DrCoffeeStatus _coffeeStatus { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 应用状态 | /// 应用状态 | ||||
/// </summary> | /// </summary> | ||||
public DrCoffeeAppStatus AppStatus { get; set; } | |||||
public DrCoffeeAppStatus AppStatus { get { return _appStatus; } set { _appStatus = value; OnPropertyChanged(); } } | |||||
private DrCoffeeAppStatus _appStatus { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 告警 | /// 告警 | ||||
/// </summary> | /// </summary> | ||||
public DrCoffeeWarning Warning { get; set; } | |||||
public DrCoffeeWarning Warning { get { return _warning; } set { _warning = value; OnPropertyChanged(); } } | |||||
public DrCoffeeWarning _warning { get; set; } | |||||
/// <summary> | /// <summary> | ||||
/// 故障信息 | /// 故障信息 | ||||
/// </summary> | /// </summary> | ||||
public DrCoffeeFault CaffeeFault { get; set; } | |||||
public DrCoffeeFault CaffeeFault { get { return _caffeeFault; } set { _caffeeFault = value; OnPropertyChanged(); } } | |||||
public DrCoffeeFault _caffeeFault { get; set; } | |||||
public List<string> Coffees { get; set; } = new List<string>(); | public List<string> Coffees { get; set; } = new List<string>(); | ||||
public string SelectedCoffee { get; set; } | public string SelectedCoffee { get; set; } | ||||
@@ -152,7 +161,7 @@ namespace BPASmartClient.ViewModel | |||||
Dictionary<string, object> CurrentData { get; set; } | Dictionary<string, object> CurrentData { get; set; } | ||||
public MorkT_DebugViewModel() | |||||
public DebugViewModel() | |||||
{ | { | ||||
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl); | Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl); | ||||
Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream); | Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream); | ||||
@@ -181,6 +190,7 @@ namespace BPASmartClient.ViewModel | |||||
{ | { | ||||
Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device => | Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device => | ||||
{ | { | ||||
CurrentData?.Clear(); | |||||
if (device.Name == "MorkT") CurrentData = device.Status.GetStatus(); | if (device.Name == "MorkT") CurrentData = device.Status.GetStatus(); | ||||
DeviceId = device.DeviceId; | DeviceId = device.DeviceId; | ||||
}); | }); |
@@ -0,0 +1,104 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using System.Collections.ObjectModel; | |||||
using BPASmartClient.Helper; | |||||
using System.IO; | |||||
using Newtonsoft.Json; | |||||
using BPASmartClient.Model; | |||||
using System.Reflection; | |||||
using Microsoft.Toolkit.Mvvm.Input; | |||||
using System.Windows; | |||||
namespace BPASmartClient.ViewModel | |||||
{ | |||||
public class DeviceMonitorViewModel : ObservableObject | |||||
{ | |||||
public DeviceMonitorViewModel() | |||||
{ | |||||
DeviceSwitch = new RelayCommand<object>((o) => | |||||
{ | |||||
if (o is string nameSpace) | |||||
{ | |||||
DeviceMonitors.Clear(); | |||||
Assembly.Load(nameSpace.Substring(0, nameSpace.LastIndexOf("."))).GetTypes().ToList().ForEach((type) => | |||||
{ | |||||
if (type?.BaseType?.Name == "UserControl") | |||||
{ | |||||
var fe = type.GetConstructor(Type.EmptyTypes).Invoke(null) as FrameworkElement; | |||||
DeviceMonitors.Add(new Device() { Name = fe.Name, Namespace = type?.FullName, fe = fe }); | |||||
} | |||||
}); | |||||
} | |||||
}); | |||||
DeviceWindowSwitch = new RelayCommand<object>((o) => | |||||
{ | |||||
if (o != null && o is string nameSpace) | |||||
{ | |||||
var fe = DeviceMonitors.FirstOrDefault(p => p.Namespace == nameSpace); | |||||
if (fe != null) MainContent = fe.fe; | |||||
} | |||||
}); | |||||
GetData(); | |||||
} | |||||
private void GetData() | |||||
{ | |||||
var text = TextHelper.GetInstance.ReadTextInfo("StartShop", "DeviceConfig"); | |||||
string path = $"{LocaPath.GetInstance().GetDeviceConfigPath}{text}.json"; | |||||
if (File.Exists(path)) | |||||
{ | |||||
string JsonString = File.ReadAllText(path); | |||||
var result = JsonConvert.DeserializeObject<ObservableCollection<DeviceConfigModelJson>>(JsonString); | |||||
if (result != null) | |||||
{ | |||||
foreach (var shop in result)//店铺集合 | |||||
{ | |||||
foreach (var device in shop.deviceModels)//设备集合 | |||||
{ | |||||
Devices.Add(new Device() { Name = device.DeviceName, Namespace = device.DeviceNamespace }); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
public FrameworkElement MainContent { get { return _mMainContent; } set { _mMainContent = value; OnPropertyChanged(); } } | |||||
private FrameworkElement _mMainContent; | |||||
public RelayCommand<object> DeviceSwitch { get; set; } | |||||
public RelayCommand<object> DeviceWindowSwitch { get; set; } | |||||
public ObservableCollection<Device> Devices { get; set; } = new ObservableCollection<Device>(); | |||||
public ObservableCollection<Device> DeviceMonitors { get; set; } = new ObservableCollection<Device>(); | |||||
} | |||||
public class Device : ObservableObject | |||||
{ | |||||
public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged(); } } | |||||
private string _mName; | |||||
public string Namespace { get { return _mNamespace; } set { _mNamespace = value; OnPropertyChanged(); } } | |||||
private string _mNamespace; | |||||
public FrameworkElement fe { get; set; } | |||||
} | |||||
} |
@@ -1,181 +0,0 @@ | |||||
//using System; | |||||
//using System.Collections.Generic; | |||||
//using System.Linq; | |||||
//using System.Text; | |||||
//using System.Threading.Tasks; | |||||
//using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
//using System.Collections.ObjectModel; | |||||
//using Microsoft.Toolkit.Mvvm.Input; | |||||
//using System.Windows; | |||||
//namespace BPASmartClient.ViewModel.Model | |||||
//{ | |||||
// /// <summary> | |||||
// /// 店铺设备 | |||||
// /// </summary> | |||||
// public class DeviceConfigModel : ObservableObject | |||||
// { | |||||
// /// <summary> | |||||
// /// 店铺名称 | |||||
// /// </summary> | |||||
// public string ShopName { get { return _mShopName; } set { _mShopName = value; OnPropertyChanged(); } } | |||||
// private string _mShopName = string.Empty; | |||||
// /// <summary> | |||||
// /// 店铺ID | |||||
// /// </summary> | |||||
// public string ShopId { get { return _mShopId; } set { _mShopId = value; OnPropertyChanged(); } } | |||||
// private string _mShopId = string.Empty; | |||||
// /// <summary> | |||||
// /// 设备集合 | |||||
// /// </summary> | |||||
// public ObservableCollection<DeviceModel> deviceModels { get; set; } = new ObservableCollection<DeviceModel>(); | |||||
// } | |||||
// /// <summary> | |||||
// /// 启动模块 | |||||
// /// </summary> | |||||
// public class DeviceModel : ObservableObject | |||||
// { | |||||
// /// <summary> | |||||
// /// 设备名称 | |||||
// /// </summary> | |||||
// public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } | |||||
// private string _mDeviceName = string.Empty; | |||||
// /// <summary> | |||||
// /// 启动设备模块 | |||||
// /// </summary> | |||||
// public string DeviceModule { get { return _mDeviceModule; } set { _mDeviceModule = value; OnPropertyChanged(); } } | |||||
// private string _mDeviceModule = string.Empty; | |||||
// public string DeviceNamespace { get; set; } | |||||
// public string Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } } | |||||
// private string _mId = string.Empty; | |||||
// /// <summary> | |||||
// /// 设备ID | |||||
// /// </summary> | |||||
// public string DeviceId { get { return _mDeviceId; } set { _mDeviceId = value; OnPropertyChanged(); } } | |||||
// private string _mDeviceId = string.Empty; | |||||
// /// <summary> | |||||
// /// 通讯模块 | |||||
// /// </summary> | |||||
// public ObservableCollection<CommunicationModel> communicationDevcies { get; set; } = new ObservableCollection<CommunicationModel>(); | |||||
// } | |||||
// /// <summary> | |||||
// /// 通讯模块 | |||||
// /// </summary> | |||||
// public class CommunicationModel : ObservableObject | |||||
// { | |||||
// /// <summary> | |||||
// /// 通讯启动模块 | |||||
// /// </summary> | |||||
// public string CommunicationModule { get { return _mCommunicationModule; } set { _mCommunicationModule = value; OnPropertyChanged(); } } | |||||
// private string _mCommunicationModule = string.Empty; | |||||
// public string CommunicationNamespace { get; set; } | |||||
// public string CommunicationName { get { return _mCommunicationName; } set { _mCommunicationName = value; OnPropertyChanged(); } } | |||||
// private string _mCommunicationName = string.Empty; | |||||
// public string DeviceModelId { get { return _mDeviceModelId; } set { _mDeviceModelId = value; OnPropertyChanged(); } } | |||||
// private string _mDeviceModelId = string.Empty; | |||||
// public CommunicationPar communicationPar { get { return _mcommunicationPar; } set { _mcommunicationPar = value; OnPropertyChanged(); } } | |||||
// private CommunicationPar _mcommunicationPar = new CommunicationPar(); | |||||
// } | |||||
// /// <summary> | |||||
// /// 通讯参数 | |||||
// /// </summary> | |||||
// public class CommunicationPar : ObservableObject | |||||
// { | |||||
// /// <summary> | |||||
// /// 选择网口通讯 | |||||
// /// </summary> | |||||
// public bool IsNetworkPort { get { return _mIsNetworkPort; } set { _mIsNetworkPort = value; OnPropertyChanged(); } } | |||||
// private bool _mIsNetworkPort = false; | |||||
// /// <summary> | |||||
// /// 选择串口通讯 | |||||
// /// </summary> | |||||
// public bool IsSerialPort { get { return _mIsSerialPort; } set { _mIsSerialPort = value; OnPropertyChanged(); } } | |||||
// private bool _mIsSerialPort = true; | |||||
// /// <summary> | |||||
// /// IP地址 | |||||
// /// </summary> | |||||
// public string IPAddress { get { return _mIPAddress; } set { _mIPAddress = value; OnPropertyChanged(); } } | |||||
// private string _mIPAddress; | |||||
// /// <summary> | |||||
// /// IP 端口号 | |||||
// /// </summary> | |||||
// public int IPPort { get { return _mIPPort; } set { _mIPPort = value; OnPropertyChanged(); } } | |||||
// private int _mIPPort; | |||||
// /// <summary> | |||||
// /// ip 串口 站号 | |||||
// /// </summary> | |||||
// public int StationNo { get { return _mStationNo; } set { _mStationNo = value; OnPropertyChanged(); } } | |||||
// private int _mStationNo; | |||||
// /// <summary> | |||||
// /// 串口单口号 | |||||
// /// </summary> | |||||
// public string SerialPort { get { return _mSerialPort; } set { _mSerialPort = value; OnPropertyChanged(); } } | |||||
// private string _mSerialPort; | |||||
// /// <summary> | |||||
// /// 波特率 | |||||
// /// </summary> | |||||
// public int BaudRate { get { return _mBaudRate; } set { _mBaudRate = value; OnPropertyChanged(); } } | |||||
// private int _mBaudRate; | |||||
// /// <summary> | |||||
// /// 数据位 | |||||
// /// </summary> | |||||
// public int DataBits { get { return _mDataBits; } set { _mDataBits = value; OnPropertyChanged(); } } | |||||
// private int _mDataBits = 8; | |||||
// /// <summary> | |||||
// /// 停止位 | |||||
// /// </summary> | |||||
// public string StopBits { get { return _mStopBits; } set { _mStopBits = value; OnPropertyChanged(); } } | |||||
// private string _mStopBits = "1"; | |||||
// /// <summary> | |||||
// /// 校验位 | |||||
// /// </summary> | |||||
// public string Parity { get { return _mParity; } set { _mParity = value; OnPropertyChanged(); } } | |||||
// private string _mParity; | |||||
// public ObservableCollection<Variable> variables { get; set; } = new ObservableCollection<Variable>(); | |||||
// } | |||||
// public class Variable : ObservableObject | |||||
// { | |||||
// public int Id { get { return _mId; } set { _mId = value; OnPropertyChanged(); } } | |||||
// private int _mId; | |||||
// public string Address { get { return _mAddress; } set { _mAddress = value; OnPropertyChanged(); } } | |||||
// private string _mAddress; | |||||
// public int ReadLeng { get { return _mReadLeng; } set { _mReadLeng = value; OnPropertyChanged(); } } | |||||
// private int _mReadLeng; | |||||
// } | |||||
//} |
@@ -26,7 +26,8 @@ | |||||
</ResourceDictionary> | </ResourceDictionary> | ||||
<ResourceDictionary> | <ResourceDictionary> | ||||
<ImageBrush x:Key="hbl" ImageSource="pack://application:,,,/BPASmartClient.CustomResource;component/Image/HBL.png" /> | |||||
<ImageBrush x:Key="hbl" ImageSource="/BPASmartClient.CustomResource;component/Image/HBL.png" /> | |||||
<ImageBrush x:Key="dbxt" ImageSource="/BPASmartClient.CustomResource;component/Image/顶部线条.png" /> | |||||
</ResourceDictionary> | </ResourceDictionary> | ||||
</ResourceDictionary.MergedDictionaries> | </ResourceDictionary.MergedDictionaries> | ||||
@@ -7,8 +7,13 @@ | |||||
<UseWPF>true</UseWPF> | <UseWPF>true</UseWPF> | ||||
<UseWindowsForms>true</UseWindowsForms> | <UseWindowsForms>true</UseWindowsForms> | ||||
<StartupObject>BPASmartClient.App</StartupObject> | <StartupObject>BPASmartClient.App</StartupObject> | ||||
<ApplicationIcon>hbl.ico</ApplicationIcon> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | |||||
<Content Include="hbl.ico" /> | |||||
</ItemGroup> | |||||
<ItemGroup> | <ItemGroup> | ||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1185.39" /> | <PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1185.39" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
@@ -30,7 +35,6 @@ | |||||
<ProjectReference Include="..\BPASmartClient.MorkT\BPASmartClient.MorkT.csproj" /> | <ProjectReference Include="..\BPASmartClient.MorkT\BPASmartClient.MorkT.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.SCChip\BPASmartClient.SCChip.csproj" /> | <ProjectReference Include="..\BPASmartClient.SCChip\BPASmartClient.SCChip.csproj" /> | ||||
<ProjectReference Include="..\BPASmartClient.ViewModel\BPASmartClient.ViewModel.csproj" /> | <ProjectReference Include="..\BPASmartClient.ViewModel\BPASmartClient.ViewModel.csproj" /> | ||||
<ProjectReference Include="..\HBLConsole.MORKIC\BPASmartClient.MORKIC.csproj" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -1,13 +1,123 @@ | |||||
<UserControl x:Class="BPASmartClient.Control.DeviceMonitorView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||||
mc:Ignorable="d" | |||||
d:DesignHeight="450" d:DesignWidth="800"> | |||||
<UserControl | |||||
x:Class="BPASmartClient.Control.DeviceMonitorView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmartClient.Control" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<UserControl.DataContext> | |||||
<vm:DeviceMonitorViewModel /> | |||||
</UserControl.DataContext> | |||||
<UserControl.Resources> | |||||
<!--#region ListBox样式--> | |||||
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> | |||||
<Setter Property="OverridesDefaultStyle" Value="True" /> | |||||
<Setter Property="SnapsToDevicePixels" Value="True" /> | |||||
<Setter Property="BorderBrush" Value="{x:Null}" /> | |||||
<Setter Property="Foreground" Value="White" /> | |||||
<Setter Property="FontSize" Value="20" /> | |||||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||||
<Border x:Name="border" CornerRadius="8"> | |||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||||
</Border> | |||||
<!--<ControlTemplate.Triggers> | |||||
<Trigger Property="IsSelected" Value="True"> | |||||
<Setter TargetName="border" Property="Background"> | |||||
<Setter.Value> | |||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> | |||||
<GradientStop Offset="0.5" Color="#FF6B6B6B" /> | |||||
<GradientStop Offset="0.5" Color="#FF535353" /> | |||||
<GradientStop Offset="0.022" Color="#FF535353" /> | |||||
<GradientStop Offset="0.991" Color="#FF555555" /> | |||||
</LinearGradientBrush> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers>--> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<!--#endregion--> | |||||
</UserControl.Resources> | |||||
<Grid> | <Grid> | ||||
<Label FontSize="100" >设备流程监视界面</Label> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="60" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<!-- 第一行是设备切换行 --> | |||||
<ListBox | |||||
x:Name="lstEnt" | |||||
Margin="100,0,0,0" | |||||
Background="{x:Null}" | |||||
BorderBrush="{x:Null}" | |||||
BorderThickness="0" | |||||
ItemContainerStyle="{StaticResource ResourceKey=ListBoxItemStyle1}" | |||||
ItemsSource="{Binding Devices}"> | |||||
<ListBox.ItemsPanel> | |||||
<ItemsPanelTemplate> | |||||
<StackPanel Orientation="Horizontal" /> | |||||
</ItemsPanelTemplate> | |||||
</ListBox.ItemsPanel> | |||||
<ListBox.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid> | |||||
<RadioButton | |||||
Margin="0,0,10,0" | |||||
HorizontalContentAlignment="Center" | |||||
VerticalContentAlignment="Center" | |||||
Command="{Binding DataContext.DeviceSwitch, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}" | |||||
CommandParameter="{Binding Namespace}" | |||||
Content="{Binding Name}" | |||||
GroupName="Devices" | |||||
Style="{StaticResource RectangleRadioButtonStyle}" /> | |||||
</Grid> | |||||
</DataTemplate> | |||||
</ListBox.ItemTemplate> | |||||
</ListBox> | |||||
<!-- 第二行是设备功能行 --> | |||||
<Grid Grid.Row="1"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="100" /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | |||||
<ItemsControl ItemsSource="{Binding DeviceMonitors}"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid> | |||||
<RadioButton | |||||
Margin="0,10,0,10" | |||||
HorizontalContentAlignment="Center" | |||||
VerticalContentAlignment="Center" | |||||
Command="{Binding DataContext.DeviceWindowSwitch, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}" | |||||
CommandParameter="{Binding Namespace}" | |||||
Content="{Binding Name}" | |||||
FontSize="16" | |||||
GroupName="DeviceMotion" | |||||
Style="{StaticResource RectangleLeftRadioButtonStyle}" /> | |||||
</Grid> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
<ContentControl Grid.Column="1" Content="{Binding MainContent}" /> | |||||
</Grid> | |||||
</Grid> | </Grid> | ||||
</UserControl> | </UserControl> |
@@ -82,11 +82,13 @@ | |||||
Header="阿里连接维护" | Header="阿里连接维护" | ||||
Tag="DataVView" /> | Tag="DataVView" /> | ||||
<Separator /> | <Separator /> | ||||
<MenuItem | |||||
Click="MenuItem_Click" | |||||
<MenuItem | |||||
Click="Debug_Click" | |||||
FontSize="12" | FontSize="12" | ||||
Header="调试界面" | Header="调试界面" | ||||
Tag="MorkT_DebugView" /> | |||||
Tag="DebugView" /> | |||||
</MenuItem> | </MenuItem> | ||||
<MenuItem Header="状态监视"> | <MenuItem Header="状态监视"> | ||||
<MenuItem | <MenuItem | ||||
@@ -13,8 +13,10 @@ using BPASmartClient.Model.冰淇淋.Enum; | |||||
using BPASmartClient.Model.咖啡机.Enum; | using BPASmartClient.Model.咖啡机.Enum; | ||||
using BPASmartClient.Peripheral; | using BPASmartClient.Peripheral; | ||||
using BPASmartClient.ViewModel; | using BPASmartClient.ViewModel; | ||||
using Newtonsoft.Json; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Collections.ObjectModel; | |||||
using System.IO; | using System.IO; | ||||
using System.Linq; | using System.Linq; | ||||
using System.Reflection; | using System.Reflection; | ||||
@@ -134,6 +136,24 @@ namespace BPASmartClient | |||||
} | } | ||||
})); | })); | ||||
}), "IotBroadcast"); | }), "IotBroadcast"); | ||||
//var text = TextHelper.GetInstance.ReadTextInfo("StartShop", "DeviceConfig"); | |||||
//string path = $"{LocaPath.GetInstance().GetDeviceConfigPath}{text}.json"; | |||||
//if (File.Exists(path)) | |||||
//{ | |||||
// string JsonString = File.ReadAllText(path); | |||||
// var result = JsonConvert.DeserializeObject<ObservableCollection<DeviceConfigModelJson>>(JsonString); | |||||
// if (result != null) | |||||
// { | |||||
// foreach (var shop in result)//店铺集合 | |||||
// { | |||||
// foreach (var device in shop.deviceModels)//设备集合 | |||||
// { | |||||
// dv.Items.Add(new MenuItem { Header = device.DeviceModule }); | |||||
// } | |||||
// } | |||||
// } | |||||
//} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// 获取设备集合 | /// 获取设备集合 | ||||
@@ -197,10 +217,9 @@ namespace BPASmartClient | |||||
}); | }); | ||||
}); | }); | ||||
} | |||||
#endregion | |||||
#region Click | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 菜单切换栏 | /// 菜单切换栏 | ||||
/// </summary> | /// </summary> | ||||
@@ -222,6 +241,24 @@ namespace BPASmartClient | |||||
MessageLog.GetInstance.ShowEx($"BPASmartClient 中引发错误,MainWindow.xaml.cs 类MenuItem_Click(),描述:[{ex.Message}]"); | MessageLog.GetInstance.ShowEx($"BPASmartClient 中引发错误,MainWindow.xaml.cs 类MenuItem_Click(),描述:[{ex.Message}]"); | ||||
} | } | ||||
} | } | ||||
private void Debug_Click(object sender,RoutedEventArgs e) | |||||
{ | |||||
try | |||||
{ | |||||
if (sender is MenuItem) | |||||
{ | |||||
Type type = Assembly.Load("BPASmartClient.MorkT").GetType("BPASmartClient.MorkT.View.DebugView"); | |||||
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes); | |||||
contentRegion.Content = (FrameworkElement)cti.Invoke(null); | |||||
Title.Text = (sender as MenuItem).Header?.ToString() + "界面"; | |||||
} | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
MessageLog.GetInstance.ShowEx($"BPASmartClient 中引发错误,MainWindow.xaml.cs 类MenuItem_Click(),描述:[{ex.Message}]"); | |||||
} | |||||
} | |||||
#endregion | #endregion | ||||
#region 公用 | #region 公用 | ||||
@@ -76,9 +76,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.PLC", "BPASm | |||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkF", "BPASmartClient.MorkF\BPASmartClient.MorkF.csproj", "{15FD3FF1-80F1-4274-945A-BA5EBA35999E}" | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkF", "BPASmartClient.MorkF\BPASmartClient.MorkF.csproj", "{15FD3FF1-80F1-4274-945A-BA5EBA35999E}" | ||||
EndProject | EndProject | ||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MORKIC", "HBLConsole.MORKIC\BPASmartClient.MORKIC.csproj", "{31A3B51C-A4BB-4FEB-B712-38482F6D1667}" | |||||
EndProject | |||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.LebaiRobot", "BPASmartClient.LebaiRobot\BPASmartClient.LebaiRobot.csproj", "{D40C3CC7-C07C-4882-93D3-7F9ABCD3B5F0}" | |||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.LebaiRobot", "BPASmartClient.LebaiRobot\BPASmartClient.LebaiRobot.csproj", "{D40C3CC7-C07C-4882-93D3-7F9ABCD3B5F0}" | |||||
EndProject | EndProject | ||||
Global | Global | ||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||||
@@ -654,18 +652,6 @@ Global | |||||
{15FD3FF1-80F1-4274-945A-BA5EBA35999E}.Release|x64.Build.0 = Release|Any CPU | {15FD3FF1-80F1-4274-945A-BA5EBA35999E}.Release|x64.Build.0 = Release|Any CPU | ||||
{15FD3FF1-80F1-4274-945A-BA5EBA35999E}.Release|x86.ActiveCfg = Release|Any CPU | {15FD3FF1-80F1-4274-945A-BA5EBA35999E}.Release|x86.ActiveCfg = Release|Any CPU | ||||
{15FD3FF1-80F1-4274-945A-BA5EBA35999E}.Release|x86.Build.0 = Release|Any CPU | {15FD3FF1-80F1-4274-945A-BA5EBA35999E}.Release|x86.Build.0 = Release|Any CPU | ||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Debug|x64.ActiveCfg = Debug|Any CPU | |||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Debug|x86.ActiveCfg = Debug|Any CPU | |||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Release|Any CPU.Build.0 = Release|Any CPU | |||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Release|ARM.ActiveCfg = Release|Any CPU | |||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Release|ARM64.ActiveCfg = Release|Any CPU | |||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Release|x64.ActiveCfg = Release|Any CPU | |||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667}.Release|x86.ActiveCfg = Release|Any CPU | |||||
{D40C3CC7-C07C-4882-93D3-7F9ABCD3B5F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | {D40C3CC7-C07C-4882-93D3-7F9ABCD3B5F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||||
{D40C3CC7-C07C-4882-93D3-7F9ABCD3B5F0}.Debug|Any CPU.Build.0 = Debug|Any CPU | {D40C3CC7-C07C-4882-93D3-7F9ABCD3B5F0}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||||
{D40C3CC7-C07C-4882-93D3-7F9ABCD3B5F0}.Debug|ARM.ActiveCfg = Debug|Any CPU | {D40C3CC7-C07C-4882-93D3-7F9ABCD3B5F0}.Debug|ARM.ActiveCfg = Debug|Any CPU | ||||
@@ -719,7 +705,6 @@ Global | |||||
{3A55F68A-D526-4CFC-A5A6-B69FB76716C2} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} | {3A55F68A-D526-4CFC-A5A6-B69FB76716C2} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} | ||||
{7F04A788-38B5-42CB-B601-70C657C953B8} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} | {7F04A788-38B5-42CB-B601-70C657C953B8} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} | ||||
{15FD3FF1-80F1-4274-945A-BA5EBA35999E} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | {15FD3FF1-80F1-4274-945A-BA5EBA35999E} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | ||||
{31A3B51C-A4BB-4FEB-B712-38482F6D1667} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | |||||
{D40C3CC7-C07C-4882-93D3-7F9ABCD3B5F0} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} | {D40C3CC7-C07C-4882-93D3-7F9ABCD3B5F0} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} | ||||
EndGlobalSection | EndGlobalSection | ||||
GlobalSection(ExtensibilityGlobals) = postSolution | GlobalSection(ExtensibilityGlobals) = postSolution | ||||
@@ -0,0 +1,8 @@ | |||||
using System; | |||||
namespace WpfLibrary1 | |||||
{ | |||||
public class Class1 | |||||
{ | |||||
} | |||||
} |
@@ -0,0 +1,9 @@ | |||||
<Project Sdk="Microsoft.NET.Sdk"> | |||||
<PropertyGroup> | |||||
<TargetFramework>net6.0-windows</TargetFramework> | |||||
<Nullable>enable</Nullable> | |||||
<UseWPF>true</UseWPF> | |||||
</PropertyGroup> | |||||
</Project> |