diff --git a/BPASmartClient.Helper/BPASmartClient.Helper.csproj b/BPASmartClient.Helper/BPASmartClient.Helper.csproj index a2b3bcbc..743e00b3 100644 --- a/BPASmartClient.Helper/BPASmartClient.Helper.csproj +++ b/BPASmartClient.Helper/BPASmartClient.Helper.csproj @@ -22,6 +22,7 @@ + diff --git a/BPASmartClient.Helper/ExcelHelper.cs b/BPASmartClient.Helper/ExcelHelper.cs new file mode 100644 index 00000000..96cbdd49 --- /dev/null +++ b/BPASmartClient.Helper/ExcelHelper.cs @@ -0,0 +1,151 @@ +using BPASmartClient.Message; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.OleDb; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + + +namespace BPASmartClient.Helper +{ + public class ExcelHelper + { + public DataTable GetExcelToDataTableBySheet(string FileFullPath, string SheetName) + + { + + //此连接只能操作Excel2007之前(.xls)文件 + + //string strConn = "Provider=Microsoft.Jet.OleDb.4.0;" + "data source=" + FileFullPath + ";Extended Properties='Excel 8.0; HDR=NO; IMEX=1'"; + + //此连接可以操作.xls与.xlsx文件 + + string strConn = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + FileFullPath + ";Extended Properties='Excel 12.0; HDR=NO; IMEX=1'"; + + + OleDbConnection conn = new OleDbConnection(strConn); + + conn.Open(); + + DataSet ds = new DataSet(); + + OleDbDataAdapter odda = new OleDbDataAdapter(string.Format("SELECT * FROM [{0}]", SheetName), conn); + + //OleDbDataAdapter odda = new OleDbDataAdapter(string.Format("select * from [Sheet1$]", conn),conn);                                    + + odda.Fill(ds, SheetName); + + conn.Close(); + + return ds.Tables[0]; + + } + //根据Excel物理路径获取Excel文件中所有表名 + + public String[] GetExcelSheetNames(string excelFile) + + { + OleDbConnection objConn = null; + System.Data.DataTable dt = null; + try + { + //此连接只能操作Excel2007之前(.xls)文件 + + //string strConn = "Provider=Microsoft.Jet.OleDb.4.0;" + "data source=" + excelFile + ";Extended Properties='Excel 8.0; HDR=NO; IMEX=1'"; + + //此连接可以操作.xls与.xlsx文件 + + string strConn = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + excelFile + ";Extended Properties='Excel 12.0; HDR=NO; IMEX=1'"; + + objConn = new OleDbConnection(strConn); + objConn.Open(); + dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); + + if (dt == null) + { + return null; + } + String[] excelSheets = new String[dt.Rows.Count]; + int i = 0; + foreach (DataRow row in dt.Rows) + { + excelSheets[i] = row["TABLE_NAME"].ToString(); + i++; + } + return excelSheets; + } + catch + { + return null; + } + finally + { + if (objConn != null) + { + objConn.Close(); + objConn.Dispose(); + } + if (dt != null) + { + dt.Dispose(); + } + } + } + + public static DataTable ReadDataFromCSV( string file) + { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + DataTable dt = null; + if(File.Exists(file)) + { + dt = new DataTable(); + FileStream fs = new FileStream(file, FileMode.Open,FileAccess.Read); + StreamReader sr; + + try + { + Encoding encoding = Encoding.Default; + using (sr = new StreamReader(fs, Encoding.GetEncoding("GB2312"))) + { + string head = sr.ReadLine(); + string[] headNames = head.Split(','); + for (int i = 0; i < headNames.Length; i++) + { + dt.Columns.Add(headNames[i], typeof(string)); + } + while (!sr.EndOfStream) + { + string lineStr = sr.ReadLine(); + if (lineStr != null) + { + string[] lines = lineStr.Split(','); + DataRow dr = dt.NewRow(); + for (int i = 0; i < lines.Length; i++) + { + dr[i] = lines[i]; + } + dt.Rows.Add(dr); + } + } + sr.Close(); + fs.Close(); + } + + } + catch (Exception ex) + { + MessageLog.GetInstance.ShowEx($"读取csv文件异常:{ex.Message}"); + } + } + return dt; + + } + } + + +} + diff --git a/BPASmartClient.KHKJ/BPASmartClient.KHKJ.csproj b/BPASmartClient.KHKJ/BPASmartClient.KHKJ.csproj new file mode 100644 index 00000000..3656ee97 --- /dev/null +++ b/BPASmartClient.KHKJ/BPASmartClient.KHKJ.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/BPASmartClient.KHKJ/Class1.cs b/BPASmartClient.KHKJ/Class1.cs new file mode 100644 index 00000000..4cbe8e57 --- /dev/null +++ b/BPASmartClient.KHKJ/Class1.cs @@ -0,0 +1,7 @@ +namespace BPASmartClient.KHKJ +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/BPASmartClient.KHKJ/KHKJMachine.cs b/BPASmartClient.KHKJ/KHKJMachine.cs new file mode 100644 index 00000000..b940c7ed --- /dev/null +++ b/BPASmartClient.KHKJ/KHKJMachine.cs @@ -0,0 +1,120 @@ +using BPASmartClient.Helper; +using BPASmartClient.Message; +using BPASmartClient.SerialPort; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +namespace BPASmartClient.KHKJ +{ + public class KHKJMachine + { + //通讯代理 + SerialPortClient commProxy = null; + //数据仓库 + private DataStorage dataStorage = new DataStorage(); + + //是否下发指令,主线程等待 + private bool free = false; + + //状态询问指令 + private byte[] cmdAsk; + + public KHKJMachine() + { + + MainLoop(); + } + + public void Communication(string serialPort) + { + commProxy = new SerialPortClient(serialPort, BaudRates.BR_9600); + commProxy.SetDataStorage(dataStorage); + commProxy.Start(); + free = true; + + } + + private void MainLoop() + { + ThreadManage.GetInstance().StartLong(new Action(() => + { + if (!free) + { + commProxy.SendData(cmdAsk); + } + Thread.Sleep(500); + }), "KHKJ询问线程"); + + ThreadManage.GetInstance().StartLong(new Action(() => + { + ResolveMsg(); + }), "KHKJ解析线程"); + } + + private void ResolveMsg() + { + List temp = new List(); + //一系列解包 + while (dataStorage.GetSize() > 0) + { + byte item = dataStorage.GetData(); + List data = new List() { item }; + if (Encoding.ASCII.GetString(data.ToArray()) == ":") + { + temp.Add(item); + while (dataStorage.GetSize() < 32) { Thread.Sleep(5); } + + while (temp.Count < 32) + { + temp.Add(dataStorage.GetData()); + } + List vs = new List() { temp[temp.Count - 4], temp[temp.Count - 3], temp[temp.Count - 2], temp[temp.Count - 1] }; + + string t = Encoding.ASCII.GetString(vs.ToArray()).ToLower(); + var package = Encoding.ASCII.GetString(temp.ToArray()); + //if (package.Contains("\\r\\n")) + //{ + // ProcessMsg(package); + //} + temp.Clear(); + } + continue; + } + Thread.Sleep(500); + } + + public void Stop() + { + try + { + commProxy.Stop(); + free = true; + } + catch (Exception ex) + { + MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); + } + } + + + /// + /// 16进制转字节数组 + /// + /// + /// + public byte[] HexStringToByteArray( string hexstring) + { + var byteArray = new byte[hexstring.Length/2]; + for (int i = 0; i < byteArray.Length; i++) + { + var x = Convert.ToInt32(hexstring.Substring(i * 2, 2), 16); + byteArray[i] = (byte)x; + } + return byteArray; + } + } +} diff --git a/BPASmartClient.MilkWithTea/App.xaml b/BPASmartClient.MilkWithTea/App.xaml index dc565115..83ac9a37 100644 --- a/BPASmartClient.MilkWithTea/App.xaml +++ b/BPASmartClient.MilkWithTea/App.xaml @@ -83,7 +83,7 @@ - + @@ -93,9 +93,9 @@ + HorizontalAlignment="Center" /> @@ -191,6 +191,38 @@ + + + + + + + + + + + + + + + + + + + + + @@ -204,8 +236,10 @@ - - + + + @@ -213,9 +247,28 @@ + HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Visibility="Collapsed" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> + + + + + + + + + + + + + + + + + + @@ -247,15 +300,15 @@ Background="{TemplateBinding Background}" SnapsToDevicePixels="True"> - - + Background="{TemplateBinding Background}" SnapsToDevicePixels="True" Canvas.Right="30"> + + - - + Background="{TemplateBinding Background}" SnapsToDevicePixels="True" Canvas.Right="30"> + + - @@ -392,7 +444,7 @@ - + @@ -585,7 +637,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/BPASmartClient.MilkWithTea/App.xaml.cs b/BPASmartClient.MilkWithTea/App.xaml.cs index 42734460..266bb6c8 100644 --- a/BPASmartClient.MilkWithTea/App.xaml.cs +++ b/BPASmartClient.MilkWithTea/App.xaml.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.Helper; +using System; using System.Collections.Generic; using System.Configuration; using System.Data; @@ -13,5 +14,11 @@ namespace BPASmartClient.MilkWithTea /// public partial class App : Application { + protected override void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + SystemHelper.GetInstance.CreateDesktopShortcut(); + + } } } diff --git a/BPASmartClient.MilkWithTea/BPASmartClient.MilkWithTea.csproj b/BPASmartClient.MilkWithTea/BPASmartClient.MilkWithTea.csproj index b7de3156..8282b987 100644 --- a/BPASmartClient.MilkWithTea/BPASmartClient.MilkWithTea.csproj +++ b/BPASmartClient.MilkWithTea/BPASmartClient.MilkWithTea.csproj @@ -5,8 +5,14 @@ net6.0-windows enable true + hbl.ico + hbl.ico + + + + @@ -22,6 +28,10 @@ PreserveNewest + + True + \ + diff --git a/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml b/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml index 2b27ca59..4aa6b2f7 100644 --- a/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml +++ b/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml @@ -7,6 +7,7 @@ xmlns:ccontrols="http://schemas.microsoft.com/expression/2010/drawing" mc:Ignorable="d" x:Name="circularProgress" Height="100" Width="100"> + + + + + + + + + diff --git a/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml.cs b/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml.cs index 953dcde6..bcb05fff 100644 --- a/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml.cs +++ b/BPASmartClient.MilkWithTea/Control/CircularProgressBar.xaml.cs @@ -10,6 +10,7 @@ using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; +using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; @@ -53,7 +54,7 @@ namespace BPASmartClient.MilkWithTea.Control { if (angle > 360) return; - if (angle <= 0) return; + if (angle < 0) return; int offset = 5; if (angle > 359) angle = 359.8; @@ -65,12 +66,33 @@ namespace BPASmartClient.MilkWithTea.Control double startPositionX = radius + offset; double startPositionY = offset; - if (angle > 180) + Storyboard sb = new Storyboard(); + DoubleAnimation yd1 = new DoubleAnimation();//实例化浮点动画 + cyclePath.RenderTransform = new RotateTransform();//设置为旋转动画 + cyclePath.RenderTransformOrigin = new Point(0.5, 0.5);//设置旋转的中心 + yd1.From = 0;//动画的起始值 + yd1.To = 360;//动画的结束值 + yd1.Duration = TimeSpan.FromSeconds(3);//动画的播放时间 + yd1.RepeatBehavior = RepeatBehavior.Forever;//设置动画循环播放 + Storyboard.SetTarget(yd1, cyclePath);//给故事板绑定动画 + Storyboard.SetTargetProperty(yd1, new PropertyPath("RenderTransform.Angle"));//动画的依赖属性 + sb.Children.Add(yd1);//故事板添加动画 + + if (angle == 0) + { + string Data = string.Format("M {0} {1} A {2} {2} 0 1 1 {3} {4}", startPositionX, startPositionY, radius, Math.Round(x, 2) + offset, Math.Round(y, 2) + offset); + this.cyclePath.Data = Geometry.Parse(Data); + + sb.Begin();//播放动画 + } + + else if (angle > 180) { //string Data = string.Format("M {0} 0 A {0} {0} 0 1 1 {1} {2}", radius, Math.Round(x, 2), Math.Round(y, 2)); string Data = string.Format("M {0} {1} A {2} {2} 0 1 1 {3} {4}", startPositionX, startPositionY, radius, Math.Round(x, 2) + offset, Math.Round(y, 2) + offset); this.cyclePath.Data = Geometry.Parse(Data); + sb.Stop(); } else { @@ -80,7 +102,10 @@ namespace BPASmartClient.MilkWithTea.Control string Data = string.Format("M {0} {1} A {2} {2} 0 0 1 {3} {4}", startPositionX, startPositionY, radius, Math.Round(x, 2) + offset, Math.Round(y, 2) + offset); this.cyclePath.Data = Geometry.Parse(Data); + sb.Stop(); } + + } } diff --git a/BPASmartClient.MilkWithTea/GLobal.cs b/BPASmartClient.MilkWithTea/GLobal.cs index ac24bfe9..386fbb90 100644 --- a/BPASmartClient.MilkWithTea/GLobal.cs +++ b/BPASmartClient.MilkWithTea/GLobal.cs @@ -1,4 +1,5 @@ -using Model; +using BPASmartClient.Model; +using Model; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -19,6 +20,10 @@ namespace BPASmartClient.MilkWithTea public static bool makeEnable = false; public static ObservableCollection MaterialRecipes { get; set; } = new ObservableCollection(); + /// + /// 设备信息列表 + /// + public static ObservableCollection deviceConfig { get; set; } = new ObservableCollection(); /// diff --git a/BPASmartClient.MilkWithTea/MainWindow.xaml b/BPASmartClient.MilkWithTea/MainWindow.xaml index 174834ae..736e97d9 100644 --- a/BPASmartClient.MilkWithTea/MainWindow.xaml +++ b/BPASmartClient.MilkWithTea/MainWindow.xaml @@ -12,6 +12,7 @@ + @@ -96,6 +99,7 @@ + + + diff --git a/BPASmartClient.MilkWithTea/ViewModel/MainControlViewModel.cs b/BPASmartClient.MilkWithTea/ViewModel/MainControlViewModel.cs index 07f8306b..b27afd0b 100644 --- a/BPASmartClient.MilkWithTea/ViewModel/MainControlViewModel.cs +++ b/BPASmartClient.MilkWithTea/ViewModel/MainControlViewModel.cs @@ -39,12 +39,14 @@ namespace BPASmartClient.MilkWithTea.ViewModel /// 当前正在制作的奶茶 /// public string CurrentGood { get { return _currentGood; } set { _currentGood = value; OnPropertyChanged(); } } - private string _currentGood = "无"; + private string _currentGood = "茉莉花茶"; /// /// 奶茶制作百分比 /// public string MakePercent { get { return _makePercent; } set { _makePercent = value; OnPropertyChanged(); } } - private string _makePercent = "100"; + private string _makePercent = "0"; + + /// /// 当前正在制作的奶茶 @@ -56,6 +58,8 @@ namespace BPASmartClient.MilkWithTea.ViewModel /// public RelayCommand MakeGoodCommand { get; set; } + + public MainControlViewModel() { MakeGoodCommand = new RelayCommand(new Action(() => @@ -63,32 +67,34 @@ namespace BPASmartClient.MilkWithTea.ViewModel })); Init(); - MorkOrderPush morkOrderPush = new MorkOrderPush() { GoodsName = "水果奶茶", SortNum = 1 }; + MorkOrderPush morkOrderPush = new MorkOrderPush() { GoodsName = "珍珠奶茶", SortNum = 1 }; + MorkOrderPush morkOrderPush1 = new MorkOrderPush() { GoodsName = "茉莉花茶", SortNum = 2 }; + MorkOrderPush morkOrderPush2 = new MorkOrderPush() { GoodsName = "芝芝梅梅", SortNum = 3 }; orderStatusLists.Add(new MorkOrder() { - StartDate = "11",EndDate ="15",CompleteDate ="4",OrderStatus = ORDER_STATUS.COOKING, + StartDate = "11:20",EndDate ="11:24",CompleteDate ="4",OrderStatus = ORDER_STATUS.COMPLETED_COOK, OrderPush = morkOrderPush }); orderStatusLists.Add(new MorkOrder() { - StartDate = "11", - EndDate = "15", + StartDate = "11:36", + EndDate = "11:40", CompleteDate = "4", OrderStatus = ORDER_STATUS.COOKING, - OrderPush = morkOrderPush + OrderPush = morkOrderPush1 }); orderStatusLists.Add(new MorkOrder() { - StartDate = "11", - EndDate = "15", - CompleteDate = "4", - OrderStatus = ORDER_STATUS.COOKING, - OrderPush = morkOrderPush + StartDate = "10:33", + EndDate = "10:28", + CompleteDate = "5", + OrderStatus = ORDER_STATUS.COMPLETED_TAKE, + OrderPush = morkOrderPush2 }); diff --git a/BPASmartClient.MilkWithTea/ViewModel/MainWindowVeiwModel.cs b/BPASmartClient.MilkWithTea/ViewModel/MainWindowVeiwModel.cs index 5aa4dc74..6dad830f 100644 --- a/BPASmartClient.MilkWithTea/ViewModel/MainWindowVeiwModel.cs +++ b/BPASmartClient.MilkWithTea/ViewModel/MainWindowVeiwModel.cs @@ -1,4 +1,5 @@ using BPASmartClient.Helper; +using BPASmartClient.Model; using Microsoft.Toolkit.Mvvm.ComponentModel; using Model; using System; @@ -31,6 +32,7 @@ namespace BPASmartClient.MilkWithTea.ViewModel GLobal.posionPath = Path.Combine(path, "MaterialPosion.json"); GLobal.MaterialRecipes = GLobal.GetJsonToT(GLobal.recipePath); + GLobal.deviceConfig = GLobal.GetJsonToT($"{LocaPath.GetInstance().GetDeviceConfigPath}奶茶味魔方.json"); } } diff --git a/BPASmartClient.MilkWithTea/ViewModel/PatrameterSettiongViewModel.cs b/BPASmartClient.MilkWithTea/ViewModel/PatrameterSettiongViewModel.cs index 72ebfdc8..ed2b05fa 100644 --- a/BPASmartClient.MilkWithTea/ViewModel/PatrameterSettiongViewModel.cs +++ b/BPASmartClient.MilkWithTea/ViewModel/PatrameterSettiongViewModel.cs @@ -1,10 +1,14 @@ using BPASmartClient.Helper; +using BPASmartClient.Message; +using BPASmartClient.Model; using BPASmartClient.MorkTM; using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -80,21 +84,39 @@ namespace BPASmartClient.MilkWithTea.ViewModel /// public RelayCommand CheckMaterailWeightCommand { get; set; } - public PatrameterSettiongViewModel() - { - foreach(MaterialPosion materialPosion in Enum.GetValues(typeof(MaterialPosion))) - { - materialPosions.Add(materialPosion); - } + #region 设备配置 + + /// + /// 店铺名称 + /// + public string ShopName { get { return _shopName; } set { _shopName = value; OnPropertyChanged(); } } + private string _shopName; + /// + /// 店铺ID + /// + public string ShopID { get { return _shopID; } set { _shopID = value; OnPropertyChanged(); } } + private string _shopID; + /// + /// 设备ID + /// + public string DeviceID { get { return _deviceID; } set { _deviceID = value; OnPropertyChanged(); } } + private string _deviceID; + /// + /// PLC地址 + /// + public string PLCAdress { get { return _pLCAdress; } set { _pLCAdress = value; OnPropertyChanged(); } } + private string _pLCAdress; - foreach(OutMaterialPosion outMaterialPosion in Enum.GetValues(typeof(OutMaterialPosion))) - { - TurntablePosion.Add(outMaterialPosion); - } + public RelayCommand SaveDevicesCommand { get; set; } + #endregion + public PatrameterSettiongViewModel() + { + OutMaterailCommad = new RelayCommand(new Action(() => { ActionManage.GetInstance.Send("通道口出料", new object[] { MaterialID +1, OutMaterailWeight }); + })); TurntableCommad = new RelayCommand(new Action(() => @@ -118,6 +140,39 @@ namespace BPASmartClient.MilkWithTea.ViewModel ActionManage.GetInstance.Send("矫正重量", new object[] { CorrectPassway + 1, CorrectMatetailWeight }); })); + SaveDevicesCommand = new RelayCommand(SaveDeviceMessage); + + init(); + } + private void init() + { + foreach (MaterialPosion materialPosion in Enum.GetValues(typeof(MaterialPosion))) + { + materialPosions.Add(materialPosion); + } + + foreach (OutMaterialPosion outMaterialPosion in Enum.GetValues(typeof(OutMaterialPosion))) + { + TurntablePosion.Add(outMaterialPosion); + } + ShopName = GLobal.deviceConfig.ElementAt(0).ShopName; + ShopID = GLobal.deviceConfig.ElementAt(0).ShopId; + DeviceID = GLobal.deviceConfig.ElementAt(0).deviceModels.ElementAt(0).DeviceId; + PLCAdress = GLobal.deviceConfig.ElementAt(0).deviceModels.ElementAt(0).communicationDevcies.ElementAt(0).communicationPar.IPAddress; + } + + private void SaveDeviceMessage() + { + if (GLobal.deviceConfig.Count > 0) + { + GLobal.deviceConfig.ElementAt(0).ShopName = ShopName; + GLobal.deviceConfig.ElementAt(0).ShopId = ShopID; + GLobal.deviceConfig.ElementAt(0).deviceModels.ElementAt(0).DeviceId = DeviceID; + GLobal.deviceConfig.ElementAt(0).deviceModels.ElementAt(0).Id = Guid.NewGuid().ToString(); + GLobal.deviceConfig.ElementAt(0).deviceModels.ElementAt(0).communicationDevcies.ElementAt(0).communicationPar.IPAddress = PLCAdress; + File.WriteAllText($"{LocaPath.GetInstance().GetDeviceConfigPath}奶茶味魔方.json", JsonConvert.SerializeObject(GLobal.deviceConfig)); + } + } } } diff --git a/BPASmartClient.MilkWithTea/hbl.ico b/BPASmartClient.MilkWithTea/hbl.ico new file mode 100644 index 00000000..cf89051a Binary files /dev/null and b/BPASmartClient.MilkWithTea/hbl.ico differ diff --git a/BPASmartClient.Modbus/BPASmartClient.Modbus.csproj b/BPASmartClient.Modbus/BPASmartClient.Modbus.csproj index b40ec4c7..646a09bc 100644 --- a/BPASmartClient.Modbus/BPASmartClient.Modbus.csproj +++ b/BPASmartClient.Modbus/BPASmartClient.Modbus.csproj @@ -6,6 +6,7 @@ + diff --git a/BPASmartClient.Modbus/ModbusRTU.cs b/BPASmartClient.Modbus/ModbusRTU.cs new file mode 100644 index 00000000..912d8a0a --- /dev/null +++ b/BPASmartClient.Modbus/ModbusRTU.cs @@ -0,0 +1,225 @@ +using NModbus; +using System; +using System.Collections.Generic; +using System.IO.Ports; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Modbus +{ + public class ModbusRTU + { + #region 参数配置 + private static IModbusMaster master; + private static IModbusSerialMaster serialMaster; + private static ModbusFactory factory; + private static SerialPort port; + //写线圈或写寄存器数组 + private bool[] coilsBuffer; + private ushort[] registerBuffer; + //功能码 + private string functionCode; + + //串口参数 + private string portName; + private int baudRate; + private Parity parity; + private int dataBits; + private StopBits stopBits; + + #endregion + + #region 串口配置 + /// + /// 串口参数获取 + /// + /// + public void InitSerialPortParameter(string protName, int bauRate, string currentParity, int dataBits, string currentStopBits) + { + switch (currentParity) + { + case "奇": + parity = Parity.Odd; + break; + case "偶": + parity = Parity.Even; + break; + case "无": + parity = Parity.None; + break; + default: + break; + } + switch (currentStopBits) + { + case "1": + stopBits = StopBits.One; + break; + case "2": + stopBits = StopBits.Two; + break; + default: + break; + } + port = new SerialPort(portName, baudRate, parity, dataBits, stopBits); + //master = factory.CreateMaster() + } + + + #endregion + + #region 串口收/发 + public async void ExecuteFunctionRecive(string functionCode, byte slaveAddress, ushort startAddress, ushort numberOfPoints) + { + try + { + + if (port.IsOpen == false) + { + port.Open(); + } + if (functionCode != null) + { + switch (functionCode) + { + case "01 Read Coils"://读取单个线圈 + try + { + coilsBuffer = master.ReadCoils(slaveAddress, startAddress, numberOfPoints); + } + catch (Exception) + { + //MessageBox.Show(e.Message); + break; + } + break; + case "02 Read DisCrete Inputs"://读取输入线圈/离散量线圈 + try + { + coilsBuffer = master.ReadInputs(slaveAddress, startAddress, numberOfPoints); + } + catch (Exception) + { + break; + } + + break; + case "03 Read Holding Registers"://读取保持寄存 + try + { + registerBuffer = master.ReadHoldingRegisters(slaveAddress, startAddress, numberOfPoints); + } + catch (Exception) + { + + break; + } + break; + case "04 Read Input Registers"://读取输入寄存器 + try + { + registerBuffer = master.ReadInputRegisters(slaveAddress, startAddress, numberOfPoints); + } + catch (Exception) + { + + break; + } + break; + default: + break; + } + + } + port.Close(); + } + catch (Exception ex) + { + port.Close(); + } + } + + public async void ExecuteFunctionSend(string data, byte slaveAddress, ushort startAddress) + { + try + { + + if (port.IsOpen == false) + { + port.Open(); + } + if (functionCode != null) + { + switch (functionCode) + { + case "05 Write Single Coil"://写单个线圈 + SetWriteParametes(data,true); + await master.WriteSingleCoilAsync(slaveAddress, startAddress, coilsBuffer[0]); + break; + case "06 Write Single Registers"://写单个输入线圈/离散量线圈 + SetWriteParametes(data,true); + await master.WriteSingleRegisterAsync(slaveAddress, startAddress, registerBuffer[0]); + break; + case "0F Write Multiple Coils"://写一组线圈 + SetWriteParametes(data); + await master.WriteMultipleCoilsAsync(slaveAddress, startAddress, coilsBuffer); + break; + case "10 Write Multiple Registers"://写一组保持寄存器 + SetWriteParametes(data); + await master.WriteMultipleRegistersAsync(slaveAddress, startAddress, registerBuffer); + break; + default: + break; + } + + } + port.Close(); + } + catch (Exception ex) + { + port.Close(); + } + } + #endregion + + + + /// + /// 设置写参数 + /// + private void SetWriteParametes(string data,bool isParametes =false) + { + + //判断是否写线圈 + if (isParametes) + { + string[] strarr = data.Split(' '); + coilsBuffer = new bool[strarr.Length]; + //转化为bool数组 + for (int i = 0; i < strarr.Length; i++) + { + // strarr[i] == "0" ? coilsBuffer[i] = false : coilsBuffer[i] = true; + if (strarr[i] == "0") + { + coilsBuffer[i] = false; + } + else + { + coilsBuffer[i] = true; + } + } + } + else + { + //转化ushort数组 + string[] strarr = data.Split(' '); + registerBuffer = new ushort[strarr.Length]; + for (int i = 0; i < strarr.Length; i++) + { + registerBuffer[i] = ushort.Parse(strarr[i]); + } + } + } + } +} diff --git a/BPASmartClient.MorkTM/BPASmartClient.MorkTM.csproj b/BPASmartClient.MorkTM/BPASmartClient.MorkTM.csproj index c10b5d75..fc9a23ad 100644 --- a/BPASmartClient.MorkTM/BPASmartClient.MorkTM.csproj +++ b/BPASmartClient.MorkTM/BPASmartClient.MorkTM.csproj @@ -47,6 +47,7 @@ + diff --git a/BPASmartClient.MorkTM/Control_MorkTM.cs b/BPASmartClient.MorkTM/Control_MorkTM.cs index da30111d..6eda755a 100644 --- a/BPASmartClient.MorkTM/Control_MorkTM.cs +++ b/BPASmartClient.MorkTM/Control_MorkTM.cs @@ -36,7 +36,7 @@ namespace BPASmartClient.MorkTM Dictionary res = new Dictionary(); res.Add(Convert.ToInt32(o[0]), Convert.ToSingle(o[1])); SetMatertialWeight(res); - Thread.Sleep(1000); + Thread.Sleep(100); OpenUsePassageWay(Convert.ToInt32(o[0])); } }), "通道口出料"); @@ -82,7 +82,7 @@ namespace BPASmartClient.MorkTM { if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value); }), "WriteBools"); - morkTM.ReachPosions = new List() { morkTM.ReachOutPosion_0, morkTM.ReachPosion_1, morkTM.ReachPosion_2, morkTM.ReachPosion_3, morkTM.ReachPosion_4, morkTM.ReachPosion_5, morkTM.ReachPosion_6 }; + morkTM.ReachPosions = new List() { morkTM.ReachPosion_1, morkTM.ReachPosion_2, morkTM.ReachPosion_3, morkTM.ReachPosion_4, morkTM.ReachPosion_5, morkTM.ReachPosion_6 , morkTM.ReachOutPosion_0, }; DeviceProcessLogShow("设备初始化完成"); @@ -170,11 +170,12 @@ namespace BPASmartClient.MorkTM { if (morkTM.morkOrderPushesTeaWithMilk.TryDequeue(out OrderLocInfo orderLoc)) //&&原点位置是否有杯子) { + DeviceProcessLogShow($"开始制作奶茶{orderLoc.GoodName}"); morkTM.MakeCount = 0; SetMatertialWeight(orderLoc.GoodPushes);//设置物料出料量 morkTM.RecipesPushes.Clear(); morkTM.RecipesPushes = orderLoc.GoodPushes; - MakeProcess(orderLoc.GoodName, morkTM.MakeCount, morkTM.RecipesPushes.Count); + MakeProcess(orderLoc.GoodName, morkTM.MakeCount, morkTM.RecipesPushes.Count);//制作进度 OrderChange(orderLoc.SuborderId, ORDER_STATUS.COOKING); foreach (var item in morkTM.RecipesPushes) { @@ -189,9 +190,6 @@ namespace BPASmartClient.MorkTM OrderChange(orderLoc.SuborderId, ORDER_STATUS.COMPLETED_COOK); MakeProcess(orderLoc.GoodName, 1, 1); DeviceProcessLogShow($"奶茶{orderLoc.GoodName}制作完成"); - - - } } } @@ -240,7 +238,7 @@ namespace BPASmartClient.MorkTM return; } } - while(!morkTM.ReachPosions[i])//等待转盘到达信号 + while(!morkTM.ReachPosions[i-1])//等待转盘到达信号 { Thread.Sleep(1000); } @@ -284,13 +282,12 @@ namespace BPASmartClient.MorkTM return ; } } - while(morkTM.ReachPosions[i-1]) + while(morkTM.ReachPosions[posion - 1]) { Thread.Sleep(1000); } WriteData(address,false); - - + DeviceProcessLogShow($"转盘转动到位置{i}"); } } @@ -316,6 +313,7 @@ namespace BPASmartClient.MorkTM private void CheckPassway(int passway,int time) { WriteData(polymer.PasswayPosionList[(MaterialPosion)passway], Convert.ToInt32(time * expand));//写入出料时间 + Thread.Sleep(100); WriteData("M5.0", true);//开始校正 } @@ -348,6 +346,7 @@ namespace BPASmartClient.MorkTM { int value = Convert.ToInt32(material.Value*expand); WriteData(polymer.MaterialPosionList[(MaterialPosion)material.Key], value); + DeviceProcessLogShow($"通道{material.Key}预设料{material.Value}g"); Thread.Sleep(200); } } diff --git a/BPASmartClient.MorkTM/PolymerBatching.cs b/BPASmartClient.MorkTM/PolymerBatching.cs index 694b78d3..05285ffb 100644 --- a/BPASmartClient.MorkTM/PolymerBatching.cs +++ b/BPASmartClient.MorkTM/PolymerBatching.cs @@ -1,5 +1,7 @@ -using System; +using BPASmartClient.Helper; +using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -15,7 +17,7 @@ namespace BPASmartClient.MorkTM } public enum OutMaterialPosion { - 出料位=0, 一号位 = 1, 二号位 = 2, 三号位 = 3, 四号位 = 4, 五号位 = 5, 六号位 = 6 + 一号位 = 1, 二号位 = 2, 三号位 = 3, 四号位 = 4, 五号位 = 5, 六号位 = 6,出料位 = 0 } public class CommationPosionPLC { @@ -34,7 +36,7 @@ namespace BPASmartClient.MorkTM public class PolymerBatching { /// - /// 物料对应的plc点位 + /// 物料需求对应的plc点位 /// public Dictionary MaterialPosionList = new Dictionary() { @@ -69,7 +71,7 @@ namespace BPASmartClient.MorkTM }; /// - /// 通道校正PLC点位 + /// 通道校正值PLC点位 /// public Dictionary PasswayPosionList = new Dictionary() { @@ -108,48 +110,50 @@ namespace BPASmartClient.MorkTM /// public List TurnPosionPLCs = new List() { - new CommationPosionPLC("M4.0","M14.0",OutMaterialPosion.一号位), - new CommationPosionPLC("M4.1","M14.1",OutMaterialPosion.二号位), - new CommationPosionPLC("M4.2","M14.2",OutMaterialPosion.三号位), - new CommationPosionPLC("M4.3","M14.3",OutMaterialPosion.四号位), - new CommationPosionPLC("M4.4","M14.4",OutMaterialPosion.五号位), - new CommationPosionPLC("M4.5","M14.5",OutMaterialPosion.六号位), + //new CommationPosionPLC("M4.0","M14.0",OutMaterialPosion.一号位), + //new CommationPosionPLC("M4.1","M14.1",OutMaterialPosion.二号位), + //new CommationPosionPLC("M4.2","M14.2",OutMaterialPosion.三号位), + //new CommationPosionPLC("M4.3","M14.3",OutMaterialPosion.四号位), + //new CommationPosionPLC("M4.4","M14.4",OutMaterialPosion.五号位), + //new CommationPosionPLC("M4.5","M14.5",OutMaterialPosion.六号位), }; - /// + /// /// plc出料点位 /// public List OutPosionPLCs = new List() { - new CommationPosionPLC("M0.0","M10.0",MaterialPosion.Top1), - new CommationPosionPLC("M0.1","M10.1",MaterialPosion.Top2), - new CommationPosionPLC("M0.2","M10.2",MaterialPosion.Top3), - new CommationPosionPLC("M0.3","M10.3",MaterialPosion.Top4), - new CommationPosionPLC("M0.4","M10.4",MaterialPosion.Top5), - new CommationPosionPLC("M0.5","M10.5",MaterialPosion.Top6), - new CommationPosionPLC("M0.6","M10.6",MaterialPosion.Top7), - new CommationPosionPLC("M0.7","M10.7",MaterialPosion.Top8), - new CommationPosionPLC("M1.0","M11.0",MaterialPosion.Top9), - new CommationPosionPLC("M1.1","M11.1",MaterialPosion.Top10), - new CommationPosionPLC("M1.2","M11.2",MaterialPosion.Top11), - new CommationPosionPLC("M1.3","M11.3",MaterialPosion.Top12), - new CommationPosionPLC("M1.4","M11.4",MaterialPosion.Top13), - new CommationPosionPLC("M1.5","M11.5",MaterialPosion.Top14), - new CommationPosionPLC("M1.6","M11.6",MaterialPosion.Top15), - new CommationPosionPLC("M1.7","M11.7",MaterialPosion.Top16), - new CommationPosionPLC("M2.0","M12.0",MaterialPosion.Top17), - new CommationPosionPLC("M2.1","M12.1",MaterialPosion.Top18), - new CommationPosionPLC("M2.2","M12.2",MaterialPosion.Top19), - new CommationPosionPLC("M2.3","M12.3",MaterialPosion.Top20), - new CommationPosionPLC("M2.4","M12.4",MaterialPosion.Top21), - new CommationPosionPLC("M2.5","M12.5",MaterialPosion.Top22), - new CommationPosionPLC("M2.6","M12.6",MaterialPosion.Top23), - new CommationPosionPLC("M2.7","M12.7",MaterialPosion.Top24), - new CommationPosionPLC("M3.0","M13.0",MaterialPosion.Top25), - new CommationPosionPLC("M3.1","M13.1",MaterialPosion.Top26), - new CommationPosionPLC("M3.2","M13.2",MaterialPosion.Top27), - new CommationPosionPLC("M3.3","M13.3",MaterialPosion.Top28), + //new CommationPosionPLC("M0.0","M10.0",MaterialPosion.Top1), + //new CommationPosionPLC("M0.1","M10.1",MaterialPosion.Top2), + //new CommationPosionPLC("M0.2","M10.2",MaterialPosion.Top3), + //new CommationPosionPLC("M0.3","M10.3",MaterialPosion.Top4), + //new CommationPosionPLC("M0.4","M10.4",MaterialPosion.Top5), + //new CommationPosionPLC("M0.5","M10.5",MaterialPosion.Top6), + //new CommationPosionPLC("M0.6","M10.6",MaterialPosion.Top7), + //new CommationPosionPLC("M0.7","M10.7",MaterialPosion.Top8), + //new CommationPosionPLC("M1.0","M11.0",MaterialPosion.Top9), + //new CommationPosionPLC("M1.1","M11.1",MaterialPosion.Top10), + //new CommationPosionPLC("M1.2","M11.2",MaterialPosion.Top11), + //new CommationPosionPLC("M1.3","M11.3",MaterialPosion.Top12), + //new CommationPosionPLC("M1.4","M11.4",MaterialPosion.Top13), + //new CommationPosionPLC("M1.5","M11.5",MaterialPosion.Top14), + //new CommationPosionPLC("M1.6","M11.6",MaterialPosion.Top15), + //new CommationPosionPLC("M1.7","M11.7",MaterialPosion.Top16), + //new CommationPosionPLC("M2.0","M12.0",MaterialPosion.Top17), + //new CommationPosionPLC("M2.1","M12.1",MaterialPosion.Top18), + //new CommationPosionPLC("M2.2","M12.2",MaterialPosion.Top19), + //new CommationPosionPLC("M2.3","M12.3",MaterialPosion.Top20), + //new CommationPosionPLC("M2.4","M12.4",MaterialPosion.Top21), + //new CommationPosionPLC("M2.5","M12.5",MaterialPosion.Top22), + //new CommationPosionPLC("M2.6","M12.6",MaterialPosion.Top23), + //new CommationPosionPLC("M2.7","M12.7",MaterialPosion.Top24), + //new CommationPosionPLC("M3.0","M13.0",MaterialPosion.Top25), + //new CommationPosionPLC("M3.1","M13.1",MaterialPosion.Top26), + //new CommationPosionPLC("M3.2","M13.2",MaterialPosion.Top27), + //new CommationPosionPLC("M3.3","M13.3",MaterialPosion.Top28), }; - + /// + /// 通道绑定出料位置 + /// public void GetMaterialInfo() { List materialPosions = Enum.GetValues(typeof(MaterialPosion)).Cast().ToList(); @@ -168,9 +172,36 @@ namespace BPASmartClient.MorkTM } } - } + + } + /// + /// 出料通道和出料口位置绑定集合 + /// 一号位(1,2,3,4,5),二号位(6,7,8,9,10),三号位(11,12,13,14),4号位(15,16,17,18),五号位(19,20,21,22,23),六号位(24,25,26,27,28) + /// public Dictionary, CommationPosionPLC> GoodsMaterialPosion = new Dictionary, CommationPosionPLC>(); + + string Path = AppDomain.CurrentDomain.BaseDirectory + "AccessFile\\DeviceConfig\\PLCVars.csv"; + + private void init() + { + DataTable dt = ExcelHelper.ReadDataFromCSV(Path); + DataRowCollection dr = dt.Rows; + for (int i = 0; i < 28; i++) + { + OutPosionPLCs.Add(new CommationPosionPLC(dr[i][0].ToString(), dr[i][2].ToString(), (MaterialPosion)i+1)); + } + for(int i = 28; i <34;i++) + { + TurnPosionPLCs.Add(new CommationPosionPLC(dr[i][0].ToString(), dr[i][2].ToString(), (OutMaterialPosion)i - 27)); + } + + } + + public PolymerBatching() + { + init(); + } } } diff --git a/BPASmartClient.MorkTSingle/Control_MORKJC.cs b/BPASmartClient.MorkTSingle/Control_MORKJC.cs index 4bb1a4a2..0cbc33c3 100644 --- a/BPASmartClient.MorkTSingle/Control_MORKJC.cs +++ b/BPASmartClient.MorkTSingle/Control_MORKJC.cs @@ -238,7 +238,7 @@ namespace BPASmartClient.MorkTSingle bFirstTrig_Coffee = false; morkT.MakeCoffeeFinish = true; }); - if (morkT.MakeCoffeeFinish != true && morkT.MakeCoffeeFinish == false) + if (morkT.MakeCoffeeFinish != true) { if (!bFirstTrig_Coffee) { diff --git a/BPASmartClient.MorkTSingle/OrderLocInfo.cs b/BPASmartClient.MorkTSingle/OrderLocInfo.cs index d09bfe0a..5d1de5ef 100644 --- a/BPASmartClient.MorkTSingle/OrderLocInfo.cs +++ b/BPASmartClient.MorkTSingle/OrderLocInfo.cs @@ -4,16 +4,16 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BPASmartClient.MorkTM +namespace BPASmartClient.MorkTSingle { public class OrderLocInfo { - public string SuborderId { get; set; } + public ushort Loc { get; set; } public ushort RecipeNumber { get; set; } + public int BatchingId { get; set; } public string GoodName { get; set; } - - public Dictionary GoodPushes { get; set; } + public string makeID { get; set; } } diff --git a/BPASmartClient.MorkT_Container/Control_MorkT_Container.cs b/BPASmartClient.MorkT_Container/Control_MorkT_Container.cs index 3cbf1a00..86ff65e4 100644 --- a/BPASmartClient.MorkT_Container/Control_MorkT_Container.cs +++ b/BPASmartClient.MorkT_Container/Control_MorkT_Container.cs @@ -186,73 +186,84 @@ namespace BPASmartClient.MorkT_Container DateTime delayTimeOut_Juice; public override void MainTask() { - EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) - { - if (morkTLebaiJC.IsHaveCoffeeCup && morkTLebaiJC.MakeCoffeeEnd != true) - morkTLebaiJC.MakeCoffeeEnd = true; - }); - if (morkTLebaiJC.IsHaveCoffeeCup && morkTLebaiJC.MakeCoffeeEnd != true) - { - if (!bFirstTrig_Coffee) + if (morkTLebaiJC.morkOrderPushesCoffee.Count > 0 && morkTLebaiJC.IsHaveCoffeeCup) + { + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) { - bFirstTrig_Coffee = true; - delayTimeOut_Coffee = DateTime.Now; - } - else if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 180 && bFirstTrig_Coffee == true) - { - DeviceProcessLogShow("接咖啡超时,接咖啡结束,等待取咖啡"); - bFirstTrig_Coffee = false; - if (morkTLebaiJC.IsHaveCoffeeCup) + if (morkTLebaiJC.IsHaveCoffeeCup && morkTLebaiJC.MakeCoffeeEnd != true) + { morkTLebaiJC.MakeCoffeeEnd = true; + bFirstTrig_Coffee = false; + } + }); + if (morkTLebaiJC.IsHaveCoffeeCup && morkTLebaiJC.MakeCoffeeEnd != true) + { + if (!bFirstTrig_Coffee) + { + bFirstTrig_Coffee = true; + delayTimeOut_Coffee = DateTime.Now; + } + else if (DateTime.Now.Subtract(delayTimeOut_Coffee).TotalSeconds > 180 && bFirstTrig_Coffee == true) + { + DeviceProcessLogShow("接咖啡超时,接咖啡结束,等待取咖啡"); + bFirstTrig_Coffee = false; + if (morkTLebaiJC.IsHaveCoffeeCup) + morkTLebaiJC.MakeCoffeeEnd = true; + } } } - - if (morkTLebaiJC.IsHaveJuiceCup && morkTLebaiJC.MakeJuiceEnd != true) + if (morkTLebaiJC.morkOrderPushesJuicer.Count > 0 && morkTLebaiJC.IsHaveJuiceCup) { - var Juicestate = GetStatus("GetDeviceStatus"); - if (Juicestate != null) + if (morkTLebaiJC.IsHaveJuiceCup && morkTLebaiJC.MakeJuiceEnd != true) { - if (Juicestate.Length > 0) + var Juicestate = GetStatus("GetDeviceStatus"); + if (Juicestate != null) { - var Juicestate1 = Convert.ToString(Juicestate[0], 2); - var Juicestate2 = Juicestate[1]; - if (Juicestate1.IndexOf("0") == 1 && Juicestate2 == 0) + if (Juicestate.Length > 0) { - morkTLebaiJC.MakeJuiceEnd = true; + var Juicestate1 = Convert.ToString(Juicestate[0], 2); + var Juicestate2 = Juicestate[1]; + if (Juicestate1.IndexOf("0") == 1 && Juicestate2 == 0) + { + morkTLebaiJC.MakeJuiceEnd = true; + bFirstTrig_Juice = false; + } + } + } + if (!morkTLebaiJC.MakeJuiceEnd) + { + //若无状态返回 则加延迟 + if (!bFirstTrig_Juice) + { + bFirstTrig_Juice = true; + delayTimeOut_Juice = DateTime.Now; + } + else if (DateTime.Now.Subtract(delayTimeOut_Juice).TotalSeconds > 15 && bFirstTrig_Juice == true) + { + DeviceProcessLogShow("接果汁超时,接果汁结束,等待取果汁"); bFirstTrig_Juice = false; + morkTLebaiJC.MakeJuiceEnd = true; } } } - if (!morkTLebaiJC.MakeJuiceEnd) + } + if ((morkTLebaiJC.morkOrderPushesTea.Count > 0 || morkTLebaiJC.morkOrderPushesWater.Count > 0) && morkTLebaiJC.IsHaveTeaWaterCup) + { + if (morkTLebaiJC.IsHaveTeaWaterCup && morkTLebaiJC.MakeTeaEnd != true) { - //若无状态返回 则加延迟 - if (!bFirstTrig_Juice) + if (!bFirstTrig_TeaWater) { - bFirstTrig_Juice = true; - delayTimeOut_Juice = DateTime.Now; + bFirstTrig_TeaWater = true; + delayTimeOut_Water = DateTime.Now;//开启接水信号后,记录当前时间 } - else if (DateTime.Now.Subtract(delayTimeOut_Juice).TotalSeconds > 15 && bFirstTrig_Juice == true) + else if (DateTime.Now.Subtract(delayTimeOut_Water).TotalSeconds >= 50 && bFirstTrig_TeaWater == true)//接水超过50s后,启动接水完成标志,开启接水程序 { - DeviceProcessLogShow("接果汁超时,接果汁结束,等待取果汁"); - bFirstTrig_Juice = false; - morkTLebaiJC.MakeJuiceEnd = true; + DeviceProcessLogShow("接茶或水延迟时间结束"); + bFirstTrig_TeaWater = false; + morkTLebaiJC.MakeTeaEnd = true; } } } - if (morkTLebaiJC.IsHaveTeaWaterCup && morkTLebaiJC.MakeTeaEnd != true) - { - if (!bFirstTrig_TeaWater) - { - bFirstTrig_TeaWater = true; - delayTimeOut_Water = DateTime.Now;//开启接水信号后,记录当前时间 - } - else if (DateTime.Now.Subtract(delayTimeOut_Water).TotalSeconds >= 50 && bFirstTrig_TeaWater == true)//接水超过50s后,启动接水完成标志,开启接水程序 - { - DeviceProcessLogShow("接茶或水延迟时间结束"); - bFirstTrig_TeaWater = false; - morkTLebaiJC.MakeTeaEnd = true; - } - } DoCoffee(); DoJuice(); DoBoiledTea(); diff --git a/BPASmartClient.SerialPort/SerialPortClient.cs b/BPASmartClient.SerialPort/SerialPortClient.cs index b966aab9..633c3372 100644 --- a/BPASmartClient.SerialPort/SerialPortClient.cs +++ b/BPASmartClient.SerialPort/SerialPortClient.cs @@ -154,7 +154,7 @@ namespace BPASmartClient.SerialPort { if (!IsHavePort) { - MessageLog.GetInstance.Show($"{portName}连接失败"); + //MessageLog.GetInstance.Show("咖乐美咖啡机连接失败"); return; } if (comPort.IsOpen) comPort.Close(); @@ -164,7 +164,7 @@ namespace BPASmartClient.SerialPort comPort.DataBits = (int)dataBits; comPort.StopBits = stopBits; comPort.Open(); - MessageLog.GetInstance.Show($"{portName}连接成功"); + //MessageLog.GetInstance.Show("咖乐美咖啡机连接成功"); } } diff --git a/BPASmartClient/App.config b/BPASmartClient/App.config index 013b8327..c29e4b30 100644 --- a/BPASmartClient/App.config +++ b/BPASmartClient/App.config @@ -6,17 +6,17 @@ - - - + - + diff --git a/BPASmartClient/BPASmartClient.csproj b/BPASmartClient/BPASmartClient.csproj index 4cec962c..a942c4cd 100644 --- a/BPASmartClient/BPASmartClient.csproj +++ b/BPASmartClient/BPASmartClient.csproj @@ -35,6 +35,7 @@ + diff --git a/SmartClient.sln b/SmartClient.sln index b465601b..5cd109b1 100644 --- a/SmartClient.sln +++ b/SmartClient.sln @@ -96,8 +96,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTHQ", "B EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.DosingSystem", "DosingSystem\BPASmartClient.DosingSystem.csproj", "{4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJuicer", "BPASmartClient.MorkTJuicer\BPASmartClient.MorkTJuicer.csproj", "{724087A3-E7E7-4494-B844-414FF5CD1D40}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.AGV", "BPASmartClient.AGV\BPASmartClient.AGV.csproj", "{507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.IceMaker", "BPASmartClient.IceMaker\BPASmartClient.IceMaker.csproj", "{F61AC179-156D-4075-BFEB-355862231F48}" @@ -120,6 +118,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTSingle" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MilkWithTea", "BPASmartClient.MilkWithTea\BPASmartClient.MilkWithTea.csproj", "{BFA4E222-BBCC-4AC7-9EA4-4549AEF3174B}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectricCurrentTestDemo", "..\..\TEST\ElectricCurrentTestDemo\ElectricCurrentTestDemo.csproj", "{75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.KHKJ", "BPASmartClient.KHKJ\BPASmartClient.KHKJ.csproj", "{C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.Nfc", "BPASmartClient.Nfc\BPASmartClient.Nfc.csproj", "{42D35B7C-764C-4692-AA85-9B343A0F5B7F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.Argox", "BPASmartClient.Argox\BPASmartClient.Argox.csproj", "{B8D499BA-A18A-4FD6-B036-44F02B4D164B}" @@ -898,26 +900,6 @@ Global {4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|x64.Build.0 = Release|Any CPU {4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|x86.ActiveCfg = Release|Any CPU {4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB}.Release|x86.Build.0 = Release|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|Any CPU.Build.0 = Debug|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|ARM.ActiveCfg = Debug|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|ARM.Build.0 = Debug|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|ARM64.Build.0 = Debug|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|x64.ActiveCfg = Debug|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|x64.Build.0 = Debug|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|x86.ActiveCfg = Debug|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Debug|x86.Build.0 = Debug|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|Any CPU.ActiveCfg = Release|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|Any CPU.Build.0 = Release|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|ARM.ActiveCfg = Release|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|ARM.Build.0 = Release|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|ARM64.ActiveCfg = Release|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|ARM64.Build.0 = Release|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|x64.ActiveCfg = Release|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|x64.Build.0 = Release|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|x86.ActiveCfg = Release|Any CPU - {724087A3-E7E7-4494-B844-414FF5CD1D40}.Release|x86.Build.0 = Release|Any CPU {507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Debug|Any CPU.Build.0 = Debug|Any CPU {507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -1138,6 +1120,46 @@ Global {BFA4E222-BBCC-4AC7-9EA4-4549AEF3174B}.Release|x64.Build.0 = Release|Any CPU {BFA4E222-BBCC-4AC7-9EA4-4549AEF3174B}.Release|x86.ActiveCfg = Release|Any CPU {BFA4E222-BBCC-4AC7-9EA4-4549AEF3174B}.Release|x86.Build.0 = Release|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Debug|Any CPU.Build.0 = Debug|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Debug|ARM.ActiveCfg = Debug|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Debug|ARM.Build.0 = Debug|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Debug|ARM64.Build.0 = Debug|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Debug|x64.ActiveCfg = Debug|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Debug|x64.Build.0 = Debug|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Debug|x86.ActiveCfg = Debug|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Debug|x86.Build.0 = Debug|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Release|Any CPU.ActiveCfg = Release|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Release|Any CPU.Build.0 = Release|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Release|ARM.ActiveCfg = Release|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Release|ARM.Build.0 = Release|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Release|ARM64.ActiveCfg = Release|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Release|ARM64.Build.0 = Release|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Release|x64.ActiveCfg = Release|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Release|x64.Build.0 = Release|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Release|x86.ActiveCfg = Release|Any CPU + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44}.Release|x86.Build.0 = Release|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Debug|ARM.ActiveCfg = Debug|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Debug|ARM.Build.0 = Debug|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Debug|ARM64.Build.0 = Debug|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Debug|x64.ActiveCfg = Debug|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Debug|x64.Build.0 = Debug|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Debug|x86.ActiveCfg = Debug|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Debug|x86.Build.0 = Debug|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Release|Any CPU.Build.0 = Release|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Release|ARM.ActiveCfg = Release|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Release|ARM.Build.0 = Release|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Release|ARM64.ActiveCfg = Release|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Release|ARM64.Build.0 = Release|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Release|x64.ActiveCfg = Release|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Release|x64.Build.0 = Release|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Release|x86.ActiveCfg = Release|Any CPU + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B}.Release|x86.Build.0 = Release|Any CPU {42D35B7C-764C-4692-AA85-9B343A0F5B7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {42D35B7C-764C-4692-AA85-9B343A0F5B7F}.Debug|Any CPU.Build.0 = Debug|Any CPU {42D35B7C-764C-4692-AA85-9B343A0F5B7F}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -1221,7 +1243,6 @@ Global {C28A88B1-E449-484C-AC67-B5038FF2CA79} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} {00C17D87-A323-4A97-BC21-7039E55614DE} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} {4E0B01AD-CFD0-4BD5-BBE6-AD2A4183B4DB} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} - {724087A3-E7E7-4494-B844-414FF5CD1D40} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} {507A30E2-246E-4AC9-82F4-BE8FBBC1C5B8} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} {F61AC179-156D-4075-BFEB-355862231F48} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} {048FED78-4BFA-4FCD-8FF2-905E9CA4D7DD} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} @@ -1233,6 +1254,8 @@ Global {099E047C-F40E-47A3-A5BA-81FC1500D5E8} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} {2366AC9B-B662-4550-9486-AF848B4D2961} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} {BFA4E222-BBCC-4AC7-9EA4-4549AEF3174B} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} + {75B55300-ABC3-4CA1-B9B6-DF954E6C7B44} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} + {C0060FB3-7AEA-4D14-ADCE-DB78D3665D5B} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} {42D35B7C-764C-4692-AA85-9B343A0F5B7F} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} {B8D499BA-A18A-4FD6-B036-44F02B4D164B} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} EndGlobalSection